From a3b267a5cb86f31a3efe2d75ecc91a3f4aac6dfb Mon Sep 17 00:00:00 2001 From: ryanngit Date: Fri, 10 Jul 2026 11:36:42 +0700 Subject: [PATCH] fix(cli): allow staged app bundle builds (#2479) Write the standalone app bundle and MITM bundle to NINEROUTER_CLI_APP_DIR when set, so staged deploys can build to a separate destination before swapping. Default output stays at cli/app when the env var is unset. --- cli/scripts/build-cli.js | 2 +- cli/scripts/buildMitm.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/cli/scripts/build-cli.js b/cli/scripts/build-cli.js index 625d94ba..a1b28c5f 100644 --- a/cli/scripts/build-cli.js +++ b/cli/scripts/build-cli.js @@ -7,7 +7,7 @@ const { execSync } = require("child_process"); const cliDir = path.resolve(__dirname, ".."); const appDir = path.resolve(cliDir, ".."); const rootDir = path.resolve(appDir, ".."); -const cliAppDir = path.join(cliDir, "app"); +const cliAppDir = process.env.NINEROUTER_CLI_APP_DIR || path.join(cliDir, "app"); const buildHomeDir = path.join(cliDir, ".build-home"); const buildDistDirName = ".next-cli-build"; const buildDistDir = path.join(appDir, buildDistDirName); diff --git a/cli/scripts/buildMitm.js b/cli/scripts/buildMitm.js index 45c1664c..e47f593a 100644 --- a/cli/scripts/buildMitm.js +++ b/cli/scripts/buildMitm.js @@ -12,7 +12,8 @@ const BUILD_CONFIG = { const cliDir = path.resolve(__dirname, ".."); const appDir = path.resolve(cliDir, ".."); -const cliMitmDir = path.join(cliDir, "app", "src", "mitm"); +const cliAppDir = process.env.NINEROUTER_CLI_APP_DIR || path.join(cliDir, "app"); +const cliMitmDir = path.join(cliAppDir, "src", "mitm"); // Bundle everything — no externals. This keeps MITM runtime self-contained so // it can be copied to DATA_DIR/runtime/ and spawned from there (escapes // node_modules file locks that block `npm i -g 9router@latest` on Windows).