Skip to content

Commit 79b51d5

Browse files
geddskiIgorMinar
authored andcommitted
chore(Grunt): switch from Rake to Grunt
Migrates the Angular project from Rake to Grunt. Benefits: - Drops Ruby dependency - Lowers barrier to entry for contributions from JavaScript ninjas - Simplifies the Angular project setup and build process - Adopts industry-standard tools specific to JavaScript projects - Support building angular.js on Windows platform (really?!? why?!?) BREAKING CHANGE: Rake is completely replaced by Grunt. Below are the deprecated Rake tasks and their Grunt equivalents: rake --> grunt rake package --> grunt package rake init --> N/A rake clean --> grunt clean rake concat_scenario --> grunt build:scenario rake concat --> grunt build rake concat_scenario --> grunt build:scenario rake minify --> grunt minify rake version --> grunt write:version rake docs --> grunt docs rake webserver --> grunt webserver rake test --> grunt test rake test:unit --> grunt test:unit rake test:<jqlite|jquery|modules|e2e> --> grunt test:<jqlite|jquery|modules|end2end|e2e> rake test[Firefox+Safari] --> grunt test --browsers Firefox,Safari rake test[Safari] --> grunt test --browsers Safari rake autotest --> grunt autotest NOTES: * For convenience grunt test:e2e starts a webserver for you, while grunt test:end2end doesn't. Use grunt test:end2end if you already have the webserver running. * Removes duplicate entry for Describe.js in the angularScenario section of angularFiles.js * Updates docs/src/gen-docs.js to use #done intead of the deprecated #end * Uses grunt-contrib-connect instead of lib/nodeserver (removed) * Removes nodeserver.sh, travis now uses grunt webserver * Built and minified files are identical to Rake's output, with the exception of one less character for git revisions (using --short) and a couple minor whitespace differences Closes angular#199
1 parent fe8d893 commit 79b51d5

18 files changed

+468
-682
lines changed

.travis.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ node_js:
55
before_script:
66
- export DISPLAY=:99.0
77
- sh -e /etc/init.d/xvfb start
8-
- npm install -g testacular@canary
9-
- rake package
10-
- ./nodeserver.sh > /dev/null &
8+
- npm install -g grunt-cli
9+
- grunt package
10+
- grunt webserver > /dev/null &
1111

1212
script:
13-
- rake test[Firefox,"--reporters=dots"]
13+
- grunt test --browsers Firefox --reporters=dots

Gruntfile.js

+170
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
var files = require('./angularFiles').files;
2+
var util = require('./lib/grunt/utils.js');
3+
4+
module.exports = function(grunt) {
5+
//grunt plugins
6+
grunt.loadNpmTasks('grunt-contrib-clean');
7+
grunt.loadNpmTasks('grunt-contrib-copy');
8+
grunt.loadNpmTasks('grunt-contrib-connect');
9+
grunt.loadNpmTasks('grunt-contrib-compress');
10+
grunt.loadTasks('lib/grunt');
11+
12+
var NG_VERSION = util.getVersion();
13+
14+
15+
//global beforeEach
16+
util.init();
17+
18+
19+
//config
20+
grunt.initConfig({
21+
NG_VERSION: NG_VERSION,
22+
23+
connect: {
24+
devserver: {
25+
options: {
26+
port: 8000,
27+
hostname: 'localhost',
28+
base: '.',
29+
keepalive: true,
30+
middleware: function(connect, options){
31+
return [
32+
//uncomment to enable CSP
33+
// util.csp(),
34+
util.rewrite(),
35+
connect.favicon('images/favicon.ico'),
36+
connect.static(options.base),
37+
connect.directory(options.base)
38+
];
39+
}
40+
}
41+
},
42+
testserver: {}
43+
},
44+
45+
46+
test: {
47+
jqlite: 'testacular-jqlite.conf.js',
48+
jquery: 'testacular-jquery.conf.js',
49+
modules: 'testacular-modules.conf.js',
50+
//NOTE run grunt test:e2e instead and it will start a webserver for you
51+
end2end: 'testacular-e2e.conf.js'
52+
},
53+
54+
55+
autotest: {
56+
jqlite: 'testacular-jqlite.conf.js',
57+
jquery: 'testacular-jquery.conf.js'
58+
},
59+
60+
61+
clean: {build: ['build']},
62+
63+
64+
build: {
65+
scenario: {
66+
dest: 'build/angular-scenario.js',
67+
src: [
68+
'lib/jquery/jquery.js',
69+
util.wrap([files['angularSrc'], files['angularScenario']], 'ngScenario/angular')
70+
],
71+
styles: {
72+
css: ['css/angular.css', 'css/angular-scenario.css']
73+
}
74+
},
75+
angular: {
76+
dest: 'build/angular.js',
77+
src: util.wrap([files['angularSrc']], 'angular'),
78+
styles: {
79+
css: ['css/angular.css'],
80+
minify: true
81+
}
82+
},
83+
loader: {
84+
dest: 'build/angular-loader.js',
85+
src: util.wrap(['src/loader.js'], 'loader')
86+
},
87+
mocks: {
88+
dest: 'build/angular-mocks.js',
89+
src: ['src/ngMock/angular-mocks.js'],
90+
strict: false
91+
},
92+
sanitize: {
93+
dest: 'build/angular-sanitize.js',
94+
src: util.wrap([
95+
'src/ngSanitize/sanitize.js',
96+
'src/ngSanitize/directive/ngBindHtml.js',
97+
'src/ngSanitize/filter/linky.js',
98+
], 'module')
99+
},
100+
resource: {
101+
dest: 'build/angular-resource.js',
102+
src: util.wrap(['src/ngResource/resource.js'], 'module')
103+
},
104+
cookies: {
105+
dest: 'build/angular-cookies.js',
106+
src: util.wrap(['src/ngCookies/cookies.js'], 'module')
107+
},
108+
bootstrap: {
109+
dest: 'build/angular-bootstrap.js',
110+
src: util.wrap(['src/bootstrap/bootstrap.js'], 'module')
111+
},
112+
bootstrapPrettify: {
113+
dest: 'build/angular-bootstrap-prettify.js',
114+
src: util.wrap(['src/bootstrap/bootstrap-prettify.js', 'src/bootstrap/google-prettify/prettify.js'], 'module'),
115+
styles: {
116+
css: ['src/bootstrap/google-prettify/prettify.css'],
117+
minify: true
118+
}
119+
}
120+
},
121+
122+
123+
min: {
124+
angular: 'build/angular.js',
125+
cookies: 'build/angular-cookies.js',
126+
loader: 'build/angular-loader.js',
127+
resource: 'build/angular-resource.js',
128+
sanitize: 'build/angular-sanitize.js',
129+
bootstrap: 'build/angular-bootstrap.js',
130+
bootstrapPrettify: 'build/angular-bootstrap-prettify.js',
131+
},
132+
133+
134+
docs: {
135+
process: ['build/docs/*.html', 'build/docs/.htaccess']
136+
},
137+
138+
139+
copy: {
140+
i18n: {
141+
files: [
142+
{ src: 'src/ngLocale/**', dest: 'build/i18n/', expand: true, flatten: true }
143+
]
144+
}
145+
},
146+
147+
148+
compress: {
149+
build: {
150+
options: {archive: 'build/angular-'+ NG_VERSION.full +'.zip'},
151+
src: ['**'], cwd: 'build', expand: true
152+
}
153+
},
154+
155+
156+
write: {
157+
versionTXT: {file: 'build/version.txt', val: NG_VERSION.full},
158+
versionJSON: {file: 'build/version.json', val: JSON.stringify(NG_VERSION)}
159+
}
160+
});
161+
162+
163+
//alias tasks
164+
grunt.registerTask('test:unit', ['test:jqlite', 'test:jquery', 'test:modules']);
165+
grunt.registerTask('minify', ['clean', 'build', 'minall']);
166+
grunt.registerTask('test:e2e', ['connect:testserver', 'test:end2end']);
167+
grunt.registerTask('webserver', ['connect:devserver']);
168+
grunt.registerTask('package', ['clean', 'buildall', 'minall', 'docs', 'copy', 'write', 'compress']);
169+
grunt.registerTask('default', ['package']);
170+
};

README.md

+6-8
Original file line numberDiff line numberDiff line change
@@ -21,21 +21,19 @@ Building AngularJS
2121
---------
2222
[Once you have your environment setup](http://docs.angularjs.org/misc/contribute) just run:
2323

24-
rake package
24+
grunt package
2525

2626

2727
Running Tests
2828
-------------
2929
To execute all unit tests, use:
3030

31-
rake test:unit
31+
grunt test:unit
3232

3333
To execute end-to-end (e2e) tests, use:
3434

35-
rake package
36-
rake webserver &
37-
rake test:e2e
35+
grunt package
36+
grunt test:e2e
3837

39-
To learn more about the rake tasks, run `rake -T` and also read our
40-
[contribution guidelines](http://docs.angularjs.org/misc/contribute) and instructions in this
41-
[commit message](https://github.com/angular/angular.js/commit/9d168f058f9c6d7eeae0daa7cb72ea4e02a0003a).
38+
To learn more about the grunt tasks, run `grunt --help` and also read our
39+
[contribution guidelines](http://docs.angularjs.org/misc/contribute).

0 commit comments

Comments
 (0)