From 6c4923b8c829873edb69cf7a4baeac95209c49f3 Mon Sep 17 00:00:00 2001 From: Bohdan Triapitsyn Date: Tue, 1 Sep 2026 16:37:40 +0300 Subject: [PATCH] fix: support Bun-only remote dev deployments --- scripts/oc-dev.config.example.json | 2 ++ scripts/oc-dev.mjs | 7 ++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/scripts/oc-dev.config.example.json b/scripts/oc-dev.config.example.json index 971c7f96..ffdc4425 100644 --- a/scripts/oc-dev.config.example.json +++ b/scripts/oc-dev.config.example.json @@ -14,6 +14,7 @@ "host": "example-host", "port": 3002, "dir": "testing-dev", + "lan": false, "apiOnly": true }, { @@ -22,6 +23,7 @@ "host": "example-host", "port": 3002, "dir": "testing-dev", + "lan": true, "apiOnly": false } ] diff --git a/scripts/oc-dev.mjs b/scripts/oc-dev.mjs index 43e6c990..a4346d4a 100755 --- a/scripts/oc-dev.mjs +++ b/scripts/oc-dev.mjs @@ -389,6 +389,7 @@ async function deployRemoteWeb(options, config) { const dir = remote.dir; const port = String(remote.port); const apiOnly = remote.apiOnly ? 'true' : 'false'; + const bindHost = remote.lan === false ? '127.0.0.1' : '0.0.0.0'; const packageBase = path.basename(packageFile); if (!host || !dir || !port) throw new Error(`Remote deployment ${remote.id} must define host, dir, and port.`); @@ -400,9 +401,9 @@ async function deployRemoteWeb(options, config) { run('scp', ['-q', packageFile, `${host}:~/${dir}/releases/${packageBase}`]); }); step('Resetting remote install state', () => run('ssh', [host, `cd ~/${dir} && rm -f package.json package-lock.json pnpm-lock.yaml bun.lockb && rm -rf node_modules`])); - step('Preparing remote package manifest', () => run('ssh', [host, `cd ~/${dir} && ${REMOTE_RUNTIME_ENV}; npm init -y >/dev/null 2>&1`])); - step('Installing remote package', () => run('ssh', [host, `cd ~/${dir} && ${REMOTE_RUNTIME_ENV}; npm install ./releases/${packageBase}`])); - step(`Starting remote instance on ${host}:${port}`, () => run('ssh', [host, `set -e; cd ~/${dir}; ${REMOTE_RUNTIME_ENV}; PASSWORD_VALUE=$(grep '^export OPENCHAMBER_UI_PASSWORD=' ~/.bashrc 2>/dev/null | sed -E 's/.*=["“]?([^"”]+)["”]?/\\1/' || true); if [ -n "$PASSWORD_VALUE" ]; then export OPENCHAMBER_UI_PASSWORD="$PASSWORD_VALUE"; fi; if [ ${quote(apiOnly)} = 'true' ]; then export OPENCHAMBER_API_ONLY=true; fi; OPENCHAMBER_HOST=0.0.0.0 node ./node_modules/@openchamber/web/bin/cli.js --port ${quote(port)} >/dev/null 2>&1; sleep 0.5; if command -v lsof >/dev/null 2>&1; then lsof -ti :${quote(port)} >/dev/null 2>&1 || exit 1; fi`])); + step('Preparing remote package manifest', () => run('ssh', [host, `set -e; cd ~/${dir}; ${REMOTE_RUNTIME_ENV}; if command -v bun >/dev/null 2>&1; then bun init -y; else npm init -y; fi`])); + step('Installing remote package', () => run('ssh', [host, `set -e; cd ~/${dir}; ${REMOTE_RUNTIME_ENV}; if command -v bun >/dev/null 2>&1; then bun add ./releases/${packageBase}; else npm install ./releases/${packageBase}; fi`])); + step(`Starting remote instance on ${host}:${port}`, () => run('ssh', [host, `set -e; cd ~/${dir}; ${REMOTE_RUNTIME_ENV}; PASSWORD_VALUE=$(grep '^export OPENCHAMBER_UI_PASSWORD=' ~/.bashrc 2>/dev/null | sed -E 's/.*=["“]?([^"”]+)["”]?/\\1/' || true); if [ -n "$PASSWORD_VALUE" ]; then export OPENCHAMBER_UI_PASSWORD="$PASSWORD_VALUE"; fi; if [ ${quote(apiOnly)} = 'true' ]; then export OPENCHAMBER_API_ONLY=true; fi; if command -v bun >/dev/null 2>&1; then OPENCHAMBER_HOST=${quote(bindHost)} bun ./node_modules/@openchamber/web/bin/cli.js --port ${quote(port)} >/dev/null 2>&1; else OPENCHAMBER_HOST=${quote(bindHost)} node ./node_modules/@openchamber/web/bin/cli.js --port ${quote(port)} >/dev/null 2>&1; fi; sleep 0.5; if command -v lsof >/dev/null 2>&1; then lsof -ti :${quote(port)} >/dev/null 2>&1 || exit 1; fi`])); log.success(`Remote deployment ready: ${host}:${port}`); }