build: improve the environmental check and warnings
- we now correctly print errors even on old Node versions - we print error messages even when node_modules are missing or messed up - error messages looks better Closes #5230
This commit is contained in:
parent
1417e12f28
commit
7f783289ab
@ -1,5 +1,11 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
|
// THIS CHECK SHOULD BE THE FIRST THING IN THIS FILE
|
||||||
|
// This is to ensure that we catch env issues before we error while requiring other dependencies.
|
||||||
|
require('./tools/check-environment')(
|
||||||
|
{requiredNpmVersion: '>=2.14.7 <3.0.0', requiredNodeVersion: '>=4.2.1 <5.0.0'});
|
||||||
|
|
||||||
|
|
||||||
var del = require('del');
|
var del = require('del');
|
||||||
var gulp = require('gulp');
|
var gulp = require('gulp');
|
||||||
var gulpPlugins = require('gulp-load-plugins')();
|
var gulpPlugins = require('gulp-load-plugins')();
|
||||||
@ -26,8 +32,6 @@ var dartSdk = require('./tools/build/dart');
|
|||||||
var browserProvidersConf = require('./browser-providers.conf.js');
|
var browserProvidersConf = require('./browser-providers.conf.js');
|
||||||
|
|
||||||
|
|
||||||
require('./tools/check-environment')(
|
|
||||||
{requiredNpmVersion: '>=2.14.7', requiredNodeVersion: '>=4.2.1'});
|
|
||||||
|
|
||||||
var cliArgs = minimist(process.argv.slice(2));
|
var cliArgs = minimist(process.argv.slice(2));
|
||||||
|
|
||||||
|
@ -1,7 +1,42 @@
|
|||||||
var exec = require('child_process').exec;
|
/* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||||
var semver = require('semver');
|
!!! !!!
|
||||||
|
!!! This file is special in that it must be able to execute with wrong Node version !!!
|
||||||
|
!!! or even when node_modules are missing. !!!
|
||||||
|
!!! !!!
|
||||||
|
!!! Do not depend on Node4+ features or presence of npm packages here. !!!
|
||||||
|
!!! !!!
|
||||||
|
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! */
|
||||||
|
|
||||||
var checkNodeModules = require('./npm/check-node-modules.js');
|
'use strict';
|
||||||
|
|
||||||
|
var exec = require('child_process').exec;
|
||||||
|
var checkNodeModules;
|
||||||
|
var semver;
|
||||||
|
|
||||||
|
|
||||||
|
var issues = [];
|
||||||
|
|
||||||
|
// coarse Node version check
|
||||||
|
if (process.version[1] !== '4') {
|
||||||
|
issues.push("Angular 2 build currently requires Node 4. Use nvm to update your node version.");
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
semver = require('semver');
|
||||||
|
} catch(e) {
|
||||||
|
issues.push("Looks like you are missing some npm dependencies. Run: npm install");
|
||||||
|
}
|
||||||
|
|
||||||
|
// wrap in try/catch in case someone requires from within that file
|
||||||
|
try {
|
||||||
|
checkNodeModules = require('./npm/check-node-modules.js');
|
||||||
|
} catch(e) {
|
||||||
|
issues.push("Looks like you are missing some npm dependencies. Run: npm install");
|
||||||
|
throw e;
|
||||||
|
} finally {
|
||||||
|
// print warnings and move on, the next steps will likely fail, but hey, we warned them.
|
||||||
|
printWarning(issues);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
function checkEnvironment(reqs) {
|
function checkEnvironment(reqs) {
|
||||||
@ -26,14 +61,20 @@ function checkEnvironment(reqs) {
|
|||||||
issues.push('Your node_modules directory is stale or out of sync with npm-shrinkwrap.json. Run: npm install');
|
issues.push('Your node_modules directory is stale or out of sync with npm-shrinkwrap.json. Run: npm install');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (issues.length) {
|
printWarning(issues);
|
||||||
console.warn(Array(80).join('!'));
|
|
||||||
console.warn('Your environment is not in a good shape. Following issues were found:');
|
|
||||||
issues.forEach(function(issue) {console.warn(' - ' + issue)});
|
|
||||||
console.warn(Array(80).join('!'));
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function printWarning(issues) {
|
||||||
|
if (!issues.length) return;
|
||||||
|
|
||||||
|
console.warn('');
|
||||||
|
console.warn(Array(110).join('!'));
|
||||||
|
console.warn('!!! Your environment is not in a good shape. Following issues were found:');
|
||||||
|
issues.forEach(function(issue) {console.warn('!!! - ' + issue)});
|
||||||
|
console.warn(Array(110).join('!'));
|
||||||
|
console.warn('');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
module.exports = checkEnvironment;
|
module.exports = checkEnvironment;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user