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