@powerhousedao/ph-cli 6.3.0-dev.9 → 6.4.0-next.1

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.
Files changed (123) hide show
  1. package/README.md +1 -1
  2. package/dist/{build-DuNe06I0.mjs → build-C490lBnu.mjs} +90 -18
  3. package/dist/build-C490lBnu.mjs.map +1 -0
  4. package/dist/build-DblrRe4z.mjs +4 -0
  5. package/dist/{check-EzkmRLx6.mjs → check-D84ta1Dh.mjs} +4 -4
  6. package/dist/{check-EzkmRLx6.mjs.map → check-D84ta1Dh.mjs.map} +1 -1
  7. package/dist/{check-B8oqVMg7.mjs → check-DIK1LTss.mjs} +5 -5
  8. package/dist/{check-B8oqVMg7.mjs.map → check-DIK1LTss.mjs.map} +1 -1
  9. package/dist/{check-VOIkykDt.mjs → check-F3nwJiG-.mjs} +3 -3
  10. package/dist/{cli-connect-override-D22yFWlC.mjs → cli-connect-override-BMU4Qldg.mjs} +8 -8
  11. package/dist/cli-connect-override-BMU4Qldg.mjs.map +1 -0
  12. package/dist/cli.mjs +21 -31
  13. package/dist/cli.mjs.map +1 -1
  14. package/dist/{compound-DKi56SSx-CXQHhS6t.mjs → compound-BWLJ0KBw-8hKyrfjG.mjs} +659 -276
  15. package/dist/compound-BWLJ0KBw-8hKyrfjG.mjs.map +1 -0
  16. package/dist/{connect-build-Be8C4skj.mjs → connect-build-DW1fFVbU.mjs} +6 -6
  17. package/dist/{connect-build-Be8C4skj.mjs.map → connect-build-DW1fFVbU.mjs.map} +1 -1
  18. package/dist/{connect-config-CVU4xhti.mjs → connect-config-DVubBBLb.mjs} +4 -4
  19. package/dist/{connect-config-CVU4xhti.mjs.map → connect-config-DVubBBLb.mjs.map} +1 -1
  20. package/dist/{connect-preview-CdFvlANO.mjs → connect-preview-BvxXGo_W.mjs} +7 -6
  21. package/dist/connect-preview-BvxXGo_W.mjs.map +1 -0
  22. package/dist/{connect-studio-BnfhpIv8.mjs → connect-studio-CQC-LDSg.mjs} +16 -7
  23. package/dist/connect-studio-CQC-LDSg.mjs.map +1 -0
  24. package/dist/definitions-worker.mjs +1 -1
  25. package/dist/{dist-DXcB8fAF.mjs → dist-BFMRL5C0.mjs} +52 -105
  26. package/dist/dist-BFMRL5C0.mjs.map +1 -0
  27. package/dist/{explain-8OEXF2Dy.mjs → explain-YPD3n6t8.mjs} +67 -21
  28. package/dist/explain-YPD3n6t8.mjs.map +1 -0
  29. package/dist/{export-DqbcbFU5.mjs → export-DjQL6zkr.mjs} +5 -5
  30. package/dist/{export-DqbcbFU5.mjs.map → export-DjQL6zkr.mjs.map} +1 -1
  31. package/dist/{generate-all-0YOnlZM0.mjs → generate-all-BLot_H9Z.mjs} +4 -4
  32. package/dist/{generate-all-0YOnlZM0.mjs.map → generate-all-BLot_H9Z.mjs.map} +1 -1
  33. package/dist/{generate-desktop-shell-BovoRsR6.mjs → generate-desktop-shell-CTrfzM9P.mjs} +6 -16
  34. package/dist/generate-desktop-shell-CTrfzM9P.mjs.map +1 -0
  35. package/dist/{get-version-JkZQOcO1.mjs → get-version-CcYVboCW.mjs} +4 -4
  36. package/dist/{get-version-JkZQOcO1.mjs.map → get-version-CcYVboCW.mjs.map} +1 -1
  37. package/dist/{index-H3AYe65i.d.mts → index-D3H9pQ8u.d.mts} +58 -4
  38. package/dist/index-D3H9pQ8u.d.mts.map +1 -0
  39. package/dist/{init-Ltg4cJzm.mjs → init-IQ0VS0JK.mjs} +4 -4
  40. package/dist/{init-Ltg4cJzm.mjs.map → init-IQ0VS0JK.mjs.map} +1 -1
  41. package/dist/{inspect-zWJnBDMJ.mjs → inspect-Bxa9y7zM.mjs} +4 -4
  42. package/dist/{inspect-zWJnBDMJ.mjs.map → inspect-Bxa9y7zM.mjs.map} +1 -1
  43. package/dist/{mcp-vSCc5KHI.mjs → mcp-B3l1mtBq.mjs} +7 -7
  44. package/dist/mcp-B3l1mtBq.mjs.map +1 -0
  45. package/dist/{migrate-C27-tFFC.mjs → migrate-CzcBEypc.mjs} +6 -6
  46. package/dist/{migrate-C27-tFFC.mjs.map → migrate-CzcBEypc.mjs.map} +1 -1
  47. package/dist/{migrate-document-models-CKnqQnRh.mjs → migrate-document-models-D0HSo4WN.mjs} +4 -4
  48. package/dist/{migrate-document-models-CKnqQnRh.mjs.map → migrate-document-models-D0HSo4WN.mjs.map} +1 -1
  49. package/dist/{migrate-subgraphs-B2nTiJ-j.mjs → migrate-subgraphs-CfSMlcJD.mjs} +55 -15
  50. package/dist/migrate-subgraphs-CfSMlcJD.mjs.map +1 -0
  51. package/dist/migrate-subgraphs-Hc5w9Mpk.mjs +4 -0
  52. package/dist/{ph-cli-commands-DhoNXWGf.mjs → ph-cli-commands-CQXdWQ74.mjs} +52 -184
  53. package/dist/ph-cli-commands-CQXdWQ74.mjs.map +1 -0
  54. package/dist/ph-cli-commands-YE0ciOSX.mjs +4 -0
  55. package/dist/run-sugar-BfnRBv7h.mjs +4 -0
  56. package/dist/run-sugar-hGKprsKz.mjs +96 -0
  57. package/dist/run-sugar-hGKprsKz.mjs.map +1 -0
  58. package/dist/runners/connect.d.mts +2 -2
  59. package/dist/runners/connect.d.mts.map +1 -1
  60. package/dist/runners/connect.mjs +30 -18
  61. package/dist/runners/connect.mjs.map +1 -1
  62. package/dist/runners/switchboard.d.mts +3 -3
  63. package/dist/runners/switchboard.mjs +11 -11
  64. package/dist/runners/switchboard.mjs.map +1 -1
  65. package/dist/scripts/generate-commands-docs.ts +3 -7
  66. package/dist/service-args-D6y3L0bm.mjs +49 -0
  67. package/dist/service-args-D6y3L0bm.mjs.map +1 -0
  68. package/dist/sugar-checks-CTCsK5DJ.mjs +175 -0
  69. package/dist/sugar-checks-CTCsK5DJ.mjs.map +1 -0
  70. package/dist/{switchboard-reset-MtTB_GAI.mjs → switchboard-reset-BP7KwUc_.mjs} +5 -5
  71. package/dist/switchboard-reset-BP7KwUc_.mjs.map +1 -0
  72. package/dist/utils-BU25LHRE.mjs +4 -0
  73. package/dist/{utils-9KyRM0mf.mjs → utils-D5VlY5AZ.mjs} +4 -15
  74. package/dist/utils-D5VlY5AZ.mjs.map +1 -0
  75. package/dist/{verify-DCf_nRt8.mjs → verify-NK6a_7j8.mjs} +4 -4
  76. package/dist/{verify-DCf_nRt8.mjs.map → verify-NK6a_7j8.mjs.map} +1 -1
  77. package/dist/vetra-gateway-Bpe50oGk.mjs +4 -0
  78. package/dist/vetra-gateway-BxcduYAI.mjs +173 -0
  79. package/dist/vetra-gateway-BxcduYAI.mjs.map +1 -0
  80. package/dist/{vetra-host-ChTpJiBJ.mjs → vetra-host-BrLdIMRP.mjs} +24 -9
  81. package/dist/vetra-host-BrLdIMRP.mjs.map +1 -0
  82. package/dist/{vetra-instance-CzhYIjxL.mjs → vetra-instance-CPNIsaxh.mjs} +9 -17
  83. package/dist/vetra-instance-CPNIsaxh.mjs.map +1 -0
  84. package/dist/vetra-launcher-BtDWQBuh.mjs +4 -0
  85. package/dist/{vetra-launch-qi10Unax.mjs → vetra-launcher-Dokr1aDK.mjs} +14 -32
  86. package/dist/vetra-launcher-Dokr1aDK.mjs.map +1 -0
  87. package/dist/{vetra-switchboard-tzdc14KA.mjs → vetra-switchboard-Ctje6iR1.mjs} +4 -4
  88. package/dist/{vetra-switchboard-tzdc14KA.mjs.map → vetra-switchboard-Ctje6iR1.mjs.map} +1 -1
  89. package/package.json +16 -16
  90. package/dist/build-CnTFRBft.mjs +0 -4
  91. package/dist/build-DuNe06I0.mjs.map +0 -1
  92. package/dist/classic-args-mH_DVsgC.mjs +0 -48
  93. package/dist/classic-args-mH_DVsgC.mjs.map +0 -1
  94. package/dist/classic-warnings-BR0S6lr5.mjs +0 -179
  95. package/dist/classic-warnings-BR0S6lr5.mjs.map +0 -1
  96. package/dist/cli-connect-override-D22yFWlC.mjs.map +0 -1
  97. package/dist/compound-DKi56SSx-CXQHhS6t.mjs.map +0 -1
  98. package/dist/connect-preview-CdFvlANO.mjs.map +0 -1
  99. package/dist/connect-studio-BnfhpIv8.mjs.map +0 -1
  100. package/dist/connect-studio-D58ByAAn.mjs +0 -4
  101. package/dist/dist-DXcB8fAF.mjs.map +0 -1
  102. package/dist/explain-8OEXF2Dy.mjs.map +0 -1
  103. package/dist/generate-desktop-shell-BovoRsR6.mjs.map +0 -1
  104. package/dist/index-H3AYe65i.d.mts.map +0 -1
  105. package/dist/mcp-vSCc5KHI.mjs.map +0 -1
  106. package/dist/migrate-subgraphs-B1_NRwV7.mjs +0 -4
  107. package/dist/migrate-subgraphs-B2nTiJ-j.mjs.map +0 -1
  108. package/dist/ph-cli-commands-DhoNXWGf.mjs.map +0 -1
  109. package/dist/ph-cli-commands-LIME9alJ.mjs +0 -4
  110. package/dist/run-sugar-DpznOP1e.mjs +0 -56
  111. package/dist/run-sugar-DpznOP1e.mjs.map +0 -1
  112. package/dist/scripts/manage-environment +0 -199
  113. package/dist/scripts/setup-environment +0 -423
  114. package/dist/scripts/setup-environment.ps1 +0 -313
  115. package/dist/switchboard-reset-MtTB_GAI.mjs.map +0 -1
  116. package/dist/utils-9KyRM0mf.mjs.map +0 -1
  117. package/dist/utils-TO9lB8Xs.mjs +0 -4
  118. package/dist/vetra-CVNZ46pK.mjs +0 -352
  119. package/dist/vetra-CVNZ46pK.mjs.map +0 -1
  120. package/dist/vetra-host-ChTpJiBJ.mjs.map +0 -1
  121. package/dist/vetra-instance-CzhYIjxL.mjs.map +0 -1
  122. package/dist/vetra-launch-qi10Unax.mjs.map +0 -1
  123. package/dist/vetra-switchboard-BrkozIm7.mjs +0 -4
@@ -1,7 +1,7 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="0de87e24-afd6-5e67-bda7-2d34eb9241c2")}catch(e){}}();
3
- import { A as normalizePluginEntries, h as entryActiveForVerb, j as normalizePluginEntry } from "../compound-DKi56SSx-CXQHhS6t.mjs";
4
- import { s as projectDriveId, u as resolveDriveDeclaration } from "../dist-DXcB8fAF.mjs";
2
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="76083e3e-dd9e-51c9-8041-2c590c0d60cc")}catch(e){}}();
3
+ import { F as normalizePluginEntries, I as normalizePluginEntry, g as entryActiveForVerb } from "../compound-BWLJ0KBw-8hKyrfjG.mjs";
4
+ import { o as projectDriveId, s as resolveDriveDeclaration } from "../dist-BFMRL5C0.mjs";
5
5
  import { DEFAULT_SWITCHBOARD_PORT } from "@powerhousedao/shared/clis/constants";
6
6
  import { VETRA_PROCESSOR_CONFIG_KEY } from "@powerhousedao/config";
7
7
  import { dev as dev$1, run as run$1 } from "@powerhousedao/ph-run/runners/switchboard";
@@ -19,9 +19,9 @@ const verbs = [
19
19
  /** Build the project's reactor package (the SAME service as `ph build`) — what
20
20
  * this switchboard serves. Starts no server; orthogonal to run/serve/dev. */
21
21
  async function build(host, _ctx) {
22
- const { runBuild } = await import("../build-CnTFRBft.mjs");
23
- const { classicBuildArgs } = await import("../classic-args-mH_DVsgC.mjs");
24
- const classic = await classicBuildArgs();
22
+ const { runBuild } = await import("../build-DblrRe4z.mjs");
23
+ const { buildServiceArgs } = await import("../service-args-D6y3L0bm.mjs");
24
+ const classic = await buildServiceArgs();
25
25
  await runBuild({
26
26
  ...classic,
27
27
  outDir: host.runner.outDir ?? classic.outDir
@@ -49,11 +49,11 @@ async function runMigrations(host, ctx, statusOnly) {
49
49
  statusOnly
50
50
  });
51
51
  }
52
- /** `ph switchboard --migrate`: run the reactor store's migrations. */
52
+ /** `ph run switchboard migrate`: run the reactor store's migrations. */
53
53
  async function migrate(host, ctx) {
54
54
  await runMigrations(host, ctx, void 0);
55
55
  }
56
- /** `ph switchboard --migrate-status`: list them, executed or pending. */
56
+ /** `ph run switchboard migrate-status`: list them, executed or pending. */
57
57
  async function migrateStatus(host, ctx) {
58
58
  await runMigrations(host, ctx, true);
59
59
  }
@@ -91,7 +91,7 @@ async function withStoreEnv(stores, work) {
91
91
  async function reset(host, ctx) {
92
92
  const stores = await storesOf(host, ctx);
93
93
  const passed = await passedOf(host, ctx);
94
- const { resetSwitchboardDatabase } = await import("../switchboard-reset-MtTB_GAI.mjs");
94
+ const { resetSwitchboardDatabase } = await import("../switchboard-reset-BP7KwUc_.mjs");
95
95
  await withStoreEnv(stores, () => resetSwitchboardDatabase({
96
96
  dbPath: passed.dbPath,
97
97
  yes: passed.yes
@@ -137,7 +137,7 @@ async function startVetraSwitchboard(host, ctx, start) {
137
137
  const remoteDrive = passed.remoteDrive ?? (vetraDrive?.kind === "remote" ? vetraDrive.remoteUrl : void 0);
138
138
  const localDriveId = vetraDrive?.slug ?? projectDriveId(ctx.projectRoot, VETRA_DRIVE);
139
139
  const requestedPort = passed.port ?? host.runner.port ?? DEFAULT_SWITCHBOARD_PORT;
140
- const { configureVetraRemoteDrive, printVetraSwitchboardUrls, vetraProcessorConfigOf } = await import("../vetra-switchboard-BrkozIm7.mjs");
140
+ const { configureVetraRemoteDrive, printVetraSwitchboardUrls, vetraProcessorConfigOf } = await import("../vetra-switchboard-Ctje6iR1.mjs");
141
141
  const vetraConfig = vetraProcessorConfigOf({
142
142
  interactive: passed.interactive ?? false,
143
143
  remoteDrive,
@@ -175,4 +175,4 @@ const dev = vetraAware(dev$1);
175
175
  export { build, dev, migrate, migrateStatus as "migrate-status", reset, run, serve, verbs };
176
176
 
177
177
  //# sourceMappingURL=switchboard.mjs.map
178
- //# debugId=0de87e24-afd6-5e67-bda7-2d34eb9241c2
178
+ //# debugId=76083e3e-dd9e-51c9-8041-2c590c0d60cc
@@ -1 +1 @@
1
- {"version":3,"file":"switchboard.mjs","sources":["../../src/runners/switchboard.ts"],"sourcesContent":["import { VETRA_PROCESSOR_CONFIG_KEY } from \"@powerhousedao/config\";\nimport {\n dev as startDev,\n run as startRun,\n type SwitchboardHandle,\n type SwitchboardHostParsed,\n type SwitchboardStores,\n} from \"@powerhousedao/ph-run/runners/switchboard\";\nimport {\n entryActiveForVerb,\n normalizePluginEntries,\n normalizePluginEntry,\n projectDriveId,\n resolveDriveDeclaration,\n type RunnerContext,\n} from \"@powerhousedao/host-core\";\nimport { DEFAULT_SWITCHBOARD_PORT } from \"@powerhousedao/shared/clis/constants\";\n\nexport * from \"@powerhousedao/ph-run/runners/switchboard\";\n\nexport const verbs = [\n \"run\",\n \"serve\",\n \"dev\",\n \"build\",\n \"migrate\",\n \"migrate-status\",\n \"reset\",\n];\n\n/** Build the project's reactor package (the SAME service as `ph build`) — what\n * this switchboard serves. Starts no server; orthogonal to run/serve/dev. */\nexport async function build(\n host: SwitchboardHostParsed,\n _ctx: RunnerContext,\n): Promise<void> {\n const { runBuild } = await import(\"../services/build.js\");\n const { classicBuildArgs } = await import(\"../services/classic-args.js\");\n // The classic `ph build` arguments, with the host's output dir over them.\n const classic = await classicBuildArgs();\n await runBuild({\n ...classic,\n outDir: host.runner.outDir ?? classic.outDir,\n });\n}\n\n// `migrate`, `migrate-status` and `reset` are the classic `ph switchboard`\n// flags of those names as verbs: the SAME services, called with the classic\n// argument shape, against the stores `run` would open for this host. Each\n// does its work and returns nothing; no server starts.\n\n/** The stores `run` would open for this host (host file, then env). */\nasync function storesOf(\n host: SwitchboardHostParsed,\n ctx: RunnerContext,\n): Promise<SwitchboardStores> {\n const { resolveStores } =\n await import(\"@powerhousedao/ph-run/runners/switchboard\");\n return resolveStores(host, ctx);\n}\n\n/** This invocation's arguments (`--db-path`, `--yes`), as `run` reads them. */\nasync function passedOf(host: SwitchboardHostParsed, ctx: RunnerContext) {\n const { invocationArgsOf } =\n await import(\"@powerhousedao/ph-run/runners/switchboard\");\n return invocationArgsOf(ctx, `hosts/${host.name}/host.js`);\n}\n\n/** The service migrates one database, the reactor store: `dbPath` names it\n * (`--db-path` over the host's). Unset, the service falls back to the env as\n * it does under `ph switchboard`. */\nasync function runMigrations(\n host: SwitchboardHostParsed,\n ctx: RunnerContext,\n statusOnly: true | undefined,\n): Promise<void> {\n const stores = await storesOf(host, ctx);\n const passed = await passedOf(host, ctx);\n const { runSwitchboardMigrations } =\n await import(\"../services/switchboard-migrate.js\");\n await runSwitchboardMigrations({\n dbPath: passed.dbPath ?? stores.reactor,\n statusOnly,\n });\n}\n\n/** `ph switchboard --migrate`: run the reactor store's migrations. */\nexport async function migrate(\n host: SwitchboardHostParsed,\n ctx: RunnerContext,\n): Promise<void> {\n await runMigrations(host, ctx, undefined);\n}\n\n/** `ph switchboard --migrate-status`: list them, executed or pending. */\nasync function migrateStatus(\n host: SwitchboardHostParsed,\n ctx: RunnerContext,\n): Promise<void> {\n await runMigrations(host, ctx, true);\n}\nexport { migrateStatus as \"migrate-status\" };\n\nconst STORE_ENV = [\n \"PH_REACTOR_DATABASE_URL\",\n \"DATABASE_URL\",\n \"PH_SWITCHBOARD_DATABASE_URL\",\n \"PH_USER_DATA_DIR\",\n] as const;\n\n/** The reset service reads the two stores from this process's env (`dbPath`\n * names one location for both), so the host's stores are that env while it\n * runs, and only then. */\nasync function withStoreEnv(\n stores: SwitchboardStores,\n work: () => Promise<void>,\n): Promise<void> {\n const values: Record<(typeof STORE_ENV)[number], string | undefined> = {\n PH_REACTOR_DATABASE_URL: stores.reactor,\n DATABASE_URL: stores.readModel,\n // Already in the two above, where the env set it.\n PH_SWITCHBOARD_DATABASE_URL: undefined,\n PH_USER_DATA_DIR: stores.userDataDir,\n };\n const before = STORE_ENV.map((name) => [name, process.env[name]] as const);\n const set = (name: string, value: string | undefined) => {\n if (value === undefined) delete process.env[name];\n else process.env[name] = value;\n };\n for (const name of STORE_ENV) set(name, values[name]);\n try {\n await work();\n } finally {\n for (const [name, value] of before) set(name, value);\n }\n}\n\n/** `ph switchboard --reset`: delete the local PGlite stores, after the\n * service's own confirmation (`--yes` skips it; without a terminal the\n * service refuses unless it is passed). It refuses a Postgres store. */\nexport async function reset(\n host: SwitchboardHostParsed,\n ctx: RunnerContext,\n): Promise<void> {\n const stores = await storesOf(host, ctx);\n const passed = await passedOf(host, ctx);\n const { resetSwitchboardDatabase } =\n await import(\"../services/switchboard-reset.js\");\n await withStoreEnv(stores, () =>\n resetSwitchboardDatabase({ dbPath: passed.dbPath, yes: passed.yes }),\n );\n}\n\n// A switchboard whose composition has the Vetra Studio plugin active is the\n// VETRA switchboard (`ph run vetra`): it gets what classic `ph vetra` gives\n// its switchboard, from the same code (services/vetra-switchboard.ts). Any\n// other switchboard starts exactly as the ph-run runner starts it.\n\nconst STUDIO_PLUGIN = \"@powerhousedao/vetra-studio/switchboard\";\n/** The declared slugs of the studio drives (hosts/vetra/host.js). */\nconst VETRA_DRIVE = \"vetra\";\nconst VETRA_PREVIEW_DRIVE = \"vetra-preview\";\nconst WORKFLOWS_DRIVE = \"workflows\";\n\ntype StartVerb = (\n host: SwitchboardHostParsed,\n ctx: RunnerContext,\n) => Promise<SwitchboardHandle>;\n\nfunction hasStudioPlugin(\n host: SwitchboardHostParsed,\n ctx: RunnerContext,\n): boolean {\n return normalizePluginEntries(\n host.runner.plugins ?? [],\n `hosts/${host.name}/host.js`,\n ).some(\n (entry) =>\n entry.module === STUDIO_PLUGIN && entryActiveForVerb(entry, ctx.verb),\n );\n}\n\n/** The host with `processorConfig` on its studio plugin entry: the plugin\n * hands it to the server (vetra-studio switchboard.ts). */\nfunction withStudioProcessorConfig(\n host: SwitchboardHostParsed,\n processorConfig: Record<string, unknown>,\n): SwitchboardHostParsed {\n return {\n ...host,\n runner: {\n ...host.runner,\n plugins: host.runner.plugins?.map((entry) => {\n const normalized = normalizePluginEntry(entry);\n if (normalized.module !== STUDIO_PLUGIN) return entry;\n const authored = normalized.config.processorConfig as\n | Record<string, unknown>\n | undefined;\n return {\n ...normalized,\n config: {\n ...normalized.config,\n processorConfig: { ...authored, ...processorConfig },\n },\n };\n }),\n },\n };\n}\n\nasync function startVetraSwitchboard(\n host: SwitchboardHostParsed,\n ctx: RunnerContext,\n start: StartVerb,\n): Promise<SwitchboardHandle> {\n const passed = await passedOf(host, ctx);\n const declared = host.reactor?.drives?.find(\n (drive) => drive.slug === VETRA_DRIVE,\n );\n const vetraDrive = declared\n ? resolveDriveDeclaration(ctx.projectRoot, declared)\n : undefined;\n // `--remote-drive`, else a vetra drive the host declares as remote.\n const remoteDrive =\n passed.remoteDrive ??\n (vetraDrive?.kind === \"remote\" ? vetraDrive.remoteUrl : undefined);\n // The slug the local vetra drive is served under (its project-hashed id).\n const localDriveId =\n vetraDrive?.slug ?? projectDriveId(ctx.projectRoot, VETRA_DRIVE);\n const requestedPort =\n passed.port ?? host.runner.port ?? DEFAULT_SWITCHBOARD_PORT;\n const {\n configureVetraRemoteDrive,\n printVetraSwitchboardUrls,\n vetraProcessorConfigOf,\n } = await import(\"../services/vetra-switchboard.js\");\n const vetraConfig = vetraProcessorConfigOf({\n interactive: passed.interactive ?? false,\n remoteDrive,\n localDriveUrl: `http://localhost:${requestedPort}/d/${localDriveId}`,\n localDriveId,\n });\n\n const handle = await start(\n withStudioProcessorConfig(host, {\n [VETRA_PROCESSOR_CONFIG_KEY]: vetraConfig,\n }),\n ctx,\n );\n\n const { origin, drives } = handle.outputs;\n const port = Number(new URL(origin).port);\n const urlOf = (slug: string): string | undefined =>\n slug in drives ? drives[slug].url : undefined;\n // A compound starts Connect after `ready`: the URLs print, and the remote\n // drive's GitHub URL is settled, before it does (the classic order).\n const ready = handle.ready.then(async () => {\n printVetraSwitchboardUrls({\n verbose: false,\n remoteDrive,\n switchboardPort: port,\n // A remote drive is served here under its own id.\n driveUrl: remoteDrive\n ? `${origin}/d/${vetraConfig.driveId}`\n : urlOf(VETRA_DRIVE),\n previewDriveUrl: urlOf(VETRA_PREVIEW_DRIVE),\n workflowsDriveUrl: urlOf(WORKFLOWS_DRIVE),\n });\n if (remoteDrive) {\n await configureVetraRemoteDrive(port, remoteDrive, false);\n }\n });\n // As the ph-run runner's own `ready`: an unsupervised caller must not die\n // of an unhandled rejection.\n ready.catch(() => undefined);\n return { ...handle, ready };\n}\n\nfunction vetraAware(start: StartVerb): StartVerb {\n return (host, ctx) =>\n hasStudioPlugin(host, ctx)\n ? startVetraSwitchboard(host, ctx, start)\n : start(host, ctx);\n}\n\nexport const run = vetraAware(startRun);\n\nexport const serve = run;\n\nexport const dev = vetraAware(startDev);\n"],"names":["startRun","startDev"],"mappings":";;;;;;;;;AAoBA,MAAa,QAAQ;CACnB;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;AAIA,eAAsB,MACpB,MACA,MACe;CACf,MAAM,EAAE,aAAa,MAAM,OAAO;CAClC,MAAM,EAAE,qBAAqB,MAAM,OAAO;CAE1C,MAAM,UAAU,MAAM,iBAAiB;CACvC,MAAM,SAAS;EACb,GAAG;EACH,QAAQ,KAAK,OAAO,UAAU,QAAQ;CACxC,CAAC;AACH;;AAQA,eAAe,SACb,MACA,KAC4B;CAC5B,MAAM,EAAE,kBACN,MAAM,OAAO;CACf,OAAO,cAAc,MAAM,GAAG;AAChC;;AAGA,eAAe,SAAS,MAA6B,KAAoB;CACvE,MAAM,EAAE,qBACN,MAAM,OAAO;CACf,OAAO,iBAAiB,KAAK,SAAS,KAAK,KAAK,SAAS;AAC3D;;;;AAKA,eAAe,cACb,MACA,KACA,YACe;CACf,MAAM,SAAS,MAAM,SAAS,MAAM,GAAG;CACvC,MAAM,SAAS,MAAM,SAAS,MAAM,GAAG;CACvC,MAAM,EAAE,6BACN,MAAM,OAAO;CACf,MAAM,yBAAyB;EAC7B,QAAQ,OAAO,UAAU,OAAO;EAChC;CACF,CAAC;AACH;;AAGA,eAAsB,QACpB,MACA,KACe;CACf,MAAM,cAAc,MAAM,KAAK,KAAA,CAAS;AAC1C;;AAGA,eAAe,cACb,MACA,KACe;CACf,MAAM,cAAc,MAAM,KAAK,IAAI;AACrC;AAGA,MAAM,YAAY;CAChB;CACA;CACA;CACA;AACF;;;;AAKA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EAAQ;CAAM;AAC5B;AAEA,SAAS,WAAW,OAA6B;CAC/C,QAAQ,MAAM,QACZ,gBAAgB,MAAM,GAAG,IACrB,sBAAsB,MAAM,KAAK,KAAK,IACtC,MAAM,MAAM,GAAG;AACvB;AAEA,MAAa,MAAM,WAAWA,KAAQ;AAEtC,MAAa,QAAQ;AAErB,MAAa,MAAM,WAAWC,KAAQ","debug_id":"0de87e24-afd6-5e67-bda7-2d34eb9241c2"}
1
+ {"version":3,"file":"switchboard.mjs","sources":["../../src/runners/switchboard.ts"],"sourcesContent":["import { VETRA_PROCESSOR_CONFIG_KEY } from \"@powerhousedao/config\";\nimport {\n dev as startDev,\n run as startRun,\n type SwitchboardHandle,\n type SwitchboardHostParsed,\n type SwitchboardStores,\n} from \"@powerhousedao/ph-run/runners/switchboard\";\nimport {\n entryActiveForVerb,\n normalizePluginEntries,\n normalizePluginEntry,\n projectDriveId,\n resolveDriveDeclaration,\n type RunnerContext,\n} from \"@powerhousedao/host-core\";\nimport { DEFAULT_SWITCHBOARD_PORT } from \"@powerhousedao/shared/clis/constants\";\n\nexport * from \"@powerhousedao/ph-run/runners/switchboard\";\n\nexport const verbs = [\n \"run\",\n \"serve\",\n \"dev\",\n \"build\",\n \"migrate\",\n \"migrate-status\",\n \"reset\",\n];\n\n/** Build the project's reactor package (the SAME service as `ph build`) — what\n * this switchboard serves. Starts no server; orthogonal to run/serve/dev. */\nexport async function build(\n host: SwitchboardHostParsed,\n _ctx: RunnerContext,\n): Promise<void> {\n const { runBuild } = await import(\"../services/build.js\");\n const { buildServiceArgs } = await import(\"../services/service-args.js\");\n // The `ph build` arguments, with the host's output dir over them.\n const classic = await buildServiceArgs();\n await runBuild({\n ...classic,\n outDir: host.runner.outDir ?? classic.outDir,\n });\n}\n\n// `migrate`, `migrate-status` and `reset` were `ph switchboard` flags of\n// those names until 6.4, and are verbs now: the SAME services, called with\n// the same argument shape, against the stores `run` would open for this host. Each\n// does its work and returns nothing; no server starts.\n\n/** The stores `run` would open for this host (host file, then env). */\nasync function storesOf(\n host: SwitchboardHostParsed,\n ctx: RunnerContext,\n): Promise<SwitchboardStores> {\n const { resolveStores } =\n await import(\"@powerhousedao/ph-run/runners/switchboard\");\n return resolveStores(host, ctx);\n}\n\n/** This invocation's arguments (`--db-path`, `--yes`), as `run` reads them. */\nasync function passedOf(host: SwitchboardHostParsed, ctx: RunnerContext) {\n const { invocationArgsOf } =\n await import(\"@powerhousedao/ph-run/runners/switchboard\");\n return invocationArgsOf(ctx, `hosts/${host.name}/host.js`);\n}\n\n/** The service migrates one database, the reactor store: `dbPath` names it\n * (`--db-path` over the host's). Unset, the service falls back to the env as\n * it does under `ph switchboard`. */\nasync function runMigrations(\n host: SwitchboardHostParsed,\n ctx: RunnerContext,\n statusOnly: true | undefined,\n): Promise<void> {\n const stores = await storesOf(host, ctx);\n const passed = await passedOf(host, ctx);\n const { runSwitchboardMigrations } =\n await import(\"../services/switchboard-migrate.js\");\n await runSwitchboardMigrations({\n dbPath: passed.dbPath ?? stores.reactor,\n statusOnly,\n });\n}\n\n/** `ph run switchboard migrate`: run the reactor store's migrations. */\nexport async function migrate(\n host: SwitchboardHostParsed,\n ctx: RunnerContext,\n): Promise<void> {\n await runMigrations(host, ctx, undefined);\n}\n\n/** `ph run switchboard migrate-status`: list them, executed or pending. */\nasync function migrateStatus(\n host: SwitchboardHostParsed,\n ctx: RunnerContext,\n): Promise<void> {\n await runMigrations(host, ctx, true);\n}\nexport { migrateStatus as \"migrate-status\" };\n\nconst STORE_ENV = [\n \"PH_REACTOR_DATABASE_URL\",\n \"DATABASE_URL\",\n \"PH_SWITCHBOARD_DATABASE_URL\",\n \"PH_USER_DATA_DIR\",\n] as const;\n\n/** The reset service reads the two stores from this process's env (`dbPath`\n * names one location for both), so the host's stores are that env while it\n * runs, and only then. */\nasync function withStoreEnv(\n stores: SwitchboardStores,\n work: () => Promise<void>,\n): Promise<void> {\n const values: Record<(typeof STORE_ENV)[number], string | undefined> = {\n PH_REACTOR_DATABASE_URL: stores.reactor,\n DATABASE_URL: stores.readModel,\n // Already in the two above, where the env set it.\n PH_SWITCHBOARD_DATABASE_URL: undefined,\n PH_USER_DATA_DIR: stores.userDataDir,\n };\n const before = STORE_ENV.map((name) => [name, process.env[name]] as const);\n const set = (name: string, value: string | undefined) => {\n if (value === undefined) delete process.env[name];\n else process.env[name] = value;\n };\n for (const name of STORE_ENV) set(name, values[name]);\n try {\n await work();\n } finally {\n for (const [name, value] of before) set(name, value);\n }\n}\n\n/** `ph switchboard --reset`: delete the local PGlite stores, after the\n * service's own confirmation (`--yes` skips it; without a terminal the\n * service refuses unless it is passed). It refuses a Postgres store. */\nexport async function reset(\n host: SwitchboardHostParsed,\n ctx: RunnerContext,\n): Promise<void> {\n const stores = await storesOf(host, ctx);\n const passed = await passedOf(host, ctx);\n const { resetSwitchboardDatabase } =\n await import(\"../services/switchboard-reset.js\");\n await withStoreEnv(stores, () =>\n resetSwitchboardDatabase({ dbPath: passed.dbPath, yes: passed.yes }),\n );\n}\n\n// A switchboard whose composition has the Vetra Studio plugin active is the\n// VETRA switchboard (`ph run vetra`): it gets the vetra drive and the studio\n// wiring of services/vetra-switchboard.ts. Any\n// other switchboard starts exactly as the ph-run runner starts it.\n\nconst STUDIO_PLUGIN = \"@powerhousedao/vetra-studio/switchboard\";\n/** The declared slugs of the studio drives (hosts/vetra/host.js). */\nconst VETRA_DRIVE = \"vetra\";\nconst VETRA_PREVIEW_DRIVE = \"vetra-preview\";\nconst WORKFLOWS_DRIVE = \"workflows\";\n\ntype StartVerb = (\n host: SwitchboardHostParsed,\n ctx: RunnerContext,\n) => Promise<SwitchboardHandle>;\n\nfunction hasStudioPlugin(\n host: SwitchboardHostParsed,\n ctx: RunnerContext,\n): boolean {\n return normalizePluginEntries(\n host.runner.plugins ?? [],\n `hosts/${host.name}/host.js`,\n ).some(\n (entry) =>\n entry.module === STUDIO_PLUGIN && entryActiveForVerb(entry, ctx.verb),\n );\n}\n\n/** The host with `processorConfig` on its studio plugin entry: the plugin\n * hands it to the server (vetra-studio switchboard.ts). */\nfunction withStudioProcessorConfig(\n host: SwitchboardHostParsed,\n processorConfig: Record<string, unknown>,\n): SwitchboardHostParsed {\n return {\n ...host,\n runner: {\n ...host.runner,\n plugins: host.runner.plugins?.map((entry) => {\n const normalized = normalizePluginEntry(entry);\n if (normalized.module !== STUDIO_PLUGIN) return entry;\n const authored = normalized.config.processorConfig as\n | Record<string, unknown>\n | undefined;\n return {\n ...normalized,\n config: {\n ...normalized.config,\n processorConfig: { ...authored, ...processorConfig },\n },\n };\n }),\n },\n };\n}\n\nasync function startVetraSwitchboard(\n host: SwitchboardHostParsed,\n ctx: RunnerContext,\n start: StartVerb,\n): Promise<SwitchboardHandle> {\n const passed = await passedOf(host, ctx);\n const declared = host.reactor?.drives?.find(\n (drive) => drive.slug === VETRA_DRIVE,\n );\n const vetraDrive = declared\n ? resolveDriveDeclaration(ctx.projectRoot, declared)\n : undefined;\n // `--remote-drive`, else a vetra drive the host declares as remote.\n const remoteDrive =\n passed.remoteDrive ??\n (vetraDrive?.kind === \"remote\" ? vetraDrive.remoteUrl : undefined);\n // The slug the local vetra drive is served under (its project-hashed id).\n const localDriveId =\n vetraDrive?.slug ?? projectDriveId(ctx.projectRoot, VETRA_DRIVE);\n const requestedPort =\n passed.port ?? host.runner.port ?? DEFAULT_SWITCHBOARD_PORT;\n const {\n configureVetraRemoteDrive,\n printVetraSwitchboardUrls,\n vetraProcessorConfigOf,\n } = await import(\"../services/vetra-switchboard.js\");\n const vetraConfig = vetraProcessorConfigOf({\n interactive: passed.interactive ?? false,\n remoteDrive,\n localDriveUrl: `http://localhost:${requestedPort}/d/${localDriveId}`,\n localDriveId,\n });\n\n const handle = await start(\n withStudioProcessorConfig(host, {\n [VETRA_PROCESSOR_CONFIG_KEY]: vetraConfig,\n }),\n ctx,\n );\n\n const { origin, drives } = handle.outputs;\n const port = Number(new URL(origin).port);\n const urlOf = (slug: string): string | undefined =>\n slug in drives ? drives[slug].url : undefined;\n // A compound starts Connect after `ready`: the URLs print, and the remote\n // drive's GitHub URL is settled, before it does (the classic order).\n const ready = handle.ready.then(async () => {\n printVetraSwitchboardUrls({\n verbose: false,\n remoteDrive,\n switchboardPort: port,\n // A remote drive is served here under its own id.\n driveUrl: remoteDrive\n ? `${origin}/d/${vetraConfig.driveId}`\n : urlOf(VETRA_DRIVE),\n previewDriveUrl: urlOf(VETRA_PREVIEW_DRIVE),\n workflowsDriveUrl: urlOf(WORKFLOWS_DRIVE),\n });\n if (remoteDrive) {\n await configureVetraRemoteDrive(port, remoteDrive, false);\n }\n });\n // As the ph-run runner's own `ready`: an unsupervised caller must not die\n // of an unhandled rejection.\n ready.catch(() => undefined);\n return { ...handle, ready };\n}\n\nfunction vetraAware(start: StartVerb): StartVerb {\n return (host, ctx) =>\n hasStudioPlugin(host, ctx)\n ? startVetraSwitchboard(host, ctx, start)\n : start(host, ctx);\n}\n\nexport const run = vetraAware(startRun);\n\nexport const serve = run;\n\nexport const dev = vetraAware(startDev);\n"],"names":["startRun","startDev"],"mappings":";;;;;;;;;AAoBA,MAAa,QAAQ;CACnB;CACA;CACA;CACA;CACA;CACA;CACA;AACF;;;AAIA,eAAsB,MACpB,MACA,MACe;CACf,MAAM,EAAE,aAAa,MAAM,OAAO;CAClC,MAAM,EAAE,qBAAqB,MAAM,OAAO;CAE1C,MAAM,UAAU,MAAM,iBAAiB;CACvC,MAAM,SAAS;EACb,GAAG;EACH,QAAQ,KAAK,OAAO,UAAU,QAAQ;CACxC,CAAC;AACH;;AAQA,eAAe,SACb,MACA,KAC4B;CAC5B,MAAM,EAAE,kBACN,MAAM,OAAO;CACf,OAAO,cAAc,MAAM,GAAG;AAChC;;AAGA,eAAe,SAAS,MAA6B,KAAoB;CACvE,MAAM,EAAE,qBACN,MAAM,OAAO;CACf,OAAO,iBAAiB,KAAK,SAAS,KAAK,KAAK,SAAS;AAC3D;;;;AAKA,eAAe,cACb,MACA,KACA,YACe;CACf,MAAM,SAAS,MAA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S,OAAO,KAAK,CAAC,MAAM,KAAA;CAGtC,MAAM,QAAQ,OAAO,MAAM,KAAK,YAAY;EAC1C,0BAA0B;GACxB,SAAS;GACT;GACA,iBAAiB;GAEjB,UAAU,cACN,GAAG,OAAO,KAAK,YAAY,YAC3B,MAAM,WAAW;GACrB,iBAAiB,MAAM,mBAAmB;GAC1C,mBAAmB,MAAM,eAAe;EAC1C,CAAC;EACD,IAAI,aACF,MAAM,0BAA0B,MAAM,aAAa,KAAK;CAE5D,CAAC;CAGD,MAAM,YAAY,KAAA,CAAS;CAC3B,OAAO;EAAE,GAAG;EAAQ;CAAM;AAC5B;AAEA,SAAS,WAAW,OAA6B;CAC/C,QAAQ,MAAM,QACZ,gBAAgB,MAAM,GAAG,IACrB,sBAAsB,MAAM,KAAK,KAAK,IACtC,MAAM,MAAM,GAAG;AACvB;AAEA,MAAa,MAAM,WAAWA,KAAQ;AAEtC,MAAa,QAAQ;AAErB,MAAa,MAAM,WAAWC,KAAQ","debug_id":"76083e3e-dd9e-51c9-8041-2c590c0d60cc"}
@@ -1,7 +1,7 @@
1
1
  import { writeCliDocsMarkdownFile } from "@powerhousedao/codegen/file-builders";
2
2
  import { accessToken } from "../src/commands/access-token.js";
3
3
  import { build as buildCmd } from "../src/commands/build.js";
4
- import { build, connect, preview, studio } from "../src/commands/connect.js";
4
+ import { config as connectConfig, connect } from "../src/commands/connect.js";
5
5
  import { generateAllCmd } from "../src/commands/generate-all.js";
6
6
  import { generateAppCmd } from "../src/commands/generate-app.js";
7
7
  import { generateConnectRoutesCmd } from "../src/commands/generate-connect-routes.js";
@@ -29,7 +29,6 @@ import { migrate } from "../src/commands/migrate.js";
29
29
  import { modelCheck, modelInspect } from "../src/commands/model.js";
30
30
  import { phCli } from "../src/commands/ph-cli.js";
31
31
  import { runHost } from "../src/commands/run.js";
32
- import { switchboard } from "../src/commands/switchboard.js";
33
32
  import { uninstall } from "../src/commands/uninstall.js";
34
33
  import { vetra } from "../src/commands/vetra.js";
35
34
 
@@ -37,6 +36,7 @@ const commands = [
37
36
  { name: "run", command: runHost },
38
37
  { name: "host check", command: hostCheck },
39
38
  { name: "host export", command: hostExport },
39
+ { name: "vetra", command: vetra },
40
40
  { name: "generate", command: generate },
41
41
  { name: "all", command: generateAllCmd },
42
42
  { name: "document-model", command: generateDocumentModelCmd },
@@ -50,12 +50,9 @@ const commands = [
50
50
  { name: "migration-file", command: generateMigrationFileCmd },
51
51
  { name: "connect-routes", command: generateConnectRoutesCmd },
52
52
  { name: "hosts", command: generateHostsCmd },
53
- { name: "vetra", command: vetra },
54
53
  { name: "build", command: buildCmd },
55
54
  { name: "connect", command: connect },
56
- { name: "connect studio", command: studio },
57
- { name: "connect build", command: build },
58
- { name: "connect preview", command: preview },
55
+ { name: "connect config", command: connectConfig },
59
56
  { name: "access token", command: accessToken },
60
57
  { name: "inspect", command: inspect },
61
58
  { name: "keyframes", command: keyframes },
@@ -64,7 +61,6 @@ const commands = [
64
61
  { name: "migrate", command: migrate },
65
62
  { name: "model check", command: modelCheck },
66
63
  { name: "model inspect", command: modelInspect },
67
- { name: "switchboard", command: switchboard },
68
64
  { name: "login", command: login },
69
65
  { name: "install", command: install },
70
66
  { name: "uninstall", command: uninstall },
@@ -0,0 +1,49 @@
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]="188193c1-aeed-5a59-bf1f-f1000da143e8")}catch(e){}}();
3
+ import { command, runSafely } from "cmd-ts";
4
+ import { buildArgs, connectBuildArgs, connectStudioArgs } from "@powerhousedao/shared/clis/args";
5
+ //#region src/services/service-args.ts
6
+ /**
7
+ * The argument shapes the Connect studio, Connect build and package build
8
+ * services take, produced by the cmd-ts definitions of
9
+ * `@powerhousedao/shared/clis/args` (see
10
+ * `@powerhousedao/ph-run/service-args`, which does this for the switchboard
11
+ * and for the Connect preview). A runner starts from one of these and
12
+ * overlays only the keys its host file and its invocation own, so a service
13
+ * is handed every key of the shape, with its default.
14
+ */
15
+ const connectStudio = command({
16
+ name: "studio",
17
+ args: connectStudioArgs,
18
+ handler: (args) => args
19
+ });
20
+ const connectBuild = command({
21
+ name: "build",
22
+ args: connectBuildArgs,
23
+ handler: (args) => args
24
+ });
25
+ const build = command({
26
+ name: "build",
27
+ args: buildArgs,
28
+ handler: (args) => args
29
+ });
30
+ async function connectStudioServiceArgs(argv = []) {
31
+ const result = await runSafely(connectStudio, argv);
32
+ if (result._tag === "error") throw new Error(`connect studio args did not parse: ${result.error.config.message}`);
33
+ return result.value;
34
+ }
35
+ async function connectBuildServiceArgs(argv = []) {
36
+ const result = await runSafely(connectBuild, argv);
37
+ if (result._tag === "error") throw new Error(`connect build args did not parse: ${result.error.config.message}`);
38
+ return result.value;
39
+ }
40
+ async function buildServiceArgs(argv = []) {
41
+ const result = await runSafely(build, argv);
42
+ if (result._tag === "error") throw new Error(`build args did not parse: ${result.error.config.message}`);
43
+ return result.value;
44
+ }
45
+ //#endregion
46
+ export { buildServiceArgs, connectBuildServiceArgs, connectStudioServiceArgs };
47
+
48
+ //# sourceMappingURL=service-args-D6y3L0bm.mjs.map
49
+ //# debugId=188193c1-aeed-5a59-bf1f-f1000da143e8
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service-args-D6y3L0bm.mjs","sources":["../src/services/service-args.ts"],"sourcesContent":["import type { ParsedCmdResult } from \"@powerhousedao/shared/clis\";\nimport {\n buildArgs,\n connectBuildArgs,\n connectStudioArgs,\n} from \"@powerhousedao/shared/clis/args\";\nimport { command, runSafely } from \"cmd-ts\";\nimport type { BuildArgs } from \"../types.js\";\n\n/**\n * The argument shapes the Connect studio, Connect build and package build\n * services take, produced by the cmd-ts definitions of\n * `@powerhousedao/shared/clis/args` (see\n * `@powerhousedao/ph-run/service-args`, which does this for the switchboard\n * and for the Connect preview). A runner starts from one of these and\n * overlays only the keys its host file and its invocation own, so a service\n * is handed every key of the shape, with its default.\n */\nconst connectStudio = command({\n name: \"studio\",\n args: connectStudioArgs,\n handler: (args) => args,\n});\n\nconst connectBuild = command({\n name: \"build\",\n args: connectBuildArgs,\n handler: (args) => args,\n});\n\nconst build = command({\n name: \"build\",\n args: buildArgs,\n handler: (args) => args,\n});\n\nexport type ConnectStudioArgs = ParsedCmdResult<typeof connectStudio>;\nexport type ConnectBuildArgs = ParsedCmdResult<typeof connectBuild>;\n\nexport async function connectStudioServiceArgs(\n argv: string[] = [],\n): Promise<ConnectStudioArgs> {\n const result = await runSafely(connectStudio, argv);\n if (result._tag === \"error\") {\n throw new Error(\n `connect studio args did not parse: ${result.error.config.message}`,\n );\n }\n return result.value;\n}\n\nexport async function connectBuildServiceArgs(\n argv: string[] = [],\n): Promise<ConnectBuildArgs> {\n const result = await runSafely(connectBuild, argv);\n if (result._tag === \"error\") {\n throw new Error(\n `connect build args did not parse: ${result.error.config.message}`,\n );\n }\n return result.value;\n}\n\nexport async function buildServiceArgs(\n argv: string[] = [],\n): Promise<BuildArgs> {\n const result = await runSafely(build, argv);\n if (result._tag === \"error\") {\n throw new Error(`build args did not parse: ${result.error.config.message}`);\n }\n return result.value;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;AAkBA,MAAM,gBAAgB,QAAQ;CAC5B,MAAM;CACN,MAAM;CACN,UAAU,SAAS;AACrB,CAAC;AAED,MAAM,eAAe,QAAQ;CAC3B,MAAM;CACN,MAAM;CACN,UAAU,SAAS;AACrB,CAAC;AAED,MAAM,QAAQ,QAAQ;CACpB,MAAM;CACN,MAAM;CACN,UAAU,SAAS;AACrB,CAAC;AAKD,eAAsB,yBACpB,OAAiB,CAAC,GACU;CAC5B,MAAM,SAAS,MAAM,UAAU,eAAe,IAAI;CAClD,IAAI,OAAO,SAAS,SAClB,MAAM,IAAI,MACR,sCAAsC,OAAO,MAAM,OAAO,SAC5D;CAEF,OAAO,OAAO;AAChB;AAEA,eAAsB,wBACpB,OAAiB,CAAC,GACS;CAC3B,MAAM,SAAS,MAAM,UAAU,cAAc,IAAI;CACjD,IAAI,OAAO,SAAS,SAClB,MAAM,IAAI,MACR,qCAAqC,OAAO,MAAM,OAAO,SAC3D;CAEF,OAAO,OAAO;AAChB;AAEA,eAAsB,iBACpB,OAAiB,CAAC,GACE;CACpB,MAAM,SAAS,MAAM,UAAU,OAAO,IAAI;CAC1C,IAAI,OAAO,SAAS,SAClB,MAAM,IAAI,MAAM,6BAA6B,OAAO,MAAM,OAAO,SAAS;CAE5E,OAAO,OAAO;AAChB","debug_id":"188193c1-aeed-5a59-bf1f-f1000da143e8"}
@@ -0,0 +1,175 @@
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]="c2e3e5f7-c34e-5af7-ba98-23479b2072b3")}catch(e){}}();
3
+ import { O as loadHost, U as probeHostsFolder, ut as withoutHostsMessage } from "./compound-BWLJ0KBw-8hKyrfjG.mjs";
4
+ import { n as HOST_COMMANDS, t as CONNECT_VERBS } from "./run-sugar-hGKprsKz.mjs";
5
+ import { DEPRECATIONS_REMOVED_IN, MIGRATION_GUIDE_URL } from "@powerhousedao/shared/clis/deprecations";
6
+ //#region src/utils/sugar-checks.ts
7
+ /**
8
+ * What `ph dev`, `ph connect` and `ph switchboard` are refused for, before
9
+ * they become `ph run <host>` (run-sugar.ts): a project without the host
10
+ * file, and the flags of the commands they once were that `ph run` has no
11
+ * argument for. `ph run` is not checked here, nor is any other host name: a
12
+ * runner refuses the arguments it does not know itself. Nor are the flags of
13
+ * a host on a runner of its own: they are checked against the stock runners.
14
+ */
15
+ /** `ph switchboard` flags that are verbs of the host. */
16
+ const SWITCHBOARD_VERB_FLAGS = {
17
+ "--migrate": "migrate",
18
+ "--migrate-status": "migrate-status",
19
+ "--reset": "reset",
20
+ "--dev": "dev"
21
+ };
22
+ /** Read by the CLI itself, before any command. */
23
+ const CLI_FLAGS = /* @__PURE__ */ new Set(["--debug"]);
24
+ function sugarInvocation(args) {
25
+ const [command, ...rest] = args;
26
+ if (command === void 0 || !Object.hasOwn(HOST_COMMANDS, command)) return;
27
+ if (rest.some((arg) => arg === "--help" || arg === "-h")) return void 0;
28
+ const flags = [...new Set(rest.filter((arg) => arg.startsWith("-") && arg !== "--").map((arg) => arg.split("=")[0]))].filter((name) => !CLI_FLAGS.has(name));
29
+ const word = rest.length > 0 && !rest[0].startsWith("-") ? rest[0] : void 0;
30
+ if (command === "connect") {
31
+ if (word === "config") return void 0;
32
+ const verb = word === void 0 ? CONNECT_VERBS.studio : Object.hasOwn(CONNECT_VERBS, word) ? CONNECT_VERBS[word] : word;
33
+ return {
34
+ typed: word ? `ph connect ${word}` : "ph connect",
35
+ host: "connect",
36
+ replacement: `ph run connect ${verb}`,
37
+ flags
38
+ };
39
+ }
40
+ const host = HOST_COMMANDS[command];
41
+ return {
42
+ typed: word ? `ph ${command} ${word}` : `ph ${command}`,
43
+ host,
44
+ replacement: word ? `ph run ${host} ${word}` : `ph run ${host}`,
45
+ flags
46
+ };
47
+ }
48
+ /**
49
+ * `ph reactor` was an alias of `ph switchboard`. It is gone, unless the
50
+ * project names a host of its own that.
51
+ */
52
+ function removedAliasError(args, projectRoot) {
53
+ if (args[0] !== "reactor") return void 0;
54
+ const probe = probeHostsFolder(projectRoot);
55
+ if (probe.kind === "present" && probe.hosts.includes("reactor")) return;
56
+ return `\`ph reactor\` was removed in ${DEPRECATIONS_REMOVED_IN}. Use \`ph switchboard\` or \`ph run switchboard\` instead.`;
57
+ }
58
+ /**
59
+ * Why the command cannot run in this project: it has no hosts (the wording
60
+ * of `ph run`, naming `ph migrate`), or it has hosts and not this one.
61
+ * Undefined for anything else, for help, and for a project with the host.
62
+ */
63
+ function withoutHostError(args, projectRoot) {
64
+ const invocation = sugarInvocation(args);
65
+ if (!invocation) return void 0;
66
+ const { typed, host } = invocation;
67
+ const probe = probeHostsFolder(projectRoot);
68
+ if (probe.kind !== "present") return withoutHostsMessage(probe, `\`${typed}\``);
69
+ if (probe.hosts.includes(host)) return void 0;
70
+ return `This project has no hosts/${host}/host.js, so \`${typed}\` cannot run. \`ph migrate\` adds the host files to a project without hosts only: add hosts/${host}/host.js to this one. See ${MIGRATION_GUIDE_URL}`;
71
+ }
72
+ /**
73
+ * The flags `ph run <host>` has no argument for, as one error. A flag the
74
+ * runner takes passes, under its member name for `ph dev`
75
+ * (`--switchboard-port`); a flag the runner retired passes too, and the
76
+ * runner says so. Undefined when every flag passes.
77
+ */
78
+ function removedFlagsError(args, schemas) {
79
+ const invocation = sugarInvocation(args);
80
+ if (!invocation) return void 0;
81
+ const { typed, host, replacement } = invocation;
82
+ const members = host === "vetra" ? [schemas.switchboard, schemas.connect] : [schemas[host]];
83
+ const scoped = new Set(members.flatMap((schema) => Object.values(schema.memberOptions ?? {})));
84
+ const accepts = (name) => host === "vetra" ? name === "--restart" || members.some((schema) => schema.memberOptions?.[name] !== void 0 || !scoped.has(name) && [...schema.options, ...schema.flags].includes(name)) : [...members[0].options, ...members[0].flags].includes(name);
85
+ const errors = [];
86
+ const unsupported = [];
87
+ for (const name of invocation.flags) {
88
+ const verb = host === "switchboard" ? SWITCHBOARD_VERB_FLAGS[name] : void 0;
89
+ const retired = members.some((schema) => schema.retired?.[name] !== void 0);
90
+ if (verb !== void 0) errors.push(`\`${typed} ${name}\` was removed in ${DEPRECATIONS_REMOVED_IN}. Use \`ph run switchboard ${verb}\` instead.`);
91
+ else if (accepts(name) || retired) continue;
92
+ else unsupported.push(name);
93
+ }
94
+ if (unsupported.length > 0) {
95
+ const one = unsupported.length === 1;
96
+ const subject = one ? `\`${typed} ${unsupported[0]}\` was removed in ${DEPRECATIONS_REMOVED_IN}: \`${replacement}\` has no such argument.` : `The \`${typed}\` flags ${unsupported.join(", ")} were removed in ${DEPRECATIONS_REMOVED_IN}: \`${replacement}\` has no such arguments.`;
97
+ errors.push(`${subject} Set what ${one ? "it configures" : "they configure"} in the host files under hosts/ instead. See ${MIGRATION_GUIDE_URL}`);
98
+ }
99
+ return errors.length > 0 ? errors.join("\n") : void 0;
100
+ }
101
+ /** The runners the scaffold's hosts name, whose schemas the flags are
102
+ * checked against. ph-cli's are the ph-run ones, re-exported. */
103
+ const STOCK_RUNNERS = {
104
+ connect: ["@powerhousedao/ph-cli/runners/connect", "@powerhousedao/ph-run/runners/connect"],
105
+ switchboard: ["@powerhousedao/ph-cli/runners/switchboard", "@powerhousedao/ph-run/runners/switchboard"]
106
+ };
107
+ const COMPOUND_RUNNER = "@powerhousedao/host-core/runners/compound";
108
+ async function runnerModuleOf(projectRoot, host) {
109
+ try {
110
+ const { host: definition } = await loadHost(projectRoot, host);
111
+ return {
112
+ module: definition.runner.module,
113
+ children: definition.children
114
+ };
115
+ } catch {
116
+ return;
117
+ }
118
+ }
119
+ /**
120
+ * Whether the host runs the stock runner of its command: the connect or
121
+ * switchboard runner, or for `ph dev` the compound over members that are
122
+ * the project's connect and switchboard hosts, each on its stock runner.
123
+ * Anything else has arguments of its own, which its runner checks.
124
+ */
125
+ async function runsStockRunner(projectRoot, host) {
126
+ const loaded = await runnerModuleOf(projectRoot, host);
127
+ if (!loaded) return false;
128
+ if (host !== "vetra") return STOCK_RUNNERS[host].includes(loaded.module);
129
+ if (loaded.module !== COMPOUND_RUNNER) return false;
130
+ const children = loaded.children;
131
+ if (typeof children !== "object" || children === null) return false;
132
+ const members = /* @__PURE__ */ new Set();
133
+ for (const child of Object.values(children)) {
134
+ const { host: member, runner } = child ?? {};
135
+ if (typeof member !== "string" || !Object.hasOwn(STOCK_RUNNERS, member)) return false;
136
+ if (runner?.module !== void 0) return false;
137
+ members.add(member);
138
+ }
139
+ for (const member of members) {
140
+ const sibling = await runnerModuleOf(projectRoot, member);
141
+ if (!sibling || !STOCK_RUNNERS[member].includes(sibling.module)) return false;
142
+ }
143
+ return true;
144
+ }
145
+ async function loadArgSchemas() {
146
+ try {
147
+ const [switchboard, connect] = await Promise.all([import("@powerhousedao/ph-run/runners/switchboard"), import("@powerhousedao/ph-run/runners/connect")]);
148
+ return {
149
+ switchboard: switchboard.argsSchema,
150
+ connect: connect.argsSchema
151
+ };
152
+ } catch {
153
+ return;
154
+ }
155
+ }
156
+ /**
157
+ * Run by the CLI on the command line as typed, before the host sugar: the
158
+ * error the invocation ends with, if any. `args` is untouched either way.
159
+ */
160
+ async function sugarError(args, projectRoot) {
161
+ const removed = removedAliasError(args, projectRoot);
162
+ if (removed !== void 0) return removed;
163
+ const withoutHost = withoutHostError(args, projectRoot);
164
+ if (withoutHost !== void 0) return withoutHost;
165
+ const invocation = sugarInvocation(args);
166
+ if (!invocation || invocation.flags.length === 0) return void 0;
167
+ if (!await runsStockRunner(projectRoot, invocation.host)) return void 0;
168
+ const schemas = await loadArgSchemas();
169
+ return schemas ? removedFlagsError(args, schemas) : void 0;
170
+ }
171
+ //#endregion
172
+ export { sugarError };
173
+
174
+ //# sourceMappingURL=sugar-checks-CTCsK5DJ.mjs.map
175
+ //# debugId=c2e3e5f7-c34e-5af7-ba98-23479b2072b3
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sugar-checks-CTCsK5DJ.mjs","sources":["../src/utils/sugar-checks.ts"],"sourcesContent":["import {\n loadHost,\n probeHostsFolder,\n withoutHostsMessage,\n type RunnerArgsSchema,\n} from \"@powerhousedao/host-core\";\nimport {\n DEPRECATIONS_REMOVED_IN,\n MIGRATION_GUIDE_URL,\n} from \"@powerhousedao/shared/clis/deprecations\";\nimport { CONNECT_VERBS, HOST_COMMANDS, type SugarHost } from \"./run-sugar.js\";\n\n/**\n * What `ph dev`, `ph connect` and `ph switchboard` are refused for, before\n * they become `ph run <host>` (run-sugar.ts): a project without the host\n * file, and the flags of the commands they once were that `ph run` has no\n * argument for. `ph run` is not checked here, nor is any other host name: a\n * runner refuses the arguments it does not know itself. Nor are the flags of\n * a host on a runner of its own: they are checked against the stock runners.\n */\n\n/** `ph switchboard` flags that are verbs of the host. */\nconst SWITCHBOARD_VERB_FLAGS: Readonly<Record<string, string>> = {\n \"--migrate\": \"migrate\",\n \"--migrate-status\": \"migrate-status\",\n \"--reset\": \"reset\",\n \"--dev\": \"dev\",\n};\n\n/** Read by the CLI itself, before any command. */\nconst CLI_FLAGS = new Set([\"--debug\"]);\n\n/** The runner argument schemas the flags are checked against. */\nexport interface SugarArgSchemas {\n switchboard: RunnerArgsSchema;\n connect: RunnerArgsSchema;\n}\n\ninterface SugarInvocation {\n /** As typed: `ph connect build`. */\n typed: string;\n /** The host it runs. */\n host: SugarHost;\n /** What it is sugar for: `ph run <host> [verb]`. */\n replacement: string;\n /** The flags passed, by name, without their values. */\n flags: string[];\n}\n\nfunction sugarInvocation(args: readonly string[]): SugarInvocation | undefined {\n const [command, ...rest] = args;\n if (command === undefined || !Object.hasOwn(HOST_COMMANDS, command)) {\n return undefined;\n }\n if (rest.some((arg) => arg === \"--help\" || arg === \"-h\")) return undefined;\n const flags = [\n ...new Set(\n rest\n .filter((arg) => arg.startsWith(\"-\") && arg !== \"--\")\n .map((arg) => arg.split(\"=\")[0]),\n ),\n ].filter((name) => !CLI_FLAGS.has(name));\n // A word right after the command is the subcommand or the verb.\n const word =\n rest.length > 0 && !rest[0].startsWith(\"-\") ? rest[0] : undefined;\n if (command === \"connect\") {\n // `ph connect config` reads and writes the config: a tool, not a host.\n if (word === \"config\") return undefined;\n const verb =\n word === undefined\n ? CONNECT_VERBS.studio\n : Object.hasOwn(CONNECT_VERBS, word)\n ? CONNECT_VERBS[word]\n : word;\n return {\n typed: word ? `ph connect ${word}` : \"ph connect\",\n host: \"connect\",\n replacement: `ph run connect ${verb}`,\n flags,\n };\n }\n // `ph dev` runs hosts/vetra.\n const host = HOST_COMMANDS[command];\n return {\n typed: word ? `ph ${command} ${word}` : `ph ${command}`,\n host,\n replacement: word ? `ph run ${host} ${word}` : `ph run ${host}`,\n flags,\n };\n}\n\n/**\n * `ph reactor` was an alias of `ph switchboard`. It is gone, unless the\n * project names a host of its own that.\n */\nfunction removedAliasError(\n args: readonly string[],\n projectRoot: string,\n): string | undefined {\n if (args[0] !== \"reactor\") return undefined;\n const probe = probeHostsFolder(projectRoot);\n if (probe.kind === \"present\" && probe.hosts.includes(\"reactor\")) {\n return undefined;\n }\n return (\n `\\`ph reactor\\` was removed in ${DEPRECATIONS_REMOVED_IN}. ` +\n \"Use `ph switchboard` or `ph run switchboard` instead.\"\n );\n}\n\n/**\n * Why the command cannot run in this project: it has no hosts (the wording\n * of `ph run`, naming `ph migrate`), or it has hosts and not this one.\n * Undefined for anything else, for help, and for a project with the host.\n */\nexport function withoutHostError(\n args: readonly string[],\n projectRoot: string,\n): string | undefined {\n const invocation = sugarInvocation(args);\n if (!invocation) return undefined;\n const { typed, host } = invocation;\n const probe = probeHostsFolder(projectRoot);\n if (probe.kind !== \"present\") {\n return withoutHostsMessage(probe, `\\`${typed}\\``);\n }\n if (probe.hosts.includes(host)) return undefined;\n // `ph migrate` adds the hosts to a project that has none, and only then.\n return (\n `This project has no hosts/${host}/host.js, so \\`${typed}\\` cannot run. ` +\n `\\`ph migrate\\` adds the host files to a project without hosts only: add hosts/${host}/host.js to this one. ` +\n `See ${MIGRATION_GUIDE_URL}`\n );\n}\n\n/**\n * The flags `ph run <host>` has no argument for, as one error. A flag the\n * runner takes passes, under its member name for `ph dev`\n * (`--switchboard-port`); a flag the runner retired passes too, and the\n * runner says so. Undefined when every flag passes.\n */\nexport function removedFlagsError(\n args: readonly string[],\n schemas: SugarArgSchemas,\n): string | undefined {\n const invocation = sugarInvocation(args);\n if (!invocation) return undefined;\n const { typed, host, replacement } = invocation;\n // A compound hands each member its arguments; a member option goes by its\n // member name there (`--switchboard-port`), never by its plain one.\n const members =\n host === \"vetra\" ? [schemas.switchboard, schemas.connect] : [schemas[host]];\n const scoped = new Set(\n members.flatMap((schema) => Object.values(schema.memberOptions ?? {})),\n );\n const accepts = (name: string): boolean =>\n host === \"vetra\"\n ? // `ph run vetra` takes --restart itself (vetra-host.ts).\n name === \"--restart\" ||\n members.some(\n (schema) =>\n schema.memberOptions?.[name] !== undefined ||\n (!scoped.has(name) &&\n [...schema.options, ...schema.flags].includes(name)),\n )\n : [...members[0].options, ...members[0].flags].includes(name);\n const errors: string[] = [];\n const unsupported: string[] = [];\n for (const name of invocation.flags) {\n const verb =\n host === \"switchboard\" ? SWITCHBOARD_VERB_FLAGS[name] : undefined;\n const retired = members.some(\n (schema) => schema.retired?.[name] !== undefined,\n );\n if (verb !== undefined) {\n errors.push(\n `\\`${typed} ${name}\\` was removed in ${DEPRECATIONS_REMOVED_IN}. Use \\`ph run switchboard ${verb}\\` instead.`,\n );\n } else if (accepts(name) || retired) {\n continue;\n } else {\n unsupported.push(name);\n }\n }\n if (unsupported.length > 0) {\n const one = unsupported.length === 1;\n const subject = one\n ? `\\`${typed} ${unsupported[0]}\\` was removed in ${DEPRECATIONS_REMOVED_IN}: \\`${replacement}\\` has no such argument.`\n : `The \\`${typed}\\` flags ${unsupported.join(\", \")} were removed in ${DEPRECATIONS_REMOVED_IN}: \\`${replacement}\\` has no such arguments.`;\n errors.push(\n `${subject} Set what ${one ? \"it configures\" : \"they configure\"} in the host files under hosts/ instead. ` +\n `See ${MIGRATION_GUIDE_URL}`,\n );\n }\n return errors.length > 0 ? errors.join(\"\\n\") : undefined;\n}\n\n/** The runners the scaffold's hosts name, whose schemas the flags are\n * checked against. ph-cli's are the ph-run ones, re-exported. */\nconst STOCK_RUNNERS: Readonly<Record<string, readonly string[]>> = {\n connect: [\n \"@powerhousedao/ph-cli/runners/connect\",\n \"@powerhousedao/ph-run/runners/connect\",\n ],\n switchboard: [\n \"@powerhousedao/ph-cli/runners/switchboard\",\n \"@powerhousedao/ph-run/runners/switchboard\",\n ],\n};\nconst COMPOUND_RUNNER = \"@powerhousedao/host-core/runners/compound\";\n\nasync function runnerModuleOf(\n projectRoot: string,\n host: string,\n): Promise<{ module: string; children?: unknown } | undefined> {\n try {\n const { host: definition } = await loadHost(projectRoot, host);\n return {\n module: definition.runner.module,\n children: (definition as { children?: unknown }).children,\n };\n } catch {\n // `ph run` loads it next and says what is wrong with it.\n return undefined;\n }\n}\n\n/**\n * Whether the host runs the stock runner of its command: the connect or\n * switchboard runner, or for `ph dev` the compound over members that are\n * the project's connect and switchboard hosts, each on its stock runner.\n * Anything else has arguments of its own, which its runner checks.\n */\nexport async function runsStockRunner(\n projectRoot: string,\n host: SugarHost,\n): Promise<boolean> {\n const loaded = await runnerModuleOf(projectRoot, host);\n if (!loaded) return false;\n if (host !== \"vetra\") return STOCK_RUNNERS[host].includes(loaded.module);\n if (loaded.module !== COMPOUND_RUNNER) return false;\n const children = loaded.children;\n if (typeof children !== \"object\" || children === null) return false;\n const members = new Set<string>();\n for (const child of Object.values(children as Record<string, unknown>)) {\n const { host: member, runner } = (child ?? {}) as {\n host?: unknown;\n runner?: { module?: unknown };\n };\n if (typeof member !== \"string\" || !Object.hasOwn(STOCK_RUNNERS, member)) {\n return false;\n }\n // A member that names a runner module is not on its sibling's.\n if (runner?.module !== undefined) return false;\n members.add(member);\n }\n for (const member of members) {\n const sibling = await runnerModuleOf(projectRoot, member);\n if (!sibling || !STOCK_RUNNERS[member].includes(sibling.module)) {\n return false;\n }\n }\n return true;\n}\n\nasync function loadArgSchemas(): Promise<SugarArgSchemas | undefined> {\n try {\n const [switchboard, connect] = await Promise.all([\n import(\"@powerhousedao/ph-run/runners/switchboard\"),\n import(\"@powerhousedao/ph-run/runners/connect\"),\n ]);\n return {\n switchboard: switchboard.argsSchema,\n connect: connect.argsSchema,\n };\n } catch {\n return undefined;\n }\n}\n\n/**\n * Run by the CLI on the command line as typed, before the host sugar: the\n * error the invocation ends with, if any. `args` is untouched either way.\n */\nexport async function sugarError(\n args: readonly string[],\n projectRoot: string,\n): Promise<string | undefined> {\n const removed = removedAliasError(args, projectRoot);\n if (removed !== undefined) return removed;\n const withoutHost = withoutHostError(args, projectRoot);\n if (withoutHost !== undefined) return withoutHost;\n const invocation = sugarInvocation(args);\n if (!invocation || invocation.flags.length === 0) return undefined;\n // A runner of the project's own takes the arguments it declares.\n if (!(await runsStockRunner(projectRoot, invocation.host))) return undefined;\n // Without the schemas the runner still refuses what it does not accept.\n const schemas = await loadArgSchemas();\n return schemas ? removedFlagsError(args, schemas) : undefined;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAsBA,MAAM,yBAA2D;CAC/D,aAAa;CACb,oBAAoB;CACpB,WAAW;CACX,SAAS;AACX;;AAGA,MAAM,4BAAY,IAAI,IAAI,CAAC,SAAS,CAAC;AAmBrC,SAAS,gBAAgB,MAAsD;CAC7E,MAAM,CAAC,SAAS,GAAG,QAAQ;CAC3B,IAAI,YAAY,KAAA,KAAa,CAAC,OAAO,OAAO,eAAe,OAAO,GAChE;CAEF,IAAI,KAAK,MAAM,QAAQ,QAAQ,YAAY,QAAQ,IAAI,GAAG,OAAO,KAAA;CACjE,MAAM,QAAQ,CACZ,GAAG,IAAI,IACL,KACG,QAAQ,QAAQ,IAAI,WAAW,GAAG,KAAK,QAAQ,IAAI,CAAC,CACpD,KAAK,QAAQ,IAAI,MAAM,GAAG,CAAC,CAAC,EAAE,CACnC,CACF,CAAC,CAAC,QAAQ,SAAS,CAAC,UAAU,IAAI,IAAI,CAAC;CAEvC,MAAM,OACJ,KAAK,SAAS,KAAK,CAAC,KAAK,EAAE,CAAC,WAAW,GAAG,IAAI,KAAK,KAAK,KAAA;CAC1D,IAAI,YAAY,WAAW;EAEzB,IAAI,SAAS,UAAU,OAAO,KAAA;EAC9B,MAAM,OACJ,SAAS,KAAA,IACL,cAAc,SACd,OAAO,OAAO,eAAe,IAAI,IAC/B,cAAc,QACd;EACR,OAAO;GACL,OAAO,OAAO,cAAc,SAAS;GACrC,MAAM;GACN,aAAa,kBAAkB;GAC/B;EACF;CACF;CAEA,MAAM,OAAO,cAAc;CAC3B,OAAO;EACL,OAAO,OAAO,MAAM,QAAQ,GAAG,SAAS,MAAM;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7-c34e-5af7-ba98-23479b2072b3"}
@@ -1,8 +1,8 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="44d0c080-10cc-5316-947d-b0281777aade")}catch(e){}}();
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]="c6d177bb-1a46-5191-9fe0-d41f393b02ba")}catch(e){}}();
3
3
  import { promises } from "node:fs";
4
- import { cyan, green, red, yellow } from "colorette";
5
4
  import { defaultStoreDirs } from "@powerhousedao/shared/clis/ph-dir";
5
+ import { cyan, green, red, yellow } from "colorette";
6
6
  //#region src/services/switchboard-reset.ts
7
7
  const CONFIRMATION_TOKEN = "reset";
8
8
  function isPostgresUrl(url) {
@@ -51,7 +51,7 @@ async function resetSwitchboardDatabase(options) {
51
51
  const paths = resolveResetPaths(options);
52
52
  if (paths.postgresUrl) {
53
53
  console.error(red(`Refusing to reset: a PostgreSQL URL is configured (${paths.postgresUrl}).`));
54
- console.error(yellow("`ph switchboard --reset` only wipes the local PGlite stores. To reset a Postgres-backed switchboard, drop/recreate the database manually."));
54
+ console.error(yellow("`ph run switchboard reset` only wipes the local PGlite stores. To reset a Postgres-backed switchboard, drop/recreate the database manually."));
55
55
  process.exit(1);
56
56
  }
57
57
  const targets = [paths.reactorDir, paths.readModelDir].filter((d) => d !== null);
@@ -85,5 +85,5 @@ async function resetSwitchboardDatabase(options) {
85
85
  //#endregion
86
86
  export { resetSwitchboardDatabase };
87
87
 
88
- //# sourceMappingURL=switchboard-reset-MtTB_GAI.mjs.map
89
- //# debugId=44d0c080-10cc-5316-947d-b0281777aade
88
+ //# sourceMappingURL=switchboard-reset-BP7KwUc_.mjs.map
89
+ //# debugId=c6d177bb-1a46-5191-9fe0-d41f393b02ba
@@ -0,0 +1 @@
1
+ {"version":3,"file":"switchboard-reset-BP7KwUc_.mjs","sources":["../src/services/switchboard-reset.ts"],"sourcesContent":["import { defaultStoreDirs } from \"@powerhousedao/shared/clis/ph-dir\";\nimport { yellow, red, green, cyan } from \"colorette\";\nimport { promises as fs } from \"node:fs\";\n\nexport interface ResetSwitchboardOptions {\n dbPath?: string;\n yes?: boolean;\n}\n\nexport interface ResolvedResetPaths {\n reactorDir: string | null;\n readModelDir: string | null;\n postgresUrl: string | null;\n}\n\nconst CONFIRMATION_TOKEN = \"reset\";\n\nexport function isPostgresUrl(url: string): boolean {\n return url.startsWith(\"postgresql://\") || url.startsWith(\"postgres://\");\n}\n\nfunction isInteractive(): boolean {\n return Boolean(process.stdin.isTTY) && !process.env.CI;\n}\n\n/**\n * Resolves the on-disk PGlite directories that `--reset` would delete.\n * Mirrors the resolution in apps/switchboard/src/server.mts so we touch the\n * same paths the running switchboard uses. When a Postgres URL is configured\n * the corresponding directory is null and `postgresUrl` is populated so the\n * caller can refuse.\n */\nexport function resolveResetPaths(\n options: ResetSwitchboardOptions,\n env: NodeJS.ProcessEnv = process.env,\n): ResolvedResetPaths {\n const defaults = defaultStoreDirs(env);\n const readModelDbPath =\n options.dbPath ?? env.DATABASE_URL ?? env.PH_SWITCHBOARD_DATABASE_URL;\n const readModelPath = readModelDbPath || defaults.readModel;\n const reactorDbUrl =\n options.dbPath ??\n env.PH_REACTOR_DATABASE_URL ??\n env.PH_SWITCHBOARD_DATABASE_URL;\n const reactorPath = reactorDbUrl || defaults.reactor;\n\n const reactorIsPostgres = !!reactorDbUrl && isPostgresUrl(reactorDbUrl);\n const readModelIsPostgres =\n !!readModelDbPath && isPostgresUrl(readModelDbPath);\n\n let postgresUrl: string | null = null;\n if (reactorIsPostgres) postgresUrl = reactorDbUrl as string;\n else if (readModelIsPostgres) postgresUrl = readModelDbPath as string;\n\n return {\n reactorDir: reactorIsPostgres ? null : reactorPath,\n readModelDir: readModelIsPostgres ? null : readModelPath,\n postgresUrl,\n };\n}\n\nasync function promptForConfirmation(): Promise<boolean> {\n const enquirer = await import(\"enquirer\");\n try {\n const answer = await enquirer.default.prompt<{ confirmation: string }>({\n type: \"input\",\n name: \"confirmation\",\n message: `Type \"${CONFIRMATION_TOKEN}\" to confirm wiping the local switchboard databases:`,\n });\n return answer.confirmation.trim() === CONFIRMATION_TOKEN;\n } catch {\n return false;\n }\n}\n\nexport async function resetSwitchboardDatabase(\n options: ResetSwitchboardOptions,\n): Promise<void> {\n const paths = resolveResetPaths(options);\n\n if (paths.postgresUrl) {\n console.error(\n red(\n `Refusing to reset: a PostgreSQL URL is configured (${paths.postgresUrl}).`,\n ),\n );\n console.error(\n yellow(\n \"`ph run switchboard reset` only wipes the local PGlite stores. \" +\n \"To reset a Postgres-backed switchboard, drop/recreate the database manually.\",\n ),\n );\n process.exit(1);\n }\n\n const targets = [paths.reactorDir, paths.readModelDir].filter(\n (d): d is string => d !== null,\n );\n\n if (targets.length === 0) {\n console.error(red(\"No local PGlite directories resolved; nothing to do.\"));\n process.exit(1);\n }\n\n console.log(yellow(\"The following directories will be permanently deleted:\"));\n for (const dir of targets) {\n console.log(` - ${dir}`);\n }\n console.log(\n yellow(\n \"This will wipe all local switchboard state. Migrations will re-run on next `ph switchboard`.\",\n ),\n );\n\n let confirmed = false;\n if (options.yes) {\n confirmed = true;\n } else if (isInteractive()) {\n confirmed = await promptForConfirmation();\n } else {\n console.error(\n red(\n \"Refusing to reset in a non-interactive context without --yes. Re-run with --yes to confirm.\",\n ),\n );\n process.exit(1);\n }\n\n if (!confirmed) {\n console.error(red(\"Aborted: confirmation not provided.\"));\n process.exit(1);\n }\n\n for (const dir of targets) {\n await fs.rm(dir, { recursive: true, force: true });\n console.log(cyan(`Removed ${dir}`));\n }\n\n console.log(\n green(\n \"Switchboard local storage reset. Run `ph switchboard` to re-initialize.\",\n ),\n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ACpD,MAAmB,MAAM,IAC5B;CAEA,IAAI,QAAQ,WAAW,GAAG;EACxB,QAAQ,MAAM,IAAI,sDAAsD,CAAC;EACzE,QAAQ,KAAK,CAAC;CAChB;CAEA,QAAQ,IAAI,OAAO,wDAAwD,CAAC;CAC5E,KAAK,MAAM,OAAO,SAChB,QAAQ,IAAI,OAAO,KAAK;CAE1B,QAAQ,IACN,OACE,8FACF,CACF;CAEA,IAAI,YAAY;CAChB,IAAI,QAAQ,KACV,YAAY;MACP,IAAI,cAAc,GACvB,YAAY,MAAM,sBAAsB;MACnC;EACL,QAAQ,MACN,IACE,6FACF,CACF;EACA,QAAQ,KAAK,CAAC;CAChB;CAEA,IAAI,CAAC,WAAW;EACd,QAAQ,MAAM,IAAI,qCAAqC,CAAC;EACxD,QAAQ,KAAK,CAAC;CAChB;CAEA,KAAK,MAAM,OAAO,SAAS;EACzB,MAAMA,SAAG,GAAG,KAAK;GAAE,WAAW;GAAM,OAAO;EAAK,CAAC;EACjD,QAAQ,IAAI,KAAK,WAAW,KAAK,CAAC;CACpC;CAEA,QAAQ,IACN,MACE,yEACF,CACF;AACF","debug_id":"c6d177bb-1a46-5191-9fe0-d41f393b02ba"}
@@ -0,0 +1,4 @@
1
+ import { l as removeStylesImports, u as updateConfigFile } from "./utils-D5VlY5AZ.mjs";
2
+ export { removeStylesImports, updateConfigFile };
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]="e1a4788f-ef5b-535f-8308-9c90b4cc6586")}catch(e){}}();
4
+ //# debugId=e1a4788f-ef5b-535f-8308-9c90b4cc6586
@@ -1,8 +1,7 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="e3fbf59a-7996-5c5c-9db7-c8d207b68849")}catch(e){}}();
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]="0f1fdb8d-6b86-5a6f-b105-a704f04a63ab")}catch(e){}}();
3
3
  import fs from "node:fs";
4
4
  import path, { dirname } from "node:path";
5
- import crypto from "node:crypto";
6
5
  import { homedir } from "node:os";
7
6
  //#region src/utils.ts
8
7
  const POWERHOUSE_CONFIG_FILE = "powerhouse.config.json";
@@ -73,16 +72,6 @@ function getProjectInfo(debug) {
73
72
  packageManager: getPackageManagerFromLockfile(projectPath)
74
73
  };
75
74
  }
76
- /**
77
- * Generates a unique drive ID based on the project path.
78
- * The same project path will always generate the same ID.
79
- * @param name - The name prefix for the drive ID (e.g., "vetra", "powerhouse")
80
- * @returns A unique drive ID in the format "{name}-{hash}"
81
- */
82
- function generateProjectDriveId(name) {
83
- const projectInfo = getProjectInfo();
84
- return `${name}-${crypto.createHash("sha256").update(projectInfo.path).digest("hex").substring(0, 8)}`;
85
- }
86
75
  function getPackageManagerFromLockfile(dir) {
87
76
  if (fs.existsSync(path.join(dir, packageManagers.pnpm.lockfile))) return "pnpm";
88
77
  else if (fs.existsSync(path.join(dir, packageManagers.yarn.lockfile))) return "yarn";
@@ -131,7 +120,7 @@ function removeStylesImports(dependencies, projectPath) {
131
120
  if (updatedStyles !== currentStyles) fs.writeFileSync(stylesPath, updatedStyles);
132
121
  }
133
122
  //#endregion
134
- export { generateProjectDriveId as a, isPowerhouseProject as c, updateConfigFile as d, updatePackagesArray as f, findNodeProjectRoot as i, packageManagers as l, POWERHOUSE_GLOBAL_DIR as n, getPackageManagerFromLockfile as o, defaultPathValidation as r, getProjectInfo as s, POWERHOUSE_CONFIG_FILE as t, removeStylesImports as u };
123
+ export { getPackageManagerFromLockfile as a, packageManagers as c, updatePackagesArray as d, findNodeProjectRoot as i, removeStylesImports as l, POWERHOUSE_GLOBAL_DIR as n, getProjectInfo as o, defaultPathValidation as r, isPowerhouseProject as s, POWERHOUSE_CONFIG_FILE as t, updateConfigFile as u };
135
124
 
136
- //# sourceMappingURL=utils-9KyRM0mf.mjs.map
137
- //# debugId=e3fbf59a-7996-5c5c-9db7-c8d207b68849
125
+ //# sourceMappingURL=utils-D5VlY5AZ.mjs.map
126
+ //# debugId=0f1fdb8d-6b86-5a6f-b105-a704f04a63ab
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils-D5VlY5AZ.mjs","sources":["../src/utils.ts"],"sourcesContent":["import type { PowerhouseConfig } from \"@powerhousedao/config\";\nimport fs from \"node:fs\";\nimport { homedir } from \"node:os\";\nimport path, { dirname } from \"node:path\";\nexport const POWERHOUSE_CONFIG_FILE = \"powerhouse.config.json\";\nexport const POWERHOUSE_GLOBAL_DIR = path.join(homedir(), \".ph\");\nexport const SUPPORTED_PACKAGE_MANAGERS = [\"npm\", \"yarn\", \"pnpm\", \"bun\"];\n\nexport const packageManagers = {\n bun: {\n globalPathRegexp: /[\\\\/].bun[\\\\/]/,\n installCommand: \"bun add {{dependency}}\",\n uninstallCommand: \"bun remove {{dependency}}\",\n workspaceOption: \"\",\n lockfile: \"bun.lock\",\n updateCommand: \"bun update {{dependency}}\",\n buildAffected: \"bun run build:affected\",\n },\n pnpm: {\n globalPathRegexp: /[\\\\/]pnpm[\\\\/]/,\n installCommand: \"pnpm add {{dependency}}\",\n uninstallCommand: \"pnpm remove {{dependency}}\",\n workspaceOption: \"--workspace-root\",\n lockfile: \"pnpm-lock.yaml\",\n updateCommand: \"pnpm update {{dependency}}\",\n buildAffected: \"pnpm run build:affected\",\n },\n yarn: {\n globalPathRegexp: /[\\\\/]yarn[\\\\/]/,\n installCommand: \"yarn add {{dependency}}\",\n uninstallCommand: \"yarn remove {{dependency}}\",\n workspaceOption: \"-W\",\n lockfile: \"yarn.lock\",\n updateCommand: \"yarn upgrade {{dependency}}\",\n buildAffected: \"yarn run build:affected\",\n },\n npm: {\n installCommand: \"npm install {{dependency}}\",\n uninstallCommand: \"npm uninstall {{dependency}}\",\n workspaceOption: \"\",\n lockfile: \"package-lock.json\",\n updateCommand: \"npm update {{dependency}} --save\",\n buildAffected: \"npm run build:affected\",\n },\n};\n\ntype PathValidation = (dir: string) => boolean;\n\nexport type PackageManager = \"npm\" | \"yarn\" | \"pnpm\" | \"bun\";\n\nexport type ProjectInfo = {\n isGlobal: boolean;\n path: string;\n packageManager: PackageManager;\n};\n\nexport function defaultPathValidation() {\n return true;\n}\n\nexport function isPowerhouseProject(dir: string) {\n const powerhouseConfigPath = path.join(dir, POWERHOUSE_CONFIG_FILE);\n\n return fs.existsSync(powerhouseConfigPath);\n}\n\nexport function findNodeProjectRoot(\n dir: string,\n pathValidation: PathValidation = defaultPathValidation,\n) {\n const packageJsonPath = path.join(dir, \"package.json\");\n\n if (fs.existsSync(packageJsonPath) && pathValidation(dir)) {\n return dir;\n }\n\n const parentDir = dirname(dir);\n\n if (parentDir === dir) {\n return null;\n }\n\n return findNodeProjectRoot(parentDir, pathValidation);\n}\n\nexport function getProjectInfo(debug?: boolean): ProjectInfo {\n const currentPath = process.cwd();\n\n if (debug) {\n console.log(\">>> currentPath\", currentPath);\n }\n\n const projectPath = findNodeProjectRoot(currentPath, isPowerhouseProject);\n\n if (!projectPath) {\n return {\n isGlobal: true,\n path: POWERHOUSE_GLOBAL_DIR,\n packageManager: getPackageManagerFromLockfile(POWERHOUSE_GLOBAL_DIR),\n };\n }\n\n return {\n isGlobal: false,\n path: projectPath,\n packageManager: getPackageManagerFromLockfile(projectPath),\n };\n}\n\nexport function getPackageManagerFromLockfile(dir: string): PackageManager {\n if (fs.existsSync(path.join(dir, packageManagers.pnpm.lockfile))) {\n return \"pnpm\";\n } else if (fs.existsSync(path.join(dir, packageManagers.yarn.lockfile))) {\n return \"yarn\";\n } else if (fs.existsSync(path.join(dir, packageManagers.bun.lockfile))) {\n return \"bun\";\n }\n\n return \"npm\";\n}\n\nexport function updatePackagesArray(\n currentPackages: PowerhouseConfig[\"packages\"] = [],\n dependencies: { name: string; version: string | undefined }[],\n task: \"install\" | \"uninstall\" = \"install\",\n provider: \"registry\" | \"local\" = \"registry\",\n): PowerhouseConfig[\"packages\"] {\n const isInstall = task === \"install\";\n const mappedPackages = dependencies.map((dep) => ({\n packageName: dep.name,\n version: dep.version,\n provider,\n }));\n\n if (isInstall) {\n // Overwrite existing package if version is different\n const filteredPackages = currentPackages.filter(\n (pkg) => !dependencies.find((dep) => dep.name === pkg.packageName),\n );\n return [...filteredPackages, ...mappedPackages];\n }\n\n return currentPackages.filter(\n (pkg) => !dependencies.map((dep) => dep.name).includes(pkg.packageName),\n );\n}\n\n// Modify updateConfigFile to use the new function\nexport function updateConfigFile(\n dependencies: { name: string; version: string | undefined }[],\n projectPath: string,\n task: \"install\" | \"uninstall\" = \"install\",\n provider: \"registry\" | \"local\" = \"registry\",\n registryUrl?: string,\n registryUrlExplicit = false,\n) {\n const configPath = path.join(projectPath, POWERHOUSE_CONFIG_FILE);\n\n if (!fs.existsSync(configPath)) {\n throw new Error(\n `powerhouse.config.json file not found. projectPath: ${projectPath}`,\n );\n }\n\n const config = JSON.parse(\n fs.readFileSync(configPath, \"utf-8\"),\n ) as PowerhouseConfig;\n\n const updatedConfig: PowerhouseConfig = {\n ...config,\n packages: updatePackagesArray(\n config.packages,\n dependencies,\n task,\n provider,\n ),\n };\n\n if (\n task === \"install\" &&\n registryUrl &&\n (registryUrlExplicit || !config.packageRegistryUrl) &&\n dependencies.length > 0\n ) {\n updatedConfig.packageRegistryUrl = registryUrl;\n }\n\n fs.writeFileSync(configPath, JSON.stringify(updatedConfig, null, 2));\n}\n\n/**\n * Recursively searches for a specific file by traversing up the directory tree.\n * Starting from the given path, it checks each parent directory until it finds\n * the target file or reaches the root directory.\n *\n * @param startPath - The absolute path of the directory to start searching from\n * @param targetFile - The name of the file to search for (e.g., 'package.json', 'pnpm-workspace.yaml')\n * @returns The absolute path of the directory containing the target file, or null if not found\n *\n * @example\n * // Find the workspace root directory\n * const workspaceRoot = findContainerDirectory('/path/to/project/src', 'pnpm-workspace.yaml');\n *\n * // Find the nearest package.json\n * const packageDir = findContainerDirectory('/path/to/project/src/components', 'package.json');\n */\nexport const findContainerDirectory = (\n startPath: string,\n targetFile: string,\n): string | null => {\n const filePath = path.join(startPath, targetFile);\n\n if (fs.existsSync(filePath)) {\n return startPath;\n }\n\n const parentDir = path.dirname(startPath);\n\n //reached the root directory and haven't found the file\n if (parentDir === startPath) {\n return null;\n }\n\n return findContainerDirectory(parentDir, targetFile);\n};\n\n/**\n * Removes the CSS imports `ph install --local` used to add to style.css for\n * uninstalled packages; Connect now loads a bundled package's CSS with its code.\n */\nexport function removeStylesImports(\n dependencies: { name: string; version: string | undefined }[],\n projectPath: string,\n) {\n const stylesPath = path.join(projectPath, \"style.css\");\n\n // Check if styles.css exists\n if (!fs.existsSync(stylesPath)) {\n console.warn(\"⚠️ Warning: style.css file not found in project root\");\n return;\n }\n\n const currentStyles = fs.readFileSync(stylesPath, \"utf-8\");\n let updatedStyles = currentStyles;\n\n for (const dep of dependencies) {\n const cssPath = `./node_modules/${dep.name}/dist/style.css`;\n const importStatement = `@import '${cssPath}';`;\n\n // Remove the import line if it exists\n const lines = updatedStyles.split(\"\\n\");\n const filteredLines = lines.filter(\n (line) => !line.trim().includes(importStatement),\n );\n\n if (filteredLines.length !== lines.length) {\n updatedStyles = filteredLines.join(\"\\n\");\n }\n }\n\n // Only write if changes were made\n if (updatedStyles !== currentStyles) {\n fs.writeFileSync(stylesPath, updatedStyles);\n }\n}\n"],"names":[],"mappings":";;;;;;AAIA,MAAa,yBAAyB;AACtC,MAAa,wBAAwB,KAAK,KAAK,QAAQ,GAAG,KAAK;AAG/D,MAAa,kBAAkB;CAC7B,KAAK;EACH,kBAAkB;EAClB,gBAAgB;EAChB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M,gBAAgB,GAAG,aAAa,YAAY,OAAO;CACzD,IAAI,gBAAgB;CAEpB,KAAK,MAAM,OAAO,cAAc;EAE9B,MAAM,kBAAkB,YAAY,kBADF,IAAI,KAAK,iBACC;EAG5C,MAAM,QAAQ,cAAc,MAAM,IAAI;EACtC,MAAM,gBAAgB,MAAM,QACzB,SAAS,CAAC,KAAK,KAAK,CAAC,CAAC,SAAS,eAAe,CACjD;EAEA,IAAI,cAAc,WAAW,MAAM,QACjC,gBAAgB,cAAc,KAAK,IAAI;CAE3C;CAGA,IAAI,kBAAkB,eACpB,GAAG,cAAc,YAAY,aAAa;AAE9C","debug_id":"0f1fdb8d-6b86-5a6f-b105-a704f04a63ab"}
@@ -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]="15a55997-5950-56a1-9948-172da9dfa017")}catch(e){}}();
3
- import { t as getVersion } from "./get-version-JkZQOcO1.mjs";
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]="9c1bf72c-bcf7-512a-813a-8cfe96e6aa48")}catch(e){}}();
3
+ import { t as getVersion } from "./get-version-CcYVboCW.mjs";
4
4
  import { f as verifyReleaseApproval, i as revisionFiles, n as publishedFiles, o as packRelease, r as readReleaseApproval, s as packedDigests, u as decisionWithoutApproval } from "./files-D6_euBBn.mjs";
5
5
  //#region src/services/release/verify.ts
6
6
  /**
@@ -67,5 +67,5 @@ function checkApprovalBeforePublish(packageRoot, required) {
67
67
  //#endregion
68
68
  export { checkApprovalBeforePublish, renderReleaseDecision, verifyRelease };
69
69
 
70
- //# sourceMappingURL=verify-DCf_nRt8.mjs.map
71
- //# debugId=15a55997-5950-56a1-9948-172da9dfa017
70
+ //# sourceMappingURL=verify-NK6a_7j8.mjs.map
71
+ //# debugId=9c1bf72c-bcf7-512a-813a-8cfe96e6aa48
@@ -1 +1 @@
1
- {"version":3,"file":"verify-DCf_nRt8.mjs","sources":["../src/services/release/verify.ts"],"sourcesContent":["import { getVersion } from \"../../get-version.js\";\nimport {\n type ApprovalRead,\n decisionWithoutApproval,\n type ReleaseDecision,\n verifyReleaseApproval,\n} from \"./approval.js\";\nimport { publishedFiles, readReleaseApproval, revisionFiles } from \"./files.js\";\nimport { packedDigests, packRelease, type PackedRelease } from \"./pack.js\";\nimport type { FileDigest } from \"./revision.js\";\n\n/**\n * Compares the package as it is now with its release approval: the files\n * the revision reads, with the output directory and exclusions the approval\n * records, and what `npm pack` publishes, or `published` when the caller\n * already packed it. Throws when either cannot be read.\n */\nexport function verifyRelease(\n packageRoot: string,\n read: ApprovalRead = readReleaseApproval(packageRoot),\n published?: readonly FileDigest[],\n): ReleaseDecision {\n if (read.kind !== \"found\") return decisionWithoutApproval(read);\n const { approval } = read;\n return verifyReleaseApproval(approval, {\n phCliVersion: getVersion(),\n files: revisionFiles(packageRoot, [\n approval.outDir,\n ...approval.packageRevision.excluded,\n ]),\n publishedFiles: published ?? publishedFiles(packageRoot),\n });\n}\n\nconst HEADLINES: Readonly<Record<ReleaseDecision[\"decision\"], string>> = {\n approved: \"the release approval matches this package\",\n missing: \"this package has no release approval\",\n unreadable: \"the release approval cannot be read\",\n stale: \"the release approval does not match this package\",\n refused: \"the release approval records a release check that did not pass\",\n};\n\n/** The decision and each reason on its own line. */\nexport function renderReleaseDecision(decision: ReleaseDecision): string {\n return [\n `${decision.decision}: ${HEADLINES[decision.decision]}`,\n ...decision.reasons.map((reason) => ` - ${reason}`),\n ].join(\"\\n\");\n}\n\n/**\n * Whether `ph publish` goes on. With `--require-approval`, `packed` is the\n * tarball the approval was checked against: publish that file, and call its\n * `dispose` once done.\n */\nexport type PublishCheck =\n | { readonly proceed: false }\n | { readonly proceed: true; readonly packed?: PackedRelease };\n\n/**\n * Checks the release approval before `ph publish` resolves a registry.\n * Without an approval file and without `required`, does nothing, as before\n * approvals existed. Otherwise a decision other than approved is a warning,\n * or with `required` a refusal.\n */\nexport function checkApprovalBeforePublish(\n packageRoot: string,\n required: boolean,\n): PublishCheck {\n const read = readReleaseApproval(packageRoot);\n if (read.kind === \"missing\" && !required) return { proceed: true };\n let text: string;\n let packed: PackedRelease | undefined;\n let approved = false;\n try {\n if (required && read.kind === \"found\") packed = packRelease(packageRoot);\n const decision = verifyRelease(\n packageRoot,\n read,\n packed && packedDigests(packed),\n );\n approved = decision.decision === \"approved\";\n text = renderReleaseDecision(decision);\n } catch (error) {\n text = `the release approval could not be checked: ${error instanceof Error ? error.message : String(error)}`;\n }\n if (approved) {\n console.log(`✔ ${text}`);\n return { proceed: true, packed };\n }\n packed?.dispose();\n if (required) {\n console.error(\n `✘ ${text}\\nph publish --require-approval publishes only an approved package. Run ph build --release, then publish again.`,\n );\n return { proceed: false };\n }\n console.warn(\n `⚠ ${text}\\nPublishing anyway. Run ph build --release to approve this package, or pass --require-approval to stop here instead.`,\n );\n return { proceed: true };\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAiBA,SAAgB,cACd,aACA,OAAqB,oBAAoB,WAAW,GACpD,WACiB;CACjB,IAAI,KAAK,SAAS,SAAS,OAAO,wBAAwB,IAAI;CAC9D,MAAM,EAAE,aAAa;CACrB,OAAO,sBAAsB,UAAU;EACrC,cAAc,WAAW;EACzB,OAAO,cAAc,aAAa,CAChC,SAAS,QACT,GAAG,SAAS,gBAAgB,QAC9B,CAAC;EACD,gBAAgB,aAAa,eAAe,WAAW;CACzD,CAAC;AACH;AAEA,MAAM,YAAmE;CACvE,UAAU;CACV,SAAS;CACT,YAAY;CACZ,OAAO;CACP,SAAS;AACX;;AAGA,SAAgB,sBAAsB,UAAmC;CACvE,OAAO,CACL,GAAG,SAAS,SAAS,IAAI,UAAU,SAAS,aAC5C,GAAG,SAAS,QAAQ,KAAK,WAAW,OAAO,QAAQ,CACrD,CAAC,CAAC,KAAK,IAAI;AACb;;;;;;;AAiBA,SAAgB,2BACd,aACA,UACc;CACd,MAAM,OAAO,oBAAoB,WAAW;CAC5C,IAAI,KAAK,SAAS,aAAa,CAAC,UAAU,OAAO,EAAE,SAAS,KAAK;CACjE,IAAI;CACJ,IAAI;CACJ,IAAI,WAAW;CACf,IAAI;EACF,IAAI,YAAY,KAAK,SAAS,SAAS,SAAS,YAAY,WAAW;EACvE,MAAM,WAAW,cACf,aACA,MACA,UAAU,cAAc,MAAM,CAChC;EACA,WAAW,SAAS,aAAa;EACjC,OAAO,sBAAsB,QAAQ;CACvC,SAAS,OAAO;EACd,OAAO,8CAA8C,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;CAC5G;CACA,IAAI,UAAU;EACZ,QAAQ,IAAI,KAAK,MAAM;EACvB,OAAO;GAAE,SAAS;GAAM;EAAO;CACjC;CACA,QAAQ,QAAQ;CAChB,IAAI,UAAU;EACZ,QAAQ,MACN,KAAK,KAAK,gHACZ;EACA,OAAO,EAAE,SAAS,MAAM;CAC1B;CACA,QAAQ,KACN,KAAK,KAAK,sHACZ;CACA,OAAO,EAAE,SAAS,KAAK;AACzB","debug_id":"15a55997-5950-56a1-9948-172da9dfa017"}
1
+ {"version":3,"file":"verify-NK6a_7j8.mjs","sources":["../src/services/release/verify.ts"],"sourcesContent":["import { getVersion } from \"../../get-version.js\";\nimport {\n type ApprovalRead,\n decisionWithoutApproval,\n type ReleaseDecision,\n verifyReleaseApproval,\n} from \"./approval.js\";\nimport { publishedFiles, readReleaseApproval, revisionFiles } from \"./files.js\";\nimport { packedDigests, packRelease, type PackedRelease } from \"./pack.js\";\nimport type { FileDigest } from \"./revision.js\";\n\n/**\n * Compares the package as it is now with its release approval: the files\n * the revision reads, with the output directory and exclusions the approval\n * records, and what `npm pack` publishes, or `published` when the caller\n * already packed it. Throws when either cannot be read.\n */\nexport function verifyRelease(\n packageRoot: string,\n read: ApprovalRead = readReleaseApproval(packageRoot),\n published?: readonly FileDigest[],\n): ReleaseDecision {\n if (read.kind !== \"found\") return decisionWithoutApproval(read);\n const { approval } = read;\n return verifyReleaseApproval(approval, {\n phCliVersion: getVersion(),\n files: revisionFiles(packageRoot, [\n approval.outDir,\n ...approval.packageRevision.excluded,\n ]),\n publishedFiles: published ?? publishedFiles(packageRoot),\n });\n}\n\nconst HEADLINES: Readonly<Record<ReleaseDecision[\"decision\"], string>> = {\n approved: \"the release approval matches this package\",\n missing: \"this package has no release approval\",\n unreadable: \"the release approval cannot be read\",\n stale: \"the release approval does not match this package\",\n refused: \"the release approval records a release check that did not pass\",\n};\n\n/** The decision and each reason on its own line. */\nexport function renderReleaseDecision(decision: ReleaseDecision): string {\n return [\n `${decision.decision}: ${HEADLINES[decision.decision]}`,\n ...decision.reasons.map((reason) => ` - ${reason}`),\n ].join(\"\\n\");\n}\n\n/**\n * Whether `ph publish` goes on. With `--require-approval`, `packed` is the\n * tarball the approval was checked against: publish that file, and call its\n * `dispose` once done.\n */\nexport type PublishCheck =\n | { readonly proceed: false }\n | { readonly proceed: true; readonly packed?: PackedRelease };\n\n/**\n * Checks the release approval before `ph publish` resolves a registry.\n * Without an approval file and without `required`, does nothing, as before\n * approvals existed. Otherwise a decision other than approved is a warning,\n * or with `required` a refusal.\n */\nexport function checkApprovalBeforePublish(\n packageRoot: string,\n required: boolean,\n): PublishCheck {\n const read = readReleaseApproval(packageRoot);\n if (read.kind === \"missing\" && !required) return { proceed: true };\n let text: string;\n let packed: PackedRelease | undefined;\n let approved = false;\n try {\n if (required && read.kind === \"found\") packed = packRelease(packageRoot);\n const decision = verifyRelease(\n packageRoot,\n read,\n packed && packedDigests(packed),\n );\n approved = decision.decision === \"approved\";\n text = renderReleaseDecision(decision);\n } catch (error) {\n text = `the release approval could not be checked: ${error instanceof Error ? error.message : String(error)}`;\n }\n if (approved) {\n console.log(`✔ ${text}`);\n return { proceed: true, packed };\n }\n packed?.dispose();\n if (required) {\n console.error(\n `✘ ${text}\\nph publish --require-approval publishes only an approved package. Run ph build --release, then publish again.`,\n );\n return { proceed: false };\n }\n console.warn(\n `⚠ ${text}\\nPublishing anyway. Run ph build --release to approve this package, or pass --require-approval to stop here instead.`,\n );\n return { proceed: true };\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAiBA,SAAgB,cACd,aACA,OAAqB,oBAAoB,WAAW,GACpD,WACiB;CACjB,IAAI,KAAK,SAAS,SAAS,OAAO,wBAAwB,IAAI;CAC9D,MAAM,EAAE,aAAa;CACrB,OAAO,sBAAsB,UAAU;EACrC,cAAc,WAAW;EACzB,OAAO,cAAc,aAAa,CAChC,SAAS,QACT,GAAG,SAAS,gBAAgB,QAC9B,CAAC;EACD,gBAAgB,aAAa,eAAe,WAAW;CACzD,CAAC;AACH;AAEA,MAAM,YAAmE;CACvE,UAAU;CACV,SAAS;CACT,YAAY;CACZ,OAAO;CACP,SAAS;AACX;;AAGA,SAAgB,sBAAsB,UAAmC;CACvE,OAAO,CACL,GAAG,SAAS,SAAS,IAAI,UAAU,SAAS,aAC5C,GAAG,SAAS,QAAQ,KAAK,WAAW,OAAO,QAAQ,CACrD,CAAC,CAAC,KAAK,IAAI;AACb;;;;;;;AAiBA,SAAgB,2BACd,aACA,UACc;CACd,MAAM,OAAO,oBAAoB,WAAW;CAC5C,IAAI,KAAK,SAAS,aAAa,CAAC,UAAU,OAAO,EAAE,SAAS,KAAK;CACjE,IAAI;CACJ,IAAI;CACJ,IAAI,WAAW;CACf,IAAI;EACF,IAAI,YAAY,KAAK,SAAS,SAAS,SAAS,YAAY,WAAW;EACvE,MAAM,WAAW,cACf,aACA,MACA,UAAU,cAAc,MAAM,CAChC;EACA,WAAW,SAAS,aAAa;EACjC,OAAO,sBAAsB,QAAQ;CACvC,SAAS,OAAO;EACd,OAAO,8CAA8C,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;CAC5G;CACA,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