forked from videojs/video-js-swf
-
Notifications
You must be signed in to change notification settings - Fork 53
/
Gruntfile.js
307 lines (289 loc) · 11.2 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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
module.exports = function (grunt) {
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
connect: {
dev: {
port: 8000,
base: '.'
}
},
mxmlc: {
options: {
// http://livedocs.adobe.com/flex/3/html/help.html?content=compilers_16.html
metadata: {
// `-title "Adobe Flex Application"`
title: 'VideoJS SWF',
// `-description "http://www.adobe.com/flex"`
description: 'http://www.videojs.com',
// `-publisher "The Publisher"`
publisher: 'Brightcove, Inc.',
// `-creator "The Author"`
creator: 'Brightcove, Inc.',
// `-language=EN`
// `-language+=klingon`
language: 'EN',
// `-localized-title "The Color" en-us -localized-title "The Colour" en-ca`
localizedTitle: null,
// `-localized-description "Standardized Color" en-us -localized-description "Standardised Colour" en-ca`
localizedDescription: null,
// `-contributor "Contributor #1" -contributor "Contributor #2"`
contributor: null,
// `-date "Mar 10, 2013"`
date: null
},
// http://livedocs.adobe.com/flex/3/html/help.html?content=compilers_18.html
application: {
// `-default-size 240 240`
layoutSize: {
width: 640,
height: 360
},
// `-default-frame-rate=24`
frameRate: 30,
// `-default-background-color=0x869CA7`
backgroundColor: 0x000000,
// `-default-script-limits 1000 60`
scriptLimits: {
maxRecursionDepth: 1000,
maxExecutionTime: 60
}
},
// http://livedocs.adobe.com/flex/3/html/help.html?content=compilers_19.html
// `-library-path+=libraryPath1 -library-path+=libraryPath2`
libraries: ['libs/*.*'],
// http://livedocs.adobe.com/flex/3/html/help.html?content=compilers_14.html
// http://livedocs.adobe.com/flex/3/html/help.html?content=compilers_17.html
// http://livedocs.adobe.com/flex/3/html/help.html?content=compilers_20.html
// http://livedocs.adobe.com/flex/3/html/help.html?content=compilers_21.html
compiler: {
// `-accessible=false`
'accessible': false,
// `-actionscript-file-encoding=UTF-8`
'actionscriptFileEncoding': null,
// `-allow-source-path-overlap=false`
'allowSourcePathOverlap': false,
// `-as3=true`
'as3': true,
// `-benchmark=true`
'benchmark': true,
// `-context-root context-path`
'contextRoot': null,
// `-debug=false`
'debug': false,
// `-defaults-css-files filePath1 ...`
'defaultsCssFiles': [],
// `-defaults-css-url http://example.com/main.css`
'defaultsCssUrl': null,
// `-define=CONFIG::debugging,true -define=CONFIG::release,false`
// `-define+=CONFIG::bool2,false -define+=CONFIG::and1,"CONFIG::bool2 && false"
// `-define+=NAMES::Company,"'Adobe Systems'"`
'defines': {},
// `-es=true -as3=false`
'es': false,
// `-externs className1 ...`
'externs': [],
// `-external-library-path+=pathElement`
'externalLibraries': [],
'fonts': {
// `-fonts.advanced-anti-aliasing=false`
advancedAntiAliasing: false,
// `-fonts.languages.language-range "Alpha and Plus" "U+0041-U+007F,U+002B"`
// USAGE:
// ```
// languages: [{
// lang: 'Alpha and Plus',
// range: ['U+0041-U+007F', 'U+002B']
// }]
// ```
languages: [],
// `-fonts.local-fonts-snapsnot filePath`
localFontsSnapshot: null,
// `-fonts.managers flash.fonts.JREFontManager flash.fonts.BatikFontManager flash.fonts.AFEFontManager`
// NOTE: FontManager preference is in REVERSE order (prefers LAST array item).
// For more info, see http://livedocs.adobe.com/flex/3/html/help.html?content=fonts_06.html
managers: []
},
// `-incremental=false`
'incremental': false
}
},
videojs_swf: {
files: {
'dist/video-js.swf': ['src/VideoJS.as']
}
}
},
bumpup: {
options: {
updateProps: {
pkg: 'package.json'
}
},
file: 'package.json'
},
tagrelease: {
file: 'package.json',
commit: true,
message: 'Release %version%',
prefix: 'v'
},
shell: {
options: {
failOnError: true
},
'git-diff-exit-code': { command: 'git diff --exit-code' },
'git-diff-cached-exit-code': { command: 'git diff --cached --exit-code' },
'git-add-dist-force': { command: 'git add dist --force' },
'git-merge-stable': { command: 'git merge stable' },
'git-merge-master': { command: 'git merge master' },
'git-checkout-stable': { command: 'git checkout stable' },
'git-checkout-master': { command: 'git checkout master' },
'git-push-origin-stable': { command: 'git push origin stable' },
'git-push-upstream-stable': { command: 'git push upstream stable' },
'git-push-origin-master': { command: 'git push origin master' },
'git-push-upstream-master': { command: 'git push upstream master' },
'git-push-upstream-tags': { command: 'git push upstream --tags' }
},
prompt: {
release: {
options: {
questions: [
{
config: 'release', // arbitray name or config for any other grunt task
type: 'confirm', // list, checkbox, confirm, input, password
message: 'You tested and merged the changes into stable?',
default: false, // default value if nothing is entered
// choices: 'Array|function(answers)',
// validate: function(value){ console.log('hi', value); grunt.fatal('test'); return "error"; }, // return true if valid, error message if invalid
// filter: function(value), // modify the answer
// when: function(answers) // only ask this question when this function returns true
}
]
}
},
}
});
grunt.loadNpmTasks('grunt-connect');
grunt.loadNpmTasks('grunt-bumpup');
grunt.loadNpmTasks('grunt-tagrelease');
grunt.loadNpmTasks('grunt-npm');
grunt.loadNpmTasks('grunt-shell');
grunt.loadNpmTasks('grunt-prompt');
grunt.loadNpmTasks('chg');
grunt.registerTask('dist', ['mxmlc']);
grunt.registerTask('default', ['dist']);
grunt.registerMultiTask('mxmlc', 'Compiling SWF', function () {
// Merge task-specific and/or target-specific options with these defaults.
var childProcess = require('child_process');
var flexSdk = require('flex-sdk');
var async = require('async');
var pkg = grunt.file.readJSON('package.json');
var
options = this.options,
done = this.async(),
maxConcurrency = 1,
q,
workerFn;
workerFn = function(f, callback) {
// Concat specified files.
var srcList = f.src.filter(function(filepath) {
// Warn on and remove invalid source files (if nonull was set).
if (!grunt.file.exists(filepath)) {
grunt.log.error('Source file "' + filepath + '" not found.');
return false;
}
else {
return true;
}
});
var cmdLineOpts = [];
if (f.dest) {
cmdLineOpts.push('-output');
cmdLineOpts.push(f.dest);
}
cmdLineOpts.push('-library-path+=libs/flashls.swc');
cmdLineOpts.push('-define=CONFIG::version, "' + pkg.version + '"');
cmdLineOpts.push('--');
cmdLineOpts.push.apply(cmdLineOpts, srcList);
grunt.verbose.writeln('package version: ' + pkg.version);
grunt.verbose.writeln('mxmlc path: ' + flexSdk.bin.mxmlc);
grunt.verbose.writeln('options: ' + JSON.stringify(cmdLineOpts));
// Compile!
childProcess.execFile(flexSdk.bin.mxmlc, cmdLineOpts, function(err, stdout, stderr) {
if (!err) {
grunt.log.writeln('File "' + f.dest + '" created.');
}
else {
grunt.log.error(err.toString());
grunt.verbose.writeln('stdout: ' + stdout);
grunt.verbose.writeln('stderr: ' + stderr);
if (options.force === true) {
grunt.log.warn('Should have failed but will continue because this task had the `force` option set to `true`.');
}
else {
grunt.fail.warn('FAILED');
}
}
callback(err);
});
};
q = async.queue(workerFn, maxConcurrency);
q.drain = done;
q.push(this.files);
});
/**
* How releases work:
*
* Changes come from pullrequests to master or stable.
* They are tested then pulled into their base branch.
* A change log item is added to "Unreleased".
* In a minor/major release, master is merged into stable
* (possibly by way of a release branch if testing more).
*
* Check out stable if not already checked out.
* Run `grunt release:RELEASE_TYPE`
* RELEASE_TYPE = major, minor, or patch
* Does the following:
* Bump version
* Build dist
* Force add dist
* Rotate changelog
* Commit changes
* Tag release
*
* Staging should be merged back into master.
* Push stable and master to origin.
* Run `npm publish`.
*/
grunt.registerTask('release', 'Bump, build, and tag', function(type) {
// major, minor, patch
type = type ? type : 'patch';
grunt.task.run([
'prompt-release', // make sure user is ready
'shell:git-diff-exit-code', // ensure there's no unadded changes
'shell:git-diff-cached-exit-code', // ensure there's no added changes
'shell:git-checkout-stable', // must start on the stable branch
'chg-release:'+type, // add release to changelog
'bumpup:'+type, // bump up the package version
'dist', // build distribution
'shell:git-add-dist-force', // force add the distribution
'tagrelease', // commit & tag the changes
'shell:git-push-origin-stable', // push changes to your fork
'shell:git-push-upstream-stable', // push changes to upstream
'shell:git-push-upstream-tags', // push version tag
'npm-publish', // publish to npm
'shell:git-checkout-master', // switch to master branch
'shell:git-merge-stable', // merge stable into master
'shell:git-push-origin-master', // push changes to your fork
'shell:git-push-upstream-master' // push changes upstream
]);
});
// Can't bail out when a prompt-confirm returns false, so need this hack
// https://github.com/dylang/grunt-prompt/issues/4
grunt.registerTask('prompt-release', ['prompt:release', 'prompt-release-check']);
grunt.registerTask('prompt-release-check', '', function(type) {
if(!grunt.config('release')) {
grunt.fatal('Confirmation failed.');
}
});
};