Migrate from gulp 3.x to 4.x dirtily

This commit is contained in:
Ilya Ig. Petrov 2019-02-24 16:47:27 +00:00
parent 2ce48cbd50
commit 927fd7d043
4 changed files with 2827 additions and 1157 deletions

View File

@ -1,8 +1,5 @@
# Install # Install
Nodejs 10 and gulp have [issues](https://github.com/nodejs/node/issues/20285),
use nodejs 8 instead for a while.
``` ```
npm install npm install
cd src/extension-common/pages/options/ cd src/extension-common/pages/options/
@ -14,10 +11,7 @@ use your build/extension-beta
# Release # Release
1. `vim src/extension-common/pages/options/src/components/App.js` 1. `npm run release`
2. Change github link there. 2. `vim src/templates-data.js` and bump version.
3. `npm run release` 3. Commit bumped version.
4. Change `App.js` back to original: `git checkout src/extension-common/pages/options/src/components/App.js` 4. Merge development to production (usually after deployment and testing and many patches).
5. `vim src/templates-data.js` and bump version.
6. Commit bumped version.
7. Merge development to production (usually after deployment and testing and many patches).

View File

@ -3,7 +3,7 @@
const gulp = require('gulp'); const gulp = require('gulp');
const del = require('del'); const del = require('del');
const through = require('through2'); const through = require('through2');
const PluginError = require('gulp-util').PluginError; const PluginError = require('plugin-error');
const changed = require('gulp-changed'); const changed = require('gulp-changed');
const PluginName = 'Template literals'; const PluginName = 'Template literals';
@ -29,7 +29,7 @@ const templatePlugin = (context) => through.obj(function(file, encoding, cb) {
}, { keys: [], values: [] }); }, { keys: [], values: [] });
try { try {
file.contents = new Buffer( file.contents = Buffer.from(
(new Function(...keys, 'return `' + String(file.contents) + '`;'))(...values) (new Function(...keys, 'return `' + String(file.contents) + '`;'))(...values)
); );
} catch(e) { } catch(e) {
@ -43,14 +43,13 @@ const templatePlugin = (context) => through.obj(function(file, encoding, cb) {
}); });
gulp.task('default', ['build:beta']);
gulp.task('clean', function(cb) { const clean = function(cb) {
//return del.sync('./build'); //return del.sync('./build');
return cb(); return cb();
}); };
const contexts = require('./src/templates-data').contexts; const contexts = require('./src/templates-data').contexts;
@ -69,16 +68,16 @@ const firefoxSrc = './src/extension-firefox/**/*';
const joinSrc = (...args) => [...args, ...excluded]; const joinSrc = (...args) => [...args, ...excluded];
gulp.task('_cp-mini', function(cb) { const copyMini = function(cb) {
gulp.src(joinSrc(commonSrc, miniSrc)) gulp.src(joinSrc(commonSrc, miniSrc))
//.pipe(changed(miniDst)) //.pipe(changed(miniDst))
.pipe(templatePlugin(contexts.mini)) .pipe(templatePlugin(contexts.mini))
.pipe(gulp.dest(miniDst)) .pipe(gulp.dest(miniDst))
.on('end', cb); .on('end', cb);
}); };
gulp.task('_cp-full', function(cb) { const copyFull = function(cb) {
gulp.src(joinSrc(commonSrc, fullSrc)) gulp.src(joinSrc(commonSrc, fullSrc))
//.pipe(changed(fullDst)) //.pipe(changed(fullDst))
@ -86,19 +85,9 @@ gulp.task('_cp-full', function(cb) {
.pipe(gulp.dest(fullDst)) .pipe(gulp.dest(fullDst))
.on('end', cb); .on('end', cb);
}); };
gulp.task('_cp-firefox', function(cb) { const copyBeta = function(cb) {
gulp.src(joinSrc(commonSrc, fullSrc, firefoxSrc))
//.pipe(changed(fullDst))
.pipe(templatePlugin(contexts.firefox))
.pipe(gulp.dest(firefoxDst))
.on('end', cb);
});
gulp.task('_cp-beta', function(cb) {
gulp.src(joinSrc(commonSrc, fullSrc)) gulp.src(joinSrc(commonSrc, fullSrc))
//.pipe(changed(fullDst)) //.pipe(changed(fullDst))
@ -106,8 +95,13 @@ gulp.task('_cp-beta', function(cb) {
.pipe(gulp.dest(betaDst)) .pipe(gulp.dest(betaDst))
.on('end', cb); .on('end', cb);
}); };
gulp.task('build:all', ['_cp-mini', '_cp-full', '_cp-beta', '_cp-firefox']); const buildAll = gulp.parallel(copyMini, copyFull, copyBeta);
gulp.task('build:beta', ['_cp-beta']); const buildBeta = copyBeta;
gulp.task('build:firefox', ['_cp-firefox']);
module.exports = {
default: buildAll,
buildAll,
buildBeta,
};

File diff suppressed because it is too large Load Diff

View File

@ -8,8 +8,8 @@
"test": "mocha --recursive ./src/**/test/*", "test": "mocha --recursive ./src/**/test/*",
"subpages": "cd ./src/extension-common/pages/options/ && npm run build && cd -", "subpages": "cd ./src/extension-common/pages/options/ && npm run build && cd -",
"subpages:dev": "cd ./src/extension-common/pages/options/ && npm run build:dev:nocomp && cd -", "subpages:dev": "cd ./src/extension-common/pages/options/ && npm run build:dev:nocomp && cd -",
"start": "npm run subpages:dev && npm run gulp build:beta", "start": "npm run subpages:dev && npm run gulp buildAll",
"release": "npm run subpages && npm run gulp build:all" "release": "npm run subpages && npm run gulp buildAll"
}, },
"author": "Ilya Ig. Petrov", "author": "Ilya Ig. Petrov",
"license": "GPLv3", "license": "GPLv3",
@ -23,8 +23,9 @@
"symlink-to": "^0.0.4" "symlink-to": "^0.0.4"
}, },
"dependencies": { "dependencies": {
"del": "^2.2.2", "del": "^3.0.0",
"gulp": "^3.9.1", "gulp": "^4.0.0",
"through2": "^2.0.3" "plugin-error": "^1.0.1",
"through2": "^3.0.0"
} }
} }