-
Notifications
You must be signed in to change notification settings - Fork 2
/
build.js
99 lines (68 loc) · 2.07 KB
/
build.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
var fs = require('fs');
var UglifyJS = require("uglify-js");
var version = require("./version.json");
var frameworkOut = "malibu.js";
var frameworkOutMin = "malibu.min.js";
var baseUrl = "src/";
var frameworkFiles = {
include: [
"Version",
"Simplrz",
"Trigger",
"Timer",
"Value",
"Application",
"Keyframes",
"domExtend/DomExtend",
"domExtend/State",
"domExtend/Transform",
"domExtend/Transition",
"domExtend/Animation",
"FrameImpulse",
"HistoryRouter",
"Loader",
"VirtualScroll",
"Gesture",
"Template",
"Util"
]
};
var updateVersion = function() {
version.build++;
version.date = new Date();
var jsHeader = "/**\n";
jsHeader += " * @const Framework\n";
jsHeader += " * @description autogenerated with build script, holds current verison info\n";
jsHeader += " * @property {string} version - the version \n";
jsHeader += " * @property {string} build - the build number\n";
jsHeader += " * @property {string} date - the date of the build\n";
jsHeader += " */\n"
jsHeader += "// DO NOT EDIT. Updated from version.json\nvar Framework = ";
fs.writeFileSync("./version.json", JSON.stringify(version));
fs.writeFileSync(baseUrl + "Version.js", jsHeader + JSON.stringify(version));
}
var minify = function(set) {
var includes = [];
for(var i = 0; i < set.include.length; i++) {
includes.push(baseUrl + set.include[i] + ".js");
}
var result = UglifyJS.minify(includes);
return result.code;
}
var concat = function(set) {
var concatFile = "";
for(var i = 0; i < set.include.length; i++) {
var f = baseUrl + set.include[i] + ".js";
concatFile += "/* --- --- [" + set.include[i] + "] --- --- */\n\n";
concatFile += fs.readFileSync(f);
concatFile += "\n\n";
}
return concatFile;
}
updateVersion();
console.log("[ Framework " + version.version + " build " + version.build + " ]");
var minifiedFramework = minify(frameworkFiles, false);
var concatenatedFramework = concat(frameworkFiles, false);
fs.writeFileSync(frameworkOut, concatenatedFramework);
fs.writeFileSync(frameworkOutMin, minifiedFramework);
console.log("...done!");