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