Update to Gulp 4.x.

This commit is contained in:
Christopher Charbonneau Wells 2018-07-15 10:12:55 -07:00
parent 2701aadc8d
commit 3413d7110c
16 changed files with 2483 additions and 1059 deletions

View File

@ -595,7 +595,6 @@ in the [`babybuddy/management/commands`](babybuddy/management/commands) folder.
- [`gulp`](#gulp)
- [`gulp build`](#build)
- [`gulp collectstatic`](#collectstatic)
- [`gulp compress`](#compress)
- [`gulp coverage`](#coverage)
- [`gulp extras`](#extras)
- [`gulp fake`](#fake)
@ -624,13 +623,6 @@ the `babybuddy/static` folder, so generally `gulp build` should be run before
this command for production deployments. Gulp also passes along
non-overlapping arguments for this command, e.g. `--no-input`.
#### `compress`
:exclamation: *DEPRECATED* :exclamation:
Compresses built scripts and styles. This command has been deprecated in favor
of WhiteNoise's compression as part of the `collectstatic` command.
#### `coverage`
Create a test coverage report. See [`.coveragerc`](.coveragerc) for default

View File

@ -2,14 +2,6 @@ var basePath = 'babybuddy/static/babybuddy/';
module.exports = {
basePath: basePath,
compressConfig: {
scripts: {
dest: basePath + 'js/'
},
styles: {
dest: basePath + 'css/'
}
},
extrasConfig: {
fonts: {
dest: basePath + 'fonts/',
@ -35,8 +27,7 @@ module.exports = {
'node_modules/popper.js/dist/umd/popper.js',
'node_modules/bootstrap/dist/js/bootstrap.js',
'node_modules/moment/moment.js',
'node_modules/tempusdominus-bootstrap-4/build/js/tempusdominus-bootstrap-4.js',
'node_modules/visibilityjs/lib/visibility.core.js'
'node_modules/tempusdominus-bootstrap-4/build/js/tempusdominus-bootstrap-4.js'
],
graph: [
'node_modules/plotly.js/dist/plotly-cartesian.js'
@ -60,11 +51,11 @@ module.exports = {
},
watchConfig: {
scriptsGlob: [
'**/static_src/js/**/*.js',
'*/static_src/js/**/*.js',
'!babybuddy/static/js/'
],
stylesGlob: [
'**/static_src/scss/**/*.scss'
'*/static_src/scss/**/*.scss'
]
}
};

179
gulpfile.js Normal file
View File

@ -0,0 +1,179 @@
var gulp = require('gulp');
var concat = require('gulp-concat');
var flatten = require('gulp-flatten');
var pump = require('pump');
var sass = require('gulp-sass');
var sassGlob = require('gulp-sass-glob');
var sassLint = require('gulp-sass-lint');
var spawn = require('child_process').spawn;
var config = require('./gulpfile.config.js');
function extras(cb) {
pump([
gulp.src(config.extrasConfig.fonts.files),
gulp.dest(config.extrasConfig.fonts.dest)
], cb);
pump([
gulp.src(config.extrasConfig.images.files),
flatten({ subPath: 3 }),
gulp.dest(config.extrasConfig.images.dest)
], cb);
pump([
gulp.src(config.extrasConfig.logo.files),
flatten({ subPath: 3 }),
gulp.dest(config.extrasConfig.logo.dest)
], cb);
pump([
gulp.src(config.extrasConfig.root.files),
gulp.dest(config.extrasConfig.root.dest)
], cb);
}
gulp.task('extras', extras);
function scripts(cb) {
pump([
gulp.src(config.scriptsConfig.vendor),
concat('vendor.js'),
gulp.dest(config.scriptsConfig.dest)
], cb);
pump([
gulp.src(config.scriptsConfig.graph),
concat('graph.js'),
gulp.dest(config.scriptsConfig.dest)
], cb);
pump([
gulp.src(config.scriptsConfig.app),
concat('app.js'),
gulp.dest(config.scriptsConfig.dest)
], cb);
}
gulp.task('scripts', scripts);
function styles(cb) {
pump([
gulp.src(config.stylesConfig.vendor),
concat('vendor.css'),
gulp.dest(config.stylesConfig.dest)
], cb);
pump([
gulp.src(config.stylesConfig.app),
sassGlob({ignorePaths: config.stylesConfig.ignore}),
sass().on('error', sass.logError),
concat('app.css'),
gulp.dest(config.stylesConfig.dest)
], cb);
}
gulp.task('styles', styles);
gulp.task('build', gulp.parallel(extras, scripts, styles));
function watch() {
gulp.watch(config.watchConfig.scriptsGlob, scripts);
gulp.watch(config.watchConfig.stylesGlob, styles);
}
gulp.task('watch', watch);
function lint(cb) {
var command = ['run', 'flake8', '--exclude=etc,migrations,manage.py,node_modules,settings'];
command = command.concat(process.argv.splice(3));
spawn('pipenv', command, { stdio: 'inherit' }).on('exit', cb);
pump([
gulp.src(config.watchConfig.stylesGlob),
sassLint({
rules: {
'declarations-before-nesting': 1,
'indentation': [ 1, { 'size': 4 } ],
'no-ids': 0,
'no-vendor-prefixes': 2,
'placeholder-in-extend': 0,
'property-sort-order': 0
}
}),
sassLint.format(),
sassLint.failOnError()
], cb);
}
gulp.task('lint', lint);
function test(cb) {
var command = ['run', 'python', 'manage.py', 'test'];
command = command.concat(process.argv.splice(3));
spawn('pipenv', command, { stdio: 'inherit' }).on('exit', cb);
}
gulp.task('test', test);
function coverage(cb) {
spawn(
'pipenv',
[
'run',
'coverage',
'run',
'manage.py',
'test'
],
{
stdio: 'inherit'
}
).on('exit', cb);
}
gulp.task('coverage', coverage);
gulp.task('collectstatic', function(cb) {
var command = ['run', 'python', 'manage.py', 'collectstatic'];
command = command.concat(process.argv.splice(3));
spawn('pipenv', command, { stdio: 'inherit' }).on('exit', cb);
});
gulp.task('fake', function(cb) {
var command = ['run', 'python', 'manage.py', 'fake'];
command = command.concat(process.argv.splice(3));
spawn('pipenv', command, { stdio: 'inherit' }).on('exit', cb);
});
gulp.task('migrate', function(cb) {
var command = ['run', 'python', 'manage.py', 'migrate'];
command = command.concat(process.argv.splice(3));
spawn('pipenv', command, { stdio: 'inherit' }).on('exit', cb);
});
gulp.task('makemigrations', function(cb) {
var command = ['run', 'python', 'manage.py', 'makemigrations'];
command = command.concat(process.argv.splice(3));
spawn('pipenv', command, { stdio: 'inherit' }).on('exit', cb);
});
gulp.task('reset', function(cb) {
spawn(
'pipenv',
[
'run',
'python',
'manage.py',
'reset',
'--no-input'
],
{
stdio: 'inherit'
}
).on('exit', cb);
});
gulp.task('runserver', function(cb) {
var command = ['run', 'python', 'manage.py', 'runserver'];
command = command.concat(process.argv.splice(3));
spawn('pipenv', command, { stdio: 'inherit' }).on('exit', cb);
});
gulp.task('default', gulp.series('build', gulp.parallel(watch, 'runserver')));

View File

@ -1,4 +0,0 @@
var requireDir = require('require-dir');
requireDir('./tasks', { recurse: true });

View File

@ -1,4 +0,0 @@
const gulp = require('gulp');
gulp.task('build', ['scripts', 'styles', 'extras']);

View File

@ -1,63 +0,0 @@
var gulp = require('gulp');
var concat = require('gulp-concat');
var csso = require('gulp-csso');
var pump = require('pump');
var uglify = require('gulp-uglify');
var basePath = require('../config.js').basePath;
var compressConfig = require('../config.js').compressConfig;
gulp.task('compress', [
'compress:scripts:app',
'compress:styles:app',
'compress:scripts:vendor',
'compress:styles:vendor',
'compress:scripts:graph'
]);
gulp.task('compress:scripts:app', ['scripts:app'], function (cb) {
pump([
gulp.src(basePath + 'js/app.js'),
concat('app.min.js'),
uglify(),
gulp.dest(compressConfig.scripts.dest)
], cb);
});
gulp.task('compress:scripts:vendor', ['scripts:vendor'], function (cb) {
pump([
gulp.src(basePath + 'js/vendor.js'),
concat('vendor.min.js'),
uglify(),
gulp.dest(compressConfig.scripts.dest)
], cb);
});
gulp.task('compress:scripts:graph', ['scripts:graph'], function (cb) {
pump([
gulp.src(basePath + 'js/graph.js'),
concat('graph.min.js'),
uglify(),
gulp.dest(compressConfig.scripts.dest)
], cb);
});
gulp.task('compress:styles:app', ['styles:app'], function (cb) {
pump([
gulp.src(basePath + 'css/app.css'),
concat('app.min.css'),
csso(),
gulp.dest(compressConfig.styles.dest)
], cb);
});
gulp.task('compress:styles:vendor', ['styles:vendor'], function (cb) {
pump([
gulp.src(basePath + 'css/vendor.css'),
concat('vendor.min.css'),
csso(),
gulp.dest(compressConfig.styles.dest)
], cb);
});

View File

@ -1,8 +0,0 @@
var gulp = require('gulp');
var runSequence = require('run-sequence');
gulp.task('default', function(cb) {
runSequence(['build', 'watch'], 'runserver', cb);
});

View File

@ -1,39 +0,0 @@
var gulp = require('gulp');
var flatten = require('gulp-flatten');
var pump = require('pump');
var extrasConfig = require('../config.js').extrasConfig;
gulp.task('extras', ['extras:fonts', 'extras:images', 'extras:logo', 'extras:root']);
gulp.task('extras:fonts', function(cb) {
pump([
gulp.src(extrasConfig.fonts.files),
gulp.dest(extrasConfig.fonts.dest)
], cb);
});
gulp.task('extras:images', function(cb) {
pump([
gulp.src(extrasConfig.images.files),
flatten({ subPath: 3 }),
gulp.dest(extrasConfig.images.dest)
], cb);
});
gulp.task('extras:logo', function(cb) {
pump([
gulp.src(extrasConfig.logo.files),
flatten({ subPath: 3 }),
gulp.dest(extrasConfig.logo.dest)
], cb);
});
gulp.task('extras:root', function(cb) {
pump([
gulp.src(extrasConfig.root.files),
gulp.dest(extrasConfig.root.dest)
], cb);
});

View File

@ -1,34 +0,0 @@
var gulp = require('gulp');
var sassLint = require('gulp-sass-lint');
var pump = require('pump');
var spawn = require('child_process').spawn;
var watchConfig = require('../config.js').watchConfig;
gulp.task('lint', ['lint:styles', 'lint:python']);
gulp.task('lint:python', function(cb) {
var command = ['run', 'flake8', '--exclude=etc,migrations,manage.py,node_modules,settings'];
command = command.concat(process.argv.splice(3));
spawn('pipenv', command, { stdio: 'inherit' }).on('exit', cb);
});
gulp.task('lint:styles', function(cb) {
pump([
gulp.src(watchConfig.stylesGlob),
sassLint({
rules: {
'declarations-before-nesting': 1,
'indentation': [ 1, { 'size': 4 } ],
'no-ids': 0,
'no-vendor-prefixes': 2,
'placeholder-in-extend': 0,
'property-sort-order': 0
}
}),
sassLint.format(),
sassLint.failOnError()
], cb);
});

View File

@ -1,51 +0,0 @@
var gulp = require('gulp');
var spawn = require('child_process').spawn;
gulp.task('collectstatic', function(cb) {
var command = ['run', 'python', 'manage.py', 'collectstatic'];
command = command.concat(process.argv.splice(3));
spawn('pipenv', command, { stdio: 'inherit' }).on('exit', cb);
});
gulp.task('fake', function(cb) {
var command = ['run', 'python', 'manage.py', 'fake'];
command = command.concat(process.argv.splice(3));
spawn('pipenv', command, { stdio: 'inherit' }).on('exit', cb);
});
gulp.task('migrate', function(cb) {
var command = ['run', 'python', 'manage.py', 'migrate'];
command = command.concat(process.argv.splice(3));
spawn('pipenv', command, { stdio: 'inherit' }).on('exit', cb);
});
gulp.task('makemigrations', function(cb) {
var command = ['run', 'python', 'manage.py', 'makemigrations'];
command = command.concat(process.argv.splice(3));
spawn('pipenv', command, { stdio: 'inherit' }).on('exit', cb);
});
gulp.task('reset', function(cb) {
spawn(
'pipenv',
[
'run',
'python',
'manage.py',
'reset',
'--no-input'
],
{
stdio: 'inherit'
}
).on('exit', cb);
});
gulp.task('runserver', function(cb) {
var command = ['run', 'python', 'manage.py', 'runserver'];
command = command.concat(process.argv.splice(3));
spawn('pipenv', command, { stdio: 'inherit' }).on('exit', cb);
});

View File

@ -1,33 +0,0 @@
var gulp = require('gulp');
var concat = require('gulp-concat');
var pump = require('pump');
var scriptsConfig = require('../config.js').scriptsConfig;
gulp.task('scripts', ['scripts:vendor', 'scripts:graph', 'scripts:app']);
gulp.task('scripts:vendor', function(cb) {
pump([
gulp.src(scriptsConfig.vendor),
concat('vendor.js'),
gulp.dest(scriptsConfig.dest)
], cb);
});
gulp.task('scripts:graph', function(cb) {
pump([
gulp.src(scriptsConfig.graph),
concat('graph.js'),
gulp.dest(scriptsConfig.dest)
], cb);
});
gulp.task('scripts:app', function(cb) {
pump([
gulp.src(scriptsConfig.app),
concat('app.js'),
gulp.dest(scriptsConfig.dest)
], cb);
});

View File

@ -1,29 +0,0 @@
var gulp = require('gulp');
var concat = require('gulp-concat');
var pump = require('pump');
var sass = require('gulp-sass');
var sassGlob = require('gulp-sass-glob');
var stylesConfig = require('../config.js').stylesConfig;
gulp.task('styles', ['styles:vendor', 'styles:app']);
gulp.task('styles:vendor', function(cb) {
pump([
gulp.src(stylesConfig.vendor),
concat('vendor.css'),
gulp.dest(stylesConfig.dest)
], cb);
});
gulp.task('styles:app', function (cb) {
pump([
gulp.src(stylesConfig.app),
sassGlob({ignorePaths: stylesConfig.ignore}),
sass().on('error', sass.logError),
concat('app.css'),
gulp.dest(stylesConfig.dest)
], cb);
});

View File

@ -1,26 +0,0 @@
var gulp = require('gulp');
var spawn = require('child_process').spawn;
gulp.task('test', function(cb) {
var command = ['run', 'python', 'manage.py', 'test'];
command = command.concat(process.argv.splice(3));
spawn('pipenv', command, { stdio: 'inherit' }).on('exit', cb);
});
gulp.task('coverage', function(cb) {
spawn(
'pipenv',
[
'run',
'coverage',
'run',
'manage.py',
'test'
],
{
stdio: 'inherit'
}
).on('exit', cb);
});

View File

@ -1,14 +0,0 @@
var gulp = require('gulp');
var watchConfig = require('../config.js').watchConfig;
gulp.task('watch', ['watch:scripts', 'watch:styles']);
gulp.task('watch:scripts', function() {
return gulp.watch(watchConfig.scriptsGlob, ['scripts:app']);
});
gulp.task('watch:styles', function() {
return gulp.watch(watchConfig.stylesGlob, ['styles:app']);
});

3031
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -9,7 +9,7 @@
"dependencies": {
"bootstrap": "4.1.2",
"font-awesome": "^4.7.0",
"gulp": "^3.9.1",
"gulp": "^4.0.0",
"gulp-concat": "^2.6.1",
"gulp-csso": "^3.0.1",
"gulp-flatten": "^0.4.0",
@ -23,8 +23,6 @@
"plotly.js": "^1.39.1",
"popper.js": "^1.14.3",
"pump": "^3.0.0",
"require-dir": "^1.0.0",
"run-sequence": "^2.2.1",
"tempusdominus-bootstrap-4": "^5.0.1",
"tempusdominus-core": "^5.0.0"
},