forked from bjdash/apic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
192 lines (177 loc) · 6.02 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
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
//@ts-check
var gulp = require('gulp'),
del = require('del'),
zip = require('gulp-zip'),
bump = require('gulp-bump'),
rename = require('gulp-rename'),
args = require('yargs').argv,
gulpGit = require('gulp-git'),
textTransformation = require('gulp-text-simple'),
run = require('gulp-run');
//Build extn for local
var buildExtnLocal = {
clean: function () {
return del(['./dist/extnLocal']);
},
build: function () {
//@ts-ignore
return run('ng build --configuration=extnLocal --base-href=index.html --output-path=dist/extnLocal --stats-json', { verbosity: 2 }).exec();
},
copyExtnFiles: function () {
return gulp.src(['./platform_files/extension/*.*', '!./platform_files/extension/manifest_*.json'])
.pipe(gulp.dest('./dist/extnLocal'))
},
copyManifestChrome: function () {
return gulp.src(['./platform_files/extension/manifest_chrome.json'])
.pipe(rename("manifest.json"))
.pipe(gulp.dest('./dist/extnLocal/'))
},
devTools: function () {
return gulp.src(['./platform_files/extension/devtools/*.*'])
.pipe(gulp.dest('./dist/extnLocal/devtools'))
},
copyDevtoolsSrc: function () {
return gulp.src(['./dist/devtools-temp/build/**/*.*', '!./dist/devtools-temp/dist/asset-manifest.json', '!./dist/devtools-temp/dist/service-worker.js', '!./dist/devtools-temp/build/precache-manifest*.*'])
.pipe(gulp.dest('./dist/extnLocal/devtools'))
}
}
//END: Build extn for local
//Build chrome extension
var buildExtn = {
clean: function () {
return del(['./dist/extn']);
},
build: function () {
//@ts-ignore
return run('ng build --prod --configuration=extn --base-href=index.html --output-path=dist/extn --stats-json --source-map=false', { verbosity: 2 }).exec();
},
copyExtnFiles: function () {
return gulp.src(['./platform_files/extension/*.*', '!./platform_files/extension/manifest_*.json'])
.pipe(gulp.dest('./dist/extn'))
},
copyManifestChrome: function () {
return gulp.src(['./platform_files/extension/manifest_chrome.json'])
.pipe(rename("manifest.json"))
.pipe(gulp.dest('./dist/extn/'))
},
copyManifestEdge: function () {
return gulp.src(['./platform_files/extension/manifest_edge.json'])
.pipe(rename("manifest.json"))
.pipe(gulp.dest('./dist/extn/'))
},
devTools: function () {
return gulp.src(['./platform_files/extension/devtools/*.*'])
.pipe(gulp.dest('./dist/extn/devtools'))
},
copyDevtoolsSrc: function () {
return gulp.src(['./dist/devtools-temp/build/**/*.*', '!./dist/devtools-temp/dist/asset-manifest.json', '!./dist/devtools-temp/dist/service-worker.js', '!./dist/devtools-temp/build/precache-manifest*.*'])
.pipe(gulp.dest('./dist/extn/devtools'))
},
zipChrome: function () {
return gulp.src('./dist/extn/**/*.*')
.pipe(zip('chrome.zip'))
.pipe(gulp.dest("./dist"));
},
zipEdge: function () {
return gulp.src('./dist/extn/**/*.*')
.pipe(zip('edge.zip'))
.pipe(gulp.dest("./dist"));
}
}
//END: Build chrome extension
//Electron
let updateBase = textTransformation(function (s) {
s = s.replace('<base href="/">', '<base href="./">');
return s;
}, {})
var electron = {
cleanElectron: function () {
return del(['./dist/win', './dist/native']);
},
copyJs: function () {
return gulp.src(['./platform_files/electron/*.*'])
.pipe(gulp.dest('./dist/win'))
},
updateBase: function () {
return gulp.src(['./dist/win/index.html'])
.pipe(updateBase())
.pipe(gulp.dest('./dist/win'))
},
}
//END: Electtron
var devTools = {
cleanDevTools: function () {
return del(['./dist/devtools-temp']);
},
cloneDevtools: function () {
return gulpGit.clone('https://github.com/bjdash/apic-devtools.git', { args: './dist/devtools-temp' });
},
}
exports.cleanExtnLocal = gulp.series(
buildExtnLocal.clean,
devTools.cleanDevTools,
);
exports.buildExtnLocal = gulp.series(
buildExtnLocal.copyExtnFiles,
buildExtnLocal.copyManifestChrome,
buildExtnLocal.devTools,
devTools.cloneDevtools,
buildExtnLocal.copyDevtoolsSrc,
devTools.cleanDevTools
);
exports.cleanExtn = gulp.series(
buildExtn.clean,
devTools.cleanDevTools,
);
exports.buildExtnChrome = gulp.series(
buildExtn.copyExtnFiles,
buildExtn.copyManifestChrome,
buildExtn.devTools,
devTools.cloneDevtools,
buildExtn.copyDevtoolsSrc,
devTools.cleanDevTools,
buildExtn.zipChrome
);
exports.buildExtnEdge = gulp.series(
buildExtn.copyExtnFiles,
buildExtn.copyManifestEdge,
buildExtn.devTools,
devTools.cloneDevtools,
buildExtn.copyDevtoolsSrc,
devTools.cleanDevTools,
buildExtn.zipEdge
);
exports.cleanElectron = gulp.series(
electron.cleanElectron
)
exports.buildElectron = gulp.series(
electron.copyJs,
electron.updateBase
)
exports.bump = function () {
/// <summary>
/// It bumps revisions
/// Usage:
/// 1. gulp bump : bumps the package.json and bower.json to the next minor revision.
/// i.e. from 0.1.1 to 0.1.2
/// 2. gulp bump --ver 1.1.1 : bumps/sets the package.json and bower.json to the
/// specified revision.
/// 3. gulp bump --type major : bumps 1.0.0
/// gulp bump --type minor : bumps 0.1.0
/// gulp bump --type patch : bumps 0.0.2
/// gulp bump --type prerelease : bumps 0.0.1-2
/// </summary>
var type = args.type;
var version = args.ver;
var options = {};
if (version) {
options.version = version;
} else {
options.type = type;
}
return gulp
.src(['./package.json', './platform_files/extension/manifest_*.json', './platform_files/electron/package.json'], { base: './' })
//@ts-ignore
.pipe(bump(options))
.pipe(gulp.dest('./'));
}