2020-10-26 15:18:23 +03:00
|
|
|
import fs from 'fs';
|
|
|
|
import gulp from 'gulp';
|
|
|
|
import gutil from 'gulp-util';
|
|
|
|
import rename from 'gulp-rename';
|
|
|
|
import zip from 'gulp-zip';
|
|
|
|
import webpack from 'webpack';
|
|
|
|
import mocha from 'gulp-mocha';
|
|
|
|
import crdv from 'chromedriver';
|
|
|
|
import devConfig from './webpack/dev.config';
|
|
|
|
import prodConfig from './webpack/prod.config';
|
|
|
|
import wrapConfig from './webpack/wrap.config';
|
|
|
|
|
|
|
|
function copy(dest) {
|
|
|
|
gulp.src('./src/assets/**/*').pipe(gulp.dest(dest));
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* dev tasks
|
|
|
|
*/
|
|
|
|
|
|
|
|
gulp.task('webpack:dev', (callback) => {
|
|
|
|
webpack(devConfig, (err, stats) => {
|
|
|
|
if (err) {
|
|
|
|
throw new gutil.PluginError('webpack:dev', err);
|
|
|
|
}
|
|
|
|
gutil.log('[webpack:dev]', stats.toString({ colors: true }));
|
|
|
|
});
|
|
|
|
callback();
|
|
|
|
});
|
|
|
|
|
2020-10-31 15:51:20 +03:00
|
|
|
gulp.task('copy:dev', (done) => {
|
2020-10-26 15:18:23 +03:00
|
|
|
gulp
|
|
|
|
.src('./src/browser/extension/manifest.json')
|
|
|
|
.pipe(rename('manifest.json'))
|
|
|
|
.pipe(gulp.dest('./dev'));
|
|
|
|
copy('./dev');
|
2020-10-31 15:51:20 +03:00
|
|
|
done();
|
2020-10-26 15:18:23 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
/*
|
|
|
|
* build tasks
|
|
|
|
*/
|
|
|
|
|
|
|
|
gulp.task('webpack:build:extension', (callback) => {
|
|
|
|
function webpackProcess(config) {
|
|
|
|
return new Promise((resolve, reject) =>
|
|
|
|
webpack(config, (err, stats) => {
|
|
|
|
if (err) {
|
|
|
|
reject(new gutil.PluginError('webpack:build', err));
|
|
|
|
}
|
|
|
|
gutil.log('[webpack:build]', stats.toString({ colors: true }));
|
|
|
|
resolve();
|
|
|
|
})
|
|
|
|
);
|
|
|
|
}
|
|
|
|
webpackProcess(wrapConfig)
|
|
|
|
.then(() => webpackProcess(prodConfig))
|
|
|
|
.then(() => {
|
|
|
|
const dest = './build/extension';
|
|
|
|
fs.rename(
|
2020-11-17 00:43:49 +03:00
|
|
|
`${dest}/redux-devtools-extension.bundle.js`,
|
|
|
|
`${dest}/redux-devtools-extension.js`,
|
2020-10-26 15:18:23 +03:00
|
|
|
callback
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2020-10-31 15:51:20 +03:00
|
|
|
gulp.task('copy:build:extension', (done) => {
|
2020-10-26 15:18:23 +03:00
|
|
|
gulp
|
|
|
|
.src('./src/browser/extension/manifest.json')
|
|
|
|
.pipe(rename('manifest.json'))
|
|
|
|
.pipe(gulp.dest('./build/extension'));
|
|
|
|
copy('./build/extension');
|
2020-10-31 15:51:20 +03:00
|
|
|
done();
|
2020-10-26 15:18:23 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
/*
|
|
|
|
* compress task
|
|
|
|
*/
|
|
|
|
|
2020-10-31 15:51:20 +03:00
|
|
|
gulp.task('compress:extension', (done) => {
|
2020-10-26 15:18:23 +03:00
|
|
|
gulp
|
|
|
|
.src('build/extension/**')
|
|
|
|
.pipe(zip('extension.zip'))
|
|
|
|
.pipe(gulp.dest('./build'));
|
2020-10-31 15:51:20 +03:00
|
|
|
done();
|
2020-10-26 15:18:23 +03:00
|
|
|
});
|
|
|
|
|
2020-10-31 15:51:20 +03:00
|
|
|
gulp.task('compress:firefox', (done) => {
|
2020-10-26 15:18:23 +03:00
|
|
|
gulp
|
|
|
|
.src('build/firefox/**')
|
|
|
|
.pipe(zip('firefox.zip'))
|
|
|
|
.pipe(gulp.dest('./build'));
|
2020-10-31 15:51:20 +03:00
|
|
|
done();
|
2020-10-26 15:18:23 +03:00
|
|
|
});
|
|
|
|
|
|
|
|
/*
|
|
|
|
* watch tasks
|
|
|
|
*/
|
|
|
|
|
|
|
|
gulp.task('copy:watch', () => {
|
|
|
|
gulp.watch(
|
|
|
|
['./src/browser/extension/manifest.json', './src/assets/**/*'],
|
2020-10-31 15:51:20 +03:00
|
|
|
gulp.series('copy:dev')
|
2020-10-26 15:18:23 +03:00
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('test:chrome', () => {
|
|
|
|
crdv.start();
|
|
|
|
return gulp
|
|
|
|
.src('./test/chrome/*.spec.js')
|
2020-11-16 21:37:40 +03:00
|
|
|
.pipe(mocha({ require: ['@babel/polyfill', 'co-mocha'] }))
|
2020-10-26 15:18:23 +03:00
|
|
|
.on('end', () => crdv.stop());
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('test:electron', () => {
|
|
|
|
crdv.start();
|
|
|
|
return gulp
|
|
|
|
.src('./test/electron/*.spec.js')
|
2020-11-16 21:37:40 +03:00
|
|
|
.pipe(mocha({ require: ['@babel/polyfill', 'co-mocha'] }))
|
2020-10-26 15:18:23 +03:00
|
|
|
.on('end', () => crdv.stop());
|
|
|
|
});
|
|
|
|
|
2020-11-17 00:43:49 +03:00
|
|
|
gulp.task('default', gulp.parallel('webpack:dev', 'copy:dev', 'copy:watch'));
|
2020-10-31 15:51:20 +03:00
|
|
|
gulp.task(
|
|
|
|
'build:extension',
|
2020-11-17 00:43:49 +03:00
|
|
|
gulp.parallel('webpack:build:extension', 'copy:build:extension')
|
2020-10-31 15:51:20 +03:00
|
|
|
);
|
|
|
|
gulp.task(
|
|
|
|
'copy:build:firefox',
|
|
|
|
gulp.series('build:extension', (done) => {
|
|
|
|
gulp
|
|
|
|
.src([
|
|
|
|
'./build/extension/**',
|
2020-11-17 00:43:49 +03:00
|
|
|
'!./build/extension/redux-devtools-extension.js',
|
2020-10-31 15:51:20 +03:00
|
|
|
])
|
|
|
|
.pipe(gulp.dest('./build/firefox'))
|
|
|
|
.on('finish', function () {
|
|
|
|
gulp
|
|
|
|
.src('./src/browser/firefox/manifest.json')
|
|
|
|
.pipe(gulp.dest('./build/firefox'));
|
|
|
|
});
|
|
|
|
copy('./build/firefox');
|
|
|
|
done();
|
|
|
|
})
|
|
|
|
);
|
|
|
|
gulp.task('build:firefox', gulp.series('copy:build:firefox'));
|