Merge pull request #3301 from charhate/gulp4-revert

Reverting gulp 4.0.2 upgrade
This commit is contained in:
charhate 2020-12-10 10:13:52 -08:00 committed by GitHub
commit 90531e79f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 64 additions and 60 deletions

View File

@ -29,24 +29,24 @@ var gulp = require('gulp'),
replace = require('gulp-replace'), replace = require('gulp-replace'),
argv = require('yargs').argv; argv = require('yargs').argv;
gulp.task('clean', async function (cb) { gulp.task('default', ['clean'], function () {
gulp.start('fonts', 'styles');
});
gulp.task('clean', function (cb) {
del(['.tmp', 'lemur/static/dist'], cb); del(['.tmp', 'lemur/static/dist'], cb);
}); });
gulp.task('default', gulp.series('clean', function () { gulp.task('test', function (done) {
gulp.start('fonts', 'styles');
}));
gulp.task('test', gulp.series(function (done) {
new karma.Server({ new karma.Server({
configFile: __dirname + '/karma.conf.js', configFile: __dirname + '/karma.conf.js',
singleRun: true singleRun: true
}, function() { }, function() {
done(); done();
}).start(); }).start();
})); });
gulp.task('dev:fonts', async function () { gulp.task('dev:fonts', function () {
var fileList = [ var fileList = [
'bower_components/bootstrap/dist/fonts/*', 'bower_components/bootstrap/dist/fonts/*',
'bower_components/fontawesome/fonts/*' 'bower_components/fontawesome/fonts/*'
@ -56,7 +56,7 @@ gulp.task('dev:fonts', async function () {
.pipe(gulp.dest('.tmp/fonts')); .pipe(gulp.dest('.tmp/fonts'));
}); });
gulp.task('dev:styles', async function () { gulp.task('dev:styles', function () {
var baseContent = '@import "bower_components/bootstrap/less/bootstrap.less";@import "bower_components/bootswatch/$theme$/variables.less";@import "bower_components/bootswatch/$theme$/bootswatch.less";@import "bower_components/bootstrap/less/utilities.less";'; var baseContent = '@import "bower_components/bootstrap/less/bootstrap.less";@import "bower_components/bootswatch/$theme$/variables.less";@import "bower_components/bootswatch/$theme$/bootswatch.less";@import "bower_components/bootstrap/less/utilities.less";';
var isBootswatchFile = function (file) { var isBootswatchFile = function (file) {
@ -74,6 +74,7 @@ gulp.task('dev:styles', async function () {
var fileList = [ var fileList = [
'bower_components/bootswatch/sandstone/bootswatch.less', 'bower_components/bootswatch/sandstone/bootswatch.less',
'bower_components/fontawesome/css/font-awesome.css', 'bower_components/fontawesome/css/font-awesome.css',
'bower_components/angular-spinkit/src/angular-spinkit.css',
'bower_components/angular-chart.js/dist/angular-chart.css', 'bower_components/angular-chart.js/dist/angular-chart.css',
'bower_components/angular-loading-bar/src/loading-bar.css', 'bower_components/angular-loading-bar/src/loading-bar.css',
'bower_components/angular-ui-switch/angular-ui-switch.css', 'bower_components/angular-ui-switch/angular-ui-switch.css',
@ -99,7 +100,7 @@ gulp.task('dev:styles', async function () {
// http://stackoverflow.com/questions/21719833/gulp-how-to-add-src-files-in-the-middle-of-a-pipe // http://stackoverflow.com/questions/21719833/gulp-how-to-add-src-files-in-the-middle-of-a-pipe
// https://github.com/gulpjs/gulp/blob/master/docs/recipes/using-multiple-sources-in-one-task.md // https://github.com/gulpjs/gulp/blob/master/docs/recipes/using-multiple-sources-in-one-task.md
return merge(stream, gulp.src(['.tmp/styles/font-awesome.css', '.tmp/styles/lemur.css'], { allowEmpty: true })) return merge(stream, gulp.src(['.tmp/styles/font-awesome.css', '.tmp/styles/lemur.css']))
.pipe(concat('style-' + themeName + '.css')); .pipe(concat('style-' + themeName + '.css'));
}))) })))
.pipe(plumber()) .pipe(plumber())
@ -128,14 +129,14 @@ function string_src(filename, string) {
return src; return src;
} }
gulp.task('dev:scripts', async function () { gulp.task('dev:scripts', function () {
return gulp.src(['lemur/static/app/angular/**/*.js']) return gulp.src(['lemur/static/app/angular/**/*.js'])
.pipe(jshint()) .pipe(jshint())
.pipe(jshint.reporter('jshint-stylish')) .pipe(jshint.reporter('jshint-stylish'))
.pipe(size()); .pipe(size());
}); });
gulp.task('build:extras', async function () { gulp.task('build:extras', function () {
return gulp.src(['lemur/static/app/*.*', '!lemur/static/app/*.html']) return gulp.src(['lemur/static/app/*.*', '!lemur/static/app/*.html'])
.pipe(gulp.dest('lemur/static/dist')); .pipe(gulp.dest('lemur/static/dist'));
}); });
@ -161,7 +162,7 @@ function injectHtml(isDev) {
})) }))
.pipe( .pipe(
gulpif(!isDev, gulpif(!isDev,
inject(gulp.src('lemur/static/dist/ngviews/ngviews.min.js', { allowEmpty: true }), { inject(gulp.src('lemur/static/dist/ngviews/ngviews.min.js'), {
starttag: '<!-- inject:ngviews -->', starttag: '<!-- inject:ngviews -->',
addRootSlash: false addRootSlash: false
}) })
@ -169,11 +170,15 @@ function injectHtml(isDev) {
).pipe(gulp.dest('.tmp/')); ).pipe(gulp.dest('.tmp/'));
} }
gulp.task('dev:inject', gulp.series(['dev:styles', 'dev:scripts'], function () { gulp.task('dev:inject', ['dev:styles', 'dev:scripts'], function () {
return injectHtml(true); return injectHtml(true);
})); });
gulp.task('build:ngviews', async function () { gulp.task('build:inject', ['dev:styles', 'dev:scripts', 'build:ngviews'], function () {
return injectHtml(false);
});
gulp.task('build:ngviews', function () {
return gulp.src(['lemur/static/app/angular/**/*.html']) return gulp.src(['lemur/static/app/angular/**/*.html'])
.pipe(minifyHtml({ .pipe(minifyHtml({
empty: true, empty: true,
@ -184,11 +189,7 @@ gulp.task('build:ngviews', async function () {
.pipe(size()); .pipe(size());
}); });
gulp.task('build:inject', gulp.series(['dev:styles', 'dev:scripts', 'build:ngviews'], function () { gulp.task('build:html', ['dev:styles', 'dev:scripts', 'build:ngviews', 'build:inject'], function () {
return injectHtml(false);
}));
gulp.task('build:html', gulp.series('build:inject', function () {
var jsFilter = filter(['**/*.js'], {'restore': true}); var jsFilter = filter(['**/*.js'], {'restore': true});
var cssFilter = filter(['**/*.css'], {'restore': true}); var cssFilter = filter(['**/*.css'], {'restore': true});
@ -202,14 +203,14 @@ gulp.task('build:html', gulp.series('build:inject', function () {
.pipe(useref()) .pipe(useref())
.pipe(gulp.dest('lemur/static/dist')) .pipe(gulp.dest('lemur/static/dist'))
.pipe(size()); .pipe(size());
})); });
gulp.task('build:fonts', gulp.series('dev:fonts', function () { gulp.task('build:fonts', ['dev:fonts'], function () {
return gulp.src('.tmp/fonts/**/*') return gulp.src('.tmp/fonts/**/*')
.pipe(gulp.dest('lemur/static/dist/fonts')); .pipe(gulp.dest('lemur/static/dist/fonts'));
})); });
gulp.task('build:images', async function () { gulp.task('build:images', function () {
return gulp.src('lemur/static/app/images/**/*') return gulp.src('lemur/static/app/images/**/*')
.pipe(cache(imagemin({ .pipe(cache(imagemin({
optimizationLevel: 3, optimizationLevel: 3,
@ -220,8 +221,8 @@ gulp.task('build:images', async function () {
.pipe(size()); .pipe(size());
}); });
gulp.task('package:strip', async function () { gulp.task('package:strip', function () {
return gulp.src('lemur/static/dist/scripts/main*') return gulp.src(['lemur/static/dist/scripts/main*'])
.pipe(replace('http:\/\/localhost:3000', '')) .pipe(replace('http:\/\/localhost:3000', ''))
.pipe(replace('http:\/\/localhost:8000', '')) .pipe(replace('http:\/\/localhost:8000', ''))
.pipe(useref()) .pipe(useref())
@ -229,22 +230,7 @@ gulp.task('package:strip', async function () {
.pipe(size()); .pipe(size());
}); });
gulp.task('addUrlContextPath:revision', async function(){ gulp.task('addUrlContextPath',['addUrlContextPath:revreplace'], function(){
return gulp.src(['lemur/static/dist/**/*.css','lemur/static/dist/**/*.js'])
.pipe(rev())
.pipe(gulp.dest('lemur/static/dist'))
.pipe(rev.manifest())
.pipe(gulp.dest('lemur/static/dist'))
});
gulp.task('addUrlContextPath:revreplace', gulp.series('addUrlContextPath:revision', function(){
var manifest = gulp.src("lemur/static/dist/rev-manifest.json", { allowEmpty: true });
var urlContextPathExists = argv.urlContextPath ? true : false;
return gulp.src( "lemur/static/dist/index.html")
.pipe(gulp.dest('lemur/static/dist'));
}));
gulp.task('addUrlContextPath', gulp.series('addUrlContextPath:revreplace', async function(){
var urlContextPathExists = argv.urlContextPath ? true : false; var urlContextPathExists = argv.urlContextPath ? true : false;
['lemur/static/dist/scripts/main*.js', ['lemur/static/dist/scripts/main*.js',
'lemur/static/dist/angular/**/*.html'] 'lemur/static/dist/angular/**/*.html']
@ -256,8 +242,23 @@ gulp.task('addUrlContextPath', gulp.series('addUrlContextPath:revreplace', async
return file.base; return file.base;
})) }))
}) })
})); });
gulp.task('addUrlContextPath:revision', function(){
return gulp.src(['lemur/static/dist/**/*.css','lemur/static/dist/**/*.js'])
.pipe(rev())
.pipe(gulp.dest('lemur/static/dist'))
.pipe(rev.manifest())
.pipe(gulp.dest('lemur/static/dist'))
})
gulp.task('addUrlContextPath:revreplace', ['addUrlContextPath:revision'], function(){
var manifest = gulp.src("lemur/static/dist/rev-manifest.json");
var urlContextPathExists = argv.urlContextPath ? true : false;
return gulp.src( "lemur/static/dist/index.html")
.pipe(gulp.dest('lemur/static/dist'));
})
gulp.task('build', gulp.series(['build:images', 'build:fonts', 'build:html', 'build:extras'])); gulp.task('build', ['build:ngviews', 'build:inject', 'build:images', 'build:fonts', 'build:html', 'build:extras']);
gulp.task('package', gulp.series(['addUrlContextPath', 'package:strip'])); gulp.task('package', ['addUrlContextPath', 'package:strip']);

View File

@ -38,16 +38,7 @@ function browserSyncInit(baseDir, files, browser) {
} }
gulp.task('watch', gulp.series(['dev:inject', 'dev:fonts'], function (done) { gulp.task('serve', ['watch'], function () {
gulp.watch('app/styles/**/*.less', gulp.parallel('dev:styles'));
gulp.watch('app/styles/**/*.css', gulp.parallel('dev:styles'));
gulp.watch('app/**/*.js', gulp.parallel('dev:scripts'));
gulp.watch('app/images/**/*', gulp.parallel('build:images'));
gulp.watch('bower.json', gulp.parallel('dev:inject'));
done();
}));
gulp.task('serve', gulp.series('watch', function () {
browserSyncInit([ browserSyncInit([
'.tmp', '.tmp',
'lemur/static/app' 'lemur/static/app'
@ -60,9 +51,9 @@ gulp.task('serve', gulp.series('watch', function () {
'lemur/static/app/angular/**/*', 'lemur/static/app/angular/**/*',
'lemur/static/app/index.html' 'lemur/static/app/index.html'
]); ]);
})); });
gulp.task('serve:dist', gulp.series('build', function () { gulp.task('serve:dist', ['build'], function () {
browserSyncInit('lemur/static/dist'); browserSyncInit('lemur/static/dist');
})); });

12
gulp/watch.js Normal file
View File

@ -0,0 +1,12 @@
'use strict';
var gulp = require('gulp');
gulp.task('watch', ['dev:styles', 'dev:scripts', 'dev:inject', 'dev:fonts'] ,function () {
gulp.watch('app/styles/**/*.less', ['dev:styles']);
gulp.watch('app/styles/**/*.css', ['dev:styles']);
gulp.watch('app/**/*.js', ['dev:scripts']);
gulp.watch('app/images/**/*', ['build:images']);
gulp.watch('bower.json', ['dev:inject']);
});

View File

@ -58,7 +58,7 @@
"test": "gulp test" "test": "gulp test"
}, },
"devDependencies": { "devDependencies": {
"gulp": "^4.0.2", "gulp": "^3.9.1",
"jshint": "^2.11.0", "jshint": "^2.11.0",
"karma-chrome-launcher": "^2.0.0" "karma-chrome-launcher": "^2.0.0"
} }