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