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