@brickkit/cli 0.7.3 → 0.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +173 -1
- package/dashboard-dist/CollapsiblePanel-DM8J3g8m.js +2 -0
- package/dashboard-dist/Geist-Variable.woff2 +0 -0
- package/dashboard-dist/GeistMono-Variable.woff2 +0 -0
- package/dashboard-dist/PopoverPopup-B6eMOlOC.js +1 -0
- package/dashboard-dist/api-reference-wTdT1AVt.js +260 -0
- package/dashboard-dist/app.css +2 -0
- package/dashboard-dist/app.js +18 -0
- package/dashboard-dist/core-CHWYtApw.js +1 -0
- package/dashboard-dist/docs-DflzpIIh.js +4 -0
- package/dashboard-dist/docs.css +1 -0
- package/dashboard-dist/preload-helper-CVJ-D494.js +1 -0
- package/dashboard-dist/react-jsx-runtime.js +4 -0
- package/dashboard-dist/react.js +3 -0
- package/dashboard-dist/rolldown-runtime-XKyaHtl9.js +1 -0
- package/dist/bin.d.ts.map +1 -1
- package/dist/bin.js +17 -6
- package/dist/bin.js.map +1 -1
- package/dist/dev-reporter.d.ts +15 -0
- package/dist/dev-reporter.d.ts.map +1 -0
- package/dist/dev-reporter.js +28 -0
- package/dist/dev-reporter.js.map +1 -0
- package/dist/dev-telemetry-store.js +1897 -0
- package/dist/dev-telemetry-store.js.map +1 -0
- package/dist/dev-telemetry.js +199 -0
- package/dist/dev-telemetry.js.map +1 -0
- package/dist/dev-worker.js +54 -9
- package/dist/dev-worker.js.map +1 -1
- package/dist/index.d.ts +24 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/runner.js +157 -8
- package/dist/runner.js.map +1 -1
- package/dist/vite.d.ts +11 -0
- package/dist/vite.d.ts.map +1 -1
- package/dist/vite.js +104 -6
- package/dist/vite.js.map +1 -1
- package/package.json +42 -4
- package/dist/port-utils.js +0 -13
- package/dist/port-utils.js.map +0 -1
package/dist/dev-worker.js
CHANGED
|
@@ -1,7 +1,31 @@
|
|
|
1
|
-
import { t as startDevApplication } from "./runner.js";
|
|
2
|
-
import {
|
|
1
|
+
import { i as parsePort, t as startDevApplication } from "./runner.js";
|
|
2
|
+
import { i as sendToSupervisor, n as installWorkerTelemetry, r as reportWorkerError } from "./dev-telemetry.js";
|
|
3
|
+
import { getGlobalRegistry } from "@brickkit/core";
|
|
3
4
|
//#region src/dev-worker.ts
|
|
4
|
-
|
|
5
|
+
const telemetry = process.argv[6] === "1";
|
|
6
|
+
let startupComplete = false;
|
|
7
|
+
let reported = false;
|
|
8
|
+
async function reportOnce(phase, error) {
|
|
9
|
+
if (!telemetry || reported) return;
|
|
10
|
+
reported = true;
|
|
11
|
+
await reportWorkerError(phase, error);
|
|
12
|
+
}
|
|
13
|
+
async function exitAfterFailure(phase, error) {
|
|
14
|
+
await reportOnce(phase, error);
|
|
15
|
+
console.error(error);
|
|
16
|
+
process.exit(1);
|
|
17
|
+
}
|
|
18
|
+
if (telemetry) {
|
|
19
|
+
installWorkerTelemetry();
|
|
20
|
+
const phaseOf = () => startupComplete ? "uncaught" : "startup";
|
|
21
|
+
process.on("uncaughtException", (error) => {
|
|
22
|
+
exitAfterFailure(phaseOf(), error);
|
|
23
|
+
});
|
|
24
|
+
process.on("unhandledRejection", (reason) => {
|
|
25
|
+
exitAfterFailure(startupComplete ? "unhandled-rejection" : "startup", reason);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
if (process.argv[2]) {
|
|
5
29
|
const files = /* @__PURE__ */ new Set();
|
|
6
30
|
try {
|
|
7
31
|
await Bun.build({
|
|
@@ -24,12 +48,33 @@ if (process.argv[5] && process.argv[2]) {
|
|
|
24
48
|
});
|
|
25
49
|
}
|
|
26
50
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
51
|
+
try {
|
|
52
|
+
const app = await startDevApplication({
|
|
53
|
+
entry: process.argv[2],
|
|
54
|
+
port: parsePort(process.argv[3] || void 0, process.env.PORT),
|
|
55
|
+
prefix: process.argv[4] || void 0,
|
|
56
|
+
clientOutput: process.argv[5] || void 0
|
|
57
|
+
});
|
|
58
|
+
startupComplete = true;
|
|
59
|
+
if (telemetry) {
|
|
60
|
+
sendToSupervisor({
|
|
61
|
+
type: "brick:architecture",
|
|
62
|
+
architecture: getGlobalRegistry().exportArchitecture(app.definition)
|
|
63
|
+
});
|
|
64
|
+
sendToSupervisor({
|
|
65
|
+
type: "brick:documentation",
|
|
66
|
+
documentation: app.definition.documentation
|
|
67
|
+
});
|
|
68
|
+
app.referenceDocuments().then((documents) => sendToSupervisor({
|
|
69
|
+
type: "brick:api-documents",
|
|
70
|
+
documents
|
|
71
|
+
}), (error) => console.warn(`[Brick-TS] Could not load the API documents: ${error instanceof Error ? error.message : String(error)}`));
|
|
72
|
+
}
|
|
73
|
+
if (telemetry && !app.definition.telemetry) console.warn("[Brick-TS] The dashboard shows no requests: pass { telemetry: true } to brick() in your app entry.");
|
|
74
|
+
} catch (error) {
|
|
75
|
+
await reportOnce("startup", error);
|
|
76
|
+
throw error;
|
|
77
|
+
}
|
|
33
78
|
//#endregion
|
|
34
79
|
export {};
|
|
35
80
|
|
package/dist/dev-worker.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev-worker.js","names":[],"sources":["../src/dev-worker.ts"],"sourcesContent":["import { startDevApplication } from \"./runner\";\nimport { parsePort } from \"./port-utils\";\n\n// Scan local imports so dependencies outside the app directory are watched too.\nif (process.argv[
|
|
1
|
+
{"version":3,"file":"dev-worker.js","names":[],"sources":["../src/dev-worker.ts"],"sourcesContent":["import { getGlobalRegistry } from \"@brickkit/core\";\nimport { startDevApplication } from \"./runner\";\nimport { parsePort } from \"./port-utils\";\nimport {\n installWorkerTelemetry,\n reportWorkerError,\n sendToSupervisor,\n} from \"./dev-telemetry\";\nimport type { WorkerErrorPhase } from \"./dev-telemetry\";\n\n// argv[6] is \"1\" when the supervisor serves the dashboard and needs spans.\nconst telemetry = process.argv[6] === \"1\";\nlet startupComplete = false;\nlet reported = false;\n\nasync function reportOnce(phase: WorkerErrorPhase, error: unknown) {\n if (!telemetry || reported) return;\n reported = true;\n await reportWorkerError(phase, error);\n}\n\nasync function exitAfterFailure(phase: WorkerErrorPhase, error: unknown) {\n await reportOnce(phase, error);\n console.error(error);\n process.exit(1);\n}\n\nif (telemetry) {\n installWorkerTelemetry();\n // Failures before the app is listening are startup failures, not crashes.\n const phaseOf = (): WorkerErrorPhase =>\n startupComplete ? \"uncaught\" : \"startup\";\n process.on(\"uncaughtException\", (error) => {\n void exitAfterFailure(phaseOf(), error);\n });\n process.on(\"unhandledRejection\", (reason) => {\n void exitAfterFailure(\n startupComplete ? \"unhandled-rejection\" : \"startup\",\n reason,\n );\n });\n}\n\n// Scan local imports so dependencies outside the app directory are watched too.\nif (process.argv[2]) {\n const files = new Set<string>();\n try {\n await Bun.build({\n entrypoints: [process.argv[2]],\n target: \"bun\",\n packages: \"external\",\n plugins: [\n {\n name: \"brick:dependencies\",\n setup(build) {\n build.onLoad({ filter: /./ }, (args) => {\n files.add(args.path);\n return undefined;\n });\n },\n },\n ],\n });\n } finally {\n process.send?.({ type: \"brick:dependencies\", files: [...files] });\n }\n}\n\ntry {\n const app = await startDevApplication({\n entry: process.argv[2],\n port: parsePort(process.argv[3] || undefined, process.env.PORT),\n prefix: process.argv[4] || undefined,\n clientOutput: process.argv[5] || undefined,\n });\n startupComplete = true;\n if (telemetry) {\n void sendToSupervisor({\n type: \"brick:architecture\",\n architecture: getGlobalRegistry().exportArchitecture(app.definition),\n });\n void sendToSupervisor({\n type: \"brick:documentation\",\n documentation: app.definition.documentation,\n });\n void app.referenceDocuments().then(\n (documents) =>\n sendToSupervisor({ type: \"brick:api-documents\", documents }),\n (error: unknown) =>\n console.warn(\n `[Brick-TS] Could not load the API documents: ${error instanceof Error ? error.message : String(error)}`,\n ),\n );\n }\n if (telemetry && !app.definition.telemetry) {\n console.warn(\n \"[Brick-TS] The dashboard shows no requests: pass { telemetry: true } to brick() in your app entry.\",\n );\n }\n} catch (error) {\n await reportOnce(\"startup\", error);\n throw error;\n}\n"],"mappings":";;;;AAWA,MAAM,YAAY,QAAQ,KAAK,OAAO;AACtC,IAAI,kBAAkB;AACtB,IAAI,WAAW;AAEf,eAAe,WAAW,OAAyB,OAAgB;CACjE,IAAI,CAAC,aAAa,UAAU;CAC5B,WAAW;CACX,MAAM,kBAAkB,OAAO,KAAK;AACtC;AAEA,eAAe,iBAAiB,OAAyB,OAAgB;CACvE,MAAM,WAAW,OAAO,KAAK;CAC7B,QAAQ,MAAM,KAAK;CACnB,QAAQ,KAAK,CAAC;AAChB;AAEA,IAAI,WAAW;CACb,uBAAuB;CAEvB,MAAM,gBACJ,kBAAkB,aAAa;CACjC,QAAQ,GAAG,sBAAsB,UAAU;EACzC,iBAAsB,QAAQ,GAAG,KAAK;CACxC,CAAC;CACD,QAAQ,GAAG,uBAAuB,WAAW;EAC3C,iBACE,kBAAkB,wBAAwB,WAC1C,MACF;CACF,CAAC;AACH;AAGA,IAAI,QAAQ,KAAK,IAAI;CACnB,MAAM,wBAAQ,IAAI,IAAY;CAC9B,IAAI;EACF,MAAM,IAAI,MAAM;GACd,aAAa,CAAC,QAAQ,KAAK,EAAE;GAC7B,QAAQ;GACR,UAAU;GACV,SAAS,CACP;IACE,MAAM;IACN,MAAM,OAAO;KACX,MAAM,OAAO,EAAE,QAAQ,IAAI,IAAI,SAAS;MACtC,MAAM,IAAI,KAAK,IAAI;KAErB,CAAC;IACH;GACF,CACF;EACF,CAAC;CACH,UAAU;EACR,QAAQ,OAAO;GAAE,MAAM;GAAsB,OAAO,CAAC,GAAG,KAAK;EAAE,CAAC;CAClE;AACF;AAEA,IAAI;CACF,MAAM,MAAM,MAAM,oBAAoB;EACpC,OAAO,QAAQ,KAAK;EACpB,MAAM,UAAU,QAAQ,KAAK,MAAM,KAAA,GAAW,QAAQ,IAAI,IAAI;EAC9D,QAAQ,QAAQ,KAAK,MAAM,KAAA;EAC3B,cAAc,QAAQ,KAAK,MAAM,KAAA;CACnC,CAAC;CACD,kBAAkB;CAClB,IAAI,WAAW;EACb,iBAAsB;GACpB,MAAM;GACN,cAAc,kBAAkB,CAAC,CAAC,mBAAmB,IAAI,UAAU;EACrE,CAAC;EACD,iBAAsB;GACpB,MAAM;GACN,eAAe,IAAI,WAAW;EAChC,CAAC;EACD,IAAS,mBAAmB,CAAC,CAAC,MAC3B,cACC,iBAAiB;GAAE,MAAM;GAAuB;EAAU,CAAC,IAC5D,UACC,QAAQ,KACN,gDAAgD,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,GACvG,CACJ;CACF;CACA,IAAI,aAAa,CAAC,IAAI,WAAW,WAC/B,QAAQ,KACN,oGACF;AAEJ,SAAS,OAAO;CACd,MAAM,WAAW,WAAW,KAAK;CACjC,MAAM;AACR"}
|
package/dist/index.d.ts
CHANGED
|
@@ -9,7 +9,31 @@ interface DevServerOptions {
|
|
|
9
9
|
clientOutput?: string;
|
|
10
10
|
/** Frontend command, launched once after the first successful generation. */
|
|
11
11
|
frontend?: string;
|
|
12
|
+
/**
|
|
13
|
+
* Local dashboard with live requests, traces, errors, and reloads. Needs an
|
|
14
|
+
* entry. `historyDays` is how long finished requests are kept on disk
|
|
15
|
+
* (default 90); zero keeps live data only.
|
|
16
|
+
*/
|
|
17
|
+
dashboard?: {
|
|
18
|
+
port: number;
|
|
19
|
+
historyDays?: number;
|
|
20
|
+
} | false;
|
|
12
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* What `brick dev` runs: start the application, restart it when its files
|
|
24
|
+
* change, and serve the dashboard beside it. With an `entry`, the app runs in
|
|
25
|
+
* a worker process that restarts on every change to the entry or the files it
|
|
26
|
+
* imports, and reports its requests to the dashboard; without one, a server
|
|
27
|
+
* with the registered services starts in this process.
|
|
28
|
+
*
|
|
29
|
+
* @param options - `entry`, `port` (else `PORT`, else 4000), `prefix`,
|
|
30
|
+
* `clientOutput` to regenerate the typed client's contract on each start,
|
|
31
|
+
* `frontend` to launch a frontend command once, and `dashboard` (`port` and
|
|
32
|
+
* `historyDays`, or `false`).
|
|
33
|
+
* @returns The application, when started in this process.
|
|
34
|
+
* @throws When `frontend` is given without `clientOutput`, or the dashboard
|
|
35
|
+
* would use the app's port.
|
|
36
|
+
*/
|
|
13
37
|
export declare function startDevServer(options?: DevServerOptions): Promise<BrickApp$1 | {
|
|
14
38
|
stop: () => void;
|
|
15
39
|
}>;
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","names":["BrickApp","BrickApp"],"sources":["../src/runner.ts","../src/build.ts","../src/client-contract.ts"],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":["BrickApp","BrickApp"],"sources":["../src/runner.ts","../src/build.ts","../src/client-contract.ts"],"mappings":";;;UAyBiB;EACf;EACA;EACA;;EAEA;;EAEA;;;;;;EAMA;IAAc;IAAc;;;;;;;;;;;;;;;;;;wBAqMR,eAAe,UAAS,mBAAqB,QAAAA;;;;;UCrOlD;;EAEf;EACA;EACA;;EAEA;;;wBAIoB,iBAAiB,SAAS,0BAAuB;;;;;;;;wBCVvD,uBAAuB,KAAKC"}
|
package/dist/runner.js
CHANGED
|
@@ -1,7 +1,76 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as isLoopbackHost, i as startDevDashboard, n as DocsHost, o as openHistory, t as DevTelemetryStore } from "./dev-telemetry-store.js";
|
|
2
|
+
import { t as installTracing } from "./dev-telemetry.js";
|
|
3
|
+
import { brick, getGlobalRegistry, getPluginActionRoute, isBrickApp } from "@brickkit/core";
|
|
2
4
|
import { existsSync, watch } from "fs";
|
|
3
5
|
import { basename, dirname, resolve } from "path";
|
|
4
6
|
import { fileURLToPath } from "node:url";
|
|
7
|
+
//#region src/port-utils.ts
|
|
8
|
+
function parsePort(portStr, envPort) {
|
|
9
|
+
let port;
|
|
10
|
+
if (portStr !== void 0) port = Number(portStr);
|
|
11
|
+
else if (envPort !== void 0 && envPort !== "") port = Number(envPort);
|
|
12
|
+
else port = 4e3;
|
|
13
|
+
if (!Number.isInteger(port) || port < 1 || port > 65535) throw new Error(`Invalid port: ${port}. Port must be an integer between 1 and 65535`);
|
|
14
|
+
return port;
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
//#region src/production-dashboard.ts
|
|
18
|
+
/**
|
|
19
|
+
* Serve the monitoring dashboard an app asks for with `brick({ dashboard })`,
|
|
20
|
+
* in the process that serves the app. It listens on a port of its own, so it
|
|
21
|
+
* stays up when the app's routes do not answer, and its `/_health` tells an
|
|
22
|
+
* uptime monitor whether the app does. From here on `ctx.logger` and `console`
|
|
23
|
+
* lines written during a request go to the dashboard, not the console.
|
|
24
|
+
*
|
|
25
|
+
* Call it before the app starts listening. Returns undefined when the app
|
|
26
|
+
* asks for no dashboard, or when it cannot start (the app runs on without it,
|
|
27
|
+
* and says so). A configuration that would leave the dashboard open to others
|
|
28
|
+
* throws instead: the app must not start unprotected.
|
|
29
|
+
*/
|
|
30
|
+
async function startProductionDashboard(app, options) {
|
|
31
|
+
const config = app.definition.dashboard;
|
|
32
|
+
if (!config) return void 0;
|
|
33
|
+
const warn = options.warn ?? ((message) => console.warn(message));
|
|
34
|
+
const host = config.host ?? "127.0.0.1";
|
|
35
|
+
const port = config.port ?? 9400;
|
|
36
|
+
if (!isLoopbackHost(host) && !config.auth) throw new Error(`Brick: the dashboard would listen on ${host}, where others can reach it, so it needs access control. Set dashboard.auth with a token or an authorize function.`);
|
|
37
|
+
const history = await openHistory({
|
|
38
|
+
directory: options.directory ?? process.cwd(),
|
|
39
|
+
days: config.historyDays ?? 0,
|
|
40
|
+
warn
|
|
41
|
+
});
|
|
42
|
+
const store = new DevTelemetryStore({ history });
|
|
43
|
+
let started;
|
|
44
|
+
try {
|
|
45
|
+
started = await startDevDashboard({
|
|
46
|
+
port,
|
|
47
|
+
host,
|
|
48
|
+
mode: "production",
|
|
49
|
+
auth: config.auth,
|
|
50
|
+
store,
|
|
51
|
+
history,
|
|
52
|
+
probe: async () => {
|
|
53
|
+
return (await fetch(`http://127.0.0.1:${options.appPort}/_health`, { signal: AbortSignal.timeout(2e3) })).ok;
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
} catch (error) {
|
|
57
|
+
history?.close();
|
|
58
|
+
warn(`[Brick-TS] ${error instanceof Error ? error.message : String(error)} Continuing without the dashboard.`);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
if (!installTracing((records) => store.ingest(records, store.latestGeneration))) warn("[Brick-TS] Another tracer provider is already registered, so the dashboard will show no requests or logs.");
|
|
62
|
+
const generation = store.startGeneration("application started");
|
|
63
|
+
store.setArchitecture(getGlobalRegistry().exportArchitecture(app.definition), generation);
|
|
64
|
+
return {
|
|
65
|
+
host,
|
|
66
|
+
port: started.port,
|
|
67
|
+
stop() {
|
|
68
|
+
started.stop();
|
|
69
|
+
history?.close();
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
//#endregion
|
|
5
74
|
//#region src/runner.ts
|
|
6
75
|
async function createServer(options, label, application) {
|
|
7
76
|
let port;
|
|
@@ -36,6 +105,7 @@ async function createServer(options, label, application) {
|
|
|
36
105
|
}
|
|
37
106
|
async function startProdServer(options = {}) {
|
|
38
107
|
const entry = options.entry;
|
|
108
|
+
let exported;
|
|
39
109
|
if (entry) {
|
|
40
110
|
const resolvedEntry = resolve(process.cwd(), entry);
|
|
41
111
|
if (!existsSync(resolvedEntry)) {
|
|
@@ -43,11 +113,13 @@ async function startProdServer(options = {}) {
|
|
|
43
113
|
process.exit(1);
|
|
44
114
|
}
|
|
45
115
|
console.log(`[Brick-TS] Loading application entry: ${resolvedEntry}`);
|
|
46
|
-
await import(resolvedEntry);
|
|
116
|
+
const module = await import(resolvedEntry);
|
|
117
|
+
if (isBrickApp(module?.default)) exported = module.default;
|
|
47
118
|
}
|
|
119
|
+
if (exported && options.prefix !== void 0) console.warn(`[Brick-TS] Ignoring prefix ${options.prefix}: exported BrickApp prefix ${exported.definition.prefix} takes precedence.`);
|
|
48
120
|
const port = options.port !== void 0 ? options.port : process.env.PORT !== void 0 && process.env.PORT !== "" ? Number(process.env.PORT) : 4e3;
|
|
49
121
|
if (!Number.isInteger(port) || port < 1 || port > 65535) throw new Error(`Invalid port: ${port}. Port must be an integer between 1 and 65535`);
|
|
50
|
-
const app = brick({
|
|
122
|
+
const app = exported ?? brick({
|
|
51
123
|
port,
|
|
52
124
|
prefix: options.prefix
|
|
53
125
|
});
|
|
@@ -66,9 +138,14 @@ async function startProdServer(options = {}) {
|
|
|
66
138
|
console.log(` -> ${method.padEnd(6)} ${path}`);
|
|
67
139
|
}
|
|
68
140
|
}
|
|
141
|
+
const dashboard = await startProductionDashboard(app, { appPort: port });
|
|
69
142
|
app.listen(port);
|
|
70
143
|
console.log(`\n⚡ API Gateway running on: http://localhost:${port}`);
|
|
71
144
|
console.log(`🩺 Health check: http://localhost:${port}/_health`);
|
|
145
|
+
if (dashboard) {
|
|
146
|
+
const shown = dashboard.host === "0.0.0.0" || dashboard.host === "::" ? "localhost" : dashboard.host.includes(":") ? `[${dashboard.host.replace(/^\[|\]$/g, "")}]` : dashboard.host;
|
|
147
|
+
console.log(`📊 Dashboard: http://${shown}:${dashboard.port} (health: /_health)`);
|
|
148
|
+
}
|
|
72
149
|
console.log(`🗺️ Architecture graph: http://localhost:${port}/_brick/services\n`);
|
|
73
150
|
return app;
|
|
74
151
|
}
|
|
@@ -87,6 +164,21 @@ async function startDevApplication(options) {
|
|
|
87
164
|
}
|
|
88
165
|
return createServer(options, "Development", isBrickApp(module?.default) ? module.default : void 0);
|
|
89
166
|
}
|
|
167
|
+
/**
|
|
168
|
+
* What `brick dev` runs: start the application, restart it when its files
|
|
169
|
+
* change, and serve the dashboard beside it. With an `entry`, the app runs in
|
|
170
|
+
* a worker process that restarts on every change to the entry or the files it
|
|
171
|
+
* imports, and reports its requests to the dashboard; without one, a server
|
|
172
|
+
* with the registered services starts in this process.
|
|
173
|
+
*
|
|
174
|
+
* @param options - `entry`, `port` (else `PORT`, else 4000), `prefix`,
|
|
175
|
+
* `clientOutput` to regenerate the typed client's contract on each start,
|
|
176
|
+
* `frontend` to launch a frontend command once, and `dashboard` (`port` and
|
|
177
|
+
* `historyDays`, or `false`).
|
|
178
|
+
* @returns The application, when started in this process.
|
|
179
|
+
* @throws When `frontend` is given without `clientOutput`, or the dashboard
|
|
180
|
+
* would use the app's port.
|
|
181
|
+
*/
|
|
90
182
|
async function startDevServer(options = {}) {
|
|
91
183
|
const entry = options.entry;
|
|
92
184
|
if (!entry && (options.clientOutput || options.frontend)) throw new Error("Brick: --client and --frontend require an app entry.");
|
|
@@ -98,25 +190,45 @@ async function startDevServer(options = {}) {
|
|
|
98
190
|
}
|
|
99
191
|
const worker = new URL(import.meta.url.endsWith(".ts") ? "./dev-worker.ts" : "./dev-worker.js", import.meta.url);
|
|
100
192
|
if (options.frontend && !options.clientOutput) throw new Error("Brick: --frontend requires --client <file>.");
|
|
193
|
+
if (options.dashboard && options.port !== void 0 && options.dashboard.port === options.port) throw new Error("Brick: dashboard port must differ from the API port. Use --dashboard-port <number>.");
|
|
194
|
+
const appPort = () => parsePort(options.port === void 0 ? void 0 : String(options.port), process.env.PORT);
|
|
195
|
+
const history = options.dashboard ? await openHistory({
|
|
196
|
+
directory: process.cwd(),
|
|
197
|
+
days: options.dashboard.historyDays ?? 90,
|
|
198
|
+
warn: (message) => console.warn(message)
|
|
199
|
+
}) : void 0;
|
|
200
|
+
const telemetry = options.dashboard ? new DevTelemetryStore({ history }) : void 0;
|
|
201
|
+
const docs = telemetry ? new DocsHost(telemetry, (message) => console.warn(message)) : void 0;
|
|
101
202
|
let frontend;
|
|
102
203
|
const dependencyFiles = /* @__PURE__ */ new Set();
|
|
103
204
|
const dependencyWatchers = /* @__PURE__ */ new Map();
|
|
104
205
|
let stopped = false;
|
|
105
206
|
const intentionalExits = /* @__PURE__ */ new WeakSet();
|
|
207
|
+
let generationCount = 0;
|
|
208
|
+
let childGeneration = 0;
|
|
106
209
|
const launch = () => {
|
|
210
|
+
const generation = ++generationCount;
|
|
211
|
+
childGeneration = generation;
|
|
212
|
+
telemetry?.recordReload({
|
|
213
|
+
kind: "started",
|
|
214
|
+
generation
|
|
215
|
+
});
|
|
107
216
|
const application = Bun.spawn([
|
|
108
217
|
process.execPath,
|
|
109
218
|
fileURLToPath(worker),
|
|
110
219
|
resolvedEntry,
|
|
111
220
|
String(options.port ?? ""),
|
|
112
221
|
options.prefix ?? "",
|
|
113
|
-
options.clientOutput ? resolve(options.clientOutput) : ""
|
|
222
|
+
options.clientOutput ? resolve(options.clientOutput) : "",
|
|
223
|
+
telemetry ? "1" : ""
|
|
114
224
|
], {
|
|
115
225
|
cwd: process.cwd(),
|
|
116
226
|
stdout: "inherit",
|
|
117
227
|
stderr: "inherit",
|
|
118
228
|
ipc(message) {
|
|
119
229
|
if (!message || typeof message !== "object" || !("type" in message)) return;
|
|
230
|
+
if (telemetry && message.type === "brick:telemetry" && "records" in message && Array.isArray(message.records)) telemetry.ingest(message.records, generation);
|
|
231
|
+
if (telemetry && message.type === "brick:error" && "phase" in message && "error" in message) telemetry.recordWorkerError(message.phase, message.error, generation);
|
|
120
232
|
if (message.type === "brick:contract-ready" && options.frontend && !frontend && !stopped) frontend = Bun.spawn([
|
|
121
233
|
process.env.SHELL ?? "/bin/sh",
|
|
122
234
|
"-c",
|
|
@@ -127,6 +239,14 @@ async function startDevServer(options = {}) {
|
|
|
127
239
|
stdout: "inherit",
|
|
128
240
|
stderr: "inherit"
|
|
129
241
|
});
|
|
242
|
+
if (telemetry && message.type === "brick:architecture" && "architecture" in message) telemetry.setArchitecture(message.architecture, generation);
|
|
243
|
+
if (docs && message.type === "brick:documentation") docs.configure(dirname(resolvedEntry), "documentation" in message ? message.documentation : void 0);
|
|
244
|
+
if (telemetry && message.type === "brick:api-documents" && "documents" in message && Array.isArray(message.documents)) telemetry.setApiDocuments(message.documents, `http://localhost:${appPort()}`);
|
|
245
|
+
if (telemetry && message.type === "brick:contract-ready") telemetry.recordReload({
|
|
246
|
+
kind: "contract-ready",
|
|
247
|
+
generation,
|
|
248
|
+
detail: "browser contract generated"
|
|
249
|
+
});
|
|
130
250
|
if (message.type === "brick:dependencies" && "files" in message && Array.isArray(message.files)) for (const file of message.files) {
|
|
131
251
|
if (typeof file !== "string" || file === resolve(options.clientOutput ?? "_brick/contract.ts")) continue;
|
|
132
252
|
dependencyFiles.add(file);
|
|
@@ -139,10 +259,31 @@ async function startDevServer(options = {}) {
|
|
|
139
259
|
}
|
|
140
260
|
});
|
|
141
261
|
application.exited.then((code) => {
|
|
142
|
-
if (!stopped && !intentionalExits.has(application))
|
|
262
|
+
if (!stopped && !intentionalExits.has(application)) {
|
|
263
|
+
console.error(`[Brick-TS] Application process exited with code ${code}. Waiting for changes to restart.`);
|
|
264
|
+
telemetry?.recordReload({
|
|
265
|
+
kind: "exited",
|
|
266
|
+
generation,
|
|
267
|
+
detail: `exit code ${code}`
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
telemetry?.interruptGeneration(generation);
|
|
143
271
|
});
|
|
144
272
|
return application;
|
|
145
273
|
};
|
|
274
|
+
const dashboard = telemetry && options.dashboard ? await startDevDashboard({
|
|
275
|
+
port: options.dashboard.port,
|
|
276
|
+
store: telemetry,
|
|
277
|
+
history,
|
|
278
|
+
docs: () => docs?.current,
|
|
279
|
+
restart: () => {
|
|
280
|
+
restart("dashboard");
|
|
281
|
+
}
|
|
282
|
+
}).catch((error) => {
|
|
283
|
+
history?.close();
|
|
284
|
+
throw error;
|
|
285
|
+
}) : void 0;
|
|
286
|
+
if (dashboard) console.log(`📊 Dev dashboard: http://127.0.0.1:${dashboard.port}`);
|
|
146
287
|
let child = launch();
|
|
147
288
|
const watchDirs = [.../* @__PURE__ */ new Set([
|
|
148
289
|
resolve("src"),
|
|
@@ -152,14 +293,19 @@ async function startDevServer(options = {}) {
|
|
|
152
293
|
let pending;
|
|
153
294
|
let restarting = false;
|
|
154
295
|
let dirty = false;
|
|
155
|
-
async function restart() {
|
|
296
|
+
async function restart(trigger = "changes") {
|
|
156
297
|
dirty = true;
|
|
157
298
|
if (restarting || stopped) return;
|
|
158
299
|
restarting = true;
|
|
159
300
|
try {
|
|
160
301
|
while (dirty && !stopped) {
|
|
161
302
|
dirty = false;
|
|
162
|
-
console.log("\n📝 Changes detected. Restarting server...");
|
|
303
|
+
console.log(trigger === "changes" ? "\n📝 Changes detected. Restarting server..." : "\n🔄 Restart requested from the dashboard. Restarting server...");
|
|
304
|
+
telemetry?.recordReload({
|
|
305
|
+
kind: "restarting",
|
|
306
|
+
generation: childGeneration,
|
|
307
|
+
detail: trigger === "changes" ? "source changed" : "restart from dashboard"
|
|
308
|
+
});
|
|
163
309
|
intentionalExits.add(child);
|
|
164
310
|
child.kill();
|
|
165
311
|
await child.exited;
|
|
@@ -201,6 +347,9 @@ async function startDevServer(options = {}) {
|
|
|
201
347
|
if (!(error instanceof Error && "code" in error && error.code === "ESRCH")) throw error;
|
|
202
348
|
}
|
|
203
349
|
}
|
|
350
|
+
dashboard?.stop();
|
|
351
|
+
docs?.close();
|
|
352
|
+
history?.close();
|
|
204
353
|
child.kill();
|
|
205
354
|
process.off("SIGINT", onSignal);
|
|
206
355
|
process.off("SIGTERM", onSignal);
|
|
@@ -217,6 +366,6 @@ async function startDevServer(options = {}) {
|
|
|
217
366
|
return { stop };
|
|
218
367
|
}
|
|
219
368
|
//#endregion
|
|
220
|
-
export { startDevServer as n, startProdServer as r, startDevApplication as t };
|
|
369
|
+
export { parsePort as i, startDevServer as n, startProdServer as r, startDevApplication as t };
|
|
221
370
|
|
|
222
371
|
//# sourceMappingURL=runner.js.map
|
package/dist/runner.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runner.js","names":[],"sources":["../src/runner.ts"],"sourcesContent":["import { existsSync } from \"fs\";\nimport { watch } from \"fs\";\nimport { resolve, dirname, basename } from \"path\";\nimport { fileURLToPath } from \"node:url\";\nimport {\n brick,\n getPluginActionRoute,\n isBrickApp,\n type BrickApp,\n} from \"@brickkit/core\";\n\nexport interface DevServerOptions {\n port?: number;\n entry?: string;\n prefix?: string;\n /** Generate a browser contract before starting the backend and frontend. */\n clientOutput?: string;\n /** Frontend command, launched once after the first successful generation. */\n frontend?: string;\n}\n\nasync function createServer(\n options: DevServerOptions,\n label: string,\n application?: BrickApp,\n) {\n let port: number;\n if (options.port !== undefined) {\n port = options.port;\n } else if (process.env.PORT !== undefined && process.env.PORT !== \"\") {\n port = Number(process.env.PORT);\n } else {\n port = 4000;\n }\n if (!Number.isInteger(port) || port < 1 || port > 65535) {\n throw new Error(\n `Invalid port: ${port}. Port must be an integer between 1 and 65535`,\n );\n }\n\n const app =\n application ??\n brick({\n port,\n prefix: options.prefix,\n });\n\n await app.listen({ port });\n\n const prefix = app.definition.prefix;\n const services = app.definition.services;\n\n console.log(`\\n🧱 Brick-TS ${label} Server`);\n console.log(` Registered Services: ${services.length}`);\n\n for (const svc of services) {\n const actions = svc.listActions();\n console.log(` • ${svc.name} (${actions.length} actions)`);\n for (const act of actions) {\n const pluginRoute = getPluginActionRoute(act, prefix);\n if (pluginRoute === false) continue;\n const method = pluginRoute?.method ?? act.config.method ?? \"POST\";\n const path =\n pluginRoute?.path ??\n act.config.path ??\n `${prefix}/${svc.name}/${act.name}`;\n console.log(` -> ${method.padEnd(6)} ${path}`);\n }\n }\n\n console.log(`\\n⚡ API Gateway running on: http://localhost:${port}`);\n console.log(`🩺 Health check: http://localhost:${port}/_health`);\n console.log(\n `🗺️ Architecture graph: http://localhost:${port}/_brick/services\\n`,\n );\n\n return app;\n}\n\nexport async function startProdServer(options: DevServerOptions = {}) {\n const entry = options.entry;\n\n if (entry) {\n const resolvedEntry = resolve(process.cwd(), entry);\n if (!existsSync(resolvedEntry)) {\n console.error(`[Brick-TS] Error: Entry file not found: ${resolvedEntry}`);\n process.exit(1);\n }\n console.log(`[Brick-TS] Loading application entry: ${resolvedEntry}`);\n await import(resolvedEntry);\n }\n\n const port =\n options.port !== undefined\n ? options.port\n : process.env.PORT !== undefined && process.env.PORT !== \"\"\n ? Number(process.env.PORT)\n : 4000;\n if (!Number.isInteger(port) || port < 1 || port > 65535) {\n throw new Error(\n `Invalid port: ${port}. Port must be an integer between 1 and 65535`,\n );\n }\n\n const app = brick({\n port,\n prefix: options.prefix,\n });\n\n const prefix = app.definition.prefix;\n const services = app.definition.services;\n\n console.log(`\\n🧱 Brick-TS Production Server`);\n console.log(` Registered Services: ${services.length}`);\n\n for (const svc of services) {\n const actions = svc.listActions();\n console.log(` • ${svc.name} (${actions.length} actions)`);\n for (const act of actions) {\n const pluginRoute = getPluginActionRoute(act, prefix);\n if (pluginRoute === false) continue;\n const method = pluginRoute?.method ?? act.config.method ?? \"POST\";\n const path =\n pluginRoute?.path ??\n act.config.path ??\n `${prefix}/${svc.name}/${act.name}`;\n console.log(` -> ${method.padEnd(6)} ${path}`);\n }\n }\n\n app.listen(port);\n\n console.log(`\\n⚡ API Gateway running on: http://localhost:${port}`);\n console.log(`🩺 Health check: http://localhost:${port}/_health`);\n console.log(\n `🗺️ Architecture graph: http://localhost:${port}/_brick/services\\n`,\n );\n\n return app;\n}\n\nexport async function startDevApplication(options: DevServerOptions) {\n const module = options.entry\n ? await import(resolve(options.entry))\n : undefined;\n if (isBrickApp(module?.default) && options.prefix !== undefined) {\n console.warn(\n `[Brick-TS] Ignoring prefix ${options.prefix}: exported BrickApp prefix ${module.default.definition.prefix} takes precedence.`,\n );\n }\n if (options.clientOutput) {\n if (!isBrickApp(module?.default))\n throw new Error(\n \"Brick: client generation requires a default-exported BrickApp.\",\n );\n const { generateClientContract } = await import(\"./client-contract\");\n const { writeContractSource } = await import(\"./client-contract-file\");\n const { requireBrickApp } = await import(\"./app-entry\");\n const output = resolve(options.clientOutput);\n if (output === resolve(options.entry!))\n throw new Error(\n \"Brick: contract output must not overwrite the app entry.\",\n );\n await writeContractSource(\n output,\n generateClientContract(requireBrickApp(module.default)),\n );\n process.send?.({ type: \"brick:contract-ready\" });\n }\n return createServer(\n options,\n \"Development\",\n isBrickApp(module?.default) ? module.default : undefined,\n );\n}\n\nexport async function startDevServer(options: DevServerOptions = {}) {\n const entry = options.entry;\n if (!entry && (options.clientOutput || options.frontend))\n throw new Error(\"Brick: --client and --frontend require an app entry.\");\n if (!entry) return createServer(options, \"Development\");\n const resolvedEntry = resolve(entry);\n if (!existsSync(resolvedEntry)) {\n console.error(`[Brick-TS] Error: Entry file not found: ${resolvedEntry}`);\n process.exit(1);\n }\n\n const worker = new URL(\n import.meta.url.endsWith(\".ts\") ? \"./dev-worker.ts\" : \"./dev-worker.js\",\n import.meta.url,\n );\n if (options.frontend && !options.clientOutput)\n throw new Error(\"Brick: --frontend requires --client <file>.\");\n let frontend: ReturnType<typeof Bun.spawn> | undefined;\n const dependencyFiles = new Set<string>();\n const dependencyWatchers = new Map<string, ReturnType<typeof watch>>();\n let stopped = false;\n const intentionalExits = new WeakSet<ReturnType<typeof Bun.spawn>>();\n const launch = () => {\n const application = Bun.spawn(\n [\n process.execPath,\n fileURLToPath(worker),\n resolvedEntry,\n String(options.port ?? \"\"),\n options.prefix ?? \"\",\n options.clientOutput ? resolve(options.clientOutput) : \"\",\n ],\n {\n cwd: process.cwd(),\n stdout: \"inherit\",\n stderr: \"inherit\",\n ipc(message) {\n if (!message || typeof message !== \"object\" || !(\"type\" in message))\n return;\n if (\n message.type === \"brick:contract-ready\" &&\n options.frontend &&\n !frontend &&\n !stopped\n ) {\n frontend = Bun.spawn(\n [process.env.SHELL ?? \"/bin/sh\", \"-c\", options.frontend],\n {\n detached: true,\n cwd: process.cwd(),\n stdout: \"inherit\",\n stderr: \"inherit\",\n },\n );\n }\n if (\n message.type === \"brick:dependencies\" &&\n \"files\" in message &&\n Array.isArray(message.files)\n ) {\n for (const file of message.files) {\n if (\n typeof file !== \"string\" ||\n file === resolve(options.clientOutput ?? \"_brick/contract.ts\")\n )\n continue;\n dependencyFiles.add(file);\n const directory = dirname(file);\n if (!dependencyWatchers.has(directory))\n dependencyWatchers.set(\n directory,\n watch(directory, (_event, filename) => {\n if (\n !filename ||\n !dependencyFiles.has(resolve(directory, filename))\n )\n return;\n scheduleRestart();\n }),\n );\n }\n }\n },\n },\n );\n void application.exited.then((code) => {\n if (!stopped && !intentionalExits.has(application)) {\n console.error(\n `[Brick-TS] Application process exited with code ${code}. Waiting for changes to restart.`,\n );\n }\n });\n return application;\n };\n let child = launch();\n const watchDirs = [\n ...new Set([resolve(\"src\"), resolve(\"app\"), resolve(resolvedEntry, \"..\")]),\n ].filter(existsSync);\n let pending: ReturnType<typeof setTimeout> | undefined;\n let restarting = false;\n let dirty = false;\n\n async function restart() {\n dirty = true;\n if (restarting || stopped) return;\n restarting = true;\n try {\n while (dirty && !stopped) {\n dirty = false;\n console.log(\"\\n📝 Changes detected. Restarting server...\");\n intentionalExits.add(child);\n child.kill();\n await child.exited;\n if (!stopped) child = launch();\n }\n } finally {\n restarting = false;\n }\n }\n\n function scheduleRestart() {\n clearTimeout(pending);\n pending = setTimeout(() => {\n void restart();\n }, 100);\n }\n const watchers = watchDirs.map((dir) =>\n watch(dir, { recursive: true }, (_event, filename) => {\n if (!filename || filename.split(/[\\\\/]/).includes(\"node_modules\")) return;\n const file = resolve(dir, filename);\n if (\n file === resolve(options.clientOutput ?? \"_brick/contract.ts\") ||\n basename(file).startsWith(\".brick-contract-\")\n )\n return;\n scheduleRestart();\n }),\n );\n const stop = () => {\n if (stopped) return;\n stopped = true;\n clearTimeout(pending);\n for (const watcher of watchers) watcher.close();\n for (const watcher of dependencyWatchers.values()) watcher.close();\n if (frontend) {\n if (process.platform === \"win32\") {\n Bun.spawnSync([\"taskkill\", \"/pid\", String(frontend.pid), \"/t\", \"/f\"]);\n } else {\n try {\n process.kill(-frontend.pid, \"SIGTERM\");\n } catch (error) {\n if (\n !(\n error instanceof Error &&\n \"code\" in error &&\n error.code === \"ESRCH\"\n )\n )\n throw error;\n }\n }\n }\n child.kill();\n process.off(\"SIGINT\", onSignal);\n process.off(\"SIGTERM\", onSignal);\n process.off(\"exit\", stop);\n };\n const onSignal = () => {\n stop();\n process.exit(0);\n };\n process.on(\"SIGINT\", onSignal);\n process.on(\"SIGTERM\", onSignal);\n process.on(\"exit\", stop);\n console.log(`\\n👀 Watching for changes in: ${watchDirs.join(\", \")}`);\n return { stop };\n}\n"],"mappings":";;;;;AAqBA,eAAe,aACb,SACA,OACA,aACA;CACA,IAAI;CACJ,IAAI,QAAQ,SAAS,KAAA,GACnB,OAAO,QAAQ;MACV,IAAI,QAAQ,IAAI,SAAS,KAAA,KAAa,QAAQ,IAAI,SAAS,IAChE,OAAO,OAAO,QAAQ,IAAI,IAAI;MAE9B,OAAO;CAET,IAAI,CAAC,OAAO,UAAU,IAAI,KAAK,OAAO,KAAK,OAAO,OAChD,MAAM,IAAI,MACR,iBAAiB,KAAK,8CACxB;CAGF,MAAM,MACJ,eACA,MAAM;EACJ;EACA,QAAQ,QAAQ;CAClB,CAAC;CAEH,MAAM,IAAI,OAAO,EAAE,KAAK,CAAC;CAEzB,MAAM,SAAS,IAAI,WAAW;CAC9B,MAAM,WAAW,IAAI,WAAW;CAEhC,QAAQ,IAAI,iBAAiB,MAAM,QAAQ;CAC3C,QAAQ,IAAI,2BAA2B,SAAS,QAAQ;CAExD,KAAK,MAAM,OAAO,UAAU;EAC1B,MAAM,UAAU,IAAI,YAAY;EAChC,QAAQ,IAAI,QAAQ,IAAI,KAAK,IAAI,QAAQ,OAAO,UAAU;EAC1D,KAAK,MAAM,OAAO,SAAS;GACzB,MAAM,cAAc,qBAAqB,KAAK,MAAM;GACpD,IAAI,gBAAgB,OAAO;GAC3B,MAAM,SAAS,aAAa,UAAU,IAAI,OAAO,UAAU;GAC3D,MAAM,OACJ,aAAa,QACb,IAAI,OAAO,QACX,GAAG,OAAO,GAAG,IAAI,KAAK,GAAG,IAAI;GAC/B,QAAQ,IAAI,WAAW,OAA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A,MAAM,aAAa;EACjB,IAAI,SAAS;EACb,UAAU;EACV,aAAa,OAAO;EACpB,KAAK,MAAM,WAAW,UAAU,QAAQ,MAAM;EAC9C,KAAK,MAAM,WAAW,mBAAmB,OAAO,GAAG,QAAQ,MAAM;EACjE,IAAI,UAAU;GACZ,IAAI,QAAQ,aAAa,SACvB,IAAI,UAAU;IAAC;IAAY;IAAQ,OAAO,SAAS,GAAG;IAAG;IAAM;GAAI,CAAC;QAEpE,IAAI;IACF,QAAQ,KAAK,CAAC,SAAS,KAAK,SAAS;GACvC,SAAS,OAAO;IACd,IACE,EACE,iBAAiB,SACjB,UAAU,SACV,MAAM,SAAS,UAGjB,MAAM;GACV;EAEJ;EACA,MAAM,KAAK;EACX,QAAQ,IAAI,UAAU,QAAQ;EAC9B,QAAQ,IAAI,WAAW,QAAQ;EAC/B,QAAQ,IAAI,QAAQ,IAAI;CAC1B;CACA,MAAM,iBAAiB;EACrB,KAAK;EACL,QAAQ,KAAK,CAAC;CAChB;CACA,QAAQ,GAAG,UAAU,QAAQ;CAC7B,QAAQ,GAAG,WAAW,QAAQ;CAC9B,QAAQ,GAAG,QAAQ,IAAI;CACvB,QAAQ,IAAI,iCAAiC,UAAU,KAAK,IAAI,GAAG;CACnE,OAAO,EAAE,KAAK;AAChB"}
|
|
1
|
+
{"version":3,"file":"runner.js","names":[],"sources":["../src/port-utils.ts","../src/production-dashboard.ts","../src/runner.ts"],"sourcesContent":["export function parsePort(\n portStr: string | undefined,\n envPort?: string | undefined,\n): number {\n let port: number | undefined;\n if (portStr !== undefined) {\n port = Number(portStr);\n } else if (envPort !== undefined && envPort !== \"\") {\n port = Number(envPort);\n } else {\n port = 4000;\n }\n\n if (!Number.isInteger(port) || port < 1 || port > 65535) {\n throw new Error(\n `Invalid port: ${port}. Port must be an integer between 1 and 65535`,\n );\n }\n return port;\n}\n","import { getGlobalRegistry, type BrickApp } from \"@brickkit/core\";\nimport { isLoopbackHost } from \"./dashboard-access\";\nimport { DEFAULT_DASHBOARD_PORT, startDevDashboard } from \"./dev-dashboard\";\nimport { openHistory } from \"./dev-history\";\nimport { installTracing } from \"./dev-telemetry\";\nimport { DevTelemetryStore } from \"./dev-telemetry-store\";\n\nexport interface ProductionDashboard {\n readonly host: string;\n readonly port: number;\n stop(): void;\n}\n\n/**\n * Serve the monitoring dashboard an app asks for with `brick({ dashboard })`,\n * in the process that serves the app. It listens on a port of its own, so it\n * stays up when the app's routes do not answer, and its `/_health` tells an\n * uptime monitor whether the app does. From here on `ctx.logger` and `console`\n * lines written during a request go to the dashboard, not the console.\n *\n * Call it before the app starts listening. Returns undefined when the app\n * asks for no dashboard, or when it cannot start (the app runs on without it,\n * and says so). A configuration that would leave the dashboard open to others\n * throws instead: the app must not start unprotected.\n */\nexport async function startProductionDashboard(\n app: BrickApp,\n options: {\n /** The port the app listens on, for the health probe. */\n appPort: number;\n /** Where `.brick/` history is kept; the working folder by default. */\n directory?: string;\n warn?: (message: string) => void;\n },\n): Promise<ProductionDashboard | undefined> {\n const config = app.definition.dashboard;\n if (!config) return undefined;\n const warn = options.warn ?? ((message) => console.warn(message));\n const host = config.host ?? \"127.0.0.1\";\n const port = config.port ?? DEFAULT_DASHBOARD_PORT;\n if (!isLoopbackHost(host) && !config.auth) {\n throw new Error(\n `Brick: the dashboard would listen on ${host}, where others can reach it, so it needs access control. Set dashboard.auth with a token or an authorize function.`,\n );\n }\n\n const history = await openHistory({\n directory: options.directory ?? process.cwd(),\n days: config.historyDays ?? 0,\n warn,\n });\n const store = new DevTelemetryStore({ history });\n let started;\n try {\n started = await startDevDashboard({\n port,\n host,\n mode: \"production\",\n auth: config.auth,\n store,\n history,\n probe: async () => {\n const response = await fetch(\n `http://127.0.0.1:${options.appPort}/_health`,\n { signal: AbortSignal.timeout(2000) },\n );\n return response.ok;\n },\n });\n } catch (error) {\n history?.close();\n const reason = error instanceof Error ? error.message : String(error);\n warn(`[Brick-TS] ${reason} Continuing without the dashboard.`);\n return undefined;\n }\n\n const registered = installTracing((records) =>\n store.ingest(records, store.latestGeneration),\n );\n if (!registered) {\n warn(\n \"[Brick-TS] Another tracer provider is already registered, so the dashboard will show no requests or logs.\",\n );\n }\n const generation = store.startGeneration(\"application started\");\n store.setArchitecture(\n getGlobalRegistry().exportArchitecture(app.definition),\n generation,\n );\n return {\n host,\n port: started.port,\n stop() {\n started.stop();\n history?.close();\n },\n };\n}\n","import { existsSync } from \"fs\";\nimport { watch } from \"fs\";\nimport { resolve, dirname, basename } from \"path\";\nimport { fileURLToPath } from \"node:url\";\nimport {\n brick,\n getPluginActionRoute,\n isBrickApp,\n type ApiDocument,\n type ArchitectureSchema,\n type BrickApp,\n type DocumentationOptions,\n} from \"@brickkit/core\";\nimport { startDevDashboard, type DevDashboard } from \"./dev-dashboard\";\nimport { DocsHost } from \"./dev-docs\";\nimport { DEFAULT_HISTORY_DAYS, openHistory } from \"./dev-history\";\nimport { DevTelemetryStore } from \"./dev-telemetry-store\";\nimport { parsePort } from \"./port-utils\";\nimport { startProductionDashboard } from \"./production-dashboard\";\nimport type {\n SerializedError,\n TelemetryRecord,\n WorkerErrorPhase,\n} from \"./dev-telemetry\";\n\nexport interface DevServerOptions {\n port?: number;\n entry?: string;\n prefix?: string;\n /** Generate a browser contract before starting the backend and frontend. */\n clientOutput?: string;\n /** Frontend command, launched once after the first successful generation. */\n frontend?: string;\n /**\n * Local dashboard with live requests, traces, errors, and reloads. Needs an\n * entry. `historyDays` is how long finished requests are kept on disk\n * (default 90); zero keeps live data only.\n */\n dashboard?: { port: number; historyDays?: number } | false;\n}\n\nasync function createServer(\n options: DevServerOptions,\n label: string,\n application?: BrickApp,\n) {\n let port: number;\n if (options.port !== undefined) {\n port = options.port;\n } else if (process.env.PORT !== undefined && process.env.PORT !== \"\") {\n port = Number(process.env.PORT);\n } else {\n port = 4000;\n }\n if (!Number.isInteger(port) || port < 1 || port > 65535) {\n throw new Error(\n `Invalid port: ${port}. Port must be an integer between 1 and 65535`,\n );\n }\n\n const app =\n application ??\n brick({\n port,\n prefix: options.prefix,\n });\n\n await app.listen({ port });\n\n const prefix = app.definition.prefix;\n const services = app.definition.services;\n\n console.log(`\\n🧱 Brick-TS ${label} Server`);\n console.log(` Registered Services: ${services.length}`);\n\n for (const svc of services) {\n const actions = svc.listActions();\n console.log(` • ${svc.name} (${actions.length} actions)`);\n for (const act of actions) {\n const pluginRoute = getPluginActionRoute(act, prefix);\n if (pluginRoute === false) continue;\n const method = pluginRoute?.method ?? act.config.method ?? \"POST\";\n const path =\n pluginRoute?.path ??\n act.config.path ??\n `${prefix}/${svc.name}/${act.name}`;\n console.log(` -> ${method.padEnd(6)} ${path}`);\n }\n }\n\n console.log(`\\n⚡ API Gateway running on: http://localhost:${port}`);\n console.log(`🩺 Health check: http://localhost:${port}/_health`);\n console.log(\n `🗺️ Architecture graph: http://localhost:${port}/_brick/services\\n`,\n );\n\n return app;\n}\n\nexport async function startProdServer(options: DevServerOptions = {}) {\n const entry = options.entry;\n\n let exported: BrickApp | undefined;\n if (entry) {\n const resolvedEntry = resolve(process.cwd(), entry);\n if (!existsSync(resolvedEntry)) {\n console.error(`[Brick-TS] Error: Entry file not found: ${resolvedEntry}`);\n process.exit(1);\n }\n console.log(`[Brick-TS] Loading application entry: ${resolvedEntry}`);\n const module = await import(resolvedEntry);\n // An entry that default-exports its app is served as it built it, with its\n // options (telemetry, dashboard, and the rest), as `brick dev` does.\n if (isBrickApp(module?.default)) exported = module.default;\n }\n if (exported && options.prefix !== undefined) {\n console.warn(\n `[Brick-TS] Ignoring prefix ${options.prefix}: exported BrickApp prefix ${exported.definition.prefix} takes precedence.`,\n );\n }\n\n const port =\n options.port !== undefined\n ? options.port\n : process.env.PORT !== undefined && process.env.PORT !== \"\"\n ? Number(process.env.PORT)\n : 4000;\n if (!Number.isInteger(port) || port < 1 || port > 65535) {\n throw new Error(\n `Invalid port: ${port}. Port must be an integer between 1 and 65535`,\n );\n }\n\n const app =\n exported ??\n brick({\n port,\n prefix: options.prefix,\n });\n\n const prefix = app.definition.prefix;\n const services = app.definition.services;\n\n console.log(`\\n🧱 Brick-TS Production Server`);\n console.log(` Registered Services: ${services.length}`);\n\n for (const svc of services) {\n const actions = svc.listActions();\n console.log(` • ${svc.name} (${actions.length} actions)`);\n for (const act of actions) {\n const pluginRoute = getPluginActionRoute(act, prefix);\n if (pluginRoute === false) continue;\n const method = pluginRoute?.method ?? act.config.method ?? \"POST\";\n const path =\n pluginRoute?.path ??\n act.config.path ??\n `${prefix}/${svc.name}/${act.name}`;\n console.log(` -> ${method.padEnd(6)} ${path}`);\n }\n }\n\n // Before listening, so the first request is already traced and its logs kept.\n const dashboard = await startProductionDashboard(app, { appPort: port });\n app.listen(port);\n\n console.log(`\\n⚡ API Gateway running on: http://localhost:${port}`);\n console.log(`🩺 Health check: http://localhost:${port}/_health`);\n if (dashboard) {\n const shown =\n dashboard.host === \"0.0.0.0\" || dashboard.host === \"::\"\n ? \"localhost\"\n : dashboard.host.includes(\":\")\n ? `[${dashboard.host.replace(/^\\[|\\]$/g, \"\")}]`\n : dashboard.host;\n console.log(\n `📊 Dashboard: http://${shown}:${dashboard.port} (health: /_health)`,\n );\n }\n console.log(\n `🗺️ Architecture graph: http://localhost:${port}/_brick/services\\n`,\n );\n\n return app;\n}\n\nexport async function startDevApplication(options: DevServerOptions) {\n const module = options.entry\n ? await import(resolve(options.entry))\n : undefined;\n if (isBrickApp(module?.default) && options.prefix !== undefined) {\n console.warn(\n `[Brick-TS] Ignoring prefix ${options.prefix}: exported BrickApp prefix ${module.default.definition.prefix} takes precedence.`,\n );\n }\n if (options.clientOutput) {\n if (!isBrickApp(module?.default))\n throw new Error(\n \"Brick: client generation requires a default-exported BrickApp.\",\n );\n const { generateClientContract } = await import(\"./client-contract\");\n const { writeContractSource } = await import(\"./client-contract-file\");\n const { requireBrickApp } = await import(\"./app-entry\");\n const output = resolve(options.clientOutput);\n if (output === resolve(options.entry!))\n throw new Error(\n \"Brick: contract output must not overwrite the app entry.\",\n );\n await writeContractSource(\n output,\n generateClientContract(requireBrickApp(module.default)),\n );\n process.send?.({ type: \"brick:contract-ready\" });\n }\n return createServer(\n options,\n \"Development\",\n isBrickApp(module?.default) ? module.default : undefined,\n );\n}\n\n/**\n * What `brick dev` runs: start the application, restart it when its files\n * change, and serve the dashboard beside it. With an `entry`, the app runs in\n * a worker process that restarts on every change to the entry or the files it\n * imports, and reports its requests to the dashboard; without one, a server\n * with the registered services starts in this process.\n *\n * @param options - `entry`, `port` (else `PORT`, else 4000), `prefix`,\n * `clientOutput` to regenerate the typed client's contract on each start,\n * `frontend` to launch a frontend command once, and `dashboard` (`port` and\n * `historyDays`, or `false`).\n * @returns The application, when started in this process.\n * @throws When `frontend` is given without `clientOutput`, or the dashboard\n * would use the app's port.\n */\nexport async function startDevServer(options: DevServerOptions = {}) {\n const entry = options.entry;\n if (!entry && (options.clientOutput || options.frontend))\n throw new Error(\"Brick: --client and --frontend require an app entry.\");\n if (!entry) return createServer(options, \"Development\");\n const resolvedEntry = resolve(entry);\n if (!existsSync(resolvedEntry)) {\n console.error(`[Brick-TS] Error: Entry file not found: ${resolvedEntry}`);\n process.exit(1);\n }\n\n const worker = new URL(\n import.meta.url.endsWith(\".ts\") ? \"./dev-worker.ts\" : \"./dev-worker.js\",\n import.meta.url,\n );\n if (options.frontend && !options.clientOutput)\n throw new Error(\"Brick: --frontend requires --client <file>.\");\n if (\n options.dashboard &&\n options.port !== undefined &&\n options.dashboard.port === options.port\n )\n throw new Error(\n \"Brick: dashboard port must differ from the API port. Use --dashboard-port <number>.\",\n );\n // The worker resolves its port the same way, so this is where the app listens.\n const appPort = () =>\n parsePort(\n options.port === undefined ? undefined : String(options.port),\n process.env.PORT,\n );\n const history = options.dashboard\n ? await openHistory({\n directory: process.cwd(),\n days: options.dashboard.historyDays ?? DEFAULT_HISTORY_DAYS,\n warn: (message) => console.warn(message),\n })\n : undefined;\n const telemetry = options.dashboard\n ? new DevTelemetryStore({ history })\n : undefined;\n const docs = telemetry\n ? new DocsHost(telemetry, (message) => console.warn(message))\n : undefined;\n let frontend: ReturnType<typeof Bun.spawn> | undefined;\n const dependencyFiles = new Set<string>();\n const dependencyWatchers = new Map<string, ReturnType<typeof watch>>();\n let stopped = false;\n const intentionalExits = new WeakSet<ReturnType<typeof Bun.spawn>>();\n let generationCount = 0;\n let childGeneration = 0;\n const launch = () => {\n const generation = ++generationCount;\n childGeneration = generation;\n telemetry?.recordReload({ kind: \"started\", generation });\n const application = Bun.spawn(\n [\n process.execPath,\n fileURLToPath(worker),\n resolvedEntry,\n String(options.port ?? \"\"),\n options.prefix ?? \"\",\n options.clientOutput ? resolve(options.clientOutput) : \"\",\n telemetry ? \"1\" : \"\",\n ],\n {\n cwd: process.cwd(),\n stdout: \"inherit\",\n stderr: \"inherit\",\n ipc(message) {\n if (!message || typeof message !== \"object\" || !(\"type\" in message))\n return;\n if (\n telemetry &&\n message.type === \"brick:telemetry\" &&\n \"records\" in message &&\n Array.isArray(message.records)\n ) {\n telemetry.ingest(message.records as TelemetryRecord[], generation);\n }\n if (\n telemetry &&\n message.type === \"brick:error\" &&\n \"phase\" in message &&\n \"error\" in message\n ) {\n telemetry.recordWorkerError(\n message.phase as WorkerErrorPhase,\n message.error as SerializedError,\n generation,\n );\n }\n if (\n message.type === \"brick:contract-ready\" &&\n options.frontend &&\n !frontend &&\n !stopped\n ) {\n frontend = Bun.spawn(\n [process.env.SHELL ?? \"/bin/sh\", \"-c\", options.frontend],\n {\n detached: true,\n cwd: process.cwd(),\n stdout: \"inherit\",\n stderr: \"inherit\",\n },\n );\n }\n if (\n telemetry &&\n message.type === \"brick:architecture\" &&\n \"architecture\" in message\n ) {\n telemetry.setArchitecture(\n message.architecture as ArchitectureSchema,\n generation,\n );\n }\n if (docs && message.type === \"brick:documentation\") {\n void docs.configure(\n dirname(resolvedEntry),\n \"documentation\" in message\n ? (message.documentation as DocumentationOptions | undefined)\n : undefined,\n );\n }\n if (\n telemetry &&\n message.type === \"brick:api-documents\" &&\n \"documents\" in message &&\n Array.isArray(message.documents)\n ) {\n telemetry.setApiDocuments(\n message.documents as ApiDocument[],\n `http://localhost:${appPort()}`,\n );\n }\n if (telemetry && message.type === \"brick:contract-ready\") {\n telemetry.recordReload({\n kind: \"contract-ready\",\n generation,\n detail: \"browser contract generated\",\n });\n }\n if (\n message.type === \"brick:dependencies\" &&\n \"files\" in message &&\n Array.isArray(message.files)\n ) {\n for (const file of message.files) {\n if (\n typeof file !== \"string\" ||\n file === resolve(options.clientOutput ?? \"_brick/contract.ts\")\n )\n continue;\n dependencyFiles.add(file);\n const directory = dirname(file);\n if (!dependencyWatchers.has(directory))\n dependencyWatchers.set(\n directory,\n watch(directory, (_event, filename) => {\n if (\n !filename ||\n !dependencyFiles.has(resolve(directory, filename))\n )\n return;\n scheduleRestart();\n }),\n );\n }\n }\n },\n },\n );\n void application.exited.then((code) => {\n if (!stopped && !intentionalExits.has(application)) {\n console.error(\n `[Brick-TS] Application process exited with code ${code}. Waiting for changes to restart.`,\n );\n telemetry?.recordReload({\n kind: \"exited\",\n generation,\n detail: `exit code ${code}`,\n });\n }\n telemetry?.interruptGeneration(generation);\n });\n return application;\n };\n // Bind the dashboard before the first worker starts, so a port conflict\n // does not leave an application process running.\n const dashboard: DevDashboard | undefined =\n telemetry && options.dashboard\n ? await startDevDashboard({\n port: options.dashboard.port,\n store: telemetry,\n history,\n docs: () => docs?.current,\n restart: () => {\n void restart(\"dashboard\");\n },\n }).catch((error: unknown) => {\n history?.close();\n throw error;\n })\n : undefined;\n if (dashboard) {\n console.log(`📊 Dev dashboard: http://127.0.0.1:${dashboard.port}`);\n }\n let child = launch();\n const watchDirs = [\n ...new Set([resolve(\"src\"), resolve(\"app\"), resolve(resolvedEntry, \"..\")]),\n ].filter(existsSync);\n let pending: ReturnType<typeof setTimeout> | undefined;\n let restarting = false;\n let dirty = false;\n\n async function restart(trigger: \"changes\" | \"dashboard\" = \"changes\") {\n dirty = true;\n if (restarting || stopped) return;\n restarting = true;\n try {\n while (dirty && !stopped) {\n dirty = false;\n console.log(\n trigger === \"changes\"\n ? \"\\n📝 Changes detected. Restarting server...\"\n : \"\\n🔄 Restart requested from the dashboard. Restarting server...\",\n );\n telemetry?.recordReload({\n kind: \"restarting\",\n generation: childGeneration,\n detail:\n trigger === \"changes\" ? \"source changed\" : \"restart from dashboard\",\n });\n intentionalExits.add(child);\n child.kill();\n await child.exited;\n if (!stopped) child = launch();\n }\n } finally {\n restarting = false;\n }\n }\n\n function scheduleRestart() {\n clearTimeout(pending);\n pending = setTimeout(() => {\n void restart();\n }, 100);\n }\n const watchers = watchDirs.map((dir) =>\n watch(dir, { recursive: true }, (_event, filename) => {\n if (!filename || filename.split(/[\\\\/]/).includes(\"node_modules\")) return;\n const file = resolve(dir, filename);\n if (\n file === resolve(options.clientOutput ?? \"_brick/contract.ts\") ||\n basename(file).startsWith(\".brick-contract-\")\n )\n return;\n scheduleRestart();\n }),\n );\n const stop = () => {\n if (stopped) return;\n stopped = true;\n clearTimeout(pending);\n for (const watcher of watchers) watcher.close();\n for (const watcher of dependencyWatchers.values()) watcher.close();\n if (frontend) {\n if (process.platform === \"win32\") {\n Bun.spawnSync([\"taskkill\", \"/pid\", String(frontend.pid), \"/t\", \"/f\"]);\n } else {\n try {\n process.kill(-frontend.pid, \"SIGTERM\");\n } catch (error) {\n if (\n !(\n error instanceof Error &&\n \"code\" in error &&\n error.code === \"ESRCH\"\n )\n )\n throw error;\n }\n }\n }\n dashboard?.stop();\n docs?.close();\n history?.close();\n child.kill();\n process.off(\"SIGINT\", onSignal);\n process.off(\"SIGTERM\", onSignal);\n process.off(\"exit\", stop);\n };\n const onSignal = () => {\n stop();\n process.exit(0);\n };\n process.on(\"SIGINT\", onSignal);\n process.on(\"SIGTERM\", onSignal);\n process.on(\"exit\", stop);\n console.log(`\\n👀 Watching for changes in: ${watchDirs.join(\", \")}`);\n return { stop };\n}\n"],"mappings":";;;;;;;AAAA,SAAgB,UACd,SACA,SACQ;CACR,IAAI;CACJ,IAAI,YAAY,K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F,QAAQ,KAAK,CAAC,SAAS,KAAK,SAAS;GACvC,SAAS,OAAO;IACd,IACE,EACE,iBAAiB,SACjB,UAAU,SACV,MAAM,SAAS,UAGjB,MAAM;GACV;EAEJ;EACA,WAAW,KAAK;EAChB,MAAM,MAAM;EACZ,SAAS,MAAM;EACf,MAAM,KAAK;EACX,QAAQ,IAAI,UAAU,QAAQ;EAC9B,QAAQ,IAAI,WAAW,QAAQ;EAC/B,QAAQ,IAAI,QAAQ,IAAI;CAC1B;CACA,MAAM,iBAAiB;EACrB,KAAK;EACL,QAAQ,KAAK,CAAC;CAChB;CACA,QAAQ,GAAG,UAAU,QAAQ;CAC7B,QAAQ,GAAG,WAAW,QAAQ;CAC9B,QAAQ,GAAG,QAAQ,IAAI;CACvB,QAAQ,IAAI,iCAAiC,UAAU,KAAK,IAAI,GAAG;CACnE,OAAO,EAAE,KAAK;AAChB"}
|
package/dist/vite.d.ts
CHANGED
|
@@ -5,6 +5,17 @@ export interface BrickClientPluginOptions {
|
|
|
5
5
|
entry: string;
|
|
6
6
|
/** Generated browser contract, relative to the Vite root (default _brick/contract.ts). */
|
|
7
7
|
output?: string;
|
|
8
|
+
/**
|
|
9
|
+
* Local dashboard for the app's requests, traces, errors, and reloads, served
|
|
10
|
+
* during `vite dev` (default: on at port 9400). Apps must pass
|
|
11
|
+
* `telemetry: true` to brick() to record requests. `historyDays` is how long
|
|
12
|
+
* finished requests are kept in `.brick/` (default 90, 0 for none). Set to
|
|
13
|
+
* false to disable.
|
|
14
|
+
*/
|
|
15
|
+
dashboard?: {
|
|
16
|
+
port?: number;
|
|
17
|
+
historyDays?: number;
|
|
18
|
+
} | false;
|
|
8
19
|
}
|
|
9
20
|
/** Load a BrickApp through Vite's server module graph, including dependency HMR. */
|
|
10
21
|
export declare function brickClient(options: BrickClientPluginOptions): Plugin;
|
package/dist/vite.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vite.d.ts","names":[],"sources":["../src/vite.ts"],"mappings":";;
|
|
1
|
+
{"version":3,"file":"vite.d.ts","names":[],"sources":["../src/vite.ts"],"mappings":";;iBAgBiB;;EAEf;;EAEA;;;;;;;;EAQA;IAAc;IAAe;;;;wBAIf,YAAY,SAAS,2BAA2B"}
|