updates for testmode

This commit is contained in:
Emily
2025-01-29 17:14:10 +01:00
parent bfeee8673c
commit a2e4ed9ee0
22 changed files with 343 additions and 61 deletions

View File

@@ -7,17 +7,11 @@ import { DeployHelper } from '../helpers/deploy-helper';
const TMP_PATH = path.join(__dirname, '../../tmp');
const LOCAL_PATH = path.join(__dirname, '../../dashboard');
const REMOTE_PATH = '/home/testmode/litlyx/dashboard';
const REMOTE_PATH = '/home/litlyx/dashboard';
const ZIP_NAME = 'dashboard.zip';
const TESTMODE_PORT = "4010";
const argvMode = process.argv[2]
if (argvMode != '--production' && argvMode != '--testmode') {
console.error('use --production or --testmode');
process.exit(1);
}
const MODE = argvMode === '--production' ? 'production' : 'testmode';
const MODE = DeployHelper.getMode();
const SKIP_BUILD = DeployHelper.getArgAt(0) == '--no-build';
console.log('Deploying dashboard in mode:', MODE);
@@ -28,20 +22,16 @@ async function main() {
if (fs.existsSync(TMP_PATH)) fs.rmSync(TMP_PATH, { force: true, recursive: true });
fs.ensureDirSync(TMP_PATH);
console.log('Building');
child.execSync(`cd ${LOCAL_PATH} && pnpm i && pnpm run build`)
if (!SKIP_BUILD) {
console.log('Building');
child.execSync(`cd ${LOCAL_PATH} && pnpm i && pnpm run build`)
}
console.log('Creting zip file');
console.log('Creating zip file');
const archive = createZip(TMP_PATH + '/' + ZIP_NAME);
archive.directory(LOCAL_PATH + '/.output', '/.output');
archive.file(LOCAL_PATH + '/ecosystem.config.js', { name: '/ecosystem.config.js' })
if (MODE === 'testmode') {
const ecosystemContent = fs.readFileSync(LOCAL_PATH + '/ecosystem.config.js', 'utf8');
const devContent = ecosystemContent.replace(/name: '(.*?)'/, "name: 'test-$1'").replace(/3010/, TESTMODE_PORT);
archive.append(Buffer.from(devContent), { name: '/ecosystem.config.js' });
} else {
archive.file(LOCAL_PATH + '/ecosystem.config.js', { name: '/ecosystem.config.js' })
}
// archive.file(LOCAL_PATH + '/.env', { name: '/.env' });
await archive.finalize();