Skip to content

Commit 916e9bd

Browse files
authored
feat(angular-cli): Add a postinstall warning for Node 4 deprecation. (angular#4309)
BREAKING CHANGE: Node < 6.9 will be deprecated soon, and this will show a warning to users. Moving forward, that warning will be moved to an error with the next release.
1 parent ba89125 commit 916e9bd

File tree

3 files changed

+60
-10
lines changed

3 files changed

+60
-10
lines changed

.travis.yml

-3
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

+39-7
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/lib/config/schema.json

+21
Original file line numberDiff line numberDiff line change
@@ -292,6 +292,27 @@
292292
}
293293
},
294294
"additionalProperties": false
295+
},
296+
"warnings": {
297+
"description": "Allow people to disable console warnings.",
298+
"type": "object",
299+
"properties": {
300+
"nodeDeprecation": {
301+
"description": "Show a warning when the node version is incompatible.",
302+
"type": "boolean",
303+
"default": true
304+
},
305+
"packageDeprecation": {
306+
"description": "Show a warning when the user installed angular-cli.",
307+
"type": "boolean",
308+
"default": true
309+
},
310+
"versionMismatch": {
311+
"description": "Show a warning when the global version is newer than the local one.",
312+
"type": "boolean",
313+
"default": true
314+
}
315+
}
295316
}
296317
},
297318
"additionalProperties": false

0 commit comments

Comments
 (0)