Skip to content

Commit

Permalink
feat(angular-cli): Add a postinstall warning for Node 4 deprecation. (a…
Browse files Browse the repository at this point in the history
…ngular#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.
  • Loading branch information
hansl authored and MRHarrison committed Feb 9, 2017
1 parent a39ac0e commit d22d7bb
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 10 deletions.
3 changes: 0 additions & 3 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,6 @@ matrix:
- node_js: "6"
os: linux
env: SCRIPT=build
- node_js: "4"
os: linux
env: NODE_SCRIPT=tests/run_e2e.js
- node_js: "6"
os: linux
env: SCRIPT=test
Expand Down
46 changes: 39 additions & 7 deletions packages/angular-cli/bin/ng
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,16 @@
// Provide a title to the process in `ps`
process.title = 'angular-cli';

const resolve = require('resolve');
const packageJson = require('../package.json');
const CliConfig = require('../models/config').CliConfig;
const Version = require('../upgrade/version').Version;
const yellow = require('chalk').yellow;
const SemVer = require('semver').SemVer;

const fs = require('fs');
const packageJson = require('../package.json');
const path = require('path');
const resolve = require('resolve');
const stripIndents = require('common-tags').stripIndents;
const yellow = require('chalk').yellow;
const SemVer = require('semver').SemVer;


function _fromPackageJson(cwd) {
Expand Down Expand Up @@ -59,6 +62,31 @@ if (process.env['NG_CLI_PROFILING']) {
}


// Show the warnings due to package and version deprecation.
const version = new SemVer(process.version);
if (version.compare(new SemVer('6.9.0')) < 0
&& CliConfig.fromGlobal().get('warnings.nodeDeprecation')) {
process.stderr.write(yellow(stripIndents`
You are running version ${version.version} of Node, which will not be supported in future
versions of the CLI. The official Node version that will be supported is 6.9 and greater.
To disable this warning use "ng set --global warnings.nodeDeprecation=false".
`));
}


if (require('../package.json')['name'] == 'angular-cli'
&& CliConfig.fromGlobal().get('warnings.packageDeprecation')) {
process.stderr.write(yellow(stripIndents`
As a forewarning, we are moving the CLI npm package to "@angular/cli" with the next release,
which will only support Node 6.9 and greater. This package will be officially deprecated
shortly after.
To disable this warning use "ng set --global warnings.packageDeprecation=false".
`));
}


resolve('angular-cli', { basedir: process.cwd() },
function (error, projectLocalCli) {
var cli;
Expand All @@ -85,10 +113,14 @@ resolve('angular-cli', { basedir: process.cwd() },
shouldWarn = true;
}

if (shouldWarn) {
if (shouldWarn && CliConfig.fromGlobal().get('warnings.versionMismatch')) {
// eslint-disable no-console
console.log(yellow(`Your global Angular CLI version (${globalVersion}) is greater than `
+ `your local version (${localVersion}). The local Angular CLI version is used.`));
console.log(yellow(stripIndents`
Your global Angular CLI version (${globalVersion}) is greater than your local
version (${localVersion}). The local Angular CLI version is used.
To disable this warning use "ng set --global warnings.versionMismatch=false".
`));
}

// No error implies a projectLocalCli, which will load whatever
Expand Down
21 changes: 21 additions & 0 deletions packages/angular-cli/lib/config/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,27 @@
}
},
"additionalProperties": false
},
"warnings": {
"description": "Allow people to disable console warnings.",
"type": "object",
"properties": {
"nodeDeprecation": {
"description": "Show a warning when the node version is incompatible.",
"type": "boolean",
"default": true
},
"packageDeprecation": {
"description": "Show a warning when the user installed angular-cli.",
"type": "boolean",
"default": true
},
"versionMismatch": {
"description": "Show a warning when the global version is newer than the local one.",
"type": "boolean",
"default": true
}
}
}
},
"additionalProperties": false
Expand Down

0 comments on commit d22d7bb

Please sign in to comment.