diff --git a/dev-all.mts b/dev-all.mts deleted file mode 100644 index c8a7ff2..0000000 --- a/dev-all.mts +++ /dev/null @@ -1,117 +0,0 @@ -#!/usr/bin/env -S node --enable-source-maps -import { createServer as createHttpServer, request as httpRequest } from "node:http"; -import { URL } from "node:url"; -import { spawn } from "node:child_process"; -import fg from "fast-glob"; -import path from "node:path"; - -const REACT_PORT = 4450; -const PROXY_PORT = 4444; - -function detectEntryNames(): string[] { - const entries = fg.sync("src/**/index.{tsx,jsx}", { dot: false }); - return entries.map((entry) => path.basename(path.dirname(entry))); -} - -function startVite(configFile: string, port: number) { - const child = spawn( - process.platform === "win32" ? "pnpm.cmd" : "pnpm", - ["vite", "--config", configFile, "--port", String(port), "--strictPort"], - { - stdio: ["ignore", "pipe", "pipe"], - env: { - ...process.env, - VITE_DEV_CLIENT_ORIGIN: `http://localhost:${port}`, - }, - } - ); - - const prefix = (s: string) => `[react] ${s}`; - child.stdout.on("data", (d) => process.stdout.write(prefix(d.toString()))); - child.stderr.on("data", (d) => process.stderr.write(prefix(d.toString()))); - child.on("exit", (code) => { - console.log(`react exited with code ${code}`); - }); - return child; -} - -async function main() { - const entryNames = detectEntryNames(); - console.log("Detected widget entries:"); - for (const name of entryNames) { - console.log(` /${name}.js, /${name}.css`); - } - - const reactChild = startVite("vite.config.mts", REACT_PORT); - - // Simple proxy to keep legacy 4444 port and allow missing base prefix - const server = createHttpServer((req, res) => { - const urlObj = new URL(req.url || "/", `http://localhost:${PROXY_PORT}`); - - if (urlObj.pathname === "/") { - res.setHeader("content-type", "text/html; charset=utf-8"); - res.end( - `
Entries:
` + - `