habitica/gulp/gulp-build.js

100 lines
2.8 KiB
JavaScript
Raw Normal View History

/* eslint-disable no-console */
2015-09-04 20:30:44 +00:00
import gulp from 'gulp';
import path from 'path';
import babel from 'gulp-babel';
import os from 'os';
import fs from 'fs';
import spawn from 'cross-spawn'; // eslint-disable-line import/no-extraneous-dependencies
import clean from 'rimraf';
2015-09-04 20:30:44 +00:00
2020-04-01 11:31:39 +00:00
gulp.task('build:babel:server', () => gulp.src('website/server/**/*.js')
2019-10-08 14:57:10 +00:00
.pipe(babel())
.pipe(gulp.dest('website/transpiled-babel/')));
2020-04-01 11:31:39 +00:00
gulp.task('build:babel:common', () => gulp.src('website/common/script/**/*.js')
2019-10-08 14:57:10 +00:00
.pipe(babel())
.pipe(gulp.dest('website/common/transpiled-babel/')));
2020-04-01 11:31:39 +00:00
gulp.task('build:babel', gulp.parallel('build:babel:server', 'build:babel:common', done => done()));
gulp.task('build:cache', gulp.parallel(
'cache:content',
'cache:i18n',
done => done(),
));
gulp.task('build:prod', gulp.series(
2020-04-01 11:31:39 +00:00
'build:babel',
Merge develop into release (#9154) * Client: fix Apidoc and move email files (#9139) * fix apidoc * move emails files * quest leader can start/end quest; admins can edit challenges/guilds; reverse chat works; remove static/videos link; etc (#9140) * enable link to markdown info on group and challenge edit screen * allow admin (moderators and staff) to edit challenges * allow admin (moderators and staff) to edit guilds Also add some unrelated TODO comments. * allow any party member (not just leader) to start quest from party page * allow quest owner to cancel, begin, abort quest Previously only the party leader could see those buttons. The leader still can. This also hides those buttons from all other party members. * enable reverse chat in guilds and party * remove outdated videos from press kit * adjust various wordings * Be consistent with capitalization of Check-In. (#9118) * limit for inlined svg images and make home leaner by not bundling it with the rest of static pages * sep 27 fixes (#9088) * fix item paddings / drawer width * expand the width of item-rows by the margin of an item * fix hatchedPet-dialog * fix hatching-modal * remove min-height * Oct 3 fixes (#9148) * Only show level after yesterdailies modal * Fixed zindex * Added spcial spells to rewards column * Added single click buy for health and armoire * Prevented task scoring when casting a spell * Renamed generic purchase method * Updated nav for small screen * Hide checklist while casting * fix some text describing menu items (#9145)
2017-10-04 02:15:00 +00:00
'apidoc',
'build:cache',
2019-10-08 14:57:10 +00:00
done => done(),
));
2018-02-04 18:30:30 +00:00
// Due to this issue https://github.com/vkarpov15/run-rs/issues/45
// When used on windows `run-rs` must first be run without the `--keep` option
// in order to be setup correctly, afterwards it can be used.
const MONGO_PATH = path.join(__dirname, '/../mongodb-data/');
gulp.task('build:prepare-mongo', async () => {
if (fs.existsSync(MONGO_PATH)) {
// console.log('MongoDB data folder exists, skipping setup.');
return;
}
if (os.platform() !== 'win32') {
// console.log('Not on Windows, skipping MongoDB setup.');
return;
}
console.log('MongoDB data folder is missing, setting up.');
// use run-rs without --keep, kill it as soon as the replica set starts
const runRsProcess = spawn('run-rs', ['-v', '4.2.8', '-l', 'ubuntu1804', '--dbpath', 'mongodb-data', '--number', '1', '--quiet']);
for await (const chunk of runRsProcess.stdout) {
const stringChunk = chunk.toString();
console.log(stringChunk);
// kills the process after the replica set is setup
if (stringChunk.includes('Started replica set')) {
console.log('MongoDB setup correctly.');
runRsProcess.kill();
}
}
let error = '';
for await (const chunk of runRsProcess.stderr) {
const stringChunk = chunk.toString();
error += stringChunk;
}
const exitCode = await new Promise(resolve => {
runRsProcess.on('close', resolve);
});
if (exitCode || error.length > 0) {
// remove any leftover files
clean.sync(MONGO_PATH);
throw new Error(`Error running run-rs: ${error}`);
}
});
gulp.task('build:dev', gulp.series(
'build:prepare-mongo',
done => done(),
));
2019-10-08 14:57:10 +00:00
const buildArgs = [];
2018-02-04 18:30:30 +00:00
if (process.env.NODE_ENV === 'production') { // eslint-disable-line no-process-env
buildArgs.push('build:prod');
} else if (process.env.NODE_ENV !== 'test') { // eslint-disable-line no-process-env
buildArgs.push('build:dev');
2018-02-04 18:30:30 +00:00
}
2019-10-08 14:57:10 +00:00
gulp.task('build', gulp.series(buildArgs, done => {
2018-02-04 18:30:30 +00:00
done();
2019-10-08 14:57:10 +00:00
}));