diff --git a/packages/angular-cli/bin/ng b/packages/angular-cli/bin/ng index 1f5e6d68983c..e55b5f28e0b2 100755 --- a/packages/angular-cli/bin/ng +++ b/packages/angular-cli/bin/ng @@ -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) { @@ -59,6 +62,37 @@ 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` + We detected that you are using Node v${version.version}. Unfortunately, this version will not + be officially supported when the Angular CLI is released. The official Node version that will + be supported is 6.9 and greater. This beta release (Beta.27) will be the last release to + support Node 4. + + This is to ensure that we can provide our users with better support for the upcoming releases. + Many of our dependencies are moving to deprecating Node 4 already and that would mean that we + could not update them to the latest versions which might have bug fixes and new useful features. + + 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; @@ -85,10 +119,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 diff --git a/packages/angular-cli/lib/config/schema.json b/packages/angular-cli/lib/config/schema.json index 69fdccaef764..927ee789ef34 100644 --- a/packages/angular-cli/lib/config/schema.json +++ b/packages/angular-cli/lib/config/schema.json @@ -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 diff --git a/packages/angular-cli/package.json b/packages/angular-cli/package.json index 8253a4c88761..5d100755b3be 100644 --- a/packages/angular-cli/package.json +++ b/packages/angular-cli/package.json @@ -19,6 +19,9 @@ "node": ">= 4.1.0", "npm": ">= 3.0.0" }, + "scripts": { + "postinstall": "node ./scripts/install.js" + }, "author": "Angular Authors", "license": "MIT", "bugs": {