2014-08-25 15:10:51 +08:00
|
|
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */
|
2014-06-17 03:56:11 +08:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var
|
|
|
|
pkg = require('./package.json'),
|
|
|
|
cfg = {
|
|
|
|
devVersion: '0.0.0',
|
|
|
|
releasesPath: 'build/dist/releases',
|
|
|
|
|
|
|
|
destPath: '',
|
|
|
|
cleanPath: '',
|
|
|
|
zipSrcPath: '',
|
|
|
|
zipFile: '',
|
|
|
|
|
|
|
|
paths: {},
|
|
|
|
summary: {
|
|
|
|
verbose: true,
|
|
|
|
reasonCol: 'cyan,bold',
|
|
|
|
codeCol: 'green'
|
|
|
|
},
|
|
|
|
uglify: {
|
|
|
|
mangle: true,
|
2014-09-05 06:49:03 +08:00
|
|
|
compress: true
|
2014-06-17 03:56:11 +08:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
fs = require('node-fs'),
|
|
|
|
path = require('path'),
|
|
|
|
gulp = require('gulp'),
|
|
|
|
concat = require('gulp-concat-util'),
|
|
|
|
header = require('gulp-header'),
|
2014-09-13 00:32:05 +08:00
|
|
|
eol = require('gulp-eol'),
|
2014-06-17 03:56:11 +08:00
|
|
|
rename = require('gulp-rename'),
|
2014-09-05 06:49:03 +08:00
|
|
|
replace = require('gulp-replace'),
|
2014-06-17 03:56:11 +08:00
|
|
|
uglify = require('gulp-uglify'),
|
|
|
|
gutil = require('gulp-util')
|
|
|
|
;
|
|
|
|
|
|
|
|
function regOtherMinTask(sName, sPath, sInc, sOut, sHeader)
|
|
|
|
{
|
|
|
|
gulp.task(sName, function() {
|
|
|
|
return gulp.src(sPath + sInc)
|
|
|
|
.pipe(uglify())
|
|
|
|
.pipe(header(sHeader || ''))
|
|
|
|
.pipe(rename(sOut))
|
2014-09-13 00:32:05 +08:00
|
|
|
.pipe(eol('\n', true))
|
2014-06-17 03:56:11 +08:00
|
|
|
.pipe(gulp.dest(sPath));
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
function zipDir(sSrcDir, sDestDir, sFileName)
|
|
|
|
{
|
|
|
|
return gulp.src(sSrcDir + '**/*')
|
|
|
|
.pipe(require('gulp-zip')(sFileName))
|
|
|
|
.pipe(gulp.dest(sDestDir));
|
|
|
|
}
|
|
|
|
|
|
|
|
function cleanDir(sDir)
|
|
|
|
{
|
|
|
|
return gulp.src(sDir, {read: false})
|
2014-08-25 23:49:01 +08:00
|
|
|
.pipe(require('gulp-rimraf')());
|
2014-06-17 03:56:11 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function renameFileWothMd5Hash(sFile)
|
|
|
|
{
|
|
|
|
var sHash = require('crypto').createHash('md5').update(fs.readFileSync(sFile)).digest('hex');
|
|
|
|
fs.renameSync(sFile, sFile.replace(/\.zip$/, '-' + sHash + '.zip'));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2014-08-25 23:49:01 +08:00
|
|
|
cfg.paths.globjs = 'dev/**/*.js';
|
2014-09-06 05:44:29 +08:00
|
|
|
cfg.paths.static = 'rainloop/v/' + cfg.devVersion + '/static/';
|
2014-06-17 03:56:11 +08:00
|
|
|
cfg.paths.staticJS = 'rainloop/v/' + cfg.devVersion + '/static/js/';
|
2014-09-05 06:49:03 +08:00
|
|
|
cfg.paths.staticMinJS = 'rainloop/v/' + cfg.devVersion + '/static/js/min/';
|
2014-06-17 03:56:11 +08:00
|
|
|
cfg.paths.staticCSS = 'rainloop/v/' + cfg.devVersion + '/static/css/';
|
|
|
|
|
|
|
|
cfg.paths.less = {
|
|
|
|
main: {
|
|
|
|
name: 'less.css',
|
|
|
|
src: 'dev/Styles/@Main.less',
|
|
|
|
watch: ['dev/Styles/*.less'],
|
|
|
|
options: {
|
|
|
|
paths: [path.join(__dirname, 'dev/Styles/'), path.join(__dirname, 'vendors/bootstrap/less/')]
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
cfg.paths.css = {
|
|
|
|
main: {
|
|
|
|
name: 'app.css',
|
|
|
|
src: [
|
|
|
|
'vendors/jquery-ui/css/smoothness/jquery-ui-1.10.3.custom.css',
|
|
|
|
'vendors/normalize/normalize.css',
|
|
|
|
'vendors/fontastic/styles.css',
|
|
|
|
'vendors/jquery-nanoscroller/nanoscroller.css',
|
|
|
|
'vendors/jquery-magnific-popup/magnific-popup.css',
|
|
|
|
'vendors/jquery-magnific-popup/magnific-popup-animations.css',
|
2014-10-30 05:08:53 +08:00
|
|
|
'vendors/jquery-letterfx/jquery-letterfx.min.css',
|
2014-06-17 03:56:11 +08:00
|
|
|
'vendors/simple-pace/styles.css',
|
|
|
|
'vendors/inputosaurus/inputosaurus.css',
|
|
|
|
'vendors/flags/flags-fixed.css',
|
|
|
|
cfg.paths.staticCSS + cfg.paths.less.main.name
|
|
|
|
]
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
cfg.paths.js = {
|
|
|
|
boot: {
|
|
|
|
name: 'boot.js',
|
|
|
|
src: [
|
|
|
|
'vendors/json2.min.js',
|
2014-08-14 17:26:58 +08:00
|
|
|
'vendors/labjs/LAB.min.js',
|
2014-06-17 03:56:11 +08:00
|
|
|
'vendors/simple-pace/simple-pace-1.0.min.js',
|
2014-08-29 23:30:52 +08:00
|
|
|
'vendors/rl/rl-1.2.min.js'
|
2014-06-17 03:56:11 +08:00
|
|
|
]
|
|
|
|
},
|
|
|
|
openpgp: {
|
2014-09-05 06:49:03 +08:00
|
|
|
name: 'openpgp.js',
|
2014-06-17 03:56:11 +08:00
|
|
|
src: [
|
2014-08-07 17:34:20 +08:00
|
|
|
'vendors/openpgp/openpgp-0.7.2.min.js'
|
2014-06-17 03:56:11 +08:00
|
|
|
]
|
|
|
|
},
|
2014-07-25 06:28:10 +08:00
|
|
|
encrypt: {
|
2014-09-05 06:49:03 +08:00
|
|
|
name: 'bundle.js',
|
2014-07-25 06:28:10 +08:00
|
|
|
header: '(function (window) {',
|
|
|
|
footer: '}(window));',
|
|
|
|
dest: 'vendors/jsbn/',
|
2014-07-25 00:18:03 +08:00
|
|
|
src: [
|
2014-07-25 06:28:10 +08:00
|
|
|
'vendors/jsbn/jsbn.js',
|
|
|
|
'vendors/jsbn/prng4.js',
|
|
|
|
'vendors/jsbn/rng.js',
|
|
|
|
'vendors/jsbn/rsa.js',
|
2014-09-05 06:49:03 +08:00
|
|
|
'vendors/jsbn/fix.js'
|
2014-07-25 00:18:03 +08:00
|
|
|
]
|
|
|
|
},
|
2014-06-17 03:56:11 +08:00
|
|
|
libs: {
|
|
|
|
name: 'libs.js',
|
|
|
|
src: [
|
|
|
|
'vendors/modernizr.js',
|
2014-08-26 23:24:47 +08:00
|
|
|
'vendors/underscore/1.6.0/underscore-min.js',
|
2014-06-17 03:56:11 +08:00
|
|
|
'vendors/jquery/jquery-1.11.1.min.js',
|
|
|
|
'vendors/jquery-ui/js/jquery-ui-1.10.3.custom.min.js',
|
|
|
|
'vendors/jquery-cookie/jquery.cookie-1.4.0.min.js',
|
|
|
|
'vendors/jquery-finger/jquery.finger.min.js',
|
|
|
|
'vendors/jquery-mousewheel/jquery.mousewheel-3.1.4.min.js',
|
|
|
|
'vendors/jquery-scrollstop/jquery.scrollstop.min.js',
|
|
|
|
'vendors/jquery-lazyload/jquery.lazyload.min.js',
|
|
|
|
'vendors/jquery-nanoscroller/jquery.nanoscroller-0.7.min.js',
|
|
|
|
'vendors/jquery-wakeup/jquery.wakeup.min.js',
|
2014-10-30 05:08:53 +08:00
|
|
|
'vendors/jquery-letterfx/jquery-letterfx.min.js',
|
2014-06-17 03:56:11 +08:00
|
|
|
'vendors/inputosaurus/inputosaurus.min.js',
|
|
|
|
'vendors/moment/min/moment.min.js ',
|
|
|
|
'vendors/routes/signals.min.js',
|
|
|
|
'vendors/routes/hasher.min.js',
|
|
|
|
'vendors/routes/crossroads.min.js',
|
2014-08-19 18:33:59 +08:00
|
|
|
'vendors/knockout/knockout-3.2.0.js',
|
2014-06-17 03:56:11 +08:00
|
|
|
'vendors/knockout-projections/knockout-projections-1.0.0.min.js',
|
|
|
|
'vendors/ssm/ssm.min.js',
|
|
|
|
'vendors/jua/jua.min.js',
|
2014-09-05 23:53:44 +08:00
|
|
|
'vendors/Autolinker/Autolinker.min.js',
|
2014-09-19 21:31:14 +08:00
|
|
|
'vendors/jsencrypt/jsencrypt.min.js',
|
2014-09-13 00:32:05 +08:00
|
|
|
'vendors/keymaster/keymaster.min.js',
|
2014-06-17 03:56:11 +08:00
|
|
|
'vendors/ifvisible/ifvisible.min.js',
|
|
|
|
'vendors/jquery-magnific-popup/jquery.magnific-popup.min.js',
|
2014-08-14 17:26:58 +08:00
|
|
|
'vendors/bootstrap/js/bootstrap.min.js'
|
2014-06-17 03:56:11 +08:00
|
|
|
]
|
|
|
|
},
|
|
|
|
app: {
|
2014-08-28 23:27:30 +08:00
|
|
|
name: 'app.js'
|
2014-06-17 03:56:11 +08:00
|
|
|
},
|
|
|
|
admin: {
|
2014-08-28 23:27:30 +08:00
|
|
|
name: 'admin.js'
|
2014-06-17 03:56:11 +08:00
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
// CSS
|
|
|
|
gulp.task('less:main', function() {
|
2014-08-29 23:30:52 +08:00
|
|
|
var less = require('gulp-less');
|
2014-06-17 03:56:11 +08:00
|
|
|
return gulp.src(cfg.paths.less.main.src)
|
|
|
|
.pipe(less({
|
|
|
|
'paths': cfg.paths.less.main.options.paths
|
|
|
|
}))
|
|
|
|
.pipe(rename(cfg.paths.less.main.name))
|
2014-09-13 00:32:05 +08:00
|
|
|
.pipe(eol('\n', true))
|
2014-06-17 03:56:11 +08:00
|
|
|
.pipe(gulp.dest(cfg.paths.staticCSS));
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('css:main', ['less:main'], function() {
|
2014-08-29 23:30:52 +08:00
|
|
|
|
|
|
|
var
|
|
|
|
// csslint = require('gulp-csslint'),
|
|
|
|
csscomb = require('gulp-csscomb'),
|
|
|
|
autoprefixer = require('gulp-autoprefixer')
|
|
|
|
;
|
|
|
|
|
2014-06-17 03:56:11 +08:00
|
|
|
return gulp.src(cfg.paths.css.main.src)
|
|
|
|
.pipe(concat(cfg.paths.css.main.name))
|
2014-08-28 23:27:30 +08:00
|
|
|
.pipe(autoprefixer('last 3 versions', '> 1%', 'ie 9', 'Firefox ESR', 'Opera 12.1'))
|
2014-10-30 05:08:53 +08:00
|
|
|
// .pipe(csscomb())
|
2014-08-28 23:27:30 +08:00
|
|
|
// .pipe(csslint())
|
|
|
|
// .pipe(csslint.reporter())
|
2014-09-13 00:32:05 +08:00
|
|
|
.pipe(eol('\n', true))
|
2014-08-28 23:27:30 +08:00
|
|
|
.pipe(gulp.dest(cfg.paths.staticCSS))
|
|
|
|
;
|
2014-06-17 03:56:11 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('css:main:min', ['css:main'], function() {
|
2014-08-29 23:30:52 +08:00
|
|
|
var minifyCss = require('gulp-minify-css');
|
2014-06-17 03:56:11 +08:00
|
|
|
return gulp.src(cfg.paths.staticCSS + cfg.paths.css.main.name)
|
2014-08-29 23:30:52 +08:00
|
|
|
.pipe(minifyCss({
|
|
|
|
'keepSpecialComments': 0
|
|
|
|
}))
|
2014-08-28 23:27:30 +08:00
|
|
|
.pipe(rename({suffix: '.min'}))
|
2014-09-13 00:32:05 +08:00
|
|
|
.pipe(eol('\n', true))
|
2014-06-17 03:56:11 +08:00
|
|
|
.pipe(gulp.dest(cfg.paths.staticCSS));
|
|
|
|
});
|
|
|
|
|
|
|
|
// JS
|
|
|
|
gulp.task('js:boot', function() {
|
|
|
|
return gulp.src(cfg.paths.js.boot.src)
|
|
|
|
.pipe(concat(cfg.paths.js.boot.name))
|
2014-09-13 00:32:05 +08:00
|
|
|
.pipe(eol('\n', true))
|
2014-09-05 06:49:03 +08:00
|
|
|
.pipe(gulp.dest(cfg.paths.staticMinJS));
|
2014-06-17 03:56:11 +08:00
|
|
|
});
|
|
|
|
|
2014-07-25 06:28:10 +08:00
|
|
|
gulp.task('js:encrypt', function() {
|
|
|
|
return gulp.src(cfg.paths.js.encrypt.src)
|
|
|
|
.pipe(concat(cfg.paths.js.encrypt.name))
|
2014-10-24 01:59:21 +08:00
|
|
|
.pipe(concat.header(cfg.paths.js.encrypt.header || ''))
|
|
|
|
.pipe(concat.footer(cfg.paths.js.encrypt.footer || ''))
|
2014-07-25 06:28:10 +08:00
|
|
|
.pipe(uglify(cfg.uglify))
|
2014-09-13 00:32:05 +08:00
|
|
|
.pipe(eol('\n', true))
|
2014-09-05 06:49:03 +08:00
|
|
|
.pipe(gulp.dest(cfg.paths.js.encrypt.dest))
|
2014-07-25 06:28:10 +08:00
|
|
|
.on('error', gutil.log);
|
2014-07-25 00:18:03 +08:00
|
|
|
});
|
|
|
|
|
2014-06-17 03:56:11 +08:00
|
|
|
gulp.task('js:openpgp', function() {
|
|
|
|
return gulp.src(cfg.paths.js.openpgp.src)
|
|
|
|
.pipe(rename(cfg.paths.js.openpgp.name))
|
2014-09-13 00:32:05 +08:00
|
|
|
.pipe(eol('\n', true))
|
2014-09-05 06:49:03 +08:00
|
|
|
.pipe(gulp.dest(cfg.paths.staticMinJS));
|
2014-06-17 03:56:11 +08:00
|
|
|
});
|
|
|
|
|
2014-09-19 21:31:14 +08:00
|
|
|
gulp.task('js:libs', function() {
|
2014-06-17 03:56:11 +08:00
|
|
|
return gulp.src(cfg.paths.js.libs.src)
|
|
|
|
.pipe(concat(cfg.paths.js.libs.name, {separator: '\n\n'}))
|
2014-09-13 00:32:05 +08:00
|
|
|
.pipe(eol('\n', true))
|
2014-09-05 06:49:03 +08:00
|
|
|
.pipe(gulp.dest(cfg.paths.staticMinJS));
|
2014-06-17 03:56:11 +08:00
|
|
|
});
|
|
|
|
|
2014-09-06 05:44:29 +08:00
|
|
|
gulp.task('js:ckeditor:beautify', function() {
|
|
|
|
var beautify = require('gulp-beautify');
|
|
|
|
return gulp.src(cfg.paths.static + 'ckeditor/ckeditor.js')
|
|
|
|
.pipe(beautify({
|
|
|
|
'indentSize': 2
|
|
|
|
}))
|
|
|
|
.pipe(rename('ckeditor.beautify.js'))
|
2014-09-13 00:32:05 +08:00
|
|
|
.pipe(eol('\n', true))
|
2014-09-06 05:44:29 +08:00
|
|
|
.pipe(gulp.dest(cfg.paths.static + 'ckeditor/'));
|
|
|
|
});
|
|
|
|
|
2014-09-05 06:49:03 +08:00
|
|
|
gulp.task('js:webpack:clear', function() {
|
|
|
|
return gulp.src([cfg.paths.staticJS + '*.chunk.js', cfg.paths.staticMinJS + '*.chunk.js'], {read: false})
|
|
|
|
.pipe(require('gulp-rimraf')());
|
|
|
|
});
|
2014-09-05 07:22:39 +08:00
|
|
|
|
2014-09-05 06:49:03 +08:00
|
|
|
gulp.task('js:webpack', ['js:webpack:clear'], function(callback) {
|
2014-08-29 23:30:52 +08:00
|
|
|
var
|
2014-09-05 06:49:03 +08:00
|
|
|
webpack = require('webpack'),
|
|
|
|
webpackCfg = require('./webpack.config.js')
|
2014-08-29 23:30:52 +08:00
|
|
|
;
|
|
|
|
|
2014-09-05 06:49:03 +08:00
|
|
|
if (webpackCfg && webpackCfg.output)
|
|
|
|
{
|
|
|
|
webpackCfg.output.publicPath = cfg.paths.staticJS;
|
|
|
|
}
|
|
|
|
|
|
|
|
webpack(webpackCfg, function(err, stats) {
|
|
|
|
if (err) {
|
|
|
|
throw new gutil.PluginError('webpack', err);
|
|
|
|
}
|
|
|
|
gutil.log('[webpack]', stats.toString({}));
|
|
|
|
callback();
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('js:app', ['js:webpack'], function() {
|
|
|
|
return gulp.src(cfg.paths.staticJS + cfg.paths.js.app.name)
|
2014-09-02 08:15:31 +08:00
|
|
|
.pipe(header('/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */\n'))
|
2014-09-13 00:32:05 +08:00
|
|
|
.pipe(eol('\n', true))
|
2014-08-25 23:49:01 +08:00
|
|
|
.pipe(gulp.dest(cfg.paths.staticJS))
|
|
|
|
.on('error', gutil.log);
|
2014-06-17 03:56:11 +08:00
|
|
|
});
|
|
|
|
|
2014-09-05 06:49:03 +08:00
|
|
|
gulp.task('js:admin', ['js:webpack'], function() {
|
|
|
|
return gulp.src(cfg.paths.staticJS + cfg.paths.js.admin.name)
|
|
|
|
.pipe(header('/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */\n'))
|
2014-09-13 00:32:05 +08:00
|
|
|
.pipe(eol('\n', true))
|
2014-09-05 06:49:03 +08:00
|
|
|
.pipe(gulp.dest(cfg.paths.staticJS))
|
|
|
|
.on('error', gutil.log);
|
|
|
|
});
|
2014-08-31 05:33:34 +08:00
|
|
|
|
2014-09-05 06:49:03 +08:00
|
|
|
gulp.task('js:chunks', ['js:webpack'], function() {
|
|
|
|
return gulp.src(cfg.paths.staticJS + '*.chunk.js')
|
2014-09-02 08:15:31 +08:00
|
|
|
.pipe(header('/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */\n'))
|
2014-09-13 00:32:05 +08:00
|
|
|
.pipe(eol('\n', true))
|
2014-08-25 23:49:01 +08:00
|
|
|
.pipe(gulp.dest(cfg.paths.staticJS))
|
|
|
|
.on('error', gutil.log);
|
2014-06-17 03:56:11 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
// - min
|
2014-09-05 07:22:39 +08:00
|
|
|
gulp.task('js:min', ['js:app', 'js:admin', 'js:chunks'], function() {
|
|
|
|
return gulp.src(cfg.paths.staticJS + '*.js')
|
|
|
|
.pipe(replace(/"rainloop\/v\/([^\/]+)\/static\/js\/"/g, '"rainloop/v/$1/static/js/min/"'))
|
2014-09-05 06:49:03 +08:00
|
|
|
.pipe(uglify(cfg.uglify))
|
|
|
|
.pipe(header('/* RainLoop Webmail (c) RainLoop Team | Licensed under CC BY-NC-SA 3.0 */\n'))
|
2014-09-13 00:32:05 +08:00
|
|
|
.pipe(eol('\n', true))
|
2014-09-05 06:49:03 +08:00
|
|
|
.pipe(gulp.dest(cfg.paths.staticMinJS))
|
2014-06-17 03:56:11 +08:00
|
|
|
.on('error', gutil.log);
|
|
|
|
});
|
|
|
|
|
2014-08-25 23:49:01 +08:00
|
|
|
// lint
|
|
|
|
gulp.task('js:lint', function() {
|
2014-08-31 05:33:34 +08:00
|
|
|
|
2014-08-29 23:30:52 +08:00
|
|
|
var
|
|
|
|
closureCompiler = require('gulp-closure-compiler'),
|
|
|
|
jshint = require('gulp-jshint')
|
|
|
|
;
|
|
|
|
|
2014-08-25 23:49:01 +08:00
|
|
|
return gulp.src(cfg.paths.globjs)
|
|
|
|
.pipe(jshint('.jshintrc'))
|
|
|
|
.pipe(jshint.reporter('jshint-summary', cfg.summary))
|
2014-08-29 23:30:52 +08:00
|
|
|
.pipe(jshint.reporter('fail'))
|
|
|
|
// google compiler
|
|
|
|
.pipe(closureCompiler({
|
|
|
|
compilerPath: './build/compiler.jar',
|
|
|
|
fileName: 'gc.js',
|
|
|
|
compilerFlags: {
|
|
|
|
output_wrapper: '(function(){%output%}());'
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
;
|
2014-08-25 23:49:01 +08:00
|
|
|
});
|
|
|
|
|
2014-06-17 03:56:11 +08:00
|
|
|
// OTHER
|
|
|
|
regOtherMinTask('other:cookie', 'vendors/jquery-cookie/', 'jquery.cookie.js', 'jquery.cookie-1.4.0.min.js',
|
|
|
|
'/*! jquery.cookie v1.4.0 (c) 2013 Klaus Hartl | MIT */\n');
|
|
|
|
|
|
|
|
regOtherMinTask('other:ifvisible', 'vendors/ifvisible/', 'src/ifvisible.js', 'ifvisible.min.js',
|
|
|
|
'/*!ifvisible.js v1.0.0 (c) 2013 Serkan Yersen | MIT */\n');
|
|
|
|
|
2014-09-13 00:32:05 +08:00
|
|
|
regOtherMinTask('other:keymaster', 'vendors/keymaster/', 'keymaster.js', 'keymaster.min.js',
|
|
|
|
'/*!keymaster.js (c) 2011-2013 Thomas Fuchs | MIT */\n');
|
|
|
|
|
2014-06-17 03:56:11 +08:00
|
|
|
regOtherMinTask('other:wakeup', 'vendors/jquery-wakeup/', 'jquery.wakeup.js', 'jquery.wakeup.min.js',
|
|
|
|
'/*! jQuery WakeUp plugin (c) 2013 Paul Okopny <paul.okopny@gmail.com> | MIT */\n');
|
|
|
|
|
|
|
|
regOtherMinTask('other:mousewheel', 'vendors/jquery-mousewheel/', 'jquery.mousewheel.js', 'jquery.mousewheel-3.1.4.min.js',
|
|
|
|
'/*! jquery.mousewheel v3.1.4 (c) 2013 Brandon Aaron (http://brandon.aaron.sh) | MIT */\n');
|
|
|
|
|
|
|
|
regOtherMinTask('other:nano', 'vendors/jquery-nanoscroller/', 'jquery.nanoscroller.js', 'jquery.nanoscroller-0.7.min.js',
|
|
|
|
'/*! nanoScrollerJS v0.7 (c) 2013 James Florentino; modified by RainLoop Team | MIT */\n');
|
|
|
|
|
|
|
|
regOtherMinTask('other:inputosaurus', 'vendors/inputosaurus/', 'inputosaurus.js', 'inputosaurus.min.js',
|
|
|
|
'/*! Inputosaurus Text v0.1.6 (c) 2013 Dan Kielp <dan@sproutsocial.com>; modified by RainLoop Team | MIT */\n');
|
|
|
|
|
|
|
|
regOtherMinTask('other:pace', 'vendors/simple-pace/', 'simple-pace.js', 'simple-pace-1.0.min.js',
|
2014-08-14 17:26:58 +08:00
|
|
|
'/*! RainLoop Simple Pace v1.0 (c) 2014 RainLoop Team; Licensed under MIT */\n');
|
2014-06-17 03:56:11 +08:00
|
|
|
|
2014-08-29 23:30:52 +08:00
|
|
|
regOtherMinTask('other:rl', 'vendors/rl/', 'rl.js', 'rl-1.2.min.js',
|
|
|
|
'/*! RainLoop Index Helper v1.2 (c) 2014 RainLoop Team; Licensed under MIT */\n');
|
2014-06-17 03:56:11 +08:00
|
|
|
|
|
|
|
gulp.task('package-inc-release', function() {
|
|
|
|
fs.writeFileSync('package.json',
|
|
|
|
fs.readFileSync('package.json', 'utf8').replace(/"release":\s?"[\d]+",/, '"release": "' +
|
|
|
|
(1 + parseInt(pkg.release, 10)) + '",'));
|
|
|
|
});
|
|
|
|
|
|
|
|
// BUILD (RainLoop)
|
2014-06-25 05:05:29 +08:00
|
|
|
gulp.task('rainloop:copy', ['default'], function() {
|
2014-06-17 03:56:11 +08:00
|
|
|
|
|
|
|
var
|
|
|
|
versionFull = pkg.version + '.' + parseInt(pkg.release, 10),
|
|
|
|
dist = cfg.releasesPath + '/webmail/' + versionFull + '/src/'
|
|
|
|
;
|
|
|
|
|
|
|
|
fs.mkdirSync(dist, '0777', true);
|
|
|
|
fs.mkdirSync(dist + 'data');
|
|
|
|
fs.mkdirSync(dist + 'rainloop/v/' + versionFull, '0777', true);
|
|
|
|
|
|
|
|
return gulp.src('rainloop/v/' + cfg.devVersion + '/**/*', {base: 'rainloop/v/' + cfg.devVersion})
|
|
|
|
.pipe(gulp.dest(dist + 'rainloop/v/' + versionFull));
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('rainloop:setup', ['rainloop:copy'], function() {
|
|
|
|
|
|
|
|
var
|
|
|
|
versionFull = pkg.version + '.' + parseInt(pkg.release, 10),
|
|
|
|
dist = cfg.releasesPath + '/webmail/' + versionFull + '/src/'
|
|
|
|
;
|
|
|
|
|
2014-06-24 05:32:09 +08:00
|
|
|
fs.writeFileSync(dist + 'data/VERSION', versionFull);
|
2014-06-17 03:56:11 +08:00
|
|
|
fs.writeFileSync(dist + 'data/EMPTY', versionFull);
|
|
|
|
|
|
|
|
fs.writeFileSync(dist + 'index.php',
|
|
|
|
fs.readFileSync('index.php', 'utf8').replace('\'APP_VERSION\', \'0.0.0\'', '\'APP_VERSION\', \'' + versionFull + '\''));
|
|
|
|
|
|
|
|
fs.writeFileSync(dist + 'rainloop/v/' + versionFull + '/index.php.root', fs.readFileSync(dist + 'index.php'));
|
|
|
|
|
|
|
|
fs.unlinkSync(dist + 'rainloop/v/' + versionFull + '/static/css/less.css');
|
|
|
|
|
|
|
|
cfg.destPath = cfg.releasesPath + '/webmail/' + versionFull + '/';
|
|
|
|
cfg.cleanPath = dist;
|
|
|
|
cfg.zipSrcPath = dist;
|
|
|
|
cfg.zipFile = 'rainloop-' + versionFull + '.zip';
|
|
|
|
cfg.md5File = cfg.zipFile;
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('rainloop:zip', ['rainloop:copy', 'rainloop:setup'], function() {
|
|
|
|
return (cfg.destPath && cfg.zipSrcPath && cfg.zipFile) ?
|
|
|
|
zipDir(cfg.zipSrcPath, cfg.destPath, cfg.zipFile) : false;
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('rainloop:md5', ['rainloop:zip'], function() {
|
|
|
|
return (cfg.destPath && cfg.md5File) ?
|
|
|
|
renameFileWothMd5Hash(cfg.destPath + cfg.md5File) : false;
|
|
|
|
});
|
|
|
|
|
2014-08-31 05:33:34 +08:00
|
|
|
gulp.task('rainloop:clean', ['rainloop:copy', 'rainloop:setup', 'rainloop:zip'], function() {
|
2014-06-17 03:56:11 +08:00
|
|
|
return (cfg.cleanPath) ? cleanDir(cfg.cleanPath) : false;
|
|
|
|
});
|
|
|
|
|
|
|
|
// BUILD (OwnCloud)
|
|
|
|
gulp.task('rainloop:owncloud:copy', function() {
|
|
|
|
|
|
|
|
var
|
|
|
|
versionFull = pkg.ownCloudPackageVersion,
|
|
|
|
dist = cfg.releasesPath + '/owncloud/' + versionFull + '/src/'
|
|
|
|
;
|
|
|
|
|
|
|
|
fs.mkdirSync(dist, '0777', true);
|
|
|
|
fs.mkdirSync(dist + 'rainloop', '0777', true);
|
|
|
|
|
|
|
|
return gulp.src('build/owncloud/rainloop-app/**/*', {base: 'build/owncloud/rainloop-app/'})
|
|
|
|
.pipe(gulp.dest(dist + 'rainloop'));
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('rainloop:owncloud:setup', ['rainloop:owncloud:copy'], function() {
|
|
|
|
|
|
|
|
var
|
|
|
|
versionFull = pkg.ownCloudPackageVersion,
|
|
|
|
dist = cfg.releasesPath + '/owncloud/' + versionFull + '/src/'
|
|
|
|
;
|
|
|
|
|
|
|
|
fs.writeFileSync(dist + 'rainloop/appinfo/info.xml',
|
|
|
|
fs.readFileSync(dist + 'rainloop/appinfo/info.xml', 'utf8').replace('<version>0.0</version>', '<version>' + versionFull + '</version>'));
|
|
|
|
|
|
|
|
fs.writeFileSync(dist + 'rainloop/appinfo/version', versionFull);
|
|
|
|
fs.writeFileSync(dist + 'rainloop/VERSION', versionFull);
|
|
|
|
|
|
|
|
cfg.destPath = cfg.releasesPath + '/owncloud/' + versionFull + '/';
|
|
|
|
cfg.cleanPath = dist;
|
|
|
|
cfg.zipSrcPath = dist;
|
|
|
|
cfg.zipFile = 'rainloop-owncloud-app-' + versionFull + '.zip';
|
|
|
|
cfg.md5File = cfg.zipFile;
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('rainloop:owncloud:zip', ['rainloop:owncloud:copy', 'rainloop:owncloud:setup'], function() {
|
|
|
|
return (cfg.destPath && cfg.zipSrcPath && cfg.zipFile) ?
|
|
|
|
zipDir(cfg.zipSrcPath, cfg.destPath, cfg.zipFile) : false;
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('rainloop:owncloud:md5', ['rainloop:owncloud:zip'], function() {
|
|
|
|
return (cfg.destPath && cfg.md5File) ?
|
|
|
|
renameFileWothMd5Hash(cfg.destPath + cfg.md5File) : false;
|
|
|
|
});
|
|
|
|
|
2014-08-31 05:33:34 +08:00
|
|
|
gulp.task('rainloop:owncloud:clean', ['rainloop:owncloud:copy', 'rainloop:owncloud:setup', 'rainloop:owncloud:zip'], function() {
|
2014-06-17 03:56:11 +08:00
|
|
|
return (cfg.cleanPath) ? cleanDir(cfg.cleanPath) : false;
|
|
|
|
});
|
|
|
|
|
|
|
|
// MAIN
|
2014-09-19 21:31:14 +08:00
|
|
|
gulp.task('default', ['js:libs', 'js:boot', 'js:openpgp', 'js:min', 'css:main:min']);
|
2014-09-05 07:22:39 +08:00
|
|
|
gulp.task('fast', ['js:app', 'js:admin', 'js:chunks', 'css:main']);
|
2014-06-17 03:56:11 +08:00
|
|
|
|
2014-09-05 07:22:39 +08:00
|
|
|
gulp.task('rainloop', ['js:lint', 'rainloop:copy', 'rainloop:setup', 'rainloop:zip', 'rainloop:md5', 'rainloop:clean']);
|
2014-06-17 03:56:11 +08:00
|
|
|
gulp.task('rainloop+', ['rainloop', 'package-inc-release']);
|
|
|
|
|
|
|
|
gulp.task('owncloud', ['rainloop:owncloud:copy', 'rainloop:owncloud:setup', 'rainloop:owncloud:zip', 'rainloop:owncloud:md5', 'rainloop:owncloud:clean']);
|
|
|
|
|
|
|
|
//WATCH
|
2014-08-07 05:02:20 +08:00
|
|
|
gulp.task('watch', ['fast'], function() {
|
2014-08-25 23:49:01 +08:00
|
|
|
gulp.watch(cfg.paths.globjs, {interval: 500}, ['js:app', 'js:admin']);
|
|
|
|
gulp.watch(cfg.paths.less.main.watch, {interval: 500}, ['css:main']);
|
2014-06-17 03:56:11 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
// aliases
|
|
|
|
gulp.task('w', ['watch']);
|
|
|
|
gulp.task('f', ['fast']);
|
|
|
|
|
|
|
|
gulp.task('rl', ['rainloop']);
|
|
|
|
gulp.task('rl+', ['rainloop+']);
|
|
|
|
gulp.task('build', ['rainloop']);
|
|
|
|
gulp.task('build+', ['rainloop+']);
|
|
|
|
gulp.task('b', ['rainloop']);
|
|
|
|
gulp.task('b+', ['rainloop+']);
|
|
|
|
|
2014-08-25 23:49:01 +08:00
|
|
|
gulp.task('own', ['owncloud']);
|