wishforge-ide/scripts/build-local-web.mjs
eust-w da1cfcea13 🔥 Remove the cloud IDE
The cluster never ran Theia or the IDE gateway, so every workspace stayed
"未配置" forever. The feature is gone instead of half-present:

- API: workspace, launch and lifecycle endpoints, the gateway identity and
  its internal routes, the dispatcher's workspace provisioning and the
  lifecycle worker. Migration 003 deletes stored workspaces and settles
  their pending outbox items.
- Provisioner: workspace provisioning and lifecycle for both backends.
- Web: the 云 IDE panel, the launch route, the start-branch picker that
  listed IDE branches, and the workspace count on usage.
- apps/ide, infra/oct, dev:ide and the CI job; IDE parts of local k3s,
  network policies, RBAC, docs and the architecture diagram.

A wish can still start from a pushed branch through the API (sourceBranch).
Plan files and stored entitlements may still carry maxWorkspaces; it is
accepted and ignored.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-11-04 12:43:02 +08:00

56 lines
2.0 KiB
JavaScript

import { spawn } from 'node:child_process';
import { resolve } from 'node:path';
import { fileURLToPath, pathToFileURL } from 'node:url';
import { environment, loadLocalEnvironment } from './local-services.mjs';
import { buildWithRollback } from './local-web-build.mjs';
export async function main() {
const root = fileURLToPath(new URL('..', import.meta.url));
process.chdir(root);
loadLocalEnvironment();
// Load env in this parent, not Node's --env-file argv: Next forwards execArgv to
// worker NODE_OPTIONS, where Node rejects --env-file. No database credentials go to Web.
const build = () =>
new Promise((resolveBuild, reject) => {
const child = spawn(process.execPath, [resolve('node_modules/next/dist/bin/next'), 'build'], {
cwd: resolve('apps/web'),
env: environment(
[
/^WF_LOCAL_ACCESS/,
/^WF_LOCAL_ALLOWED_ORIGINS$/,
/^WF_DEV_AUTH_TOKEN$/,
/^WF_SESSION_SECRET$/,
/^WF_PUBLIC_URL$/,
/^WF_API_URL$/,
/^WF_WEB_/,
/^OIDC_/,
],
{ NODE_ENV: 'production', NEXT_TELEMETRY_DISABLED: '1' },
),
stdio: 'inherit',
});
const stop = () => child.kill('SIGTERM');
process.once('SIGINT', stop);
process.once('SIGTERM', stop);
child.on('error', reject);
child.on('close', code => {
process.removeListener('SIGINT', stop);
process.removeListener('SIGTERM', stop);
code === 0
? resolveBuild()
: reject(new Error(`Web build failed (${code ?? 'signal'}); the previous build was restored when available`));
});
});
const receipt = await buildWithRollback(root, build, {
port: Number(process.env.WF_WEB_PORT || 3000),
host: process.env.WF_WEB_HOST || '0.0.0.0',
});
console.log(JSON.stringify(receipt, null, 2));
}
if (process.argv[1] && pathToFileURL(resolve(process.argv[1])).href === import.meta.url)
main().catch(error => {
console.error(error.message);
process.exitCode = 1;
});