2022-09-01 02:15:45 +08:00
|
|
|
/* RainLoop Webmail (c) RainLoop Team | Licensed under MIT */
|
2019-06-29 22:16:09 +08:00
|
|
|
/* eslint-disable consistent-return */
|
|
|
|
const gulp = require('gulp');
|
|
|
|
const fs = require('node-fs');
|
|
|
|
const chmod = require('gulp-chmod');
|
|
|
|
|
|
|
|
const pkg = require('../package.json');
|
2019-07-05 03:09:27 +08:00
|
|
|
const { config } = require('./config');
|
2022-09-01 02:15:45 +08:00
|
|
|
const { zip, del } = require('./common');
|
2019-06-29 22:16:09 +08:00
|
|
|
|
|
|
|
const rainloopCopy = () => {
|
2019-07-05 03:09:27 +08:00
|
|
|
const versionFull = pkg.version,
|
|
|
|
dist = config.releasesPath + '/webmail/' + versionFull + '/src/';
|
2019-06-29 22:16:09 +08:00
|
|
|
fs.mkdirSync(dist, '0777', true);
|
|
|
|
fs.mkdirSync(dist + 'data');
|
|
|
|
fs.mkdirSync(dist + 'rainloop/v/' + versionFull, '0777', true);
|
|
|
|
|
2019-07-05 03:09:27 +08:00
|
|
|
return gulp
|
|
|
|
.src('rainloop/v/' + config.devVersion + '/**/*', { base: 'rainloop/v/' + config.devVersion })
|
2019-06-29 22:16:09 +08:00
|
|
|
.pipe(chmod(0o644, 0o755))
|
|
|
|
.pipe(gulp.dest(dist + 'rainloop/v/' + versionFull));
|
|
|
|
};
|
|
|
|
|
|
|
|
const rainloopSetup = (done) => {
|
2019-07-05 03:09:27 +08:00
|
|
|
const versionFull = pkg.version,
|
|
|
|
dist = config.releasesPath + '/webmail/' + versionFull + '/src/';
|
2019-06-29 22:16:09 +08:00
|
|
|
fs.writeFileSync(dist + 'data/VERSION', versionFull);
|
|
|
|
fs.writeFileSync(dist + 'data/EMPTY', versionFull);
|
|
|
|
|
2019-07-05 03:09:27 +08:00
|
|
|
fs.writeFileSync(
|
|
|
|
dist + 'index.php',
|
|
|
|
fs
|
|
|
|
.readFileSync('index.php', 'utf8')
|
|
|
|
.replace("'APP_VERSION', '0.0.0'", "'APP_VERSION', '" + versionFull + "'")
|
2019-06-29 22:16:09 +08:00
|
|
|
);
|
|
|
|
|
|
|
|
fs.writeFileSync(dist + 'rainloop/v/' + versionFull + '/index.php.root', fs.readFileSync(dist + 'index.php'));
|
|
|
|
|
|
|
|
config.destPath = config.releasesPath + '/webmail/' + versionFull + '/';
|
|
|
|
config.cleanPath = dist;
|
|
|
|
config.zipSrcPath = dist;
|
2022-09-01 02:15:45 +08:00
|
|
|
config.zipFile = 'rainloop-legacy-' + versionFull + '.zip';
|
2019-06-29 22:16:09 +08:00
|
|
|
|
|
|
|
config.rainloopBuilded = true;
|
|
|
|
|
|
|
|
done();
|
|
|
|
};
|
|
|
|
|
|
|
|
const rainloopZip = (done) => {
|
|
|
|
if (config.destPath && config.zipSrcPath && config.zipFile) {
|
|
|
|
return zip(config.zipSrcPath, config.destPath, config.zipFile);
|
|
|
|
}
|
|
|
|
|
|
|
|
done();
|
|
|
|
};
|
|
|
|
|
|
|
|
const rainloopClean = (done) => {
|
|
|
|
if (config.cleanPath) {
|
|
|
|
return del(config.cleanPath);
|
|
|
|
}
|
|
|
|
|
|
|
|
done();
|
|
|
|
};
|
|
|
|
|
2019-07-05 03:09:27 +08:00
|
|
|
exports.rainloopBuild = gulp.series(rainloopCopy, rainloopSetup);
|
|
|
|
|
2022-09-01 02:15:45 +08:00
|
|
|
exports.rainloop = gulp.series(exports.rainloopBuild, rainloopZip, rainloopClean);
|