代码拉取完成,页面将自动刷新
同步操作将从 brookshi/Hitchhiker 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
var gulp = require('gulp'),
argv = require('yargs').argv,
replace = require('gulp-replace'),
exec = require('child_process').exec,
fs = require('fs-extra'),
path = require('path'),
archiver = require('archiver');
gulp.task('build', ['copyTemplate', 'copyGlobalData', 'copyLocales']);
gulp.task('package', ['release'], function () {
const keepFiles = ['build', 'node_modules', 'appconfig.json', 'gulpfile.js', 'logconfig.json', 'mail.json', 'pm2.json', 'sample collection.json', 'tsconfig.json'];
const files = fs.readdirSync(__dirname);
files.forEach(f => {
if (!keepFiles.find(fileName => f.endsWith(fileName))) {
fs.removeSync(f)
}
});
const zipPath = __dirname;
const zipFile = `${zipPath}.zip`;
if (fs.existsSync(zipFile)) {
fs.unlinkSync(zipFile);
}
const output = fs.createWriteStream(zipFile);
const archive = archiver('zip');
let isClose = false;
output.on('close', () => {
isClose = true;
});
output.on('end', () => {
isClose = true;
});
archive.pipe(output);
archive.directory(zipPath, false);
archive.finalize();
});
gulp.task('release', ['copy', 'copyTemplate', 'copyGlobalData', 'copyLocales', 'createBackupFolder']);
gulp.task('copy', ['compilerClient'], function () {
return gulp.src('./client/build/**/*.*')
.pipe(gulp.dest('./build/public'))
.on('end', function () {
gulp.src('./pm2.json')
.pipe(gulp.dest('./build'))
});
});
gulp.task('copyTemplate', function () {
fs.removeSync(path.join(__dirname, 'build/mail/templates'));
return gulp.src('./api/mail/templates/**/*.*')
.pipe(gulp.dest('./build/mail/templates'));
});
gulp.task('copyGlobalData', function () {
let globalPath = path.join(__dirname, 'build/global_data');
fs.removeSync(globalPath);
fs.mkdirpSync(`${globalPath}/project`);
return gulp.src('./api/global_data/**/*.*')
.pipe(gulp.dest('./build/global_data'));
});
gulp.task('copyLocales', function () {
fs.removeSync(path.join(__dirname, 'build/locales'));
return gulp.src('./api/locales/**/*.*')
.pipe(gulp.dest('./build/locales'));
});
gulp.task('createBackupFolder', function () {
const backupFolder = path.join(__dirname, 'build/backup');
fs.rmdirSync(backupFolder);
fs.mkdirSync(backupFolder, 0o666);
});
gulp.task('compilerClient', ['compilerServer'], function (cb) {
process.chdir('./client');
exec('yarn build', function (err, stdout, stderr) {
console.log(stdout);
console.log(stderr);
process.chdir('../');
cb();
});
});
gulp.task('compilerServer', ['config'], function (cb) {
exec('tsc -p . -w false', function (err, stdout, stderr) {
console.log(stdout);
console.log(stderr);
cb();
});
});
gulp.task('config', [], function () {
return gulp.src('./client/src/utils/urls.ts')
.pipe(replace('http://localhost:3000/', 'HITCHHIKER_APP_HOST'))
.pipe(gulp.dest('./client/src/utils/'))
.on('end', function () {
gulp.src('./appconfig.json')
.pipe(replace('localhost:3000', `localhost:8080`))
.pipe(replace('localhost:81', `localhost:8080`))
.pipe(replace('"database": "hitchhiker"', '"database": "hitchhiker-prod"'))
.pipe(replace('DEV', `PROD`))
.pipe(gulp.dest('./'))
.on('end', function () {
gulp.src('./client/package.json')
.pipe(replace('localhost:81', `localhost:8080`))
.pipe(gulp.dest('./client/'));
});
});
});
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。