-
Notifications
You must be signed in to change notification settings - Fork 135
/
Jakefile.js
executable file
·317 lines (255 loc) · 7.59 KB
/
Jakefile.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
308
309
310
311
312
313
314
315
var fs = require('fs');
var path = require('path');
var utils = require('./build/utils');
var mkjs = require('./build/mkjs');
var mkswf = require('./build/mkswf');
var mkxap = require('./build/mkxap');
var wiki = require('./build/wiki');
var tools = require('./build/tools');
var copyright = [
"/**",
" * mOxie - multi-runtime File API & XMLHttpRequest L2 Polyfill",
" * v@@version@@",
" *",
" * Copyright 2013, Moxiecode Systems AB",
" * Released under GPL License.",
" *",
" * License: http://www.plupload.com/license",
" * Contributing: http://www.plupload.com/contributing",
" *",
" * Date: @@releasedate@@",
" */"
].join("\n");
task("default", ["mkjs", "mkswf", "mkxap", "docs"], function (params) {});
desc("Build release package");
task("release", ["default", "package"], function (params) {});
desc("Runs JSHint on source files");
task("jshint", [], function (params) {
jshint("src", {
curly: true
});
});
desc("Compile JS");
task("mkjs", [], function () {
var amdlc = require('amdlc');
var baseDir = "src/javascript", targetDir = "bin/js";
var uglifyOptions = {
unused: true,
dead_code: true,
global_defs: {
MXI_DEBUG: false
}
};
var options = {
from: [],
compress: uglifyOptions,
baseDir: baseDir,
rootNS: "moxie",
expose: "public",
verbose: true,
outputSource: targetDir + "/moxie.js",
outputMinified: false,
outputDev: false,
outputCoverage: false
};
var modules = [].slice.call(arguments);
if (!modules.length) {
modules = ["file/Blob", "file/FileInput", "file/FileDrop", "file/FileReader", "xhr/XMLHttpRequest", "image/Image"];
}
// get paths to runtime extensions
var extPaths = mkjs.getExtensionPaths4(modules, {
runtimes: process.env.runtimes,
baseDir: baseDir
});
// we need to strip off the baseDir, since amdlc will be prepending its own anyway
extPaths = extPaths.map(function(item) {
var re = new RegExp('^'+baseDir+'\\/', 'i');
return item.replace(re, '');
});
// include corresponding runtime extensions
options.from = modules.map(function(mod) { return mod + '.js'; }).concat(extPaths);
// start fresh
if (fs.existsSync(targetDir)) {
jake.rmRf(targetDir);
}
jake.mkdirP(targetDir);
amdlc.compile(options);
// for dev and cov versions expose all modules to be able to test them properly
amdlc.compile(utils.extend({}, options, {
expose: 'all',
force: true,
outputSource: false,
outputMinified: false,
outputDev: targetDir + "/moxie.dev.js",
outputCoverage: targetDir + "/moxie.cov.js"
}));
var sourceCode = fs.readFileSync(targetDir + '/moxie.js').toString();
if (process.env.umd != 'no' && process.env.compat != 'yes') {
fs.writeFileSync(targetDir + '/moxie.js', mkjs.addUMD("moxie", sourceCode));
}
// compile minified version
tools.uglify(targetDir + "/moxie.js", targetDir + "/moxie.min.js", uglifyOptions);
console.info("Writing minified version output to: " + targetDir + "/moxie.min.js");
// inject version and copyright info
var info = require('./package.json');
info.copyright = copyright;
tools.addReleaseDetailsTo(targetDir, info);
// add debug constant to dev source
mkjs.addDebug(targetDir + "/moxie.js");
mkjs.addDebug(targetDir + "/moxie.dev.js");
mkjs.addDebug(targetDir + "/moxie.cov.js");
// add compatibility
if (process.env.compat == 'yes') {
mkjs.addCompat({
baseDir: baseDir,
targetDir: targetDir
});
}
});
desc("Compile SWF");
task("mkswf", [], function() {
var targetDir = "bin/flash";
// start fresh
if (fs.existsSync(targetDir)) {
jake.rmRf(targetDir);
}
jake.mkdirP(targetDir);
// compile both
utils.inSeries([
function(cb) {
mkswf({
src: "./src/flash/src",
input: "./src/flash/src/Moxie.as",
output: targetDir + "/Moxie.swf",
extra: "-define=MXI::IncludeImageLibs,true -define=MXI::EnableCSS,false -debug=false -optimize=true -swf-version=16"
}, cb);
},
function(cb) {
mkswf({
src: "./src/flash/src",
input: "./src/flash/src/Moxie.as",
output: targetDir + "/Moxie.cdn.swf",
extra: "-define=MXI::IncludeImageLibs,true -define=MXI::EnableCSS,true -debug=false -optimize=true -swf-version=16"
}, cb);
},
function(cb) {
// we do not require any fancy stuff in this one, so target FP 11.2 (last version supported by linux)
mkswf({
src: "./src/flash/src",
input: "./src/flash/src/Moxie.as",
output: targetDir + "/Moxie.min.swf",
extra: "-define=MXI::IncludeImageLibs,false -define=MXI::EnableCSS,false -debug=false -optimize=true -swf-version=15"
}, cb);
}
], complete);
}, true);
desc("Compile XAP");
task("mkxap", [], function() {
var targetDir = "bin\\silverlight\\";
// start fresh
if (fs.existsSync(targetDir)) {
jake.rmRf(targetDir);
}
jake.mkdirP(targetDir);
// compile both
utils.inSeries([
function(cb) {
mkxap({
input: ".\\src\\silverlight\\Moxie.csproj",
output: "/p:IncludeImageLibs=TRUE,XapFilename=Moxie.xap,OutputDir=..\\..\\" + targetDir
}, cb);
},
function(cb) {
mkxap({
input: ".\\src\\silverlight\\Moxie.csproj",
output: "/p:IncludeImageLibs=TRUE,EnableCSS=TRUE,XapFilename=Moxie.cdn.xap,OutputDir=..\\..\\" + targetDir
}, cb);
},
function(cb) {
mkxap({
input: ".\\src\\silverlight\\Moxie.csproj",
output: "/p:IncludeImageLibs=FALSE,XapFilename=Moxie.min.xap,OutputDir=..\\..\\" + targetDir
}, cb);
}
], complete);
}, true);
desc("Generate documentation using YUIDoc");
task("docs", [], function (params) {
var baseDir = "src/javascript"
, exclude = [
"runtime/flash",
"runtime/silverlight",
"runtime/html5",
"runtime/html4"
];
tools.yuidoc(baseDir, "docs", {
exclude: exclude.map(function(filePath) { return baseDir + "/" + filePath; }).join(",")
});
}, true);
desc("Generate wiki pages");
task("wiki", ["docs"], function() {
wiki("[email protected]:moxiecode/moxie.wiki.git", "wiki", "docs");
});
desc("Package library");
task("package", [], function (params) {
var zip = tools.zip;
var info = require("./package.json");
var tmpDir = "./tmp";
if (fs.existsSync(tmpDir)) {
jake.rmRf(tmpDir);
}
fs.mkdirSync(tmpDir, 0755);
var suffix = info.version.replace(/\./g, '_');
if (/(?:beta|alpha)/.test(suffix)) {
var dateFormat = require('dateformat');
// If some public test build, append build number
suffix += "." + dateFormat(new Date(), "yymmddHHMM", true);
}
zip([
"bin/**/*",
"README.md",
"LICENSE.txt"
], path.join(tmpDir, utils.format("moxie_%s.zip", suffix)), complete);
}, true);
desc("Run tests");
task("test", [], function() {
var baseDir = 'tests/auto';
var suite = eval('(' + fs.readFileSync(baseDir + '/tests.js').toString() + ')');
var tests = suite.tests.map(function(test) { return baseDir + '/' + test.url; });
var config = {
hub: "http://localhost:9000"
, farm: 'saucelabs'
, saucelabs: {
user: process.env.SAUCE_USERNAME
, pass: process.env.SAUCE_ACCESS_KEY
, slots: 1
}
, args: tests
, browsers: [
{ id: 'ie', version: 10, osId: 'win' }
, { id: 'chrome', version: 28, osId: 'mac' }
//, { id: 'firefox', version: 16, osId: 'mac' }
]
, verbose: true
, wait: true
};
require('./node_modules/bunyip/lib/bunyip').main(config);
}, true);
desc("Publish NuGet package from last tag.");
task('mknuget', [], function(apiKey) {
var mknuget = require('./build/mknuget');
var info = require('./package.json');
var endPoint = 'https://staging.nuget.org/api/v2/package';
if (!apiKey) {
console.info("Error: Provide NuGet ApiKey: jake mknuget[apiKey]");
process.exit(1);
}
mknuget.publish(info, endPoint, apiKey, function(err) {
if (err) {
console.info(err);
process.exit(1);
}
console.info("NuGet package has been published.");
complete();
});
}, true);