@powerhousedao/ph-cli 6.3.0-dev.9 → 6.4.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{build-DuNe06I0.mjs → build-D8_USaRh.mjs} +88 -16
- package/dist/build-D8_USaRh.mjs.map +1 -0
- package/dist/build-FVWjguYr.mjs +4 -0
- package/dist/{check-VOIkykDt.mjs → check-CVRb-CJD.mjs} +3 -3
- package/dist/{check-B8oqVMg7.mjs → check-EpzhIKt1.mjs} +4 -4
- package/dist/{check-B8oqVMg7.mjs.map → check-EpzhIKt1.mjs.map} +1 -1
- package/dist/{check-EzkmRLx6.mjs → check-_K6EAsag.mjs} +4 -4
- package/dist/{check-EzkmRLx6.mjs.map → check-_K6EAsag.mjs.map} +1 -1
- package/dist/{cli-connect-override-D22yFWlC.mjs → cli-connect-override-DwlViDdp.mjs} +5 -5
- package/dist/{cli-connect-override-D22yFWlC.mjs.map → cli-connect-override-DwlViDdp.mjs.map} +1 -1
- package/dist/cli.mjs +15 -31
- package/dist/cli.mjs.map +1 -1
- package/dist/{compound-DKi56SSx-CXQHhS6t.mjs → compound-n-bO0qKh-Dx7fgKWx.mjs} +658 -275
- package/dist/compound-n-bO0qKh-Dx7fgKWx.mjs.map +1 -0
- package/dist/{connect-build-Be8C4skj.mjs → connect-build-BIkm5fcG.mjs} +6 -6
- package/dist/{connect-build-Be8C4skj.mjs.map → connect-build-BIkm5fcG.mjs.map} +1 -1
- package/dist/{connect-config-CVU4xhti.mjs → connect-config-CH0KQqyU.mjs} +4 -4
- package/dist/{connect-config-CVU4xhti.mjs.map → connect-config-CH0KQqyU.mjs.map} +1 -1
- package/dist/{connect-preview-CdFvlANO.mjs → connect-preview-BvxXGo_W.mjs} +7 -6
- package/dist/connect-preview-BvxXGo_W.mjs.map +1 -0
- package/dist/{connect-studio-BnfhpIv8.mjs → connect-studio-C-9WE2Bg.mjs} +16 -7
- package/dist/connect-studio-C-9WE2Bg.mjs.map +1 -0
- package/dist/definitions-worker.mjs +1 -1
- package/dist/{dist-DXcB8fAF.mjs → dist-Dbvm_SmC.mjs} +51 -104
- package/dist/dist-Dbvm_SmC.mjs.map +1 -0
- package/dist/{explain-8OEXF2Dy.mjs → explain-DB7uoJkY.mjs} +67 -21
- package/dist/explain-DB7uoJkY.mjs.map +1 -0
- package/dist/{export-DqbcbFU5.mjs → export-DuYGBuQZ.mjs} +4 -4
- package/dist/{export-DqbcbFU5.mjs.map → export-DuYGBuQZ.mjs.map} +1 -1
- package/dist/{generate-all-0YOnlZM0.mjs → generate-all-Mj_xGZZN.mjs} +4 -4
- package/dist/{generate-all-0YOnlZM0.mjs.map → generate-all-Mj_xGZZN.mjs.map} +1 -1
- package/dist/{generate-desktop-shell-BovoRsR6.mjs → generate-desktop-shell-DD9o4Rcl.mjs} +7 -17
- package/dist/generate-desktop-shell-DD9o4Rcl.mjs.map +1 -0
- package/dist/{get-version-JkZQOcO1.mjs → get-version-DXnnvS_S.mjs} +4 -4
- package/dist/{get-version-JkZQOcO1.mjs.map → get-version-DXnnvS_S.mjs.map} +1 -1
- package/dist/{index-H3AYe65i.d.mts → index-V7TKBh-y.d.mts} +57 -3
- package/dist/index-V7TKBh-y.d.mts.map +1 -0
- package/dist/{inspect-zWJnBDMJ.mjs → inspect-Bxa9y7zM.mjs} +4 -4
- package/dist/{inspect-zWJnBDMJ.mjs.map → inspect-Bxa9y7zM.mjs.map} +1 -1
- package/dist/{mcp-vSCc5KHI.mjs → mcp-DKqOFZlX.mjs} +7 -7
- package/dist/mcp-DKqOFZlX.mjs.map +1 -0
- package/dist/{migrate-C27-tFFC.mjs → migrate-CQpwBF1l.mjs} +5 -5
- package/dist/{migrate-C27-tFFC.mjs.map → migrate-CQpwBF1l.mjs.map} +1 -1
- package/dist/{migrate-document-models-CKnqQnRh.mjs → migrate-document-models-DpXzLDuu.mjs} +4 -4
- package/dist/{migrate-document-models-CKnqQnRh.mjs.map → migrate-document-models-DpXzLDuu.mjs.map} +1 -1
- package/dist/{migrate-subgraphs-B2nTiJ-j.mjs → migrate-subgraphs-CdfkO6l9.mjs} +54 -14
- package/dist/migrate-subgraphs-CdfkO6l9.mjs.map +1 -0
- package/dist/migrate-subgraphs-CoUuwzmR.mjs +4 -0
- package/dist/ph-cli-commands-Daeqh5Me.mjs +4 -0
- package/dist/{ph-cli-commands-DhoNXWGf.mjs → ph-cli-commands-Dq-tIYhy.mjs} +30 -182
- package/dist/ph-cli-commands-Dq-tIYhy.mjs.map +1 -0
- package/dist/run-sugar-Bnab2Z3f.mjs +4 -0
- package/dist/run-sugar-DsG2RRgx.mjs +89 -0
- package/dist/run-sugar-DsG2RRgx.mjs.map +1 -0
- package/dist/runners/connect.d.mts +2 -2
- package/dist/runners/connect.d.mts.map +1 -1
- package/dist/runners/connect.mjs +30 -18
- package/dist/runners/connect.mjs.map +1 -1
- package/dist/runners/switchboard.d.mts +3 -3
- package/dist/runners/switchboard.mjs +11 -11
- package/dist/runners/switchboard.mjs.map +1 -1
- package/dist/scripts/generate-commands-docs.ts +2 -8
- package/dist/service-args-D6y3L0bm.mjs +49 -0
- package/dist/service-args-D6y3L0bm.mjs.map +1 -0
- package/dist/sugar-checks-DBk5q_uJ.mjs +175 -0
- package/dist/sugar-checks-DBk5q_uJ.mjs.map +1 -0
- package/dist/{switchboard-reset-MtTB_GAI.mjs → switchboard-reset-CY6J0lWO.mjs} +4 -4
- package/dist/switchboard-reset-CY6J0lWO.mjs.map +1 -0
- package/dist/utils-BU25LHRE.mjs +4 -0
- package/dist/{utils-9KyRM0mf.mjs → utils-D5VlY5AZ.mjs} +4 -15
- package/dist/utils-D5VlY5AZ.mjs.map +1 -0
- package/dist/{verify-DCf_nRt8.mjs → verify-C_fL8YsF.mjs} +4 -4
- package/dist/{verify-DCf_nRt8.mjs.map → verify-C_fL8YsF.mjs.map} +1 -1
- package/dist/{vetra-host-ChTpJiBJ.mjs → vetra-host-CDfny6E8.mjs} +24 -9
- package/dist/vetra-host-CDfny6E8.mjs.map +1 -0
- package/dist/{vetra-instance-CzhYIjxL.mjs → vetra-instance-DlXAeiU7.mjs} +8 -16
- package/dist/{vetra-instance-CzhYIjxL.mjs.map → vetra-instance-DlXAeiU7.mjs.map} +1 -1
- package/dist/{vetra-launch-qi10Unax.mjs → vetra-launcher-CYX10K2m.mjs} +14 -32
- package/dist/vetra-launcher-CYX10K2m.mjs.map +1 -0
- package/dist/vetra-launcher-TDLXj0tY.mjs +4 -0
- package/dist/{vetra-switchboard-tzdc14KA.mjs → vetra-switchboard-Ctje6iR1.mjs} +4 -4
- package/dist/{vetra-switchboard-tzdc14KA.mjs.map → vetra-switchboard-Ctje6iR1.mjs.map} +1 -1
- package/package.json +16 -16
- package/dist/build-CnTFRBft.mjs +0 -4
- package/dist/build-DuNe06I0.mjs.map +0 -1
- package/dist/classic-args-mH_DVsgC.mjs +0 -48
- package/dist/classic-args-mH_DVsgC.mjs.map +0 -1
- package/dist/classic-warnings-BR0S6lr5.mjs +0 -179
- package/dist/classic-warnings-BR0S6lr5.mjs.map +0 -1
- package/dist/compound-DKi56SSx-CXQHhS6t.mjs.map +0 -1
- package/dist/connect-preview-CdFvlANO.mjs.map +0 -1
- package/dist/connect-studio-BnfhpIv8.mjs.map +0 -1
- package/dist/connect-studio-D58ByAAn.mjs +0 -4
- package/dist/dist-DXcB8fAF.mjs.map +0 -1
- package/dist/explain-8OEXF2Dy.mjs.map +0 -1
- package/dist/generate-desktop-shell-BovoRsR6.mjs.map +0 -1
- package/dist/index-H3AYe65i.d.mts.map +0 -1
- package/dist/mcp-vSCc5KHI.mjs.map +0 -1
- package/dist/migrate-subgraphs-B1_NRwV7.mjs +0 -4
- package/dist/migrate-subgraphs-B2nTiJ-j.mjs.map +0 -1
- package/dist/ph-cli-commands-DhoNXWGf.mjs.map +0 -1
- package/dist/ph-cli-commands-LIME9alJ.mjs +0 -4
- package/dist/run-sugar-DpznOP1e.mjs +0 -56
- package/dist/run-sugar-DpznOP1e.mjs.map +0 -1
- package/dist/scripts/manage-environment +0 -199
- package/dist/scripts/setup-environment +0 -423
- package/dist/scripts/setup-environment.ps1 +0 -313
- package/dist/switchboard-reset-MtTB_GAI.mjs.map +0 -1
- package/dist/utils-9KyRM0mf.mjs.map +0 -1
- package/dist/utils-TO9lB8Xs.mjs +0 -4
- package/dist/vetra-CVNZ46pK.mjs +0 -352
- package/dist/vetra-CVNZ46pK.mjs.map +0 -1
- package/dist/vetra-host-ChTpJiBJ.mjs.map +0 -1
- package/dist/vetra-launch-qi10Unax.mjs.map +0 -1
- package/dist/vetra-switchboard-BrkozIm7.mjs +0 -4
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { t as runBuild } from "./build-D8_USaRh.mjs";
|
|
2
|
+
export { runBuild };
|
|
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]="65f0363c-0037-536a-91a6-748cff0a967e")}catch(e){}}();
|
|
4
|
+
//# debugId=65f0363c-0037-536a-91a6-748cff0a967e
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as runModelCheck, t as definitionChecks } from "./check-
|
|
1
|
+
import { n as runModelCheck, t as definitionChecks } from "./check-_K6EAsag.mjs";
|
|
2
2
|
export { definitionChecks, runModelCheck };
|
|
3
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
4
|
-
//# debugId=
|
|
3
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="b0c9ace3-9b8f-58a1-ba3a-6943343286e5")}catch(e){}}();
|
|
4
|
+
//# debugId=b0c9ace3-9b8f-58a1-ba3a-6943343286e5
|
|
@@ -1,6 +1,6 @@
|
|
|
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 checkHost } from "./dist-
|
|
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]="da798533-9229-51f4-acc4-e889fba8d641")}catch(e){}}();
|
|
3
|
+
import { t as checkHost } from "./dist-Dbvm_SmC.mjs";
|
|
4
4
|
import path from "node:path";
|
|
5
5
|
import { readFile } from "node:fs/promises";
|
|
6
6
|
import { CALLER_CWD_ENV } from "@powerhousedao/shared/clis/command-names";
|
|
@@ -61,5 +61,5 @@ async function runHostCheck(args) {
|
|
|
61
61
|
//#endregion
|
|
62
62
|
export { runHostCheck };
|
|
63
63
|
|
|
64
|
-
//# sourceMappingURL=check-
|
|
65
|
-
//# debugId=
|
|
64
|
+
//# sourceMappingURL=check-EpzhIKt1.mjs.map
|
|
65
|
+
//# debugId=da798533-9229-51f4-acc4-e889fba8d641
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check-
|
|
1
|
+
{"version":3,"file":"check-EpzhIKt1.mjs","sources":["../src/services/host/check.ts"],"sourcesContent":["import { readFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { checkHost, type HostIssue } from \"@powerhousedao/host-core\";\nimport { CALLER_CWD_ENV } from \"@powerhousedao/shared/clis/command-names\";\nimport {\n envNamesBeforeProjectEnv,\n loadProjectEnv,\n} from \"@powerhousedao/shared/clis/project-env\";\nimport dotenv from \"dotenv\";\nimport { rememberShellNames } from \"@powerhousedao/ph-run/member-config\";\n\nexport interface HostCheckArgs {\n host: string;\n envFile?: string;\n verb?: string;\n projectRoot?: string;\n}\n\n/** Without `envFile`: what `ph run` sees (project .env under process env). */\nasync function checkEnv(\n projectRoot: string,\n envFile: string | undefined,\n): Promise<Record<string, string | undefined>> {\n if (envFile === undefined) {\n loadProjectEnv(projectRoot);\n // A snapshot: a .env a runner's checkBoot loads later never reaches it.\n const env = { ...process.env };\n // The switchboard's checkBoot puts the .env's values under the host file.\n rememberShellNames(env, envNamesBeforeProjectEnv() ?? Object.keys(env));\n return env;\n }\n const from = process.env[CALLER_CWD_ENV] ?? process.cwd();\n try {\n return dotenv.parse(await readFile(path.resolve(from, envFile), \"utf8\"));\n } catch (error) {\n throw new Error(\n `Cannot read the env file ${envFile}: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n}\n\nfunction issueBlocks(\n found: readonly { label: string; issue: HostIssue }[],\n): string {\n const byFile = new Map<string, typeof found>();\n for (const entry of found) {\n byFile.set(entry.issue.file, [\n ...(byFile.get(entry.issue.file) ?? []),\n entry,\n ]);\n }\n const blocks = [...byFile].map(([at, entries]) => {\n const lines = entries.flatMap(({ label, issue }) => {\n const where = issue.path ? `${issue.path}: ` : \"\";\n const line = ` ${label} ${where}${issue.message.replaceAll(\"\\n\", \"\\n \")}`;\n return issue.hint ? [line, ` hint: ${issue.hint}`] : [line];\n });\n return [at, ...lines].join(\"\\n\");\n });\n return blocks.join(\"\\n\\n\");\n}\n\nexport function formatHostIssues(\n file: string,\n issues: readonly HostIssue[],\n deferred: number,\n warnings: readonly HostIssue[] = [],\n): string {\n const warned = warnings.map((issue) => ({ label: \"warning\", issue }));\n if (issues.length === 0) {\n const note =\n deferred > 0\n ? `\\n ${deferred} output token(s) checked declared-only`\n : \"\";\n const tail = warned.length > 0 ? `\\n\\n${issueBlocks(warned)}` : \"\";\n return `${file}: ok${note}${tail}`;\n }\n return issueBlocks([\n ...issues.map((issue) => ({ label: issue.stage, issue })),\n ...warned,\n ]);\n}\n\n/** `ph host check <host>`: exits 1 on any issue; warnings only print. */\nexport async function runHostCheck(\n args: HostCheckArgs,\n): Promise<{ output: string; exitCode: number }> {\n const projectRoot = args.projectRoot ?? process.cwd();\n const env = await checkEnv(projectRoot, args.envFile);\n const { issues, warnings, deferred } = await checkHost(args.host, {\n projectRoot,\n env,\n ...(args.verb !== undefined ? { verb: args.verb } : {}),\n });\n return {\n output: formatHostIssues(\n `hosts/${args.host}/host.js`,\n issues,\n deferred.length,\n warnings,\n ),\n exitCode: issues.length > 0 ? 1 : 0,\n };\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAmBA,eAAe,SACb,aACA,SAC6C;CAC7C,IAAI,YAAY,KAAA,GAAW;EACzB,eAAe,WAAW;EAE1B,MAAM,MAAM,EAAE,GAAG,QAAQ,IAAI;EAE7B,mBAAmB,KAAK,yBAAyB,KAAK,OAAO,KAAK,GAAG,CAAC;EACtE,OAAO;CACT;CACA,MAAM,OAAO,QAAQ,IAAI,mBAAmB,QAAQ,IAAI;CACxD,IAAI;EACF,OAAO,OAAO,MAAM,MAAM,SAAS,KAAK,QAAQ,MAAM,OAAO,GAAG,MAAM,CAAC;CACzE,SAAS,OAAO;EACd,MAAM,IAAI,MACR,4BAA4B,QAAQ,IAAI,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK,KAC7F,EAAE,OAAO,MAAM,CACjB;CACF;AACF;AAEA,SAAS,YACP,OACQ;CACR,MAAM,yBAAS,IAAI,IAA0B;CAC7C,KAAK,MAAM,SAAS,OAClB,OAAO,IAAI,MAAM,MAAM,MAAM,CAC3B,GAAI,OAAO,IAAI,MAAM,MAAM,IAAI,KAAK,CAAC,GACrC,KACF,CAAC;CAUH,OARe,CAAC,GAAG,MAAM,CAAC,CAAC,KAAK,CAAC,IAAI,aAAa;EAMhD,OAAO,CAAC,IAAI,GALE,QAAQ,SAAS,EAAE,OAAO,YAAY;GAElD,MAAM,OAAO,KAAK,MAAM,IADV,MAAM,OAAO,GAAG,MAAM,KAAK,MAAM,KACX,MAAM,QAAQ,WAAW,MAAM,QAAQ;GAC3E,OAAO,MAAM,OAAO,CAAC,MAAM,aAAa,MAAM,MAAM,IAAI,CAAC,IAAI;EAC/D,CACmB,CAAC,CAAC,CAAC,KAAK,IAAI;CACjC,CACY,CAAC,CAAC,KAAK,MAAM;AAC3B;AAEA,SAAgB,iBACd,MACA,QACA,UACA,WAAiC,CAAC,GAC1B;CACR,MAAM,SAAS,SAAS,KAAK,WAAW;EAAE,OAAO;EAAW;CAAM,EAAE;CACpE,IAAI,OAAO,WAAW,GAMpB,OAAO,GAAG,KAAK,MAJb,WAAW,IACP,OAAO,SAAS,0CAChB,KACO,OAAO,SAAS,IAAI,OAAO,YAAY,MAAM,MAAM;CAGlE,OAAO,YAAY,CACjB,GAAG,OAAO,KAAK,WAAW;EAAE,OAAO,MAAM;EAAO;CAAM,EAAE,GACxD,GAAG,MACL,CAAC;AACH;;AAGA,eAAsB,aACpB,MAC+C;CAC/C,MAAM,cAAc,KAAK,eAAe,QAAQ,IAAI;CACpD,MAAM,MAAM,MAAM,SAAS,aAAa,KAAK,OAAO;CACpD,MAAM,EAAE,QAAQ,UAAU,aAAa,MAAM,UAAU,KAAK,MAAM;EAChE;EACA;EACA,GAAI,KAAK,SAAS,KAAA,IAAY,EAAE,MAAM,KAAK,KAAK,IAAI,CAAC;CACvD,CAAC;CACD,OAAO;EACL,QAAQ,iBACN,SAAS,KAAK,KAAK,WACnB,QACA,SAAS,QACT,QACF;EACA,UAAU,OAAO,SAAS,IAAI,IAAI;CACpC;AACF","debug_id":"da798533-9229-51f4-acc4-e889fba8d641"}
|
|
@@ -1,5 +1,5 @@
|
|
|
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]="79a502a0-3860-5358-8673-9557b0f0d4b4")}catch(e){}}();
|
|
3
3
|
import { t as readProjectSubgraphs } from "./subgraphs-7OYWwP-C.mjs";
|
|
4
4
|
import { n as processStreams, r as runModelCommand } from "./run--de_-WAz.mjs";
|
|
5
5
|
import { t as renderCheckReport } from "./render-SVfj3m8A.mjs";
|
|
@@ -59,7 +59,7 @@ async function runModelCheck(args, options = {}) {
|
|
|
59
59
|
*/
|
|
60
60
|
async function runPrepackCheck(json, options) {
|
|
61
61
|
const streams = options.streams ?? processStreams;
|
|
62
|
-
const { renderReleaseDecision, verifyRelease } = await import("./verify-
|
|
62
|
+
const { renderReleaseDecision, verifyRelease } = await import("./verify-C_fL8YsF.mjs");
|
|
63
63
|
let decision;
|
|
64
64
|
try {
|
|
65
65
|
decision = verifyRelease(options.projectRoot ?? process.cwd());
|
|
@@ -77,5 +77,5 @@ async function runPrepackCheck(json, options) {
|
|
|
77
77
|
//#endregion
|
|
78
78
|
export { runModelCheck as n, definitionChecks as t };
|
|
79
79
|
|
|
80
|
-
//# sourceMappingURL=check-
|
|
81
|
-
//# debugId=
|
|
80
|
+
//# sourceMappingURL=check-_K6EAsag.mjs.map
|
|
81
|
+
//# debugId=79a502a0-3860-5358-8673-9557b0f0d4b4
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"check-
|
|
1
|
+
{"version":3,"file":"check-_K6EAsag.mjs","sources":["../src/services/model/check.ts"],"sourcesContent":["import type { DefinitionCheckReport } from \"@powerhousedao/shared/document-model\";\nimport {\n checkProjectDefinitions,\n documentModelChecks,\n type ProjectDefinitions,\n subgraphChecks,\n} from \"document-model/tooling\";\nimport type { ReleaseDecision } from \"../release/approval.js\";\nimport type { ReleaseCheck } from \"../release/evidence.js\";\nimport type { ProjectModules } from \"./project.js\";\nimport { readProjectSubgraphs } from \"./subgraphs.js\";\nimport {\n type ModelRunOptions,\n processStreams,\n runModelCommand,\n} from \"./run.js\";\nimport { renderCheckReport } from \"./render.js\";\n\nasync function subgraphContributions(\n project: ProjectDefinitions,\n modules: ProjectModules,\n) {\n const subgraphs = await readProjectSubgraphs(project, modules);\n if (subgraphs === undefined) return undefined;\n return {\n checks: subgraphChecks,\n input: { subgraphs: subgraphs.input },\n inventory: subgraphs.inventory,\n };\n}\n\n/**\n * The edit and the release profile of the definition check, as `ph model\n * check` runs them and the definitions worker runs them for `ph build`.\n */\nexport const definitionChecks = {\n edit: async (\n project: ProjectDefinitions,\n modules: ProjectModules,\n ): Promise<DefinitionCheckReport> => {\n const contributions = await subgraphContributions(project, modules);\n if (contributions === undefined) return checkProjectDefinitions(project);\n return checkProjectDefinitions(\n { ...project, ...contributions.input },\n {\n checks: [...documentModelChecks, ...contributions.checks],\n definitions: contributions.inventory,\n },\n );\n },\n release: async (\n project: ProjectDefinitions,\n modules: ProjectModules,\n ): Promise<ReleaseCheck> => {\n const contributions = await subgraphContributions(project, modules);\n const { checkForRelease } = await import(\"../release/evidence.js\");\n return await checkForRelease(\n project,\n modules,\n contributions === undefined ? {} : { contributions },\n );\n },\n};\n\n/** `ph model check`. Returns the exit code. */\nexport async function runModelCheck(\n args: {\n readonly json: boolean;\n readonly release?: boolean;\n readonly prepack?: boolean;\n },\n options: ModelRunOptions = {},\n): Promise<number> {\n if (args.prepack) {\n if (args.release) {\n (options.streams ?? processStreams).err(\n \"ph model check could not run: --prepack and --release cannot be combined.\\n\",\n );\n return 2;\n }\n return await runPrepackCheck(args.json, options);\n }\n return await runModelCommand(\n {\n name: \"ph model check\",\n json: args.json,\n read: async (project, modules) =>\n args.release\n ? (await definitionChecks.release(project, modules)).report\n : await definitionChecks.edit(project, modules),\n render: renderCheckReport,\n },\n options,\n );\n}\n\n/**\n * `ph model check --prepack`: 0 when the release approval matches the\n * package, 1 when it does not, 2 when it cannot be checked. Loads none of\n * the package's modules.\n */\nasync function runPrepackCheck(\n json: boolean,\n options: ModelRunOptions,\n): Promise<number> {\n const streams = options.streams ?? processStreams;\n const { renderReleaseDecision, verifyRelease } =\n await import(\"../release/verify.js\");\n let decision: ReleaseDecision;\n try {\n decision = verifyRelease(options.projectRoot ?? process.cwd());\n } catch (error) {\n const message = error instanceof Error ? error.message : String(error);\n streams.err(`ph model check --prepack could not run: ${message}\\n`);\n return 2;\n }\n streams.out(\n `${json ? JSON.stringify({ decision: decision.decision, reasons: decision.reasons }) : renderReleaseDecision(decision)}\\n`,\n );\n return decision.decision === \"approved\" ? 0 : 1;\n}\n"],"names":[],"mappings":";;;;;;;AAkBA,eAAe,sBACb,SACA,SACA;CACA,MAAM,YAAY,MAAM,qBAAqB,SAAS,OAAO;CAC7D,IAAI,cAAc,KAAA,GAAW,OAAO,KAAA;CACpC,OAAO;EACL,QAAQ;EACR,OAAO,EAAE,WAAW,UAAU,MAAM;EACpC,WAAW,UAAU;CACvB;AACF;;;;;AAMA,MAAa,mBAAmB;CAC9B,MAAM,OACJ,SACA,YACmC;EACnC,MAAM,gBAAgB,MAAM,sBAAsB,SAAS,OAAO;EAClE,IAAI,kBAAkB,KAAA,GAAW,OAAO,wBAAwB,OAAO;EACvE,OAAO,wBACL;GAAE,GAAG;GAAS,GAAG,cAAc;EAAM,GACrC;GACE,QAAQ,CAAC,GAAG,qBAAqB,GAAG,cAAc,MAAM;GACxD,aAAa,cAAc;EAC7B,CACF;CACF;CACA,SAAS,OACP,SACA,YAC0B;EAC1B,MAAM,gBAAgB,MAAM,sBAAsB,SAAS,OAAO;EAClE,MAAM,EAAE,oBAAoB,MAAM,OAAO;EACzC,OAAO,MAAM,gBACX,SACA,SACA,kBAAkB,KAAA,IAAY,CAAC,IAAI,EAAE,cAAc,CACrD;CACF;AACF;;AAGA,eAAsB,cACpB,MAKA,UAA2B,CAAC,GACX;CACjB,IAAI,KAAK,SAAS;EAChB,IAAI,KAAK,SAAS;GAChB,CAAC,QAAQ,WAAW,eAAA,CAAgB,IAClC,6EACF;GACA,OAAO;EACT;EACA,OAAO,MAAM,gBAAgB,KAAK,MAAM,OAAO;CACjD;CACA,OAAO,MAAM,gBACX;EACE,MAAM;EACN,MAAM,KAAK;EACX,MAAM,OAAO,SAAS,YACpB,KAAK,WACA,MAAM,iBAAiB,QAAQ,SAAS,OAAO,EAAA,CAAG,SACnD,MAAM,iBAAiB,KAAK,SAAS,OAAO;EAClD,QAAQ;CACV,GACA,OACF;AACF;;;;;;AAOA,eAAe,gBACb,MACA,SACiB;CACjB,MAAM,UAAU,QAAQ,WAAW;CACnC,MAAM,EAAE,uBAAuB,kBAC7B,MAAM,OAAO;CACf,IAAI;CACJ,IAAI;EACF,WAAW,cAAc,QAAQ,eAAe,QAAQ,IAAI,CAAC;CAC/D,SAAS,OAAO;EACd,MAAM,UAAU,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;EACrE,QAAQ,IAAI,2CAA2C,QAAQ,GAAG;EAClE,OAAO;CACT;CACA,QAAQ,IACN,GAAG,OAAO,KAAK,UAAU;EAAE,UAAU,SAAS;EAAU,SAAS,SAAS;CAAQ,CAAC,IAAI,sBAAsB,QAAQ,EAAE,GACzH;CACA,OAAO,SAAS,aAAa,aAAa,IAAI;AAChD","debug_id":"79a502a0-3860-5358-8673-9557b0f0d4b4"}
|
|
@@ -1,6 +1,6 @@
|
|
|
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 {
|
|
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]="c8d228e0-c39c-5aef-b4ce-8ba4f405a95e")}catch(e){}}();
|
|
3
|
+
import { i as mergeDefaultDrives } from "./dist-Dbvm_SmC.mjs";
|
|
4
4
|
import { deepMerge, phConnectRuntimeConfigSchema } from "@powerhousedao/shared/connect";
|
|
5
5
|
import AjvNs from "ajv";
|
|
6
6
|
import { isPlainObject, stringToPath } from "remeda";
|
|
@@ -287,7 +287,7 @@ function buildStudioConnectOverride(args, callerOverride) {
|
|
|
287
287
|
return merged;
|
|
288
288
|
}
|
|
289
289
|
//#endregion
|
|
290
|
-
export {
|
|
290
|
+
export { normalizeKey as a, validateConnectPatch as c, wasFlagExplicitlyPassed as i, buildConnectFlagPatch as n, parseCliValue as o, buildStudioConnectOverride as r, validateConnectKeyValue as s, buildCliConnectOverride as t };
|
|
291
291
|
|
|
292
|
-
//# sourceMappingURL=cli-connect-override-
|
|
293
|
-
//# debugId=
|
|
292
|
+
//# sourceMappingURL=cli-connect-override-DwlViDdp.mjs.map
|
|
293
|
+
//# debugId=c8d228e0-c39c-5aef-b4ce-8ba4f405a95e
|
package/dist/{cli-connect-override-D22yFWlC.mjs.map → cli-connect-override-DwlViDdp.mjs.map}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli-connect-override-D22yFWlC.mjs","sources":["../src/utils/connect-config-validation.ts","../src/utils/parse-default-drives.ts","../src/utils/cli-connect-override.ts"],"sourcesContent":["// Ajv-backed validation for `ph connect config` writes.\n//\n// Two entry points:\n//\n// - validateConnectKeyValue(key, value)\n// For the `<key> <value>` form. Sets the value at the dotted path inside a\n// stub connect block, then validates the result against the runtime schema.\n// Catches both invalid paths (key doesn't map to a real field) and invalid\n// types (e.g. `connect.renown.chainId \"abc\"` — schema says number).\n//\n// - validateConnectPatch(patch)\n// For the `--json` form. Validates the whole patch as a partial connect.*\n// blob. Same schema, but we only check the keys actually present in the\n// patch (additional keys still fail per `additionalProperties: false`).\n//\n// Both return a typed `connect.*` partial on success or throw with a multi-\n// line, actionable message on failure.\n\nimport { phConnectRuntimeConfigSchema } from \"@powerhousedao/shared/connect\";\nimport type { PHConnectRuntimeConfig } from \"@powerhousedao/shared/clis\";\nimport AjvNs from \"ajv\";\nimport { isPlainObject, stringToPath } from \"remeda\";\n\ntype PlainObject = Record<string, unknown>;\ntype ConnectPartial = Partial<PHConnectRuntimeConfig>;\n\n// Ajv ships as CJS — under NodeNext ESM the default lands on `.default` while\n// types still point at the class on the namespace. Normalize the constructor.\ntype AjvCtor = new (opts?: Record<string, unknown>) => {\n compile: (schema: unknown) => AjvValidate;\n};\ntype AjvError = {\n instancePath?: string;\n message?: string;\n params?: { additionalProperty?: string };\n};\ntype AjvValidate = ((data: unknown) => boolean) & {\n errors?: AjvError[] | null;\n};\n\nconst Ajv = ((AjvNs as unknown as { default?: AjvCtor }).default ??\n (AjvNs as unknown as AjvCtor)) as AjvCtor;\n\nconst ajv = new Ajv({ allErrors: true, strict: false });\nconst validateConnect: AjvValidate = ajv.compile(phConnectRuntimeConfigSchema);\n\n/**\n * Parse the CLI-supplied value. Tries JSON first so `true`, `42`, `\"a\"`,\n * `null`, `[1,2]` coerce; falls back to the raw string for unquoted text.\n *\n * Examples:\n * \"true\" -> true (boolean)\n * \"42\" -> 42 (number)\n * '\"x\"' -> \"x\" (string, quoted)\n * \"x\" -> \"x\" (string, bare)\n * \"[1,2]\" -> [1, 2] (array)\n */\nexport function parseCliValue(raw: string): unknown {\n try {\n return JSON.parse(raw);\n } catch {\n return raw;\n }\n}\n\n/**\n * Strip the optional leading \"connect.\" prefix so callers can pass either\n * \"connect.renown.url\" or \"renown.url\" interchangeably.\n */\nexport function normalizeKey(key: string): string {\n return key.startsWith(\"connect.\") ? key.slice(\"connect.\".length) : key;\n}\n\nfunction formatErrors(errors: AjvError[] | null | undefined): string {\n if (!errors || errors.length === 0) return \"unknown validation error\";\n return errors\n .map((e) => {\n const path = e.instancePath || \"(root)\";\n const extra = e.params?.additionalProperty;\n const suffix = extra === undefined ? \"\" : ` (${JSON.stringify(extra)})`;\n return ` ${path} ${e.message ?? \"\"}${suffix}`.trim();\n })\n .join(\"\\n\");\n}\n\n/**\n * Validate a single `<key> <value>` pair. Returns the parsed connect-partial\n * that, when deep-merged into the existing config, applies the change.\n *\n * Throws on:\n * - Empty key\n * - Path that doesn't exist in the schema\n * - Value whose type doesn't match the schema at the leaf path\n */\nexport function validateConnectKeyValue(\n key: string,\n rawValue: string,\n): ConnectPartial {\n const normalized = normalizeKey(key);\n if (!normalized) {\n throw new Error(\n \"ph connect config: key cannot be empty. Pass a dotted path inside connect.* (e.g. connect.renown.url).\",\n );\n }\n const parsed = parseCliValue(rawValue);\n // Build a nested-stub object from the dotted path so Ajv can validate\n // the value's shape against the schema (e.g. \"renown.url\" + parsed →\n // { renown: { url: parsed } }). Remeda's `setPath` requires the path\n // to exist; this is the sparse-creation case, so we fold the parts.\n const stub = stringToPath(normalized).reduceRight<unknown>(\n (acc, key) => ({ [String(key)]: acc }),\n parsed,\n ) as PlainObject;\n if (!validateConnect(stub)) {\n throw new Error(\n `ph connect config: validation failed for key=\"${normalized}\" value=${JSON.stringify(parsed)} (parsed as ${typeof parsed}):\\n${formatErrors(validateConnect.errors)}`,\n );\n }\n return stub;\n}\n\n/**\n * Validate a `--json` bulk override. Returns the parsed partial.\n *\n * `packageRegistryUrl` is a top-level runtime field (not part of the\n * `connect.*` schema). If present in the payload, it is extracted before\n * validation so the connect-only blob can be checked against the schema,\n * then re-attached on the returned object so the caller can route it.\n *\n * `command` prefixes error messages (e.g. \"ph connect build\").\n */\nexport function validateConnectPatch(\n raw: string,\n command = \"ph connect config\",\n): ConnectPartial & {\n packageRegistryUrl?: unknown;\n} {\n const label = `${command} --json`;\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw);\n } catch (e) {\n const msg = e instanceof Error ? e.message : String(e);\n throw new Error(\n `${label}: invalid JSON (${msg}). Expected a partial connect.* blob, e.g. --json '{\"renown\":{\"url\":\"...\"}}'.`,\n { cause: e },\n );\n }\n if (!isPlainObject(parsed)) {\n throw new Error(\n `${label}: payload must be a JSON object, got ${typeof parsed}.`,\n );\n }\n if (Object.prototype.hasOwnProperty.call(parsed, \"connect\")) {\n const inner = JSON.stringify((parsed as PlainObject).connect);\n throw new Error(\n `${label}: pass the connect.* block without the \"connect\" wrapper, e.g. --json '${inner}'.`,\n );\n }\n // Extract `packageRegistryUrl` (top-level field, not in the connect schema)\n // before validating, so a payload like `{\"packageRegistryUrl\":\"…\"}` doesn't\n // fail the `additionalProperties: false` check on the connect schema.\n const top = parsed as PlainObject;\n const hasPackageRegistryUrl = Object.prototype.hasOwnProperty.call(\n top,\n \"packageRegistryUrl\",\n );\n const packageRegistryUrl = top.packageRegistryUrl;\n const connectOnly: PlainObject = { ...top };\n delete connectOnly.packageRegistryUrl;\n if (!validateConnect(connectOnly)) {\n throw new Error(\n `${label}: validation failed:\\n${formatErrors(validateConnect.errors)}\\nExpected a partial connect.* blob with nested keys, e.g. --json '{\"app\":{\"workflowsEnabled\":true}}'.`,\n );\n }\n return hasPackageRegistryUrl\n ? ({ ...connectOnly, packageRegistryUrl } as ConnectPartial & {\n packageRegistryUrl?: unknown;\n })\n : (connectOnly as ConnectPartial);\n}\n","/**\n * Comma-separated URL string → array of `{url, name: null, icon: null}`\n * entries suitable for `connect.drives.defaultDrives`. Used by ph-cli's\n * CLI-override builders and by `ph vetra` when forwarding the local\n * switchboard's drive URLs into the runtime config.\n */\nexport const parseDefaultDrivesUrl = (\n v: string,\n): Array<{ url: string; name: null; icon: null }> =>\n v\n .split(\",\")\n .map((s) => s.trim())\n .filter(Boolean)\n .map((url) => ({ url, name: null, icon: null }));\n","// Builds a `connectOverride` partial from CLI flags. Shared by:\n//\n// - `ph connect build` — uses `buildCliConnectOverride` to produce the\n// `cliConnectOverride` patch the Vite plugin applies at the top of the\n// precedence ladder:\n//\n// DEFAULT_CONNECT_CONFIG < env-var seeds < source connect.* < --json < individual --flag\n//\n// - `ph connect config` — uses `buildConnectFlagPatch` (the per-field\n// partial builder) to translate flag-set values into the patch that\n// gets dual-written to source + dist `powerhouse.config.json`.\n//\n// `--json` parses as a partial `connect.*` blob and merges in first; then any\n// individual --flag values merge on top, so a flag beats a conflicting --json\n// value.\n\nimport type {\n PHConnectDefaultDrive,\n PHConnectRuntimeConfig,\n} from \"@powerhousedao/shared/clis\";\nimport { deepMerge } from \"@powerhousedao/shared/connect\";\nimport { mergeDefaultDrives } from \"@powerhousedao/host-core\";\nimport type { ConnectBuildArgs, ConnectStudioArgs } from \"../types.js\";\nimport {\n normalizeKey,\n parseCliValue,\n validateConnectKeyValue,\n validateConnectPatch,\n} from \"./connect-config-validation.js\";\nimport { parseDefaultDrivesUrl } from \"./parse-default-drives.js\";\n\ntype PlainObject = Record<string, unknown>;\n\n/**\n * Structural input shape consumed by `buildConnectFlagPatch`. Every property\n * is strict-optional — `undefined` means \"user did not pass this flag\" and\n * the path is excluded from the patch.\n *\n * Callers with cmd-ts-typed args where some flags have built-in defaults\n * (e.g. the 4 commonArgs flags `--base` / `--log-level` /\n * `--default-drives-url` / `--drive-preserve-strategy`) must filter through\n * `wasFlagExplicitlyPassed` BEFORE building this input — otherwise default\n * values like `\"info\"` will silently clobber source `powerhouse.config.json`\n * values.\n */\nexport type ConnectFlagInput = {\n // Strict-optional flags from connectRuntimeOverrideArgs (excluding\n // `packagesRegistry`, which is a top-level runtime field — see\n // `buildCliConnectOverride`).\n json?: string | undefined;\n renownUrl?: string | undefined;\n renownNetworkId?: string | undefined;\n renownChainId?: number | undefined;\n renownNamespace?: string | undefined;\n renownSwitchboardUrl?: string | undefined;\n allowAddDrive?: boolean | undefined;\n externalPackages?: boolean | undefined;\n workflows?: boolean | undefined;\n remoteDrivesEnabled?: boolean | undefined;\n remoteDrivesAllowAdd?: boolean | undefined;\n remoteDrivesAllowDelete?: boolean | undefined;\n localDrivesEnabled?: boolean | undefined;\n localDrivesAllowAdd?: boolean | undefined;\n localDrivesAllowDelete?: boolean | undefined;\n appName?: string | undefined;\n homeBackground?: string | undefined;\n sentryDsn?: string | undefined;\n sentryEnv?: string | undefined;\n sentryTracingEnabled?: boolean | undefined;\n // commonArgs flags. Callers must apply `wasFlagExplicitlyPassed`\n // filtering (see above).\n basePath?: string | undefined;\n logLevel?: string | undefined;\n defaultDrivesUrl?: string | undefined;\n drivesPreserveStrategy?: string | undefined;\n};\n\n// Schema-validates `--json` so unknown keys, a `connect` wrapper or wrong\n// types fail instead of being dropped from the dist config.\nfunction parseJsonOverride(raw: string | undefined): PlainObject {\n if (raw === undefined || raw === \"\") return {};\n return validateConnectPatch(raw, \"ph connect build\") as PlainObject;\n}\n\nfunction setIfDefined<V>(\n target: PlainObject,\n key: string,\n value: V | undefined,\n): void {\n if (value !== undefined) target[key] = value;\n}\n\n/**\n * Detect whether the user literally typed `--<longName>` on the command\n * line. Used to gate the 4 commonArgs flags through `cliConnectOverride` —\n * those flags have cmd-ts defaults, so their parsed value is always\n * defined, and a naive merge would silently clobber source values with the\n * default on every build.\n *\n * Handles both `--flag value` and `--flag=value` forms.\n */\nexport function wasFlagExplicitlyPassed(longName: string): boolean {\n const dashed = `--${longName}`;\n return process.argv.some(\n (arg) => arg === dashed || arg.startsWith(`${dashed}=`),\n );\n}\n\n/**\n * Build a `connect.*` partial from the 20 field flags. Only includes paths\n * the user explicitly set (undefined values are excluded).\n *\n * Single source of truth for the flag → JSON-path mapping; consumed by both\n * `ph connect build` and `ph connect config`.\n */\nexport function buildConnectFlagPatch(args: ConnectFlagInput): PlainObject {\n const out: PlainObject = {};\n\n const app: PlainObject = {};\n setIfDefined(app, \"basePath\", args.basePath);\n setIfDefined(app, \"logLevel\", args.logLevel);\n setIfDefined(app, \"workflowsEnabled\", args.workflows);\n if (Object.keys(app).length > 0) out.app = app;\n\n const renown: PlainObject = {};\n setIfDefined(renown, \"url\", args.renownUrl);\n setIfDefined(renown, \"networkId\", args.renownNetworkId);\n setIfDefined(renown, \"chainId\", args.renownChainId);\n setIfDefined(renown, \"namespace\", args.renownNamespace);\n setIfDefined(renown, \"switchboardUrl\", args.renownSwitchboardUrl);\n if (Object.keys(renown).length > 0) out.renown = renown;\n\n const packages: PlainObject = {};\n setIfDefined(packages, \"externalEnabled\", args.externalPackages);\n if (Object.keys(packages).length > 0) out.packages = packages;\n\n const branding: PlainObject = {};\n setIfDefined(branding, \"appName\", args.appName);\n if (Object.keys(branding).length > 0) out.branding = branding;\n\n // --home-background: empty string is the explicit \"set null\" form\n // (cmd-ts can't pass `null` directly through a string option). The home\n // screen is the generic plugin's, so this lands in connect.home.\n if (args.homeBackground !== undefined) {\n out.home = {\n background: args.homeBackground === \"\" ? null : args.homeBackground,\n };\n }\n\n // --sentry-dsn: empty string is the explicit \"set null\" form (disables\n // Sentry). Same pattern as --home-background.\n const sentry: PlainObject = {};\n if (args.sentryDsn !== undefined) {\n sentry.dsn = args.sentryDsn === \"\" ? null : args.sentryDsn;\n }\n setIfDefined(sentry, \"env\", args.sentryEnv);\n setIfDefined(sentry, \"tracing\", args.sentryTracingEnabled);\n if (Object.keys(sentry).length > 0) out.sentry = sentry;\n\n const drives: PlainObject = {};\n setIfDefined(drives, \"allowAddDrive\", args.allowAddDrive);\n setIfDefined(drives, \"preserveStrategy\", args.drivesPreserveStrategy);\n if (args.defaultDrivesUrl !== undefined && args.defaultDrivesUrl !== \"\") {\n drives.defaultDrives = parseDefaultDrivesUrl(args.defaultDrivesUrl);\n }\n\n const remote: PlainObject = {};\n setIfDefined(remote, \"enabled\", args.remoteDrivesEnabled);\n setIfDefined(remote, \"allowAdd\", args.remoteDrivesAllowAdd);\n setIfDefined(remote, \"allowDelete\", args.remoteDrivesAllowDelete);\n\n const local: PlainObject = {};\n setIfDefined(local, \"enabled\", args.localDrivesEnabled);\n setIfDefined(local, \"allowAdd\", args.localDrivesAllowAdd);\n setIfDefined(local, \"allowDelete\", args.localDrivesAllowDelete);\n\n const sections: PlainObject = {};\n if (Object.keys(remote).length > 0) sections.remote = remote;\n if (Object.keys(local).length > 0) sections.local = local;\n if (Object.keys(sections).length > 0) drives.sections = sections;\n if (Object.keys(drives).length > 0) out.drives = drives;\n\n return out;\n}\n\n/**\n * Combine `--json` and the individual flag values into the two override\n * inputs `ph connect build` forwards to the Vite plugin:\n *\n * - `connectOverride`: a partial `connect.*` patch (deep-merged at the top\n * of the runtime-config precedence ladder).\n * - `packageRegistryUrl`: a separate top-level override; mirrors the\n * source-config top-level field (the SPA reads it directly).\n *\n * `--packages-registry` and `--json` containing a top-level\n * `packageRegistryUrl` both flow into `packageRegistryUrl`; the flag wins on\n * collision. Returns `undefined` for whichever override was not supplied.\n *\n * The 4 commonArgs flags (`--base`, `--log-level`, `--default-drives-url`,\n * `--drive-preserve-strategy`) are gated through `wasFlagExplicitlyPassed`\n * because they carry cmd-ts defaults that would otherwise leak into the\n * override on every build.\n */\nexport function buildCliConnectOverride(args: ConnectBuildArgs): {\n connectOverride: PHConnectRuntimeConfig | undefined;\n packageRegistryUrl: string | undefined;\n} {\n const fromJson = parseJsonOverride(args.json);\n\n const input: ConnectFlagInput = {\n renownUrl: args.renownUrl,\n renownNetworkId: args.renownNetworkId,\n renownChainId: args.renownChainId,\n renownNamespace: args.renownNamespace,\n renownSwitchboardUrl: args.renownSwitchboardUrl,\n allowAddDrive: args.allowAddDrive,\n externalPackages: args.externalPackages,\n workflows: args.workflows,\n remoteDrivesEnabled: args.remoteDrivesEnabled,\n remoteDrivesAllowAdd: args.remoteDrivesAllowAdd,\n remoteDrivesAllowDelete: args.remoteDrivesAllowDelete,\n localDrivesEnabled: args.localDrivesEnabled,\n localDrivesAllowAdd: args.localDrivesAllowAdd,\n localDrivesAllowDelete: args.localDrivesAllowDelete,\n appName: args.appName,\n homeBackground: args.homeBackground,\n sentryDsn: args.sentryDsn,\n sentryEnv: args.sentryEnv,\n sentryTracingEnabled: args.sentryTracingEnabled,\n // commonArgs flags — only forward when the user explicitly passed them.\n basePath: wasFlagExplicitlyPassed(\"base\")\n ? args.connectBasePath\n : undefined,\n logLevel: wasFlagExplicitlyPassed(\"log-level\") ? args.logLevel : undefined,\n defaultDrivesUrl: wasFlagExplicitlyPassed(\"default-drives-url\")\n ? args.defaultDrivesUrl\n : undefined,\n drivesPreserveStrategy: wasFlagExplicitlyPassed(\"drive-preserve-strategy\")\n ? args.drivesPreserveStrategy\n : undefined,\n };\n\n const fromFlags = buildConnectFlagPatch(input);\n\n // Positional `<key> <value>` override (only set when both are present;\n // `runConnectBuild` rejects the 1-positional case up front because build\n // has no read mode). Layered on top of --json + flags so a positional\n // override wins on collision — matches the user's literal command line.\n let positionalRegistry: string | undefined;\n let fromPositional: PlainObject = {};\n if (args.keyPositional !== undefined && args.valuePositional !== undefined) {\n const normalized = normalizeKey(args.keyPositional);\n if (!normalized) {\n throw new Error(\n \"ph connect build: positional <key> cannot be empty. Pass a dotted path inside connect.* (e.g. connect.renown.url).\",\n );\n }\n if (normalized === \"packageRegistryUrl\") {\n const parsed = parseCliValue(args.valuePositional);\n if (typeof parsed !== \"string\") {\n throw new Error(\n `ph connect build: positional packageRegistryUrl must be a string (got ${typeof parsed}).`,\n );\n }\n positionalRegistry = parsed;\n } else {\n fromPositional = validateConnectKeyValue(\n normalized,\n args.valuePositional,\n );\n }\n }\n\n // Top-level `packageRegistryUrl` can come from --json (top-level),\n // --packages-registry flag, or positional `packageRegistryUrl <value>`.\n // Precedence (highest → lowest): positional > flag > --json.\n const jsonRegistry =\n typeof fromJson.packageRegistryUrl === \"string\"\n ? (fromJson.packageRegistryUrl as string)\n : undefined;\n const packageRegistryUrl =\n positionalRegistry ?? args.packagesRegistry ?? jsonRegistry;\n // Strip the top-level field from the JSON patch before deep-merging into\n // the connect partial — it isn't a `connect.*` field.\n const jsonConnect = { ...fromJson };\n delete jsonConnect.packageRegistryUrl;\n\n const hasJsonConnect = Object.keys(jsonConnect).length > 0;\n const hasFlags = Object.keys(fromFlags).length > 0;\n const hasPositional = Object.keys(fromPositional).length > 0;\n const connectOverride =\n !hasJsonConnect && !hasFlags && !hasPositional\n ? undefined\n : deepMerge(\n deepMerge(\n jsonConnect as PHConnectRuntimeConfig,\n fromFlags as PHConnectRuntimeConfig,\n ),\n fromPositional as PHConnectRuntimeConfig,\n );\n\n return { connectOverride, packageRegistryUrl };\n}\n\n/**\n * Parallel of `buildCliConnectOverride` for `ph connect studio` / `ph vetra`.\n * Studio only exposes the 4 commonArgs flags (`--base`, `--log-level`,\n * `--default-drives-url`, `--drive-preserve-strategy`); each is gated through\n * `wasFlagExplicitlyPassed` so cmd-ts defaults don't leak into the override.\n *\n * `callerOverride` is supplied by wrappers around studio (notably `ph vetra`,\n * which sets default drives + preserveStrategy directly). The flag override\n * deep-merges on top of it: caller choices apply for every flag the user\n * didn't type, and an explicitly passed flag wins for its own field —\n * except `drives.defaultDrives`, which merges additively: a flag's drives\n * are appended to the caller's list (de-duplicated by drive identity) rather\n * than replacing it, so vetra's own drives stay in Connect's default set.\n * Without a caller override (plain `ph connect studio`) only the flag can\n * carry defaultDrives, so that command's behavior is unchanged.\n */\nexport function buildStudioConnectOverride(\n args: ConnectStudioArgs,\n callerOverride: PHConnectRuntimeConfig | undefined,\n): PHConnectRuntimeConfig | undefined {\n const flagOverride = buildConnectFlagPatch({\n basePath: wasFlagExplicitlyPassed(\"base\")\n ? args.connectBasePath\n : undefined,\n logLevel: wasFlagExplicitlyPassed(\"log-level\") ? args.logLevel : undefined,\n defaultDrivesUrl: wasFlagExplicitlyPassed(\"default-drives-url\")\n ? args.defaultDrivesUrl\n : undefined,\n drivesPreserveStrategy: wasFlagExplicitlyPassed(\"drive-preserve-strategy\")\n ? args.drivesPreserveStrategy\n : undefined,\n renownNamespace: args.renownNamespace,\n }) as PHConnectRuntimeConfig;\n\n // Studio commands (`ph connect studio`, `ph vetra`) always run in studio\n // mode: Connect loads the vetra package and offers builder document types.\n const studioOverride: PHConnectRuntimeConfig = { app: { studioMode: true } };\n const layers = [callerOverride, flagOverride, studioOverride].filter(\n (o): o is PHConnectRuntimeConfig =>\n o !== undefined && Object.keys(o).length > 0,\n );\n const merged = layers.reduce(\n (acc, o) => deepMerge(acc, o),\n {} as PHConnectRuntimeConfig,\n );\n\n // `deepMerge` replaces arrays, so the flag's defaultDrives would clobber\n // the caller's list; re-apply them as the de-duplicated union instead.\n // Only needed when two or more layers contribute default drives (the\n // plain-studio single-layer case is already exactly the flag's list).\n const driveGroups = layers\n .map((l) => l.drives?.defaultDrives)\n .filter(\n (d): d is PHConnectDefaultDrive[] => Array.isArray(d) && d.length > 0,\n );\n if (driveGroups.length > 1) {\n merged.drives = {\n ...merged.drives,\n defaultDrives: mergeDefaultDrives(...driveGroups),\n };\n }\n return merged;\n}\n"],"names":[],"mappings":";;;;;;;AA4CA,MAAM,kBAA+B,KAJvB,MAA2C,WACtD,OAEiB;CAAE,WAAW;CAAM,QAAQ;AAAM,CACd,CAAC,CAAC,QAAQ,4BAA4B;;;;;;;;;;;;AAa7E,SAAgB,cAAc,KAAsB;CAClD,IAAI;EACF,OAAO,KAAK,MAAM,GAAG;CACvB,QAAQ;EACN,OAAO;CACT;AACF;;;;;AAMA,SAAgB,aAAa,KAAqB;CAChD,OAAO,IAAI,WAAW,UAAU,IAAI,IAAI,MAAM,CAAiB,IAAI;AACrE;AAEA,SAAS,aAAa,QAA+C;CACnE,IAAI,CAAC,UAAU,OAAO,WAAW,GAAG,OAAO;CAC3C,OAAO,OACJ,KAAK,MAAM;EACV,MAAM,OAAO,EAAE,gBAAgB;EAC/B,MAAM,QAAQ,EAAE,QAAQ;EACxB,MAAM,SAAS,UAAU,KAAA,IAAY,KAAK,KAAK,KAAK,UAAU,KAAK,EAAE;EACrE,OAAO,KAAK,KAAK,GAAG,EAAE,WAAW,KAAK,SAAS,KAAK;CACtD,CAAC,CAAC,CACD,KAAK,IAAI;AACd;;;;;;;;;;AAWA,SAAgB,wBACd,KACA,UACgB;CAChB,MAAM,aAAa,aAAa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{"version":3,"file":"cli-connect-override-DwlViDdp.mjs","sources":["../src/utils/connect-config-validation.ts","../src/utils/parse-default-drives.ts","../src/utils/cli-connect-override.ts"],"sourcesContent":["// Ajv-backed validation for `ph connect config` writes.\n//\n// Two entry points:\n//\n// - validateConnectKeyValue(key, value)\n// For the `<key> <value>` form. Sets the value at the dotted path inside a\n// stub connect block, then validates the result against the runtime schema.\n// Catches both invalid paths (key doesn't map to a real field) and invalid\n// types (e.g. `connect.renown.chainId \"abc\"` — schema says number).\n//\n// - validateConnectPatch(patch)\n// For the `--json` form. Validates the whole patch as a partial connect.*\n// blob. Same schema, but we only check the keys actually present in the\n// patch (additional keys still fail per `additionalProperties: false`).\n//\n// Both return a typed `connect.*` partial on success or throw with a multi-\n// line, actionable message on failure.\n\nimport { phConnectRuntimeConfigSchema } from \"@powerhousedao/shared/connect\";\nimport type { PHConnectRuntimeConfig } from \"@powerhousedao/shared/clis\";\nimport AjvNs from \"ajv\";\nimport { isPlainObject, stringToPath } from \"remeda\";\n\ntype PlainObject = Record<string, unknown>;\ntype ConnectPartial = Partial<PHConnectRuntimeConfig>;\n\n// Ajv ships as CJS — under NodeNext ESM the default lands on `.default` while\n// types still point at the class on the namespace. Normalize the constructor.\ntype AjvCtor = new (opts?: Record<string, unknown>) => {\n compile: (schema: unknown) => AjvValidate;\n};\ntype AjvError = {\n instancePath?: string;\n message?: string;\n params?: { additionalProperty?: string };\n};\ntype AjvValidate = ((data: unknown) => boolean) & {\n errors?: AjvError[] | null;\n};\n\nconst Ajv = ((AjvNs as unknown as { default?: AjvCtor }).default ??\n (AjvNs as unknown as AjvCtor)) as AjvCtor;\n\nconst ajv = new Ajv({ allErrors: true, strict: false });\nconst validateConnect: AjvValidate = ajv.compile(phConnectRuntimeConfigSchema);\n\n/**\n * Parse the CLI-supplied value. Tries JSON first so `true`, `42`, `\"a\"`,\n * `null`, `[1,2]` coerce; falls back to the raw string for unquoted text.\n *\n * Examples:\n * \"true\" -> true (boolean)\n * \"42\" -> 42 (number)\n * '\"x\"' -> \"x\" (string, quoted)\n * \"x\" -> \"x\" (string, bare)\n * \"[1,2]\" -> [1, 2] (array)\n */\nexport function parseCliValue(raw: string): unknown {\n try {\n return JSON.parse(raw);\n } catch {\n return raw;\n }\n}\n\n/**\n * Strip the optional leading \"connect.\" prefix so callers can pass either\n * \"connect.renown.url\" or \"renown.url\" interchangeably.\n */\nexport function normalizeKey(key: string): string {\n return key.startsWith(\"connect.\") ? key.slice(\"connect.\".length) : key;\n}\n\nfunction formatErrors(errors: AjvError[] | null | undefined): string {\n if (!errors || errors.length === 0) return \"unknown validation error\";\n return errors\n .map((e) => {\n const path = e.instancePath || \"(root)\";\n const extra = e.params?.additionalProperty;\n const suffix = extra === undefined ? \"\" : ` (${JSON.stringify(extra)})`;\n return ` ${path} ${e.message ?? \"\"}${suffix}`.trim();\n })\n .join(\"\\n\");\n}\n\n/**\n * Validate a single `<key> <value>` pair. Returns the parsed connect-partial\n * that, when deep-merged into the existing config, applies the change.\n *\n * Throws on:\n * - Empty key\n * - Path that doesn't exist in the schema\n * - Value whose type doesn't match the schema at the leaf path\n */\nexport function validateConnectKeyValue(\n key: string,\n rawValue: string,\n): ConnectPartial {\n const normalized = normalizeKey(key);\n if (!normalized) {\n throw new Error(\n \"ph connect config: key cannot be empty. Pass a dotted path inside connect.* (e.g. connect.renown.url).\",\n );\n }\n const parsed = parseCliValue(rawValue);\n // Build a nested-stub object from the dotted path so Ajv can validate\n // the value's shape against the schema (e.g. \"renown.url\" + parsed →\n // { renown: { url: parsed } }). Remeda's `setPath` requires the path\n // to exist; this is the sparse-creation case, so we fold the parts.\n const stub = stringToPath(normalized).reduceRight<unknown>(\n (acc, key) => ({ [String(key)]: acc }),\n parsed,\n ) as PlainObject;\n if (!validateConnect(stub)) {\n throw new Error(\n `ph connect config: validation failed for key=\"${normalized}\" value=${JSON.stringify(parsed)} (parsed as ${typeof parsed}):\\n${formatErrors(validateConnect.errors)}`,\n );\n }\n return stub;\n}\n\n/**\n * Validate a `--json` bulk override. Returns the parsed partial.\n *\n * `packageRegistryUrl` is a top-level runtime field (not part of the\n * `connect.*` schema). If present in the payload, it is extracted before\n * validation so the connect-only blob can be checked against the schema,\n * then re-attached on the returned object so the caller can route it.\n *\n * `command` prefixes error messages (e.g. \"ph connect build\").\n */\nexport function validateConnectPatch(\n raw: string,\n command = \"ph connect config\",\n): ConnectPartial & {\n packageRegistryUrl?: unknown;\n} {\n const label = `${command} --json`;\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw);\n } catch (e) {\n const msg = e instanceof Error ? e.message : String(e);\n throw new Error(\n `${label}: invalid JSON (${msg}). Expected a partial connect.* blob, e.g. --json '{\"renown\":{\"url\":\"...\"}}'.`,\n { cause: e },\n );\n }\n if (!isPlainObject(parsed)) {\n throw new Error(\n `${label}: payload must be a JSON object, got ${typeof parsed}.`,\n );\n }\n if (Object.prototype.hasOwnProperty.call(parsed, \"connect\")) {\n const inner = JSON.stringify((parsed as PlainObject).connect);\n throw new Error(\n `${label}: pass the connect.* block without the \"connect\" wrapper, e.g. --json '${inner}'.`,\n );\n }\n // Extract `packageRegistryUrl` (top-level field, not in the connect schema)\n // before validating, so a payload like `{\"packageRegistryUrl\":\"…\"}` doesn't\n // fail the `additionalProperties: false` check on the connect schema.\n const top = parsed as PlainObject;\n const hasPackageRegistryUrl = Object.prototype.hasOwnProperty.call(\n top,\n \"packageRegistryUrl\",\n );\n const packageRegistryUrl = top.packageRegistryUrl;\n const connectOnly: PlainObject = { ...top };\n delete connectOnly.packageRegistryUrl;\n if (!validateConnect(connectOnly)) {\n throw new Error(\n `${label}: validation failed:\\n${formatErrors(validateConnect.errors)}\\nExpected a partial connect.* blob with nested keys, e.g. --json '{\"app\":{\"workflowsEnabled\":true}}'.`,\n );\n }\n return hasPackageRegistryUrl\n ? ({ ...connectOnly, packageRegistryUrl } as ConnectPartial & {\n packageRegistryUrl?: unknown;\n })\n : (connectOnly as ConnectPartial);\n}\n","/**\n * Comma-separated URL string → array of `{url, name: null, icon: null}`\n * entries suitable for `connect.drives.defaultDrives`. Used by ph-cli's\n * CLI-override builders and by `ph vetra` when forwarding the local\n * switchboard's drive URLs into the runtime config.\n */\nexport const parseDefaultDrivesUrl = (\n v: string,\n): Array<{ url: string; name: null; icon: null }> =>\n v\n .split(\",\")\n .map((s) => s.trim())\n .filter(Boolean)\n .map((url) => ({ url, name: null, icon: null }));\n","// Builds a `connectOverride` partial from CLI flags. Shared by:\n//\n// - `ph connect build` — uses `buildCliConnectOverride` to produce the\n// `cliConnectOverride` patch the Vite plugin applies at the top of the\n// precedence ladder:\n//\n// DEFAULT_CONNECT_CONFIG < env-var seeds < source connect.* < --json < individual --flag\n//\n// - `ph connect config` — uses `buildConnectFlagPatch` (the per-field\n// partial builder) to translate flag-set values into the patch that\n// gets dual-written to source + dist `powerhouse.config.json`.\n//\n// `--json` parses as a partial `connect.*` blob and merges in first; then any\n// individual --flag values merge on top, so a flag beats a conflicting --json\n// value.\n\nimport type {\n PHConnectDefaultDrive,\n PHConnectRuntimeConfig,\n} from \"@powerhousedao/shared/clis\";\nimport { deepMerge } from \"@powerhousedao/shared/connect\";\nimport { mergeDefaultDrives } from \"@powerhousedao/host-core\";\nimport type { ConnectBuildArgs, ConnectStudioArgs } from \"../types.js\";\nimport {\n normalizeKey,\n parseCliValue,\n validateConnectKeyValue,\n validateConnectPatch,\n} from \"./connect-config-validation.js\";\nimport { parseDefaultDrivesUrl } from \"./parse-default-drives.js\";\n\ntype PlainObject = Record<string, unknown>;\n\n/**\n * Structural input shape consumed by `buildConnectFlagPatch`. Every property\n * is strict-optional — `undefined` means \"user did not pass this flag\" and\n * the path is excluded from the patch.\n *\n * Callers with cmd-ts-typed args where some flags have built-in defaults\n * (e.g. the 4 commonArgs flags `--base` / `--log-level` /\n * `--default-drives-url` / `--drive-preserve-strategy`) must filter through\n * `wasFlagExplicitlyPassed` BEFORE building this input — otherwise default\n * values like `\"info\"` will silently clobber source `powerhouse.config.json`\n * values.\n */\nexport type ConnectFlagInput = {\n // Strict-optional flags from connectRuntimeOverrideArgs (excluding\n // `packagesRegistry`, which is a top-level runtime field — see\n // `buildCliConnectOverride`).\n json?: string | undefined;\n renownUrl?: string | undefined;\n renownNetworkId?: string | undefined;\n renownChainId?: number | undefined;\n renownNamespace?: string | undefined;\n renownSwitchboardUrl?: string | undefined;\n allowAddDrive?: boolean | undefined;\n externalPackages?: boolean | undefined;\n workflows?: boolean | undefined;\n remoteDrivesEnabled?: boolean | undefined;\n remoteDrivesAllowAdd?: boolean | undefined;\n remoteDrivesAllowDelete?: boolean | undefined;\n localDrivesEnabled?: boolean | undefined;\n localDrivesAllowAdd?: boolean | undefined;\n localDrivesAllowDelete?: boolean | undefined;\n appName?: string | undefined;\n homeBackground?: string | undefined;\n sentryDsn?: string | undefined;\n sentryEnv?: string | undefined;\n sentryTracingEnabled?: boolean | undefined;\n // commonArgs flags. Callers must apply `wasFlagExplicitlyPassed`\n // filtering (see above).\n basePath?: string | undefined;\n logLevel?: string | undefined;\n defaultDrivesUrl?: string | undefined;\n drivesPreserveStrategy?: string | undefined;\n};\n\n// Schema-validates `--json` so unknown keys, a `connect` wrapper or wrong\n// types fail instead of being dropped from the dist config.\nfunction parseJsonOverride(raw: string | undefined): PlainObject {\n if (raw === undefined || raw === \"\") return {};\n return validateConnectPatch(raw, \"ph connect build\") as PlainObject;\n}\n\nfunction setIfDefined<V>(\n target: PlainObject,\n key: string,\n value: V | undefined,\n): void {\n if (value !== undefined) target[key] = value;\n}\n\n/**\n * Detect whether the user literally typed `--<longName>` on the command\n * line. Used to gate the 4 commonArgs flags through `cliConnectOverride` —\n * those flags have cmd-ts defaults, so their parsed value is always\n * defined, and a naive merge would silently clobber source values with the\n * default on every build.\n *\n * Handles both `--flag value` and `--flag=value` forms.\n */\nexport function wasFlagExplicitlyPassed(longName: string): boolean {\n const dashed = `--${longName}`;\n return process.argv.some(\n (arg) => arg === dashed || arg.startsWith(`${dashed}=`),\n );\n}\n\n/**\n * Build a `connect.*` partial from the 20 field flags. Only includes paths\n * the user explicitly set (undefined values are excluded).\n *\n * Single source of truth for the flag → JSON-path mapping; consumed by both\n * `ph connect build` and `ph connect config`.\n */\nexport function buildConnectFlagPatch(args: ConnectFlagInput): PlainObject {\n const out: PlainObject = {};\n\n const app: PlainObject = {};\n setIfDefined(app, \"basePath\", args.basePath);\n setIfDefined(app, \"logLevel\", args.logLevel);\n setIfDefined(app, \"workflowsEnabled\", args.workflows);\n if (Object.keys(app).length > 0) out.app = app;\n\n const renown: PlainObject = {};\n setIfDefined(renown, \"url\", args.renownUrl);\n setIfDefined(renown, \"networkId\", args.renownNetworkId);\n setIfDefined(renown, \"chainId\", args.renownChainId);\n setIfDefined(renown, \"namespace\", args.renownNamespace);\n setIfDefined(renown, \"switchboardUrl\", args.renownSwitchboardUrl);\n if (Object.keys(renown).length > 0) out.renown = renown;\n\n const packages: PlainObject = {};\n setIfDefined(packages, \"externalEnabled\", args.externalPackages);\n if (Object.keys(packages).length > 0) out.packages = packages;\n\n const branding: PlainObject = {};\n setIfDefined(branding, \"appName\", args.appName);\n if (Object.keys(branding).length > 0) out.branding = branding;\n\n // --home-background: empty string is the explicit \"set null\" form\n // (cmd-ts can't pass `null` directly through a string option). The home\n // screen is the generic plugin's, so this lands in connect.home.\n if (args.homeBackground !== undefined) {\n out.home = {\n background: args.homeBackground === \"\" ? null : args.homeBackground,\n };\n }\n\n // --sentry-dsn: empty string is the explicit \"set null\" form (disables\n // Sentry). Same pattern as --home-background.\n const sentry: PlainObject = {};\n if (args.sentryDsn !== undefined) {\n sentry.dsn = args.sentryDsn === \"\" ? null : args.sentryDsn;\n }\n setIfDefined(sentry, \"env\", args.sentryEnv);\n setIfDefined(sentry, \"tracing\", args.sentryTracingEnabled);\n if (Object.keys(sentry).length > 0) out.sentry = sentry;\n\n const drives: PlainObject = {};\n setIfDefined(drives, \"allowAddDrive\", args.allowAddDrive);\n setIfDefined(drives, \"preserveStrategy\", args.drivesPreserveStrategy);\n if (args.defaultDrivesUrl !== undefined && args.defaultDrivesUrl !== \"\") {\n drives.defaultDrives = parseDefaultDrivesUrl(args.defaultDrivesUrl);\n }\n\n const remote: PlainObject = {};\n setIfDefined(remote, \"enabled\", args.remoteDrivesEnabled);\n setIfDefined(remote, \"allowAdd\", args.remoteDrivesAllowAdd);\n setIfDefined(remote, \"allowDelete\", args.remoteDrivesAllowDelete);\n\n const local: PlainObject = {};\n setIfDefined(local, \"enabled\", args.localDrivesEnabled);\n setIfDefined(local, \"allowAdd\", args.localDrivesAllowAdd);\n setIfDefined(local, \"allowDelete\", args.localDrivesAllowDelete);\n\n const sections: PlainObject = {};\n if (Object.keys(remote).length > 0) sections.remote = remote;\n if (Object.keys(local).length > 0) sections.local = local;\n if (Object.keys(sections).length > 0) drives.sections = sections;\n if (Object.keys(drives).length > 0) out.drives = drives;\n\n return out;\n}\n\n/**\n * Combine `--json` and the individual flag values into the two override\n * inputs `ph connect build` forwards to the Vite plugin:\n *\n * - `connectOverride`: a partial `connect.*` patch (deep-merged at the top\n * of the runtime-config precedence ladder).\n * - `packageRegistryUrl`: a separate top-level override; mirrors the\n * source-config top-level field (the SPA reads it directly).\n *\n * `--packages-registry` and `--json` containing a top-level\n * `packageRegistryUrl` both flow into `packageRegistryUrl`; the flag wins on\n * collision. Returns `undefined` for whichever override was not supplied.\n *\n * The 4 commonArgs flags (`--base`, `--log-level`, `--default-drives-url`,\n * `--drive-preserve-strategy`) are gated through `wasFlagExplicitlyPassed`\n * because they carry cmd-ts defaults that would otherwise leak into the\n * override on every build.\n */\nexport function buildCliConnectOverride(args: ConnectBuildArgs): {\n connectOverride: PHConnectRuntimeConfig | undefined;\n packageRegistryUrl: string | undefined;\n} {\n const fromJson = parseJsonOverride(args.json);\n\n const input: ConnectFlagInput = {\n renownUrl: args.renownUrl,\n renownNetworkId: args.renownNetworkId,\n renownChainId: args.renownChainId,\n renownNamespace: args.renownNamespace,\n renownSwitchboardUrl: args.renownSwitchboardUrl,\n allowAddDrive: args.allowAddDrive,\n externalPackages: args.externalPackages,\n workflows: args.workflows,\n remoteDrivesEnabled: args.remoteDrivesEnabled,\n remoteDrivesAllowAdd: args.remoteDrivesAllowAdd,\n remoteDrivesAllowDelete: args.remoteDrivesAllowDelete,\n localDrivesEnabled: args.localDrivesEnabled,\n localDrivesAllowAdd: args.localDrivesAllowAdd,\n localDrivesAllowDelete: args.localDrivesAllowDelete,\n appName: args.appName,\n homeBackground: args.homeBackground,\n sentryDsn: args.sentryDsn,\n sentryEnv: args.sentryEnv,\n sentryTracingEnabled: args.sentryTracingEnabled,\n // commonArgs flags — only forward when the user explicitly passed them.\n basePath: wasFlagExplicitlyPassed(\"base\")\n ? args.connectBasePath\n : undefined,\n logLevel: wasFlagExplicitlyPassed(\"log-level\") ? args.logLevel : undefined,\n defaultDrivesUrl: wasFlagExplicitlyPassed(\"default-drives-url\")\n ? args.defaultDrivesUrl\n : undefined,\n drivesPreserveStrategy: wasFlagExplicitlyPassed(\"drive-preserve-strategy\")\n ? args.drivesPreserveStrategy\n : undefined,\n };\n\n const fromFlags = buildConnectFlagPatch(input);\n\n // Positional `<key> <value>` override (only set when both are present;\n // `runConnectBuild` rejects the 1-positional case up front because build\n // has no read mode). Layered on top of --json + flags so a positional\n // override wins on collision — matches the user's literal command line.\n let positionalRegistry: string | undefined;\n let fromPositional: PlainObject = {};\n if (args.keyPositional !== undefined && args.valuePositional !== undefined) {\n const normalized = normalizeKey(args.keyPositional);\n if (!normalized) {\n throw new Error(\n \"ph connect build: positional <key> cannot be empty. Pass a dotted path inside connect.* (e.g. connect.renown.url).\",\n );\n }\n if (normalized === \"packageRegistryUrl\") {\n const parsed = parseCliValue(args.valuePositional);\n if (typeof parsed !== \"string\") {\n throw new Error(\n `ph connect build: positional packageRegistryUrl must be a string (got ${typeof parsed}).`,\n );\n }\n positionalRegistry = parsed;\n } else {\n fromPositional = validateConnectKeyValue(\n normalized,\n args.valuePositional,\n );\n }\n }\n\n // Top-level `packageRegistryUrl` can come from --json (top-level),\n // --packages-registry flag, or positional `packageRegistryUrl <value>`.\n // Precedence (highest → lowest): positional > flag > --json.\n const jsonRegistry =\n typeof fromJson.packageRegistryUrl === \"string\"\n ? (fromJson.packageRegistryUrl as string)\n : undefined;\n const packageRegistryUrl =\n positionalRegistry ?? args.packagesRegistry ?? jsonRegistry;\n // Strip the top-level field from the JSON patch before deep-merging into\n // the connect partial — it isn't a `connect.*` field.\n const jsonConnect = { ...fromJson };\n delete jsonConnect.packageRegistryUrl;\n\n const hasJsonConnect = Object.keys(jsonConnect).length > 0;\n const hasFlags = Object.keys(fromFlags).length > 0;\n const hasPositional = Object.keys(fromPositional).length > 0;\n const connectOverride =\n !hasJsonConnect && !hasFlags && !hasPositional\n ? undefined\n : deepMerge(\n deepMerge(\n jsonConnect as PHConnectRuntimeConfig,\n fromFlags as PHConnectRuntimeConfig,\n ),\n fromPositional as PHConnectRuntimeConfig,\n );\n\n return { connectOverride, packageRegistryUrl };\n}\n\n/**\n * Parallel of `buildCliConnectOverride` for `ph connect studio` / `ph vetra`.\n * Studio only exposes the 4 commonArgs flags (`--base`, `--log-level`,\n * `--default-drives-url`, `--drive-preserve-strategy`); each is gated through\n * `wasFlagExplicitlyPassed` so cmd-ts defaults don't leak into the override.\n *\n * `callerOverride` is supplied by wrappers around studio (notably `ph vetra`,\n * which sets default drives + preserveStrategy directly). The flag override\n * deep-merges on top of it: caller choices apply for every flag the user\n * didn't type, and an explicitly passed flag wins for its own field —\n * except `drives.defaultDrives`, which merges additively: a flag's drives\n * are appended to the caller's list (de-duplicated by drive identity) rather\n * than replacing it, so vetra's own drives stay in Connect's default set.\n * Without a caller override (plain `ph connect studio`) only the flag can\n * carry defaultDrives, so that command's behavior is unchanged.\n */\nexport function buildStudioConnectOverride(\n args: ConnectStudioArgs,\n callerOverride: PHConnectRuntimeConfig | undefined,\n): PHConnectRuntimeConfig | undefined {\n const flagOverride = buildConnectFlagPatch({\n basePath: wasFlagExplicitlyPassed(\"base\")\n ? args.connectBasePath\n : undefined,\n logLevel: wasFlagExplicitlyPassed(\"log-level\") ? args.logLevel : undefined,\n defaultDrivesUrl: wasFlagExplicitlyPassed(\"default-drives-url\")\n ? args.defaultDrivesUrl\n : undefined,\n drivesPreserveStrategy: wasFlagExplicitlyPassed(\"drive-preserve-strategy\")\n ? args.drivesPreserveStrategy\n : undefined,\n renownNamespace: args.renownNamespace,\n }) as PHConnectRuntimeConfig;\n\n // Studio commands (`ph connect studio`, `ph vetra`) always run in studio\n // mode: Connect loads the vetra package and offers builder document types.\n const studioOverride: PHConnectRuntimeConfig = { app: { studioMode: true } };\n const layers = [callerOverride, flagOverride, studioOverride].filter(\n (o): o is PHConnectRuntimeConfig =>\n o !== undefined && Object.keys(o).length > 0,\n );\n const merged = layers.reduce(\n (acc, o) => deepMerge(acc, o),\n {} as PHConnectRuntimeConfig,\n );\n\n // `deepMerge` replaces arrays, so the flag's defaultDrives would clobber\n // the caller's list; re-apply them as the de-duplicated union instead.\n // Only needed when two or more layers contribute default drives (the\n // plain-studio single-layer case is already exactly the flag's list).\n const driveGroups = layers\n .map((l) => l.drives?.defaultDrives)\n .filter(\n (d): d is PHConnectDefaultDrive[] => Array.isArray(d) && d.length > 0,\n );\n if (driveGroups.length > 1) {\n merged.drives = {\n ...merged.drives,\n defaultDrives: mergeDefaultDrives(...driveGroups),\n };\n }\n return merged;\n}\n"],"names":[],"mappings":";;;;;;;AA4CA,MAAM,kBAA+B,KAJvB,MAA2C,WACtD,OAEiB;CAAE,WAAW;CAAM,QAAQ;AAAM,CACd,CAAC,CAAC,QAAQ,4BAA4B;;;;;;;;;;;;AAa7E,SAAgB,cAAc,KAAsB;CAClD,IAAI;EACF,OAAO,KAAK,MAAM,GAAG;CACvB,QAAQ;EACN,OAAO;CACT;AACF;;;;;AAMA,SAAgB,aAAa,KAAqB;CAChD,OAAO,IAAI,WAAW,UAAU,IAAI,IAAI,MAAM,CAAiB,IAAI;AACrE;AAEA,SAAS,aAAa,QAA+C;CACnE,IAA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CAC/C;CACA,MAAM,SAAS,OAAO,QACnB,KAAK,MAAM,UAAU,KAAK,CAAC,GAC5B,CAAC,CACH;CAMA,MAAM,cAAc,OACjB,KAAK,MAAM,EAAE,QAAQ,aAAa,CAAC,CACnC,QACE,MAAoC,MAAM,QAAQ,CAAC,KAAK,EAAE,SAAS,CACtE;CACF,IAAI,YAAY,SAAS,GACvB,OAAO,SAAS;EACd,GAAG,OAAO;EACV,eAAe,mBAAmB,GAAG,WAAW;CAClD;CAEF,OAAO;AACT","debug_id":"c8d228e0-c39c-5aef-b4ce-8ba4f405a95e"}
|
package/dist/cli.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
4
|
-
import { t as getVersion } from "./get-version-
|
|
5
|
-
import { t as phCliCommands } from "./ph-cli-commands-
|
|
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]="1f49f204-dfaf-57ae-83d3-41174b4aeca9")}catch(e){}}();
|
|
4
|
+
import { t as getVersion } from "./get-version-DXnnvS_S.mjs";
|
|
5
|
+
import { t as phCliCommands } from "./ph-cli-commands-Dq-tIYhy.mjs";
|
|
6
6
|
import { initCliTelemetry } from "@powerhousedao/shared/clis/telemetry";
|
|
7
7
|
import { assertNodeVersion } from "@powerhousedao/shared/clis/utils";
|
|
8
8
|
import { run, runSafely, subcommands } from "cmd-ts";
|
|
@@ -65,7 +65,7 @@ function printDbRecoveryHint(err) {
|
|
|
65
65
|
if (offending) console.error(yellow(` ${offending}`));
|
|
66
66
|
console.error("");
|
|
67
67
|
console.error(yellow("If this is a local PGlite store, you can reset it with:"));
|
|
68
|
-
console.error(yellow(" ph switchboard
|
|
68
|
+
console.error(yellow(" ph run switchboard reset"));
|
|
69
69
|
console.error(yellow("This is destructive: it wipes the local .ph/reactor-storage and .ph/read-storage directories."));
|
|
70
70
|
console.error(yellow("For Postgres-backed deployments (PH_REACTOR_DATABASE_URL / DATABASE_URL), reset the database manually instead."));
|
|
71
71
|
console.error("");
|
|
@@ -75,7 +75,6 @@ function printDbRecoveryHint(err) {
|
|
|
75
75
|
let sentryClient = void 0;
|
|
76
76
|
const COMMANDS_WITH_SUBCOMMANDS = /* @__PURE__ */ new Set([
|
|
77
77
|
"connect",
|
|
78
|
-
"vetra",
|
|
79
78
|
"host",
|
|
80
79
|
"model"
|
|
81
80
|
]);
|
|
@@ -112,17 +111,16 @@ async function main() {
|
|
|
112
111
|
cliName: "ph-cli",
|
|
113
112
|
release: getVersion()
|
|
114
113
|
});
|
|
115
|
-
|
|
116
|
-
const {
|
|
117
|
-
const
|
|
118
|
-
|
|
114
|
+
const typed = process.argv.slice(2);
|
|
115
|
+
const { sugarError } = await import("./sugar-checks-DBk5q_uJ.mjs");
|
|
116
|
+
const refused = await sugarError(typed, process.cwd());
|
|
117
|
+
if (refused !== void 0) throw new Error(refused);
|
|
118
|
+
const { applyRunSugar, forwardRunnerArgv } = await import("./run-sugar-Bnab2Z3f.mjs");
|
|
119
|
+
const { phCliCommands } = await import("./ph-cli-commands-Daeqh5Me.mjs");
|
|
120
|
+
const sugar = applyRunSugar(typed, new Set(Object.keys(phCliCommands)), process.cwd());
|
|
119
121
|
if (sugar.warning) console.warn(sugar.warning);
|
|
120
|
-
args = forwardRunnerArgv(sugar.args);
|
|
122
|
+
const args = forwardRunnerArgv(sugar.args);
|
|
121
123
|
const command = args[0];
|
|
122
|
-
if (command === "vetra" || command === "connect" || command === "switchboard" || command === "reactor") {
|
|
123
|
-
const { warnClassicInvocation } = await import("./classic-warnings-BR0S6lr5.mjs");
|
|
124
|
-
await warnClassicInvocation(args, process.cwd());
|
|
125
|
-
}
|
|
126
124
|
const subcommand = command && COMMANDS_WITH_SUBCOMMANDS.has(command) && args[1] && !args[1].startsWith("-") ? args[1] : void 0;
|
|
127
125
|
sentryClient?.attachInvocationContext({
|
|
128
126
|
command,
|
|
@@ -132,23 +130,9 @@ async function main() {
|
|
|
132
130
|
cwd: process.cwd()
|
|
133
131
|
});
|
|
134
132
|
const hasNoArgs = args.length === 0;
|
|
135
|
-
const
|
|
136
|
-
const isTopLevelHelp = isHelp && args.length === 1;
|
|
133
|
+
const isTopLevelHelp = args.some((arg) => arg === "--help" || arg === "-h") && args.length === 1;
|
|
137
134
|
const cli = hasNoArgs || isTopLevelHelp ? phCliHelp : phCli;
|
|
138
|
-
|
|
139
|
-
if (command === "connect" && ![
|
|
140
|
-
"studio",
|
|
141
|
-
"build",
|
|
142
|
-
"preview",
|
|
143
|
-
"config"
|
|
144
|
-
].includes(args[1]) && !isHelp) {
|
|
145
|
-
const argsWithDefaultConnectSubCommand = [
|
|
146
|
-
"connect",
|
|
147
|
-
"studio",
|
|
148
|
-
...restArgs
|
|
149
|
-
];
|
|
150
|
-
await run(cli, argsWithDefaultConnectSubCommand);
|
|
151
|
-
} else if (command === "model") await runModelCli(cli, args);
|
|
135
|
+
if (command === "model") await runModelCli(cli, args);
|
|
152
136
|
else await run(cli, args);
|
|
153
137
|
}
|
|
154
138
|
await main().catch(async (error) => {
|
|
@@ -165,4 +149,4 @@ await main().catch(async (error) => {
|
|
|
165
149
|
export {};
|
|
166
150
|
|
|
167
151
|
//# sourceMappingURL=cli.mjs.map
|
|
168
|
-
//# debugId=
|
|
152
|
+
//# debugId=1f49f204-dfaf-57ae-83d3-41174b4aeca9
|
package/dist/cli.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.mjs","sources":["../src/utils/constants.ts","../src/commands/ph-cli-help.ts","../src/commands/ph-cli.ts","../src/utils/db-error-hint.ts","../src/cli.ts"],"sourcesContent":["export const PH_CLI_DESCRIPTION =\n \"The Powerhouse CLI (ph-cli) is a command-line interface tool that provides essential commands for managing Powerhouse projects. The tool and it's commands are fundamental for creating, building, and running Document Models as a builder in studio mode.\" as const;\n","import { phCliHelpCommands } from \"@powerhousedao/shared/clis/args\";\nimport { subcommands } from \"cmd-ts\";\nimport { getVersion } from \"../get-version.js\";\nimport { PH_CLI_DESCRIPTION } from \"../utils/constants.js\";\n\nconst version = getVersion();\nexport const phCliHelp = subcommands({\n name: \"ph-cli\",\n description: PH_CLI_DESCRIPTION,\n version,\n cmds: phCliHelpCommands,\n});\n","import { subcommands } from \"cmd-ts\";\nimport { getVersion } from \"../get-version.js\";\nimport { PH_CLI_DESCRIPTION } from \"../utils/constants.js\";\nimport { phCliCommands } from \"./ph-cli-commands.js\";\n\nconst version = getVersion();\nexport const phCli = subcommands({\n name: \"ph-cli\",\n description: PH_CLI_DESCRIPTION,\n version,\n cmds: phCliCommands,\n});\n","import { yellow, bold } from \"colorette\";\n\nconst UNRECOVERABLE_DB_PATTERNS: RegExp[] = [\n /Database migration failed:/i,\n /Migration .* failed/i,\n /relation \"[^\"]+\" already exists/i,\n /column \"[^\"]+\" does not exist/i,\n /schema \"reactor\" does not exist/i,\n /Unsupported PGLite data dir/i,\n /PG_VERSION/i,\n];\n\nfunction collectMessages(err: unknown): string[] {\n const messages: string[] = [];\n let current: unknown = err;\n const seen = new Set<unknown>();\n while (current && !seen.has(current)) {\n seen.add(current);\n if (current instanceof Error) {\n messages.push(current.message);\n current = (current as Error & { cause?: unknown }).cause;\n } else {\n messages.push(\n typeof current === \"string\" ? current : JSON.stringify(current),\n );\n break;\n }\n }\n return messages;\n}\n\nexport function isUnrecoverableDbError(err: unknown): boolean {\n const messages = collectMessages(err);\n return messages.some((msg) =>\n UNRECOVERABLE_DB_PATTERNS.some((re) => re.test(msg)),\n );\n}\n\nexport function printDbRecoveryHint(err: unknown): void {\n const messages = collectMessages(err);\n const offending = messages.find((msg) =>\n UNRECOVERABLE_DB_PATTERNS.some((re) => re.test(msg)),\n );\n console.error(\"\");\n console.error(\n yellow(bold(\"Switchboard hit an unrecoverable database error.\")),\n );\n if (offending) {\n console.error(yellow(` ${offending}`));\n }\n console.error(\"\");\n console.error(\n yellow(\"If this is a local PGlite store, you can reset it with:\"),\n );\n console.error(yellow(\" ph switchboard --reset\"));\n console.error(\n yellow(\n \"This is destructive: it wipes the local .ph/reactor-storage and .ph/read-storage directories.\",\n ),\n );\n console.error(\n yellow(\n \"For Postgres-backed deployments (PH_REACTOR_DATABASE_URL / DATABASE_URL), reset the database manually instead.\",\n ),\n );\n console.error(\"\");\n}\n","#!/usr/bin/env node\nimport {\n initCliTelemetry,\n type TelemetryClient,\n} from \"@powerhousedao/shared/clis/telemetry\";\nimport { assertNodeVersion } from \"@powerhousedao/shared/clis/utils\";\nimport { run, runSafely } from \"cmd-ts\";\nimport { phCliHelp } from \"./commands/ph-cli-help.js\";\nimport { phCli } from \"./commands/ph-cli.js\";\nimport { getVersion } from \"./get-version.js\";\nimport {\n isUnrecoverableDbError,\n printDbRecoveryHint,\n} from \"./utils/db-error-hint.js\";\n\nlet sentryClient: TelemetryClient | undefined = undefined;\n\n// Commands whose second positional is itself a subcommand (vs. a project\n// name / file path). Keeping this explicit avoids high-cardinality tag\n// values like `subcommand:my-package` polluting Sentry.\nconst COMMANDS_WITH_SUBCOMMANDS = new Set([\n \"connect\",\n \"vetra\",\n \"host\",\n \"model\",\n]);\n\nfunction detectPackageManager(): string | undefined {\n // npm, pnpm, yarn and bun all set npm_config_user_agent like\n // \"pnpm/8.5.0 npm/? node/v20.11.1 darwin arm64\". When the user invokes\n // `ph` directly (not via dlx/exec) it's typically unset — skip the tag\n // in that case rather than mislabel.\n const ua = process.env.npm_config_user_agent;\n if (!ua) return undefined;\n return ua.split(\" \")[0]?.split(\"/\")[0] || undefined;\n}\n\n/**\n * `ph model` exits 1 only for invalid models, so an argument error or a crash\n * the command could not report itself, such as its lazy import failing, is 2.\n */\nasync function runModelCli(\n cli: Parameters<typeof runSafely>[0],\n args: string[],\n): Promise<void> {\n try {\n const result = await runSafely(cli, args);\n if (result._tag === \"error\") {\n const { exitCode, message, into } = result.error.config;\n (into === \"stdout\" ? console.log : console.error)(message);\n process.exitCode = exitCode === 1 ? 2 : exitCode;\n }\n } catch (error) {\n await sentryClient?.captureCliError(error);\n console.error(error instanceof Error ? error.message : String(error));\n process.exitCode = 2;\n }\n}\n\nasync function main() {\n assertNodeVersion();\n // Retired env switches: warns, or refuses to start, per the shared table.\n const { checkRetiredFlags } =\n await import(\"@powerhousedao/shared/clis/retired-flags\");\n checkRetiredFlags();\n // Env switches that still work and go in the next release: warns only.\n const { checkDeprecatedFlags } =\n await import(\"@powerhousedao/shared/clis/deprecations\");\n checkDeprecatedFlags();\n // Initializes Sentry only if user consented (opt-out by default, asked\n // once on first interactive run). Respects PH_NO_TELEMETRY/DO_NOT_TRACK.\n sentryClient = await initCliTelemetry({\n cliName: \"ph-cli\",\n release: getVersion(),\n });\n let args = process.argv.slice(2);\n // Host sugar: `ph <host-name> [verb]` → `ph run <host-name> [verb]` when the\n // first arg names a host in this project's hosts/ folder. Built-in commands\n // always win.\n const { applyRunSugar, forwardRunnerArgv } =\n await import(\"./utils/run-sugar.js\");\n const { phCliCommands } = await import(\"./commands/ph-cli-commands.js\");\n const sugar = applyRunSugar(\n args,\n new Set(Object.keys(phCliCommands)),\n process.cwd(),\n );\n if (sugar.warning) console.warn(sugar.warning);\n // A runner's own arguments (`ph run vetra --switchboard-port 4001`).\n args = forwardRunnerArgv(sugar.args);\n const command = args[0];\n // 6.3: a classic command says what replaces it. Not for `ph run`.\n if (\n command === \"vetra\" ||\n command === \"connect\" ||\n command === \"switchboard\" ||\n command === \"reactor\"\n ) {\n const { warnClassicInvocation } =\n await import(\"./utils/classic-warnings.js\");\n await warnClassicInvocation(args, process.cwd());\n }\n const subcommand =\n command &&\n COMMANDS_WITH_SUBCOMMANDS.has(command) &&\n args[1] &&\n !args[1].startsWith(\"-\")\n ? args[1]\n : undefined;\n sentryClient?.attachInvocationContext({\n command,\n subcommand,\n pm: detectPackageManager(),\n argv: args,\n cwd: process.cwd(),\n });\n const hasNoArgs = args.length === 0;\n const isHelp = args.some((arg) => arg === \"--help\" || arg === \"-h\");\n const isTopLevelHelp = isHelp && args.length === 1;\n const showTopLevelHelp = hasNoArgs || isTopLevelHelp;\n const cli = showTopLevelHelp ? phCliHelp : phCli;\n const restArgs = args.slice(1);\n if (\n command === \"connect\" &&\n ![\"studio\", \"build\", \"preview\", \"config\"].includes(args[1]) &&\n !isHelp\n ) {\n const argsWithDefaultConnectSubCommand = [\"connect\", \"studio\", ...restArgs];\n await run(cli, argsWithDefaultConnectSubCommand);\n } else if (command === \"model\") {\n await runModelCli(cli, args);\n } else {\n await run(cli, args);\n }\n}\n\nawait main().catch(async (error) => {\n const isDebug = process.argv.slice(2).includes(\"--debug\");\n // Report to Sentry (no-op when telemetry disabled) before exiting.\n await sentryClient?.captureCliError(error);\n if (isDebug) {\n throw error;\n }\n if (error instanceof Error) {\n console.error(error.message);\n if (isUnrecoverableDbError(error)) {\n printDbRecoveryHint(error);\n }\n process.exit(1);\n } else {\n throw error;\n }\n});\n"],"names":["version"],"mappings":";;;;;;;;;;;AAAA,MAAa,qBACX;;;ACIF,MAAMA,YAAU,WAAW;AAC3B,MAAa,YAAY,YAAY;CACnC,MAAM;CACN,aAAa;CACb,SAAA;CACA,MAAM;AACR,CAAC;;;ACND,MAAM,UAAU,WAAW;AAC3B,MAAa,QAAQ,YAAY;CAC/B,MAAM;CACN,aAAa;CACb;CACA,MAAM;AACR,CAAC;;;ACTD,MAAM,4BAAsC;CAC1C;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,SAAS,gBAAgB,KAAwB;CAC/C,MAAM,WAAqB,CAAC;CAC5B,IAAI,UAAmB;CACvB,MAAM,uBAAO,IAAI,IAAa;CAC9B,OAAO,WAAW,C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AM,QAAQ,QAAQ,YAAY,QAAQ,IAAI;CAClE,MAAM,iBAAiB,UAAU,KAAK,WAAW;CAEjD,MAAM,MADmB,aAAa,iBACP,YAAY;CAC3C,MAAM,WAAW,KAAK,MAAM,CAAC;CAC7B,IACE,YAAY,aACZ,CAAC;EAAC;EAAU;EAAS;EAAW;CAAQ,CAAC,CAAC,SAAS,KAAK,EAAE,KAC1D,CAAC,QACD;EACA,MAAM,mCAAmC;GAAC;GAAW;GAAU,GAAG;EAAQ;EAC1E,MAAM,IAAI,KAAK,gCAAgC;CACjD,OAAO,IAAI,YAAY,SACrB,MAAM,YAAY,KAAK,IAAI;MAE3B,MAAM,IAAI,KAAK,IAAI;AAEvB;AAEA,MAAM,KAAK,CAAC,CAAC,MAAM,OAAO,UAAU;CAClC,MAAM,UAAU,QAAQ,KAAK,MAAM,CAAC,CAAC,CAAC,SAAS,SAAS;CAExD,MAAM,cAAc,gBAAgB,KAAK;CACzC,IAAI,SACF,MAAM;CAER,IAAI,iBAAiB,OAAO;EAC1B,QAAQ,MAAM,MAAM,OAAO;EAC3B,IAAI,uBAAuB,KAAK,GAC9B,oBAAoB,KAAK;EAE3B,QAAQ,KAAK,CAAC;CAChB,OACE,MAAM;AAEV,CAAC","debug_id":"aa38e5db-5dbe-5933-859e-76cf696ddca8"}
|
|
1
|
+
{"version":3,"file":"cli.mjs","sources":["../src/utils/constants.ts","../src/commands/ph-cli-help.ts","../src/commands/ph-cli.ts","../src/utils/db-error-hint.ts","../src/cli.ts"],"sourcesContent":["export const PH_CLI_DESCRIPTION =\n \"The Powerhouse CLI (ph-cli) is a command-line interface tool that provides essential commands for managing Powerhouse projects. The tool and it's commands are fundamental for creating, building, and running Document Models as a builder in studio mode.\" as const;\n","import { phCliHelpCommands } from \"@powerhousedao/shared/clis/args\";\nimport { subcommands } from \"cmd-ts\";\nimport { getVersion } from \"../get-version.js\";\nimport { PH_CLI_DESCRIPTION } from \"../utils/constants.js\";\n\nconst version = getVersion();\nexport const phCliHelp = subcommands({\n name: \"ph-cli\",\n description: PH_CLI_DESCRIPTION,\n version,\n cmds: phCliHelpCommands,\n});\n","import { subcommands } from \"cmd-ts\";\nimport { getVersion } from \"../get-version.js\";\nimport { PH_CLI_DESCRIPTION } from \"../utils/constants.js\";\nimport { phCliCommands } from \"./ph-cli-commands.js\";\n\nconst version = getVersion();\nexport const phCli = subcommands({\n name: \"ph-cli\",\n description: PH_CLI_DESCRIPTION,\n version,\n cmds: phCliCommands,\n});\n","import { yellow, bold } from \"colorette\";\n\nconst UNRECOVERABLE_DB_PATTERNS: RegExp[] = [\n /Database migration failed:/i,\n /Migration .* failed/i,\n /relation \"[^\"]+\" already exists/i,\n /column \"[^\"]+\" does not exist/i,\n /schema \"reactor\" does not exist/i,\n /Unsupported PGLite data dir/i,\n /PG_VERSION/i,\n];\n\nfunction collectMessages(err: unknown): string[] {\n const messages: string[] = [];\n let current: unknown = err;\n const seen = new Set<unknown>();\n while (current && !seen.has(current)) {\n seen.add(current);\n if (current instanceof Error) {\n messages.push(current.message);\n current = (current as Error & { cause?: unknown }).cause;\n } else {\n messages.push(\n typeof current === \"string\" ? current : JSON.stringify(current),\n );\n break;\n }\n }\n return messages;\n}\n\nexport function isUnrecoverableDbError(err: unknown): boolean {\n const messages = collectMessages(err);\n return messages.some((msg) =>\n UNRECOVERABLE_DB_PATTERNS.some((re) => re.test(msg)),\n );\n}\n\nexport function printDbRecoveryHint(err: unknown): void {\n const messages = collectMessages(err);\n const offending = messages.find((msg) =>\n UNRECOVERABLE_DB_PATTERNS.some((re) => re.test(msg)),\n );\n console.error(\"\");\n console.error(\n yellow(bold(\"Switchboard hit an unrecoverable database error.\")),\n );\n if (offending) {\n console.error(yellow(` ${offending}`));\n }\n console.error(\"\");\n console.error(\n yellow(\"If this is a local PGlite store, you can reset it with:\"),\n );\n console.error(yellow(\" ph run switchboard reset\"));\n console.error(\n yellow(\n \"This is destructive: it wipes the local .ph/reactor-storage and .ph/read-storage directories.\",\n ),\n );\n console.error(\n yellow(\n \"For Postgres-backed deployments (PH_REACTOR_DATABASE_URL / DATABASE_URL), reset the database manually instead.\",\n ),\n );\n console.error(\"\");\n}\n","#!/usr/bin/env node\nimport {\n initCliTelemetry,\n type TelemetryClient,\n} from \"@powerhousedao/shared/clis/telemetry\";\nimport { assertNodeVersion } from \"@powerhousedao/shared/clis/utils\";\nimport { run, runSafely } from \"cmd-ts\";\nimport { phCliHelp } from \"./commands/ph-cli-help.js\";\nimport { phCli } from \"./commands/ph-cli.js\";\nimport { getVersion } from \"./get-version.js\";\nimport {\n isUnrecoverableDbError,\n printDbRecoveryHint,\n} from \"./utils/db-error-hint.js\";\n\nlet sentryClient: TelemetryClient | undefined = undefined;\n\n// Commands whose second positional is itself a subcommand (vs. a project\n// name / file path). Keeping this explicit avoids high-cardinality tag\n// values like `subcommand:my-package` polluting Sentry.\nconst COMMANDS_WITH_SUBCOMMANDS = new Set([\"connect\", \"host\", \"model\"]);\n\nfunction detectPackageManager(): string | undefined {\n // npm, pnpm, yarn and bun all set npm_config_user_agent like\n // \"pnpm/8.5.0 npm/? node/v20.11.1 darwin arm64\". When the user invokes\n // `ph` directly (not via dlx/exec) it's typically unset — skip the tag\n // in that case rather than mislabel.\n const ua = process.env.npm_config_user_agent;\n if (!ua) return undefined;\n return ua.split(\" \")[0]?.split(\"/\")[0] || undefined;\n}\n\n/**\n * `ph model` exits 1 only for invalid models, so an argument error or a crash\n * the command could not report itself, such as its lazy import failing, is 2.\n */\nasync function runModelCli(\n cli: Parameters<typeof runSafely>[0],\n args: string[],\n): Promise<void> {\n try {\n const result = await runSafely(cli, args);\n if (result._tag === \"error\") {\n const { exitCode, message, into } = result.error.config;\n (into === \"stdout\" ? console.log : console.error)(message);\n process.exitCode = exitCode === 1 ? 2 : exitCode;\n }\n } catch (error) {\n await sentryClient?.captureCliError(error);\n console.error(error instanceof Error ? error.message : String(error));\n process.exitCode = 2;\n }\n}\n\nasync function main() {\n assertNodeVersion();\n // Retired env switches: warns, or refuses to start, per the shared table.\n const { checkRetiredFlags } =\n await import(\"@powerhousedao/shared/clis/retired-flags\");\n checkRetiredFlags();\n // Env switches that still work and go in the next release: warns only.\n const { checkDeprecatedFlags } =\n await import(\"@powerhousedao/shared/clis/deprecations\");\n checkDeprecatedFlags();\n // Initializes Sentry only if user consented (opt-out by default, asked\n // once on first interactive run). Respects PH_NO_TELEMETRY/DO_NOT_TRACK.\n sentryClient = await initCliTelemetry({\n cliName: \"ph-cli\",\n release: getVersion(),\n });\n const typed = process.argv.slice(2);\n // `ph vetra`, `ph connect` and `ph switchboard` run the host of that name:\n // refused here in a project without it, and for the flags `ph run` lacks.\n const { sugarError } = await import(\"./utils/sugar-checks.js\");\n const refused = await sugarError(typed, process.cwd());\n if (refused !== undefined) throw new Error(refused);\n // Host sugar: `ph <host-name> [verb]` → `ph run <host-name> [verb]` when the\n // first arg names a host in this project's hosts/ folder. Built-in commands\n // always win.\n const { applyRunSugar, forwardRunnerArgv } =\n await import(\"./utils/run-sugar.js\");\n const { phCliCommands } = await import(\"./commands/ph-cli-commands.js\");\n const sugar = applyRunSugar(\n typed,\n new Set(Object.keys(phCliCommands)),\n process.cwd(),\n );\n if (sugar.warning) console.warn(sugar.warning);\n // A runner's own arguments (`ph run vetra --switchboard-port 4001`).\n const args = forwardRunnerArgv(sugar.args);\n const command = args[0];\n const subcommand =\n command &&\n COMMANDS_WITH_SUBCOMMANDS.has(command) &&\n args[1] &&\n !args[1].startsWith(\"-\")\n ? args[1]\n : undefined;\n sentryClient?.attachInvocationContext({\n command,\n subcommand,\n pm: detectPackageManager(),\n argv: args,\n cwd: process.cwd(),\n });\n const hasNoArgs = args.length === 0;\n const isHelp = args.some((arg) => arg === \"--help\" || arg === \"-h\");\n const isTopLevelHelp = isHelp && args.length === 1;\n const showTopLevelHelp = hasNoArgs || isTopLevelHelp;\n const cli = showTopLevelHelp ? phCliHelp : phCli;\n if (command === \"model\") {\n await runModelCli(cli, args);\n } else {\n await run(cli, args);\n }\n}\n\nawait main().catch(async (error) => {\n const isDebug = process.argv.slice(2).includes(\"--debug\");\n // Report to Sentry (no-op when telemetry disabled) before exiting.\n await sentryClient?.captureCliError(error);\n if (isDebug) {\n throw error;\n }\n if (error instanceof Error) {\n console.error(error.message);\n if (isUnrecoverableDbError(error)) {\n printDbRecoveryHint(error);\n }\n process.exit(1);\n } else {\n throw error;\n }\n});\n"],"names":["version"],"mappings":";;;;;;;;;;;AAAA,MAAa,qBACX;;;ACIF,MAAMA,YAAU,WAAW;AAC3B,MAAa,YAAY,YAAY;CACnC,MAAM;CACN,aAAa;CACb,SAAA;CACA,MAAM;AACR,CAAC;;;ACND,MAAM,UAAU,WAAW;AAC3B,MAAa,QAAQ,YAAY;CAC/B,MAAM;CACN,aAAa;CACb;CACA,MAAM;AACR,CAAC;;;ACTD,MAAM,4BAAsC;CAC1C;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAEA,SAAS,gBAAgB,KAAwB;CAC/C,MAAM,WAAqB,CAAC;CAC5B,IAAI,UAAmB;CACvB,MAAM,uBAAO,IAAI,IAAa;CAC9B,OAAO,WAAW,CAAC,KAAK,IAAI,OAAO,GAAG;EACpC,KAAK,IAAI,OAAO;EAChB,IAAI,mBAAmB,OAAO;GAC5B,SAAS,KAAK,QAAQ,OAAO;GAC7B,UAAW,QAAwC;EACrD,OAAO;GACL,SAAS,KACP,OAAO,YAAY,WAAW,UAAU,KAAK,UAAU,OAAO,CAChE;GACA;EACF;CACF;CACA,OAAO;AACT;AAEA,SAAgB,uBAAuB,KAAuB;CAE5D,OADiB,gBAAgB,GACnB,CAAC,CAAC,MAAM,QACpB,0BAA0B,MAAM,OAAO,GAAG,KAAK,GAAG,CAAC,CACrD;AACF;AAEA,SAAgB,oBAAoB,KAAoB;CAEtD,MAAM,YADW,gBAAgB,GACR,CAAC,CAAC,MAAM,QAC/B,0BAA0B,MAAM,OAAO,GAAG,KAAK,GAAG,CAAC,CACrD;CACA,QAAQ,MAAM,EAAE;CAChB,QAAQ,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