Skip to content

Commit 7d5cf37

Browse files
authored
Merge pull request #6 from angular/master
chore: merge September 11th 2016
2 parents a6274e3 + ba668a8 commit 7d5cf37

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+1335
-841
lines changed

.appveyor.yml

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ environment:
33
- nodejs_version: "5.0"
44
- nodejs_version: "6.0"
55

6+
matrix:
7+
fast_finish: true
8+
69
install:
710
- ps: Install-Product node $env:nodejs_version
811
- npm install
@@ -11,5 +14,6 @@ test_script:
1114
- node --version
1215
- npm --version
1316
- npm test
17+
- npm run test:e2e
1418

1519
build: off

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
dist/
22
node_modules/
3-
npm-debug.log
3+
npm-debug.log*
44

55
# IDEs
66
.idea/
77
jsconfig.json
8+
.vscode/
89

910
# Typings file.
1011
typings/

.travis.yml

+7
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,22 @@ env:
1313
matrix:
1414
- SCRIPT=lint
1515
# - SCRIPT=build
16+
- SCRIPT=e2e
17+
- SCRIPT=e2e:nightly
1618
- SCRIPT=test
1719
# - TARGET=mobile SCRIPT=mobile_test
1820
matrix:
1921
fast_finish: true
2022
allow_failures:
2123
- os: osx
24+
- env: SCRIPT=e2e:nightly
2225
exclude:
2326
- node_js: "6"
2427
env: SCRIPT=lint
28+
- os: osx
29+
env: SCRIPT=e2e:nightly
30+
- node_js: "6"
31+
env: SCRIPT=e2e:nightly
2532
- os: osx
2633
node_js: "5"
2734
env: SCRIPT=lint

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ Navigate to `http://localhost:4200/`. The app will automatically reload if you c
7878
You can configure the default HTTP port and the one used by the LiveReload server with two command-line options :
7979

8080
```bash
81-
ng serve --port 4201 --live-reload-port 49153
81+
ng serve --host 0.0.0.0 --port 4201 --live-reload-port 49153
8282
```
8383

8484
### Generating Components, Directives, Pipes and Services

WEBPACK_UPDATE.md

-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ rm -rf node_modules dist tmp typings
1616
npm install --save-dev angular-cli@webpack
1717
```
1818

19-
IMPORTANT NOTE:
20-
Currently project generated with `ng new` will use a wrong local CLI version (see https://github.com/angular/angular-cli/issues/1528). After initializing your project, run `npm install --save-dev angular-cli@webpack` to set the correct version.
21-
2219
## Project files
2320

2421
You will need to run `ng init` to check for changes in all the auto-generated files created by `ng new` and allow you to update yours. You are offered four choices for each changed file: `y` (overwrite), `n` (don't overwrite), `d` (show diff between your file and the updated file) and `h` (help).

addon/ng2/blueprints/component/index.js

+11-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ var path = require('path');
22
var chalk = require('chalk');
33
var Blueprint = require('ember-cli/lib/models/blueprint');
44
var dynamicPathParser = require('../../utilities/dynamic-path-parser');
5+
const findParentModule = require('../../utilities/find-parent-module').default;
56
var getFiles = Blueprint.prototype.files;
67
const stringUtils = require('ember-cli-string-utils');
78
const astUtils = require('../../utilities/ast-utils');
@@ -17,6 +18,14 @@ module.exports = {
1718
{ name: 'spec', type: Boolean, default: true }
1819
],
1920

21+
beforeInstall: function() {
22+
try {
23+
this.pathToModule = findParentModule(this.project, this.dynamicPath.dir);
24+
} catch(e) {
25+
throw `Error locating module for declaration\n\t${e}`;
26+
}
27+
},
28+
2029
normalizeEntityName: function (entityName) {
2130
var parsedPath = dynamicPathParser(this.project, entityName);
2231

@@ -100,15 +109,14 @@ module.exports = {
100109
}
101110

102111
const returns = [];
103-
const modulePath = path.join(this.project.root, this.dynamicPath.appRoot, 'app.module.ts');
104112
const className = stringUtils.classify(`${options.entity.name}Component`);
105113
const fileName = stringUtils.dasherize(`${options.entity.name}.component`);
106-
const componentDir = path.relative(this.dynamicPath.appRoot, this.generatePath);
114+
const componentDir = path.relative(path.dirname(this.pathToModule), this.generatePath);
107115
const importPath = componentDir ? `./${componentDir}/${fileName}` : `./${fileName}`;
108116

109117
if (!options['skip-import']) {
110118
returns.push(
111-
astUtils.addComponentToModule(modulePath, className, importPath)
119+
astUtils.addDeclarationToModule(this.pathToModule, className, importPath)
112120
.then(change => change.apply()));
113121
}
114122

addon/ng2/blueprints/directive/index.js

+11-3
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ var path = require('path');
22
var dynamicPathParser = require('../../utilities/dynamic-path-parser');
33
const stringUtils = require('ember-cli-string-utils');
44
const astUtils = require('../../utilities/ast-utils');
5+
const findParentModule = require('../../utilities/find-parent-module').default;
56

67
module.exports = {
78
description: '',
@@ -11,11 +12,19 @@ module.exports = {
1112
{ name: 'prefix', type: Boolean, default: true }
1213
],
1314

15+
beforeInstall: function() {
16+
try {
17+
this.pathToModule = findParentModule(this.project, this.dynamicPath.dir);
18+
} catch(e) {
19+
throw `Error locating module for declaration\n\t${e}`;
20+
}
21+
},
22+
1423
normalizeEntityName: function (entityName) {
1524
var parsedPath = dynamicPathParser(this.project, entityName);
1625

1726
this.dynamicPath = parsedPath;
18-
27+
1928
var defaultPrefix = '';
2029
if (this.project.ngConfig &&
2130
this.project.ngConfig.apps[0] &&
@@ -56,15 +65,14 @@ module.exports = {
5665
}
5766

5867
const returns = [];
59-
const modulePath = path.join(this.project.root, this.dynamicPath.appRoot, 'app.module.ts');
6068
const className = stringUtils.classify(`${options.entity.name}Directive`);
6169
const fileName = stringUtils.dasherize(`${options.entity.name}.directive`);
6270
const componentDir = path.relative(this.dynamicPath.appRoot, this.generatePath);
6371
const importPath = componentDir ? `./${componentDir}/${fileName}` : `./${fileName}`;
6472

6573
if (!options['skip-import']) {
6674
returns.push(
67-
astUtils.addComponentToModule(modulePath, className, importPath)
75+
astUtils.addDeclarationToModule(this.pathToModule, className, importPath)
6876
.then(change => change.apply()));
6977
}
7078

Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
import { NgModule } from '@angular/core';
2-
import { CommonModule } from '@angular/common';
3-
import { routing } from './<%= dasherizedModuleName %>.routes';
4-
import { <%= classifiedModuleName %>Component } from './<%= dasherizedModuleName %>.component';
2+
import { CommonModule } from '@angular/common';<% if (routing) { %>
3+
import { <%= camelizedModuleName %>Routing } from './<%= dasherizedModuleName %>.routing';<% } %>
54

65
@NgModule({
76
imports: [
8-
CommonModule,
9-
routing
7+
CommonModule<% if (routing) { %>,
8+
<%= camelizedModuleName %>Routing<% } %>
109
],
11-
declarations: [
12-
<%= classifiedModuleName %>Component
13-
]
10+
declarations: []
1411
})
1512
export class <%= classifiedModuleName %>Module { }
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import { Routes, RouterModule } from '@angular/router';
2+
3+
export const <%= camelizedModuleName %>Routes: Routes = [];
4+
5+
export const <%= camelizedModuleName %>Routing = RouterModule.forChild(<%= camelizedModuleName %>˝Routes);
6+

addon/ng2/blueprints/module/index.js

+13-8
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ module.exports = {
77
description: '',
88

99
availableOptions: [
10-
{ name: 'spec', type: Boolean, default: false }
10+
{ name: 'spec', type: Boolean, default: false },
11+
{ name: 'routing', type: Boolean, default: false }
1112
],
12-
13+
1314
normalizeEntityName: function (entityName) {
1415
this.entityName = entityName;
1516
var parsedPath = dynamicPathParser(this.project, entityName);
@@ -19,9 +20,10 @@ module.exports = {
1920
},
2021

2122
locals: function (options) {
22-
return {
23+
return {
2324
dynamicPath: this.dynamicPath.dir,
24-
spec: options.spec
25+
spec: options.spec,
26+
routing: options.routing
2527
};
2628
},
2729

@@ -31,6 +33,9 @@ module.exports = {
3133
if (!this.options || !this.options.spec) {
3234
fileList = fileList.filter(p => p.indexOf('__name__.module.spec.ts') < 0);
3335
}
36+
if (this.options && !this.options.routing) {
37+
fileList = fileList.filter(p => p.indexOf('__name__.routing.ts') < 0);
38+
}
3439

3540
return fileList;
3641
},
@@ -40,17 +45,17 @@ module.exports = {
4045
this.dasherizedModuleName = options.dasherizedModuleName;
4146
return {
4247
__path__: () => {
43-
this.generatePath = this.dynamicPath.dir
44-
+ path.sep
48+
this.generatePath = this.dynamicPath.dir
49+
+ path.sep
4550
+ options.dasherizedModuleName;
4651
return this.generatePath;
4752
}
4853
};
4954
},
5055

5156
afterInstall: function (options) {
52-
options.entity.name = this.entityName;
53-
options.flat = false;
57+
options.entity.name = path.join(this.entityName, this.dasherizedModuleName);
58+
options.flat = true;
5459
options.route = false;
5560
options.inlineTemplate = false;
5661
options.inlineStyle = false;

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,6 @@
4646
"protractor": "4.0.3",
4747
"ts-node": "1.2.1",
4848
"tslint": "3.13.0",
49-
"typescript": "2.0.0"
49+
"typescript": "2.0.2"
5050
}
5151
}

addon/ng2/blueprints/ng2/index.js

+2-3
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ module.exports = {
2121

2222
locals: function(options) {
2323
this.styleExt = options.style;
24-
this.version = require(path.resolve(__dirname, '..', '..', '..', '..', 'package.json')).version;
24+
this.version = require(path.resolve(__dirname, '../../../../package.json')).version;
2525

2626
// Join with / not path.sep as reference to typings require forward slashes.
2727
const relativeRootPath = options.sourceDir.split(path.sep).map(() => '..').join('/');
@@ -44,12 +44,11 @@ module.exports = {
4444

4545
files: function() {
4646
var fileList = getFiles.call(this);
47-
4847
if (this.options && this.options.mobile) {
4948
fileList = fileList.filter(p => p.indexOf('__name__.component.html') < 0);
5049
fileList = fileList.filter(p => p.indexOf('__name__.component.__styleext__') < 0);
5150
}
52-
51+
5352
return fileList;
5453
},
5554

addon/ng2/blueprints/pipe/index.js

+13-5
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,23 @@ var path = require('path');
22
var dynamicPathParser = require('../../utilities/dynamic-path-parser');
33
const stringUtils = require('ember-cli-string-utils');
44
const astUtils = require('../../utilities/ast-utils');
5+
const findParentModule = require('../../utilities/find-parent-module').default;
56

67
module.exports = {
78
description: '',
8-
9+
910
availableOptions: [
1011
{ name: 'flat', type: Boolean, default: true }
1112
],
1213

14+
beforeInstall: function() {
15+
try {
16+
this.pathToModule = findParentModule(this.project, this.dynamicPath.dir);
17+
} catch(e) {
18+
throw `Error locating module for declaration\n\t${e}`;
19+
}
20+
},
21+
1322
normalizeEntityName: function (entityName) {
1423
var parsedPath = dynamicPathParser(this.project, entityName);
1524

@@ -18,7 +27,7 @@ module.exports = {
1827
},
1928

2029
locals: function (options) {
21-
return {
30+
return {
2231
dynamicPath: this.dynamicPath.dir,
2332
flat: options.flat
2433
};
@@ -37,22 +46,21 @@ module.exports = {
3746
}
3847
};
3948
},
40-
49+
4150
afterInstall: function(options) {
4251
if (options.dryRun) {
4352
return;
4453
}
4554

4655
const returns = [];
47-
const modulePath = path.join(this.project.root, this.dynamicPath.appRoot, 'app.module.ts');
4856
const className = stringUtils.classify(`${options.entity.name}Pipe`);
4957
const fileName = stringUtils.dasherize(`${options.entity.name}.pipe`);
5058
const componentDir = path.relative(this.dynamicPath.appRoot, this.generatePath);
5159
const importPath = componentDir ? `./${componentDir}/${fileName}` : `./${fileName}`;
5260

5361
if (!options['skip-import']) {
5462
returns.push(
55-
astUtils.addComponentToModule(modulePath, className, importPath)
63+
astUtils.addDeclarationToModule(this.pathToModule, className, importPath)
5664
.then(change => change.apply()));
5765
}
5866

addon/ng2/blueprints/service/index.js

+6
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
var path = require('path');
2+
const chalk = require('chalk');
23
var dynamicPathParser = require('../../utilities/dynamic-path-parser');
34

45
module.exports = {
@@ -34,5 +35,10 @@ module.exports = {
3435
return dir;
3536
}
3637
};
38+
},
39+
40+
afterInstall() {
41+
const warningMessage = 'Service is generated but not provided, it must be provided to be used';
42+
this._writeStatusToUI(chalk.yellow, 'WARNING', warningMessage);
3743
}
3844
};

0 commit comments

Comments
 (0)