@aion0/forge 0.1.7 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/forge-server.mjs +20 -0
- package/package.json +1 -1
package/bin/forge-server.mjs
CHANGED
|
@@ -24,6 +24,7 @@ const LOG_FILE = join(DATA_DIR, 'forge.log');
|
|
|
24
24
|
const isDev = process.argv.includes('--dev');
|
|
25
25
|
const isBackground = process.argv.includes('--background');
|
|
26
26
|
const isStop = process.argv.includes('--stop');
|
|
27
|
+
const isRebuild = process.argv.includes('--rebuild');
|
|
27
28
|
|
|
28
29
|
process.chdir(ROOT);
|
|
29
30
|
mkdirSync(DATA_DIR, { recursive: true });
|
|
@@ -55,6 +56,25 @@ if (isStop) {
|
|
|
55
56
|
process.exit(0);
|
|
56
57
|
}
|
|
57
58
|
|
|
59
|
+
// ── Rebuild ──
|
|
60
|
+
if (isRebuild || existsSync(join(ROOT, '.next', 'BUILD_ID'))) {
|
|
61
|
+
// Always rebuild after npm install (new version)
|
|
62
|
+
const buildIdFile = join(ROOT, '.next', 'BUILD_ID');
|
|
63
|
+
const pkgVersion = JSON.parse(readFileSync(join(ROOT, 'package.json'), 'utf-8')).version;
|
|
64
|
+
const versionFile = join(ROOT, '.next', '.forge-version');
|
|
65
|
+
const lastBuiltVersion = existsSync(versionFile) ? readFileSync(versionFile, 'utf-8').trim() : '';
|
|
66
|
+
if (isRebuild || lastBuiltVersion !== pkgVersion) {
|
|
67
|
+
console.log(`[forge] Rebuilding (v${pkgVersion})...`);
|
|
68
|
+
execSync('rm -rf .next', { cwd: ROOT });
|
|
69
|
+
execSync('npx next build', { cwd: ROOT, stdio: 'inherit' });
|
|
70
|
+
writeFileSync(versionFile, pkgVersion);
|
|
71
|
+
if (isRebuild) {
|
|
72
|
+
console.log('[forge] Rebuild complete');
|
|
73
|
+
process.exit(0);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
58
78
|
// ── Background ──
|
|
59
79
|
if (isBackground) {
|
|
60
80
|
// Build if needed
|