Completed
Push — master ( acbe43...f61a4c )
by Rain
02:08
created

gulpfile.js (2 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

Code
1
/* RainLoop Webmail (c) RainLoop Team | Licensed under AGPL 3 */
2
'use strict';
3
4
var
5
	pkg = require('./package.json'),
6
	head = {
7
		rainloop: '/* RainLoop Webmail (c) RainLoop Team | Licensed under RainLoop Software License */',
8
		agpl: '/* RainLoop Webmail (c) RainLoop Team | Licensed under AGPL v3 */'
9
	},
10
	cfg = {
11
		devVersion: '0.0.0',
12
		releasesPath: 'build/dist/releases',
13
		community: true,
14
		watch: false,
15
		watchInterval: 1000,
16
		googleCompile: false,
17
18
		rainloopBuilded: false,
19
		destPath: '',
20
		cleanPath: '',
21
		zipSrcPath: '',
22
		zipFile: '',
23
		zipFileShort: '',
24
25
		paths: {}
26
	},
27
28
	_ = require('lodash'),
29
	fs = require('node-fs'),
30
	path = require('path'),
31
	notifier = require('node-notifier'),
32
	runSequence = require('run-sequence'),
33
34
	webpack = require('webpack'),
35
	webpackCfgBuilder = require('./webpack.config.builder.js'),
36
37
	argv = require('yargs').argv,
38
39
	gulp = require('gulp'),
40
	concat = require('gulp-concat-util'),
41
	header = require('gulp-header'),
42
	stripbom = require('gulp-stripbom'),
43
	rename = require('gulp-rename'),
44
	replace = require('gulp-replace'),
45
	uglify = require('gulp-uglify'),
46
	notify = require("gulp-notify"),
47
	plumber = require('gulp-plumber'),
48
	gulpif = require('gulp-if'),
49
	eol = require('gulp-eol'),
50
	livereload = require('gulp-livereload'),
51
	eslint = require('gulp-eslint'),
52
	cache = require('gulp-cached'),
53
	filter = require('gulp-filter'),
54
	expect = require('gulp-expect-file'),
55
	chmod = require('gulp-chmod'),
56
	gutil = require('gulp-util');
57
58
cfg.community = !argv.pro;
59
60
// webpack
61
function webpackCallback(callback)
62
{
63
	return function(err, stats) {
64
65
		if (err)
66
		{
67
			if (cfg.watch)
68
			{
69
				webpackError(err);
70
			}
71
			else
72
			{
73
				throw new gutil.PluginError('webpack', err);
74
			}
75
		}
76
		else if (stats && stats.compilation && stats.compilation.errors && stats.compilation.errors[0])
77
		{
78
			if (cfg.watch)
79
			{
80
				_.each(stats.compilation.errors, webpackError);
81
			}
82
			else
83
			{
84
				throw new gutil.PluginError('webpack', stats.compilation.errors[0]);
85
			}
86
		}
87
88
        callback();
89
    };
90
}
91
92
function webpackError(err) {
93
	if (err)
94
	{
95
		gutil.log('[webpack]', '---');
96
		gutil.log('[webpack]', err.error ? err.error.toString() : '');
97
		gutil.log('[webpack]', err.message || '');
98
		gutil.log('[webpack]', '---');
99
100
		notifier.notify({
101
			'sound': true,
102
			'title': 'webpack',
103
			'message': err.error ? err.error.toString() : err.message
104
		});
105
	}
106
}
107
108
function getHead()
109
{
110
	return !cfg.community ? head.rainloop : head.agpl;
111
}
112
113
function zipDir(sSrcDir, sDestDir, sFileName)
114
{
115
	return gulp.src(sSrcDir + '**/*')
116
		.pipe(require('gulp-zip')(sFileName))
117
		.pipe(gulp.dest(sDestDir));
118
}
119
120
function cleanDir(sDir)
121
{
122
	return gulp.src(sDir, {read: false})
123
		.pipe(require('gulp-rimraf')());
124
}
125
126
function copyFile(sFile, sNewFile, callback)
127
{
128
	fs.writeFileSync(sNewFile, fs.readFileSync(sFile));
129
	callback();
130
}
131
132
function signFile(sFile, callback)
133
{
134
	var exec = require('child_process').exec;
135
	exec('gpg2 --openpgp -u 87DA4591 -a -b ' + sFile, function(err) {
136
		if (err) {
137
			gutil.log('gpg error: skip');
138
		}
139
		callback();
140
	});
141
}
142
143
function signFileTask(callback) {
144
	if (argv.sign)
145
	{
146
		signFile(cfg.destPath + cfg.zipFile, function() {
147
			if (cfg.zipFileShort)
148
			{
149
				signFile(cfg.destPath + cfg.zipFileShort, callback);
150
			}
151
			else
152
			{
153
				callback();
154
			}
155
		});
156
	}
157
	else
158
	{
159
		callback();
160
	}
161
};
162
163
cfg.paths.globjs = 'dev/**/*.js';
164
cfg.paths.static = 'rainloop/v/' + cfg.devVersion + '/static/';
165
cfg.paths.staticJS = 'rainloop/v/' + cfg.devVersion + '/static/js/';
166
cfg.paths.staticMinJS = 'rainloop/v/' + cfg.devVersion + '/static/js/min/';
167
cfg.paths.staticCSS = 'rainloop/v/' + cfg.devVersion + '/static/css/';
168
cfg.paths.momentLocales = 'rainloop/v/' + cfg.devVersion + '/app/localization/moment/';
169
170
cfg.paths.assets = {
171
	src: 'assets/**/*.*'
172
};
173
174
cfg.paths.less = {
175
	main: {
176
		src: 'dev/Styles/@Main.less',
177
		watch: ['dev/Styles/*.less'],
178
		options: {
179
			paths: [
180
				path.join(__dirname, 'dev', 'Styles'),
181
				path.join(__dirname, 'vendors', 'bootstrap', 'less')
182
			]
183
		}
184
	}
185
};
186
187
cfg.paths.css = {
188
	main: {
189
		name: 'app.css',
190
		src: [
191
			'node_modules/normalize.css/normalize.css',
192
			'vendors/jquery-ui/css/smoothness/jquery-ui-1.10.3.custom.css',
193
			'vendors/fontastic/styles.css',
194
			'vendors/jquery-nanoscroller/nanoscroller.css',
195
			'vendors/jquery-letterfx/jquery-letterfx.min.css',
196
			'vendors/inputosaurus/inputosaurus.css',
197
			'vendors/flags/flags-fixed.css',
198
			'node_modules/opentip/css/opentip.css',
199
			'node_modules/pikaday/css/pikaday.css',
200
			'node_modules/lightgallery/dist/css/lightgallery.min.css',
201
			'node_modules/lightgallery/dist/css/lg-transitions.min.css',
202
			'node_modules/Progress.js/minified/progressjs.min.css',
203
			'dev/Styles/_progressjs.css'
204
		]
205
	},
206
	social: {
207
		name: 'social.css',
208
		src: [
209
			'vendors/fontastic/styles.css',
210
			'dev/Styles/_social.css'
211
		]
212
	}
213
};
214
215
cfg.paths.js = {
216
	moment: {
217
		locales: [
218
			'node_modules/moment/locale/*.js'
219
		]
220
	},
221
	libs: {
222
		name: 'libs.js',
223
		src: [
224
			'node_modules/jquery/dist/jquery.min.js',
225
			'node_modules/jquery-mousewheel/jquery.mousewheel.js',
226
			'node_modules/jquery-scrollstop/jquery.scrollstop.js',
227
			'node_modules/jquery-lazyload/jquery.lazyload.js ',
228
			'node_modules/jquery.backstretch/jquery.backstretch.min.js',
229
			'vendors/jquery-ui/js/jquery-ui-1.10.3.custom.min.js', // custom
230
			'vendors/jquery-nanoscroller/jquery.nanoscroller.js', // custom (modified)
231
			'vendors/jquery-wakeup/jquery.wakeup.js', // no-npm
232
			'vendors/jquery-letterfx/jquery-letterfx.min.js', // no-npm
233
			'vendors/inputosaurus/inputosaurus.js', // custom (modified)
234
			'vendors/routes/signals.min.js', // fixed
235
			'vendors/routes/hasher.min.js', // fixed
236
			'vendors/routes/crossroads.min.js', // fixed
237
			'vendors/jua/jua.min.js', // custom
238
			'vendors/keymaster/keymaster.js', // custom (modified)
239
			'vendors/qr.js/qr.min.js', // fixed
240
			'vendors/bootstrap/js/bootstrap.min.js', // fixed
241
			'node_modules/underscore/underscore-min.js',
242
			'node_modules/moment/min/moment.min.js',
243
			'node_modules/knockout/build/output/knockout-latest.js',
244
			'node_modules/knockout-projections/dist/knockout-projections.min.js',
245
			'node_modules/knockout-sortable/build/knockout-sortable.min.js ',
246
			'node_modules/matchmedia-polyfill/matchMedia.js',
247
			'node_modules/matchmedia-polyfill/matchMedia.addListener.js',
248
			'node_modules/simplestatemanager/dist/ssm.min.js',
249
			'node_modules/autolinker/dist/Autolinker.min.js',
250
			'node_modules/opentip/lib/opentip.js',
251
			'node_modules/opentip/lib/adapter-jquery.js',
252
			'node_modules/lightgallery/dist/js/lightgallery.min.js',
253
			'node_modules/lightgallery/dist/js/lg-fullscreen.min.js',
254
			'node_modules/lightgallery/dist/js/lg-thumbnail.min.js',
255
			'node_modules/lightgallery/dist/js/lg-zoom.min.js',
256
			'node_modules/lightgallery/dist/js/lg-autoplay.min.js',
257
			'node_modules/ifvisible.js/src/ifvisible.min.js'
258
		]
259
	},
260
	app: {
261
		name: 'app.js'
262
	},
263
	admin: {
264
		name: 'admin.js'
265
	}
266
};
267
268
269
// assers
270
271
gulp.task('assets:clean', function() {
272
	return cleanDir(cfg.paths.static);
273
});
274
275
gulp.task('assets', function() {
276
	return gulp.src(cfg.paths.assets.src)
277
		.pipe(gulp.dest(cfg.paths.static));
278
});
279
280
// CSS
281
282
gulp.task('css:clean', function() {
283
	return cleanDir(cfg.paths.staticCSS + '/*.css');
284
});
285
286
gulp.task('css:main', ['assets'], function() {
287
	var autoprefixer = require('gulp-autoprefixer'),
288
		less = require('gulp-less'),
289
		lessFilter = filter('**/*.less', {restore: true}),
290
		src = cfg.paths.css.main.src.concat([cfg.paths.less.main.src]);
291
292
	return gulp.src(src)
293
		.pipe(expect.real({errorOnFailure: true}, src))
294
		.pipe(lessFilter)
295
		.pipe(gulpif(cfg.watch, plumber({errorHandler: notify.onError("Error: <%= error.message %>")})))
296
		.pipe(less({
297
			'paths': cfg.paths.less.main.options.paths
298
		}))
299
		.pipe(lessFilter.restore)
300
		.pipe(concat(cfg.paths.css.main.name))
301
		.pipe(autoprefixer('last 3 versions', 'ie >= 9', 'Firefox ESR'))
302
		.pipe(replace(/\.\.\/(img|images|fonts|svg)\//g, '$1/'))
303
		.pipe(eol('\n', true))
304
		.pipe(gulp.dest(cfg.paths.staticCSS))
305
		.pipe(livereload());
306
});
307
308
gulp.task('css:social', function() {
309
	var autoprefixer = require('gulp-autoprefixer'),
310
		src = cfg.paths.css.social.src;
311
	return gulp.src(src)
312
		.pipe(expect.real({errorOnFailure: true}, src))
313
		.pipe(concat(cfg.paths.css.social.name))
314
		.pipe(autoprefixer('last 3 versions', 'ie >= 9', 'Firefox ESR'))
315
		.pipe(replace(/\.\.\/(img|images|fonts|svg)\//g, '$1/'))
316
		.pipe(eol('\n', true))
317
		.pipe(gulp.dest(cfg.paths.staticCSS));
318
});
319
320
gulp.task('css:main:min', ['css:main'], function() {
321
	var cleanCss = require('gulp-clean-css');
322
	return gulp.src(cfg.paths.staticCSS + cfg.paths.css.main.name)
323
		.pipe(cleanCss())
324
		.pipe(rename({suffix: '.min'}))
325
		.pipe(eol('\n', true))
326
		.pipe(gulp.dest(cfg.paths.staticCSS));
327
});
328
329
gulp.task('css:social:min', ['css:social'], function() {
330
	var cleanCss = require('gulp-clean-css');
331
	return gulp.src(cfg.paths.staticCSS + cfg.paths.css.social.name)
332
		.pipe(cleanCss())
333
		.pipe(rename({suffix: '.min'}))
334
		.pipe(eol('\n', true))
335
		.pipe(gulp.dest(cfg.paths.staticCSS));
336
});
337
338
gulp.task('css:min', ['css:main:min', 'css:social:min']);
339
340
// JS
341
gulp.task('moment:locales-clear', function() {
342
	return cleanDir('rainloop/v/' + cfg.devVersion + '/app/localization/moment/*.js');
343
});
344
345
gulp.task('moment:locales', ['moment:locales-clear'], function() {
346
	return gulp.src(cfg.paths.js.moment.locales)
347
		.pipe(gulp.dest(cfg.paths.momentLocales));
348
});
349
350
gulp.task('js:libs', function() {
351
	var src = cfg.paths.js.libs.src;
352
	return gulp.src(src)
353
		.pipe(expect.real({errorOnFailure: true}, src))
354
		.pipe(concat(cfg.paths.js.libs.name, {separator: '\n\n'}))
355
		.pipe(eol('\n', true))
356
		.pipe(replace(/sourceMappingURL=[a-z0-9\.\-_]{1,20}\.map/ig, ''))
357
		.pipe(gulp.dest(cfg.paths.staticJS));
358
});
359
360
gulp.task('js:clean', function() {
361
	return cleanDir(cfg.paths.staticJS + '/**/*.js');
362
});
363
364
gulp.task('js:webpack', function(callback) {
365
	webpack(webpackCfgBuilder(cfg.paths.staticJS, !cfg.community, false), webpackCallback(callback));
366
});
367
368
gulp.task('js:app', ['js:webpack'], function() {
369
	return gulp.src(cfg.paths.staticJS + cfg.paths.js.app.name)
370
		.pipe(header(getHead() + '\n'))
371
		.pipe(eol('\n', true))
372
		.pipe(gulp.dest(cfg.paths.staticJS))
373
		.on('error', gutil.log);
374
});
375
376
gulp.task('js:admin', ['js:webpack'], function() {
377
	return gulp.src(cfg.paths.staticJS + cfg.paths.js.admin.name)
378
		.pipe(header(getHead() + '\n'))
379
		.pipe(eol('\n', true))
380
		.pipe(gulp.dest(cfg.paths.staticJS))
381
		.on('error', gutil.log);
382
});
383
384
// - min
385
gulp.task('js:min', ['js:app', 'js:admin'], function() {
386
	return gulp.src(cfg.paths.staticJS + '*.js')
387
		.pipe(replace(/"rainloop\/v\/([^\/]+)\/static\/js\/"/g, '"rainloop/v/$1/static/js/min/"'))
388
		.pipe(rename({suffix: '.min'}))
389
		.pipe(uglify({
390
			mangle: true,
391
			compress: true,
392
			ie8: false
393
		}))
394
		.pipe(eol('\n', true))
395
		.pipe(gulp.dest(cfg.paths.staticMinJS))
396
		.on('error', gutil.log);
397
});
398
399
// lint
400
gulp.task('js:eslint', function() {
401
	return gulp.src(cfg.paths.globjs)
402
		.pipe(cache('eslint'))
403
		.pipe(eslint())
404
		.pipe(gulpif(cfg.watch, plumber({errorHandler: notify.onError("Error: <%= error.message %>")})))
405
		.pipe(eslint.format())
406
		.pipe(eslint.failAfterError());
407
});
408
409
gulp.task('js:validate', ['js:eslint']);
410
411
// other
412
gulp.task('lightgallery-fonts:clear', function() {
413
	return cleanDir('rainloop/v/' + cfg.devVersion + '/static/css/fonts/lg.*');
414
});
415
416
gulp.task('fontastic-fonts:clear', function() {
417
	return cleanDir('rainloop/v/' + cfg.devVersion + '/static/css/fonts/rainloop.*');
418
});
419
420
gulp.task('lightgallery-fonts:copy', ['lightgallery-fonts:clear'], function() {
421
	return gulp.src('node_modules/lightgallery/dist/fonts/lg.*')
422
		.pipe(gulp.dest('rainloop/v/' + cfg.devVersion + '/static/css/fonts'));
423
});
424
425
gulp.task('fontastic-fonts:copy', ['fontastic-fonts:clear'], function() {
426
	return gulp.src('vendors/fontastic/fonts/rainloop.*')
427
		.pipe(gulp.dest('rainloop/v/' + cfg.devVersion + '/static/css/fonts'));
428
});
429
430
gulp.task('lightgallery', ['lightgallery-fonts:copy']);
431
gulp.task('fontastic', ['fontastic-fonts:copy']);
432
433
gulp.task('ckeditor:clear', function() {
434
	return cleanDir('rainloop/v/' + cfg.devVersion + '/static/ckeditor');
435
});
436
437
gulp.task('ckeditor:copy', ['ckeditor:clear'], function() {
438
	return gulp.src(['vendors/ckeditor/**/*', '!vendors/ckeditor/samples{,/**}', '!vendors/ckeditor/adapters{,/**}', '!vendors/ckeditor/*.md'])
439
		.pipe(gulp.dest('rainloop/v/' + cfg.devVersion + '/static/ckeditor'));
440
});
441
442
gulp.task('ckeditor:copy-plugins', ['ckeditor:copy'], function() {
443
	return gulp.src('vendors/ckeditor-plugins/**/*')
444
		.pipe(gulp.dest('rainloop/v/' + cfg.devVersion + '/static/ckeditor/plugins'));
445
});
446
447
gulp.task('ckeditor', ['ckeditor:copy-plugins', 'ckeditor:copy', 'ckeditor:clear'], function () {
448
	return gulp.src('rainloop/v/' + cfg.devVersion + '/static/ckeditor/*.js')
449
		.pipe(stripbom())
450
		.pipe(header("\uFEFF")) // BOM
451
		.pipe(gulp.dest('rainloop/v/' + cfg.devVersion + '/static/ckeditor'));
452
});
453
454
// build (RainLoop)
455
gulp.task('rainloop:copy', ['default'], function() {
456
457
	var
458
		versionFull = pkg.version,
459
		dist = cfg.releasesPath + '/webmail/' + versionFull + '/src/'
460
	;
461
462
	fs.mkdirSync(dist, '0777', true);
463
	fs.mkdirSync(dist + 'data');
464
	fs.mkdirSync(dist + 'rainloop/v/' + versionFull, '0777', true);
465
466
	return gulp.src('rainloop/v/' + cfg.devVersion + '/**/*', {base: 'rainloop/v/' + cfg.devVersion})
467
		.pipe(chmod(0o644, 0o755))
468
		.pipe(gulp.dest(dist + 'rainloop/v/' + versionFull));
469
});
470
471 View Code Duplication
gulp.task('rainloop:setup', ['rainloop:copy'], function() {
0 ignored issues
show
This code seems to be duplicated in your project.
Loading history...
472
473
	var
474
		versionFull = pkg.version,
475
		dist = cfg.releasesPath + '/webmail/' + versionFull + '/src/'
476
	;
477
478
	fs.writeFileSync(dist + 'data/VERSION', versionFull);
479
	fs.writeFileSync(dist + 'data/EMPTY', versionFull);
480
481
	fs.writeFileSync(dist + 'index.php', fs.readFileSync('index.php', 'utf8')
482
		.replace('\'APP_VERSION\', \'0.0.0\'', '\'APP_VERSION\', \'' + versionFull + '\'')
483
		.replace('\'APP_VERSION_TYPE\', \'source\'', '\'APP_VERSION_TYPE\', \'' + (cfg.community ? 'community' : 'standard') + '\'')
484
	);
485
486
	fs.writeFileSync(dist + 'rainloop/v/' + versionFull + '/index.php.root', fs.readFileSync(dist + 'index.php'));
487
488
	if (cfg.community)
489
	{
490
		require('rimraf').sync(dist + 'rainloop/v/' + versionFull + '/app/libraries/RainLoop/Providers/Prem.php');
491
	}
492
493
	cfg.destPath = cfg.releasesPath + '/webmail/' + versionFull + '/';
494
	cfg.cleanPath = dist;
495
	cfg.zipSrcPath = dist;
496
	cfg.zipFile = 'rainloop-' + (cfg.community ? 'community-' : '') + versionFull + '.zip';
497
	cfg.zipFileShort = 'rainloop-' + (cfg.community ? 'community-' : '') + 'latest.zip';
498
499
	cfg.rainloopBuilded = true;
500
});
501
502
gulp.task('rainloop:zip', ['rainloop:copy', 'rainloop:setup'], function() {
503
	return (cfg.destPath && cfg.zipSrcPath && cfg.zipFile) ?
504
		zipDir(cfg.zipSrcPath, cfg.destPath, cfg.zipFile) : false;
505
});
506
507
gulp.task('rainloop:clean', ['rainloop:copy', 'rainloop:setup', 'rainloop:zip'], function() {
508
	return (cfg.cleanPath) ? cleanDir(cfg.cleanPath) : false;
509
});
510
511
gulp.task('rainloop:shortname', ['rainloop:zip'], function(callback) {
512
	copyFile(cfg.destPath + cfg.zipFile, cfg.destPath + cfg.zipFileShort, callback);
513
});
514
515
gulp.task('rainloop:sign', ['rainloop:shortname'], signFileTask);
516
517
// build (OwnCloud)
518
gulp.task('rainloop:owncloud:copy', function() {
519
520
	var
521
		versionFull = pkg.ownCloudVersion,
522
		dist = cfg.releasesPath + '/owncloud/' + versionFull + '/src/'
523
	;
524
525
	fs.mkdirSync(dist, '0777', true);
526
	fs.mkdirSync(dist + 'rainloop', '0777', true);
527
528
	return gulp.src('build/owncloud/rainloop-app/**/*', {base: 'build/owncloud/rainloop-app/'})
529
		.pipe(gulp.dest(dist + 'rainloop'));
530
});
531
532
gulp.task('rainloop:owncloud:copy-rainloop', ['rainloop:start', 'rainloop:owncloud:copy'], function() {
533
534
	var
535
		versionFull = pkg.ownCloudVersion,
536
		dist = cfg.releasesPath + '/owncloud/' + versionFull + '/src/rainloop/'
537
	;
538
539
	if (cfg.rainloopBuilded && cfg.destPath)
540
	{
541
		return gulp.src(cfg.destPath + '/src/**/*', {base: cfg.destPath + '/src/'})
542
			.pipe(gulp.dest(dist + 'app/'));
543
	}
544
545
	return true;
546
});
547
548
gulp.task('rainloop:owncloud:copy-rainloop:clean', ['rainloop:owncloud:copy-rainloop'], function() {
549
	return (cfg.cleanPath) ? cleanDir(cfg.cleanPath) : false;
550
});
551
552 View Code Duplication
gulp.task('rainloop:owncloud:setup', ['rainloop:owncloud:copy', 'rainloop:owncloud:copy-rainloop'], function() {
0 ignored issues
show
This code seems to be duplicated in your project.
Loading history...
553
554
	var
555
		versionFull = pkg.ownCloudVersion,
556
		dist = cfg.releasesPath + '/owncloud/' + versionFull + '/src/'
557
	;
558
559
	fs.writeFileSync(dist + 'rainloop/appinfo/info.xml',
560
		fs.readFileSync(dist + 'rainloop/appinfo/info.xml', 'utf8')
561
			.replace('<version>0.0</version>', '<version>' + versionFull + '</version>')
562
			.replace('<licence></licence>', '<licence>' + (cfg.community ? 'AGPLv3' : 'RainLoop Software License') + '</licence>')
563
		);
564
565
	fs.writeFileSync(dist + 'rainloop/appinfo/version', versionFull);
566
	fs.writeFileSync(dist + 'rainloop/VERSION', versionFull);
567
568
	cfg.destPath = cfg.releasesPath + '/owncloud/' + versionFull + '/';
569
	cfg.cleanPath = dist;
570
	cfg.zipSrcPath = dist;
571
	cfg.zipFile = 'rainloop-owncloud-app-' + (cfg.community ? '' : 'standard-') + versionFull + '.zip';
572
	cfg.zipFileShort = 'rainloop' + (cfg.community ? '' : '-standard') + '.zip';
573
});
574
575
gulp.task('rainloop:owncloud:zip', ['rainloop:owncloud:copy', 'rainloop:owncloud:setup'], function() {
576
	return (cfg.destPath && cfg.zipSrcPath && cfg.zipFile) ?
577
		zipDir(cfg.zipSrcPath, cfg.destPath, cfg.zipFile) : false;
578
});
579
580
gulp.task('rainloop:owncloud:clean', ['rainloop:owncloud:copy', 'rainloop:owncloud:setup', 'rainloop:owncloud:zip'], function() {
581
	return (cfg.cleanPath) ? cleanDir(cfg.cleanPath) : false;
582
});
583
584
gulp.task('rainloop:owncloud:shortname', ['rainloop:owncloud:zip'], function(callback) {
585
	copyFile(cfg.destPath + cfg.zipFile, cfg.destPath + cfg.zipFileShort, callback);
586
});
587
588
gulp.task('rainloop:owncloud:sign', ['rainloop:owncloud:shortname'], signFileTask);
589
590
// main
591
gulp.task('moment', ['moment:locales']);
592
gulp.task('js', ['js:libs', 'js:min', 'js:validate']);
593
gulp.task('css', ['css:min']);
594
595
gulp.task('vendors', ['moment', 'ckeditor', 'fontastic', 'lightgallery']);
596
597
gulp.task('clean', ['js:clean', 'css:clean', 'assets:clean']);
598
599
gulp.task('rainloop:start', ['rainloop:copy', 'rainloop:setup']);
600
601
gulp.task('rainloop', ['rainloop:start', 'rainloop:zip', 'rainloop:clean', 'rainloop:shortname', 'rainloop:sign']);
602
603
gulp.task('owncloud', ['rainloop:owncloud:copy',
604
	'rainloop:owncloud:copy-rainloop', 'rainloop:owncloud:copy-rainloop:clean',
605
	'rainloop:owncloud:setup', 'rainloop:owncloud:zip', 'rainloop:owncloud:clean', 'rainloop:owncloud:shortname', 'rainloop:owncloud:sign']);
606
607
// default
608
gulp.task('default', function(callback) {
609
	runSequence('clean', ['js', 'css', 'vendors'], callback);
610
});
611
612
// watch
613
gulp.task('watch', ['css:main', 'js:validate'], function() {
614
	cfg.watch = true;
615
	livereload.listen();
616
	gulp.watch(cfg.paths.less.main.watch, {interval: cfg.watchInterval}, ['css:main']);
617
	gulp.watch(cfg.paths.globjs, {interval: cfg.watchInterval}, ['js:validate']);
618
});
619
620
// aliases
621
gulp.task('build', ['rainloop']);
622
623
gulp.task('d', ['default']);
624
gulp.task('w', ['watch']);
625
gulp.task('l', ['js:libs']);
626
gulp.task('v', ['js:validate']);
627
628
gulp.task('b', ['build']);
629
gulp.task('o', ['owncloud']);
630