|
|
@ -1,12 +1,10 @@ |
|
|
|
var packageJson = require('./package.json') |
|
|
|
var packageJson = require('./package.json') |
|
|
|
var gulp = require('gulp') |
|
|
|
var gulp = require('gulp') |
|
|
|
var $ = require('gulp-load-plugins')({lazy: false}) |
|
|
|
var $ = require('gulp-load-plugins')({ lazy: false }) |
|
|
|
var es = require('event-stream') |
|
|
|
|
|
|
|
var path = require('path') |
|
|
|
var path = require('path') |
|
|
|
var http = require('http') |
|
|
|
var http = require('http') |
|
|
|
var st = require('st') |
|
|
|
var st = require('st') |
|
|
|
var del = require('del') |
|
|
|
var del = require('del') |
|
|
|
var runSequence = require('run-sequence') |
|
|
|
|
|
|
|
var swPrecache = require('sw-precache') |
|
|
|
var swPrecache = require('sw-precache') |
|
|
|
var Server = require('karma').Server |
|
|
|
var Server = require('karma').Server |
|
|
|
|
|
|
|
|
|
|
@ -29,9 +27,9 @@ gulp.task('clean-templates', function () { |
|
|
|
gulp.task('usemin-index', function () { |
|
|
|
gulp.task('usemin-index', function () { |
|
|
|
return gulp.src('app/index.html') |
|
|
|
return gulp.src('app/index.html') |
|
|
|
.pipe($.usemin({ |
|
|
|
.pipe($.usemin({ |
|
|
|
html: [$.minifyHtml({empty: true})], |
|
|
|
html: [$.minifyHtml({ empty: true })], |
|
|
|
js: ['concat', $.ngAnnotate(), $.uglify({outSourceMap: false})], |
|
|
|
js: ['concat', $.ngAnnotate(), $.uglify({ outSourceMap: false })], |
|
|
|
css: ['concat', $.minifyCss({compatibility: true, keepBreaks: true})] |
|
|
|
css: ['concat', $.minifyCss({ compatibility: true, keepBreaks: true })] |
|
|
|
})) |
|
|
|
})) |
|
|
|
.pipe(gulp.dest('dist')) |
|
|
|
.pipe(gulp.dest('dist')) |
|
|
|
}) |
|
|
|
}) |
|
|
@ -39,8 +37,8 @@ gulp.task('usemin-index', function () { |
|
|
|
gulp.task('usemin-badbrowser', function () { |
|
|
|
gulp.task('usemin-badbrowser', function () { |
|
|
|
return gulp.src('app/badbrowser.html') |
|
|
|
return gulp.src('app/badbrowser.html') |
|
|
|
.pipe($.usemin({ |
|
|
|
.pipe($.usemin({ |
|
|
|
html: [$.minifyHtml({empty: true})], |
|
|
|
html: [$.minifyHtml({ empty: true })], |
|
|
|
css: ['concat', $.minifyCss({compatibility: true, keepBreaks: true})] |
|
|
|
css: ['concat', $.minifyCss({ compatibility: true, keepBreaks: true })] |
|
|
|
})) |
|
|
|
})) |
|
|
|
.pipe(gulp.dest('dist')) |
|
|
|
.pipe(gulp.dest('dist')) |
|
|
|
}) |
|
|
|
}) |
|
|
@ -52,16 +50,8 @@ gulp.task('imagemin', function () { |
|
|
|
.pipe(gulp.dest('dist/img')) |
|
|
|
.pipe(gulp.dest('dist/img')) |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
gulp.task('less', function () { |
|
|
|
|
|
|
|
gulp.src('app/less/*.less') |
|
|
|
|
|
|
|
.pipe($.less({ |
|
|
|
|
|
|
|
paths: [path.join(__dirname, 'less', 'includes')] |
|
|
|
|
|
|
|
})) |
|
|
|
|
|
|
|
.pipe(gulp.dest('app/css')) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gulp.task('standard', function () { |
|
|
|
gulp.task('standard', function () { |
|
|
|
gulp.src(['app/**/*.js', '!app/vendor/**/*', 'gulpfile.js']) |
|
|
|
return gulp.src(['app/**/*.js', '!app/vendor/**/*', 'gulpfile.js']) |
|
|
|
.pipe($.standard()) |
|
|
|
.pipe($.standard()) |
|
|
|
.pipe($.standard.reporter('default', { |
|
|
|
.pipe($.standard.reporter('default', { |
|
|
|
breakOnError: true |
|
|
|
breakOnError: true |
|
|
@ -73,36 +63,54 @@ gulp.task('copy-images', function () { |
|
|
|
.pipe(gulp.dest('dist/img')) |
|
|
|
.pipe(gulp.dest('dist/img')) |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
gulp.task('copy', function () { |
|
|
|
gulp.task('copy', gulp.parallel( |
|
|
|
return es.concat( |
|
|
|
function () { |
|
|
|
gulp.src(['app/favicon.ico', 'app/favicon_unread.ico', 'app/manifest.webapp', 'app/manifest.webapp.json', 'app/manifest.json', 'app/**/*worker.js']) |
|
|
|
return gulp.src(['app/favicon.ico', 'app/favicon_unread.ico', 'app/manifest.webapp', 'app/manifest.webapp.json', 'app/manifest.json', 'app/**/*worker.js']) |
|
|
|
.pipe(gulp.dest('dist')), |
|
|
|
.pipe(gulp.dest('dist')) |
|
|
|
gulp.src(['app/img/**/*.wav']) |
|
|
|
}, |
|
|
|
.pipe(gulp.dest('dist/img')), |
|
|
|
function () { |
|
|
|
// gulp.src(['app/fonts/*'])
|
|
|
|
return gulp.src(['app/img/**/*.wav']) |
|
|
|
// .pipe(gulp.dest('dist/fonts')),
|
|
|
|
.pipe(gulp.dest('dist/img')) |
|
|
|
gulp.src(['app/js/lib/polyfill.js', 'app/js/lib/bin_utils.js']) |
|
|
|
}, |
|
|
|
.pipe(gulp.dest('dist/js/lib')), |
|
|
|
function () { |
|
|
|
gulp.src('app/vendor/closure/long.js') |
|
|
|
return gulp.src(['app/js/lib/polyfill.js', 'app/js/lib/bin_utils.js']) |
|
|
|
.pipe(gulp.dest('dist/vendor/closure')), |
|
|
|
.pipe(gulp.dest('dist/js/lib')) |
|
|
|
gulp.src(['app/css/desktop.css', 'app/css/mobile.css']) |
|
|
|
}, |
|
|
|
.pipe(gulp.dest('dist/css')), |
|
|
|
function () { |
|
|
|
gulp.src('app/vendor/jsbn/jsbn_combined.js') |
|
|
|
return gulp.src('app/vendor/closure/long.js') |
|
|
|
.pipe(gulp.dest('dist/vendor/jsbn')), |
|
|
|
.pipe(gulp.dest('dist/vendor/closure')) |
|
|
|
gulp.src('app/vendor/leemon_bigint/bigint.js') |
|
|
|
}, |
|
|
|
.pipe(gulp.dest('dist/vendor/leemon_bigint')), |
|
|
|
function () { |
|
|
|
gulp.src('app/vendor/rusha/rusha.js') |
|
|
|
return gulp.src(['app/css/desktop.css', 'app/css/mobile.css']) |
|
|
|
.pipe(gulp.dest('dist/vendor/rusha')), |
|
|
|
.pipe(gulp.dest('dist/css')) |
|
|
|
gulp.src('app/vendor/cryptoJS/crypto.js') |
|
|
|
}, |
|
|
|
.pipe(gulp.dest('dist/vendor/cryptoJS')), |
|
|
|
function () { |
|
|
|
gulp.src(['app/nacl/mtproto_crypto.pexe', 'app/nacl/mtproto_crypto.nmf']) |
|
|
|
return gulp.src('app/vendor/jsbn/jsbn_combined.js') |
|
|
|
.pipe(gulp.dest('dist/nacl/')), |
|
|
|
.pipe(gulp.dest('dist/vendor/jsbn')) |
|
|
|
gulp.src('app/js/background.js') |
|
|
|
}, |
|
|
|
|
|
|
|
function () { |
|
|
|
|
|
|
|
return gulp.src('app/vendor/leemon_bigint/bigint.js') |
|
|
|
|
|
|
|
.pipe(gulp.dest('dist/vendor/leemon_bigint')) |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
function () { |
|
|
|
|
|
|
|
return gulp.src('app/vendor/rusha/rusha.js') |
|
|
|
|
|
|
|
.pipe(gulp.dest('dist/vendor/rusha')) |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
function () { |
|
|
|
|
|
|
|
return gulp.src('app/vendor/cryptoJS/crypto.js') |
|
|
|
|
|
|
|
.pipe(gulp.dest('dist/vendor/cryptoJS')) |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
function () { |
|
|
|
|
|
|
|
return gulp.src(['app/nacl/mtproto_crypto.pexe', 'app/nacl/mtproto_crypto.nmf']) |
|
|
|
|
|
|
|
.pipe(gulp.dest('dist/nacl/')) |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
function () { |
|
|
|
|
|
|
|
return gulp.src('app/js/background.js') |
|
|
|
.pipe(gulp.dest('dist/js')) |
|
|
|
.pipe(gulp.dest('dist/js')) |
|
|
|
) |
|
|
|
} |
|
|
|
}) |
|
|
|
)) |
|
|
|
|
|
|
|
|
|
|
|
gulp.task('copy-locales', function () { |
|
|
|
gulp.task('copy-locales', function (callback) { |
|
|
|
var langpackSrc = [] |
|
|
|
var langpackSrc = [] |
|
|
|
var ngSrc = [] |
|
|
|
var ngSrc = [] |
|
|
|
|
|
|
|
|
|
|
@ -110,23 +118,80 @@ gulp.task('copy-locales', function () { |
|
|
|
langpackSrc.push('app/js/locales/' + locale + '.json') |
|
|
|
langpackSrc.push('app/js/locales/' + locale + '.json') |
|
|
|
ngSrc.push('app/vendor/angular/i18n/angular-locale_' + locale + '.js') |
|
|
|
ngSrc.push('app/vendor/angular/i18n/angular-locale_' + locale + '.js') |
|
|
|
}) |
|
|
|
}) |
|
|
|
return es.concat( |
|
|
|
gulp.parallel( |
|
|
|
gulp.src(langpackSrc) |
|
|
|
function () { |
|
|
|
.pipe(gulp.dest('dist/js/locales/')), |
|
|
|
return gulp.src(langpackSrc) |
|
|
|
gulp.src(ngSrc) |
|
|
|
.pipe(gulp.dest('dist/js/locales/')) |
|
|
|
.pipe(gulp.dest('dist/vendor/angular/i18n/')) |
|
|
|
}, |
|
|
|
) |
|
|
|
function () { |
|
|
|
|
|
|
|
return gulp.src(ngSrc) |
|
|
|
|
|
|
|
.pipe(gulp.dest('dist/vendor/angular/i18n/')) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
)(callback) |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
gulp.task('compress-dist', ['build'], function () { |
|
|
|
gulp.task('clean', function () { |
|
|
|
return gulp.src('**/*', {cwd: path.join(process.cwd(), '/dist')}) |
|
|
|
return del(['dist/*', 'app/js/templates.js', 'app/css/*', '!dist/.git']) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gulp.task('less', function () { |
|
|
|
|
|
|
|
return gulp.src('app/less/*.less') |
|
|
|
|
|
|
|
.pipe($.less({ |
|
|
|
|
|
|
|
paths: [path.join(__dirname, 'less', 'includes')], |
|
|
|
|
|
|
|
javascriptEnabled: true |
|
|
|
|
|
|
|
})) |
|
|
|
|
|
|
|
.pipe(gulp.dest('app/css')) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gulp.task('disable-production', gulp.parallel( |
|
|
|
|
|
|
|
function () { |
|
|
|
|
|
|
|
return gulp.src('app/index.html') |
|
|
|
|
|
|
|
.pipe($.replace(/PRODUCTION_ONLY_BEGIN-->/g, 'PRODUCTION_ONLY_BEGIN')) |
|
|
|
|
|
|
|
.pipe($.replace(/<!--PRODUCTION_ONLY_END/g, 'PRODUCTION_ONLY_END')) |
|
|
|
|
|
|
|
.pipe(gulp.dest('app')) |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
function () { |
|
|
|
|
|
|
|
return gulp.src('app/**/*.js') |
|
|
|
|
|
|
|
.pipe($.replace(/PRODUCTION_ONLY_BEGIN(\*\/)?/g, 'PRODUCTION_ONLY_BEGIN')) |
|
|
|
|
|
|
|
.pipe($.replace(/(\/\*)?PRODUCTION_ONLY_END/g, 'PRODUCTION_ONLY_END')) |
|
|
|
|
|
|
|
.pipe(gulp.dest('app')) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gulp.task('enable-production', gulp.parallel( |
|
|
|
|
|
|
|
function () { |
|
|
|
|
|
|
|
return gulp.src('app/**/*.html') |
|
|
|
|
|
|
|
.pipe($.replace(/PRODUCTION_ONLY_BEGIN/g, 'PRODUCTION_ONLY_BEGIN-->')) |
|
|
|
|
|
|
|
.pipe($.replace(/PRODUCTION_ONLY_END/, '<!--PRODUCTION_ONLY_END')) |
|
|
|
|
|
|
|
.pipe(gulp.dest('app')) |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
function () { |
|
|
|
|
|
|
|
return gulp.src('app/**/*.js') |
|
|
|
|
|
|
|
.pipe($.replace(/PRODUCTION_ONLY_BEGIN(\*\/)?/g, 'PRODUCTION_ONLY_BEGIN*/')) |
|
|
|
|
|
|
|
.pipe($.replace(/(\/\*)?PRODUCTION_ONLY_END/g, '/*PRODUCTION_ONLY_END')) |
|
|
|
|
|
|
|
.pipe(gulp.dest('app')) |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gulp.task('build', gulp.series( |
|
|
|
|
|
|
|
'clean', |
|
|
|
|
|
|
|
gulp.parallel('less', 'templates'), |
|
|
|
|
|
|
|
'enable-production', |
|
|
|
|
|
|
|
'usemin-index', |
|
|
|
|
|
|
|
'usemin-badbrowser', |
|
|
|
|
|
|
|
gulp.parallel('copy', 'copy-locales', 'copy-images', 'disable-production'), |
|
|
|
|
|
|
|
'clean-templates' |
|
|
|
|
|
|
|
)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gulp.task('compress-dist', gulp.series('build', function () { |
|
|
|
|
|
|
|
return gulp.src('**/*', { cwd: path.join(process.cwd(), '/dist') }) |
|
|
|
.pipe($.zip('webogram_v' + packageJson.version + '.zip')) |
|
|
|
.pipe($.zip('webogram_v' + packageJson.version + '.zip')) |
|
|
|
.pipe(gulp.dest('releases')) |
|
|
|
.pipe(gulp.dest('releases')) |
|
|
|
}) |
|
|
|
})) |
|
|
|
|
|
|
|
|
|
|
|
gulp.task('cleanup-dist', ['compress-dist'], function () { |
|
|
|
gulp.task('cleanup-dist', gulp.series('compress-dist', function () { |
|
|
|
return del(['releases/**/*', '!releases/*.zip']) |
|
|
|
return del(['releases/**/*', '!releases/*.zip']) |
|
|
|
}) |
|
|
|
})) |
|
|
|
|
|
|
|
|
|
|
|
gulp.task('bump-version-manifests', function () { |
|
|
|
gulp.task('bump-version-manifests', function () { |
|
|
|
return gulp.src(['app/manifest.webapp', 'app/manifest.json']) |
|
|
|
return gulp.src(['app/manifest.webapp', 'app/manifest.json']) |
|
|
@ -146,32 +211,6 @@ gulp.task('bump-version-comments', function () { |
|
|
|
.pipe(gulp.dest('app')) |
|
|
|
.pipe(gulp.dest('app')) |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
gulp.task('enable-production', function () { |
|
|
|
|
|
|
|
return es.concat( |
|
|
|
|
|
|
|
gulp.src('app/**/*.html') |
|
|
|
|
|
|
|
.pipe($.replace(/PRODUCTION_ONLY_BEGIN/g, 'PRODUCTION_ONLY_BEGIN-->')) |
|
|
|
|
|
|
|
.pipe($.replace(/PRODUCTION_ONLY_END/, '<!--PRODUCTION_ONLY_END')) |
|
|
|
|
|
|
|
.pipe(gulp.dest('app')), |
|
|
|
|
|
|
|
gulp.src('app/**/*.js') |
|
|
|
|
|
|
|
.pipe($.replace(/PRODUCTION_ONLY_BEGIN(\*\/)?/g, 'PRODUCTION_ONLY_BEGIN*/')) |
|
|
|
|
|
|
|
.pipe($.replace(/(\/\*)?PRODUCTION_ONLY_END/g, '/*PRODUCTION_ONLY_END')) |
|
|
|
|
|
|
|
.pipe(gulp.dest('app')) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gulp.task('disable-production', function () { |
|
|
|
|
|
|
|
return es.concat( |
|
|
|
|
|
|
|
gulp.src('app/index.html') |
|
|
|
|
|
|
|
.pipe($.replace(/PRODUCTION_ONLY_BEGIN-->/g, 'PRODUCTION_ONLY_BEGIN')) |
|
|
|
|
|
|
|
.pipe($.replace(/<!--PRODUCTION_ONLY_END/g, 'PRODUCTION_ONLY_END')) |
|
|
|
|
|
|
|
.pipe(gulp.dest('app')), |
|
|
|
|
|
|
|
gulp.src('app/**/*.js') |
|
|
|
|
|
|
|
.pipe($.replace(/PRODUCTION_ONLY_BEGIN(\*\/)?/g, 'PRODUCTION_ONLY_BEGIN')) |
|
|
|
|
|
|
|
.pipe($.replace(/(\/\*)?PRODUCTION_ONLY_END/g, 'PRODUCTION_ONLY_END')) |
|
|
|
|
|
|
|
.pipe(gulp.dest('app')) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
var fileGlobs = [ |
|
|
|
var fileGlobs = [ |
|
|
|
'./dist/**/*', |
|
|
|
'./dist/**/*', |
|
|
|
'!dist/manifest.*', |
|
|
|
'!dist/manifest.*', |
|
|
@ -192,16 +231,16 @@ function writeServiceWorkerFile (rootDir, handleFetch, callback) { |
|
|
|
importScripts: ['js/lib/push_worker.js'], |
|
|
|
importScripts: ['js/lib/push_worker.js'], |
|
|
|
verbose: true, |
|
|
|
verbose: true, |
|
|
|
maximumFileSizeToCacheInBytes: 3004152, // about 3MB, default is "2097152" 2MB,
|
|
|
|
maximumFileSizeToCacheInBytes: 3004152, // about 3MB, default is "2097152" 2MB,
|
|
|
|
navigateFallback: "index.html", |
|
|
|
navigateFallback: 'index.html' |
|
|
|
} |
|
|
|
} |
|
|
|
swPrecache.write(path.join(rootDir, 'service_worker.js'), config, callback) |
|
|
|
swPrecache.write(path.join(rootDir, 'service_worker.js'), config, callback) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
gulp.task('generate-service-worker', ['build'], function (callback) { |
|
|
|
gulp.task('generate-service-worker', gulp.series('build', function (callback) { |
|
|
|
writeServiceWorkerFile('dist', true, callback) |
|
|
|
writeServiceWorkerFile('dist', true, callback) |
|
|
|
}) |
|
|
|
})) |
|
|
|
|
|
|
|
|
|
|
|
gulp.task('add-appcache-manifest', ['build'], function () { |
|
|
|
gulp.task('add-appcache-manifest', gulp.series('build', function () { |
|
|
|
return gulp.src(fileGlobs) |
|
|
|
return gulp.src(fileGlobs) |
|
|
|
.pipe($.manifest({ |
|
|
|
.pipe($.manifest({ |
|
|
|
timestamp: false, |
|
|
|
timestamp: false, |
|
|
@ -210,74 +249,83 @@ gulp.task('add-appcache-manifest', ['build'], function () { |
|
|
|
filename: 'webogram.appcache', |
|
|
|
filename: 'webogram.appcache', |
|
|
|
exclude: ['webogram.appcache', 'app.manifest'] |
|
|
|
exclude: ['webogram.appcache', 'app.manifest'] |
|
|
|
}) |
|
|
|
}) |
|
|
|
) |
|
|
|
) |
|
|
|
.pipe(gulp.dest('./dist')) |
|
|
|
.pipe(gulp.dest('./dist')) |
|
|
|
}) |
|
|
|
})) |
|
|
|
|
|
|
|
|
|
|
|
gulp.task('package-dev', function () { |
|
|
|
gulp.task('package-dev', gulp.parallel( |
|
|
|
return es.concat( |
|
|
|
function () { |
|
|
|
gulp.src('app/partials/*.html') |
|
|
|
return gulp.src('app/partials/*.html') |
|
|
|
.pipe($.angularTemplatecache('templates.js', { |
|
|
|
.pipe($.angularTemplatecache('templates.js', { |
|
|
|
root: 'partials', |
|
|
|
root: 'partials', |
|
|
|
module: 'myApp.templates', |
|
|
|
module: 'myApp.templates', |
|
|
|
standalone: true |
|
|
|
standalone: true |
|
|
|
})) |
|
|
|
})) |
|
|
|
.pipe(gulp.dest('dist_package/js')), |
|
|
|
.pipe(gulp.dest('dist_package/js')); |
|
|
|
|
|
|
|
}, |
|
|
|
gulp.src(['app/favicon.ico', 'app/favicon_unread.ico', 'app/manifest.webapp', 'app/manifest.json']) |
|
|
|
function () { |
|
|
|
.pipe(gulp.dest('dist_package')), |
|
|
|
return gulp.src(['app/favicon.ico', 'app/favicon_unread.ico', 'app/manifest.webapp', 'app/manifest.json']) |
|
|
|
gulp.src(['app/css/**/*']) |
|
|
|
.pipe(gulp.dest('dist_package')); |
|
|
|
.pipe(gulp.dest('dist_package/css')), |
|
|
|
}, |
|
|
|
gulp.src(['app/img/**/*']) |
|
|
|
function () { |
|
|
|
.pipe(gulp.dest('dist_package/img')), |
|
|
|
return gulp.src(['app/css/**/*']) |
|
|
|
gulp.src('app/vendor/**/*') |
|
|
|
.pipe(gulp.dest('dist_package/css')); |
|
|
|
.pipe(gulp.dest('dist_package/vendor')), |
|
|
|
}, |
|
|
|
gulp.src('app/**/*.json') |
|
|
|
function () { |
|
|
|
.pipe(gulp.dest('dist_package')), |
|
|
|
return gulp.src(['app/img/**/*']) |
|
|
|
|
|
|
|
.pipe(gulp.dest('dist_package/img')); |
|
|
|
gulp.src('app/**/*.html') |
|
|
|
}, |
|
|
|
|
|
|
|
function () { |
|
|
|
|
|
|
|
return gulp.src('app/vendor/**/*') |
|
|
|
|
|
|
|
.pipe(gulp.dest('dist_package/vendor')); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
function () { |
|
|
|
|
|
|
|
return gulp.src('app/**/*.json') |
|
|
|
|
|
|
|
.pipe(gulp.dest('dist_package')); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
function () { |
|
|
|
|
|
|
|
return gulp.src('app/**/*.html') |
|
|
|
.pipe($.replace(/PRODUCTION_ONLY_BEGIN/g, 'PRODUCTION_ONLY_BEGIN-->')) |
|
|
|
.pipe($.replace(/PRODUCTION_ONLY_BEGIN/g, 'PRODUCTION_ONLY_BEGIN-->')) |
|
|
|
.pipe($.replace(/PRODUCTION_ONLY_END/, '<!--PRODUCTION_ONLY_END')) |
|
|
|
.pipe($.replace(/PRODUCTION_ONLY_END/, '<!--PRODUCTION_ONLY_END')) |
|
|
|
.pipe(gulp.dest('dist_package')), |
|
|
|
.pipe(gulp.dest('dist_package')); |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
|
|
|
|
gulp.src('app/**/*.js') |
|
|
|
function () { |
|
|
|
|
|
|
|
return gulp.src('app/**/*.js') |
|
|
|
.pipe($.ngAnnotate()) |
|
|
|
.pipe($.ngAnnotate()) |
|
|
|
.pipe($.replace(/PRODUCTION_ONLY_BEGIN(\*\/)?/g, 'PRODUCTION_ONLY_BEGIN*/')) |
|
|
|
.pipe($.replace(/PRODUCTION_ONLY_BEGIN(\*\/)?/g, 'PRODUCTION_ONLY_BEGIN*/')) |
|
|
|
.pipe($.replace(/(\/\*)?PRODUCTION_ONLY_END/g, '/*PRODUCTION_ONLY_END')) |
|
|
|
.pipe($.replace(/(\/\*)?PRODUCTION_ONLY_END/g, '/*PRODUCTION_ONLY_END')) |
|
|
|
.pipe(gulp.dest('dist_package')) |
|
|
|
.pipe(gulp.dest('dist_package')); |
|
|
|
) |
|
|
|
} |
|
|
|
}) |
|
|
|
) |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
gulp.task('watchcss', function () { |
|
|
|
gulp.task('watchcss', function () { |
|
|
|
gulp.src('app/css/*.css') |
|
|
|
return gulp.src('app/css/*.css') |
|
|
|
.pipe($.livereload()) |
|
|
|
.pipe($.livereload()) |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
gulp.task('watchhtml', function () { |
|
|
|
gulp.task('watchhtml', function () { |
|
|
|
gulp.src('app/partials/**/*.html') |
|
|
|
return gulp.src('app/partials/**/*.html') |
|
|
|
.pipe($.livereload()) |
|
|
|
.pipe($.livereload()) |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
gulp.task('watch', ['server', 'less'], function () { |
|
|
|
|
|
|
|
$.livereload.listen({ basePath: 'app' }) |
|
|
|
|
|
|
|
gulp.watch('app/css/*.css', ['watchcss']) |
|
|
|
|
|
|
|
gulp.watch('app/less/**/*.less', ['less']) |
|
|
|
|
|
|
|
gulp.watch('app/partials/**/*.html', ['watchhtml']) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gulp.task('server', function (done) { |
|
|
|
gulp.task('server', function (done) { |
|
|
|
http.createServer( |
|
|
|
http.createServer( |
|
|
|
st({ path: __dirname, index: 'index.html', cache: false }) |
|
|
|
st({ path: __dirname, index: 'index.html', cache: false }) |
|
|
|
).listen(8000, done) |
|
|
|
).listen(8000, done) |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
gulp.task('clean', function () { |
|
|
|
gulp.task('watch', gulp.series(gulp.parallel('server', 'less'), function () { |
|
|
|
return del(['dist/*', 'app/js/templates.js', 'app/css/*', '!dist/.git']) |
|
|
|
$.livereload.listen({ basePath: 'app' }) |
|
|
|
}) |
|
|
|
gulp.watch('app/css/*.css', gulp.series('watchcss')) |
|
|
|
|
|
|
|
gulp.watch('app/less/**/*.less', gulp.series('less')) |
|
|
|
|
|
|
|
gulp.watch('app/partials/**/*.html', gulp.series('watchhtml')) |
|
|
|
|
|
|
|
})) |
|
|
|
|
|
|
|
|
|
|
|
gulp.task('bump', ['bump-version-manifests', 'bump-version-config'], function () { |
|
|
|
gulp.task('bump', gulp.series(gulp.parallel('bump-version-manifests', 'bump-version-config'), function () { |
|
|
|
gulp.start('bump-version-comments') |
|
|
|
gulp.start('bump-version-comments') |
|
|
|
}) |
|
|
|
})) |
|
|
|
|
|
|
|
|
|
|
|
// Single run of karma
|
|
|
|
// Single run of karma
|
|
|
|
gulp.task('karma-single', function (done) { |
|
|
|
gulp.task('karma-single', function (done) { |
|
|
@ -294,39 +342,17 @@ gulp.task('karma-tdd', function (done) { |
|
|
|
}, done).start() |
|
|
|
}, done).start() |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
gulp.task('test', function (callback) { |
|
|
|
gulp.task('test', gulp.series('templates', 'karma-single', 'clean-templates')) |
|
|
|
runSequence( |
|
|
|
|
|
|
|
'templates', 'karma-single', 'clean-templates', |
|
|
|
|
|
|
|
callback |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gulp.task('tdd', function (callback) { |
|
|
|
|
|
|
|
runSequence( |
|
|
|
|
|
|
|
'templates', 'karma-tdd', |
|
|
|
|
|
|
|
callback |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gulp.task('build', ['clean'], function (callback) { |
|
|
|
gulp.task('tdd', gulp.series('templates', 'karma-tdd')) |
|
|
|
runSequence( |
|
|
|
|
|
|
|
['less', 'templates'], |
|
|
|
|
|
|
|
'enable-production', |
|
|
|
|
|
|
|
'usemin-index', |
|
|
|
|
|
|
|
'usemin-badbrowser', |
|
|
|
|
|
|
|
['copy', 'copy-locales', 'copy-images', 'disable-production'], |
|
|
|
|
|
|
|
'clean-templates', |
|
|
|
|
|
|
|
callback |
|
|
|
|
|
|
|
) |
|
|
|
|
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gulp.task('package', ['cleanup-dist']) |
|
|
|
gulp.task('package', gulp.series('cleanup-dist')) |
|
|
|
|
|
|
|
|
|
|
|
gulp.task('publish', ['add-appcache-manifest', 'generate-service-worker']) |
|
|
|
gulp.task('publish', gulp.series('add-appcache-manifest', 'generate-service-worker')) |
|
|
|
|
|
|
|
|
|
|
|
gulp.task('deploy', function () { |
|
|
|
gulp.task('deploy', function () { |
|
|
|
return gulp.src('./dist/**/*') |
|
|
|
return gulp.src('./dist/**/*') |
|
|
|
.pipe($.ghPages()) |
|
|
|
.pipe($.ghPages()) |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
|
|
|
|
gulp.task('default', ['build']) |
|
|
|
gulp.task('default', gulp.series('build')) |
|
|
|