forked from mozilla-b2g/firefoxos-loop-client
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gruntfile.js
171 lines (154 loc) · 3.47 KB
/
Gruntfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
'use strict';
var mountFolder = function (connect, dir) {
return connect.static(require('path').resolve(dir));
};
module.exports = function(grunt) {
[
'grunt-contrib-clean',
'grunt-contrib-compress',
'grunt-contrib-connect',
'grunt-contrib-copy',
'grunt-bower-task',
'grunt-firefoxos',
'grunt-git-describe',
'grunt-html-build',
'grunt-mocha'
].forEach(grunt.loadNpmTasks);
grunt.initConfig({
connect: {
test: {
options: {
port: 9002,
middleware: function (connect) {
return [
mountFolder(connect, '.tmp'),
mountFolder(connect, 'test'),
mountFolder(connect, 'app')
];
}
}
}
},
mocha: {
all: {
options: {
run: true,
urls: ['http://0.0.0.0:9002/index.html'],
bail: true,
logErrors: true,
reporter: 'Spec'
}
}
},
clean: {
server: [
'.tmp'
],
preTest: [
'test/index.html'
],
postTest: [
'src/'
],
app: [
'application.zip'
]
},
copy: {
test: {
files: [{
expand: true,
cwd: 'src',
src: ['index.template.html'],
dest: 'test',
rename: function() {
return 'test/index.html';
}
}]
}
},
// We use htmlbuild to add the tests dependencies to test/index.html
// This avoid us to manually add the dependencies every time we add a
// new test or script file.
htmlbuild: {
src: 'test/index.template.html',
// "dest" is not working with the current htmlbuild version, so we need
// to manually move src/index.html to test/index.html
// dest: 'test/',
options: {
beautify: true,
relative: true,
scripts: {
libs: 'app/libs/*.js',
tokbox: 'app/libs/tokbox/**/*.js',
helpers: 'app/js/helpers/*.js',
screens: 'app/js/screens/*.js',
js: 'app/js/*.js',
}
}
},
'git-describe': {
options: {
prop: 'meta.revision'
},
me: {}
},
bower: {
install: {
options: {
targetDir: 'app/libs/components/',
verbose: true,
copy: false
}
}
},
compress: {
release: {
options: {
archive: 'application.zip',
},
files: [{
cwd: 'app',
expand: true,
src: '**/*'
}]
}
},
ffospush: {
app: {
appId: 'loop.services.mozilla.org',
zip: 'application.zip'
}
}
});
grunt.registerTask('test', 'Launch tests in shell with PhantomJS', [
'clean:server',
'clean:preTest',
'htmlbuild',
'copy:test',
'clean:postTest',
'connect:test',
'mocha'
]);
grunt.registerTask('saveRevision', function() {
grunt.event.once('git-describe', function (rev) {
grunt.file.write('app/js/version.js', 'Version = { id: \'' +
rev.object + '\' }');
});
grunt.task.run('git-describe');
});
grunt.registerTask('build', 'Build app for dev', [
'bower:install',
'saveRevision',
'compress:release',
'ffospush:app'
]);
grunt.registerTask('release', 'Build app for release', [
'clean',
'bower:install',
'saveRevision',
'test',
'compress:release'
]);
grunt.registerTask('default', ['build']);
};