2016-12-28 16:49:51 -06:00
|
|
|
/**
|
|
|
|
* Gulp tasks
|
|
|
|
*/
|
|
|
|
|
2020-12-26 00:13:25 -06:00
|
|
|
import * as fs from 'fs';
|
2016-12-28 16:49:51 -06:00
|
|
|
import * as gulp from 'gulp';
|
|
|
|
import * as ts from 'gulp-typescript';
|
|
|
|
import * as rimraf from 'rimraf';
|
2017-01-19 13:43:17 -06:00
|
|
|
import * as rename from 'gulp-rename';
|
2020-12-25 19:01:32 -06:00
|
|
|
import * as replace from 'gulp-replace';
|
|
|
|
const terser = require('gulp-terser');
|
|
|
|
const cssnano = require('gulp-cssnano');
|
2017-12-07 11:44:50 -06:00
|
|
|
|
2020-05-22 23:19:31 -05:00
|
|
|
const locales: { [x: string]: any } = require('./locales');
|
2020-01-29 13:37:25 -06:00
|
|
|
const meta = require('./package.json');
|
2017-01-18 01:42:01 -06:00
|
|
|
|
2017-03-01 03:20:53 -06:00
|
|
|
gulp.task('build:ts', () => {
|
2018-02-09 19:27:05 -06:00
|
|
|
const tsProject = ts.createProject('./tsconfig.json');
|
2017-03-01 03:20:53 -06:00
|
|
|
|
|
|
|
return tsProject
|
2016-12-28 16:49:51 -06:00
|
|
|
.src()
|
2016-12-28 18:21:49 -06:00
|
|
|
.pipe(tsProject())
|
2019-01-29 01:13:11 -06:00
|
|
|
.on('error', () => {})
|
2017-03-17 10:01:59 -05:00
|
|
|
.pipe(gulp.dest('./built/'));
|
2017-03-01 03:20:53 -06:00
|
|
|
});
|
2016-12-28 16:49:51 -06:00
|
|
|
|
2018-05-05 11:34:48 -05:00
|
|
|
gulp.task('build:copy:views', () =>
|
|
|
|
gulp.src('./src/server/web/views/**/*').pipe(gulp.dest('./built/server/web/views'))
|
|
|
|
);
|
|
|
|
|
2020-05-09 01:47:20 -05:00
|
|
|
gulp.task('build:copy:fonts', () =>
|
|
|
|
gulp.src('./node_modules/three/examples/fonts/**/*').pipe(gulp.dest('./built/client/assets/fonts/'))
|
|
|
|
);
|
|
|
|
|
2020-12-26 00:13:25 -06:00
|
|
|
gulp.task('build:copy:locales', cb => {
|
|
|
|
fs.mkdirSync('./built/client/assets/locales', { recursive: true });
|
|
|
|
|
|
|
|
const v = { '_version_': meta.version };
|
|
|
|
|
|
|
|
for (const [lang, locale] of Object.entries(locales)) {
|
|
|
|
fs.writeFileSync(`./built/client/assets/locales/${lang}.${meta.version}.json`, JSON.stringify({ ...locale, ...v }), 'utf-8');
|
|
|
|
}
|
|
|
|
|
|
|
|
cb();
|
|
|
|
});
|
|
|
|
|
2020-12-25 19:01:32 -06:00
|
|
|
gulp.task('build:client:script', () => {
|
2021-03-02 10:03:29 -06:00
|
|
|
return gulp.src(['./src/server/web/boot.js', './src/server/web/bios.js', './src/server/web/cli.js'])
|
2020-12-25 19:01:32 -06:00
|
|
|
.pipe(replace('VERSION', JSON.stringify(meta.version)))
|
|
|
|
.pipe(replace('LANGS', JSON.stringify(Object.keys(locales))))
|
|
|
|
.pipe(terser({
|
|
|
|
toplevel: true
|
|
|
|
}))
|
|
|
|
.pipe(gulp.dest('./built/server/web/'));
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('build:client:style', () => {
|
2021-03-02 10:03:29 -06:00
|
|
|
return gulp.src(['./src/server/web/style.css', './src/server/web/bios.css', './src/server/web/cli.css'])
|
2021-03-04 22:51:22 -06:00
|
|
|
.pipe(cssnano({
|
|
|
|
zindex: false
|
|
|
|
}))
|
2020-12-25 19:01:32 -06:00
|
|
|
.pipe(gulp.dest('./built/server/web/'));
|
|
|
|
});
|
|
|
|
|
2020-12-26 00:13:25 -06:00
|
|
|
gulp.task('build:copy', gulp.parallel('build:copy:locales', 'build:copy:views', 'build:client:script', 'build:client:style', 'build:copy:fonts', () =>
|
2017-12-16 10:41:22 -06:00
|
|
|
gulp.src([
|
2019-09-21 07:31:38 -05:00
|
|
|
'./src/emojilist.json',
|
2018-05-05 11:34:48 -05:00
|
|
|
'./src/server/web/views/**/*',
|
2017-12-16 10:41:22 -06:00
|
|
|
'./src/**/assets/**/*',
|
2020-01-29 13:37:25 -06:00
|
|
|
'!./src/client/assets/**/*'
|
2017-12-16 10:41:22 -06:00
|
|
|
]).pipe(gulp.dest('./built/'))
|
2019-01-29 01:26:33 -06:00
|
|
|
));
|
2016-12-29 00:04:22 -06:00
|
|
|
|
2016-12-28 16:49:51 -06:00
|
|
|
gulp.task('clean', cb =>
|
|
|
|
rimraf('./built', cb)
|
|
|
|
);
|
|
|
|
|
2019-01-29 01:26:33 -06:00
|
|
|
gulp.task('cleanall', gulp.parallel('clean', cb =>
|
2016-12-28 16:49:51 -06:00
|
|
|
rimraf('./node_modules', cb)
|
2019-01-29 01:26:33 -06:00
|
|
|
));
|
2016-12-28 16:49:51 -06:00
|
|
|
|
2019-01-29 01:26:10 -06:00
|
|
|
gulp.task('copy:client', () =>
|
2017-02-22 09:54:08 -06:00
|
|
|
gulp.src([
|
2017-03-22 02:19:32 -05:00
|
|
|
'./assets/**/*',
|
2018-03-29 06:32:18 -05:00
|
|
|
'./src/client/assets/**/*',
|
2017-02-22 09:54:08 -06:00
|
|
|
])
|
|
|
|
.pipe(rename(path => {
|
2019-04-12 11:43:22 -05:00
|
|
|
path.dirname = path.dirname!.replace('assets', '.');
|
2017-02-22 09:54:08 -06:00
|
|
|
}))
|
2018-03-29 06:32:18 -05:00
|
|
|
.pipe(gulp.dest('./built/client/assets/'))
|
2017-01-13 10:26:39 -06:00
|
|
|
);
|
2016-12-28 16:49:51 -06:00
|
|
|
|
2020-02-06 11:38:02 -06:00
|
|
|
gulp.task('copy:docs', () =>
|
|
|
|
gulp.src([
|
|
|
|
'./src/docs/**/*',
|
|
|
|
])
|
|
|
|
.pipe(gulp.dest('./built/client/assets/docs/'))
|
|
|
|
);
|
|
|
|
|
2019-01-29 01:31:05 -06:00
|
|
|
gulp.task('build:client', gulp.parallel(
|
2020-02-06 11:38:02 -06:00
|
|
|
'copy:client',
|
|
|
|
'copy:docs'
|
2019-01-29 01:31:05 -06:00
|
|
|
));
|
|
|
|
|
|
|
|
gulp.task('build', gulp.parallel(
|
|
|
|
'build:ts',
|
|
|
|
'build:copy',
|
|
|
|
'build:client',
|
|
|
|
));
|
|
|
|
|
|
|
|
gulp.task('default', gulp.task('build'));
|