Skip to content

Commit

Permalink
Merge branch 'master' into Issue-1889-fix-completion-command-invalid
Browse files Browse the repository at this point in the history
  • Loading branch information
goorockey authored Sep 3, 2016
2 parents 589e276 + 440d767 commit 52f9edc
Show file tree
Hide file tree
Showing 21 changed files with 133 additions and 105 deletions.
14 changes: 0 additions & 14 deletions addon/ng2/blueprints/component/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ module.exports = {

availableOptions: [
{ name: 'flat', type: Boolean, default: false },
{ name: 'route', type: Boolean, default: false },
{ name: 'inline-template', type: Boolean, default: false, aliases: ['it'] },
{ name: 'inline-style', type: Boolean, default: false, aliases: ['is'] },
{ name: 'prefix', type: Boolean, default: true },
Expand Down Expand Up @@ -54,7 +53,6 @@ module.exports = {
inlineTemplate: options.inlineTemplate,
inlineStyle: options.inlineStyle,
route: options.route,
isLazyRoute: !!options.isLazyRoute,
isAppComponent: !!options.isAppComponent,
selector: this.selector,
styleExt: this.styleExt
Expand Down Expand Up @@ -84,18 +82,6 @@ module.exports = {
var dir = this.dynamicPath.dir;
if (!options.locals.flat) {
dir += path.sep + options.dasherizedModuleName;

if (options.locals.isLazyRoute) {
var lazyRoutePrefix = '+';
if (this.project.ngConfig &&
this.project.ngConfig.defaults &&
this.project.ngConfig.defaults.lazyRoutePrefix !== undefined) {
lazyRoutePrefix = this.project.ngConfig.defaults.lazyRoutePrefix;
}
var dirParts = dir.split(path.sep);
dirParts[dirParts.length - 1] = `${lazyRoutePrefix}${dirParts[dirParts.length - 1]}`;
dir = dirParts.join(path.sep);
}
}
var srcDir = this.project.ngConfig.apps[0].root;
this.appDir = dir.substr(dir.indexOf(srcDir) + srcDir.length);
Expand Down
2 changes: 1 addition & 1 deletion addon/ng2/blueprints/ng2/files/__path__/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import "./polyfills.ts";
import './polyfills.ts';

import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { enableProdMode } from '@angular/core';
Expand Down
3 changes: 1 addition & 2 deletions addon/ng2/blueprints/ng2/files/angular-cli.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@
},
"defaults": {
"styleExt": "<%= styleExt %>",
"prefixInterfaces": false,
"lazyRoutePrefix": "+"
"prefixInterfaces": false
}
}
2 changes: 1 addition & 1 deletion addon/ng2/blueprints/ng2/files/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@
"protractor": "4.0.3",
"ts-node": "1.2.1",
"tslint": "3.13.0",
"typescript": "^2.0.0"
"typescript": "2.0.0"
}
}
8 changes: 4 additions & 4 deletions addon/ng2/commands/init.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ const InitCommand: any = Command.extend({

// needs an explicit check in case it's just 'undefined'
// due to passing of options from 'new' and 'addon'
let gitInit;
let gitInit: any;
if (commandOptions.skipGit === false) {
gitInit = new GitInit({
ui: this.ui,
project: this.project
});
}

let linkCli;
let linkCli: any;
if (commandOptions.linkCli) {
linkCli = new LinkCli({
ui: this.ui,
Expand All @@ -72,7 +72,7 @@ const InitCommand: any = Command.extend({
});
}

let npmInstall;
let npmInstall: any;
if (!commandOptions.skipNpm) {
npmInstall = new NpmInstall({
ui: this.ui,
Expand All @@ -81,7 +81,7 @@ const InitCommand: any = Command.extend({
});
}

let bowerInstall;
let bowerInstall: any;
if (!commandOptions.skipBower) {
bowerInstall = new this.tasks.BowerInstall({
ui: this.ui,
Expand Down
4 changes: 1 addition & 3 deletions addon/ng2/models/webpack-build-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ const HtmlWebpackPlugin = require('html-webpack-plugin');
import * as webpack from 'webpack';
const atl = require('awesome-typescript-loader');

import { BaseHrefWebpackPlugin } from '@angular-cli/base-href-webpack';
import { findLazyModules } from './find-lazy-modules';


import { BaseHrefWebpackPlugin } from '../utilities/base-href-webpack-plugin';


export function getWebpackCommonConfig(
projectRoot: string,
environment: string,
Expand Down
1 change: 0 additions & 1 deletion addon/ng2/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"name": "ng2",
"version": "0.0.0",
"description": "An addon to generate an ng2 project",
"author": "rodyhaddad",
"license": "MIT",
"keywords": [
"ember-addon"
Expand Down
1 change: 1 addition & 0 deletions addon/ng2/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"baseUrl": "",
"paths": {
"@angular-cli/ast-tools": [ "../../packages/ast-tools/src" ],
"@angular-cli/base-href-webpack": [ "../../packages/base-href-webpack/src" ],
"@angular-cli/webpack": [ "../../packages/webpack/src" ]
}
},
Expand Down
1 change: 0 additions & 1 deletion lib/config/schema.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,5 @@ export interface CliConfig {
defaults?: {
styleExt?: string;
prefixInterfaces?: boolean;
lazyRoutePrefix?: string;
};
}
3 changes: 0 additions & 3 deletions lib/config/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,6 @@
},
"prefixInterfaces": {
"type": "boolean"
},
"lazyRoutePrefix": {
"type": "string"
}
},
"additionalProperties": false
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@
"ts-loader": "^0.8.2",
"tslint-loader": "^2.1.4",
"typedoc": "^0.4.2",
"typescript": "^2.0.0",
"typescript": "2.0.0",
"url-loader": "^0.5.7",
"webpack": "2.1.0-beta.21",
"webpack-dev-server": "2.1.0-beta.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/ast-tools/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "@angular-cli/ast-tools",
"version": "1.0.0-beta.11-webpack.5",
"description": "CLI tool for Angular",
"main": "./index.js",
"main": "./src/index.js",
"keywords": [
"angular",
"cli",
Expand All @@ -22,6 +22,6 @@
"dependencies": {
"rxjs": "^5.0.0-beta.11",
"denodeify": "^1.2.1",
"typescript": "^2.0.0"
"typescript": "2.0.0"
}
}
25 changes: 25 additions & 0 deletions packages/base-href-webpack/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"name": "@angular-cli/base-href-webpack",
"version": "1.0.0",
"description": "Base HREF Webpack plugin",
"main": "./src/index.js",
"keywords": [
"angular",
"cli",
"webpack",
"plugin",
"tool"
],
"repository": {
"type": "git",
"url": "https://github.com/angular/angular-cli.git"
},
"author": "angular",
"license": "MIT",
"bugs": {
"url": "https://github.com/angular/angular-cli/issues"
},
"homepage": "https://github.com/angular/angular-cli",
"dependencies": {
}
}
66 changes: 66 additions & 0 deletions packages/base-href-webpack/src/base-href-webpack-plugin.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import {oneLineTrim} from 'common-tags';
import {BaseHrefWebpackPlugin} from './base-href-webpack-plugin';


function mockCompiler(indexHtml, callback) {
return {
plugin: function (event, compilerCallback) {
const compilation = {
plugin: function (hook, compilationCallback) {
const htmlPluginData = {
html: indexHtml
};
compilationCallback(htmlPluginData, callback);
}
};
compilerCallback(compilation);
}
};
}

describe('base href webpack plugin', () => {
const html = oneLineTrim`
<html>
<head></head>
<body></body>
</html>
`;

it('should do nothing when baseHref is null', () => {
const plugin = new BaseHrefWebpackPlugin({ baseHref: null });

const compiler = mockCompiler(html, (x, htmlPluginData) => {
expect(htmlPluginData.html).toEqual('<body><head></head></body>');
});
plugin.apply(compiler);
});

it('should insert base tag when not exist', function () {
const plugin = new BaseHrefWebpackPlugin({ baseHref: '/' });
const compiler = mockCompiler(html, (x, htmlPluginData) => {
expect(htmlPluginData.html).toEqual(oneLineTrim`
<html>
<head><base href="/"></head>
<body></body>
</html>
`);
});

plugin.apply(compiler);
});

it('should replace href attribute when base tag already exists', function () {
const plugin = new BaseHrefWebpackPlugin({ baseHref: '/myUrl/' });

const compiler = mockCompiler(oneLineTrim`
<head><base href="/" target="_blank"></head>
<body></body>
`, (x, htmlPluginData) => {
expect(htmlPluginData.html).toEqual(oneLineTrim`
<head><base href="/myUrl/" target="_blank"></head>
<body></body>
`);
});
plugin.apply(compiler);
});
});
2 changes: 2 additions & 0 deletions packages/base-href-webpack/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

export * from './base-href-webpack-plugin';
24 changes: 24 additions & 0 deletions packages/base-href-webpack/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"compilerOptions": {
"declaration": true,
"experimentalDecorators": true,
"mapRoot": "",
"module": "commonjs",
"moduleResolution": "node",
"noEmitOnError": true,
"noImplicitAny": true,
"outDir": "../../dist/base-href-webpack",
"rootDir": ".",
"sourceMap": true,
"sourceRoot": "/",
"target": "es5",
"lib": ["es6"],
"typeRoots": [
"../../node_modules/@types"
],
"types": [
"jasmine",
"node"
]
}
}
4 changes: 1 addition & 3 deletions scripts/run-packages-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ const projectBaseDir = path.join(__dirname, '../packages');

// Create a Jasmine runner and configure it.
const jasmine = new Jasmine({ projectBaseDir: projectBaseDir });
jasmine.loadConfig({
spec_dir: projectBaseDir
});
jasmine.loadConfig({});
jasmine.addReporter(new JasmineSpecReporter());

// Run the tests.
Expand Down
50 changes: 0 additions & 50 deletions tests/acceptance/base-href-webpack-plugin.spec.js

This file was deleted.

21 changes: 2 additions & 19 deletions tests/acceptance/generate-route.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@ const root = process.cwd();

const testPath = path.join(root, 'tmp', 'foo', 'src', 'app');

function fileExpectations(lazy, expectation) {
const lazyPrefix = lazy ? '+' : '';
const dir = `${lazyPrefix}my-route`;
function fileExpectations(expectation) {
const dir = 'my-route';
expect(existsSync(path.join(testPath, dir, 'my-route.component.ts'))).to.equal(expectation);
}

Expand Down Expand Up @@ -43,12 +42,6 @@ xdescribe('Acceptance: ng generate route', function () {
});
});

it('ng generate route my-route --lazy false', function () {
return ng(['generate', 'route', 'my-route', '--lazy', 'false']).then(() => {
fileExpectations(false, true);
});
});

it('ng generate route +my-route', function () {
return ng(['generate', 'route', '+my-route']).then(() => {
fileExpectations(true, true);
Expand Down Expand Up @@ -102,14 +95,4 @@ xdescribe('Acceptance: ng generate route', function () {
expect(afterGenerateParentHtml).to.equal(unmodifiedParentComponentHtml);
});
});

it('lazy route prefix', () => {
return ng(['set', 'defaults.lazyRoutePrefix', 'myprefix'])
.then(() => ng(['generate', 'route', 'prefix-test']))
.then(() => {
var folderPath = path.join(testPath, 'myprefixprefix-test', 'prefix-test.component.ts');
expect(existsSync(folderPath))
.to.equal(true);
});
});
});
1 change: 1 addition & 0 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
],
"paths": {
"@angular-cli/ast-tools": [ "./packages/ast-tools/src" ],
"@angular-cli/base-href-webpack": [ "./packages/base-href-webpack/src" ],
"@angular-cli/webpack": [ "./packages/webpack/src" ]
}
},
Expand Down

0 comments on commit 52f9edc

Please sign in to comment.