build: switch from npm to yarn (#19328)

PR Close #19328
This commit is contained in:
Olivier Combe 2017-09-21 15:39:43 +02:00 committed by Igor Minar
parent 213baa37b0
commit f48b343af1
23 changed files with 8819 additions and 21264 deletions

View File

@ -27,10 +27,9 @@ jobs:
- checkout:
<<: *post_checkout
- restore_cache:
key: angular-{{ .Branch }}-{{ checksum "npm-shrinkwrap.json" }}
key: angular-{{ .Branch }}-{{ checksum "yarn.lock" }}
- run: npm install
- run: npm run postinstall
- run: yarn install
- run: ./node_modules/.bin/gulp lint
build:
@ -39,12 +38,12 @@ jobs:
- checkout:
<<: *post_checkout
- restore_cache:
key: angular-{{ .Branch }}-{{ checksum "npm-shrinkwrap.json" }}
key: angular-{{ .Branch }}-{{ checksum "yarn.lock" }}
- run: bazel run @nodejs//:npm install
- run: bazel run @yarn//:yarn
- run: bazel build packages/...
- save_cache:
key: angular-{{ .Branch }}-{{ checksum "npm-shrinkwrap.json" }}
key: angular-{{ .Branch }}-{{ checksum "yarn.lock" }}
paths:
- "node_modules"

View File

@ -27,9 +27,9 @@ repository (google3).
That repository defines dependencies on specific versions of
all the tools. You can run the tools Bazel installed, for
example rather than `npm install` (which depends on whatever
example rather than `yarn install` (which depends on whatever
version you have installed on your machine), you can
`bazel run @build_bazel_rules_typescript_node//:bin/npm install`.
`bazel run @yarn//:yarn`.
Bazel accepts a lot of options. We check in some options in the
`.bazelrc` file. See the [bazelrc doc]. For example, if you don't

View File

@ -26,6 +26,8 @@ following products on your development machine:
(version `>=3.10.7 <4.0.0`), which comes with Node. Depending on your system, you can install Node either from
source or as a pre-packaged bundle.
* [Yarn](https://yarnpkg.com) (version `>=1.0.2 <2.0.0`) which is used to install dependencies.
* [Java Development Kit](http://www.oracle.com/technetwork/es/java/javase/downloads/index.html) which is used
to execute the selenium standalone server for e2e testing.
@ -56,29 +58,13 @@ Next, install the JavaScript modules needed to build and test Angular:
```shell
# Install Angular project dependencies (package.json)
npm install
yarn install
```
**Optional**: In this document, we make use of project local `npm` package scripts and binaries
(stored under `./node_modules/.bin`) by prefixing these command invocations with `$(npm bin)`; in
particular `gulp` and `protractor` commands. If you prefer, you can drop this path prefix by either:
*Option 1*: globally installing these two packages as follows:
* `npm install -g gulp` (you might need to prefix this command with `sudo`)
* `npm install -g protractor` (you might need to prefix this command with `sudo`)
Since global installs can become stale, and required versions can vary by project, we avoid their
use in these instructions.
*Option 2*: globally installing the package `npm-run` by running `npm install -g npm-run`
(you might need to prefix this command with `sudo`). You will then be able to run locally installed
package scripts by invoking: e.g., `npm-run gulp build`
(see [npm-run project page](https://github.com/timoxley/npm-run) for more details).
*Option 3*: defining a bash alias like `alias nbin='PATH=$(npm bin):$PATH'` as detailed in this
[Stack Overflow answer](http://stackoverflow.com/questions/9679932/how-to-use-package-installed-locally-in-node-modules/15157360#15157360) and used like this: e.g., `nbin gulp build`.
## Installing Bower Modules

View File

@ -24,11 +24,8 @@ Note that the `package.json` file uses a special `file://../../dist` scheme
to reference the Angular packages, so that the locally-built Angular
is installed into the test app.
Also, beware of floating (non-shrinkwrapped) dependencies. If in doubt
you can install the package directly from `file:../../node_modules`. For example,
this is useful for protractor, which has a slow post-install step
(`webdriver-manager update`) that can be skipped when the package from
Angular's `node_modules` is installed.
Also, beware of floating (non-locked) dependencies. If in doubt
you can install the package directly from `file:../../node_modules`.
## Running integration tests

View File

@ -22,6 +22,7 @@
"protractor": "file:../../node_modules/protractor"
},
"scripts": {
"postinstall": "webdriver-manager update --gecko false",
"closure": "java -jar node_modules/google-closure-compiler/compiler.jar --flagfile closure.conf",
"test": "ngc && yarn run closure && concurrently \"yarn run serve\" \"yarn run protractor\" --kill-others --success first",
"serve": "lite-server -c e2e/browser.config.json",

View File

@ -4,6 +4,7 @@
"version": "0.0.0",
"license": "MIT",
"scripts": {
"postinstall": "webdriver-manager update --gecko false",
"test": "concurrently \"npm run serve\" \"npm run protractor\" --kill-others --success first",
"serve": "lite-server -c bs-config.e2e.json",
"preprotractor": "tsc -p e2e",

View File

@ -22,10 +22,11 @@
"protractor": "file:../../node_modules/protractor"
},
"scripts": {
"postinstall": "webdriver-manager update --gecko false",
"closure": "java -jar node_modules/google-closure-compiler/compiler.jar --flagfile closure.conf",
"test": "ngc && yarn run closure && concurrently \"yarn run serve\" \"yarn run protractor\" --kill-others --success first",
"serve": "lite-server -c e2e/browser.config.json",
"preprotractor": "tsc -p e2e",
"protractor": "protractor e2e/protractor.config.js"
}
}
}

File diff suppressed because it is too large Load Diff

12899
npm-shrinkwrap.json generated

File diff suppressed because it is too large Load Diff

View File

@ -1,51 +0,0 @@
All of our npm dependencies are locked via the `npm-shrinkwrap.json` file for the following reasons:
- our project has lots of dependencies which update at unpredictable times, so it's important that
we update them explicitly once in a while rather than implicitly when any of us runs npm install
- locked dependencies allow us to do reuse npm cache on travis, significantly speeding up our builds
(by 5 minutes or more)
- locked dependencies allow us to detect when node_modules folder is out of date after a branch switch
which allows us to build the project with the correct dependencies every time
We also generate `npm-shrinkwrap.clean.js` file which is used during code reviews or debugging to easily review what has actually changed without extra noise.
To add a new dependency do the following:
1. if you are on linux or windows, then use MacOS or ask someone with MacOS to perform the
installation. This is due to an optional `fsevents` dependency that is really required on MacOS
to get good performance from file watching.
2. make sure you are in sync with `upstream/master`
3. ensure that your `node_modules` directory is not stale by running `npm install`
4. add a new dependency via `npm install --save-dev <packagename>`
5. run `./tools/npm/reshrinkwrap`
6. these steps should change 3 files: `package.json`, `npm-shrinkwrap.json` and `npm-shrinkwrap.clean.json`
7. commit changes to these three files and you are done
To update existing dependency do the following:
1. if you are on linux or windows, then use MacOS or ask someone with MacOS to perform the
installation. This is due to an optional `fsevents` dependency that is really required on MacOS
to get good performance from file watching.
2. make sure you are in sync with `upstream/master`: `git fetch upstream && git rebase upstream/master`
3. ensure that your `node_modules` directory is not stale by running `npm install`
4. run `npm install --save-dev <packagename>@<version|latest>` or `npm update <packagename>` to
update to the latest version that matches version constraint in `package.json`
5. run `./tools/npm/reshrinkwrap`
6. these steps should change 2 files: `npm-shrinkwrap.json` and `npm-shrinkwrap.clean.json`.
Optionally if you used `npm install ...` in the first step, `package.json` might be modified as
well.
7. commit changes to these three files and you are done
To Remove an existing dependency do the following:
1. if you are on linux or windows, then use MacOS or ask someone with MacOS to perform the
installation. This is due to an optional `fsevents` dependency that is really required on MacOS
to get good performance from file watching.
2. make sure you are in sync with `upstream/master`: `git fetch upstream && git rebase upstream/master`
3. ensure that your `node_modules` directory is not stale by running `npm install`
4. run `npm uninstall --save-dev <packagename>@<version|latest>`
5. run `./tools/npm/reshrinkwrap`
6. these steps should change 3 files: `package.json`, `npm-shrinkwrap.json` and `npm-shrinkwrap.clean.json`.
7. commit changes to these three files and you are done

View File

@ -17,7 +17,8 @@
"url": "https://github.com/angular/angular.git"
},
"scripts": {
"postinstall": "node tools/npm/copy-npm-shrinkwrap && webdriver-manager update",
"preinstall": "node -e \"if(process.env.npm_execpath.indexOf('yarn') === -1) throw new Error('Please use Yarn instead of NPM to install dependencies. See: https://yarnpkg.com/lang/en/docs/install/')\"",
"postinstall": "webdriver-manager update --gecko false",
"check-env": "gulp check-env"
},
"dependencies": {
@ -28,86 +29,87 @@
"zone.js": "^0.8.12"
},
"optionalDependencies": {
"fsevents": "^1.0.14"
"fsevents": "1.0.17"
},
"devDependencies": {
"@bazel/typescript": "0.1.x",
"@types/angularjs": "^1.5.13-alpha",
"@types/base64-js": "^1.2.5",
"@types/chokidar": "^1.1.0",
"@types/angularjs": "1.5.13-alpha",
"@types/base64-js": "1.2.5",
"@types/chokidar": "1.7.3",
"@types/fs-extra": "0.0.22-alpha",
"@types/hammerjs": "^2.0.33",
"@types/jasmine": "^2.2.22-alpha",
"@types/node": "^6.0.84",
"@types/selenium-webdriver": "^3.0.6",
"@types/systemjs": "^0.19.32",
"angular": "^1.5.0",
"angular-animate": "^1.5.0",
"angular-mocks": "^1.5.0",
"base64-js": "^1.2.0",
"bower": "^1.3.12",
"browserstacktunnel-wrapper": "^1.4.2",
"@types/hammerjs": "2.0.33",
"@types/jasmine": "2.2.22-alpha",
"@types/node": "6.0.88",
"@types/selenium-webdriver": "3.0.6",
"@types/systemjs": "0.19.32",
"angular": "1.5.0",
"angular-animate": "1.5.0",
"angular-mocks": "1.5.0",
"base64-js": "1.2.0",
"bower": "1.7.2",
"browserstacktunnel-wrapper": "1.4.2",
"canonical-path": "0.0.2",
"chokidar": "^1.1.0",
"clang-format": "^1.0.32",
"cldr": "^4.5.0",
"cldr-data-downloader": "^0.3.2",
"cldrjs": "^0.5.0",
"conventional-changelog": "^1.1.0",
"cors": "^2.7.1",
"dgeni": "^0.4.2",
"dgeni-packages": "^0.16.5",
"domino": "^1.0.29",
"entities": "^1.1.1",
"firebase-tools": "^3.9.2",
"firefox-profile": "^0.3.4",
"fs-extra": "^0.26.3",
"glob": "^4.0.6",
"gulp": "^3.8.8",
"gulp-clang-format": "^1.0.23",
"gulp-connect": "^2.3.1",
"gulp-conventional-changelog": "^1.1.0",
"gulp-tslint": "^7.0.1",
"hammerjs": "^2.0.8",
"incremental-dom": "^0.4.1",
"jasmine": "^2.4.1",
"jasmine-core": "^2.4.1",
"chokidar": "1.4.2",
"clang-format": "1.0.41",
"cldr": "4.5.0",
"cldr-data-downloader": "0.3.2",
"cldrjs": "0.5.0",
"conventional-changelog": "1.1.0",
"cors": "2.7.1",
"dgeni": "0.4.2",
"dgeni-packages": "0.16.5",
"domino": "1.0.29",
"entities": "1.1.1",
"firebase-tools": "3.9.2",
"firefox-profile": "0.3.11",
"fs-extra": "0.26.3",
"glob": "4.5.3",
"gulp": "3.9.1",
"gulp-clang-format": "1.0.23",
"gulp-connect": "2.3.1",
"gulp-conventional-changelog": "1.1.0",
"gulp-tslint": "7.0.1",
"hammerjs": "2.0.8",
"incremental-dom": "0.4.1",
"jasmine": "2.4.1",
"jasmine-core": "2.4.1",
"jpm": "1.0.0",
"karma": "^0.13.20",
"karma-browserstack-launcher": "^0.1.9",
"karma-chrome-launcher": "^0.2.0",
"karma-jasmine": "^0.3.6",
"karma-sauce-launcher": "^0.3.0",
"karma-sourcemap-loader": "^0.3.6",
"karma": "0.13.20",
"karma-browserstack-launcher": "0.1.9",
"karma-chrome-launcher": "0.2.0",
"karma-jasmine": "0.3.6",
"karma-sauce-launcher": "0.3.0",
"karma-sourcemap-loader": "0.3.6",
"madge": "0.5.0",
"minimist": "^1.2.0",
"nan": "^2.4.0",
"node-uuid": "1.4.x",
"protractor": "5.1.x",
"react": "^0.14.0",
"rewire": "^2.3.3",
"rho": "^0.3.0",
"rollup": "^0.47.4",
"rollup-plugin-commonjs": "^8.1.0",
"rollup-plugin-node-resolve": "^3.0.0",
"rollup-plugin-sourcemaps": "^0.4.2",
"minimist": "1.2.0",
"nan": "2.4.0",
"node-uuid": "1.4.8",
"protractor": "5.1.2",
"react": "0.14.9",
"rewire": "2.5.2",
"rho": "0.3.0",
"rollup": "0.47.4",
"rollup-plugin-commonjs": "8.1.0",
"rollup-plugin-node-resolve": "3.0.0",
"rollup-plugin-sourcemaps": "0.4.2",
"selenium-webdriver": "3.0.x",
"semver": "^5.1.0",
"sorcery": "^0.10.0",
"source-map": "^0.5.6",
"source-map-support": "^0.4.2",
"semver": "5.1.0",
"sorcery": "0.10.0",
"source-map": "0.5.6",
"source-map-support": "0.4.2",
"systemjs": "0.18.10",
"ts-api-guardian": "^0.2.2",
"ts-api-guardian": "0.2.2",
"tsickle": "0.24.x",
"tslint": "^4.1.1",
"tslint-eslint-rules": "^3.1.0",
"typescript": "^2.4.2",
"universal-analytics": "^0.3.9",
"vlq": "^0.2.2",
"vrsource-tslint-rules": "^4.0.0",
"webpack": "^1.12.6",
"xhr2": "^0.1.4",
"yargs": "^3.31.0",
"yarn": "^0.19.1"
"tslint": "4.1.1",
"tslint-eslint-rules": "3.1.0",
"typescript": "2.4.2",
"uglify-js": "2.8.29",
"universal-analytics": "0.3.10",
"vlq": "0.2.2",
"vrsource-tslint-rules": "4.0.0",
"webpack": "1.12.9",
"xhr2": "0.1.4",
"yargs": "3.31.0",
"yarn": "1.0.2"
}
}

View File

@ -59,7 +59,7 @@ interface PromiseConstructor {
interface Function {
/**
* Returns the name of the function. Function names are read-only and can not be changed.
*/
* Returns the name of the function. Function names are read-only and can not be changed.
*/
readonly name: string;
}

View File

@ -8,6 +8,6 @@ echo "#################################"
echo "Running platform-server end to end tests"
echo "#################################"
npm install
yarn install
npm run test

View File

@ -35,9 +35,8 @@ fi
#######################
setEnvVar NODE_VERSION 6.9.5
setEnvVar NPM_VERSION 3.10.7 # do not upgrade to >3.10.8 unless https://github.com/npm/npm/issues/14042 is resolved
setEnvVar YARN_VERSION 1.0.2
setEnvVar SAUCE_CONNECT_VERSION 4.3.11
setEnvVar SAUCE_CONNECT_VERSION 4.4.9
setEnvVar ANGULAR_CLI_VERSION 1.4.0-rc.2
setEnvVar PROJECT_ROOT $(cd ${thisDir}/../..; pwd)

View File

@ -28,24 +28,17 @@ mkdir -p ${LOGS_DIR}
# Install node
#nvm install ${NODE_VERSION}
# Install version of npm that we are locked against
travisFoldStart "install-npm"
npm install -g npm@${NPM_VERSION}
travisFoldEnd "install-npm"
# Install version of yarn that we are locked against
travisFoldStart "install-yarn"
curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version "${YARN_VERSION}"
travisFoldEnd "install-yarn"
# Install all npm dependencies according to shrinkwrap.json
travisFoldStart "npm-install"
node tools/npm/check-node-modules --purge || npm install
travisFoldEnd "npm-install"
# Install Selenium WebDriver
travisFoldStart "webdriver-manager-update"
# --gecko false prevents webdriver-manager to ping Github for updates
# which can hit the Github api limit.
$(npm bin)/webdriver-manager update --gecko false
travisFoldEnd "webdriver-manager-update"
# Install all npm dependencies according to yarn.lock
travisFoldStart "yarn-install"
node tools/npm/check-node-modules --purge || yarn install
travisFoldEnd "yarn-install"
# Install bower packages
@ -54,14 +47,6 @@ travisFoldStart "bower-install"
travisFoldEnd "bower-install"
if [[ ${TRAVIS} && (${CI_MODE} == "e2e" || ${CI_MODE} == "e2e_2" || ${CI_MODE} == "aio" || ${CI_MODE} == "aio_e2e" || ${CI_MODE} == "aio_tools_test") ]]; then
# Install version of yarn that we are locked against
travisFoldStart "install-yarn"
curl -o- -L https://yarnpkg.com/install.sh | bash -s -- --version "${YARN_VERSION}"
travisFoldEnd "install-yarn"
fi
if [[ ${TRAVIS} && (${CI_MODE} == "aio" || ${CI_MODE} == "aio_e2e" || ${CI_MODE} == "aio_tools_test") ]]; then
# angular.io: Install all yarn dependencies according to angular.io/yarn.lock
travisFoldStart "yarn-install.aio"

View File

@ -22,7 +22,7 @@ CONNECT_URL="https://saucelabs.com/downloads/sc-${SAUCE_CONNECT_VERSION}-linux.t
CONNECT_DIR="/tmp/sauce-connect-$RANDOM"
CONNECT_DOWNLOAD="sc-latest-linux.tar.gz"
# logging disabled because it's seems to be overwhelming travis and causing flakes
# logging disabled because it seems to be overwhelming travis and causing flakes
# when we are cat-ing the log in print-logs.sh
# CONNECT_LOG="$LOGS_DIR/sauce-connect"
# CONNECT_STDOUT="$LOGS_DIR/sauce-connect.stdout"

View File

@ -30,7 +30,7 @@ if (+process.version[1] < 5) {
try {
semver = require('semver');
} catch (e) {
issues.push('Looks like you are missing some npm dependencies. Run: npm install');
issues.push('Looks like you are missing some npm dependencies. Run: `yarn install`');
}
if (issues.length) {
@ -46,7 +46,7 @@ if (issues.length) {
try {
checkNodeModules = require('./npm/check-node-modules.js');
} catch (e) {
issues.push('Looks like you are missing some npm dependencies. Run: npm install');
issues.push('Looks like you are missing some npm dependencies. Run: `yarn install`');
throw e;
} finally {
// print warnings and move on, the next steps will likely fail, but hey, we warned them.
@ -65,46 +65,37 @@ if (require.main === module) {
}
function checkEnvironment(reqs) {
exec('npm --version', function(npmErr, npmStdout) {
exec('yarn --version', function(yarnErr, yarnStdout) {
var foundNodeVersion = process.version;
var foundNpmVersion = semver.clean(npmStdout);
var foundYarnVersion = !yarnErr && semver.clean(yarnStdout);
var issues = [];
exec('yarn --version', function(yarnErr, yarnStdout) {
var foundNodeVersion = process.version;
var foundYarnVersion = !yarnErr && semver.clean(yarnStdout);
var issues = [];
if (!semver.satisfies(foundNodeVersion, reqs.requiredNodeVersion)) {
issues.push(
'You are running unsupported node version. Found: ' + foundNodeVersion + ' Expected: ' +
reqs.requiredNodeVersion + '. Use nvm to update your node version.');
}
if (!semver.satisfies(foundNodeVersion, reqs.requiredNodeVersion)) {
issues.push(
'You are running unsupported node version. Found: ' + foundNodeVersion + ' Expected: ' +
reqs.requiredNodeVersion + '. Use nvm to update your node version.');
}
if (yarnErr) {
issues.push(
'You don\'t have yarn globally installed. This is required because we use yarn to ' +
'ensure that we all use the exact same npm dependencies. Installation instructions: ' +
'https://yarnpkg.com/lang/en/docs/install/');
} else if (!semver.satisfies(foundYarnVersion, reqs.requiredYarnVersion)) {
issues.push(
'You are running an unsupported yarn version. Found: ' + foundYarnVersion +
' Expected: ' + reqs.requiredYarnVersion +
'. This is required because we use yarn to ' +
'ensure that we all use the exact same npm dependencies. Installation instructions: ' +
'https://yarnpkg.com/lang/en/docs/install/');
}
if (!semver.satisfies(foundNpmVersion, reqs.requiredNpmVersion)) {
issues.push(
'You are running unsupported npm version. Found: ' + foundNpmVersion + ' Expected: ' +
reqs.requiredNpmVersion + '. Run: npm update -g npm');
}
if (!checkNodeModules()) {
issues.push(
'Your node_modules directory is stale or out of sync with yarn.lock. Run: yarn install');
}
if (yarnErr) {
issues.push(
'You don\'t have yarn globally installed. This is required if you want to work on ' +
'certain areas, such as `aio/` and `integration/`. Installation instructions: ' +
'https://yarnpkg.com/lang/en/docs/install/');
} else if (!semver.satisfies(foundYarnVersion, reqs.requiredYarnVersion)) {
issues.push(
'You are running unsupported yarn version. Found: ' + foundYarnVersion + ' Expected: ' +
reqs.requiredYarnVersion + '. This is required if you want to work on ' +
'certain areas, such as `aio/` and `integration/`. See: ' +
'https://yarnpkg.com/lang/en/docs/install/');
}
if (!checkNodeModules()) {
issues.push(
'Your node_modules directory is stale or out of sync with npm-shrinkwrap.json. Run: npm install');
}
printWarning(issues);
})
printWarning(issues);
});
}

View File

@ -10,16 +10,17 @@
var fs = require('fs');
var path = require('path');
var childProcess = require('child_process');
var NPM_SHRINKWRAP_FILE = 'npm-shrinkwrap.json';
var NPM_SHRINKWRAP_CACHED_FILE = 'node_modules/.npm-shrinkwrap.cached.json';
var FS_OPTS = {encoding: 'utf-8'};
var PROJECT_ROOT = path.join(__dirname, '../../');
function checkNodeModules(logOutput, purgeIfStale) {
var nodeModulesOK = _checkCache(NPM_SHRINKWRAP_FILE, NPM_SHRINKWRAP_CACHED_FILE);
var yarnCheck = childProcess.spawnSync(
'./node_modules/.bin/yarn check --integrity',
{shell: true, cwd: path.resolve(__dirname, '../..')});
var nodeModulesOK = yarnCheck.status === 0;
if (nodeModulesOK) {
if (logOutput) console.log(':-) npm dependencies are looking good!');
} else {
@ -34,20 +35,6 @@ function checkNodeModules(logOutput, purgeIfStale) {
}
function _checkCache(markerFile, cacheMarkerFile) {
var absoluteMarkerFilePath = path.join(PROJECT_ROOT, markerFile);
var absoluteCacheMarkerFilePath = path.join(PROJECT_ROOT, cacheMarkerFile);
if (!fs.existsSync(absoluteCacheMarkerFilePath)) return false;
var markerContent = fs.readFileSync(absoluteMarkerFilePath, FS_OPTS);
var cacheMarkerContent = fs.readFileSync(absoluteCacheMarkerFilePath, FS_OPTS);
return markerContent == cacheMarkerContent;
}
/**
* Custom implementation of recursive `rm` because we can't rely on the state of node_modules to
* pull in existing module.

View File

@ -1,43 +0,0 @@
#!/usr/bin/env node
/**
* @license
* Copyright Google Inc. All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
/**
* this script is just a temporary solution to deal with the issue of npm outputting the npm
* shrinkwrap file in an unstable manner.
*
* See: https://github.com/npm/npm/issues/3581
*/
const fs = require('fs');
const path = require('path');
function cleanModule(moduleRecord) {
// keep `resolve` properties for git dependencies, delete otherwise
delete moduleRecord.from;
if (!(moduleRecord.resolved && moduleRecord.resolved.match(/^git(\+[a-z]+)?:\/\//))) {
delete moduleRecord.resolved;
}
if (moduleRecord.dependencies) {
Object.keys(moduleRecord.dependencies)
.forEach((name) => cleanModule(moduleRecord.dependencies[name]));
}
}
// console.log('Reading npm-shrinkwrap.json');
const shrinkwrap = require('../../npm-shrinkwrap.json');
// console.log('Cleaning shrinkwrap object');
cleanModule(shrinkwrap);
const cleanShrinkwrapPath = path.join(__dirname, '..', '..', 'npm-shrinkwrap.clean.json');
console.log('writing npm-shrinkwrap.clean.json');
fs.writeFileSync(cleanShrinkwrapPath, JSON.stringify(shrinkwrap, null, 2) + '\n');

View File

@ -1,18 +0,0 @@
#!/usr/bin/env node
var fs = require('fs');
var fse = require('fs-extra');
var path = require('path');
var NPM_SHRINKWRAP_FILE = 'npm-shrinkwrap.json';
var NPM_SHRINKWRAP_CACHED_FILE = 'node_modules/.npm-shrinkwrap.cached.json';
var PROJECT_ROOT = path.join(__dirname, '../../');
process.chdir(PROJECT_ROOT);
if (fs.existsSync(NPM_SHRINKWRAP_FILE)) {
console.log('copying shrinkwrap fingerprint to', NPM_SHRINKWRAP_CACHED_FILE);
fse.copySync(NPM_SHRINKWRAP_FILE, NPM_SHRINKWRAP_CACHED_FILE);
} else {
console.warn(`${NPM_SHRINKWRAP_FILE} not found. Copy operation will be skipped.`);
}

View File

@ -1,15 +0,0 @@
#!/usr/bin/env node
'use strict';
let childProcess = require('child_process');
childProcess.spawn('npm', ['shrinkwrap', '--dev'], {stdio: 'inherit'}).on('exit', (exitCode) => {
if (exitCode !== 0) return;
childProcess.fork('./tools/npm/clean-shrinkwrap.js').on('exit', (exitCode) => {
if (exitCode !== 0) return;
childProcess.fork('./tools/npm/copy-npm-shrinkwrap');
});
});

8656
yarn.lock Normal file

File diff suppressed because it is too large Load Diff

25
yarn.lock.readme.md Normal file
View File

@ -0,0 +1,25 @@
All of our npm dependencies are locked via the `yarn.lock` file for the following reasons:
- our project has lots of dependencies which update at unpredictable times, so it's important that
we update them explicitly once in a while rather than implicitly when any of us runs npm install
- locked dependencies allow us to reuse npm cache on travis, significantly speeding up our builds
(by 5 minutes or more)
- locked dependencies allow us to detect when node_modules folder is out of date after a branch switch
which allows us to build the project with the correct dependencies every time
Before changing a dependency, do the following:
- make sure you are in sync with `upstream/master`: `git fetch upstream && git rebase upstream/master`
- ensure that your `node_modules` directory is not stale by running `yarn install`
To add a new dependency do the following: `yarn add <packagename> --dev`
To update an existing dependency do the following: run `yarn upgrade <packagename>@<version|latest> --dev`
or `yarn upgrade <packagename> --dev` to update to the latest version that matches version constraint
in `package.json`
To Remove an existing dependency do the following: run `yarn remove <packagename>`
Once you've changed the dependency, commit the changes to `package.json` & `yarn.lock`, and you are done.