build(aio): do not fail if `check-env` for the main angular project fails

Fixes #17434
This commit is contained in:
Georgios Kalpakas 2017-06-14 18:34:13 +03:00 committed by Pete Bacon Darwin
parent 3515860b15
commit ce00fa3627
3 changed files with 100 additions and 16 deletions

View File

@ -13,8 +13,8 @@
"postbuild": "yarn sw-manifest && yarn sw-copy",
"lint": "yarn check-env && yarn docs-lint && ng lint && yarn example-lint",
"test": "yarn check-env && ng test",
"pree2e": "yarn ~~update-webdriver",
"e2e": "yarn check-env && ng e2e --no-webdriver-update",
"pree2e": "yarn check-env && yarn ~~update-webdriver",
"e2e": "ng e2e --no-webdriver-update",
"setup": "yarn && yarn build-ie-polyfills && yarn boilerplate:add && yarn generate-plunkers && yarn generate-zips && yarn docs",
"pretest-pwa-score-local": "yarn build",
"test-pwa-score-local": "concurrently --kill-others --success first \"http-server dist -p 4200 --silent\" \"yarn test-pwa-score -- http://localhost:4200 90\"",
@ -24,7 +24,7 @@
"deploy-preview": "scripts/deploy-preview.sh",
"deploy-staging": "scripts/deploy-to-firebase.sh staging",
"deploy-production": "scripts/deploy-to-firebase.sh production",
"check-env": "node ../tools/check-environment.js",
"check-env": "node scripts/check-environment",
"predocs": "rimraf src/generated/{docs,*.json}",
"docs": "dgeni ./tools/transforms/angular.io-package",
"docs-watch": "node tools/transforms/authors-package/watchr.js",
@ -40,6 +40,10 @@
"postinstall": "node tools/cli-patches/patch.js && uglifyjs node_modules/lunr/lunr.js -c -m -o src/assets/js/lunr.min.js --source-map",
"build-ie-polyfills": "node node_modules/webpack/bin/webpack.js -p src/ie-polyfills.js src/generated/ie-polyfills.min.js"
},
"engines": {
"node": ">=6.9.5 <7.0.0",
"yarn": ">=0.21.3 <1.0.0"
},
"private": true,
"dependencies": {
"@angular/animations": "4.2.1",
@ -108,6 +112,7 @@
"remark": "^7.0.0",
"remark-html": "^6.0.0",
"rimraf": "^2.6.1",
"semver": "^5.3.0",
"shelljs": "^0.7.7",
"tree-kill": "^1.1.0",
"ts-node": "~2.0.0",

View File

@ -0,0 +1,90 @@
/**
* Usage:
* node scripts/check-environment
*
* Checks that the expected Node and yarn versions are installed.
*
*
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* !!! !!!
* !!! 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. !!!
* !!! !!!
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
*
* This is a slightly simplified, trimmed-down version of
* [tools/check-environment.js](https://github.com/gkalpak/angular/blob/3896c60be/tools/check-environment.js).
* We use a different file, because some of the tests and error messages are not relevant for `aio/`.
*/
'use strict';
var exec = require('child_process').exec;
var engines = require(__dirname + '/../package.json').engines;
var semver;
// Import `semver`.
try {
semver = require('semver');
} catch (e) {
reportIssues(['You are missing some npm dependencies. Run: yarn install']);
console.error(
'Your environment doesn\'t provide the prerequisite dependencies.\n' +
'Please fix the issues listed above and then rerun the command.\n' +
'Check out https://github.com/angular/angular/blob/master/aio/README.md for more info.');
process.exit(1);
}
// Check Node/yarn versions.
checkEnvironment({
nodeVersion: engines.node,
yarnVersion: engines.yarn
});
// Helpers
function checkEnvironment(expected) {
exec('yarn --version', function(yarnErr, yarnStdout) {
var actualNodeVersion = process.version;
var actualYarnVersion = !yarnErr && semver.clean(yarnStdout);
var issues = [];
// Check Node version.
if (!semver.satisfies(actualNodeVersion, expected.nodeVersion)) {
issues.push(
'You are running an unsupported Node version. Expected: ' + expected.nodeVersion +
' Found: ' + actualNodeVersion + '. Use nvm to update your Node version.');
}
// Check yarn version.
if (yarnErr) {
issues.push(
'You don\'t have yarn globally installed. This is required if you want to work on this ' +
'project. Installation instructions: https://yarnpkg.com/lang/en/docs/install/');
} else if (!semver.satisfies(actualYarnVersion, expected.yarnVersion)) {
issues.push(
'You are running an unsupported yarn version. Expected: ' + expected.yarnVersion +
' Found: ' + actualYarnVersion + '. For instructions see:' +
' https://yarnpkg.com/lang/en/docs/install/');
}
reportIssues(issues);
});
}
function reportIssues(issues) {
if (!issues.length) return;
console.warn('');
console.warn('!'.repeat(110));
console.warn('!!! Your environment is not in a good shape. The following issues were found:');
issues.forEach(function(issue) { console.warn('!!! - ' + issue); });
console.warn('!'.repeat(110));
console.warn('');
if (process.env.CI) {
process.exit(1);
}
}

View File

@ -3758,11 +3758,7 @@ lower-case@^1.1.1:
version "1.1.4"
resolved "https://registry.yarnpkg.com/lower-case/-/lower-case-1.1.4.tgz#9a2cabd1b9e8e0ae993a4bf7d5875c39c42e8eac"
lru-cache@2:
version "2.7.3"
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-2.7.3.tgz#6d4524e8b955f95d4f5b58851ce21dd72fb4e952"
lru-cache@2.2.x:
lru-cache@2, lru-cache@2.2.x:
version "2.2.4"
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-2.2.4.tgz#6c658619becf14031d0d0b594b16042ce4dc063d"
@ -6572,20 +6568,13 @@ ws@1.1.1:
options ">=0.0.5"
ultron "1.0.x"
ws@1.1.2:
ws@1.1.2, ws@^1.0.1:
version "1.1.2"
resolved "https://registry.yarnpkg.com/ws/-/ws-1.1.2.tgz#8a244fa052401e08c9886cf44a85189e1fd4067f"
dependencies:
options ">=0.0.5"
ultron "1.0.x"
ws@^1.0.1:
version "1.1.4"
resolved "https://registry.yarnpkg.com/ws/-/ws-1.1.4.tgz#57f40d036832e5f5055662a397c4de76ed66bf61"
dependencies:
options ">=0.0.5"
ultron "1.0.x"
wtf-8@1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/wtf-8/-/wtf-8-1.0.0.tgz#392d8ba2d0f1c34d1ee2d630f15d0efb68e1048a"