@powerhousedao/ph-cli 6.4.0-next.3 → 6.4.0-next.6
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/dist/auth-5bqHASGL.mjs +4 -0
- package/dist/auth-DYknkWfW.mjs +23 -0
- package/dist/auth-DYknkWfW.mjs.map +1 -0
- package/dist/{build-B-rPwjM8.mjs → build-CGnPJwut.mjs} +8 -8
- package/dist/{build-B-rPwjM8.mjs.map → build-CGnPJwut.mjs.map} +1 -1
- package/dist/build-mTLB2w-Q.mjs +4 -0
- package/dist/{check-B7C3Vi_b.mjs → check-CW81vbe9.mjs} +4 -4
- package/dist/{check-B7C3Vi_b.mjs.map → check-CW81vbe9.mjs.map} +1 -1
- package/dist/{check-DeUTd514.mjs → check-Ch1obo1o.mjs} +3 -3
- package/dist/{check-DM7UdFTK.mjs → check-DQnWxQCS.mjs} +7 -7
- package/dist/check-DQnWxQCS.mjs.map +1 -0
- package/dist/{cli-connect-override-Bx_g3-ZE.mjs → cli-connect-override-DKxY3lCi.mjs} +4 -4
- package/dist/{cli-connect-override-Bx_g3-ZE.mjs.map → cli-connect-override-DKxY3lCi.mjs.map} +1 -1
- package/dist/cli.mjs +9 -8
- package/dist/cli.mjs.map +1 -1
- package/dist/{compound-Q9sZSEZF-DQvtoigb.mjs → compound-g6x_KkWp-Bs7olmlI.mjs} +465 -361
- package/dist/compound-g6x_KkWp-Bs7olmlI.mjs.map +1 -0
- package/dist/{connect-build-CaTxdYcc.mjs → connect-build-CQgSyKm1.mjs} +8 -10
- package/dist/connect-build-CQgSyKm1.mjs.map +1 -0
- package/dist/{connect-config-A-U83U8U.mjs → connect-config-BpzwJln3.mjs} +4 -4
- package/dist/{connect-config-A-U83U8U.mjs.map → connect-config-BpzwJln3.mjs.map} +1 -1
- package/dist/{connect-preview-BvxXGo_W.mjs → connect-preview-B_E4SIV6.mjs} +21 -4
- package/dist/connect-preview-B_E4SIV6.mjs.map +1 -0
- package/dist/connect-studio-SH4U0Cpm.mjs +214 -0
- package/dist/connect-studio-SH4U0Cpm.mjs.map +1 -0
- package/dist/credentials-CmtYywgk.mjs +132 -0
- package/dist/credentials-CmtYywgk.mjs.map +1 -0
- package/dist/definitions-worker.mjs +4 -4
- package/dist/definitions-worker.mjs.map +1 -1
- package/dist/{dev-host-RhWeATKB.mjs → dev-host-CM-Jg2kY.mjs} +4 -4
- package/dist/{dev-host-RhWeATKB.mjs.map → dev-host-CM-Jg2kY.mjs.map} +1 -1
- package/dist/{dist-D_UjZsgt.mjs → dist-DPj_FB8H.mjs} +5 -5
- package/dist/dist-DPj_FB8H.mjs.map +1 -0
- package/dist/{explain-DbbHpa61.mjs → explain-DQ5ymlco.mjs} +5 -5
- package/dist/{explain-DbbHpa61.mjs.map → explain-DQ5ymlco.mjs.map} +1 -1
- package/dist/{export-FduYVQEM.mjs → export-CzeF8pob.mjs} +4 -4
- package/dist/{export-FduYVQEM.mjs.map → export-CzeF8pob.mjs.map} +1 -1
- package/dist/{files-DEHg350R.mjs → files-D6_euBBn.mjs} +4 -4
- package/dist/{files-DEHg350R.mjs.map → files-D6_euBBn.mjs.map} +1 -1
- package/dist/{generate-all-BE8UmbJv.mjs → generate-all-B9MwWXlq.mjs} +4 -4
- package/dist/{generate-all-BE8UmbJv.mjs.map → generate-all-B9MwWXlq.mjs.map} +1 -1
- package/dist/{generate-document-model-DSYPTMZg.mjs → generate-document-model-D3LKY1D7.mjs} +6 -8
- package/dist/generate-document-model-D3LKY1D7.mjs.map +1 -0
- package/dist/{generate-subgraph-EQ2ZjMp9.mjs → generate-subgraph-Q1VLh3SC.mjs} +10 -17
- package/dist/generate-subgraph-Q1VLh3SC.mjs.map +1 -0
- package/dist/{get-version-7oKMD8Gt.mjs → get-version-Cz5WJkpH.mjs} +4 -4
- package/dist/{get-version-7oKMD8Gt.mjs.map → get-version-Cz5WJkpH.mjs.map} +1 -1
- package/dist/identity-DXZFeQfC.mjs +137 -0
- package/dist/identity-DXZFeQfC.mjs.map +1 -0
- package/dist/{index-Bs1PfL3W.d.mts → index-aosqo7aM.d.mts} +5 -4
- package/dist/index-aosqo7aM.d.mts.map +1 -0
- package/dist/{inspect-CulIpVsF.mjs → inspect-BgKI8Fhd.mjs} +6 -6
- package/dist/{inspect-CulIpVsF.mjs.map → inspect-BgKI8Fhd.mjs.map} +1 -1
- package/dist/{keyframes-bFo9iDhT.mjs → keyframes-BkeORfEu.mjs} +4 -4
- package/dist/{keyframes-bFo9iDhT.mjs.map → keyframes-BkeORfEu.mjs.map} +1 -1
- package/dist/{mcp-CcZT9zT9.mjs → mcp-Cx2HhCsK.mjs} +149 -7
- package/dist/mcp-Cx2HhCsK.mjs.map +1 -0
- package/dist/{migrate-Ddr7YAtM.mjs → migrate-BzPAS4zM.mjs} +4 -4
- package/dist/{migrate-Ddr7YAtM.mjs.map → migrate-BzPAS4zM.mjs.map} +1 -1
- package/dist/{migrate-document-models-X_mVTljj.mjs → migrate-document-models-BcrQKkDB.mjs} +5 -6
- package/dist/migrate-document-models-BcrQKkDB.mjs.map +1 -0
- package/dist/migrate-subgraphs-ChQdt6w7.mjs +4 -0
- package/dist/{migrate-subgraphs-Ffwwm7Oy.mjs → migrate-subgraphs-Dw5UFCQ3.mjs} +6 -7
- package/dist/migrate-subgraphs-Dw5UFCQ3.mjs.map +1 -0
- package/dist/ph-cli-commands-BcDloXsM.mjs +4 -0
- package/dist/{ph-cli-commands-D4Z6YSwd.mjs → ph-cli-commands-CGR5p3vg.mjs} +161 -107
- package/dist/ph-cli-commands-CGR5p3vg.mjs.map +1 -0
- package/dist/{registry-auth-Bm5AR-fB.mjs → registry-auth-C8D5cno2.mjs} +4 -4
- package/dist/{registry-auth-Bm5AR-fB.mjs.map → registry-auth-C8D5cno2.mjs.map} +1 -1
- package/dist/render-BQE20Cnd.mjs +4 -0
- package/dist/{render-SVfj3m8A.mjs → render-CQdi685k.mjs} +6 -6
- package/dist/render-CQdi685k.mjs.map +1 -0
- package/dist/{run-LRGy7zGo.mjs → run-C6Vha5VN.mjs} +3 -3
- package/dist/{run--de_-WAz.mjs → run-sVzTTEUx.mjs} +5 -36
- package/dist/run-sVzTTEUx.mjs.map +1 -0
- package/dist/{run-sugar-CkuGJuPg.mjs → run-sugar-BuxOaRzE.mjs} +5 -5
- package/dist/{run-sugar-CkuGJuPg.mjs.map → run-sugar-BuxOaRzE.mjs.map} +1 -1
- package/dist/{run-sugar-Dd_Mu058.mjs → run-sugar-Dz-rpeMO.mjs} +3 -3
- package/dist/runners/connect.d.mts +20 -3
- package/dist/runners/connect.d.mts.map +1 -1
- package/dist/runners/connect.mjs +37 -15
- package/dist/runners/connect.mjs.map +1 -1
- package/dist/runners/switchboard.d.mts +1 -1
- package/dist/runners/switchboard.mjs +3 -3
- package/dist/scripts/generate-commands-docs.ts +12 -0
- package/dist/{subgraphs-7OYWwP-C.mjs → subgraphs-Bm9NHTCn.mjs} +5 -38
- package/dist/subgraphs-Bm9NHTCn.mjs.map +1 -0
- package/dist/{sugar-checks-CAtgUIem.mjs → sugar-checks-DL-J3l2y.mjs} +6 -6
- package/dist/{sugar-checks-CAtgUIem.mjs.map → sugar-checks-DL-J3l2y.mjs.map} +1 -1
- package/dist/{verify-DXrs0JUp.mjs → verify-B3CKpYI8.mjs} +5 -5
- package/dist/{verify-DXrs0JUp.mjs.map → verify-B3CKpYI8.mjs.map} +1 -1
- package/dist/{vetra-gateway-BHuz7pvS.mjs → vetra-gateway-BZJEJiGT.mjs} +5 -5
- package/dist/{vetra-gateway-BHuz7pvS.mjs.map → vetra-gateway-BZJEJiGT.mjs.map} +1 -1
- package/dist/vetra-gateway-CeWIXaAl.mjs +4 -0
- package/dist/vetra-host-0rSW35_r.mjs +230 -0
- package/dist/vetra-host-0rSW35_r.mjs.map +1 -0
- package/dist/{vetra-launcher-B5L3yXPo.mjs → vetra-launcher-6NKfi6Au.mjs} +45 -5
- package/dist/vetra-launcher-6NKfi6Au.mjs.map +1 -0
- package/dist/vetra-launcher-XMk_Hv0c.mjs +4 -0
- package/package.json +17 -15
- package/dist/auth-BFUq7CvE.mjs +0 -18
- package/dist/auth-BFUq7CvE.mjs.map +0 -1
- package/dist/auth-CNhbN5UM.mjs +0 -4
- package/dist/build-DuwAPWMY.mjs +0 -4
- package/dist/check-DM7UdFTK.mjs.map +0 -1
- package/dist/compound-Q9sZSEZF-DQvtoigb.mjs.map +0 -1
- package/dist/connect-build-CaTxdYcc.mjs.map +0 -1
- package/dist/connect-preview-BvxXGo_W.mjs.map +0 -1
- package/dist/connect-studio-B2gugCJU.mjs +0 -106
- package/dist/connect-studio-B2gugCJU.mjs.map +0 -1
- package/dist/dist-D_UjZsgt.mjs.map +0 -1
- package/dist/generate-document-model-DSYPTMZg.mjs.map +0 -1
- package/dist/generate-subgraph-EQ2ZjMp9.mjs.map +0 -1
- package/dist/index-Bs1PfL3W.d.mts.map +0 -1
- package/dist/mcp-CcZT9zT9.mjs.map +0 -1
- package/dist/migrate-document-models-X_mVTljj.mjs.map +0 -1
- package/dist/migrate-subgraphs-DEqWkLoh.mjs +0 -4
- package/dist/migrate-subgraphs-Ffwwm7Oy.mjs.map +0 -1
- package/dist/ph-cli-commands-D4Z6YSwd.mjs.map +0 -1
- package/dist/ph-cli-commands-p9cO6MsE.mjs +0 -4
- package/dist/render-3M3DwFzO.mjs +0 -4
- package/dist/render-SVfj3m8A.mjs.map +0 -1
- package/dist/run--de_-WAz.mjs.map +0 -1
- package/dist/subgraphs-7OYWwP-C.mjs.map +0 -1
- package/dist/vetra-gateway-ag33E_Ta.mjs +0 -4
- package/dist/vetra-host-CYdbd3J3.mjs +0 -111
- package/dist/vetra-host-CYdbd3J3.mjs.map +0 -1
- package/dist/vetra-launcher-B5L3yXPo.mjs.map +0 -1
- package/dist/vetra-launcher-BUO9e74r.mjs +0 -4
package/dist/runners/connect.mjs
CHANGED
|
@@ -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]="
|
|
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]="90cd1745-a114-5191-91dc-77d8e2c32099")}catch(e){}}();
|
|
3
3
|
import { join } from "node:path";
|
|
4
|
-
import { callerOverride, connectBuildInvocationArgs, connectHandle, connectInvocationArgs, serve as serve$1, serveWith, servesDefaultComposition, startUnderSupervisor, validateComposition, withDefaultComposition } from "@powerhousedao/ph-run/runners/connect";
|
|
4
|
+
import { callerOverride, connectBuildInvocationArgs, connectHandle, connectInvocationArgs, localSignInPlan, serve as serve$1, serveWith, servesDefaultComposition, startUnderSupervisor, validateComposition, withDefaultComposition } from "@powerhousedao/ph-run/runners/connect";
|
|
5
5
|
import { getConfig } from "@powerhousedao/shared/clis";
|
|
6
6
|
import { deepMerge } from "@powerhousedao/shared/connect";
|
|
7
7
|
export * from "@powerhousedao/ph-run/runners/connect";
|
|
@@ -12,10 +12,16 @@ const verbs = [
|
|
|
12
12
|
"build",
|
|
13
13
|
"serve"
|
|
14
14
|
];
|
|
15
|
+
/** The issuer of sign-in by link (F3d): the person's own identity, loaded at
|
|
16
|
+
* the first page that signs in. */
|
|
17
|
+
const issuers = async (o) => {
|
|
18
|
+
const { createLocalSignInIssuer } = await import("@renown/sdk/local-sign-in");
|
|
19
|
+
return createLocalSignInIssuer(o);
|
|
20
|
+
};
|
|
15
21
|
/** The Connect studio arguments, with the keys this host and
|
|
16
22
|
* this invocation own laid over them. An argument of this invocation
|
|
17
23
|
* (`passed`) wins over the host file. */
|
|
18
|
-
async function toStudioArgs(host, passed) {
|
|
24
|
+
async function toStudioArgs(host, passed, signsIn) {
|
|
19
25
|
const { connectStudioServiceArgs } = await import("../service-args-D6y3L0bm.mjs");
|
|
20
26
|
const classic = await connectStudioServiceArgs();
|
|
21
27
|
const runner = host.runner;
|
|
@@ -23,17 +29,24 @@ async function toStudioArgs(host, passed) {
|
|
|
23
29
|
...classic,
|
|
24
30
|
port: passed.port ?? runner.port ?? classic.port,
|
|
25
31
|
host: passed.host ?? runner.host ?? classic.host,
|
|
26
|
-
open: passed.open ?? runner.openBrowser === true,
|
|
32
|
+
open: !signsIn && (passed.open ?? runner.openBrowser === true),
|
|
27
33
|
strictPort: passed.strictPort ?? runner.strictPort === true,
|
|
28
34
|
cors: passed.cors ?? classic.cors,
|
|
29
35
|
bindCLIShortcuts: false
|
|
30
36
|
};
|
|
31
37
|
}
|
|
32
38
|
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
|
-
async function
|
|
39
|
+
async function startStudio(host, ctx, { devServer }) {
|
|
34
40
|
await validateComposition(host, ctx);
|
|
35
|
-
const { runConnectStudio } = await import("../connect-studio-
|
|
36
|
-
const
|
|
41
|
+
const { runConnectStudio } = await import("../connect-studio-SH4U0Cpm.mjs");
|
|
42
|
+
const passed = await connectInvocationArgs(host, ctx);
|
|
43
|
+
const askedOpen = passed.open ?? host.runner.openBrowser;
|
|
44
|
+
const signIn = localSignInPlan(host, ctx, {
|
|
45
|
+
byDefault: true,
|
|
46
|
+
...askedOpen === void 0 ? {} : { open: askedOpen },
|
|
47
|
+
issuers
|
|
48
|
+
});
|
|
49
|
+
const args = await toStudioArgs(host, passed, signIn !== void 0);
|
|
37
50
|
const studio = {};
|
|
38
51
|
let override = callerOverride(host, ctx, ctx.verb);
|
|
39
52
|
const { reloadHost } = ctx;
|
|
@@ -51,7 +64,12 @@ async function dev(host, ctx) {
|
|
|
51
64
|
restartWith: (start) => startUnderSupervisor(ctx, start),
|
|
52
65
|
exposeStop: (stop) => {
|
|
53
66
|
studio.stop = stop;
|
|
54
|
-
}
|
|
67
|
+
},
|
|
68
|
+
...signIn ? { localSignIn: signIn.endpoint } : {},
|
|
69
|
+
...devServer && { devPlugins: {
|
|
70
|
+
entries: host.runner.devPlugins ?? [],
|
|
71
|
+
where: `hosts/${host.name}/host.js`
|
|
72
|
+
} }
|
|
55
73
|
}));
|
|
56
74
|
const current = {
|
|
57
75
|
resolvedUrls: server.resolvedUrls,
|
|
@@ -60,15 +78,17 @@ async function dev(host, ctx) {
|
|
|
60
78
|
return connectHandle(current, {
|
|
61
79
|
host: "localhost",
|
|
62
80
|
port: args.port
|
|
63
|
-
});
|
|
81
|
+
}, signIn);
|
|
64
82
|
}
|
|
83
|
+
/** Studio as a dev server, with the host's dev-server plugins. */
|
|
84
|
+
const dev = (host, ctx) => startStudio(host, ctx, { devServer: true });
|
|
65
85
|
/** `run` is dev-studio until the plugin phases give hosts a production
|
|
66
86
|
* runtime; `serve` (below) is the static production server. */
|
|
67
|
-
const run =
|
|
87
|
+
const run = (host, ctx) => startStudio(host, ctx, { devServer: false });
|
|
68
88
|
/** `build`: the Connect build service (`ph connect build` is sugar for it). */
|
|
69
89
|
async function build(host, ctx) {
|
|
70
90
|
await validateComposition(host, ctx);
|
|
71
|
-
const { runConnectBuild } = await import("../connect-build-
|
|
91
|
+
const { runConnectBuild } = await import("../connect-build-CQgSyKm1.mjs");
|
|
72
92
|
const { connectBuildServiceArgs } = await import("../service-args-D6y3L0bm.mjs");
|
|
73
93
|
const classic = await connectBuildServiceArgs();
|
|
74
94
|
const passed = await connectBuildInvocationArgs(host, ctx);
|
|
@@ -84,12 +104,14 @@ async function build(host, ctx) {
|
|
|
84
104
|
/** Opening a browser is a developer's convenience, and vite's to give, which
|
|
85
105
|
* also takes over under PH_CONNECT_SERVER=vite. Anything else needs no vite. */
|
|
86
106
|
async function serve(host, ctx) {
|
|
87
|
-
|
|
88
|
-
const
|
|
89
|
-
return
|
|
107
|
+
const open = (await connectInvocationArgs(host, ctx)).open ?? host.runner.openBrowser === true;
|
|
108
|
+
const signsIn = !!host.runner.localSignIn;
|
|
109
|
+
if ((!open || signsIn) && process.env.PH_CONNECT_SERVER !== "vite") return serve$1(host, ctx, { issuers });
|
|
110
|
+
const { runConnectPreview } = await import("../connect-preview-B_E4SIV6.mjs");
|
|
111
|
+
return serveWith(runConnectPreview, host, ctx, { issuers });
|
|
90
112
|
}
|
|
91
113
|
//#endregion
|
|
92
114
|
export { build, dev, run, serve, verbs };
|
|
93
115
|
|
|
94
116
|
//# sourceMappingURL=connect.mjs.map
|
|
95
|
-
//# debugId=
|
|
117
|
+
//# debugId=90cd1745-a114-5191-91dc-77d8e2c32099
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connect.mjs","sources":["../../src/runners/connect.ts"],"sourcesContent":["import {\n callerOverride,\n connectBuildInvocationArgs,\n connectHandle,\n connectInvocationArgs,\n serve as serveBuilt,\n servesDefaultComposition,\n serveWith,\n startUnderSupervisor,\n validateComposition,\n withDefaultComposition,\n type ConnectHostParsed,\n type ConnectInvocationArgs,\n type ConnectOutputs,\n} from \"@powerhousedao/ph-run/runners/connect\";\nimport type { RunnerContext, RunnerHandle } from \"@powerhousedao/host-core\";\nimport { getConfig } from \"@powerhousedao/shared/clis\";\nimport { deepMerge } from \"@powerhousedao/shared/connect\";\nimport { join } from \"node:path\";\nimport type { ConnectStudioArgs } from \"../types.js\";\n\nexport * from \"@powerhousedao/ph-run/runners/connect\";\n\nexport const verbs = [\"run\", \"dev\", \"build\", \"serve\"];\n\n/** The Connect studio arguments, with the keys this host and\n * this invocation own laid over them. An argument of this invocation\n * (`passed`) wins over the host file. */\nasync function toStudioArgs(\n host: ConnectHostParsed,\n passed: ConnectInvocationArgs,\n): Promise<ConnectStudioArgs> {\n const { connectStudioServiceArgs } =\n await import(\"../services/service-args.js\");\n const classic = await connectStudioServiceArgs();\n const runner = host.runner;\n return {\n ...classic,\n port: passed.port ?? runner.port ?? classic.port,\n // The bind address (runnerBaseSchema `host`); unset keeps vite's default.\n host: passed.host ?? runner.host ?? classic.host,\n open: passed.open ?? runner.openBrowser === true,\n strictPort: passed.strictPort ?? runner.strictPort === true,\n cors: passed.cors ?? classic.cors,\n bindCLIShortcuts: false,\n };\n}\n\n// Per host: Studio and other hosts' dev servers run side by side in one\n// project. A package's host has the package in front, joined by `+`, which\n// no host name holds: `.vite-@acme+tools+connect`.\nconst viteCacheOf = (host: ConnectHostParsed, ctx: RunnerContext) =>\n join(\n ctx.projectRoot,\n \"node_modules\",\n ctx.hostPackage\n ? `.vite-${`${ctx.hostPackage.name}/${host.name}`.replace(/[^\\w.@/-]/g, \"_\").replaceAll(\"/\", \"+\")}`\n : `.vite-${host.name.replace(/[^\\w.-]/g, \"_\")}`,\n );\n\nexport async function dev(\n host: ConnectHostParsed,\n ctx: RunnerContext,\n): Promise<RunnerHandle<ConnectOutputs>> {\n await validateComposition(host, ctx);\n const { runConnectStudio } = await import(\"../services/connect-studio.js\");\n const args = await toStudioArgs(host, await connectInvocationArgs(host, ctx));\n const studio: { stop?: () => Promise<void> } = {};\n // A host file projects powerhouse.config.json, so a change of that file\n // changes the host: each restart of Studio serves the host as it reads\n // then. Its port, routes, proxy and served files stay those of the start.\n let override = callerOverride(host, ctx, ctx.verb);\n const { reloadHost } = ctx;\n // Without `runner.plugins`, the default composition: worked out at each\n // start of Studio from the powerhouse.config.json it reads, with the\n // studio mode it always switches on.\n const served = servesDefaultComposition(host)\n ? () =>\n withDefaultComposition(\n override,\n getConfig(join(process.cwd(), \"powerhouse.config.json\")),\n { app: { studioMode: true } },\n )\n : reloadHost\n ? () => override\n : override;\n const server = await startUnderSupervisor(ctx, () =>\n runConnectStudio(args, undefined, served, {\n routes: host.runner.routes,\n cacheDir: viteCacheOf(host, ctx),\n proxy: host.runner.proxy?.target,\n // Served as a build's servers serve them: a Studio's tab reads them\n // in dev too.\n ...(host.runner.serveFiles ? { serveFiles: host.runner.serveFiles } : {}),\n // As `ph connect studio` and `ph dev` start it.\n reloadOnConfigChange: true,\n ...(reloadHost\n ? {\n beforeRestart: async () => {\n const reread = (await reloadHost()) as ConnectHostParsed;\n override = callerOverride(reread, ctx, ctx.verb);\n },\n }\n : {}),\n // A restart's server is started as the first is.\n restartWith: (start) => startUnderSupervisor(ctx, start),\n exposeStop: (stop) => {\n studio.stop = stop;\n },\n }),\n );\n // A config change replaces the first server: the handle stops Studio, which\n // is its watcher and whichever server is current.\n const current = {\n resolvedUrls: server.resolvedUrls,\n close: () => (studio.stop ? studio.stop() : server.close()),\n };\n // vite's dev server binds its default host (\"localhost\") here.\n return connectHandle(current, { host: \"localhost\", port: args.port });\n}\n\n/** `run` is dev-studio until the plugin phases give hosts a production\n * runtime; `serve` (below) is the static production server. */\nexport const run = dev;\n\n/** `build`: the Connect build service (`ph connect build` is sugar for it). */\nexport async function build(\n host: ConnectHostParsed,\n ctx: RunnerContext,\n): Promise<void> {\n await validateComposition(host, ctx);\n const { runConnectBuild } = await import(\"../services/connect-build.js\");\n const { connectBuildServiceArgs } =\n await import(\"../services/service-args.js\");\n const classic = await connectBuildServiceArgs();\n const passed = await connectBuildInvocationArgs(host, ctx);\n const args = {\n ...classic,\n // The default of the build arguments: `dist/` is the package `ph build` writes.\n outDir: host.runner.outDir ?? classic.outDir,\n // `--packages-registry`: the top-level packageRegistryUrl of the build.\n packagesRegistry: passed.packagesRegistry ?? classic.packagesRegistry,\n connectBasePath: passed.connectBasePath ?? classic.connectBasePath,\n };\n // The host's config bakes in: its title, favicon, manifest, base path and loading shell.\n const hostConfig = callerOverride(host, ctx, ctx.verb);\n // `--base` wins over the host file, as an argument does: connect.app.basePath,\n // where `ph connect build --base` put it. Laid over the host's config here\n // too, as the service reads the flag off the command line of the process.\n const override =\n passed.connectBasePath === undefined\n ? hostConfig\n : deepMerge(hostConfig ?? {}, {\n app: { basePath: passed.connectBasePath },\n });\n await runConnectBuild(args, override, {\n routes: host.runner.routes,\n });\n}\n\n/** Opening a browser is a developer's convenience, and vite's to give, which\n * also takes over under PH_CONNECT_SERVER=vite. Anything else needs no vite. */\nexport async function serve(\n host: ConnectHostParsed,\n ctx: RunnerContext,\n): Promise<RunnerHandle<ConnectOutputs>> {\n const passed = await connectInvocationArgs(host, ctx);\n const open = passed.open ?? host.runner.openBrowser === true;\n if (!open && process.env.PH_CONNECT_SERVER !== \"vite\") {\n return serveBuilt(host, ctx);\n }\n const { runConnectPreview } = await import(\"../services/connect-preview.js\");\n return serveWith(runConnectPreview, host, ctx);\n}\n"],"names":["serveBuilt"],"mappings":";;;;;;;;AAuBA,MAAa,QAAQ;CAAC;CAAO;CAAO;CAAS;AAAO;;;;AAKpD,eAAe,aACb,MACA,QAC4B;CAC5B,MAAM,EAAE,6BACN,MAAM,OAAO;CACf,MAAM,UAAU,MAAM,yBAAyB;CAC/C,MAAM,SAAS,KAAK;CACpB,OAAO;EACL,GAAG;EACH,MAAM,OAAO,QAAQ,OAAO,QAAQ,QAAQ;EAE5C,MAAM,OAAO,QAAQ,OAAO,QAAQ,QAAQ;EAC5C,MAAM,OAAO,QAAQ,OAAO,gBAAgB;EAC5C,YAAY,OAAO,cAAc,OAAO,eAAe;EACvD,MAAM,OAAO,QAAQ,QAAQ;EAC7B,kBAAkB;CACpB;AACF;AAKA,MAAM,eAAe,MAAyB,QAC5C,KACE,IAAI,aACJ,gBACA,IAAI,cACA,SAAS,GAAG,IAAI,YAAY,KAAK,GAAG,KAAK,OAAO,QAAQ,cAAc,GAAG,CAAC,CAAC,WAAW,KAAK,GAAG,MAC9F,SAAS,KAAK,KAAK,QAAQ,YAAY,GAAG,GAChD;AAEF,eAAsB,IACpB,MACA,KACuC;CACvC,MAAM,oBAAoB,MAAM,GAAG;CACnC,MAAM,EAAE,qBAAqB,MAAM,OAAO;CAC1C,MAAM,OAAO,MAAM,aAAa,MAAM,MAAM,sBAAsB,MAAM,GAAG,CAAC;CAC5E,MAAM,SAAyC,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AiB,OAAO,mBAAmB,QAAQ;CACrD;CAEA,MAAM,aAAa,eAAe,MAAM,KAAK,IAAI,IAAI;CAUrD,MAAM,gBAAgB,MALpB,OAAO,oBAAoB,KAAA,IACvB,aACA,UAAU,cAAc,CAAC,GAAG,EAC1B,KAAK,EAAE,UAAU,OAAO,gBAAgB,EAC1C,CAAC,GAC+B,EACpC,QAAQ,KAAK,OAAO,OACtB,CAAC;AACH;;;AAIA,eAAsB,MACpB,MACA,KACuC;CAGvC,IAAI,GADS,MADQ,sBAAsB,MAAM,GAAG,EAAA,CAChC,QAAQ,KAAK,OAAO,gBAAgB,SAC3C,QAAQ,IAAI,sBAAsB,QAC7C,OAAOA,QAAW,MAAM,GAAG;CAE7B,MAAM,EAAE,sBAAsB,MAAM,OAAO;CAC3C,OAAO,UAAU,mBAAmB,MAAM,GAAG;AAC/C","debug_id":"773b3e34-94cd-5753-9ba4-5b2339cdff3c"}
|
|
1
|
+
{"version":3,"file":"connect.mjs","sources":["../../src/runners/connect.ts"],"sourcesContent":["import {\n callerOverride,\n connectBuildInvocationArgs,\n connectHandle,\n connectInvocationArgs,\n localSignInPlan,\n serve as serveBuilt,\n servesDefaultComposition,\n serveWith,\n startUnderSupervisor,\n validateComposition,\n withDefaultComposition,\n type ConnectHostParsed,\n type ConnectInvocationArgs,\n type ConnectOutputs,\n type LocalSignInIssuerFactory,\n} from \"@powerhousedao/ph-run/runners/connect\";\nimport type { RunnerContext, RunnerHandle } from \"@powerhousedao/host-core\";\nimport { getConfig } from \"@powerhousedao/shared/clis\";\nimport { deepMerge } from \"@powerhousedao/shared/connect\";\nimport { join } from \"node:path\";\nimport type { ConnectStudioArgs } from \"../types.js\";\n\nexport * from \"@powerhousedao/ph-run/runners/connect\";\n\nexport const verbs = [\"run\", \"dev\", \"build\", \"serve\"];\n\n/** The issuer of sign-in by link (F3d): the person's own identity, loaded at\n * the first page that signs in. */\nconst issuers: LocalSignInIssuerFactory = async (o) => {\n const { createLocalSignInIssuer } = await import(\"@renown/sdk/local-sign-in\");\n return createLocalSignInIssuer(o);\n};\n\n/** The Connect studio arguments, with the keys this host and\n * this invocation own laid over them. An argument of this invocation\n * (`passed`) wins over the host file. */\nasync function toStudioArgs(\n host: ConnectHostParsed,\n passed: ConnectInvocationArgs,\n signsIn: boolean,\n): Promise<ConnectStudioArgs> {\n const { connectStudioServiceArgs } =\n await import(\"../services/service-args.js\");\n const classic = await connectStudioServiceArgs();\n const runner = host.runner;\n return {\n ...classic,\n port: passed.port ?? runner.port ?? classic.port,\n // The bind address (runnerBaseSchema `host`); unset keeps vite's default.\n host: passed.host ?? runner.host ?? classic.host,\n // With sign-in, the link is opened, not the bare app.\n open: !signsIn && (passed.open ?? runner.openBrowser === true),\n strictPort: passed.strictPort ?? runner.strictPort === true,\n cors: passed.cors ?? classic.cors,\n bindCLIShortcuts: false,\n };\n}\n\n// Per host: Studio and other hosts' dev servers run side by side in one\n// project. A package's host has the package in front, joined by `+`, which\n// no host name holds: `.vite-@acme+tools+connect`.\nconst viteCacheOf = (host: ConnectHostParsed, ctx: RunnerContext) =>\n join(\n ctx.projectRoot,\n \"node_modules\",\n ctx.hostPackage\n ? `.vite-${`${ctx.hostPackage.name}/${host.name}`.replace(/[^\\w.@/-]/g, \"_\").replaceAll(\"/\", \"+\")}`\n : `.vite-${host.name.replace(/[^\\w.-]/g, \"_\")}`,\n );\n\nasync function startStudio(\n host: ConnectHostParsed,\n ctx: RunnerContext,\n { devServer }: { devServer: boolean },\n): Promise<RunnerHandle<ConnectOutputs>> {\n await validateComposition(host, ctx);\n const { runConnectStudio } = await import(\"../services/connect-studio.js\");\n const passed = await connectInvocationArgs(host, ctx);\n const askedOpen = passed.open ?? host.runner.openBrowser;\n const signIn = localSignInPlan(host, ctx, {\n byDefault: true,\n ...(askedOpen === undefined ? {} : { open: askedOpen }),\n issuers,\n });\n const args = await toStudioArgs(host, passed, signIn !== undefined);\n const studio: { stop?: () => Promise<void> } = {};\n // A host file projects powerhouse.config.json, so a change of that file\n // changes the host: each restart of Studio serves the host as it reads\n // then. Its port, routes, proxy and served files stay those of the start.\n let override = callerOverride(host, ctx, ctx.verb);\n const { reloadHost } = ctx;\n // Without `runner.plugins`, the default composition: worked out at each\n // start of Studio from the powerhouse.config.json it reads, with the\n // studio mode it always switches on.\n const served = servesDefaultComposition(host)\n ? () =>\n withDefaultComposition(\n override,\n getConfig(join(process.cwd(), \"powerhouse.config.json\")),\n { app: { studioMode: true } },\n )\n : reloadHost\n ? () => override\n : override;\n const server = await startUnderSupervisor(ctx, () =>\n runConnectStudio(args, undefined, served, {\n routes: host.runner.routes,\n cacheDir: viteCacheOf(host, ctx),\n proxy: host.runner.proxy?.target,\n // Served as a build's servers serve them: a Studio's tab reads them\n // in dev too.\n ...(host.runner.serveFiles ? { serveFiles: host.runner.serveFiles } : {}),\n // As `ph connect studio` and `ph dev` start it.\n reloadOnConfigChange: true,\n ...(reloadHost\n ? {\n beforeRestart: async () => {\n const reread = (await reloadHost()) as ConnectHostParsed;\n override = callerOverride(reread, ctx, ctx.verb);\n },\n }\n : {}),\n // A restart's server is started as the first is.\n restartWith: (start) => startUnderSupervisor(ctx, start),\n exposeStop: (stop) => {\n studio.stop = stop;\n },\n ...(signIn ? { localSignIn: signIn.endpoint } : {}),\n // Only a dev server loads the host's dev-server plugins.\n ...(devServer && {\n devPlugins: {\n entries: host.runner.devPlugins ?? [],\n where: `hosts/${host.name}/host.js`,\n },\n }),\n }),\n );\n // A config change replaces the first server: the handle stops Studio, which\n // is its watcher and whichever server is current.\n const current = {\n resolvedUrls: server.resolvedUrls,\n close: () => (studio.stop ? studio.stop() : server.close()),\n };\n // vite's dev server binds its default host (\"localhost\") here.\n return connectHandle(current, { host: \"localhost\", port: args.port }, signIn);\n}\n\n/** Studio as a dev server, with the host's dev-server plugins. */\nexport const dev = (host: ConnectHostParsed, ctx: RunnerContext) =>\n startStudio(host, ctx, { devServer: true });\n\n/** `run` is dev-studio until the plugin phases give hosts a production\n * runtime; `serve` (below) is the static production server. */\nexport const run = (host: ConnectHostParsed, ctx: RunnerContext) =>\n startStudio(host, ctx, { devServer: false });\n\n/** `build`: the Connect build service (`ph connect build` is sugar for it). */\nexport async function build(\n host: ConnectHostParsed,\n ctx: RunnerContext,\n): Promise<void> {\n await validateComposition(host, ctx);\n const { runConnectBuild } = await import(\"../services/connect-build.js\");\n const { connectBuildServiceArgs } =\n await import(\"../services/service-args.js\");\n const classic = await connectBuildServiceArgs();\n const passed = await connectBuildInvocationArgs(host, ctx);\n const args = {\n ...classic,\n // The default of the build arguments: `dist/` is the package `ph build` writes.\n outDir: host.runner.outDir ?? classic.outDir,\n // `--packages-registry`: the top-level packageRegistryUrl of the build.\n packagesRegistry: passed.packagesRegistry ?? classic.packagesRegistry,\n connectBasePath: passed.connectBasePath ?? classic.connectBasePath,\n };\n // The host's config bakes in: its title, favicon, manifest, base path and loading shell.\n const hostConfig = callerOverride(host, ctx, ctx.verb);\n // `--base` wins over the host file, as an argument does: connect.app.basePath,\n // where `ph connect build --base` put it. Laid over the host's config here\n // too, as the service reads the flag off the command line of the process.\n const override =\n passed.connectBasePath === undefined\n ? hostConfig\n : deepMerge(hostConfig ?? {}, {\n app: { basePath: passed.connectBasePath },\n });\n await runConnectBuild(args, override, {\n routes: host.runner.routes,\n });\n}\n\n/** Opening a browser is a developer's convenience, and vite's to give, which\n * also takes over under PH_CONNECT_SERVER=vite. Anything else needs no vite. */\nexport async function serve(\n host: ConnectHostParsed,\n ctx: RunnerContext,\n): Promise<RunnerHandle<ConnectOutputs>> {\n const passed = await connectInvocationArgs(host, ctx);\n const open = passed.open ?? host.runner.openBrowser === true;\n // With sign-in by link, the link is opened, not the bare app.\n const signsIn = !!host.runner.localSignIn;\n if ((!open || signsIn) && process.env.PH_CONNECT_SERVER !== \"vite\") {\n return serveBuilt(host, ctx, { issuers });\n }\n const { runConnectPreview } = await import(\"../services/connect-preview.js\");\n return serveWith(runConnectPreview, host, ctx, { issuers });\n}\n"],"names":["serveBuilt"],"mappings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,oBAAoB,MAAM,OAAO;CACzC,MAAM,EAAE,4BACN,MAAM,OAAO;CACf,MAAM,UAAU,MAAM,wBAAwB;CAC9C,MAAM,SAAS,MAAM,2BAA2B,MAAM,GAAG;CACzD,MAAM,OAAO;EACX,GAAG;EAEH,QAAQ,KAAK,OAAO,UAAU,QAAQ;EAEtC,kBAAkB,OAAO,oBAAoB,QAAQ;EACrD,iBAAiB,OAAO,mBAAmB,QAAQ;CACrD;CAEA,MAAM,aAAa,eAAe,MAAM,KAAK,IAAI,IAAI;CAUrD,MAAM,gBAAgB,MALpB,OAAO,oBAAoB,KAAA,IACvB,aACA,UAAU,cAAc,CAAC,GAAG,EAC1B,KAAK,EAAE,UAAU,OAAO,gBAAgB,EAC1C,CAAC,GAC+B,EACpC,QAAQ,KAAK,OAAO,OACtB,CAAC;AACH;;;AAIA,eAAsB,MACpB,MACA,KACuC;CAEvC,MAAM,QAAO,MADQ,sBAAsB,MAAM,GAAG,EAAA,CAChC,QAAQ,KAAK,OAAO,gBAAgB;CAExD,MAAM,UAAU,CAAC,CAAC,KAAK,OAAO;CAC9B,KAAK,CAAC,QAAQ,YAAY,QAAQ,IAAI,sBAAsB,QAC1D,OAAOA,QAAW,MAAM,KAAK,EAAE,QAAQ,CAAC;CAE1C,MAAM,EAAE,sBAAsB,MAAM,OAAO;CAC3C,OAAO,UAAU,mBAAmB,MAAM,KAAK,EAAE,QAAQ,CAAC;AAC5D","debug_id":"90cd1745-a114-5191-91dc-77d8e2c32099"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as RunnerContext } from "../index-
|
|
1
|
+
import { t as RunnerContext } from "../index-aosqo7aM.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 {
|
|
4
|
-
import { o as projectDriveId, s as resolveDriveDeclaration } from "../dist-
|
|
3
|
+
import { lt as normalizePluginEntries, ot as entryActiveForVerb, ut as normalizePluginEntry } from "../compound-g6x_KkWp-Bs7olmlI.mjs";
|
|
4
|
+
import { o as projectDriveId, s as resolveDriveDeclaration } from "../dist-DPj_FB8H.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-mTLB2w-Q.mjs");
|
|
23
23
|
const { buildServiceArgs } = await import("../service-args-D6y3L0bm.mjs");
|
|
24
24
|
const classic = await buildServiceArgs();
|
|
25
25
|
await runBuild({
|
|
@@ -23,7 +23,13 @@ import { inspect } from "../src/commands/inspect.js";
|
|
|
23
23
|
import { install } from "../src/commands/install.js";
|
|
24
24
|
import { keyframes } from "../src/commands/keyframes.js";
|
|
25
25
|
import { list } from "../src/commands/list.js";
|
|
26
|
+
import {
|
|
27
|
+
credentialsList,
|
|
28
|
+
credentialsWithdraw,
|
|
29
|
+
} from "../src/commands/credentials.js";
|
|
30
|
+
import { identityPassword } from "../src/commands/identity.js";
|
|
26
31
|
import { login } from "../src/commands/login.js";
|
|
32
|
+
import { logout } from "../src/commands/logout.js";
|
|
27
33
|
import { mcp } from "../src/commands/mcp.js";
|
|
28
34
|
import { migrate } from "../src/commands/migrate.js";
|
|
29
35
|
import { modelCheck, modelInspect } from "../src/commands/model.js";
|
|
@@ -31,6 +37,7 @@ import { phCli } from "../src/commands/ph-cli.js";
|
|
|
31
37
|
import { runHost } from "../src/commands/run.js";
|
|
32
38
|
import { uninstall } from "../src/commands/uninstall.js";
|
|
33
39
|
import { vetra } from "../src/commands/vetra.js";
|
|
40
|
+
import { whoami } from "../src/commands/whoami.js";
|
|
34
41
|
|
|
35
42
|
const commands = [
|
|
36
43
|
{ name: "run", command: runHost },
|
|
@@ -62,6 +69,11 @@ const commands = [
|
|
|
62
69
|
{ name: "model check", command: modelCheck },
|
|
63
70
|
{ name: "model inspect", command: modelInspect },
|
|
64
71
|
{ name: "login", command: login },
|
|
72
|
+
{ name: "whoami", command: whoami },
|
|
73
|
+
{ name: "logout", command: logout },
|
|
74
|
+
{ name: "identity password", command: identityPassword },
|
|
75
|
+
{ name: "credentials list", command: credentialsList },
|
|
76
|
+
{ name: "credentials withdraw", command: credentialsWithdraw },
|
|
65
77
|
{ name: "install", command: install },
|
|
66
78
|
{ name: "uninstall", command: uninstall },
|
|
67
79
|
];
|
|
@@ -1,44 +1,11 @@
|
|
|
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]="3f8fce55-4f50-526a-9192-6274d6131949")}catch(e){}}();
|
|
3
3
|
import { r as scanSubgraphs, t as SUBGRAPHS_ENTRY } from "./subgraph-gate-BJ2PWXVY.mjs";
|
|
4
|
-
import {
|
|
4
|
+
import { statSync } from "node:fs";
|
|
5
5
|
import { join } from "node:path";
|
|
6
|
-
import { readSubgraphDefinitions, subgraphCheckInput } from "document-model/tooling";
|
|
6
|
+
import { readSubgraphDefinitions, schemaFirstSource, subgraphCheckInput } from "document-model/tooling";
|
|
7
7
|
import { projectSubgraphGraphQL } from "document-model";
|
|
8
8
|
import { parse, print } from "graphql";
|
|
9
|
-
//#region src/services/model/schema-first/sdl-sources.ts
|
|
10
|
-
const SDL_FILES = [
|
|
11
|
-
["schema.graphql", "graphql"],
|
|
12
|
-
["schema.ts", "typescript"],
|
|
13
|
-
["index.ts", "typescript"]
|
|
14
|
-
];
|
|
15
|
-
const LITERAL_NAME = /\bname(?:\s*:\s*string)?\s*=\s*["'`]([^"'`$]+)["'`]/;
|
|
16
|
-
function readText(path) {
|
|
17
|
-
if (!(statSync(path, { throwIfNoEntry: false })?.isFile() ?? false)) return null;
|
|
18
|
-
return readFileSync(path, "utf8");
|
|
19
|
-
}
|
|
20
|
-
function schemaFirstSource(projectRoot, dir) {
|
|
21
|
-
const unit = `./subgraphs/${dir}/`;
|
|
22
|
-
const name = readText(join(projectRoot, "subgraphs", dir, "index.ts"))?.match(LITERAL_NAME)?.[1] ?? null;
|
|
23
|
-
for (const [file, language] of SDL_FILES) {
|
|
24
|
-
const text = readText(join(projectRoot, "subgraphs", dir, file));
|
|
25
|
-
if (text !== null) return {
|
|
26
|
-
unit,
|
|
27
|
-
name,
|
|
28
|
-
source: { specifier: `${unit}${file}` },
|
|
29
|
-
language,
|
|
30
|
-
text
|
|
31
|
-
};
|
|
32
|
-
}
|
|
33
|
-
return {
|
|
34
|
-
unit,
|
|
35
|
-
name,
|
|
36
|
-
source: { specifier: `${unit}index.ts` },
|
|
37
|
-
language: "typescript",
|
|
38
|
-
text: null
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
//#endregion
|
|
42
9
|
//#region src/services/model/subgraphs.ts
|
|
43
10
|
const SCALARS_ENTRY = "./scalars/index.ts";
|
|
44
11
|
/** A module that hangs on a top-level await must not hang `ph model`. */
|
|
@@ -130,5 +97,5 @@ async function readProjectSubgraphs(project, modules, timeoutMs = IMPORT_TIMEOUT
|
|
|
130
97
|
//#endregion
|
|
131
98
|
export { readProjectSubgraphs as t };
|
|
132
99
|
|
|
133
|
-
//# sourceMappingURL=subgraphs-
|
|
134
|
-
//# debugId=
|
|
100
|
+
//# sourceMappingURL=subgraphs-Bm9NHTCn.mjs.map
|
|
101
|
+
//# debugId=3f8fce55-4f50-526a-9192-6274d6131949
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"subgraphs-Bm9NHTCn.mjs","sources":["../src/services/model/subgraphs.ts"],"sourcesContent":["import { projectSubgraphGraphQL } from \"document-model\";\nimport { type DocumentNode, parse, print } from \"graphql\";\nimport {\n type ProjectDefinitions,\n readSubgraphDefinitions,\n schemaFirstSource,\n subgraphCheckInput,\n type SubgraphCheckInput,\n type SubgraphDefinitions,\n type SubgraphHostConflict,\n type SubgraphImportFailure,\n type SubgraphInventoryEntry,\n} from \"document-model/tooling\";\nimport type { ProjectModules } from \"@powerhousedao/codegen/utils\";\nimport { statSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { scanSubgraphs, SUBGRAPHS_ENTRY } from \"./subgraph-gate.js\";\n\nconst SCALARS_ENTRY = \"./scalars/index.ts\";\n\n/** A module that hangs on a top-level await must not hang `ph model`. */\nconst IMPORT_TIMEOUT_MS = 60_000;\n\nexport type ProjectSubgraphs = {\n readonly input: SubgraphCheckInput;\n readonly inventory: readonly SubgraphInventoryEntry[];\n};\n\ntype Imported =\n | { readonly ok: true; readonly namespace: object }\n | { readonly ok: false; readonly failure: SubgraphImportFailure };\n\nasync function importModule(\n modules: ProjectModules,\n specifier: `./${string}`,\n packageRoot: string,\n timeoutMs: number,\n): Promise<Imported> {\n let timer: NodeJS.Timeout | undefined;\n const timeout = new Promise<never>((_, reject) => {\n timer = setTimeout(\n () =>\n reject(\n new Error(\n `it did not finish loading within ${timeoutMs / 1000} seconds`,\n ),\n ),\n timeoutMs,\n );\n timer.unref();\n });\n try {\n return {\n ok: true,\n namespace: await Promise.race([modules.importModule(specifier), timeout]),\n };\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n return {\n ok: false,\n failure: { specifier, reason: message.replaceAll(packageRoot, \".\") },\n };\n } finally {\n clearTimeout(timer);\n }\n}\n\n/** The host's admission of the code-first subgraphs, replayed against its built-in subgraphs and the package's document models. */\nasync function replayHostAdmission(\n { subgraphs }: SubgraphDefinitions,\n artifacts: ProjectDefinitions[\"artifacts\"],\n): Promise<readonly SubgraphHostConflict[]> {\n if (subgraphs.length === 0) return [];\n const models = new Map(\n artifacts.map(({ documentType, documentModel }) => [\n documentType,\n documentModel.global,\n ]),\n );\n const { findPackageSubgraphConflicts } =\n await import(\"@powerhousedao/reactor-api/subgraph-types\");\n const { conflicts } = await findPackageSubgraphConflicts(\n subgraphs.map(({ name, definition }) => ({\n name,\n // The host serves the printed projection, parsed again.\n typeDefs: parse(\n print(projectSubgraphGraphQL(definition) as unknown as DocumentNode),\n ),\n })),\n [...models.values()],\n );\n return Array.from(conflicts).flatMap(\n ([subgraph, { nameHeldBy, claims }]): SubgraphHostConflict[] =>\n nameHeldBy === \"package\"\n ? []\n : [\n {\n subgraph,\n ...(nameHeldBy !== undefined && { nameHeldBy }),\n claims,\n },\n ],\n );\n}\n\nconst usesPackageScalars = ({ subgraphs }: SubgraphDefinitions) =>\n subgraphs.some(({ definition }) =>\n definition.scalars.some(({ implementation }) =>\n implementation.startsWith(\"package#\"),\n ),\n );\n\n/**\n * `undefined` when the project has no code-first subgraph: then nothing here\n * imports a module, and projects without one keep the reports they had. A\n * module that fails or outlives `timeoutMs` becomes a diagnostic.\n */\nexport async function readProjectSubgraphs(\n project: Pick<ProjectDefinitions, \"packageRoot\" | \"artifacts\">,\n modules: ProjectModules,\n timeoutMs: number = IMPORT_TIMEOUT_MS,\n): Promise<ProjectSubgraphs | undefined> {\n const root = project.packageRoot;\n const styles = scanSubgraphs(root);\n if (!styles.hasCodeFirst) return undefined;\n const schemaFirst = styles.schemaFirstUnits.map((dir) =>\n schemaFirstSource(root, dir),\n );\n const subgraphs = await importModule(\n modules,\n SUBGRAPHS_ENTRY,\n root,\n timeoutMs,\n );\n if (!subgraphs.ok) {\n return subgraphCheckInput({\n definitions: { subgraphs: [], diagnostics: [] },\n schemaFirst,\n importFailures: [subgraphs.failure],\n });\n }\n const definitions = readSubgraphDefinitions(subgraphs.namespace, {\n specifier: SUBGRAPHS_ENTRY,\n });\n const hostConflicts = await replayHostAdmission(\n definitions,\n project.artifacts,\n );\n if (!usesPackageScalars(definitions)) {\n return subgraphCheckInput({ definitions, schemaFirst, hostConflicts });\n }\n if (\n !(\n statSync(join(root, SCALARS_ENTRY), {\n throwIfNoEntry: false,\n })?.isFile() ?? false\n )\n ) {\n return subgraphCheckInput({\n definitions,\n schemaFirst,\n hostConflicts,\n scalars: null,\n });\n }\n const scalars = await importModule(modules, SCALARS_ENTRY, root, timeoutMs);\n return subgraphCheckInput(\n scalars.ok\n ? { definitions, schemaFirst, hostConflicts, scalars: scalars.namespace }\n : {\n definitions,\n schemaFirst,\n hostConflicts,\n importFailures: [scalars.failure],\n },\n );\n}\n"],"names":[],"mappings":";;;;;;;;;AAkBA,MAAM,gBAAgB;;AAGtB,MAAM,oBAAoB;AAW1B,eAAe,aACb,SACA,WACA,aACA,WACmB;CACnB,IAAI;CACJ,MAAM,UAAU,IAAI,SAAgB,GAAG,WAAW;EAChD,QAAQ,iBAEJ,uBACE,IAAI,MACF,oCAAoC,YAAY,IAAK,SACvD,CACF,GACF,SACF;EACA,MAAM,MAAM;CACd,CAAC;CACD,IAAI;EACF,OAAO;GACL,IAAI;GACJ,WAAW,MAAM,QAAQ,KAAK,CAAC,QAAQ,aAAa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AAa;GAAE,WAAW,CAAC;GAAG,aAAa,CAAC;EAAE;EAC9C;EACA,gBAAgB,CAAC,UAAU,OAAO;CACpC,CAAC;CAEH,MAAM,cAAc,wBAAwB,UAAU,WAAW,EAC/D,WAAW,gBACb,CAAC;CACD,MAAM,gBAAgB,MAAM,oBAC1B,aACA,QAAQ,SACV;CACA,IAAI,CAAC,mBAAmB,WAAW,GACjC,OAAO,mBAAmB;EAAE;EAAa;EAAa;CAAc,CAAC;CAEvE,IACE,EACE,SAAS,KAAK,MAAM,aAAa,GAAG,EAClC,gBAAgB,MAClB,CAAC,CAAC,EAAE,OAAO,KAAK,QAGlB,OAAO,mBAAmB;EACxB;EACA;EACA;EACA,SAAS;CACX,CAAC;CAEH,MAAM,UAAU,MAAM,aAAa,SAAS,eAAe,MAAM,SAAS;CAC1E,OAAO,mBACL,QAAQ,KACJ;EAAE;EAAa;EAAa;EAAe,SAAS,QAAQ;CAAU,IACtE;EACE;EACA;EACA;EACA,gBAAgB,CAAC,QAAQ,OAAO;CAClC,CACN;AACF","debug_id":"3f8fce55-4f50-526a-9192-6274d6131949"}
|
|
@@ -1,8 +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 {
|
|
4
|
-
import { n as isDevHost } from "./dev-host-
|
|
5
|
-
import { a as sugarHostOf, n as HOST_COMMANDS, t as CONNECT_VERBS } from "./run-sugar-
|
|
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]="d279ddd7-d49c-5b6d-8bfa-741830e0f2a3")}catch(e){}}();
|
|
3
|
+
import { R as probeHostsFolder, T as loadHost, nt as withoutHostsMessage } from "./compound-g6x_KkWp-Bs7olmlI.mjs";
|
|
4
|
+
import { n as isDevHost } from "./dev-host-CM-Jg2kY.mjs";
|
|
5
|
+
import { a as sugarHostOf, n as HOST_COMMANDS, t as CONNECT_VERBS } from "./run-sugar-BuxOaRzE.mjs";
|
|
6
6
|
import { DEPRECATIONS_REMOVED_IN, MIGRATION_GUIDE_URL } from "@powerhousedao/shared/clis/deprecations";
|
|
7
7
|
//#region src/utils/sugar-checks.ts
|
|
8
8
|
/**
|
|
@@ -172,5 +172,5 @@ async function sugarError(args, projectRoot) {
|
|
|
172
172
|
//#endregion
|
|
173
173
|
export { sugarError };
|
|
174
174
|
|
|
175
|
-
//# sourceMappingURL=sugar-checks-
|
|
176
|
-
//# debugId=
|
|
175
|
+
//# sourceMappingURL=sugar-checks-DL-J3l2y.mjs.map
|
|
176
|
+
//# debugId=d279ddd7-d49c-5b6d-8bfa-741830e0f2a3
|
|
@@ -1 +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,OAAO;GACL,OAAO,OAAO,cAAc,SAAS;GACrC,MAAM;GACN,aAAa,kBAAkB;GAC/B;EACF;CACF;CAEA,MAAM,O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,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
|
+
{"version":3,"file":"sugar-checks-DL-J3l2y.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,CA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YAAY,CAAC,OAAO,OAAO,eAAe,MAAM,GACpE,OAAO;EAGT,IAAI,QAAQ,WAAW,KAAA,GAAW,OAAO;EACzC,QAAQ,IAAI,MAAM;CACpB;CACA,KAAK,MAAM,UAAU,SAAS;EAC5B,MAAM,UAAU,MAAM,eAAe,aAAa,MAAM;EACxD,IAAI,CAAC,WAAW,CAAC,cAAc,OAAO,CAAC,SAAS,QAAQ,MAAM,GAC5D,OAAO;CAEX;CACA,OAAO;AACT;AAEA,eAAe,iBAAuD;CACpE,IAAI;EACF,MAAM,CAAC,aAAa,WAAW,MAAM,QAAQ,IAAI,CAC/C,OAAO,8CACP,OAAO,wCACT,CAAC;EACD,OAAO;GACL,aAAa,YAAY;GACzB,SAAS,QAAQ;EACnB;CACF,QAAQ;EACN;CACF;AACF;;;;;AAMA,eAAsB,WACpB,MACA,aAC6B;CAC7B,MAAM,UAAU,kBAAkB,MAAM,WAAW;CACnD,IAAI,YAAY,KAAA,GAAW,OAAO;CAClC,MAAM,cAAc,iBAAiB,MAAM,WAAW;CACtD,IAAI,gBAAgB,KAAA,GAAW,OAAO;CACtC,MAAM,aAAa,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":"d279ddd7-d49c-5b6d-8bfa-741830e0f2a3"}
|
|
@@ -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]="d4bd76b8-0bc2-5659-afc3-352dbdc2f05c")}catch(e){}}();
|
|
3
|
+
import { t as getVersion } from "./get-version-Cz5WJkpH.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-D6_euBBn.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-B3CKpYI8.mjs.map
|
|
71
|
+
//# debugId=d4bd76b8-0bc2-5659-afc3-352dbdc2f05c
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"verify-
|
|
1
|
+
{"version":3,"file":"verify-B3CKpYI8.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":"d4bd76b8-0bc2-5659-afc3-352dbdc2f05c"}
|
|
@@ -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 {
|
|
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]="c706a387-cc5f-5c1d-8c47-db0b80688ee2")}catch(e){}}();
|
|
3
|
+
import { t as getVersion } from "./get-version-Cz5WJkpH.mjs";
|
|
4
|
+
import { W as resolvePackageRoot } from "./compound-g6x_KkWp-Bs7olmlI.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-BZJEJiGT.mjs.map
|
|
173
|
+
//# debugId=c706a387-cc5f-5c1d-8c47-db0b80688ee2
|
|
@@ -1 +1 @@
|
|
|
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;EACR,QACE,+BAA+B,qBAAqB,gFACX,eAAe;EAC1D;CACF;CAEF,MAAM,EAAE,YAAY;CACpB,IACE,YAAY,KAAA,KACZ,MAAM,YAAY,MAAM,QACxB,YAAY,cAEZ,OAAO;EACL,QAAQ;EACR,SAAS,GAAG,qBAAqB,GAAG,QAAQ,oCAAoC,aAAa,sBAAsB,QAAQ;CAC7H;CAEF,OAAO,EAAE,QAAQ,MAAM;AACzB;;;;;;;;AA6BA,eAAsB,gBACpB,MACA,MAC6B;CAC7B,MAAM,EAAE,aAAa,mBAAmB,MAAM,KAAK,QAAQ;CAC3D,IAAI,gBAAgB,KAAA,GAClB,MAAM,IAAI,MACR,2JAEF;CAEF,MAAM,UAAU;EAAC;EAAO;EAAmB,GAAG;CAA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AG1E,QAAQ,IAAI,oBAAoB,QAAQ,IAAI;EAC5C,QAAQ,MAAM,OAAO,WAAW;CAClC;CACA,OAAO;AACT","debug_id":"b7ed0ad1-a808-50fc-9cbc-4431643ae255"}
|
|
1
|
+
{"version":3,"file":"vetra-gateway-BZJEJiGT.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_EN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WAAW;CAClC;CACA,OAAO;AACT","debug_id":"c706a387-cc5f-5c1d-8c47-db0b80688ee2"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { c as vetraGateway } from "./vetra-gateway-BZJEJiGT.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]="6fcb8f6a-1c3f-5d03-9613-0357ed1b67af")}catch(e){}}();
|
|
4
|
+
//# debugId=6fcb8f6a-1c3f-5d03-9613-0357ed1b67af
|