-
Notifications
You must be signed in to change notification settings - Fork 27.5k
chore(*): use Yarn for dependency management #15435
Changes from all commits
05c3336
1dedcdf
736b6c7
d4863a8
e8f9cbf
ad4e86a
aadee89
d003ec1
f54e924
0990833
ca139de
5dd3a35
f04fcdf
afafb7a
b77defd
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1 @@ | ||
4 | ||
|
||
6 |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
language: node_js | ||
sudo: false | ||
node_js: | ||
- '4.4' | ||
- '6' | ||
|
||
cache: | ||
directories: | ||
|
@@ -36,19 +36,12 @@ addons: | |
packages: | ||
- g++-4.8 | ||
|
||
install: | ||
# Check the size of caches | ||
- du -sh ./node_modules ./bower_components/ ./docs/bower_components/ || true | ||
# - npm config set registry http://23.251.144.68 | ||
# Disable the spinner, it looks bad on Travis | ||
- npm config set spin false | ||
# Log HTTP requests | ||
- npm config set loglevel http | ||
#- npm install -g [email protected] | ||
# Install npm dependencies and ensure that npm cache is not stale | ||
- npm install | ||
before_install: | ||
- curl -o- -L https://raw.githubusercontent.com/yarnpkg/yarn/2a0afc73210c7a82082585283e518eeb88ca19ae/scripts/install-latest.sh | bash -s -- --version 0.17.9 | ||
- export PATH=$HOME/.yarn/bin:$PATH | ||
|
||
before_script: | ||
- du -sh ./node_modules ./bower_components/ ./docs/bower_components/ || true | ||
- ./scripts/travis/before_build.sh | ||
|
||
script: | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,26 +10,63 @@ var path = require('path'); | |
var e2e = require('./test/e2e/tools'); | ||
|
||
var semver = require('semver'); | ||
var fs = require('fs'); | ||
var exec = require('shelljs').exec; | ||
var pkg = require(__dirname + '/package.json'); | ||
|
||
var useNodeVersion = fs.readFileSync('.nvmrc', 'utf8'); | ||
if (!semver.satisfies(process.version, useNodeVersion)) { | ||
throw new Error('Invalid node version; please use node v' + useNodeVersion); | ||
// Node.js version checks | ||
if (!semver.satisfies(process.version, pkg.engines.node)) { | ||
reportOrFail('Invalid node version (' + process.version + '). ' + | ||
'Please use a version that satisfies ' + pkg.engines.node); | ||
} | ||
|
||
// Yarn version checks | ||
var expectedYarnVersion = pkg.engines.yarn; | ||
var currentYarnVersion = exec('yarn --version', {silent: true}).stdout.trim(); | ||
if (!semver.satisfies(currentYarnVersion, expectedYarnVersion)) { | ||
reportOrFail('Invalid yarn version (' + currentYarnVersion + '). ' + | ||
'Please use a version that satisfies ' + expectedYarnVersion); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: Missing trailing period. |
||
} | ||
|
||
// Grunt CLI version checks | ||
var expectedGruntVersion = pkg.engines.grunt; | ||
var currentGruntVersions = exec('grunt --version', {silent: true}).stdout; | ||
var match = /^grunt-cli v(.+)$/m.exec(currentGruntVersions); | ||
if (!match) { | ||
reportOrFail('Unable to compute the current grunt-cli version. We found:\n' + | ||
currentGruntVersions); | ||
} else { | ||
if (!semver.satisfies(match[1], expectedGruntVersion)) { | ||
reportOrFail('Invalid grunt-cli version (' + match[1] + '). ' + | ||
'Please use a version that satisfies ' + expectedGruntVersion); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nit: Missing trailing period. |
||
} | ||
} | ||
|
||
// Ensure Node.js dependencies have been installed | ||
if (!process.env.TRAVIS && !process.env.JENKINS_HOME) { | ||
var yarnOutput = exec('yarn install'); | ||
if (yarnOutput.code !== 0) { | ||
throw new Error('Yarn install failed: ' + yarnOutput.stderr); | ||
} | ||
} | ||
|
||
|
||
module.exports = function(grunt) { | ||
//grunt plugins | ||
|
||
// this loads all the node_modules that start with `grunt-` as plugins | ||
require('load-grunt-tasks')(grunt); | ||
|
||
// load additional grunt tasks | ||
grunt.loadTasks('lib/grunt'); | ||
grunt.loadNpmTasks('angular-benchpress'); | ||
|
||
// compute version related info for this build | ||
var NG_VERSION = versionInfo.currentVersion; | ||
NG_VERSION.cdn = versionInfo.cdnVersion; | ||
var dist = 'angular-' + NG_VERSION.full; | ||
|
||
if (versionInfo.cdnVersion == null) { | ||
throw new Error('Unable to read CDN version, are you offline or has the CDN not been properly pushed?'); | ||
throw new Error('Unable to read CDN version, are you offline or has the CDN not been properly pushed?\n' + | ||
'Perhaps you want to set the NG1_BUILD_NO_REMOTE_VERSION_REQUESTS environment variable?'); | ||
} | ||
|
||
//config | ||
|
@@ -292,10 +329,9 @@ module.exports = function(grunt) { | |
}, | ||
|
||
shell: { | ||
'npm-install': { | ||
command: 'node scripts/npm/check-node-modules.js' | ||
'install-node-dependencies': { | ||
command: 'yarn' | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Won't this take more time that simply comparing two files (s was happening before). I am not very keen on sacrificing speed for every task for this 😕 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It shouldn't be a problem. The following was run on the angular.js repo with npm & yarn caches cleared:
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Right 👍 When trying this myself, I stopped after the 2nd time 😃 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you try? It'd be good to make sure it's that quick not only on *NIX-es. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did try of course. I didn't take your word for it 😛 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder why it's not that fast on the second try, though. I'd expect it to behave identically in all situations where cache is populated and dependencies are correct so something looks wrong here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's see: yarnpkg/yarn#2054 |
||
}, | ||
|
||
'promises-aplus-tests': { | ||
options: { | ||
stdout: false, | ||
|
@@ -322,13 +358,6 @@ module.exports = function(grunt) { | |
} | ||
}); | ||
|
||
// global beforeEach task | ||
if (!process.env.TRAVIS) { | ||
grunt.task.run('shell:npm-install'); | ||
} | ||
|
||
|
||
|
||
//alias tasks | ||
grunt.registerTask('test', 'Run unit, docs and e2e tests with Karma', ['eslint', 'package', 'test:unit', 'test:promises-aplus', 'tests:docs', 'test:protractor']); | ||
grunt.registerTask('test:jqlite', 'Run the unit tests with Karma' , ['tests:jqlite']); | ||
|
@@ -350,3 +379,14 @@ module.exports = function(grunt) { | |
grunt.registerTask('ci-checks', ['ddescribe-iit', 'merge-conflict', 'eslint']); | ||
grunt.registerTask('default', ['package']); | ||
}; | ||
|
||
|
||
function reportOrFail(message) { | ||
if (process.env.TRAVIS || process.env.JENKINS_HOME) { | ||
throw new Error(message); | ||
} else { | ||
console.log('==============================================================================='); | ||
console.log(message); | ||
console.log('==============================================================================='); | ||
} | ||
} |
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Missing trailing period 😁
Nit: I would make the message a little "softer". For example, the build will (hopefully) work fine with v7+; calling it an "invalid version" sounds "strong".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're too kind! If you feel strongly about it I will let you fix up the messaging in a future commit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Along with the missing full stops