Skip to content

Commit 480a7e1

Browse files
authored
Merge branch 'master' into fix-3699-help-generate-print-blueprints
2 parents 3a41061 + 916e9bd commit 480a7e1

File tree

13 files changed

+195
-126
lines changed

13 files changed

+195
-126
lines changed

.travis.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ matrix:
2020
- node_js: "6"
2121
os: linux
2222
env: SCRIPT=build
23-
- node_js: "4"
24-
os: linux
25-
env: NODE_SCRIPT=tests/run_e2e.js
2623
- node_js: "6"
2724
os: linux
2825
env: SCRIPT=test

packages/angular-cli/bin/ng

Lines changed: 39 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@
44
// Provide a title to the process in `ps`
55
process.title = 'angular-cli';
66

7-
const resolve = require('resolve');
8-
const packageJson = require('../package.json');
7+
const CliConfig = require('../models/config').CliConfig;
98
const Version = require('../upgrade/version').Version;
10-
const yellow = require('chalk').yellow;
11-
const SemVer = require('semver').SemVer;
9+
1210
const fs = require('fs');
11+
const packageJson = require('../package.json');
1312
const path = require('path');
13+
const resolve = require('resolve');
14+
const stripIndents = require('common-tags').stripIndents;
15+
const yellow = require('chalk').yellow;
16+
const SemVer = require('semver').SemVer;
1417

1518

1619
function _fromPackageJson(cwd) {
@@ -59,6 +62,31 @@ if (process.env['NG_CLI_PROFILING']) {
5962
}
6063

6164

65+
// Show the warnings due to package and version deprecation.
66+
const version = new SemVer(process.version);
67+
if (version.compare(new SemVer('6.9.0')) < 0
68+
&& CliConfig.fromGlobal().get('warnings.nodeDeprecation')) {
69+
process.stderr.write(yellow(stripIndents`
70+
You are running version ${version.version} of Node, which will not be supported in future
71+
versions of the CLI. The official Node version that will be supported is 6.9 and greater.
72+
73+
To disable this warning use "ng set --global warnings.nodeDeprecation=false".
74+
`));
75+
}
76+
77+
78+
if (require('../package.json')['name'] == 'angular-cli'
79+
&& CliConfig.fromGlobal().get('warnings.packageDeprecation')) {
80+
process.stderr.write(yellow(stripIndents`
81+
As a forewarning, we are moving the CLI npm package to "@angular/cli" with the next release,
82+
which will only support Node 6.9 and greater. This package will be officially deprecated
83+
shortly after.
84+
85+
To disable this warning use "ng set --global warnings.packageDeprecation=false".
86+
`));
87+
}
88+
89+
6290
resolve('angular-cli', { basedir: process.cwd() },
6391
function (error, projectLocalCli) {
6492
var cli;
@@ -85,10 +113,14 @@ resolve('angular-cli', { basedir: process.cwd() },
85113
shouldWarn = true;
86114
}
87115

88-
if (shouldWarn) {
116+
if (shouldWarn && CliConfig.fromGlobal().get('warnings.versionMismatch')) {
89117
// eslint-disable no-console
90-
console.log(yellow(`Your global Angular CLI version (${globalVersion}) is greater than `
91-
+ `your local version (${localVersion}). The local Angular CLI version is used.`));
118+
console.log(yellow(stripIndents`
119+
Your global Angular CLI version (${globalVersion}) is greater than your local
120+
version (${localVersion}). The local Angular CLI version is used.
121+
122+
To disable this warning use "ng set --global warnings.versionMismatch=false".
123+
`));
92124
}
93125

94126
// No error implies a projectLocalCli, which will load whatever

packages/angular-cli/blueprints/class/index.js renamed to packages/angular-cli/blueprints/class/index.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@ const dynamicPathParser = require('../../utilities/dynamic-path-parser');
33
const Blueprint = require('../../ember-cli/lib/models/blueprint');
44
const getFiles = Blueprint.prototype.files;
55

6-
module.exports = {
6+
export default Blueprint.extend({
77
description: '',
88

99
availableOptions: [
1010
{ name: 'spec', type: Boolean }
1111
],
1212

13-
normalizeEntityName: function (entityName) {
14-
var parsedPath = dynamicPathParser(this.project, entityName.split('.')[0]);
13+
normalizeEntityName: function (entityName: string) {
14+
const parsedPath = dynamicPathParser(this.project, entityName.split('.')[0]);
1515

1616
this.dynamicPath = parsedPath;
1717
return parsedPath.name;
1818
},
1919

20-
locals: function (options) {
21-
const rawName = options.args[1];
20+
locals: function (options: any) {
21+
const rawName = options.args[1] as string;
2222
const nameParts = rawName.split('.')
2323
.filter(part => part.length !== 0);
2424

@@ -40,7 +40,7 @@ module.exports = {
4040
},
4141

4242
files: function() {
43-
var fileList = getFiles.call(this);
43+
let fileList = getFiles.call(this) as Array<string>;
4444

4545
if (this.options && !this.options.spec) {
4646
fileList = fileList.filter(p => p.indexOf('__name__.spec.ts') < 0);
@@ -61,4 +61,4 @@ module.exports = {
6161
}
6262
};
6363
}
64-
};
64+
});

packages/angular-cli/blueprints/component/index.js renamed to packages/angular-cli/blueprints/component/index.ts

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const stringUtils = require('ember-cli-string-utils');
99
const astUtils = require('../../utilities/ast-utils');
1010
const NodeHost = require('@angular-cli/ast-tools').NodeHost;
1111

12-
module.exports = {
12+
export default Blueprint.extend({
1313
description: '',
1414

1515
availableOptions: [
@@ -25,7 +25,7 @@ module.exports = {
2525
{ name: 'export', type: Boolean, default: false }
2626
],
2727

28-
beforeInstall: function(options) {
28+
beforeInstall: function(options: any) {
2929
if (options.module) {
3030
// Resolve path to module
3131
const modulePath = options.module.endsWith('.ts') ? options.module : `${options.module}.ts`;
@@ -38,27 +38,28 @@ module.exports = {
3838
} else {
3939
try {
4040
this.pathToModule = findParentModule(this.project, this.dynamicPath.dir);
41-
} catch(e) {
41+
} catch (e) {
4242
if (!options.skipImport) {
4343
throw `Error locating module for declaration\n\t${e}`;
4444
}
4545
}
4646
}
4747
},
4848

49-
normalizeEntityName: function (entityName) {
50-
var parsedPath = dynamicPathParser(this.project, entityName);
49+
normalizeEntityName: function (entityName: string) {
50+
const parsedPath = dynamicPathParser(this.project, entityName);
5151

5252
this.dynamicPath = parsedPath;
5353

54-
var defaultPrefix = '';
54+
let defaultPrefix = '';
5555
if (this.project.ngConfig &&
5656
this.project.ngConfig.apps[0] &&
5757
this.project.ngConfig.apps[0].prefix) {
5858
defaultPrefix = this.project.ngConfig.apps[0].prefix;
5959
}
6060

61-
var prefix = (this.options.prefix === 'false' || this.options.prefix === '') ? '' : (this.options.prefix || defaultPrefix);
61+
let prefix = (this.options.prefix === 'false' || this.options.prefix === '')
62+
? '' : (this.options.prefix || defaultPrefix);
6263
prefix = prefix && `${prefix}-`;
6364

6465
this.selector = stringUtils.dasherize(prefix + parsedPath.name);
@@ -70,7 +71,7 @@ module.exports = {
7071
return parsedPath.name;
7172
},
7273

73-
locals: function (options) {
74+
locals: function (options: any) {
7475
this.styleExt = 'css';
7576
if (this.project.ngConfig &&
7677
this.project.ngConfig.defaults &&
@@ -114,7 +115,7 @@ module.exports = {
114115
},
115116

116117
files: function() {
117-
var fileList = getFiles.call(this);
118+
let fileList = getFiles.call(this) as Array<string>;
118119

119120
if (this.options && this.options.inlineTemplate) {
120121
fileList = fileList.filter(p => p.indexOf('.html') < 0);
@@ -129,15 +130,15 @@ module.exports = {
129130
return fileList;
130131
},
131132

132-
fileMapTokens: function (options) {
133+
fileMapTokens: function (options: any) {
133134
// Return custom template variables here.
134135
return {
135136
__path__: () => {
136-
var dir = this.dynamicPath.dir;
137+
let dir = this.dynamicPath.dir;
137138
if (!options.locals.flat) {
138139
dir += path.sep + options.dasherizedModuleName;
139140
}
140-
var srcDir = this.project.ngConfig.apps[0].root;
141+
const srcDir = this.project.ngConfig.apps[0].root;
141142
this.appDir = dir.substr(dir.indexOf(srcDir) + srcDir.length);
142143
this.generatePath = dir;
143144
return dir;
@@ -148,12 +149,12 @@ module.exports = {
148149
};
149150
},
150151

151-
afterInstall: function(options) {
152+
afterInstall: function(options: any) {
152153
if (options.dryRun) {
153154
return;
154155
}
155156

156-
const returns = [];
157+
const returns: Array<any> = [];
157158
const className = stringUtils.classify(`${options.entity.name}Component`);
158159
const fileName = stringUtils.dasherize(`${options.entity.name}.component`);
159160
const componentDir = path.relative(path.dirname(this.pathToModule), this.generatePath);
@@ -162,17 +163,19 @@ module.exports = {
162163
if (!options.skipImport) {
163164
returns.push(
164165
astUtils.addDeclarationToModule(this.pathToModule, className, importPath)
165-
.then(change => change.apply(NodeHost))
166-
.then((result) => {
166+
.then((change: any) => change.apply(NodeHost))
167+
.then((result: any) => {
167168
if (options.export) {
168169
return astUtils.addExportToModule(this.pathToModule, className, importPath)
169-
.then(change => change.apply(NodeHost));
170+
.then((change: any) => change.apply(NodeHost));
170171
}
171172
return result;
172173
}));
173-
this._writeStatusToUI(chalk.yellow, 'update', path.relative(this.project.root, this.pathToModule));
174+
this._writeStatusToUI(chalk.yellow,
175+
'update',
176+
path.relative(this.project.root, this.pathToModule));
174177
}
175178

176179
return Promise.all(returns);
177180
}
178-
};
181+
});

packages/angular-cli/blueprints/directive/index.js renamed to packages/angular-cli/blueprints/directive/index.ts

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const NodeHost = require('@angular-cli/ast-tools').NodeHost;
99
const Blueprint = require('../../ember-cli/lib/models/blueprint');
1010
const getFiles = Blueprint.prototype.files;
1111

12-
module.exports = {
12+
export default Blueprint.extend({
1313
description: '',
1414

1515
availableOptions: [
@@ -21,7 +21,7 @@ module.exports = {
2121
{ name: 'export', type: Boolean, default: false }
2222
],
2323

24-
beforeInstall: function(options) {
24+
beforeInstall: function(options: any) {
2525
if (options.module) {
2626
// Resolve path to module
2727
const modulePath = options.module.endsWith('.ts') ? options.module : `${options.module}.ts`;
@@ -34,35 +34,36 @@ module.exports = {
3434
} else {
3535
try {
3636
this.pathToModule = findParentModule(this.project, this.dynamicPath.dir);
37-
} catch(e) {
37+
} catch (e) {
3838
if (!options.skipImport) {
3939
throw `Error locating module for declaration\n\t${e}`;
4040
}
4141
}
4242
}
4343
},
4444

45-
normalizeEntityName: function (entityName) {
46-
var parsedPath = dynamicPathParser(this.project, entityName);
45+
normalizeEntityName: function (entityName: string) {
46+
const parsedPath = dynamicPathParser(this.project, entityName);
4747

4848
this.dynamicPath = parsedPath;
4949

50-
var defaultPrefix = '';
50+
let defaultPrefix = '';
5151
if (this.project.ngConfig &&
5252
this.project.ngConfig.apps[0] &&
5353
this.project.ngConfig.apps[0].prefix) {
5454
defaultPrefix = this.project.ngConfig.apps[0].prefix;
5555
}
5656

57-
var prefix = (this.options.prefix === 'false' || this.options.prefix === '') ? '' : (this.options.prefix || defaultPrefix);
57+
let prefix = (this.options.prefix === 'false' || this.options.prefix === '')
58+
? '' : (this.options.prefix || defaultPrefix);
5859
prefix = prefix && `${prefix}-`;
5960

6061

6162
this.selector = stringUtils.camelize(prefix + parsedPath.name);
6263
return parsedPath.name;
6364
},
6465

65-
locals: function (options) {
66+
locals: function (options: any) {
6667
options.spec = options.spec !== undefined ?
6768
options.spec :
6869
this.project.ngConfigObj.get('defaults.spec.directive');
@@ -75,7 +76,7 @@ module.exports = {
7576
},
7677

7778
files: function() {
78-
var fileList = getFiles.call(this);
79+
let fileList = getFiles.call(this) as Array<string>;
7980

8081
if (this.options && !this.options.spec) {
8182
fileList = fileList.filter(p => p.indexOf('__name__.directive.spec.ts') < 0);
@@ -84,11 +85,11 @@ module.exports = {
8485
return fileList;
8586
},
8687

87-
fileMapTokens: function (options) {
88+
fileMapTokens: function (options: any) {
8889
// Return custom template variables here.
8990
return {
9091
__path__: () => {
91-
var dir = this.dynamicPath.dir;
92+
let dir = this.dynamicPath.dir;
9293
if (!options.locals.flat) {
9394
dir += path.sep + options.dasherizedModuleName;
9495
}
@@ -98,12 +99,12 @@ module.exports = {
9899
};
99100
},
100101

101-
afterInstall: function(options) {
102+
afterInstall: function(options: any) {
102103
if (options.dryRun) {
103104
return;
104105
}
105106

106-
const returns = [];
107+
const returns: Array<any> = [];
107108
const className = stringUtils.classify(`${options.entity.name}Directive`);
108109
const fileName = stringUtils.dasherize(`${options.entity.name}.directive`);
109110
const fullGeneratePath = path.join(this.project.root, this.generatePath);
@@ -114,17 +115,19 @@ module.exports = {
114115
if (!options.skipImport) {
115116
returns.push(
116117
astUtils.addDeclarationToModule(this.pathToModule, className, importPath)
117-
.then(change => change.apply(NodeHost))
118-
.then((result) => {
118+
.then((change: any) => change.apply(NodeHost))
119+
.then((result: any) => {
119120
if (options.export) {
120121
return astUtils.addExportToModule(this.pathToModule, className, importPath)
121-
.then(change => change.apply(NodeHost));
122+
.then((change: any) => change.apply(NodeHost));
122123
}
123124
return result;
124125
}));
125-
this._writeStatusToUI(chalk.yellow, 'update', path.relative(this.project.root, this.pathToModule));
126+
this._writeStatusToUI(chalk.yellow,
127+
'update',
128+
path.relative(this.project.root, this.pathToModule));
126129
}
127130

128131
return Promise.all(returns);
129132
}
130-
};
133+
});

0 commit comments

Comments
 (0)