-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
executable file
·362 lines (307 loc) · 10.4 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
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
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
var jsArray = [
"./bower_components/jquery/dist/jquery.js",
"https://cdnjs.cloudflare.com/ajax/libs/tinymce/4.6.5/tinymce.min.js",
"https://cdnjs.cloudflare.com/ajax/libs/tinymce/4.6.5/themes/inlite/theme.min.js",
"./bower_components/angular/angular.js",
"./bower_components/angular-ui-tinymce/src/tinymce.js",
"./bower_components/angular-sanitize/angular-sanitize.min.js",
"./bower_components/ui-router/release/angular-ui-router.min.js",
"./bower_components/angular-aria/angular-aria.js",
"./bower_components/angular-animate/angular-animate.js",
"./bower_components/angular-material/angular-material.js",
"./bower_components/angular-material-icons/angular-material-icons.min.js",
"./bower_components/svg-morpheus/compile/minified/svg-morpheus.js",
"./bower_components/lodash/lodash.min.js",
"./bower_components/jStorage/jstorage.min.js",
"./bower_components/angular-clipboard/angular-clipboard.js",
"./bower_components/js-beautify/js/lib/beautify.js",
"./bower_components/angularjs-imageupload-directive/public/javascripts/imageupload.js",
"./bower_components/jquery-ui/jquery-ui.js",
"./bower_components/angular-ui-sortable/sortable.min.js",
"./bower_components/angular-bootstrap/ui-bootstrap.min.js",
"./bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js",
"./bower_components/ace-builds/src-noconflict/ace.js",
"./bower_components/ace-builds/src-noconflict/theme-monokai.js",
"./bower_components/ace-builds/src-noconflict/mode-json.js",
"./js/app.js",
"./js/controllers.js",
"./js/navigation.js",
"./js/templateservice.js",
//please do not change it
'./w/js/templates.js',
];
var replacehostFrom = "http://localhost/demo/";
var replacehostTo = "http://wohlig.co.in/demo2/";
var ftpString = "U2FsdGVkX19KJ4w0W1pxaUyRsJcjQO5RL98s2rfWnmpoGlaoPfxb8Ibdl0yu5NoHaLfSDmk2WnqRVpQfIAB8wv/Srsy/Y9OUyx5gs3ZutJ2MdGMlS8IaMJmfLSp77xVx1yuRD4aFlRuo0yQ/Ldy2pA==";
var uploadingFolder = "renitabackend";
var password = "";
//Do not change anything below
//Do not change anything below
//Do not change anything below
//Do not change anything below
//Do not change anything below
//Do not change anything below
var gulp = require('gulp');
var gutil = require('gulp-util');
var gulpSequence = require('gulp-sequence');
var clean = require('gulp-clean');
var wait = require('gulp-wait');
var connect = require("gulp-connect");
var templateCacheBootstrap = "firstapp.run(['$templateCache', function($templateCache) {";
gulp.task('imagemin', function () {
var imagemin = require('gulp-imagemin');
return gulp.src('./img/**')
.pipe(imagemin({
progressive: true,
svgoPlugins: [{
removeViewBox: false
}]
}))
.pipe(gulp.dest('./img2/'));
});
gulp.task('deploy', function () {
var prompt = require("gulp-prompt");
return gulp.src('./index.html')
.pipe(prompt.prompt([{
type: 'password',
name: 'password',
message: 'Enter Encryption Password:'
}], function (res) {
password = res.password;
gulp.start('ftp');
}));
});
gulp.task('ftp', function () {
var CryptoJS = require("crypto-js");
var ftp = require('vinyl-ftp');
var decrypted = CryptoJS.AES.decrypt(ftpString, password);
var decryptedJSON = JSON.parse(decrypted.toString(CryptoJS.enc.Utf8));
decryptedJSON.log = gutil.log;
var conn = ftp.create(decryptedJSON);
var globs = [
'./production/**',
];
// using base = '.' will transfer everything to /public_html correctly
// turn off buffering in gulp.src for best performance
return gulp.src(globs, {
base: './production',
buffer: false
})
.pipe(conn.newer('/public_html/' + uploadingFolder)) // only upload newer files
.pipe(conn.dest('/public_html/' + uploadingFolder));
});
gulp.task('clean:production', function () {
return gulp.src('./production', {
read: false
})
.pipe(wait(200))
.pipe(clean({
force: true
}));
});
gulp.task('clean:indexHTML', function () {
return gulp.src('./production/index.html', {
read: false
})
.pipe(clean({
force: true
}));
});
gulp.task('clean:tmp', function () {
return gulp.src('./tmp', {
read: false
})
.pipe(wait(200))
.pipe(clean({
force: true
}));
});
gulp.task('clean:w', function () {
return gulp.src('./w', {
read: false
})
.pipe(wait(200))
.pipe(clean());
});
gulp.task('minify:css', function () {
var replace = require('gulp-replace');
var rename = require('gulp-rename');
var minifyCss = require('gulp-minify-css');
return gulp.src('./w/main.css')
.pipe(minifyCss({
keepSpecialComments: 0,
rebase: false
}))
.pipe(rename('w.css'))
.pipe(replace('url(../', 'url('))
.pipe(replace("url('../", "url('"))
.pipe(replace('url("../', 'url("'))
.pipe(gulp.dest('./w/'));
});
gulp.task('copy:indexhtml', function () {
var gulpCopy = require('gulp-copy');
return gulp.src("./w/index.html")
.pipe(gulpCopy("./production/", {
prefix: 1
}));
});
gulp.task('gzipfile', function () {
var gzip = require('gulp-gzip');
gulp.src('./w/index.html')
.pipe(gzip({
preExtension: 'gz'
}))
.pipe(gulp.dest('./production/'));
});
gulp.task('tarball', function () {
var tar = require('gulp-tar');
gulp.src('./production/**')
.pipe(tar('production.tar'), {
"mode": 0755,
"type": 'directory'
})
.pipe(gulp.dest('./'));
});
gulp.task('inlinesource', function () {
var inline = require('gulp-inline');
return gulp.src('./w/index.html')
.pipe(inline({
base: './w',
disabledTypes: ['svg', 'img'] // Only inline css files
}))
.pipe(gulp.dest('./w/'));
});
gulp.task('uglify:js', function () {
var uglify = require('gulp-uglify');
var stripDebug = require('gulp-strip-debug');
return gulp.src('./w/w.js')
// .pipe(stripDebug())
.pipe(uglify({
mangle: false
}))
.pipe(gulp.dest('./w'));
});
gulp.task('concat:js', function () {
var concat = require('gulp-concat');
var replace = require('gulp-replace');
return gulp.src(jsArray)
.pipe(concat('w.js'))
.pipe(replace(replacehostFrom, replacehostTo))
.pipe(gulp.dest('./w'));
});
gulp.task('templatecache', function () {
var templateCache = require('gulp-angular-templatecache');
return gulp.src('./w/views/**/*.html')
.pipe(templateCache({
root: "views/",
templateHeader: templateCacheBootstrap
}))
.pipe(gulp.dest('./w/js/'));
});
gulp.task('copy:img', function () {
var gulpCopy = require('gulp-copy');
return gulp.src("./img/**")
.pipe(gulpCopy("./production/"));
});
gulp.task('copy:wjs', function () {
var gulpCopy = require('gulp-copy');
return gulp.src("./w/w.js")
.pipe(gulpCopy("./production/"));
});
gulp.task('copy:wcss', function () {
var gulpCopy = require('gulp-copy');
return gulp.src("./w/w.css")
.pipe(gulpCopy("./production/"));
});
gulp.task('copy:fonts', function () {
var gulpCopy = require('gulp-copy');
return gulp.src("./fonts/**")
.pipe(gulpCopy("./production/w/"));
});
gulp.task('copy:pageJson', function () {
var gulpCopy = require('gulp-copy');
return gulp.src("./pageJson/**")
.pipe(gulpCopy("./production/"));
});
gulp.task('sass:production', function () {
var sass = require('gulp-sass');
gulp.src('./sass/*.scss')
.pipe(sass({
outputStyle: 'compressed'
}).on('error', sass.logError))
.pipe(gulp.dest('./w'));
});
gulp.task('sass:development', function () {
var sass = require('gulp-sass');
var sourcemaps = require('gulp-sourcemaps');
gulp.src('./sass/*.scss')
.pipe(sourcemaps.init())
.pipe(sass().on('error', sass.logError))
.pipe(sourcemaps.write())
.pipe(gulp.dest('./css'))
.pipe(connect.reload());
});
gulp.task('minify:indexproduction', function () {
var rename = require('gulp-rename');
var opts = {
conditionals: true,
spare: true
};
var minifyHTML = require('gulp-minify-html');
return gulp.src('./indexproduction.html')
.pipe(minifyHTML(opts))
.pipe(rename('index.html'))
.pipe(gulp.dest('./w/'));
});
gulp.task('minify:views', function () {
var minifyHTML = require('gulp-minify-html');
var opts = {
conditionals: true,
spare: true
};
return gulp.src('./views/**/*.html')
.pipe(minifyHTML(opts))
.pipe(gulp.dest('./w/views/'));
});
gulp.task('connect:html', function () {
gulp.src('./**/*.html')
.pipe(connect.reload());
});
gulp.task('connect:js', function () {
gulp.src('./js/*.js')
.pipe(connect.reload());
});
gulp.task('watch:all', function () {
var watch = require('gulp-watch');
var open = require('gulp-open');
connect.server({
root: './',
livereload: true
});
gulp.src(__filename)
.pipe(open({
uri: 'http://localhost:8080'
}));
gulp.watch(['./**/*.html', './sass/*.scss', './js/*.js'], ['sass:development', 'connect:html', 'connect:js']);
});
gulp.task('zip', function () {
var zip = require('gulp-zip');
return gulp.src('./production/**/*')
.pipe(zip('production.zip'))
.pipe(gulp.dest('./'));
});
gulp.task('renamePHP', function () {
var rename = require('gulp-rename');
return gulp.src("./production/index.html")
.pipe(rename("./production/index.php"))
.pipe(gulp.dest("./"));
});
gulp.task('watch', ["sass:development", "watch:all"]);
gulp.task('default', ["sass:development", "watch:all"]);
gulp.task('development', ["sass:development", "watch:all"]);
gulp.task('minifyhtml', ["minify:indexHTML", "minify:views", "templatecache"]);
gulp.task('copy', ["copy:img", "copy:fonts"]);
gulp.task('clearimage', ["clean:pImages", "clean:pFont"]);
// gulp.task('production', gulpSequence(["copy:img", "copy:fonts", "sass:production", "minify:indexproduction", "minify:views"], 'clean:tmp', "concat:js", 'clean:tmp', "templatecache", "uglify:js","minify:css", 'clean:tmp', "inlinesource", 'clean:tmp', "gzipfile", 'clean:tmp', 'clean:tmp', "zip"));
// gulp.task('productionc', gulpSequence(["copy:img", "copy:fonts", "sass:production", "minify:indexproduction", "minify:views"], 'clean:tmp', "concat:js", 'clean:tmp', "templatecache", "uglify:js","minify:css", 'clean:tmp', "inlinesource", 'clean:tmp','clean:production', "gzipfile", 'clean:tmp', 'clean:tmp', 'zip','deploy'));
gulp.task('production', gulpSequence(["copy:img", "copy:pageJson", "copy:fonts", "sass:production", "minify:indexproduction", "minify:views"], 'clean:tmp', "concat:js", 'clean:tmp', "templatecache", "uglify:js", "minify:css", 'clean:tmp', 'clean:tmp', "copy:indexhtml", "copy:wjs", "copy:wcss", 'clean:tmp', 'clean:tmp', "zip"));