2016-09-08 00:51:36 +02:00
|
|
|
|
var gulp = require('gulp'),
|
|
|
|
|
rimraf = require('rimraf'),
|
|
|
|
|
concat = require('gulp-concat'),
|
|
|
|
|
rename = require('gulp-rename'),
|
|
|
|
|
less = require('gulp-less'),
|
|
|
|
|
preprocess = require('gulp-preprocess'),
|
|
|
|
|
runSequence = require('run-sequence'),
|
|
|
|
|
jshint = require('gulp-jshint'),
|
2016-10-18 06:08:59 +02:00
|
|
|
|
merge = require('merge-stream'),
|
|
|
|
|
browserify = require('browserify'),
|
2016-10-26 03:13:59 +02:00
|
|
|
|
source = require('vinyl-source-stream'),
|
2017-02-08 06:18:26 +01:00
|
|
|
|
googleWebFonts = require('gulp-google-webfonts'),
|
2017-02-23 01:34:56 +01:00
|
|
|
|
webpack = require('webpack-stream')
|
|
|
|
|
jeditor = require("gulp-json-editor");
|
2016-09-08 00:51:36 +02:00
|
|
|
|
|
|
|
|
|
var paths = {};
|
2016-09-08 03:43:15 +02:00
|
|
|
|
paths.dist = './dist/';
|
|
|
|
|
paths.libDir = './src/lib/';
|
2016-09-08 00:51:36 +02:00
|
|
|
|
paths.npmDir = './node_modules/';
|
2016-09-08 03:43:15 +02:00
|
|
|
|
paths.popupDir = './src/popup/';
|
2016-09-08 00:51:36 +02:00
|
|
|
|
paths.lessDir = paths.popupDir + 'less/';
|
|
|
|
|
paths.cssDir = paths.popupDir + 'css/';
|
2016-10-26 03:13:59 +02:00
|
|
|
|
paths.webfontsDir = './src/webfonts/';
|
2016-09-08 00:51:36 +02:00
|
|
|
|
|
|
|
|
|
gulp.task('lint', function () {
|
|
|
|
|
return gulp.src(paths.popupDir + 'app/**/*.js')
|
|
|
|
|
.pipe(jshint())
|
|
|
|
|
.pipe(jshint.reporter('default'));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
gulp.task('build', function (cb) {
|
|
|
|
|
return runSequence(
|
|
|
|
|
'clean',
|
2017-02-08 06:18:26 +01:00
|
|
|
|
['browserify', 'webpack', 'lib', 'less', 'lint', 'webfonts'],
|
2016-09-08 00:51:36 +02:00
|
|
|
|
cb);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
gulp.task('clean:css', function (cb) {
|
|
|
|
|
return rimraf(paths.cssDir, cb);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
gulp.task('clean:lib', function (cb) {
|
|
|
|
|
return rimraf(paths.libDir, cb);
|
|
|
|
|
});
|
|
|
|
|
|
2016-10-26 03:13:59 +02:00
|
|
|
|
gulp.task('clean:fonts', function (cb) {
|
|
|
|
|
return rimraf(paths.webfontsDir, cb);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
gulp.task('clean', ['clean:css', 'clean:lib', 'clean:fonts']);
|
2016-09-08 00:51:36 +02:00
|
|
|
|
|
|
|
|
|
gulp.task('lib', ['clean:lib'], function () {
|
|
|
|
|
var libs = [
|
|
|
|
|
{
|
|
|
|
|
src: [
|
|
|
|
|
paths.npmDir + 'bootstrap/dist/**/*',
|
|
|
|
|
'!' + paths.npmDir + 'bootstrap/dist/**/npm.js',
|
2016-10-18 02:25:57 +02:00
|
|
|
|
'!' + paths.npmDir + 'bootstrap/dist/**/css/*theme*',
|
|
|
|
|
'!' + paths.npmDir + 'bootstrap/**/*.min*'
|
2016-09-08 00:51:36 +02:00
|
|
|
|
],
|
|
|
|
|
dest: paths.libDir + 'bootstrap'
|
|
|
|
|
},
|
|
|
|
|
{
|
2016-10-18 02:25:57 +02:00
|
|
|
|
src: paths.npmDir + 'font-awesome/css/font-awesome.css',
|
2016-09-08 00:51:36 +02:00
|
|
|
|
dest: paths.libDir + 'font-awesome/css'
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
src: paths.npmDir + 'font-awesome/fonts/*',
|
|
|
|
|
dest: paths.libDir + 'font-awesome/fonts'
|
|
|
|
|
},
|
|
|
|
|
{
|
2016-10-18 02:25:57 +02:00
|
|
|
|
src: paths.npmDir + 'jquery/dist/jquery.js',
|
2016-09-08 00:51:36 +02:00
|
|
|
|
dest: paths.libDir + 'jquery'
|
|
|
|
|
},
|
|
|
|
|
{
|
2016-10-18 02:25:57 +02:00
|
|
|
|
src: paths.npmDir + 'angular/angular.js',
|
2016-09-08 00:51:36 +02:00
|
|
|
|
dest: paths.libDir + 'angular'
|
|
|
|
|
},
|
2016-09-10 00:35:12 +02:00
|
|
|
|
{
|
|
|
|
|
src: paths.npmDir + 'angular-animate/angular-animate.js',
|
|
|
|
|
dest: paths.libDir + 'angular-animate'
|
|
|
|
|
},
|
2016-09-08 00:51:36 +02:00
|
|
|
|
{
|
2016-10-18 02:25:57 +02:00
|
|
|
|
src: paths.npmDir + 'angular-ui-router/release/angular-ui-router.js',
|
2016-09-08 00:51:36 +02:00
|
|
|
|
dest: paths.libDir + 'angular-ui-router'
|
|
|
|
|
},
|
2016-09-13 01:48:36 +02:00
|
|
|
|
{
|
2016-09-22 19:15:42 +02:00
|
|
|
|
src: [paths.npmDir + 'angular-toastr/dist/angular-toastr.tpls.js',
|
|
|
|
|
paths.npmDir + 'angular-toastr/dist/angular-toastr.css'],
|
2016-09-13 01:48:36 +02:00
|
|
|
|
dest: paths.libDir + 'angular-toastr'
|
|
|
|
|
},
|
2016-09-08 00:51:36 +02:00
|
|
|
|
{
|
2016-09-13 01:48:36 +02:00
|
|
|
|
src: paths.npmDir + 'ngclipboard/dist/ngclipboard.js',
|
2016-09-08 00:51:36 +02:00
|
|
|
|
dest: paths.libDir + 'ngclipboard'
|
|
|
|
|
},
|
2016-09-20 03:38:29 +02:00
|
|
|
|
{
|
|
|
|
|
src: paths.npmDir + 'angularjs-slider/dist/rzslider.js',
|
|
|
|
|
dest: paths.libDir + 'angularjs-slider'
|
|
|
|
|
},
|
2016-09-08 00:51:36 +02:00
|
|
|
|
{
|
2016-09-13 01:48:36 +02:00
|
|
|
|
src: paths.npmDir + 'clipboard/dist/clipboard.js',
|
2016-09-08 00:51:36 +02:00
|
|
|
|
dest: paths.libDir + 'clipboard'
|
2016-09-15 06:09:48 +02:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
src: paths.npmDir + 'q/q.js',
|
|
|
|
|
dest: paths.libDir + 'q'
|
2016-09-20 05:56:27 +02:00
|
|
|
|
},
|
|
|
|
|
{
|
2016-10-18 02:25:57 +02:00
|
|
|
|
src: [paths.npmDir + 'sweetalert/dist/sweetalert.css', paths.npmDir + 'sweetalert/dist/sweetalert-dev.js',
|
2016-09-22 19:15:42 +02:00
|
|
|
|
paths.npmDir + 'angular-sweetalert/SweetAlert.js'],
|
2016-09-20 05:56:27 +02:00
|
|
|
|
dest: paths.libDir + 'sweetalert'
|
2016-09-28 04:44:42 +02:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
src: [paths.npmDir + 'angulartics-google-analytics/lib/angulartics*.js',
|
|
|
|
|
paths.npmDir + 'angulartics/src/angulartics.js'
|
|
|
|
|
],
|
|
|
|
|
dest: paths.libDir + 'angulartics'
|
2016-12-08 05:01:02 +01:00
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
src: paths.npmDir + 'ng-infinite-scroll/build/ng-infinite-scroll.js',
|
|
|
|
|
dest: paths.libDir + 'ng-infinite-scroll'
|
2017-04-12 14:45:31 +02:00
|
|
|
|
},
|
|
|
|
|
{
|
2017-04-12 14:47:17 +02:00
|
|
|
|
src: paths.npmDir + 'papaparse/papaparse.js',
|
2017-04-12 14:45:31 +02:00
|
|
|
|
dest: paths.libDir + 'papaparse'
|
2016-09-08 00:51:36 +02:00
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
var tasks = libs.map(function (lib) {
|
|
|
|
|
return gulp.src(lib.src).pipe(gulp.dest(lib.dest));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return merge(tasks);
|
|
|
|
|
});
|
|
|
|
|
|
2017-02-08 06:18:26 +01:00
|
|
|
|
gulp.task('browserify', ['browserify:tldjs']);
|
|
|
|
|
|
|
|
|
|
gulp.task('browserify:tldjs', function () {
|
2016-10-18 06:08:59 +02:00
|
|
|
|
return browserify(paths.npmDir + 'tldjs/index.js', { standalone: 'tldjs' })
|
|
|
|
|
.bundle()
|
|
|
|
|
.pipe(source('tld.js'))
|
|
|
|
|
.pipe(gulp.dest(paths.libDir + 'tldjs'));
|
|
|
|
|
});
|
|
|
|
|
|
2017-02-08 06:18:26 +01:00
|
|
|
|
gulp.task('webpack', ['webpack:forge']);
|
|
|
|
|
|
|
|
|
|
gulp.task('webpack:forge', function () {
|
|
|
|
|
var forgeDir = paths.npmDir + '/node-forge/lib/';
|
|
|
|
|
|
|
|
|
|
return gulp.src([
|
|
|
|
|
forgeDir + 'pbkdf2.js',
|
|
|
|
|
forgeDir + 'aes.js',
|
|
|
|
|
forgeDir + 'hmac.js',
|
|
|
|
|
forgeDir + 'sha256.js',
|
|
|
|
|
forgeDir + 'random.js',
|
|
|
|
|
forgeDir + 'forge.js'
|
|
|
|
|
]).pipe(webpack({
|
|
|
|
|
output: {
|
|
|
|
|
filename: 'forge.js',
|
|
|
|
|
library: 'forge',
|
|
|
|
|
libraryTarget: 'umd'
|
|
|
|
|
},
|
|
|
|
|
node: {
|
|
|
|
|
Buffer: false,
|
|
|
|
|
process: false,
|
|
|
|
|
crypto: false,
|
|
|
|
|
setImmediate: false
|
|
|
|
|
}
|
|
|
|
|
})).pipe(gulp.dest(paths.libDir + 'forge'));
|
|
|
|
|
});
|
2016-10-18 06:08:59 +02:00
|
|
|
|
|
2016-09-08 00:51:36 +02:00
|
|
|
|
gulp.task('less', function () {
|
|
|
|
|
return gulp.src(paths.lessDir + 'popup.less')
|
|
|
|
|
.pipe(less())
|
|
|
|
|
.pipe(gulp.dest(paths.cssDir));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
gulp.task('watch', function () {
|
|
|
|
|
gulp.watch(paths.lessDir + '*.less', ['less']);
|
|
|
|
|
});
|
2016-09-22 06:12:49 +02:00
|
|
|
|
|
|
|
|
|
gulp.task('dist:clean', function (cb) {
|
|
|
|
|
return rimraf(paths.dist, cb);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
gulp.task('dist:move', function () {
|
|
|
|
|
var moves = [
|
|
|
|
|
{
|
|
|
|
|
src: ['src/**/*', '!src/popup/less{,/**/*}'],
|
|
|
|
|
dest: paths.dist
|
|
|
|
|
}
|
|
|
|
|
];
|
|
|
|
|
|
|
|
|
|
var tasks = moves.map(function (move) {
|
|
|
|
|
return gulp.src(move.src).pipe(gulp.dest(move.dest));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return merge(tasks);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
gulp.task('dist', ['build'], function (cb) {
|
|
|
|
|
return runSequence(
|
|
|
|
|
'dist:clean',
|
|
|
|
|
'dist:move',
|
|
|
|
|
cb);
|
|
|
|
|
});
|
2016-10-26 03:13:59 +02:00
|
|
|
|
|
2017-02-23 01:34:56 +01:00
|
|
|
|
gulp.task('dist-firefox', ['dist'], function (cb) {
|
|
|
|
|
gulp.src(paths.dist + 'manifest.json')
|
|
|
|
|
.pipe(jeditor(function (manifest) {
|
|
|
|
|
manifest.applications = {
|
|
|
|
|
gecko: {
|
2017-02-23 01:42:29 +01:00
|
|
|
|
id: "{446900e4-71c2-419f-a6a7-df9c091e268b}",
|
2017-02-23 01:34:56 +01:00
|
|
|
|
strict_min_version: "42.0"
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
return manifest;
|
|
|
|
|
}))
|
|
|
|
|
.pipe(gulp.dest(paths.dist));
|
|
|
|
|
});
|
|
|
|
|
|
2016-10-26 03:13:59 +02:00
|
|
|
|
gulp.task('webfonts', function () {
|
|
|
|
|
return gulp.src('./webfonts.list')
|
|
|
|
|
.pipe(googleWebFonts({}))
|
|
|
|
|
.pipe(gulp.dest(paths.webfontsDir))
|
|
|
|
|
;
|
|
|
|
|
});
|