-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
Jakefile.js
executable file
·228 lines (161 loc) · 5.68 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
/* global jake:true, desc:true, task:true, complete:true, require:true, console:true, process:true */
/* jshint unused:false */
var fs = require('fs');
var path = require('path');
var exec = require('child_process').exec;
var tools = require('./src/moxie/build/tools');
var utils = require('./src/moxie/build/utils');
var wiki = require('./src/moxie/build/wiki');
var mkjs = require('./src/moxie/build/mkjs');
var copyright = [
"/**",
" * Plupload - multi-runtime File Uploader",
" * 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");
desc("Default build task");
task("default", ["moxie", "mkjs", "docs"], function (params) {});
desc("Build release package");
task("release", ["default", "package"], function (params) {});
desc("Build mOxie");
task("moxie", [], function (params) {
var moxieDir = "./src/moxie";
var currentDir = process.cwd();
process.chdir(moxieDir);
exec("jake", function(error, stdout, stderr) {
if (error) {
console.info(error);
}
process.chdir(currentDir);
complete();
});
}, true);
desc("Minify JS files");
task("mkjs", [], function (i18n) {
var Instrument = require('coverjs').Instrument;
var uglify = tools.uglify;
var targetDir = "./js", moxieDir = "src/moxie";
// Clear previous versions
if (fs.existsSync(targetDir)) {
jake.rmRf(targetDir);
}
fs.mkdirSync(targetDir, 0755);
// Copy compiled moxie files
tools.copySync(moxieDir + "/bin/flash/Moxie.swf", "js/Moxie.swf");
tools.copySync(moxieDir + "/bin/silverlight/Moxie.xap", "js/Moxie.xap");
tools.copySync(moxieDir + "/bin/js/moxie.min.js", "js/moxie.min.js");
tools.copySync(moxieDir + "/bin/js/moxie.js", "js/moxie.js");
// Include Plupload source
var sourceCode = fs.readFileSync('./src/plupload.js').toString();
if (process.env.umd != 'no') {
fs.writeFileSync(targetDir + '/plupload.dev.js', mkjs.addUMD("plupload", sourceCode, ['moxie']));
} else {
fs.writeFileSync(targetDir + '/plupload.dev.js', sourceCode);
}
// Minify Plupload and combine with mOxie
uglify(targetDir + '/plupload.dev.js', targetDir + "/plupload.min.js");
var info = require("./package.json");
info.copyright = copyright;
tools.addReleaseDetailsTo(targetDir + "/plupload.dev.js", info);
tools.addReleaseDetailsTo(targetDir + "/plupload.min.js", info);
var code = "";
code += fs.readFileSync(targetDir + "/moxie.min.js") + "\n";
code += fs.readFileSync(targetDir + "/plupload.min.js");
fs.writeFileSync(targetDir + "/plupload.full.min.js", code);
// Instrument Plupload code
fs.writeFileSync(targetDir + '/plupload.cov.js', new Instrument(sourceCode, {
name: 'Plupload'
}).instrument());
// Copy UI Plupload
jake.cpR("./src/jquery.ui.plupload", targetDir + "/jquery.ui.plupload", {});
uglify(targetDir + '/jquery.ui.plupload/jquery.ui.plupload.js', targetDir + "/jquery.ui.plupload/jquery.ui.plupload.min.js");
// Copy Queue Plupload
jake.cpR("./src/jquery.plupload.queue", targetDir + "/jquery.plupload.queue", {});
uglify(targetDir + '/jquery.plupload.queue/jquery.plupload.queue.js', targetDir + "/jquery.plupload.queue/jquery.plupload.queue.min.js");
// Add I18n files
if (i18n) {
process.env.auth = "moxieuser:12345";
process.env.to = "./js/i18n";
jake.Task['i18n'].invoke();
}
});
desc("Language tools");
task("i18n", [], function(params) {
var i18n = require('./build/i18n');
switch (params) {
case 'extract':
var from = process.env.from || ['./src/plupload.js', './src/jquery.ui.plupload/jquery.ui.plupload.js', './src/jquery.plupload.queue/jquery.plupload.queue.js'];
var to = process.env.to || './tmp/en.po';
i18n.extract(from, to);
break;
case 'toPO':
// srcLang is required here, e.g.: jake i18n[toPO] srcLang=tmp/en.pot from=js/i18n/*.js
var from = process.env.from;
var to = process.env.to || './tmp/i18n';
i18n.toPot(from, to);
break;
case 'pull':
default:
var auth = (process.env.auth || "moxieuser:12345").split(':');
var to = process.env.to || './tmp/i18n';
i18n.pull(utils.format("https://%s:%s@www.transifex.com/api/2/project/plupload/resource/core/", auth[0], auth[1]), to, complete);
return;
}
complete(); // call complete manually
}, true);
desc("Generate documentation using YUIDoc");
task("docs", [], function (params) {
var yuidoc = tools.yuidoc;
yuidoc(["src", "src/jquery.plupload.queue", "src/jquery.ui.plupload"], "docs", {
norecurse: true
});
}, true);
desc("Generate wiki pages");
task("wiki", ["docs"], function() {
wiki("https://github.com/moxiecode/plupload.wiki.git", "wiki", "docs");
});
desc("Runs JSHint on source files");
task("jshint", [], function (params) {
var jshint = tools.jshint;
jshint("src", {
curly: true
});
});
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([
"js/**/*",
"examples/**/*",
"README.md",
"LICENSE.txt"
], path.join(tmpDir, utils.format("plupload_%s.zip", suffix)), complete);
}, true);
desc("Create NuGet package");
task('mknuget', [], function() {
var mknuget = require('./src/moxie/build/mknuget');
mknuget.pack(require('./package.json'), function(err, nugetPath) {
console.info(nugetPath);
complete();
});
}, true);