wishforge-ide/scripts/setup-local.mjs
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

25 lines
1.6 KiB
JavaScript

import { randomBytes } from 'node:crypto';
import { readFile, writeFile, mkdir } from 'node:fs/promises';
try {
await readFile('.env.local');
console.log('.env.local already exists; preserving it.');
process.exit(0);
} catch {}
const secret = () => randomBytes(32).toString('hex');
const dbPassword = secret();
const devToken = secret();
const config = `# Local only. Generated secrets; never commit this file.\nDATABASE_ADMIN_URL=postgresql://wishforge:wishforge-dev-only@127.0.0.1:55432/wishforge\nDATABASE_URL=postgresql://wishforge_app:${dbPassword}@127.0.0.1:55432/wishforge\nWF_DATABASE_APP_PASSWORD=${dbPassword}\nWF_DEV_AUTH_TOKEN=${devToken}\nWF_WORKER_TOKEN=${secret()}\nWF_VERIFIER_TOKEN=${secret()}\nWF_DEPLOYER_TOKEN=${secret()}\nWF_EVALUATOR_TOKEN=${secret()}\nWF_VAULT_KEY=${secret()}\nWF_SESSION_SECRET=${secret()}\nWF_PUBLIC_URL=http://localhost:3000\nWF_API_URL=http://127.0.0.1:4000\nWF_REGION=local\nWF_DISPATCH_TENANTS=demo\nPORT=4000\nTEMPORAL_ADDRESS=127.0.0.1:7233\nOIDC_ISSUER=http://127.0.0.1:4100/realms/wishforge\nOIDC_AUDIENCE=wishforge-api\nOIDC_CLIENT_ID=wishforge-web\nWF_WEB_CLIENT_ID=wishforge-web\n`;
await writeFile('.env.local', config, { mode: 0o600, flag: 'wx' });
await mkdir('apps/web', { recursive: true });
const webOnly =
config
.split('\n')
.filter(line =>
/^(WF_DEV_AUTH_TOKEN|WF_SESSION_SECRET|WF_PUBLIC_URL|WF_API_URL|OIDC_ISSUER|OIDC_CLIENT_ID)=/.test(line),
)
.join('\n') + '\n';
await writeFile('apps/web/.env.local', webOnly, { mode: 0o600, flag: 'wx' }).catch(e => {
if (e.code !== 'EEXIST') throw e;
});
console.log('Created private .env.local files. Start infra, then run db:migrate and db:seed.');