BetterDiscordApp-v2/gulpfile.babel.js

156 lines
4.0 KiB
JavaScript
Raw Normal View History

2018-07-04 19:48:45 +02:00
import gulp from 'gulp';
import pump from 'pump';
import del from 'del';
import copy from 'gulp-copy';
import rename from 'gulp-rename';
import inject from 'gulp-inject-string';
2019-03-07 18:10:08 +01:00
import replace from 'gulp-replace';
2019-03-04 16:02:52 +01:00
import copydeps from './scripts/copydeps';
2018-07-04 19:48:45 +02:00
import file from 'gulp-file';
import editjson from 'gulp-json-editor';
import corepkg from './core/package';
import clientpkg from './client/package';
2019-02-28 15:51:45 +01:00
import editorpkg from './editor/package';
2018-07-04 19:48:45 +02:00
2019-02-18 08:21:28 +01:00
// core-release >
gulp.task('core-main', function() {
2019-02-18 08:21:28 +01:00
return pump([
gulp.src('core/dist/main.js'),
2019-03-07 18:10:08 +01:00
replace('/*PRODUCTION*/', 'const PRODUCTION = true;'),
2019-02-18 08:21:28 +01:00
rename(`core.${corepkg.version}.js`),
gulp.dest('release/core')
]);
});
gulp.task('core-pkg', function() {
2018-07-04 19:48:45 +02:00
return pump([
2019-02-18 14:21:51 +01:00
gulp.src('core/package.json'),
2019-02-18 08:21:28 +01:00
editjson(function(pkg) {
pkg.main = `core.${corepkg.version}.js`;
delete pkg.devDependencies;
delete pkg.scripts;
return pkg;
2018-07-04 19:48:45 +02:00
}),
2019-02-18 08:21:28 +01:00
gulp.dest('release/core')
2018-07-04 19:48:45 +02:00
]);
});
gulp.task('core-modules', function() {
2018-07-04 19:48:45 +02:00
return pump([
2019-02-18 08:21:28 +01:00
gulp.src('core/dist/modules/**/*'),
copy('release/core', { prefix: 2 })
2018-07-04 19:48:45 +02:00
]);
});
gulp.task('core-sparkplug', function() {
2018-07-04 19:48:45 +02:00
return pump([
2019-02-18 08:21:28 +01:00
gulp.src('core/dist/sparkplug.js'),
gulp.dest('release/core')
2018-07-04 19:48:45 +02:00
]);
});
gulp.task('core-extras', function() {
return pump([
gulp.src(['core/src/csp.json']),
gulp.dest('release/core')
]);
});
gulp.task('core-release', gulp.parallel('core-main', 'core-pkg', 'core-sparkplug', 'core-modules', 'core-extras'));
2019-02-18 08:21:28 +01:00
// < core-release
// client
gulp.task('client-main', function() {
2018-07-04 19:48:45 +02:00
return pump([
2019-02-18 08:21:28 +01:00
gulp.src('client/dist/*.client-release.js'),
rename(`client.${clientpkg.version}.js`),
gulp.dest('release/client')
2018-07-04 19:48:45 +02:00
]);
});
2019-02-18 08:21:28 +01:00
gulp.task('client-pkg', function() {
2018-07-04 19:48:45 +02:00
return pump([
2019-02-18 08:21:28 +01:00
gulp.src('client/package.json'),
editjson(function (pkg) {
pkg.main = `client.${clientpkg.version}.js`;
delete pkg.scripts;
return pkg;
}),
gulp.dest('release/client')
2018-07-04 19:48:45 +02:00
]);
});
gulp.task('client-sparkplug', function() {
2018-07-04 19:48:45 +02:00
return pump([
2019-02-18 08:21:28 +01:00
gulp.src('core/dist/sparkplug.js'),
gulp.dest('release/client')
2018-07-04 19:48:45 +02:00
]);
});
2019-02-18 08:21:28 +01:00
gulp.task('client-release', gulp.parallel('client-main', 'client-pkg', 'client-sparkplug'));
2019-02-28 15:51:45 +01:00
// Editor
2019-02-18 08:21:28 +01:00
gulp.task('editor-main', function() {
2018-07-04 19:48:45 +02:00
return pump([
2019-02-28 15:51:45 +01:00
gulp.src('editor/dist/editor.release.js'),
rename(`editor.${editorpkg.version}.js`),
gulp.dest('release/editor')
2018-07-04 19:48:45 +02:00
]);
});
gulp.task('editor-pkg', function() {
2019-02-28 15:51:45 +01:00
return pump([
gulp.src('editor/package.json'),
editjson(function(pkg) {
2019-02-28 15:51:45 +01:00
pkg.main = `editor.${editorpkg.version}.js`;
delete pkg.scripts;
return pkg;
}),
gulp.dest('release/editor')
]);
});
gulp.task('editor-release', gulp.parallel('editor-main', 'editor-pkg'));
2019-02-18 08:21:28 +01:00
// Deps
2019-03-04 16:02:52 +01:00
gulp.task('node-modules', function() {
return pump([
gulp.src(copydeps({ignore: ['fsevents']}), { base: '.' }),
gulp.dest('./release/core')
]);
2018-07-04 19:48:45 +02:00
});
gulp.task('node-sass-bindings', gulp.series(function() {
return del(['release/node_modules/node-sass/vendor']);
}, function() {
2018-07-04 19:48:45 +02:00
return pump([
gulp.src('other/node_sass_bindings/**/*'),
2019-02-18 08:21:28 +01:00
copy('release/core/node_modules/node-sass/vendor', { prefix: 2 })
2018-07-04 19:48:45 +02:00
]);
}));
2018-07-04 19:48:45 +02:00
gulp.task('keytar-bindings', gulp.series(function() {
return del(['release/node_modules/keytar/build']);
}, function() {
return pump([
gulp.src('other/keytar/**/*'),
2019-02-18 08:21:28 +01:00
copy('release/core/node_modules/keytar/build/Release', { prefix: 2 })
]);
}));
2019-02-18 08:21:28 +01:00
// Other
2019-02-18 08:21:28 +01:00
gulp.task('del-release', function() {
2018-07-04 19:48:45 +02:00
return del(['release/**/*']);
2019-02-18 08:21:28 +01:00
});
gulp.task('dependencies', gulp.series('node-modules', gulp.parallel('node-sass-bindings', 'keytar-bindings')));
2019-02-28 15:51:45 +01:00
gulp.task('build-release', gulp.parallel('core-release', 'client-release', 'editor-release', 'dependencies'));
2019-03-07 18:10:08 +01:00
gulp.task('release', gulp.series('del-release', 'build-release'));