eust-w 0ef99b1e6d style: add Prettier and EditorConfig, format the codebase
Adds prettier 3.9.8 (exact) with a shared config (single quotes,
120 columns, trailing commas), .prettierignore, .editorconfig and the
`format` / `format:check` scripts, then formats all TypeScript,
JavaScript, CSS, JSON and YAML sources.

Purely mechanical: no behaviour change. Typecheck passes, the vitest
suite and the 74 IDE node tests produce the same results as before
(socket-binding tests still cannot run inside this sandbox).
Previously the longest source line was ~3000 characters; reviewing the
following semantic changes now produces readable diffs.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-19 13:32:43 +08:00

52 lines
2.3 KiB
JavaScript

import { spawn } from 'node:child_process';
import { fileURLToPath } from 'node:url';
import { existsSync, mkdirSync } from 'node:fs';
const appRoot = fileURLToPath(new URL('../', import.meta.url));
const cli = fileURLToPath(new URL('../node_modules/@theia/cli/bin/theia.js', import.meta.url));
const production = process.env.NODE_ENV === 'production';
if (!existsSync(cli) || !existsSync(`${appRoot}lib/frontend/index.html`)) {
// Theia releases may emit frontend assets under lib; use backend generation
// as the authoritative build prerequisite below.
if (!existsSync(`${appRoot}src-gen/backend/main.js`)) {
console.error('Install and build this independent package first: npm install && npm run build');
process.exit(1);
}
}
if (production && process.env.WISHFORGE_GATEWAY_ENFORCED !== 'true') {
console.error('Production requires an authenticated workspace gateway. See README.md.');
process.exit(1);
}
const port = process.env.WISHFORGE_IDE_PORT ?? '4300';
if (!/^\d+$/.test(port) || Number(port) < 1 || Number(port) > 65535) throw new Error('Invalid WISHFORGE_IDE_PORT');
const hostname = process.env.WISHFORGE_IDE_HOST ?? '127.0.0.1';
const workspace = process.env.WISHFORGE_WORKSPACE_PATH ?? `${appRoot}workspace`;
if (!process.env.WISHFORGE_WORKSPACE_PATH) mkdirSync(workspace, { recursive: true });
if (!existsSync(workspace)) throw new Error('Configured workspace path does not exist');
const child = spawn(
process.execPath,
[cli, 'start', workspace, '--hostname', hostname, '--port', port, '--plugins', `local-dir:${appRoot}plugins`],
{
cwd: appRoot,
detached: process.platform !== 'win32',
stdio: 'inherit',
env: {
...process.env,
PYTHONDONTWRITEBYTECODE: '1',
WF_IDE_MANAGED_PLUGINS_DIR: `${appRoot}plugins`,
// No public/default OCT fallback while project-bound room admission is absent.
COLLABORATION_SERVER_URL: process.env.WF_COLLABORATION_GATEWAY_URL ?? 'https://collaboration-disabled.invalid/',
},
},
);
for (const signal of ['SIGINT', 'SIGTERM'])
process.on(signal, () => {
try {
if (process.platform !== 'win32' && child.pid) process.kill(-child.pid, signal);
else child.kill(signal);
} catch {
child.kill(signal);
}
});
child.on('exit', code => process.exit(code ?? 1));