BetterDiscordApp-v2/gulpfile.js

81 lines
2.2 KiB
JavaScript
Raw Normal View History

2018-03-19 23:02:44 +01:00
const
2018-03-20 07:54:33 +01:00
fs = require('fs'),
2018-03-19 23:02:44 +01:00
gulp = require('gulp'),
2018-03-20 07:54:33 +01:00
del = require('del'),
2018-03-19 23:02:44 +01:00
pump = require('pump'),
merge = require('gulp-merge'),
copy = require('gulp-copy'),
2018-03-20 07:54:33 +01:00
rename = require('gulp-rename'),
2018-03-22 03:19:25 +01:00
inject = require('gulp-inject-string'),
2018-03-19 23:02:44 +01:00
copydeps = require('gulp-npm-copy-deps');
2018-03-21 21:47:46 +01:00
const mainpkg = require('./package.json');
2018-03-20 07:54:33 +01:00
const corepkg = require('./core/package.json');
const clientpkg = require('./client/package.json');
const editorpkg = require('./csseditor/package.json');
2018-03-21 21:47:46 +01:00
const releasepkg = function() {
delete mainpkg.main;
delete mainpkg.devDependencies;
delete mainpkg.scripts;
return fs.writeFileSync('./release/package.json', JSON.stringify(mainpkg, null, 2));
};
2018-03-19 23:02:44 +01:00
const client = function() {
return pump([
2018-03-22 03:19:25 +01:00
gulp.src('./client/dist/*.client-release.js'),
2018-03-20 07:54:33 +01:00
rename(`client.${clientpkg.version}.js`),
gulp.dest('./release')
2018-03-19 23:02:44 +01:00
]);
};
2018-03-19 23:02:44 +01:00
const core = function() {
return pump([
2018-03-20 07:54:33 +01:00
gulp.src('./core/dist/main.js'),
2018-03-22 03:19:25 +01:00
inject.after("'use strict';\n", 'const PRODUCTION = true;\n'),
2018-03-20 07:54:33 +01:00
rename(`core.${corepkg.version}.js`),
gulp.dest('./release')
2018-03-19 23:02:44 +01:00
]);
};
2018-03-20 07:54:33 +01:00
const sparkplug = function() {
return pump([
gulp.src('./core/dist/sparkplug.js'),
gulp.dest('./release')
]);
};
const core_modules = function() {
return pump([
gulp.src('./core/dist/modules/**/*'),
copy('release/', { prefix: 2 })
]);
};
const index = function() {
return fs.writeFileSync('./release/index.js', `module.exports = require('./core.${corepkg.version}.js');`);
};
2018-03-19 23:02:44 +01:00
const cssEditor = function() {
return pump([
2018-03-22 03:37:30 +01:00
gulp.src('./csseditor/dist/csseditor-release.js'),
rename('csseditor.js'),
2018-03-19 23:02:44 +01:00
copy('release/csseditor', { prefix: 2 })
]);
};
2018-03-19 23:02:44 +01:00
const deps = function() {
return copydeps('./', './release');
};
2018-03-19 23:02:44 +01:00
const node_sass_bindings = function() {
2018-03-19 23:02:44 +01:00
return pump([
gulp.src('./other/node_sass_bindings/**/*'),
copy('release/node_modules/node-sass/vendor', { prefix: 2 })
]);
};
2018-03-19 23:02:44 +01:00
2018-03-20 07:54:33 +01:00
gulp.task('release', function () {
2018-03-21 21:47:46 +01:00
del(['./release/**/*']).then(() => merge(releasepkg(), client(), core(), sparkplug(), core_modules(), index(), cssEditor(), deps(), node_sass_bindings()));
2018-03-20 07:54:33 +01:00
});