Skip to content

Commit 1a29a2e

Browse files
committed
feat(angular-cli): Add a postinstall warning for Node 4 deprecation.
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 3e03c97 commit 1a29a2e

File tree

2 files changed

+66
-7
lines changed

2 files changed

+66
-7
lines changed

packages/angular-cli/bin/ng

Lines changed: 45 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,37 @@ 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+
We detected that you are using Node v${version.version}. Unfortunately, this version will not
71+
be officially supported when the Angular CLI is released. The official Node version that will
72+
be supported is 6.9 and greater. This beta release (Beta.27) will be the last release to
73+
support Node 4.
74+
75+
This is to ensure that we can provide our users with better support for the upcoming releases.
76+
Many of our dependencies are moving to deprecating Node 4 already and that would mean that we
77+
could not update them to the latest versions which might have bug fixes and new useful features.
78+
79+
To disable this warning use "ng set --global warnings.nodeDeprecation=false".
80+
`));
81+
}
82+
83+
84+
if (require('../package.json')['name'] == 'angular-cli'
85+
&& CliConfig.fromGlobal().get('warnings.packageDeprecation')) {
86+
process.stderr.write(yellow(stripIndents`
87+
As a forewarning, We are moving the CLI npm package to "@angular/cli" with the next release,
88+
which will only support Node 6.9 and greater. This package will be officially deprecated
89+
shortly after.
90+
91+
To disable this warning use "ng set --global warnings.packageDeprecation=false".
92+
`));
93+
}
94+
95+
6296
resolve('angular-cli', { basedir: process.cwd() },
6397
function (error, projectLocalCli) {
6498
var cli;
@@ -85,10 +119,14 @@ resolve('angular-cli', { basedir: process.cwd() },
85119
shouldWarn = true;
86120
}
87121

88-
if (shouldWarn) {
122+
if (shouldWarn && CliConfig.fromGlobal().get('warnings.versionMismatch')) {
89123
// 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.`));
124+
console.log(yellow(stripIndents`
125+
Your global Angular CLI version (${globalVersion}) is greater than your local
126+
version (${localVersion}). The local Angular CLI version is used.
127+
128+
To disable this warning use "ng set --global warnings.versionMismatch=false".
129+
`));
92130
}
93131

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

packages/angular-cli/lib/config/schema.json

Lines changed: 21 additions & 0 deletions
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)