Files
thebet365/pack.mjs
Mars bbede5d164 fix(docker): upgrade Node.js to v22 and pnpm to v11 to resolve build failure
pnpm 11.5.2 requires Node.js v22.13+ and uses node:sqlite module unavailable in Node.js v20.
Also switch to --no-frozen-lockfile temporarily for lockfile format migration compatibility.

🤖 Generated with [Qoder][https://qoder.com]
2026-06-08 16:50:51 +08:00

69 lines
1.9 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env node
/**
* 生成部署用 zip排除 node_modules、构建产物、.git、本地 .env 等。
* 用法: node pack.mjs
* 输出: release/thebet365-deploy-YYYYMMDD-HHmmss.zip
*/
import { execSync } from 'node:child_process';
import { mkdirSync, statSync } from 'node:fs';
import { basename, join } from 'node:path';
const root = process.cwd();
const projectName = basename(root);
const parent = join(root, '..');
const stamp = new Date()
.toISOString()
.replace(/[-:]/g, '')
.slice(0, 15)
.replace('T', '-');
const outDir = join(root, 'release');
const outFile = join(outDir, `thebet365-deploy-${stamp}.zip`);
/** 相对项目根目录的路径tar 归档时加 projectName/ 前缀) */
const excludePaths = [
'node_modules',
'apps/api/node_modules',
'apps/player/node_modules',
'apps/admin/node_modules',
'packages/shared/node_modules',
'.claude',
'.git',
'.env',
'.env.local',
'.env.docker',
'apps/api/.env',
'apps/api/dist',
'apps/player/dist',
'apps/admin/dist',
'release',
];
mkdirSync(outDir, { recursive: true });
const excludeArgs = excludePaths
.map((p) => `--exclude=${projectName}/${p}`)
.join(' ');
const cmd = `tar -a -c -f "${outFile}" ${excludeArgs} -C "${parent}" "${projectName}"`;
console.log('Packing deployment archive...');
console.log('Excluding:');
for (const p of excludePaths) console.log(` - ${p}/`);
console.log('');
try {
execSync(cmd, { stdio: 'inherit' });
} catch {
console.error('\nPack failed. Ensure tar is available (Windows 10+ / Linux / macOS).');
process.exit(1);
}
const sizeMb = (statSync(outFile).size / (1024 * 1024)).toFixed(2);
console.log(`\nDone: ${outFile}`);
console.log(`Size: ${sizeMb} MB`);
console.log('\nUpload to server, extract under /www/wwwroot/thebet365, then:');
console.log(' cp .env.docker.example .env.docker');
console.log(' docker compose -f docker-compose.prod.yml --env-file .env.docker up -d --build');