|
|
|
@ -5,6 +5,8 @@ const shell = require('shelljs');
|
|
|
|
|
const execa = require('execa');
|
|
|
|
|
const { Config } = require('../utils/config');
|
|
|
|
|
|
|
|
|
|
const buildPath = Config.buildPath;
|
|
|
|
|
const codePath = Config.codePath;
|
|
|
|
|
|
|
|
|
|
program.parse(process.argv);
|
|
|
|
|
const env = program.args[0];
|
|
|
|
@ -23,7 +25,7 @@ if (!mappingBranch[env]) {
|
|
|
|
|
|
|
|
|
|
const runBuild = (task) => new Promise(async resolve => {
|
|
|
|
|
try {
|
|
|
|
|
shell.cd(Config.codePath);
|
|
|
|
|
shell.cd(codePath);
|
|
|
|
|
await execa('git', ['checkout', mappingBranch[env].code]);
|
|
|
|
|
await execa('git', ['pull', 'origin', mappingBranch[env].code]);
|
|
|
|
|
await execa('npm', ['run', 'build', 'test-build']);
|
|
|
|
@ -37,12 +39,12 @@ const runBuild = (task) => new Promise(async resolve => {
|
|
|
|
|
|
|
|
|
|
const deleteBuild = (task) => new Promise(async resolve => {
|
|
|
|
|
try {
|
|
|
|
|
shell.cd(Config.buildPath);
|
|
|
|
|
shell.cd(buildPath);
|
|
|
|
|
await execa('git', ['checkout', mappingBranch[env].build]);
|
|
|
|
|
await execa('git', ['pull', 'origin', mappingBranch[env].build]);
|
|
|
|
|
|
|
|
|
|
shell.rm(`${Config.buildPath}/*`);
|
|
|
|
|
shell.rm('-rf', `${Config.buildPath}/static`);
|
|
|
|
|
shell.rm(`${buildPath}/*`);
|
|
|
|
|
shell.rm('-rf', `${buildPath}/static`);
|
|
|
|
|
|
|
|
|
|
await execa('git', ['add', '.']);
|
|
|
|
|
await execa('git', ['commit', '-m', `'发布新版本'`]);
|
|
|
|
@ -57,9 +59,9 @@ const deleteBuild = (task) => new Promise(async resolve => {
|
|
|
|
|
|
|
|
|
|
const copyBuild = (task) => new Promise(async resolve => {
|
|
|
|
|
try {
|
|
|
|
|
shell.cp('-r', `${Config.codePath}/dist/*`, Config.buildPath);
|
|
|
|
|
shell.cp('-r', `${codePath}/dist/*`, buildPath);
|
|
|
|
|
|
|
|
|
|
shell.cd(Config.buildPath);
|
|
|
|
|
shell.cd(buildPath);
|
|
|
|
|
await execa('git', ['add', '.']);
|
|
|
|
|
await execa('git', ['commit', '-m', `'发布新版本'`]);
|
|
|
|
|
await execa('git', ['push', 'origin', mappingBranch[env].build]);
|
|
|
|
|