@powerhousedao/ph-cli 6.4.0-next.1 → 6.4.0-next.3
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 +6 -5
- package/dist/{build-C490lBnu.mjs → build-B-rPwjM8.mjs} +7 -7
- package/dist/{build-C490lBnu.mjs.map → build-B-rPwjM8.mjs.map} +1 -1
- package/dist/build-DuwAPWMY.mjs +4 -0
- package/dist/{check-DIK1LTss.mjs → check-B7C3Vi_b.mjs} +4 -4
- package/dist/{check-DIK1LTss.mjs.map → check-B7C3Vi_b.mjs.map} +1 -1
- package/dist/{check-D84ta1Dh.mjs → check-DM7UdFTK.mjs} +4 -4
- package/dist/{check-D84ta1Dh.mjs.map → check-DM7UdFTK.mjs.map} +1 -1
- package/dist/{check-F3nwJiG-.mjs → check-DeUTd514.mjs} +3 -3
- package/dist/{cli-connect-override-BMU4Qldg.mjs → cli-connect-override-Bx_g3-ZE.mjs} +4 -4
- package/dist/{cli-connect-override-BMU4Qldg.mjs.map → cli-connect-override-Bx_g3-ZE.mjs.map} +1 -1
- package/dist/cli.mjs +8 -8
- package/dist/cli.mjs.map +1 -1
- package/dist/{compound-BWLJ0KBw-8hKyrfjG.mjs → compound-Q9sZSEZF-DQvtoigb.mjs} +6 -6
- package/dist/compound-Q9sZSEZF-DQvtoigb.mjs.map +1 -0
- package/dist/{connect-build-DW1fFVbU.mjs → connect-build-CaTxdYcc.mjs} +5 -5
- package/dist/{connect-build-DW1fFVbU.mjs.map → connect-build-CaTxdYcc.mjs.map} +1 -1
- package/dist/{connect-config-DVubBBLb.mjs → connect-config-A-U83U8U.mjs} +4 -4
- package/dist/{connect-config-DVubBBLb.mjs.map → connect-config-A-U83U8U.mjs.map} +1 -1
- package/dist/{connect-studio-CQC-LDSg.mjs → connect-studio-B2gugCJU.mjs} +4 -4
- package/dist/{connect-studio-CQC-LDSg.mjs.map → connect-studio-B2gugCJU.mjs.map} +1 -1
- package/dist/definitions-worker.mjs +1 -1
- package/dist/dev-host-RhWeATKB.mjs +19 -0
- package/dist/dev-host-RhWeATKB.mjs.map +1 -0
- package/dist/{dist-BFMRL5C0.mjs → dist-D_UjZsgt.mjs} +4 -4
- package/dist/dist-D_UjZsgt.mjs.map +1 -0
- package/dist/{explain-YPD3n6t8.mjs → explain-DbbHpa61.mjs} +5 -5
- package/dist/{explain-YPD3n6t8.mjs.map → explain-DbbHpa61.mjs.map} +1 -1
- package/dist/{export-DjQL6zkr.mjs → export-FduYVQEM.mjs} +4 -4
- package/dist/{export-DjQL6zkr.mjs.map → export-FduYVQEM.mjs.map} +1 -1
- package/dist/{files-D6_euBBn.mjs → files-DEHg350R.mjs} +4 -4
- package/dist/{files-D6_euBBn.mjs.map → files-DEHg350R.mjs.map} +1 -1
- package/dist/{generate-all-BLot_H9Z.mjs → generate-all-BE8UmbJv.mjs} +6 -21
- package/dist/generate-all-BE8UmbJv.mjs.map +1 -0
- package/dist/{generate-app-hm6CJ_4O.mjs → generate-app-C7n0j8Ak.mjs} +5 -18
- package/dist/generate-app-C7n0j8Ak.mjs.map +1 -0
- package/dist/{generate-document-model-BiD6ovXc.mjs → generate-document-model-DSYPTMZg.mjs} +9 -31
- package/dist/generate-document-model-DSYPTMZg.mjs.map +1 -0
- package/dist/{generate-editor-DBj_Pxwa.mjs → generate-editor-DKuRUeIt.mjs} +5 -18
- package/dist/generate-editor-DKuRUeIt.mjs.map +1 -0
- package/dist/{generate-processor-BVjOsfjJ.mjs → generate-processor-CwJvJDpd.mjs} +5 -18
- package/dist/generate-processor-CwJvJDpd.mjs.map +1 -0
- package/dist/{generate-subgraph-DJZCr0Tk.mjs → generate-subgraph-EQ2ZjMp9.mjs} +6 -25
- package/dist/generate-subgraph-EQ2ZjMp9.mjs.map +1 -0
- package/dist/{get-version-CcYVboCW.mjs → get-version-7oKMD8Gt.mjs} +4 -4
- package/dist/{get-version-CcYVboCW.mjs.map → get-version-7oKMD8Gt.mjs.map} +1 -1
- package/dist/{index-D3H9pQ8u.d.mts → index-Bs1PfL3W.d.mts} +17 -4
- package/dist/index-Bs1PfL3W.d.mts.map +1 -0
- package/dist/{mcp-B3l1mtBq.mjs → mcp-CcZT9zT9.mjs} +8 -8
- package/dist/mcp-CcZT9zT9.mjs.map +1 -0
- package/dist/{migrate-CzcBEypc.mjs → migrate-Ddr7YAtM.mjs} +4 -4
- package/dist/{migrate-CzcBEypc.mjs.map → migrate-Ddr7YAtM.mjs.map} +1 -1
- package/dist/{migrate-document-models-D0HSo4WN.mjs → migrate-document-models-X_mVTljj.mjs} +4 -4
- package/dist/{migrate-document-models-D0HSo4WN.mjs.map → migrate-document-models-X_mVTljj.mjs.map} +1 -1
- package/dist/migrate-subgraphs-DEqWkLoh.mjs +4 -0
- package/dist/{migrate-subgraphs-CfSMlcJD.mjs → migrate-subgraphs-Ffwwm7Oy.mjs} +5 -5
- package/dist/{migrate-subgraphs-CfSMlcJD.mjs.map → migrate-subgraphs-Ffwwm7Oy.mjs.map} +1 -1
- package/dist/{ph-cli-commands-CQXdWQ74.mjs → ph-cli-commands-D4Z6YSwd.mjs} +39 -104
- package/dist/ph-cli-commands-D4Z6YSwd.mjs.map +1 -0
- package/dist/ph-cli-commands-p9cO6MsE.mjs +4 -0
- package/dist/{run-sugar-hGKprsKz.mjs → run-sugar-CkuGJuPg.mjs} +16 -8
- package/dist/run-sugar-CkuGJuPg.mjs.map +1 -0
- package/dist/{run-sugar-BfnRBv7h.mjs → run-sugar-Dd_Mu058.mjs} +3 -3
- package/dist/runners/connect.d.mts +1 -1
- package/dist/runners/connect.mjs +2 -2
- package/dist/runners/switchboard.d.mts +1 -1
- package/dist/runners/switchboard.mjs +3 -3
- package/dist/{sugar-checks-CTCsK5DJ.mjs → sugar-checks-CAtgUIem.mjs} +16 -15
- package/dist/sugar-checks-CAtgUIem.mjs.map +1 -0
- package/dist/{verify-NK6a_7j8.mjs → verify-DXrs0JUp.mjs} +5 -5
- package/dist/{verify-NK6a_7j8.mjs.map → verify-DXrs0JUp.mjs.map} +1 -1
- package/dist/{vetra-gateway-BxcduYAI.mjs → vetra-gateway-BHuz7pvS.mjs} +5 -5
- package/dist/{vetra-gateway-BxcduYAI.mjs.map → vetra-gateway-BHuz7pvS.mjs.map} +1 -1
- package/dist/vetra-gateway-ag33E_Ta.mjs +4 -0
- package/dist/{vetra-host-BrLdIMRP.mjs → vetra-host-CYdbd3J3.mjs} +28 -11
- package/dist/vetra-host-CYdbd3J3.mjs.map +1 -0
- package/dist/{vetra-launcher-Dokr1aDK.mjs → vetra-launcher-B5L3yXPo.mjs} +16 -13
- package/dist/vetra-launcher-B5L3yXPo.mjs.map +1 -0
- package/dist/vetra-launcher-BUO9e74r.mjs +4 -0
- package/dist/{vetra-instance-CPNIsaxh.mjs → vetra-runtime-Bk6CW-BE.mjs} +7 -25
- package/dist/vetra-runtime-Bk6CW-BE.mjs.map +1 -0
- package/dist/warn-subgraph-type-conflicts-BZ4NwLx5.mjs +131 -0
- package/dist/warn-subgraph-type-conflicts-BZ4NwLx5.mjs.map +1 -0
- package/package.json +15 -16
- package/dist/build-DblrRe4z.mjs +0 -4
- package/dist/compound-BWLJ0KBw-8hKyrfjG.mjs.map +0 -1
- package/dist/dist-BFMRL5C0.mjs.map +0 -1
- package/dist/generate-all-BLot_H9Z.mjs.map +0 -1
- package/dist/generate-app-hm6CJ_4O.mjs.map +0 -1
- package/dist/generate-document-model-BiD6ovXc.mjs.map +0 -1
- package/dist/generate-editor-DBj_Pxwa.mjs.map +0 -1
- package/dist/generate-processor-BVjOsfjJ.mjs.map +0 -1
- package/dist/generate-subgraph-DJZCr0Tk.mjs.map +0 -1
- package/dist/index-D3H9pQ8u.d.mts.map +0 -1
- package/dist/mcp-B3l1mtBq.mjs.map +0 -1
- package/dist/migrate-subgraphs-Hc5w9Mpk.mjs +0 -4
- package/dist/ph-cli-commands-CQXdWQ74.mjs.map +0 -1
- package/dist/ph-cli-commands-YE0ciOSX.mjs +0 -4
- package/dist/run-sugar-hGKprsKz.mjs.map +0 -1
- package/dist/sugar-checks-CTCsK5DJ.mjs.map +0 -1
- package/dist/vetra-gateway-Bpe50oGk.mjs +0 -4
- package/dist/vetra-host-BrLdIMRP.mjs.map +0 -1
- package/dist/vetra-instance-CPNIsaxh.mjs.map +0 -1
- package/dist/vetra-launcher-BtDWQBuh.mjs +0 -4
- package/dist/vetra-launcher-Dokr1aDK.mjs.map +0 -1
- package/dist/warn-subgraph-type-conflicts-BOHBmThq.mjs +0 -19
- package/dist/warn-subgraph-type-conflicts-BOHBmThq.mjs.map +0 -1
|
@@ -1,19 +1,27 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
3
|
-
import { U as probeHostsFolder, it as splitRunArgv } from "./compound-
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="fb112778-9ced-5169-9983-5eb72b8aceba")}catch(e){}}();
|
|
3
|
+
import { U as probeHostsFolder, it as splitRunArgv } from "./compound-Q9sZSEZF-DQvtoigb.mjs";
|
|
4
|
+
import { t as devHostOf } from "./dev-host-RhWeATKB.mjs";
|
|
5
|
+
import { DEV_HOST } from "@powerhousedao/shared/clis/constants";
|
|
4
6
|
//#region src/utils/run-sugar.ts
|
|
5
7
|
/**
|
|
6
8
|
* The commands that run a host every scaffold has, and the host: `ph dev`,
|
|
7
9
|
* `ph connect` and `ph switchboard` are `ph run <host>` and have no code of
|
|
8
|
-
* their own. `ph dev` runs
|
|
10
|
+
* their own. `ph dev` runs the dev mode: hosts/dev, or hosts/vetra in a
|
|
11
|
+
* project that has only that one ({@link sugarHostOf}). They are rewritten
|
|
9
12
|
* whatever the project holds, so a project without the host gets the error
|
|
10
13
|
* of `ph run` (sugar-checks.ts says it first, as typed).
|
|
11
14
|
*/
|
|
12
15
|
const HOST_COMMANDS = {
|
|
13
|
-
dev:
|
|
16
|
+
dev: DEV_HOST,
|
|
14
17
|
connect: "connect",
|
|
15
18
|
switchboard: "switchboard"
|
|
16
19
|
};
|
|
20
|
+
/** The host the command runs in this project. */
|
|
21
|
+
function sugarHostOf(command, projectRoot) {
|
|
22
|
+
const host = HOST_COMMANDS[command];
|
|
23
|
+
return host === DEV_HOST ? devHostOf(projectRoot) : host;
|
|
24
|
+
}
|
|
17
25
|
/** `ph connect <subcommand>` and the verb of the connect host it stands for. */
|
|
18
26
|
const CONNECT_VERBS = {
|
|
19
27
|
studio: "dev",
|
|
@@ -58,7 +66,7 @@ function applyRunSugar(args, knownCommands, projectRoot) {
|
|
|
58
66
|
if (first === "connect") return { args: connectSugar(args) };
|
|
59
67
|
if (Object.hasOwn(HOST_COMMANDS, first)) return { args: [
|
|
60
68
|
"run",
|
|
61
|
-
|
|
69
|
+
sugarHostOf(first, projectRoot),
|
|
62
70
|
...args.slice(1)
|
|
63
71
|
] };
|
|
64
72
|
if (knownCommands.has(first)) return { args };
|
|
@@ -90,7 +98,7 @@ function forwardRunnerArgv(args) {
|
|
|
90
98
|
];
|
|
91
99
|
}
|
|
92
100
|
//#endregion
|
|
93
|
-
export { forwardRunnerArgv as i, HOST_COMMANDS as n, applyRunSugar as r, CONNECT_VERBS as t };
|
|
101
|
+
export { sugarHostOf as a, forwardRunnerArgv as i, HOST_COMMANDS as n, applyRunSugar as r, CONNECT_VERBS as t };
|
|
94
102
|
|
|
95
|
-
//# sourceMappingURL=run-sugar-
|
|
96
|
-
//# debugId=
|
|
103
|
+
//# sourceMappingURL=run-sugar-CkuGJuPg.mjs.map
|
|
104
|
+
//# debugId=fb112778-9ced-5169-9983-5eb72b8aceba
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"run-sugar-CkuGJuPg.mjs","sources":["../src/utils/run-sugar.ts"],"sourcesContent":["import { probeHostsFolder, splitRunArgv } from \"@powerhousedao/host-core\";\nimport { DEV_HOST } from \"@powerhousedao/shared/clis/constants\";\nimport { devHostOf, type DevHost } from \"./dev-host.js\";\n\nexport interface RunSugarResult {\n args: string[];\n /** Set when hosts/ exists but is empty: no host is defined, so nothing is rewritten. */\n warning?: string;\n}\n\n/** A host a scaffold has. */\nexport type SugarHost = DevHost | \"connect\" | \"switchboard\";\n\n/**\n * The commands that run a host every scaffold has, and the host: `ph dev`,\n * `ph connect` and `ph switchboard` are `ph run <host>` and have no code of\n * their own. `ph dev` runs the dev mode: hosts/dev, or hosts/vetra in a\n * project that has only that one ({@link sugarHostOf}). They are rewritten\n * whatever the project holds, so a project without the host gets the error\n * of `ph run` (sugar-checks.ts says it first, as typed).\n */\nexport const HOST_COMMANDS: Readonly<Record<string, SugarHost>> = {\n dev: DEV_HOST,\n connect: \"connect\",\n switchboard: \"switchboard\",\n};\n\n/** The host the command runs in this project. */\nexport function sugarHostOf(command: string, projectRoot: string): SugarHost {\n const host = HOST_COMMANDS[command];\n return host === DEV_HOST ? devHostOf(projectRoot) : host;\n}\n\n/** `ph connect <subcommand>` and the verb of the connect host it stands for. */\nexport const CONNECT_VERBS: Readonly<Record<string, string>> = {\n studio: \"dev\",\n build: \"build\",\n preview: \"serve\",\n};\n\nconst isHelp = (arg: string | undefined) => arg === \"--help\" || arg === \"-h\";\n\n/**\n * `ph connect [studio|build|preview]` → `ph run connect <dev|build|serve>`.\n * Without a subcommand it is `studio`, as it always was. `ph connect config`\n * and `ph connect --help` stay the `connect` command: a tool, not a host.\n * Any other word is a verb of the host (`ph connect serve`).\n */\nfunction connectSugar(args: string[]): string[] {\n const rest = args.slice(1);\n if (rest[0] === \"config\" || isHelp(rest[0])) return args;\n if (rest.length === 0 || rest[0].startsWith(\"-\")) {\n return [\"run\", \"connect\", CONNECT_VERBS.studio, ...rest];\n }\n if (Object.hasOwn(CONNECT_VERBS, rest[0])) {\n return [\"run\", \"connect\", CONNECT_VERBS[rest[0]], ...rest.slice(1)];\n }\n return [\"run\", ...args];\n}\n\n/**\n * `ph <host-name> [verb]` sugar: when the first arg is not a registered\n * command and names a host in the project's hosts/ folder, splice in `run`.\n * Built-in commands win collisions by construction — the known-command check\n * runs first. {@link HOST_COMMANDS} are sugar in every project. `ph vetra` is\n * a command, the gateway to Vetra Studio (services/vetra-gateway.ts), and\n * never a host.\n */\nexport function applyRunSugar(\n args: string[],\n knownCommands: ReadonlySet<string>,\n projectRoot: string,\n): RunSugarResult {\n const first = args[0];\n if (!first || first.startsWith(\"-\")) {\n return { args };\n }\n if (first === \"connect\") {\n return { args: connectSugar(args) };\n }\n if (Object.hasOwn(HOST_COMMANDS, first)) {\n return {\n args: [\"run\", sugarHostOf(first, projectRoot), ...args.slice(1)],\n };\n }\n if (knownCommands.has(first)) {\n return { args };\n }\n const probe = probeHostsFolder(projectRoot);\n if (probe.kind === \"empty\") {\n return {\n args,\n warning:\n `hosts/ exists at ${probe.dir} but contains no <name>/host.js — ` +\n \"no host is defined. Run `ph migrate` to add the host files.\",\n };\n }\n if (probe.kind === \"present\" && probe.hosts.includes(first)) {\n return { args: [\"run\", ...args] };\n }\n return { args };\n}\n\n/**\n * `ph run <host> [verb] <runner arguments>`: moves the runner's arguments\n * behind a `--`, so the `run` command takes them as they are instead of\n * refusing the ones it does not know. The verb is spelled out: after the `--`\n * nothing is read as one. Any other invocation is returned as it is.\n */\nexport function forwardRunnerArgv(args: string[]): string[] {\n if (args[0] !== \"run\") return args;\n const { host, verb, own, argv } = splitRunArgv(args.slice(1));\n if (host === undefined || argv.length === 0) return args;\n return [\"run\", host, verb ?? \"run\", ...own, \"--\", ...argv];\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAqBA,MAAa,gBAAqD;CAChE,KAAK;CACL,SAAS;CACT,aAAa;AACf;;AAGA,SAAgB,YAAY,SAAiB,aAAgC;C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;;;AAQA,SAAgB,kBAAkB,MAA0B;CAC1D,IAAI,KAAK,OAAO,OAAO,OAAO;CAC9B,MAAM,EAAE,MAAM,MAAM,KAAK,SAAS,aAAa,KAAK,MAAM,CAAC,CAAC;CAC5D,IAAI,SAAS,KAAA,KAAa,KAAK,WAAW,GAAG,OAAO;CACpD,OAAO;EAAC;EAAO;EAAM,QAAQ;EAAO,GAAG;EAAK;EAAM,GAAG;CAAI;AAC3D","debug_id":"fb112778-9ced-5169-9983-5eb72b8aceba"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as forwardRunnerArgv, r as applyRunSugar } from "./run-sugar-
|
|
1
|
+
import { i as forwardRunnerArgv, r as applyRunSugar } from "./run-sugar-CkuGJuPg.mjs";
|
|
2
2
|
export { applyRunSugar, forwardRunnerArgv };
|
|
3
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
4
|
-
//# debugId=
|
|
3
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="58f6055d-6409-5a6a-b403-b9aec3f3faf1")}catch(e){}}();
|
|
4
|
+
//# debugId=58f6055d-6409-5a6a-b403-b9aec3f3faf1
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as RunnerHandle, t as RunnerContext } from "../index-
|
|
1
|
+
import { n as RunnerHandle, t as RunnerContext } from "../index-Bs1PfL3W.mjs";
|
|
2
2
|
import { ConnectHostParsed, ConnectOutputs } from "@powerhousedao/ph-run/runners/connect";
|
|
3
3
|
export * from "@powerhousedao/ph-run/runners/connect";
|
|
4
4
|
//#region src/runners/connect.d.ts
|
package/dist/runners/connect.mjs
CHANGED
|
@@ -32,7 +32,7 @@ async function toStudioArgs(host, passed) {
|
|
|
32
32
|
const viteCacheOf = (host, ctx) => join(ctx.projectRoot, "node_modules", ctx.hostPackage ? `.vite-${`${ctx.hostPackage.name}/${host.name}`.replace(/[^\w.@/-]/g, "_").replaceAll("/", "+")}` : `.vite-${host.name.replace(/[^\w.-]/g, "_")}`);
|
|
33
33
|
async function dev(host, ctx) {
|
|
34
34
|
await validateComposition(host, ctx);
|
|
35
|
-
const { runConnectStudio } = await import("../connect-studio-
|
|
35
|
+
const { runConnectStudio } = await import("../connect-studio-B2gugCJU.mjs");
|
|
36
36
|
const args = await toStudioArgs(host, await connectInvocationArgs(host, ctx));
|
|
37
37
|
const studio = {};
|
|
38
38
|
let override = callerOverride(host, ctx, ctx.verb);
|
|
@@ -68,7 +68,7 @@ const run = dev;
|
|
|
68
68
|
/** `build`: the Connect build service (`ph connect build` is sugar for it). */
|
|
69
69
|
async function build(host, ctx) {
|
|
70
70
|
await validateComposition(host, ctx);
|
|
71
|
-
const { runConnectBuild } = await import("../connect-build-
|
|
71
|
+
const { runConnectBuild } = await import("../connect-build-CaTxdYcc.mjs");
|
|
72
72
|
const { connectBuildServiceArgs } = await import("../service-args-D6y3L0bm.mjs");
|
|
73
73
|
const classic = await connectBuildServiceArgs();
|
|
74
74
|
const passed = await connectBuildInvocationArgs(host, ctx);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as RunnerContext } from "../index-
|
|
1
|
+
import { t as RunnerContext } from "../index-Bs1PfL3W.mjs";
|
|
2
2
|
import { SwitchboardHandle, SwitchboardHostParsed } from "@powerhousedao/ph-run/runners/switchboard";
|
|
3
3
|
export * from "@powerhousedao/ph-run/runners/switchboard";
|
|
4
4
|
//#region src/runners/switchboard.d.ts
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="76083e3e-dd9e-51c9-8041-2c590c0d60cc")}catch(e){}}();
|
|
3
|
-
import { F as normalizePluginEntries, I as normalizePluginEntry, g as entryActiveForVerb } from "../compound-
|
|
4
|
-
import { o as projectDriveId, s as resolveDriveDeclaration } from "../dist-
|
|
3
|
+
import { F as normalizePluginEntries, I as normalizePluginEntry, g as entryActiveForVerb } from "../compound-Q9sZSEZF-DQvtoigb.mjs";
|
|
4
|
+
import { o as projectDriveId, s as resolveDriveDeclaration } from "../dist-D_UjZsgt.mjs";
|
|
5
5
|
import { DEFAULT_SWITCHBOARD_PORT } from "@powerhousedao/shared/clis/constants";
|
|
6
6
|
import { VETRA_PROCESSOR_CONFIG_KEY } from "@powerhousedao/config";
|
|
7
7
|
import { dev as dev$1, run as run$1 } from "@powerhousedao/ph-run/runners/switchboard";
|
|
@@ -19,7 +19,7 @@ const verbs = [
|
|
|
19
19
|
/** Build the project's reactor package (the SAME service as `ph build`) — what
|
|
20
20
|
* this switchboard serves. Starts no server; orthogonal to run/serve/dev. */
|
|
21
21
|
async function build(host, _ctx) {
|
|
22
|
-
const { runBuild } = await import("../build-
|
|
22
|
+
const { runBuild } = await import("../build-DuwAPWMY.mjs");
|
|
23
23
|
const { buildServiceArgs } = await import("../service-args-D6y3L0bm.mjs");
|
|
24
24
|
const classic = await buildServiceArgs();
|
|
25
25
|
await runBuild({
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
3
|
-
import { O as loadHost, U as probeHostsFolder, ut as withoutHostsMessage } from "./compound-
|
|
4
|
-
import { n as
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="3c436273-79ee-547c-a05e-e6be85827ec5")}catch(e){}}();
|
|
3
|
+
import { O as loadHost, U as probeHostsFolder, ut as withoutHostsMessage } from "./compound-Q9sZSEZF-DQvtoigb.mjs";
|
|
4
|
+
import { n as isDevHost } from "./dev-host-RhWeATKB.mjs";
|
|
5
|
+
import { a as sugarHostOf, n as HOST_COMMANDS, t as CONNECT_VERBS } from "./run-sugar-CkuGJuPg.mjs";
|
|
5
6
|
import { DEPRECATIONS_REMOVED_IN, MIGRATION_GUIDE_URL } from "@powerhousedao/shared/clis/deprecations";
|
|
6
7
|
//#region src/utils/sugar-checks.ts
|
|
7
8
|
/**
|
|
@@ -21,7 +22,7 @@ const SWITCHBOARD_VERB_FLAGS = {
|
|
|
21
22
|
};
|
|
22
23
|
/** Read by the CLI itself, before any command. */
|
|
23
24
|
const CLI_FLAGS = /* @__PURE__ */ new Set(["--debug"]);
|
|
24
|
-
function sugarInvocation(args) {
|
|
25
|
+
function sugarInvocation(args, projectRoot) {
|
|
25
26
|
const [command, ...rest] = args;
|
|
26
27
|
if (command === void 0 || !Object.hasOwn(HOST_COMMANDS, command)) return;
|
|
27
28
|
if (rest.some((arg) => arg === "--help" || arg === "-h")) return void 0;
|
|
@@ -37,7 +38,7 @@ function sugarInvocation(args) {
|
|
|
37
38
|
flags
|
|
38
39
|
};
|
|
39
40
|
}
|
|
40
|
-
const host = HOST_COMMANDS[command];
|
|
41
|
+
const host = projectRoot === void 0 ? HOST_COMMANDS[command] : sugarHostOf(command, projectRoot);
|
|
41
42
|
return {
|
|
42
43
|
typed: word ? `ph ${command} ${word}` : `ph ${command}`,
|
|
43
44
|
host,
|
|
@@ -61,7 +62,7 @@ function removedAliasError(args, projectRoot) {
|
|
|
61
62
|
* Undefined for anything else, for help, and for a project with the host.
|
|
62
63
|
*/
|
|
63
64
|
function withoutHostError(args, projectRoot) {
|
|
64
|
-
const invocation = sugarInvocation(args);
|
|
65
|
+
const invocation = sugarInvocation(args, projectRoot);
|
|
65
66
|
if (!invocation) return void 0;
|
|
66
67
|
const { typed, host } = invocation;
|
|
67
68
|
const probe = probeHostsFolder(projectRoot);
|
|
@@ -75,13 +76,13 @@ function withoutHostError(args, projectRoot) {
|
|
|
75
76
|
* (`--switchboard-port`); a flag the runner retired passes too, and the
|
|
76
77
|
* runner says so. Undefined when every flag passes.
|
|
77
78
|
*/
|
|
78
|
-
function removedFlagsError(args, schemas) {
|
|
79
|
-
const invocation = sugarInvocation(args);
|
|
79
|
+
function removedFlagsError(args, schemas, projectRoot) {
|
|
80
|
+
const invocation = sugarInvocation(args, projectRoot);
|
|
80
81
|
if (!invocation) return void 0;
|
|
81
82
|
const { typed, host, replacement } = invocation;
|
|
82
|
-
const members = host
|
|
83
|
+
const members = isDevHost(host) ? [schemas.switchboard, schemas.connect] : [schemas[host]];
|
|
83
84
|
const scoped = new Set(members.flatMap((schema) => Object.values(schema.memberOptions ?? {})));
|
|
84
|
-
const accepts = (name) => host
|
|
85
|
+
const accepts = (name) => isDevHost(host) ? name === "--restart" || members.some((schema) => schema.memberOptions?.[name] !== void 0 || !scoped.has(name) && [...schema.options, ...schema.flags].includes(name)) : [...members[0].options, ...members[0].flags].includes(name);
|
|
85
86
|
const errors = [];
|
|
86
87
|
const unsupported = [];
|
|
87
88
|
for (const name of invocation.flags) {
|
|
@@ -125,7 +126,7 @@ async function runnerModuleOf(projectRoot, host) {
|
|
|
125
126
|
async function runsStockRunner(projectRoot, host) {
|
|
126
127
|
const loaded = await runnerModuleOf(projectRoot, host);
|
|
127
128
|
if (!loaded) return false;
|
|
128
|
-
if (host
|
|
129
|
+
if (!isDevHost(host)) return STOCK_RUNNERS[host].includes(loaded.module);
|
|
129
130
|
if (loaded.module !== COMPOUND_RUNNER) return false;
|
|
130
131
|
const children = loaded.children;
|
|
131
132
|
if (typeof children !== "object" || children === null) return false;
|
|
@@ -162,14 +163,14 @@ async function sugarError(args, projectRoot) {
|
|
|
162
163
|
if (removed !== void 0) return removed;
|
|
163
164
|
const withoutHost = withoutHostError(args, projectRoot);
|
|
164
165
|
if (withoutHost !== void 0) return withoutHost;
|
|
165
|
-
const invocation = sugarInvocation(args);
|
|
166
|
+
const invocation = sugarInvocation(args, projectRoot);
|
|
166
167
|
if (!invocation || invocation.flags.length === 0) return void 0;
|
|
167
168
|
if (!await runsStockRunner(projectRoot, invocation.host)) return void 0;
|
|
168
169
|
const schemas = await loadArgSchemas();
|
|
169
|
-
return schemas ? removedFlagsError(args, schemas) : void 0;
|
|
170
|
+
return schemas ? removedFlagsError(args, schemas, projectRoot) : void 0;
|
|
170
171
|
}
|
|
171
172
|
//#endregion
|
|
172
173
|
export { sugarError };
|
|
173
174
|
|
|
174
|
-
//# sourceMappingURL=sugar-checks-
|
|
175
|
-
//# debugId=
|
|
175
|
+
//# sourceMappingURL=sugar-checks-CAtgUIem.mjs.map
|
|
176
|
+
//# debugId=3c436273-79ee-547c-a05e-e6be85827ec5
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sugar-checks-CAtgUIem.mjs","sources":["../src/utils/sugar-checks.ts"],"sourcesContent":["import {\n loadHost,\n probeHostsFolder,\n withoutHostsMessage,\n type RunnerArgsSchema,\n} from \"@powerhousedao/host-core\";\nimport {\n DEPRECATIONS_REMOVED_IN,\n MIGRATION_GUIDE_URL,\n} from \"@powerhousedao/shared/clis/deprecations\";\nimport { isDevHost } from \"./dev-host.js\";\nimport {\n CONNECT_VERBS,\n HOST_COMMANDS,\n sugarHostOf,\n type SugarHost,\n} from \"./run-sugar.js\";\n\n/**\n * What `ph dev`, `ph connect` and `ph switchboard` are refused for, before\n * they become `ph run <host>` (run-sugar.ts): a project without the host\n * file, and the flags of the commands they once were that `ph run` has no\n * argument for. `ph run` is not checked here, nor is any other host name: a\n * runner refuses the arguments it does not know itself. Nor are the flags of\n * a host on a runner of its own: they are checked against the stock runners.\n */\n\n/** `ph switchboard` flags that are verbs of the host. */\nconst SWITCHBOARD_VERB_FLAGS: Readonly<Record<string, string>> = {\n \"--migrate\": \"migrate\",\n \"--migrate-status\": \"migrate-status\",\n \"--reset\": \"reset\",\n \"--dev\": \"dev\",\n};\n\n/** Read by the CLI itself, before any command. */\nconst CLI_FLAGS = new Set([\"--debug\"]);\n\n/** The runner argument schemas the flags are checked against. */\nexport interface SugarArgSchemas {\n switchboard: RunnerArgsSchema;\n connect: RunnerArgsSchema;\n}\n\ninterface SugarInvocation {\n /** As typed: `ph connect build`. */\n typed: string;\n /** The host it runs. */\n host: SugarHost;\n /** What it is sugar for: `ph run <host> [verb]`. */\n replacement: string;\n /** The flags passed, by name, without their values. */\n flags: string[];\n}\n\nfunction sugarInvocation(\n args: readonly string[],\n projectRoot?: string,\n): SugarInvocation | undefined {\n const [command, ...rest] = args;\n if (command === undefined || !Object.hasOwn(HOST_COMMANDS, command)) {\n return undefined;\n }\n if (rest.some((arg) => arg === \"--help\" || arg === \"-h\")) return undefined;\n const flags = [\n ...new Set(\n rest\n .filter((arg) => arg.startsWith(\"-\") && arg !== \"--\")\n .map((arg) => arg.split(\"=\")[0]),\n ),\n ].filter((name) => !CLI_FLAGS.has(name));\n // A word right after the command is the subcommand or the verb.\n const word =\n rest.length > 0 && !rest[0].startsWith(\"-\") ? rest[0] : undefined;\n if (command === \"connect\") {\n // `ph connect config` reads and writes the config: a tool, not a host.\n if (word === \"config\") return undefined;\n const verb =\n word === undefined\n ? CONNECT_VERBS.studio\n : Object.hasOwn(CONNECT_VERBS, word)\n ? CONNECT_VERBS[word]\n : word;\n return {\n typed: word ? `ph connect ${word}` : \"ph connect\",\n host: \"connect\",\n replacement: `ph run connect ${verb}`,\n flags,\n };\n }\n // `ph dev` runs hosts/dev, or hosts/vetra where that is the one there is.\n const host =\n projectRoot === undefined\n ? HOST_COMMANDS[command]\n : sugarHostOf(command, projectRoot);\n return {\n typed: word ? `ph ${command} ${word}` : `ph ${command}`,\n host,\n replacement: word ? `ph run ${host} ${word}` : `ph run ${host}`,\n flags,\n };\n}\n\n/**\n * `ph reactor` was an alias of `ph switchboard`. It is gone, unless the\n * project names a host of its own that.\n */\nfunction removedAliasError(\n args: readonly string[],\n projectRoot: string,\n): string | undefined {\n if (args[0] !== \"reactor\") return undefined;\n const probe = probeHostsFolder(projectRoot);\n if (probe.kind === \"present\" && probe.hosts.includes(\"reactor\")) {\n return undefined;\n }\n return (\n `\\`ph reactor\\` was removed in ${DEPRECATIONS_REMOVED_IN}. ` +\n \"Use `ph switchboard` or `ph run switchboard` instead.\"\n );\n}\n\n/**\n * Why the command cannot run in this project: it has no hosts (the wording\n * of `ph run`, naming `ph migrate`), or it has hosts and not this one.\n * Undefined for anything else, for help, and for a project with the host.\n */\nexport function withoutHostError(\n args: readonly string[],\n projectRoot: string,\n): string | undefined {\n const invocation = sugarInvocation(args, projectRoot);\n if (!invocation) return undefined;\n const { typed, host } = invocation;\n const probe = probeHostsFolder(projectRoot);\n if (probe.kind !== \"present\") {\n return withoutHostsMessage(probe, `\\`${typed}\\``);\n }\n if (probe.hosts.includes(host)) return undefined;\n // `ph migrate` adds the hosts to a project that has none, and only then.\n return (\n `This project has no hosts/${host}/host.js, so \\`${typed}\\` cannot run. ` +\n `\\`ph migrate\\` adds the host files to a project without hosts only: add hosts/${host}/host.js to this one. ` +\n `See ${MIGRATION_GUIDE_URL}`\n );\n}\n\n/**\n * The flags `ph run <host>` has no argument for, as one error. A flag the\n * runner takes passes, under its member name for `ph dev`\n * (`--switchboard-port`); a flag the runner retired passes too, and the\n * runner says so. Undefined when every flag passes.\n */\nexport function removedFlagsError(\n args: readonly string[],\n schemas: SugarArgSchemas,\n projectRoot?: string,\n): string | undefined {\n const invocation = sugarInvocation(args, projectRoot);\n if (!invocation) return undefined;\n const { typed, host, replacement } = invocation;\n // A compound hands each member its arguments; a member option goes by its\n // member name there (`--switchboard-port`), never by its plain one.\n const members = isDevHost(host)\n ? [schemas.switchboard, schemas.connect]\n : [schemas[host]];\n const scoped = new Set(\n members.flatMap((schema) => Object.values(schema.memberOptions ?? {})),\n );\n const accepts = (name: string): boolean =>\n isDevHost(host)\n ? // `ph run dev` takes --restart itself (vetra-host.ts).\n name === \"--restart\" ||\n members.some(\n (schema) =>\n schema.memberOptions?.[name] !== undefined ||\n (!scoped.has(name) &&\n [...schema.options, ...schema.flags].includes(name)),\n )\n : [...members[0].options, ...members[0].flags].includes(name);\n const errors: string[] = [];\n const unsupported: string[] = [];\n for (const name of invocation.flags) {\n const verb =\n host === \"switchboard\" ? SWITCHBOARD_VERB_FLAGS[name] : undefined;\n const retired = members.some(\n (schema) => schema.retired?.[name] !== undefined,\n );\n if (verb !== undefined) {\n errors.push(\n `\\`${typed} ${name}\\` was removed in ${DEPRECATIONS_REMOVED_IN}. Use \\`ph run switchboard ${verb}\\` instead.`,\n );\n } else if (accepts(name) || retired) {\n continue;\n } else {\n unsupported.push(name);\n }\n }\n if (unsupported.length > 0) {\n const one = unsupported.length === 1;\n const subject = one\n ? `\\`${typed} ${unsupported[0]}\\` was removed in ${DEPRECATIONS_REMOVED_IN}: \\`${replacement}\\` has no such argument.`\n : `The \\`${typed}\\` flags ${unsupported.join(\", \")} were removed in ${DEPRECATIONS_REMOVED_IN}: \\`${replacement}\\` has no such arguments.`;\n errors.push(\n `${subject} Set what ${one ? \"it configures\" : \"they configure\"} in the host files under hosts/ instead. ` +\n `See ${MIGRATION_GUIDE_URL}`,\n );\n }\n return errors.length > 0 ? errors.join(\"\\n\") : undefined;\n}\n\n/** The runners the scaffold's hosts name, whose schemas the flags are\n * checked against. ph-cli's are the ph-run ones, re-exported. */\nconst STOCK_RUNNERS: Readonly<Record<string, readonly string[]>> = {\n connect: [\n \"@powerhousedao/ph-cli/runners/connect\",\n \"@powerhousedao/ph-run/runners/connect\",\n ],\n switchboard: [\n \"@powerhousedao/ph-cli/runners/switchboard\",\n \"@powerhousedao/ph-run/runners/switchboard\",\n ],\n};\nconst COMPOUND_RUNNER = \"@powerhousedao/host-core/runners/compound\";\n\nasync function runnerModuleOf(\n projectRoot: string,\n host: string,\n): Promise<{ module: string; children?: unknown } | undefined> {\n try {\n const { host: definition } = await loadHost(projectRoot, host);\n return {\n module: definition.runner.module,\n children: (definition as { children?: unknown }).children,\n };\n } catch {\n // `ph run` loads it next and says what is wrong with it.\n return undefined;\n }\n}\n\n/**\n * Whether the host runs the stock runner of its command: the connect or\n * switchboard runner, or for `ph dev` the compound over members that are\n * the project's connect and switchboard hosts, each on its stock runner.\n * Anything else has arguments of its own, which its runner checks.\n */\nexport async function runsStockRunner(\n projectRoot: string,\n host: SugarHost,\n): Promise<boolean> {\n const loaded = await runnerModuleOf(projectRoot, host);\n if (!loaded) return false;\n if (!isDevHost(host)) return STOCK_RUNNERS[host].includes(loaded.module);\n if (loaded.module !== COMPOUND_RUNNER) return false;\n const children = loaded.children;\n if (typeof children !== \"object\" || children === null) return false;\n const members = new Set<string>();\n for (const child of Object.values(children as Record<string, unknown>)) {\n const { host: member, runner } = (child ?? {}) as {\n host?: unknown;\n runner?: { module?: unknown };\n };\n if (typeof member !== \"string\" || !Object.hasOwn(STOCK_RUNNERS, member)) {\n return false;\n }\n // A member that names a runner module is not on its sibling's.\n if (runner?.module !== undefined) return false;\n members.add(member);\n }\n for (const member of members) {\n const sibling = await runnerModuleOf(projectRoot, member);\n if (!sibling || !STOCK_RUNNERS[member].includes(sibling.module)) {\n return false;\n }\n }\n return true;\n}\n\nasync function loadArgSchemas(): Promise<SugarArgSchemas | undefined> {\n try {\n const [switchboard, connect] = await Promise.all([\n import(\"@powerhousedao/ph-run/runners/switchboard\"),\n import(\"@powerhousedao/ph-run/runners/connect\"),\n ]);\n return {\n switchboard: switchboard.argsSchema,\n connect: connect.argsSchema,\n };\n } catch {\n return undefined;\n }\n}\n\n/**\n * Run by the CLI on the command line as typed, before the host sugar: the\n * error the invocation ends with, if any. `args` is untouched either way.\n */\nexport async function sugarError(\n args: readonly string[],\n projectRoot: string,\n): Promise<string | undefined> {\n const removed = removedAliasError(args, projectRoot);\n if (removed !== undefined) return removed;\n const withoutHost = withoutHostError(args, projectRoot);\n if (withoutHost !== undefined) return withoutHost;\n const invocation = sugarInvocation(args, projectRoot);\n if (!invocation || invocation.flags.length === 0) return undefined;\n // A runner of the project's own takes the arguments it declares.\n if (!(await runsStockRunner(projectRoot, invocation.host))) return undefined;\n // Without the schemas the runner still refuses what it does not accept.\n const schemas = await loadArgSchemas();\n return schemas ? removedFlagsError(args, schemas, projectRoot) : undefined;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;AA4BA,MAAM,yBAA2D;CAC/D,aAAa;CACb,oBAAoB;CACpB,WAAW;CACX,SAAS;AACX;;AAGA,MAAM,4BAAY,IAAI,IAAI,CAAC,SAAS,CAAC;AAmBrC,SAAS,gBACP,MACA,aAC6B;CAC7B,MAAM,CAAC,SAAS,GAAG,QAAQ;CAC3B,IAAI,YAAY,KAAA,KAAa,CAAC,OAAO,OAAO,eAAe,OAAO,GAChE;CAEF,IAAI,KAAK,MAAM,QAAQ,QAAQ,YAAY,QAAQ,IAAI,GAAG,OAAO,KAAA;CACjE,MAAM,QAAQ,CACZ,GAAG,IAAI,IACL,KACG,QAAQ,QAAQ,IAAI,WAAW,GAAG,KAAK,QAAQ,IAAI,CAAC,CACpD,KAAK,QAAQ,IAAI,MAAM,GAAG,CAAC,CAAC,EAAE,CACnC,CACF,CAAC,CAAC,QAAQ,SAAS,CAAC,UAAU,IAAI,IAAI,CAAC;CAEvC,MAAM,OACJ,KAAK,SAAS,KAAK,CAAC,KAAK,EAAE,CAAC,WAAW,GAAG,IAAI,KAAK,KAAK,KAAA;CAC1D,IAAI,YAAY,WAAW;EAEzB,IAAI,SAAS,UAAU,OAAO,KAAA;EAC9B,MAAM,OACJ,SAAS,KAAA,IACL,cAAc,SACd,OAAO,OAAO,eAAe,IAAI,IAC/B,cAAc,QACd;EACR,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Aa,gBAAgB,MAAM,WAAW;CACpD,IAAI,CAAC,cAAc,WAAW,MAAM,WAAW,GAAG,OAAO,KAAA;CAEzD,IAAI,CAAE,MAAM,gBAAgB,aAAa,WAAW,IAAI,GAAI,OAAO,KAAA;CAEnE,MAAM,UAAU,MAAM,eAAe;CACrC,OAAO,UAAU,kBAAkB,MAAM,SAAS,WAAW,IAAI,KAAA;AACnE","debug_id":"3c436273-79ee-547c-a05e-e6be85827ec5"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
3
|
-
import { t as getVersion } from "./get-version-
|
|
4
|
-
import { f as verifyReleaseApproval, i as revisionFiles, n as publishedFiles, o as packRelease, r as readReleaseApproval, s as packedDigests, u as decisionWithoutApproval } from "./files-
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="db2f8cf1-db95-56bb-a5ee-18b7580a513f")}catch(e){}}();
|
|
3
|
+
import { t as getVersion } from "./get-version-7oKMD8Gt.mjs";
|
|
4
|
+
import { f as verifyReleaseApproval, i as revisionFiles, n as publishedFiles, o as packRelease, r as readReleaseApproval, s as packedDigests, u as decisionWithoutApproval } from "./files-DEHg350R.mjs";
|
|
5
5
|
//#region src/services/release/verify.ts
|
|
6
6
|
/**
|
|
7
7
|
* Compares the package as it is now with its release approval: the files
|
|
@@ -67,5 +67,5 @@ function checkApprovalBeforePublish(packageRoot, required) {
|
|
|
67
67
|
//#endregion
|
|
68
68
|
export { checkApprovalBeforePublish, renderReleaseDecision, verifyRelease };
|
|
69
69
|
|
|
70
|
-
//# sourceMappingURL=verify-
|
|
71
|
-
//# debugId=
|
|
70
|
+
//# sourceMappingURL=verify-DXrs0JUp.mjs.map
|
|
71
|
+
//# debugId=db2f8cf1-db95-56bb-a5ee-18b7580a513f
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verify-
|
|
1
|
+
{"version":3,"file":"verify-DXrs0JUp.mjs","sources":["../src/services/release/verify.ts"],"sourcesContent":["import { getVersion } from \"../../get-version.js\";\nimport {\n type ApprovalRead,\n decisionWithoutApproval,\n type ReleaseDecision,\n verifyReleaseApproval,\n} from \"./approval.js\";\nimport { publishedFiles, readReleaseApproval, revisionFiles } from \"./files.js\";\nimport { packedDigests, packRelease, type PackedRelease } from \"./pack.js\";\nimport type { FileDigest } from \"./revision.js\";\n\n/**\n * Compares the package as it is now with its release approval: the files\n * the revision reads, with the output directory and exclusions the approval\n * records, and what `npm pack` publishes, or `published` when the caller\n * already packed it. Throws when either cannot be read.\n */\nexport function verifyRelease(\n packageRoot: string,\n read: ApprovalRead = readReleaseApproval(packageRoot),\n published?: readonly FileDigest[],\n): ReleaseDecision {\n if (read.kind !== \"found\") return decisionWithoutApproval(read);\n const { approval } = read;\n return verifyReleaseApproval(approval, {\n phCliVersion: getVersion(),\n files: revisionFiles(packageRoot, [\n approval.outDir,\n ...approval.packageRevision.excluded,\n ]),\n publishedFiles: published ?? publishedFiles(packageRoot),\n });\n}\n\nconst HEADLINES: Readonly<Record<ReleaseDecision[\"decision\"], string>> = {\n approved: \"the release approval matches this package\",\n missing: \"this package has no release approval\",\n unreadable: \"the release approval cannot be read\",\n stale: \"the release approval does not match this package\",\n refused: \"the release approval records a release check that did not pass\",\n};\n\n/** The decision and each reason on its own line. */\nexport function renderReleaseDecision(decision: ReleaseDecision): string {\n return [\n `${decision.decision}: ${HEADLINES[decision.decision]}`,\n ...decision.reasons.map((reason) => ` - ${reason}`),\n ].join(\"\\n\");\n}\n\n/**\n * Whether `ph publish` goes on. With `--require-approval`, `packed` is the\n * tarball the approval was checked against: publish that file, and call its\n * `dispose` once done.\n */\nexport type PublishCheck =\n | { readonly proceed: false }\n | { readonly proceed: true; readonly packed?: PackedRelease };\n\n/**\n * Checks the release approval before `ph publish` resolves a registry.\n * Without an approval file and without `required`, does nothing, as before\n * approvals existed. Otherwise a decision other than approved is a warning,\n * or with `required` a refusal.\n */\nexport function checkApprovalBeforePublish(\n packageRoot: string,\n required: boolean,\n): PublishCheck {\n const read = readReleaseApproval(packageRoot);\n if (read.kind === \"missing\" && !required) return { proceed: true };\n let text: string;\n let packed: PackedRelease | undefined;\n let approved = false;\n try {\n if (required && read.kind === \"found\") packed = packRelease(packageRoot);\n const decision = verifyRelease(\n packageRoot,\n read,\n packed && packedDigests(packed),\n );\n approved = decision.decision === \"approved\";\n text = renderReleaseDecision(decision);\n } catch (error) {\n text = `the release approval could not be checked: ${error instanceof Error ? error.message : String(error)}`;\n }\n if (approved) {\n console.log(`✔ ${text}`);\n return { proceed: true, packed };\n }\n packed?.dispose();\n if (required) {\n console.error(\n `✘ ${text}\\nph publish --require-approval publishes only an approved package. Run ph build --release, then publish again.`,\n );\n return { proceed: false };\n }\n console.warn(\n `⚠ ${text}\\nPublishing anyway. Run ph build --release to approve this package, or pass --require-approval to stop here instead.`,\n );\n return { proceed: true };\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAiBA,SAAgB,cACd,aACA,OAAqB,oBAAoB,WAAW,GACpD,WACiB;CACjB,IAAI,KAAK,SAAS,SAAS,OAAO,wBAAwB,IAAI;CAC9D,MAAM,EAAE,aAAa;CACrB,OAAO,sBAAsB,UAAU;EACrC,cAAc,WAAW;EACzB,OAAO,cAAc,aAAa,CAChC,SAAS,QACT,GAAG,SAAS,gBAAgB,QAC9B,CAAC;EACD,gBAAgB,aAAa,eAAe,WAAW;CACzD,CAAC;AACH;AAEA,MAAM,YAAmE;CACvE,UAAU;CACV,SAAS;CACT,YAAY;CACZ,OAAO;CACP,SAAS;AACX;;AAGA,SAAgB,sBAAsB,UAAmC;CACvE,OAAO,CACL,GAAG,SAAS,SAAS,IAAI,UAAU,SAAS,aAC5C,GAAG,SAAS,QAAQ,KAAK,WAAW,OAAO,QAAQ,CACrD,CAAC,CAAC,KAAK,IAAI;AACb;;;;;;;AAiBA,SAAgB,2BACd,aACA,UACc;CACd,MAAM,OAAO,oBAAoB,WAAW;CAC5C,IAAI,KAAK,SAAS,aAAa,CAAC,UAAU,OAAO,EAAE,SAAS,KAAK;CACjE,IAAI;CACJ,IAAI;CACJ,IAAI,WAAW;CACf,IAAI;EACF,IAAI,YAAY,KAAK,SAAS,SAAS,SAAS,YAAY,WAAW;EACvE,MAAM,WAAW,cACf,aACA,MACA,UAAU,cAAc,MAAM,CAChC;EACA,WAAW,SAAS,aAAa;EACjC,OAAO,sBAAsB,QAAQ;CACvC,SAAS,OAAO;EACd,OAAO,8CAA8C,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;CAC5G;CACA,IAAI,UAAU;EACZ,QAAQ,IAAI,KAAK,MAAM;EACvB,OAAO;GAAE,SAAS;GAAM;EAAO;CACjC;CACA,QAAQ,QAAQ;CAChB,IAAI,UAAU;EACZ,QAAQ,MACN,KAAK,KAAK,gHACZ;EACA,OAAO,EAAE,SAAS,MAAM;CAC1B;CACA,QAAQ,KACN,KAAK,KAAK,sHACZ;CACA,OAAO,EAAE,SAAS,KAAK;AACzB","debug_id":"db2f8cf1-db95-56bb-a5ee-18b7580a513f"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
3
|
-
import { t as getVersion } from "./get-version-
|
|
4
|
-
import { Q as resolvePackageRoot } from "./compound-
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="b7ed0ad1-a808-50fc-9cbc-4431643ae255")}catch(e){}}();
|
|
3
|
+
import { t as getVersion } from "./get-version-7oKMD8Gt.mjs";
|
|
4
|
+
import { Q as resolvePackageRoot } from "./compound-Q9sZSEZF-DQvtoigb.mjs";
|
|
5
5
|
import { readFileSync } from "node:fs";
|
|
6
6
|
import path from "node:path";
|
|
7
7
|
import { spawn } from "node:child_process";
|
|
@@ -169,5 +169,5 @@ async function vetraGateway(rest) {
|
|
|
169
169
|
//#endregion
|
|
170
170
|
export { openVetraStudio as a, vetraGateway as c, installedStudio as i, VETRA_STUDIO_HOST as n, planVetraGateway as o, VETRA_STUDIO_PACKAGE as r, studioInstallCommand as s, VETRA_GATEWAY_ENV as t };
|
|
171
171
|
|
|
172
|
-
//# sourceMappingURL=vetra-gateway-
|
|
173
|
-
//# debugId=
|
|
172
|
+
//# sourceMappingURL=vetra-gateway-BHuz7pvS.mjs.map
|
|
173
|
+
//# debugId=b7ed0ad1-a808-50fc-9cbc-4431643ae255
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vetra-gateway-BxcduYAI.mjs","sources":["../src/services/vetra-gateway.ts"],"sourcesContent":["import { resolvePackageRoot } from \"@powerhousedao/host-core\";\nimport { CALLER_CWD_ENV } from \"@powerhousedao/shared/clis/command-names\";\nimport { yellow } from \"colorette\";\nimport { spawn } from \"node:child_process\";\nimport { readFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport { resolveCommand, type Agent } from \"package-manager-detector\";\nimport { valid } from \"semver\";\nimport { getVersion } from \"../get-version.js\";\n\n/**\n * `ph vetra` is the gateway to Vetra Studio, the host `studio` that the\n * package @powerhousedao/vetra-cli supplies. ph-cli names the package and the\n * host and nothing else of it: `ph vetra [verb] [args]` is\n * `ph run @powerhousedao/vetra-cli/studio [verb] [args]`, once the project\n * has the package. A project without it gets it first, as a devDependency at\n * this ph-cli's version: the two are released with the same version numbers.\n */\nexport const VETRA_STUDIO_PACKAGE = \"@powerhousedao/vetra-cli\";\nexport const VETRA_STUDIO_HOST = `${VETRA_STUDIO_PACKAGE}/studio`;\n\n/** Set on the ph-cli started after an install: it finds the package, or\n * fails, and never installs it again. */\nexport const VETRA_GATEWAY_ENV = \"PH_VETRA_GATEWAY_INSTALLED\";\n\n/** The package as the project has it; undefined when it has none. */\nexport type InstalledStudio = { version: string | undefined } | undefined;\n\nexport type VetraGatewayPlan =\n | { action: \"run\"; warning?: string }\n | { action: \"install\"; notice: string; command: string };\n\n/** The command line that adds the package at ph-cli's version as a\n * devDependency, with the project's package manager. */\nexport function studioInstallCommand(\n agent: Agent,\n phCliVersion: string,\n): string {\n // A build that does not know its version takes the latest release.\n const version = valid(phCliVersion) ?? \"latest\";\n // As `ph install --local`: on a release day the packages are younger than\n // pnpm 11's minimumReleaseAge.\n const releaseAge = agent.startsWith(\"pnpm\")\n ? [\"--config.minimum-release-age=0\"]\n : [];\n const resolved = resolveCommand(agent, \"add\", [\n \"-D\",\n `${VETRA_STUDIO_PACKAGE}@${version}`,\n ...releaseAge,\n ]);\n if (!resolved) {\n throw new Error(\n `Could not resolve an install command for package manager \"${agent}\".`,\n );\n }\n return [resolved.command, ...resolved.args].join(\" \");\n}\n\n/** What `ph vetra` does in a project: install the package, or run its host,\n * warning when the installed version is not ph-cli's. */\nexport function planVetraGateway(facts: {\n installed: InstalledStudio;\n phCliVersion: string;\n packageManager: Agent;\n}): VetraGatewayPlan {\n const { installed, phCliVersion, packageManager } = facts;\n const command = studioInstallCommand(packageManager, phCliVersion);\n if (installed === undefined) {\n return {\n action: \"install\",\n notice:\n `Vetra Studio is the package ${VETRA_STUDIO_PACKAGE}, which this project does not have yet. ` +\n `Installing it as a devDependency with ${packageManager}:`,\n command,\n };\n }\n const { version } = installed;\n if (\n version !== undefined &&\n valid(phCliVersion) !== null &&\n version !== phCliVersion\n ) {\n return {\n action: \"run\",\n warning: `${VETRA_STUDIO_PACKAGE} ${version} is installed, but this ph-cli is ${phCliVersion}: align them with \\`${command}\\`.`,\n };\n }\n return { action: \"run\" };\n}\n\nexport interface VetraGatewayDeps {\n /** The project root, undefined outside a project, and its package manager. */\n project: () => Promise<{ projectPath?: string; packageManager: Agent }>;\n phCliVersion: string;\n installedStudio: (projectRoot: string) => InstalledStudio;\n /** Runs an install command line in `cwd`; resolves to its exit code. */\n install: (command: string, cwd: string) => Promise<number | null>;\n /** Runs this ph-cli with `args` in a new process; resolves to its exit code. */\n reexec: (args: string[], cwd: string) => Promise<number>;\n env: NodeJS.ProcessEnv;\n log: (message: string) => void;\n warn: (message: string) => void;\n}\n\nexport type VetraGatewayResult =\n /** Go on with this command line, in the project root. */\n | { args: string[]; projectRoot: string }\n /** A new ph-cli ran it, after the install. */\n | { exitCode: number };\n\n/**\n * `ph vetra [verb] [args]` (`rest`) in the project: the `ph run` command line\n * of the studio host when the package is there. Otherwise it installs the\n * package and runs that command line in a new ph-cli, since a package\n * installed while this one runs is not reliably resolved by it (Node caches\n * lookups, and the install may relink what it imports later).\n */\nexport async function openVetraStudio(\n rest: readonly string[],\n deps: VetraGatewayDeps,\n): Promise<VetraGatewayResult> {\n const { projectPath, packageManager } = await deps.project();\n if (projectPath === undefined) {\n throw new Error(\n \"No Powerhouse project found, so `ph vetra` cannot open Vetra Studio: it installs into and runs in a project. \" +\n \"Run it in one, or create one with `ph init`.\",\n );\n }\n const runArgs = [\"run\", VETRA_STUDIO_HOST, ...rest];\n const plan = planVetraGateway({\n installed: deps.installedStudio(projectPath),\n phCliVersion: deps.phCliVersion,\n packageManager,\n });\n if (plan.action === \"run\") {\n if (plan.warning) deps.warn(plan.warning);\n return { args: runArgs, projectRoot: projectPath };\n }\n // A stop reads the run record only: there is nothing to install for it.\n if (rest.includes(\"--stop\"))\n return { args: runArgs, projectRoot: projectPath };\n const manual = `Install it yourself, then run \\`ph vetra\\` again:\\n ${plan.command}`;\n if (deps.env[VETRA_GATEWAY_ENV]) {\n throw new Error(\n `${VETRA_STUDIO_PACKAGE} was installed, but this ph-cli does not find it from ${projectPath}. ${manual}`,\n );\n }\n deps.log(plan.notice);\n deps.log(`> ${plan.command}`);\n const code = await deps.install(plan.command, projectPath);\n if (code !== 0) {\n const how = code === null ? \"could not run\" : `exited with code ${code}`;\n throw new Error(\n `The install of ${VETRA_STUDIO_PACKAGE} ${how}, so Vetra Studio cannot start. ${manual}`,\n );\n }\n if (deps.installedStudio(projectPath) === undefined) {\n throw new Error(\n `The install passed, but ${VETRA_STUDIO_PACKAGE} does not resolve from ${projectPath}. ${manual}`,\n );\n }\n return { exitCode: await deps.reexec(runArgs, projectPath) };\n}\n\n/** The package's version as `ph run <package>/<host>` finds it: from the\n * project root, by its package.json, without importing it. */\nexport function installedStudio(projectRoot: string): InstalledStudio {\n const root = resolvePackageRoot(projectRoot, VETRA_STUDIO_PACKAGE);\n if (root === undefined) return undefined;\n try {\n const { version } = JSON.parse(\n readFileSync(path.join(root, \"package.json\"), \"utf8\"),\n ) as { version?: unknown };\n return { version: typeof version === \"string\" ? version : undefined };\n } catch {\n return { version: undefined };\n }\n}\n\nfunction runInstall(command: string, cwd: string): Promise<number | null> {\n return new Promise((resolve) => {\n // One command line, as printed: a shell runs the package manager's shim.\n const child = spawn(command, {\n cwd,\n stdio: \"inherit\",\n shell: true,\n windowsHide: true,\n });\n child.once(\"error\", () => resolve(null));\n child.once(\"close\", (code) => resolve(code));\n });\n}\n\nfunction reexecPhCli(args: string[], cwd: string): Promise<number> {\n const child = spawn(process.execPath, [process.argv[1], ...args], {\n cwd,\n stdio: \"inherit\",\n env: { ...process.env, [VETRA_GATEWAY_ENV]: \"1\" },\n windowsHide: true,\n });\n // Ctrl-C reaches the child from the terminal as well: wait while it stops.\n const ignore = () => {};\n const forward = (signal: NodeJS.Signals) => child.kill(signal);\n process.on(\"SIGINT\", ignore);\n process.on(\"SIGTERM\", forward);\n return new Promise<number>((resolve) => {\n const done = (code: number) => {\n process.off(\"SIGINT\", ignore);\n process.off(\"SIGTERM\", forward);\n resolve(code);\n };\n child.once(\"error\", () => done(1));\n child.once(\"exit\", (code) => done(code ?? 1));\n });\n}\n\n/** cli.ts's `ph vetra`: the command line to go on with, in the project root,\n * or the exit code of the ph-cli that ran it. */\nexport async function vetraGateway(\n rest: readonly string[],\n): Promise<{ args: string[] } | { exitCode: number }> {\n const result = await openVetraStudio(rest, {\n project: async () => {\n const { getPowerhouseProjectInfo } =\n await import(\"@powerhousedao/shared/clis\");\n return getPowerhouseProjectInfo(undefined, { silent: true });\n },\n phCliVersion: getVersion(),\n installedStudio,\n install: runInstall,\n reexec: reexecPhCli,\n env: process.env,\n log: (message) => console.log(message),\n warn: (message) => console.warn(yellow(message)),\n });\n if (\"args\" in result && path.resolve(result.projectRoot) !== process.cwd()) {\n // As ph-cmd runs ph-cli: in the project root, with relative paths still\n // meaning the caller's cwd.\n process.env[CALLER_CWD_ENV] ??= process.cwd();\n process.chdir(result.projectRoot);\n }\n return result;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAkBA,MAAa,uBAAuB;AACpC,MAAa,oBAAoB,GAAG,qBAAqB;;;AAIzD,MAAa,oBAAoB;;;AAWjC,SAAgB,qBACd,OACA,cACQ;CAER,MAAM,UAAU,MAAM,YAAY,KAAK;CAGvC,MAAM,aAAa,MAAM,WAAW,MAAM,IACtC,CAAC,gCAAgC,IACjC,CAAC;CACL,MAAM,WAAW,eAAe,OAAO,OAAO;EAC5C;EACA,GAAG,qBAAqB,GAAG;EAC3B,GAAG;CACL,CAAC;CACD,IAAI,CAAC,UACH,MAAM,IAAI,MACR,6DAA6D,MAAM,GACrE;CAEF,OAAO,CAAC,SAAS,SAAS,GAAG,SAAS,IAAI,CAAC,CAAC,KAAK,GAAG;AACtD;;;AAIA,SAAgB,iBAAiB,OAIZ;CACnB,MAAM,EAAE,WAAW,cAAc,mBAAmB;CACpD,MAAM,UAAU,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AI;EACd;EACA,MAAM,KAAK,eAAe,KAAK,CAAC,CAAC;EACjC,MAAM,KAAK,SAAS,SAAS,KAAK,QAAQ,CAAC,CAAC;CAC9C,CAAC;AACH;;;AAIA,eAAsB,aACpB,MACoD;CACpD,MAAM,SAAS,MAAM,gBAAgB,MAAM;EACzC,SAAS,YAAY;GACnB,MAAM,EAAE,6BACN,MAAM,OAAO;GACf,OAAO,yBAAyB,KAAA,GAAW,EAAE,QAAQ,KAAK,CAAC;EAC7D;EACA,cAAc,WAAW;EACzB;EACA,SAAS;EACT,QAAQ;EACR,KAAK,QAAQ;EACb,MAAM,YAAY,QAAQ,IAAI,OAAO;EACrC,OAAO,YAAY,QAAQ,KAAK,OAAO,OAAO,CAAC;CACjD,CAAC;CACD,IAAI,UAAU,UAAU,KAAK,QAAQ,OAAO,WAAW,MAAM,QAAQ,IAAI,GAAG;EAG1E,QAAQ,IAAI,oBAAoB,QAAQ,IAAI;EAC5C,QAAQ,MAAM,OAAO,WAAW;CAClC;CACA,OAAO;AACT","debug_id":"46e3ee35-2128-5e5e-a250-776548e23331"}
|
|
1
|
+
{"version":3,"file":"vetra-gateway-BHuz7pvS.mjs","sources":["../src/services/vetra-gateway.ts"],"sourcesContent":["import { resolvePackageRoot } from \"@powerhousedao/host-core\";\nimport { CALLER_CWD_ENV } from \"@powerhousedao/shared/clis/command-names\";\nimport { yellow } from \"colorette\";\nimport { spawn } from \"node:child_process\";\nimport { readFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport { resolveCommand, type Agent } from \"package-manager-detector\";\nimport { valid } from \"semver\";\nimport { getVersion } from \"../get-version.js\";\n\n/**\n * `ph vetra` is the gateway to Vetra Studio, the host `studio` that the\n * package @powerhousedao/vetra-cli supplies. ph-cli names the package and the\n * host and nothing else of it: `ph vetra [verb] [args]` is\n * `ph run @powerhousedao/vetra-cli/studio [verb] [args]`, once the project\n * has the package. A project without it gets it first, as a devDependency at\n * this ph-cli's version: the two are released with the same version numbers.\n */\nexport const VETRA_STUDIO_PACKAGE = \"@powerhousedao/vetra-cli\";\nexport const VETRA_STUDIO_HOST = `${VETRA_STUDIO_PACKAGE}/studio`;\n\n/** Set on the ph-cli started after an install: it finds the package, or\n * fails, and never installs it again. */\nexport const VETRA_GATEWAY_ENV = \"PH_VETRA_GATEWAY_INSTALLED\";\n\n/** The package as the project has it; undefined when it has none. */\nexport type InstalledStudio = { version: string | undefined } | undefined;\n\nexport type VetraGatewayPlan =\n | { action: \"run\"; warning?: string }\n | { action: \"install\"; notice: string; command: string };\n\n/** The command line that adds the package at ph-cli's version as a\n * devDependency, with the project's package manager. */\nexport function studioInstallCommand(\n agent: Agent,\n phCliVersion: string,\n): string {\n // A build that does not know its version takes the latest release.\n const version = valid(phCliVersion) ?? \"latest\";\n // As `ph install --local`: on a release day the packages are younger than\n // pnpm 11's minimumReleaseAge.\n const releaseAge = agent.startsWith(\"pnpm\")\n ? [\"--config.minimum-release-age=0\"]\n : [];\n const resolved = resolveCommand(agent, \"add\", [\n \"-D\",\n `${VETRA_STUDIO_PACKAGE}@${version}`,\n ...releaseAge,\n ]);\n if (!resolved) {\n throw new Error(\n `Could not resolve an install command for package manager \"${agent}\".`,\n );\n }\n return [resolved.command, ...resolved.args].join(\" \");\n}\n\n/** What `ph vetra` does in a project: install the package, or run its host,\n * warning when the installed version is not ph-cli's. */\nexport function planVetraGateway(facts: {\n installed: InstalledStudio;\n phCliVersion: string;\n packageManager: Agent;\n}): VetraGatewayPlan {\n const { installed, phCliVersion, packageManager } = facts;\n const command = studioInstallCommand(packageManager, phCliVersion);\n if (installed === undefined) {\n return {\n action: \"install\",\n notice:\n `Vetra Studio is the package ${VETRA_STUDIO_PACKAGE}, which this project does not have yet. ` +\n `Installing it as a devDependency with ${packageManager}:`,\n command,\n };\n }\n const { version } = installed;\n if (\n version !== undefined &&\n valid(phCliVersion) !== null &&\n version !== phCliVersion\n ) {\n return {\n action: \"run\",\n warning: `${VETRA_STUDIO_PACKAGE} ${version} is installed, but this ph-cli is ${phCliVersion}: align them with \\`${command}\\`.`,\n };\n }\n return { action: \"run\" };\n}\n\nexport interface VetraGatewayDeps {\n /** The project root, undefined outside a project, and its package manager. */\n project: () => Promise<{ projectPath?: string; packageManager: Agent }>;\n phCliVersion: string;\n installedStudio: (projectRoot: string) => InstalledStudio;\n /** Runs an install command line in `cwd`; resolves to its exit code. */\n install: (command: string, cwd: string) => Promise<number | null>;\n /** Runs this ph-cli with `args` in a new process; resolves to its exit code. */\n reexec: (args: string[], cwd: string) => Promise<number>;\n env: NodeJS.ProcessEnv;\n log: (message: string) => void;\n warn: (message: string) => void;\n}\n\nexport type VetraGatewayResult =\n /** Go on with this command line, in the project root. */\n | { args: string[]; projectRoot: string }\n /** A new ph-cli ran it, after the install. */\n | { exitCode: number };\n\n/**\n * `ph vetra [verb] [args]` (`rest`) in the project: the `ph run` command line\n * of the studio host when the package is there. Otherwise it installs the\n * package and runs that command line in a new ph-cli, since a package\n * installed while this one runs is not reliably resolved by it (Node caches\n * lookups, and the install may relink what it imports later).\n */\nexport async function openVetraStudio(\n rest: readonly string[],\n deps: VetraGatewayDeps,\n): Promise<VetraGatewayResult> {\n const { projectPath, packageManager } = await deps.project();\n if (projectPath === undefined) {\n throw new Error(\n \"No Powerhouse project found, so `ph vetra` cannot open Vetra Studio: it installs into and runs in a project. \" +\n \"Run it in one, or create one with `ph init`.\",\n );\n }\n const runArgs = [\"run\", VETRA_STUDIO_HOST, ...rest];\n const plan = planVetraGateway({\n installed: deps.installedStudio(projectPath),\n phCliVersion: deps.phCliVersion,\n packageManager,\n });\n if (plan.action === \"run\") {\n if (plan.warning) deps.warn(plan.warning);\n return { args: runArgs, projectRoot: projectPath };\n }\n // A stop reads the run record only: there is nothing to install for it.\n if (rest.includes(\"--stop\"))\n return { args: runArgs, projectRoot: projectPath };\n const manual = `Install it yourself, then run \\`ph vetra\\` again:\\n ${plan.command}`;\n if (deps.env[VETRA_GATEWAY_ENV]) {\n throw new Error(\n `${VETRA_STUDIO_PACKAGE} was installed, but this ph-cli does not find it from ${projectPath}. ${manual}`,\n );\n }\n deps.log(plan.notice);\n deps.log(`> ${plan.command}`);\n const code = await deps.install(plan.command, projectPath);\n if (code !== 0) {\n const how = code === null ? \"could not run\" : `exited with code ${code}`;\n throw new Error(\n `The install of ${VETRA_STUDIO_PACKAGE} ${how}, so Vetra Studio cannot start. ${manual}`,\n );\n }\n if (deps.installedStudio(projectPath) === undefined) {\n throw new Error(\n `The install passed, but ${VETRA_STUDIO_PACKAGE} does not resolve from ${projectPath}. ${manual}`,\n );\n }\n return { exitCode: await deps.reexec(runArgs, projectPath) };\n}\n\n/** The package's version as `ph run <package>/<host>` finds it: from the\n * project root, by its package.json, without importing it. */\nexport function installedStudio(projectRoot: string): InstalledStudio {\n const root = resolvePackageRoot(projectRoot, VETRA_STUDIO_PACKAGE);\n if (root === undefined) return undefined;\n try {\n const { version } = JSON.parse(\n readFileSync(path.join(root, \"package.json\"), \"utf8\"),\n ) as { version?: unknown };\n return { version: typeof version === \"string\" ? version : undefined };\n } catch {\n return { version: undefined };\n }\n}\n\nfunction runInstall(command: string, cwd: string): Promise<number | null> {\n return new Promise((resolve) => {\n // One command line, as printed: a shell runs the package manager's shim.\n const child = spawn(command, {\n cwd,\n stdio: \"inherit\",\n shell: true,\n windowsHide: true,\n });\n child.once(\"error\", () => resolve(null));\n child.once(\"close\", (code) => resolve(code));\n });\n}\n\nfunction reexecPhCli(args: string[], cwd: string): Promise<number> {\n const child = spawn(process.execPath, [process.argv[1], ...args], {\n cwd,\n stdio: \"inherit\",\n env: { ...process.env, [VETRA_GATEWAY_ENV]: \"1\" },\n windowsHide: true,\n });\n // Ctrl-C reaches the child from the terminal as well: wait while it stops.\n const ignore = () => {};\n const forward = (signal: NodeJS.Signals) => child.kill(signal);\n process.on(\"SIGINT\", ignore);\n process.on(\"SIGTERM\", forward);\n return new Promise<number>((resolve) => {\n const done = (code: number) => {\n process.off(\"SIGINT\", ignore);\n process.off(\"SIGTERM\", forward);\n resolve(code);\n };\n child.once(\"error\", () => done(1));\n child.once(\"exit\", (code) => done(code ?? 1));\n });\n}\n\n/** cli.ts's `ph vetra`: the command line to go on with, in the project root,\n * or the exit code of the ph-cli that ran it. */\nexport async function vetraGateway(\n rest: readonly string[],\n): Promise<{ args: string[] } | { exitCode: number }> {\n const result = await openVetraStudio(rest, {\n project: async () => {\n const { getPowerhouseProjectInfo } =\n await import(\"@powerhousedao/shared/clis\");\n return getPowerhouseProjectInfo(undefined, { silent: true });\n },\n phCliVersion: getVersion(),\n installedStudio,\n install: runInstall,\n reexec: reexecPhCli,\n env: process.env,\n log: (message) => console.log(message),\n warn: (message) => console.warn(yellow(message)),\n });\n if (\"args\" in result && path.resolve(result.projectRoot) !== process.cwd()) {\n // As ph-cmd runs ph-cli: in the project root, with relative paths still\n // meaning the caller's cwd.\n process.env[CALLER_CWD_ENV] ??= process.cwd();\n process.chdir(result.projectRoot);\n }\n return result;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;AAkBA,MAAa,uBAAuB;AACpC,MAAa,oBAAoB,GAAG,qBAAqB;;;AAIzD,MAAa,oBAAoB;;;AAWjC,SAAgB,qBACd,OACA,cACQ;CAER,MAAM,UAAU,MAAM,YAAY,KAAK;CAGvC,MAAM,aAAa,MAAM,WAAW,MAAM,IACtC,CAAC,gCAAgC,IACjC,CAAC;CACL,MAAM,WAAW,eAAe,OAAO,OAAO;EAC5C;EACA,GAAG,qBAAqB,GAAG;EAC3B,GAAG;CACL,CAAC;CACD,IAAI,CAAC,UACH,MAAM,IAAI,MACR,6DAA6D,MAAM,GACrE;CAEF,OAAO,CAAC,SAAS,SAAS,GAAG,SAAS,IAAI,CAAC,CAAC,KAAK,GAAG;AACtD;;;AAIA,SAAgB,iBAAiB,OAIZ;CACnB,MAAM,EAAE,WAAW,cAAc,mBAAmB;CACpD,MAAM,UAAU,qBAAqB,gBAAgB,YAAY;CACjE,IAAI,cAAc,KAAA,GAChB,OAAO;EACL,QAAQ;E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,SAAS,KAAK,QAAQ,CAAC,CAAC;CAC9C,CAAC;AACH;;;AAIA,eAAsB,aACpB,MACoD;CACpD,MAAM,SAAS,MAAM,gBAAgB,MAAM;EACzC,SAAS,YAAY;GACnB,MAAM,EAAE,6BACN,MAAM,OAAO;GACf,OAAO,yBAAyB,KAAA,GAAW,EAAE,QAAQ,KAAK,CAAC;EAC7D;EACA,cAAc,WAAW;EACzB;EACA,SAAS;EACT,QAAQ;EACR,KAAK,QAAQ;EACb,MAAM,YAAY,QAAQ,IAAI,OAAO;EACrC,OAAO,YAAY,QAAQ,KAAK,OAAO,OAAO,CAAC;CACjD,CAAC;CACD,IAAI,UAAU,UAAU,KAAK,QAAQ,OAAO,WAAW,MAAM,QAAQ,IAAI,GAAG;EAG1E,QAAQ,IAAI,oBAAoB,QAAQ,IAAI;EAC5C,QAAQ,MAAM,OAAO,WAAW;CAClC;CACA,OAAO;AACT","debug_id":"b7ed0ad1-a808-50fc-9cbc-4431643ae255"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { c as vetraGateway } from "./vetra-gateway-BHuz7pvS.mjs";
|
|
2
|
+
export { vetraGateway };
|
|
3
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="f734f1fd-bdbd-56f6-bc8e-267e364dce34")}catch(e){}}();
|
|
4
|
+
//# debugId=f734f1fd-bdbd-56f6-bc8e-267e364dce34
|
|
@@ -1,18 +1,35 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="7e86de88-1f95-568c-b75a-ab170ec68eb4")}catch(e){}}();
|
|
3
3
|
import { _ as unknown, d as object, r as array } from "./schemas-DzgKfQIx.mjs";
|
|
4
|
-
import { J as readProjectName, a as STORE_VERBS, r as ONE_SHOT_VERBS } from "./compound-
|
|
5
|
-
import {
|
|
4
|
+
import { J as readProjectName, a as STORE_VERBS, r as ONE_SHOT_VERBS } from "./compound-Q9sZSEZF-DQvtoigb.mjs";
|
|
5
|
+
import { a as syncMcpPortNotices, o as vetraRuntimeRecord, r as probeVetraRuntime, s as writeVetraRuntime, t as clearVetraRuntime } from "./vetra-runtime-Bk6CW-BE.mjs";
|
|
6
6
|
import { yellow } from "colorette";
|
|
7
7
|
import { outputsSchema } from "@powerhousedao/ph-run/runners/connect";
|
|
8
8
|
import { outputsSchema as outputsSchema$1 } from "@powerhousedao/ph-run/runners/switchboard";
|
|
9
9
|
import { startRun } from "@powerhousedao/ph-run/start-run";
|
|
10
|
+
//#region src/utils/vetra-instance.ts
|
|
11
|
+
/**
|
|
12
|
+
* One dev stack per project. `ph run dev` (hosts/vetra in a project that has
|
|
13
|
+
* only that one) records its stack in `.ph/run/<host>.json` and, once ready,
|
|
14
|
+
* in `.ph/vetra-runtime.json`, which is what a start asks here: whether a
|
|
15
|
+
* stack already holds the project.
|
|
16
|
+
*/
|
|
17
|
+
/** Why the dev host must not start: a live one holds the project. */
|
|
18
|
+
async function vetraRuntimeRefusal(projectDir, projectName) {
|
|
19
|
+
const probe = await probeVetraRuntime(projectDir, projectName);
|
|
20
|
+
if (probe.status === "live" || probe.status === "starting") {
|
|
21
|
+
if (probe.record.pid === process.pid) return void 0;
|
|
22
|
+
return `Vetra is already running for this project (pid ${probe.record.pid}). Stop it before starting another.`;
|
|
23
|
+
}
|
|
24
|
+
if (probe.status === "foreign") return `.ph/vetra-runtime.json describes a live Vetra for "${probe.record.projectName}", but this project is "${projectName}". Refusing to start a second instance. Delete .ph/vetra-runtime.json if that record is wrong.`;
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
10
27
|
//#region src/services/run/vetra-host.ts
|
|
11
28
|
/**
|
|
12
|
-
* `ph run
|
|
13
|
-
* switchboard and a connect member, so
|
|
14
|
-
*
|
|
15
|
-
* startRun: refuse while another
|
|
29
|
+
* `ph run dev` (and `ph run vetra` in a project with that host): the dev host
|
|
30
|
+
* is the generic compound runner over a switchboard and a connect member, so
|
|
31
|
+
* nothing below `ph run` knows it is the dev stack. What makes the stack the
|
|
32
|
+
* project's own is done here around startRun: refuse while another one holds
|
|
16
33
|
* the project, publish `.ph/vetra-runtime.json` once the stack is ready,
|
|
17
34
|
* clear it on exit, and correct a drifted `.mcp.json`. `--restart` is its own
|
|
18
35
|
* argument, not a runner's: it stops the recorded Vetra first.
|
|
@@ -24,7 +41,7 @@ async function runVetraHost(args) {
|
|
|
24
41
|
const projectName = readProjectName(projectDir);
|
|
25
42
|
const restart = args.argv?.includes(RESTART_FLAG) ?? false;
|
|
26
43
|
if (restart) {
|
|
27
|
-
const { stopVetra } = await import("./vetra-launcher-
|
|
44
|
+
const { stopVetra } = await import("./vetra-launcher-BUO9e74r.mjs");
|
|
28
45
|
await stopVetra({
|
|
29
46
|
projectDir,
|
|
30
47
|
projectName,
|
|
@@ -40,7 +57,7 @@ async function runVetraHost(args) {
|
|
|
40
57
|
publishVetraRuntime(projectDir, projectName, result);
|
|
41
58
|
return result;
|
|
42
59
|
}
|
|
43
|
-
/** `ph run
|
|
60
|
+
/** `ph run dev --restart`, which `ph dev --restart` is sugar for. */
|
|
44
61
|
const RESTART_FLAG = "--restart";
|
|
45
62
|
const startedSchema = object({ started: array(object({ outputs: unknown() })) });
|
|
46
63
|
const portOf = (url) => Number(new URL(url).port);
|
|
@@ -90,5 +107,5 @@ function publishVetraRuntime(projectDir, projectName, result) {
|
|
|
90
107
|
//#endregion
|
|
91
108
|
export { runVetraHost };
|
|
92
109
|
|
|
93
|
-
//# sourceMappingURL=vetra-host-
|
|
94
|
-
//# debugId=
|
|
110
|
+
//# sourceMappingURL=vetra-host-CYdbd3J3.mjs.map
|
|
111
|
+
//# debugId=7e86de88-1f95-568c-b75a-ab170ec68eb4
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vetra-host-CYdbd3J3.mjs","sources":["../src/utils/vetra-instance.ts","../src/services/run/vetra-host.ts"],"sourcesContent":["import { probeVetraRuntime } from \"./vetra-runtime.js\";\n\n/**\n * One dev stack per project. `ph run dev` (hosts/vetra in a project that has\n * only that one) records its stack in `.ph/run/<host>.json` and, once ready,\n * in `.ph/vetra-runtime.json`, which is what a start asks here: whether a\n * stack already holds the project.\n */\n\n/** Why the dev host must not start: a live one holds the project. */\nexport async function vetraRuntimeRefusal(\n projectDir: string,\n projectName: string,\n): Promise<string | undefined> {\n const probe = await probeVetraRuntime(projectDir, projectName);\n if (probe.status === \"live\" || probe.status === \"starting\") {\n if (probe.record.pid === process.pid) return undefined;\n return `Vetra is already running for this project (pid ${probe.record.pid}). Stop it before starting another.`;\n }\n if (probe.status === \"foreign\") {\n return (\n `.ph/vetra-runtime.json describes a live Vetra for \"${probe.record.projectName}\", ` +\n `but this project is \"${projectName}\". Refusing to start a second instance. ` +\n `Delete .ph/vetra-runtime.json if that record is wrong.`\n );\n }\n return undefined;\n}\n","import {\n ONE_SHOT_VERBS,\n readProjectName,\n STORE_VERBS,\n} from \"@powerhousedao/host-core\";\nimport { outputsSchema as connectOutputsSchema } from \"@powerhousedao/ph-run/runners/connect\";\nimport { outputsSchema as switchboardOutputsSchema } from \"@powerhousedao/ph-run/runners/switchboard\";\nimport { startRun, type StartRunArgs } from \"@powerhousedao/ph-run/start-run\";\nimport { yellow } from \"colorette\";\nimport { z } from \"zod\";\nimport { vetraRuntimeRefusal } from \"../../utils/vetra-instance.js\";\nimport {\n clearVetraRuntime,\n syncMcpPortNotices,\n vetraRuntimeRecord,\n writeVetraRuntime,\n type VetraRuntimeRecord,\n} from \"../../utils/vetra-runtime.js\";\n\n/**\n * `ph run dev` (and `ph run vetra` in a project with that host): the dev host\n * is the generic compound runner over a switchboard and a connect member, so\n * nothing below `ph run` knows it is the dev stack. What makes the stack the\n * project's own is done here around startRun: refuse while another one holds\n * the project, publish `.ph/vetra-runtime.json` once the stack is ready,\n * clear it on exit, and correct a drifted `.mcp.json`. `--restart` is its own\n * argument, not a runner's: it stops the recorded Vetra first.\n */\nexport async function runVetraHost(args: StartRunArgs): Promise<unknown> {\n const verb = args.verb ?? \"run\";\n // `build` starts nothing; a store verb is refused for a compound.\n if (ONE_SHOT_VERBS.has(verb) || STORE_VERBS.has(verb)) {\n return startRun(args);\n }\n const projectDir = args.projectRoot ?? process.cwd();\n const projectName = readProjectName(projectDir);\n const restart = args.argv?.includes(RESTART_FLAG) ?? false;\n if (restart) {\n const { stopVetra } = await import(\"../../utils/vetra-launcher.js\");\n await stopVetra({\n projectDir,\n projectName,\n onProgress: (message) => console.log(message),\n });\n }\n const refusal = await vetraRuntimeRefusal(projectDir, projectName);\n if (refusal) throw new Error(refusal);\n\n const result = await startRun(\n restart\n ? { ...args, argv: args.argv?.filter((arg) => arg !== RESTART_FLAG) }\n : args,\n );\n publishVetraRuntime(projectDir, projectName, result);\n return result;\n}\n\n/** `ph run dev --restart`, which `ph dev --restart` is sugar for. */\nconst RESTART_FLAG = \"--restart\";\n\nconst startedSchema = z.object({\n started: z.array(z.object({ outputs: z.unknown() })),\n});\n\nconst portOf = (url: string) => Number(new URL(url).port);\n\nfunction firstMatch<T>(\n schema: z.ZodType<T>,\n candidates: unknown[],\n): T | undefined {\n for (const candidate of candidates) {\n const match = schema.safeParse(candidate);\n if (match.success) return match.data;\n }\n return undefined;\n}\n\n/**\n * The record of a ready compound: its members are told apart by the outputs\n * their runners publish, since a host file is free to name them.\n */\nexport function vetraRecordOfRun(\n projectName: string,\n result: unknown,\n): VetraRuntimeRecord | undefined {\n const parsed = startedSchema.safeParse(result);\n const outputs = parsed.success\n ? parsed.data.started.map((member) => member.outputs)\n : [];\n const switchboard = firstMatch(switchboardOutputsSchema, outputs);\n if (!switchboard) return undefined;\n const connect = firstMatch(connectOutputsSchema, outputs);\n return vetraRuntimeRecord({\n projectName,\n switchboardPort: portOf(switchboard.origin),\n // Vite may have taken another port, and the base path is Connect's.\n connectPort: connect ? portOf(connect.origin) : 0,\n switchboardUrl: switchboard.endpoints.graphql,\n mcpUrl: switchboard.endpoints.mcp,\n connectUrl: connect?.endpoints.connect,\n });\n}\n\n/**\n * Publishes the record of the stack startRun returned and syncs the MCP\n * configs to its port. Returns what clears the record again; it also runs on\n * exit. No SIGINT/SIGTERM handler: the compound owns the exit, and its\n * process.exit reaches the exit event.\n */\nexport function publishVetraRuntime(\n projectDir: string,\n projectName: string,\n result: unknown,\n): () => void {\n const record = vetraRecordOfRun(projectName, result);\n if (!record) {\n console.warn(\n yellow(\n \"No switchboard member is running, so .ph/vetra-runtime.json is not written and `ph mcp` will not find this stack.\",\n ),\n );\n return () => {};\n }\n // Record what the stack actually bound, so a second Vetra can tell a live\n // instance from a stale file, and so an agent can see the real ports.\n writeVetraRuntime(projectDir, record);\n // A restarted Vetra may already have written its own.\n const release = () => clearVetraRuntime(projectDir, process.pid);\n process.on(\"exit\", release);\n\n for (const notice of syncMcpPortNotices(projectDir, record.switchboardPort)) {\n console.log(yellow(notice));\n }\n return release;\n}\n"],"names":["z.object","z.array","z.unknown","switchboardOutputsSchema","connectOutputsSchema"],"mappings":";;;;;;;;;;;;;;;;;AAUA,eAAsB,oBACpB,YACA,aAC6B;CAC7B,MAAM,QAAQ,MAAM,kBAAkB,YAAY,WAAW;CAC7D,IAAI,MAAM,WAAW,UAAU,MAAM,WAAW,YAAY;EAC1D,IAAI,MAAM,OAAO,QAAQ,QAAQ,KAAK,OAAO,KAAA;EAC7C,OAAO,kDAAkD,MAAM,OAAO,IAAI;CAC5E;CACA,IA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cAAc,WAAWC,iBAA0B,OAAO;CAChE,IAAI,CAAC,aAAa,OAAO,KAAA;CACzB,MAAM,UAAU,WAAWC,eAAsB,OAAO;CACxD,OAAO,mBAAmB;EACxB;EACA,iBAAiB,OAAO,YAAY,MAAM;EAE1C,aAAa,UAAU,OAAO,QAAQ,MAAM,IAAI;EAChD,gBAAgB,YAAY,UAAU;EACtC,QAAQ,YAAY,UAAU;EAC9B,YAAY,SAAS,UAAU;CACjC,CAAC;AACH;;;;;;;AAQA,SAAgB,oBACd,YACA,aACA,QACY;CACZ,MAAM,SAAS,iBAAiB,aAAa,MAAM;CACnD,IAAI,CAAC,QAAQ;EACX,QAAQ,KACN,OACE,mHACF,CACF;EACA,aAAa,CAAC;CAChB;CAGA,kBAAkB,YAAY,MAAM;CAEpC,MAAM,gBAAgB,kBAAkB,YAAY,QAAQ,GAAG;CAC/D,QAAQ,GAAG,QAAQ,OAAO;CAE1B,KAAK,MAAM,UAAU,mBAAmB,YAAY,OAAO,eAAe,GACxE,QAAQ,IAAI,OAAO,MAAM,CAAC;CAE5B,OAAO;AACT","debug_id":"7e86de88-1f95-568c-b75a-ab170ec68eb4"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
3
|
-
import { X as requestStop } from "./compound-
|
|
4
|
-
import {
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="a660c9f3-f25c-525d-96ae-8c85ff483998")}catch(e){}}();
|
|
3
|
+
import { X as requestStop } from "./compound-Q9sZSEZF-DQvtoigb.mjs";
|
|
4
|
+
import { t as devHostOf } from "./dev-host-RhWeATKB.mjs";
|
|
5
|
+
import { n as isPortInUse, r as probeVetraRuntime, t as clearVetraRuntime } from "./vetra-runtime-Bk6CW-BE.mjs";
|
|
5
6
|
import fs from "node:fs";
|
|
6
7
|
import path from "node:path";
|
|
7
8
|
import { spawn } from "node:child_process";
|
|
@@ -16,20 +17,22 @@ const lockPath = (projectDir) => path.join(resolvePhDir(projectDir), "vetra-star
|
|
|
16
17
|
const vetraLogPath = (projectDir) => path.join(resolvePhDir(projectDir), "vetra.log");
|
|
17
18
|
const shownLogPath = (projectDir) => path.relative(projectDir, vetraLogPath(projectDir)).split(path.sep).join("/");
|
|
18
19
|
/**
|
|
19
|
-
* What starts a project's
|
|
20
|
-
*
|
|
21
|
-
*
|
|
20
|
+
* What starts a project's dev stack: `ph run dev --strictPort` (hosts/vetra
|
|
21
|
+
* in a project that has only that one), run by the ph-cli executing this
|
|
22
|
+
* code. The host's own defaultVerb picks the verb. In a project without the
|
|
23
|
+
* host it fails, and its output says why.
|
|
22
24
|
*/
|
|
23
|
-
function currentPhCliRunVetraCommand() {
|
|
25
|
+
function currentPhCliRunVetraCommand(projectDir) {
|
|
26
|
+
const host = devHostOf(projectDir);
|
|
24
27
|
return {
|
|
25
28
|
command: process.execPath,
|
|
26
29
|
args: [
|
|
27
30
|
process.argv[1],
|
|
28
31
|
"run",
|
|
29
|
-
|
|
32
|
+
host,
|
|
30
33
|
"--strictPort"
|
|
31
34
|
],
|
|
32
|
-
label: `ph run ${
|
|
35
|
+
label: `ph run ${host}`
|
|
33
36
|
};
|
|
34
37
|
}
|
|
35
38
|
function isPidAlive(pid) {
|
|
@@ -101,7 +104,7 @@ async function waitForLive(options, deadline, stillStarting) {
|
|
|
101
104
|
await sleep(pollMs);
|
|
102
105
|
}
|
|
103
106
|
}
|
|
104
|
-
/** This project's live
|
|
107
|
+
/** This project's live dev stack, or a detached `ph run dev` started and awaited; never a second reactor. */
|
|
105
108
|
async function ensureVetra(options) {
|
|
106
109
|
const { projectDir, projectName, switchboardPort, timeoutMs } = options;
|
|
107
110
|
const deadline = Date.now() + timeoutMs;
|
|
@@ -164,7 +167,7 @@ async function ensureVetra(options) {
|
|
|
164
167
|
if (spawnError) throw new VetraStartError(`Could not run \`${options.command.command}\`: ${spawnError.message}`);
|
|
165
168
|
if (exit) {
|
|
166
169
|
const how = exit.signal !== null ? `was killed by ${exit.signal}` : `exited with code ${exit.code}`;
|
|
167
|
-
throw withOutput(`\`${options.command.label ?? `ph run
|
|
170
|
+
throw withOutput(`\`${options.command.label ?? `ph run ${devHostOf(projectDir)}`}\` ${how} before it was ready.`, projectDir);
|
|
168
171
|
}
|
|
169
172
|
keepLock = true;
|
|
170
173
|
throw withOutput(`Vetra (pid ${child.pid}) did not answer /ready on port ${switchboardPort} within ${seconds}s. It is still running; the next tool call waits for it again.`, projectDir);
|
|
@@ -215,5 +218,5 @@ async function restartVetra(options) {
|
|
|
215
218
|
//#endregion
|
|
216
219
|
export { restartVetra as a, readLogTail as i, currentPhCliRunVetraCommand as n, stopVetra as o, ensureVetra as r, vetraLogPath as s, VetraStartError as t };
|
|
217
220
|
|
|
218
|
-
//# sourceMappingURL=vetra-launcher-
|
|
219
|
-
//# debugId=
|
|
221
|
+
//# sourceMappingURL=vetra-launcher-B5L3yXPo.mjs.map
|
|
222
|
+
//# debugId=a660c9f3-f25c-525d-96ae-8c85ff483998
|