Skip to content

Commit 52f9edc

Browse files
authored
Merge branch 'master' into Issue-1889-fix-completion-command-invalid
2 parents 589e276 + 440d767 commit 52f9edc

21 files changed

+133
-105
lines changed

addon/ng2/blueprints/component/index.js

-14
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ module.exports = {
1111

1212
availableOptions: [
1313
{ name: 'flat', type: Boolean, default: false },
14-
{ name: 'route', type: Boolean, default: false },
1514
{ name: 'inline-template', type: Boolean, default: false, aliases: ['it'] },
1615
{ name: 'inline-style', type: Boolean, default: false, aliases: ['is'] },
1716
{ name: 'prefix', type: Boolean, default: true },
@@ -54,7 +53,6 @@ module.exports = {
5453
inlineTemplate: options.inlineTemplate,
5554
inlineStyle: options.inlineStyle,
5655
route: options.route,
57-
isLazyRoute: !!options.isLazyRoute,
5856
isAppComponent: !!options.isAppComponent,
5957
selector: this.selector,
6058
styleExt: this.styleExt
@@ -84,18 +82,6 @@ module.exports = {
8482
var dir = this.dynamicPath.dir;
8583
if (!options.locals.flat) {
8684
dir += path.sep + options.dasherizedModuleName;
87-
88-
if (options.locals.isLazyRoute) {
89-
var lazyRoutePrefix = '+';
90-
if (this.project.ngConfig &&
91-
this.project.ngConfig.defaults &&
92-
this.project.ngConfig.defaults.lazyRoutePrefix !== undefined) {
93-
lazyRoutePrefix = this.project.ngConfig.defaults.lazyRoutePrefix;
94-
}
95-
var dirParts = dir.split(path.sep);
96-
dirParts[dirParts.length - 1] = `${lazyRoutePrefix}${dirParts[dirParts.length - 1]}`;
97-
dir = dirParts.join(path.sep);
98-
}
9985
}
10086
var srcDir = this.project.ngConfig.apps[0].root;
10187
this.appDir = dir.substr(dir.indexOf(srcDir) + srcDir.length);

addon/ng2/blueprints/ng2/files/__path__/main.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import "./polyfills.ts";
1+
import './polyfills.ts';
22

33
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
44
import { enableProdMode } from '@angular/core';

addon/ng2/blueprints/ng2/files/angular-cli.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@
3939
},
4040
"defaults": {
4141
"styleExt": "<%= styleExt %>",
42-
"prefixInterfaces": false,
43-
"lazyRoutePrefix": "+"
42+
"prefixInterfaces": false
4443
}
4544
}

addon/ng2/blueprints/ng2/files/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,6 @@
4545
"protractor": "4.0.3",
4646
"ts-node": "1.2.1",
4747
"tslint": "3.13.0",
48-
"typescript": "^2.0.0"
48+
"typescript": "2.0.0"
4949
}
5050
}

addon/ng2/commands/init.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -55,15 +55,15 @@ const InitCommand: any = Command.extend({
5555

5656
// needs an explicit check in case it's just 'undefined'
5757
// due to passing of options from 'new' and 'addon'
58-
let gitInit;
58+
let gitInit: any;
5959
if (commandOptions.skipGit === false) {
6060
gitInit = new GitInit({
6161
ui: this.ui,
6262
project: this.project
6363
});
6464
}
6565

66-
let linkCli;
66+
let linkCli: any;
6767
if (commandOptions.linkCli) {
6868
linkCli = new LinkCli({
6969
ui: this.ui,
@@ -72,7 +72,7 @@ const InitCommand: any = Command.extend({
7272
});
7373
}
7474

75-
let npmInstall;
75+
let npmInstall: any;
7676
if (!commandOptions.skipNpm) {
7777
npmInstall = new NpmInstall({
7878
ui: this.ui,
@@ -81,7 +81,7 @@ const InitCommand: any = Command.extend({
8181
});
8282
}
8383

84-
let bowerInstall;
84+
let bowerInstall: any;
8585
if (!commandOptions.skipBower) {
8686
bowerInstall = new this.tasks.BowerInstall({
8787
ui: this.ui,

addon/ng2/models/webpack-build-common.ts

+1-3
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,10 @@ const HtmlWebpackPlugin = require('html-webpack-plugin');
44
import * as webpack from 'webpack';
55
const atl = require('awesome-typescript-loader');
66

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

910

10-
import { BaseHrefWebpackPlugin } from '../utilities/base-href-webpack-plugin';
11-
12-
1311
export function getWebpackCommonConfig(
1412
projectRoot: string,
1513
environment: string,

addon/ng2/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
"name": "ng2",
33
"version": "0.0.0",
44
"description": "An addon to generate an ng2 project",
5-
"author": "rodyhaddad",
65
"license": "MIT",
76
"keywords": [
87
"ember-addon"

addon/ng2/tsconfig.json

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"baseUrl": "",
2121
"paths": {
2222
"@angular-cli/ast-tools": [ "../../packages/ast-tools/src" ],
23+
"@angular-cli/base-href-webpack": [ "../../packages/base-href-webpack/src" ],
2324
"@angular-cli/webpack": [ "../../packages/webpack/src" ]
2425
}
2526
},

lib/config/schema.d.ts

-1
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,5 @@ export interface CliConfig {
5959
defaults?: {
6060
styleExt?: string;
6161
prefixInterfaces?: boolean;
62-
lazyRoutePrefix?: string;
6362
};
6463
}

lib/config/schema.json

-3
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,6 @@
135135
},
136136
"prefixInterfaces": {
137137
"type": "boolean"
138-
},
139-
"lazyRoutePrefix": {
140-
"type": "string"
141138
}
142139
},
143140
"additionalProperties": false

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
"ts-loader": "^0.8.2",
103103
"tslint-loader": "^2.1.4",
104104
"typedoc": "^0.4.2",
105-
"typescript": "^2.0.0",
105+
"typescript": "2.0.0",
106106
"url-loader": "^0.5.7",
107107
"webpack": "2.1.0-beta.21",
108108
"webpack-dev-server": "2.1.0-beta.0",

packages/ast-tools/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@angular-cli/ast-tools",
33
"version": "1.0.0-beta.11-webpack.5",
44
"description": "CLI tool for Angular",
5-
"main": "./index.js",
5+
"main": "./src/index.js",
66
"keywords": [
77
"angular",
88
"cli",
@@ -22,6 +22,6 @@
2222
"dependencies": {
2323
"rxjs": "^5.0.0-beta.11",
2424
"denodeify": "^1.2.1",
25-
"typescript": "^2.0.0"
25+
"typescript": "2.0.0"
2626
}
2727
}
+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "@angular-cli/base-href-webpack",
3+
"version": "1.0.0",
4+
"description": "Base HREF Webpack plugin",
5+
"main": "./src/index.js",
6+
"keywords": [
7+
"angular",
8+
"cli",
9+
"webpack",
10+
"plugin",
11+
"tool"
12+
],
13+
"repository": {
14+
"type": "git",
15+
"url": "https://github.com/angular/angular-cli.git"
16+
},
17+
"author": "angular",
18+
"license": "MIT",
19+
"bugs": {
20+
"url": "https://github.com/angular/angular-cli/issues"
21+
},
22+
"homepage": "https://github.com/angular/angular-cli",
23+
"dependencies": {
24+
}
25+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
import {oneLineTrim} from 'common-tags';
2+
import {BaseHrefWebpackPlugin} from './base-href-webpack-plugin';
3+
4+
5+
function mockCompiler(indexHtml, callback) {
6+
return {
7+
plugin: function (event, compilerCallback) {
8+
const compilation = {
9+
plugin: function (hook, compilationCallback) {
10+
const htmlPluginData = {
11+
html: indexHtml
12+
};
13+
compilationCallback(htmlPluginData, callback);
14+
}
15+
};
16+
compilerCallback(compilation);
17+
}
18+
};
19+
}
20+
21+
describe('base href webpack plugin', () => {
22+
const html = oneLineTrim`
23+
<html>
24+
<head></head>
25+
<body></body>
26+
</html>
27+
`;
28+
29+
it('should do nothing when baseHref is null', () => {
30+
const plugin = new BaseHrefWebpackPlugin({ baseHref: null });
31+
32+
const compiler = mockCompiler(html, (x, htmlPluginData) => {
33+
expect(htmlPluginData.html).toEqual('<body><head></head></body>');
34+
});
35+
plugin.apply(compiler);
36+
});
37+
38+
it('should insert base tag when not exist', function () {
39+
const plugin = new BaseHrefWebpackPlugin({ baseHref: '/' });
40+
const compiler = mockCompiler(html, (x, htmlPluginData) => {
41+
expect(htmlPluginData.html).toEqual(oneLineTrim`
42+
<html>
43+
<head><base href="/"></head>
44+
<body></body>
45+
</html>
46+
`);
47+
});
48+
49+
plugin.apply(compiler);
50+
});
51+
52+
it('should replace href attribute when base tag already exists', function () {
53+
const plugin = new BaseHrefWebpackPlugin({ baseHref: '/myUrl/' });
54+
55+
const compiler = mockCompiler(oneLineTrim`
56+
<head><base href="/" target="_blank"></head>
57+
<body></body>
58+
`, (x, htmlPluginData) => {
59+
expect(htmlPluginData.html).toEqual(oneLineTrim`
60+
<head><base href="/myUrl/" target="_blank"></head>
61+
<body></body>
62+
`);
63+
});
64+
plugin.apply(compiler);
65+
});
66+
});
+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
2+
export * from './base-href-webpack-plugin';
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
{
2+
"compilerOptions": {
3+
"declaration": true,
4+
"experimentalDecorators": true,
5+
"mapRoot": "",
6+
"module": "commonjs",
7+
"moduleResolution": "node",
8+
"noEmitOnError": true,
9+
"noImplicitAny": true,
10+
"outDir": "../../dist/base-href-webpack",
11+
"rootDir": ".",
12+
"sourceMap": true,
13+
"sourceRoot": "/",
14+
"target": "es5",
15+
"lib": ["es6"],
16+
"typeRoots": [
17+
"../../node_modules/@types"
18+
],
19+
"types": [
20+
"jasmine",
21+
"node"
22+
]
23+
}
24+
}

scripts/run-packages-spec.js

+1-3
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,7 @@ const projectBaseDir = path.join(__dirname, '../packages');
1111

1212
// Create a Jasmine runner and configure it.
1313
const jasmine = new Jasmine({ projectBaseDir: projectBaseDir });
14-
jasmine.loadConfig({
15-
spec_dir: projectBaseDir
16-
});
14+
jasmine.loadConfig({});
1715
jasmine.addReporter(new JasmineSpecReporter());
1816

1917
// Run the tests.

tests/acceptance/base-href-webpack-plugin.spec.js

-50
This file was deleted.

tests/acceptance/generate-route.spec.js

+2-19
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@ const root = process.cwd();
1212

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

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

@@ -43,12 +42,6 @@ xdescribe('Acceptance: ng generate route', function () {
4342
});
4443
});
4544

46-
it('ng generate route my-route --lazy false', function () {
47-
return ng(['generate', 'route', 'my-route', '--lazy', 'false']).then(() => {
48-
fileExpectations(false, true);
49-
});
50-
});
51-
5245
it('ng generate route +my-route', function () {
5346
return ng(['generate', 'route', '+my-route']).then(() => {
5447
fileExpectations(true, true);
@@ -102,14 +95,4 @@ xdescribe('Acceptance: ng generate route', function () {
10295
expect(afterGenerateParentHtml).to.equal(unmodifiedParentComponentHtml);
10396
});
10497
});
105-
106-
it('lazy route prefix', () => {
107-
return ng(['set', 'defaults.lazyRoutePrefix', 'myprefix'])
108-
.then(() => ng(['generate', 'route', 'prefix-test']))
109-
.then(() => {
110-
var folderPath = path.join(testPath, 'myprefixprefix-test', 'prefix-test.component.ts');
111-
expect(existsSync(folderPath))
112-
.to.equal(true);
113-
});
114-
});
11598
});

tsconfig.json

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
],
2323
"paths": {
2424
"@angular-cli/ast-tools": [ "./packages/ast-tools/src" ],
25+
"@angular-cli/base-href-webpack": [ "./packages/base-href-webpack/src" ],
2526
"@angular-cli/webpack": [ "./packages/webpack/src" ]
2627
}
2728
},

0 commit comments

Comments
 (0)