@@ -9,19 +9,64 @@ var versionInfo = require('./lib/versions/version-info');
9
9
var path = require ( 'path' ) ;
10
10
var e2e = require ( './test/e2e/tools' ) ;
11
11
12
+ var semver = require ( 'semver' ) ;
13
+ var exec = require ( 'shelljs' ) . exec ;
14
+ var pkg = require ( __dirname + '/package.json' ) ;
15
+
16
+ // Node.js version checks
17
+ if ( ! semver . satisfies ( process . version , pkg . engines . node ) ) {
18
+ reportOrFail ( 'Invalid node version (' + process . version + '). ' +
19
+ 'Please use a version that satisfies ' + pkg . engines . node ) ;
20
+ }
21
+
22
+ // Yarn version checks
23
+ var expectedYarnVersion = pkg . engines . yarn ;
24
+ var currentYarnVersion = exec ( 'yarn --version' , { silent : true } ) . stdout . trim ( ) ;
25
+ if ( ! semver . satisfies ( currentYarnVersion , expectedYarnVersion ) ) {
26
+ reportOrFail ( 'Invalid yarn version (' + currentYarnVersion + '). ' +
27
+ 'Please use a version that satisfies ' + expectedYarnVersion ) ;
28
+ }
29
+
30
+ // Grunt CLI version checks
31
+ var expectedGruntVersion = pkg . engines . grunt ;
32
+ var currentGruntVersions = exec ( 'grunt --version' , { silent : true } ) . stdout ;
33
+ var match = / ^ g r u n t - c l i v ( .+ ) $ / m. exec ( currentGruntVersions ) ;
34
+ if ( ! match ) {
35
+ reportOrFail ( 'Unable to compute the current grunt-cli version. We found:\n' +
36
+ currentGruntVersions ) ;
37
+ } else {
38
+ if ( ! semver . satisfies ( match [ 1 ] , expectedGruntVersion ) ) {
39
+ reportOrFail ( 'Invalid grunt-cli version (' + match [ 1 ] + '). ' +
40
+ 'Please use a version that satisfies ' + expectedGruntVersion ) ;
41
+ }
42
+ }
43
+
44
+ // Ensure Node.js dependencies have been installed
45
+ if ( ! process . env . TRAVIS && ! process . env . JENKINS_HOME ) {
46
+ var yarnOutput = exec ( 'yarn install' ) ;
47
+ if ( yarnOutput . code !== 0 ) {
48
+ throw new Error ( 'Yarn install failed: ' + yarnOutput . stderr ) ;
49
+ }
50
+ }
51
+
52
+
12
53
module . exports = function ( grunt ) {
13
- //grunt plugins
54
+
55
+ // this loads all the node_modules that start with `grunt-` as plugins
14
56
require ( 'load-grunt-tasks' ) ( grunt ) ;
15
57
58
+ // load additional grunt tasks
16
59
grunt . loadTasks ( 'lib/grunt' ) ;
17
60
grunt . loadNpmTasks ( 'angular-benchpress' ) ;
18
61
62
+ // compute version related info for this build
19
63
var NG_VERSION = versionInfo . currentVersion ;
20
64
NG_VERSION . cdn = versionInfo . cdnVersion ;
21
65
var dist = 'angular-' + NG_VERSION . full ;
22
66
23
67
if ( versionInfo . cdnVersion == null ) {
24
- throw new Error ( 'Unable to read CDN version, are you offline or has the CDN not been properly pushed?' ) ;
68
+ throw new Error ( 'Unable to read CDN version, are you offline or has the CDN not been properly pushed?\n' +
69
+ 'Perhaps you want to set the NG1_BUILD_NO_REMOTE_VERSION_REQUESTS environment variable?' ) ;
25
70
}
26
71
27
72
//config
@@ -313,10 +358,6 @@ module.exports = function(grunt) {
313
358
}
314
359
} ) ;
315
360
316
- if ( ! process . env . TRAVIS ) {
317
- grunt . task . run ( 'shell:install-node-dependencies' ) ;
318
- }
319
-
320
361
//alias tasks
321
362
grunt . registerTask ( 'test' , 'Run unit, docs and e2e tests with Karma' , [ 'eslint' , 'package' , 'test:unit' , 'test:promises-aplus' , 'tests:docs' , 'test:protractor' ] ) ;
322
363
grunt . registerTask ( 'test:jqlite' , 'Run the unit tests with Karma' , [ 'tests:jqlite' ] ) ;
@@ -338,3 +379,14 @@ module.exports = function(grunt) {
338
379
grunt . registerTask ( 'ci-checks' , [ 'ddescribe-iit' , 'merge-conflict' , 'eslint' ] ) ;
339
380
grunt . registerTask ( 'default' , [ 'package' ] ) ;
340
381
} ;
382
+
383
+
384
+ function reportOrFail ( message ) {
385
+ if ( process . env . TRAVIS || process . env . JENKINS_HOME ) {
386
+ throw new Error ( message ) ;
387
+ } else {
388
+ console . log ( '===============================================================================' ) ;
389
+ console . log ( message ) ;
390
+ console . log ( '===============================================================================' ) ;
391
+ }
392
+ }
0 commit comments