forked from nikitaeverywhere/LightPivotTable
-
Notifications
You must be signed in to change notification settings - Fork 4
/
gulpfile.js
111 lines (100 loc) · 3.83 KB
/
gulpfile.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
var gulp = require("gulp"),
fs = require("fs"),
clean = require("gulp-clean"),
concat = require("gulp-concat"),
uglify = require("gulp-uglify"),
wrap = require("gulp-wrap"),
minifyCSS = require("gulp-minify-css"),
htmlReplace = require("gulp-html-replace"),
header = require("gulp-header"),
replace = require("gulp-replace"),
pkg = require("./package.json"),
zip = require("gulp-zip"),
rename = require("gulp-rename");
var banner = [
"/** <%= pkg.name %>",
" ** <%= pkg.description %>",
" ** @author <%= pkg.author %>",
" ** @version <%= pkg.version %>",
" ** @license Apache 2.0",
" ** @see https://github.com/ZitRos/LightPivotTable",
" **/",
""
].join("\n");
gulp.task("clean", function () {
return gulp.src("build", {read: false})
.pipe(clean());
});
gulp.task("gatherScripts", ["clean"], function () {
return gulp.src("source/js/*.js")
.pipe(concat("lightPivotTable.js"))
.pipe(replace(/\/\*\{\{replace:version}}\*\//, "\"" + pkg["version"] + "\""))
.pipe(wrap("LightPivotTable = (function(){<%= contents %> return LightPivotTable;}());"))
.pipe(uglify({
output: {
ascii_only: true,
width: 25000,
max_line_len: 25000
}
}))
.pipe(header(banner, { pkg: pkg }))
.pipe(gulp.dest("build/WEBModule/js/"));
});
gulp.task("gatherCSS", ["clean"], function () {
return gulp.src("source/css/*.css")
.pipe(concat("lightPivotTable.css"))
.pipe(minifyCSS())
.pipe(gulp.dest("build/WEBModule/css/"));
});
gulp.task("addExample", ["clean"], function () {
return gulp.src("example/index.html")
.pipe(htmlReplace({
"css": "css/lightPivotTable.css",
"js": "js/lightPivotTable.js"
}))
.pipe(gulp.dest("build/WEBModule/"));
});
gulp.task("copyLICENSE", ["clean"], function (){
return gulp.src("LICENSE")
.pipe(gulp.dest("build/"));
});
gulp.task("copyREADME", ["clean"], function (){
return gulp.src("readme.md")
.pipe(gulp.dest("build/"));
});
gulp.task("exportCacheXML", [
"clean", "addExample", "gatherScripts", "gatherCSS", "copyLICENSE", "copyREADME"
], function () {
return gulp.src("export/LightPivotTable-DeepSeePortlet.xml")
.pipe(
replace(/\{\{replace:css}}/,
fs.readFileSync("build/WEBModule/css/lightPivotTable.css"))
)
.pipe(
replace(/\{\{replace:js}}/,
fs.readFileSync("build/WEBModule/js/lightPivotTable.js"))
)
.pipe(rename(function (path) { path.basename += "-v" + pkg["version"]; }))
.pipe(gulp.dest("build/Caché"));
});
gulp.task("zipRelease", ["exportCacheXML"], function () {
return gulp.src("build/**/*")
.pipe(zip("LightPivotTable-v" + pkg["version"] + ".zip", {
comment: "Light pivot table v" + pkg["version"] + " by Nikita Savchenko\n\n" +
"+ WEBModule folder holds JS and CSS files to integrate Light pivot table to any WEB " +
"application;\n" +
"+ Cache folder holds XML file to import to InterSystems Cache.\n\n" +
"NOTE: MDX2JSON must be installed and configured for InterSystems Cache.\nYou can " +
"download and install it from here: https://github.com/intersystems-ru/Cache-MDX2JSON\n"
+ "\nFor further information about installation and information, check README.md file."
}))
.pipe(gulp.dest("build"));
});
gulp.task("desktop", ["default"], function () {
return gulp.src("build/Caché/*")
.pipe(gulp.dest("C:/Users/ZitRo/Desktop"));
});
gulp.task("default", [
"clean", "gatherScripts", "gatherCSS", "addExample", "copyLICENSE", "copyREADME",
"exportCacheXML", "zipRelease"
]);