@powerhousedao/ph-cli 6.2.3-dev.1 → 6.2.3-dev.100

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 (180) hide show
  1. package/README.md +21 -0
  2. package/dist/{auth-AR3VxAIk.mjs → auth-BFUq7CvE.mjs} +3 -3
  3. package/dist/{auth-AR3VxAIk.mjs.map → auth-BFUq7CvE.mjs.map} +1 -1
  4. package/dist/auth-CNhbN5UM.mjs +4 -0
  5. package/dist/authoring-mode-DWbbsuWh.mjs +23 -0
  6. package/dist/authoring-mode-DWbbsuWh.mjs.map +1 -0
  7. package/dist/build-C1mmZvlb.mjs +3011 -0
  8. package/dist/build-C1mmZvlb.mjs.map +1 -0
  9. package/dist/build-Ws5hhqol.mjs +4 -0
  10. package/dist/check-Cco7-UC2.mjs +65 -0
  11. package/dist/check-Cco7-UC2.mjs.map +1 -0
  12. package/dist/check-CjFMilhk.mjs +4 -0
  13. package/dist/check-DvG9Xy4c.mjs +60 -0
  14. package/dist/check-DvG9Xy4c.mjs.map +1 -0
  15. package/dist/{cli-connect-override-D3hh4aH_.mjs → cli-connect-override-D3N3gbp_.mjs} +39 -27
  16. package/dist/cli-connect-override-D3N3gbp_.mjs.map +1 -0
  17. package/dist/cli.d.mts +2 -1
  18. package/dist/cli.mjs +54 -1178
  19. package/dist/cli.mjs.map +1 -1
  20. package/dist/compound-DO_mvh0O-Dp1YPhR0.mjs +2806 -0
  21. package/dist/compound-DO_mvh0O-Dp1YPhR0.mjs.map +1 -0
  22. package/dist/connect-build-COdexcA8.mjs +322 -0
  23. package/dist/connect-build-COdexcA8.mjs.map +1 -0
  24. package/dist/{connect-config-BWGiW3IB.mjs → connect-config-C6hKMsUG.mjs} +19 -12
  25. package/dist/connect-config-C6hKMsUG.mjs.map +1 -0
  26. package/dist/connect-preview-CdFvlANO.mjs +49 -0
  27. package/dist/connect-preview-CdFvlANO.mjs.map +1 -0
  28. package/dist/connect-studio-C7Bbh50O.mjs +81 -0
  29. package/dist/connect-studio-C7Bbh50O.mjs.map +1 -0
  30. package/dist/connect-studio-xQNYl142.mjs +4 -0
  31. package/dist/definitions-worker.d.mts +98 -0
  32. package/dist/definitions-worker.d.mts.map +1 -0
  33. package/dist/definitions-worker.mjs +28 -0
  34. package/dist/definitions-worker.mjs.map +1 -0
  35. package/dist/dist-B-_lMGlB.mjs +480 -0
  36. package/dist/dist-B-_lMGlB.mjs.map +1 -0
  37. package/dist/evidence-Dchpoogs.mjs +120 -0
  38. package/dist/evidence-Dchpoogs.mjs.map +1 -0
  39. package/dist/explain-lynfOtDg.mjs +230 -0
  40. package/dist/explain-lynfOtDg.mjs.map +1 -0
  41. package/dist/export-YkeGUZjR.mjs +42 -0
  42. package/dist/export-YkeGUZjR.mjs.map +1 -0
  43. package/dist/external-M25AgDIE.d.mts +4277 -0
  44. package/dist/external-M25AgDIE.d.mts.map +1 -0
  45. package/dist/feature-flags-xwqcHEWC.mjs +4 -0
  46. package/dist/files-D6_euBBn.mjs +457 -0
  47. package/dist/files-D6_euBBn.mjs.map +1 -0
  48. package/dist/generate-all-_7S0Iii2.mjs +36 -0
  49. package/dist/generate-all-_7S0Iii2.mjs.map +1 -0
  50. package/dist/generate-app-hm6CJ_4O.mjs +72 -0
  51. package/dist/generate-app-hm6CJ_4O.mjs.map +1 -0
  52. package/dist/generate-desktop-shell-CEcE_1gb.mjs +323 -0
  53. package/dist/generate-desktop-shell-CEcE_1gb.mjs.map +1 -0
  54. package/dist/generate-document-model-DCjzz3Sa.mjs +114 -0
  55. package/dist/generate-document-model-DCjzz3Sa.mjs.map +1 -0
  56. package/dist/generate-editor-DdoapkEK.mjs +64 -0
  57. package/dist/generate-editor-DdoapkEK.mjs.map +1 -0
  58. package/dist/generate-hosts-BFmPIW2X.mjs +18 -0
  59. package/dist/generate-hosts-BFmPIW2X.mjs.map +1 -0
  60. package/dist/generate-hosts-RWj7WPHZ.mjs +4 -0
  61. package/dist/generate-migration-file-yK8uA70U.mjs +20 -0
  62. package/dist/generate-migration-file-yK8uA70U.mjs.map +1 -0
  63. package/dist/generate-piece-5Nyr2UZj.mjs +73 -0
  64. package/dist/generate-piece-5Nyr2UZj.mjs.map +1 -0
  65. package/dist/generate-piece-action-DqR8BcoO.mjs +31 -0
  66. package/dist/generate-piece-action-DqR8BcoO.mjs.map +1 -0
  67. package/dist/generate-piece-trigger-CZaDD-cc.mjs +30 -0
  68. package/dist/generate-piece-trigger-CZaDD-cc.mjs.map +1 -0
  69. package/dist/generate-processor-BVjOsfjJ.mjs +58 -0
  70. package/dist/generate-processor-BVjOsfjJ.mjs.map +1 -0
  71. package/dist/generate-subgraph-CrHbYK91.mjs +64 -0
  72. package/dist/generate-subgraph-CrHbYK91.mjs.map +1 -0
  73. package/dist/get-version-BBiGShxz.mjs +11 -0
  74. package/dist/get-version-BBiGShxz.mjs.map +1 -0
  75. package/dist/index-BdxG1c0H.d.mts +188 -0
  76. package/dist/index-BdxG1c0H.d.mts.map +1 -0
  77. package/dist/{init-BZP6gvYd.mjs → init-BjwbWklG.mjs} +24 -15
  78. package/dist/init-BjwbWklG.mjs.map +1 -0
  79. package/dist/inspect-BpVHe9vz.mjs +46 -0
  80. package/dist/inspect-BpVHe9vz.mjs.map +1 -0
  81. package/dist/{inspect-DXjbQEV_.mjs → inspect-zWJnBDMJ.mjs} +11 -4
  82. package/dist/inspect-zWJnBDMJ.mjs.map +1 -0
  83. package/dist/install-added-dependencies-DnZFR3aE.mjs +18 -0
  84. package/dist/install-added-dependencies-DnZFR3aE.mjs.map +1 -0
  85. package/dist/keyframes-bFo9iDhT.mjs +201 -0
  86. package/dist/keyframes-bFo9iDhT.mjs.map +1 -0
  87. package/dist/mcp-BK-qb1ZS.mjs +262 -0
  88. package/dist/mcp-BK-qb1ZS.mjs.map +1 -0
  89. package/dist/migrate-B-MM9TlS.mjs +177 -0
  90. package/dist/migrate-B-MM9TlS.mjs.map +1 -0
  91. package/dist/module-dir-1avCXsBi.mjs +17 -0
  92. package/dist/module-dir-1avCXsBi.mjs.map +1 -0
  93. package/dist/npm-args-g1Tgel4s.mjs +78 -0
  94. package/dist/npm-args-g1Tgel4s.mjs.map +1 -0
  95. package/dist/offered-routes-imports-CQInWI6y.mjs +4 -0
  96. package/dist/offered-routes-imports-CalXK9dh.mjs +96 -0
  97. package/dist/offered-routes-imports-CalXK9dh.mjs.map +1 -0
  98. package/dist/ph-cli-commands-DwSp4Sbq.mjs +1770 -0
  99. package/dist/ph-cli-commands-DwSp4Sbq.mjs.map +1 -0
  100. package/dist/ph-cli-commands-HLM5KIpd.mjs +4 -0
  101. package/dist/{registry-auth-DxEWCJu2.mjs → registry-auth-Bm5AR-fB.mjs} +4 -4
  102. package/dist/{registry-auth-DxEWCJu2.mjs.map → registry-auth-Bm5AR-fB.mjs.map} +1 -1
  103. package/dist/render-BO-Nwn2H.mjs +71 -0
  104. package/dist/render-BO-Nwn2H.mjs.map +1 -0
  105. package/dist/render-DdieUjtg.mjs +4 -0
  106. package/dist/run-DEKE4MJY.mjs +111 -0
  107. package/dist/run-DEKE4MJY.mjs.map +1 -0
  108. package/dist/run-DP3fNgPv.mjs +4 -0
  109. package/dist/run-sugar-D9lIzhAx.mjs +39 -0
  110. package/dist/run-sugar-D9lIzhAx.mjs.map +1 -0
  111. package/dist/runners/connect.d.mts +17 -0
  112. package/dist/runners/connect.d.mts.map +1 -0
  113. package/dist/runners/connect.mjs +63 -0
  114. package/dist/runners/connect.mjs.map +1 -0
  115. package/dist/runners/switchboard.d.mts +11 -0
  116. package/dist/runners/switchboard.d.mts.map +1 -0
  117. package/dist/runners/switchboard.mjs +21 -0
  118. package/dist/runners/switchboard.mjs.map +1 -0
  119. package/dist/schemas-DzgKfQIx.mjs +6024 -0
  120. package/dist/schemas-DzgKfQIx.mjs.map +1 -0
  121. package/dist/scripts/emit-runner-schemas.ts +24 -0
  122. package/dist/scripts/generate-commands-docs.ts +17 -0
  123. package/dist/scripts/manage-environment +0 -0
  124. package/dist/scripts/setup.sh +0 -0
  125. package/dist/{switchboard-migrate-NQ7LHWSi.mjs → switchboard-migrate-Docb8Cjv.mjs} +6 -5
  126. package/dist/{switchboard-migrate-NQ7LHWSi.mjs.map → switchboard-migrate-Docb8Cjv.mjs.map} +1 -1
  127. package/dist/switchboard-proxy-CGfMtENM.mjs +37 -0
  128. package/dist/switchboard-proxy-CGfMtENM.mjs.map +1 -0
  129. package/dist/{switchboard-reset-BcQXlcVf.mjs → switchboard-reset-MtTB_GAI.mjs} +8 -6
  130. package/dist/switchboard-reset-MtTB_GAI.mjs.map +1 -0
  131. package/dist/sync-connect-routes-BtAsFPXN.mjs +4 -0
  132. package/dist/sync-connect-routes-t0Slg-P6.mjs +25 -0
  133. package/dist/sync-connect-routes-t0Slg-P6.mjs.map +1 -0
  134. package/dist/{utils-C4isxXSO.mjs → utils-9KyRM0mf.mjs} +6 -34
  135. package/dist/{utils-C4isxXSO.mjs.map → utils-9KyRM0mf.mjs.map} +1 -1
  136. package/dist/utils-TO9lB8Xs.mjs +4 -0
  137. package/dist/verify-l5f7BDmy.mjs +71 -0
  138. package/dist/verify-l5f7BDmy.mjs.map +1 -0
  139. package/dist/{vetra-DkF6EJMY.mjs → vetra-DSFzAl_1.mjs} +115 -148
  140. package/dist/vetra-DSFzAl_1.mjs.map +1 -0
  141. package/dist/vetra-launch-DQDZxGTV.mjs +343 -0
  142. package/dist/vetra-launch-DQDZxGTV.mjs.map +1 -0
  143. package/dist/warn-subgraph-type-conflicts-BOHBmThq.mjs +19 -0
  144. package/dist/warn-subgraph-type-conflicts-BOHBmThq.mjs.map +1 -0
  145. package/package.json +45 -18
  146. package/dist/auth-BNkN6kS9.mjs +0 -4
  147. package/dist/build-C-A5-ipO.mjs +0 -4
  148. package/dist/build-uQXq6_HU.mjs +0 -71
  149. package/dist/build-uQXq6_HU.mjs.map +0 -1
  150. package/dist/cli-connect-override-D3hh4aH_.mjs.map +0 -1
  151. package/dist/connect-build-WL4axo4z.mjs +0 -43
  152. package/dist/connect-build-WL4axo4z.mjs.map +0 -1
  153. package/dist/connect-config-BWGiW3IB.mjs.map +0 -1
  154. package/dist/connect-preview-D7ypzFDc.mjs +0 -28
  155. package/dist/connect-preview-D7ypzFDc.mjs.map +0 -1
  156. package/dist/connect-studio-BIQzyq5B.mjs +0 -5
  157. package/dist/connect-studio-D6rfWCNB.mjs +0 -31
  158. package/dist/connect-studio-D6rfWCNB.mjs.map +0 -1
  159. package/dist/generate-all-DrT4ZxHX.mjs +0 -30
  160. package/dist/generate-all-DrT4ZxHX.mjs.map +0 -1
  161. package/dist/generate-app-DNNqA-H3.mjs +0 -48
  162. package/dist/generate-app-DNNqA-H3.mjs.map +0 -1
  163. package/dist/generate-document-model-BJXyODfm.mjs +0 -34
  164. package/dist/generate-document-model-BJXyODfm.mjs.map +0 -1
  165. package/dist/generate-editor-BejvaVVT.mjs +0 -48
  166. package/dist/generate-editor-BejvaVVT.mjs.map +0 -1
  167. package/dist/generate-processor-_WOx-mMe.mjs +0 -40
  168. package/dist/generate-processor-_WOx-mMe.mjs.map +0 -1
  169. package/dist/generate-subgraph-BsHUstpl.mjs +0 -38
  170. package/dist/generate-subgraph-BsHUstpl.mjs.map +0 -1
  171. package/dist/init-BZP6gvYd.mjs.map +0 -1
  172. package/dist/inspect-DXjbQEV_.mjs.map +0 -1
  173. package/dist/migrate-jGKfE02L.mjs +0 -83
  174. package/dist/migrate-jGKfE02L.mjs.map +0 -1
  175. package/dist/switchboard-CJMoMzWx.mjs +0 -75
  176. package/dist/switchboard-CJMoMzWx.mjs.map +0 -1
  177. package/dist/switchboard-iRFugh8I.mjs +0 -4
  178. package/dist/switchboard-reset-BcQXlcVf.mjs.map +0 -1
  179. package/dist/utils-BzwczAW-.mjs +0 -4
  180. package/dist/vetra-DkF6EJMY.mjs.map +0 -1
@@ -0,0 +1,24 @@
1
+ import fs from "node:fs";
2
+ import path from "node:path";
3
+ import { fileURLToPath } from "node:url";
4
+ import { emittedRunnerSchemas } from "../src/runners/emitted-schemas.js";
5
+
6
+ /**
7
+ * Writes the runners' editor JSON Schemas into clis/ph-cli/schemas/. Run
8
+ * `pnpm --filter @powerhousedao/ph-cli emit-schemas` after changing a
9
+ * runner's hostSchema or outputsSchema; the drift test
10
+ * (test/runner-schemas-drift.test.ts) fails while the files are behind.
11
+ */
12
+ const outDir = path.join(
13
+ path.dirname(fileURLToPath(import.meta.url)),
14
+ "..",
15
+ "schemas",
16
+ );
17
+ fs.mkdirSync(outDir, { recursive: true });
18
+ for (const [file, schema] of Object.entries(emittedRunnerSchemas())) {
19
+ fs.writeFileSync(
20
+ path.join(outDir, file),
21
+ `${JSON.stringify(schema, null, 2)}\n`,
22
+ );
23
+ console.log(`emitted schemas/${file}`);
24
+ }
@@ -1,19 +1,27 @@
1
1
  import { writeCliDocsMarkdownFile } from "@powerhousedao/codegen/file-builders";
2
2
  import { accessToken } from "../src/commands/access-token.js";
3
+ import { build as buildCmd } from "../src/commands/build.js";
3
4
  import { build, connect, preview, studio } from "../src/commands/connect.js";
4
5
  import { generateAllCmd } from "../src/commands/generate-all.js";
5
6
  import { generateAppCmd } from "../src/commands/generate-app.js";
7
+ import { generateConnectRoutesCmd } from "../src/commands/generate-connect-routes.js";
6
8
  import { generateDocumentModelCmd } from "../src/commands/generate-document-model.js";
7
9
  import { generateEditorCmd } from "../src/commands/generate-editor.js";
8
10
  import { generateMigrationFileCmd } from "../src/commands/generate-migration-file.js";
11
+ import { generatePieceActionCmd } from "../src/commands/generate-piece-action.js";
12
+ import { generatePieceTriggerCmd } from "../src/commands/generate-piece-trigger.js";
13
+ import { generatePieceCmd } from "../src/commands/generate-piece.js";
9
14
  import { generateProcessorCmd } from "../src/commands/generate-processor.js";
10
15
  import { generateSubgraphCmd } from "../src/commands/generate-subgraph.js";
11
16
  import { generate } from "../src/commands/generate.js";
12
17
  import { inspect } from "../src/commands/inspect.js";
13
18
  import { install } from "../src/commands/install.js";
19
+ import { keyframes } from "../src/commands/keyframes.js";
14
20
  import { list } from "../src/commands/list.js";
15
21
  import { login } from "../src/commands/login.js";
22
+ import { mcp } from "../src/commands/mcp.js";
16
23
  import { migrate } from "../src/commands/migrate.js";
24
+ import { modelCheck, modelInspect } from "../src/commands/model.js";
17
25
  import { phCli } from "../src/commands/ph-cli.js";
18
26
  import { switchboard } from "../src/commands/switchboard.js";
19
27
  import { uninstall } from "../src/commands/uninstall.js";
@@ -27,16 +35,25 @@ const commands = [
27
35
  { name: "app", command: generateAppCmd },
28
36
  { name: "processor", command: generateProcessorCmd },
29
37
  { name: "subgraph", command: generateSubgraphCmd },
38
+ { name: "piece", command: generatePieceCmd },
39
+ { name: "piece-action", command: generatePieceActionCmd },
40
+ { name: "piece-trigger", command: generatePieceTriggerCmd },
30
41
  { name: "migration-file", command: generateMigrationFileCmd },
42
+ { name: "connect-routes", command: generateConnectRoutesCmd },
31
43
  { name: "vetra", command: vetra },
44
+ { name: "build", command: buildCmd },
32
45
  { name: "connect", command: connect },
33
46
  { name: "connect studio", command: studio },
34
47
  { name: "connect build", command: build },
35
48
  { name: "connect preview", command: preview },
36
49
  { name: "access token", command: accessToken },
37
50
  { name: "inspect", command: inspect },
51
+ { name: "keyframes", command: keyframes },
38
52
  { name: "list", command: list },
53
+ { name: "mcp", command: mcp },
39
54
  { name: "migrate", command: migrate },
55
+ { name: "model check", command: modelCheck },
56
+ { name: "model inspect", command: modelInspect },
40
57
  { name: "switchboard", command: switchboard },
41
58
  { name: "login", command: login },
42
59
  { name: "install", command: install },
File without changes
File without changes
@@ -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]="9ca57982-bee9-5f08-aa81-5fb5a7ca8324")}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]="ff779d1d-972c-53db-a71e-946208cc05bd")}catch(e){}}();
3
+ import { REACTOR_SCHEMA, getMigrationStatus, runMigrations } from "@powerhousedao/reactor";
3
4
  import { Kysely, PostgresDialect } from "kysely";
4
5
  import { Pool } from "pg";
5
- import { REACTOR_SCHEMA, getMigrationStatus, runMigrations } from "@powerhousedao/reactor";
6
6
  //#region src/services/switchboard-migrate.ts
7
7
  function isPostgresUrl(url) {
8
8
  return url.startsWith("postgresql://") || url.startsWith("postgres://");
@@ -15,7 +15,8 @@ async function runSwitchboardMigrations(options) {
15
15
  return;
16
16
  }
17
17
  console.log(`Database: ${dbPath}`);
18
- const db = new Kysely({ dialect: new PostgresDialect({ pool: new Pool({ connectionString: dbPath }) }) });
18
+ const pool = new Pool({ connectionString: dbPath });
19
+ const db = new Kysely({ dialect: new PostgresDialect({ pool }) });
19
20
  try {
20
21
  if (options.statusOnly) {
21
22
  console.log("\nChecking migration status...");
@@ -49,5 +50,5 @@ async function runSwitchboardMigrations(options) {
49
50
  //#endregion
50
51
  export { runSwitchboardMigrations };
51
52
 
52
- //# sourceMappingURL=switchboard-migrate-NQ7LHWSi.mjs.map
53
- //# debugId=9ca57982-bee9-5f08-aa81-5fb5a7ca8324
53
+ //# sourceMappingURL=switchboard-migrate-Docb8Cjv.mjs.map
54
+ //# debugId=ff779d1d-972c-53db-a71e-946208cc05bd
@@ -1 +1 @@
1
- {"version":3,"file":"switchboard-migrate-NQ7LHWSi.mjs","sources":["../src/services/switchboard-migrate.ts"],"sourcesContent":["import { Kysely, PostgresDialect } from \"kysely\";\nimport { Pool } from \"pg\";\nimport {\n runMigrations,\n getMigrationStatus,\n REACTOR_SCHEMA,\n} from \"@powerhousedao/reactor\";\n\ninterface MigrationOptions {\n dbPath?: string;\n statusOnly?: boolean;\n}\n\nfunction isPostgresUrl(url: string): boolean {\n return url.startsWith(\"postgresql://\") || url.startsWith(\"postgres://\");\n}\n\nexport async function runSwitchboardMigrations(\n options: MigrationOptions,\n): Promise<void> {\n const dbPath =\n options.dbPath ??\n process.env.PH_REACTOR_DATABASE_URL ??\n process.env.DATABASE_URL;\n\n if (!dbPath || !isPostgresUrl(dbPath)) {\n console.log(\"No PostgreSQL URL configured. Skipping migrations.\");\n console.log(\"(PGlite migrations are handled automatically on startup)\");\n return;\n }\n\n console.log(`Database: ${dbPath}`);\n\n const pool = new Pool({ connectionString: dbPath });\n\n const db = new Kysely<any>({\n dialect: new PostgresDialect({ pool }),\n });\n\n try {\n if (options.statusOnly) {\n console.log(\"\\nChecking migration status...\");\n const migrations = await getMigrationStatus(db, REACTOR_SCHEMA);\n\n console.log(\"\\nMigration Status:\");\n console.log(\"=================\");\n\n for (const migration of migrations) {\n const status = migration.executedAt\n ? `[OK] Executed at ${migration.executedAt.toISOString()}`\n : \"[--] Pending\";\n console.log(`${status} - ${migration.name}`);\n }\n } else {\n console.log(\"\\nRunning migrations...\");\n const result = await runMigrations(db, REACTOR_SCHEMA);\n\n if (!result.success) {\n console.error(\"Migration failed:\", result.error?.message);\n process.exit(1);\n }\n\n if (result.migrationsExecuted.length === 0) {\n console.log(\"No migrations to run - database is up to date\");\n } else {\n console.log(\n `Successfully executed ${result.migrationsExecuted.length} migration(s):`,\n );\n for (const name of result.migrationsExecuted) {\n console.log(` - ${name}`);\n }\n }\n }\n } catch (error) {\n console.error(\n \"Error:\",\n error instanceof Error ? error.message : String(error),\n );\n process.exit(1);\n } finally {\n await db.destroy();\n }\n}\n"],"names":[],"mappings":";;;;;;AAaA,SAAS,cAAc,KAAsB;AAC3C,QAAO,IAAI,WAAW,gBAAgB,IAAI,IAAI,WAAW,cAAc;;AAGzE,eAAsB,yBACpB,SACe;CACf,MAAM,SACJ,QAAQ,UACR,QAAQ,IAAI,2BACZ,QAAQ,IAAI;AAEd,KAAI,CAAC,UAAU,CAAC,cAAc,OAAO,EAAE;AACrC,UAAQ,IAAI,qDAAqD;AACjE,UAAQ,IAAI,2DAA2D;AACvE;;AAGF,SAAQ,IAAI,aAAa,SAAS;CAIlC,MAAM,KAAK,IAAI,OAAY,EACzB,SAAS,IAAI,gBAAgB,EAAE,MAHpB,IAAI,KAAK,EAAE,kBAAkB,QAAQ,CAAC,EAGZ,CAAC,EACvC,CAAC;AAEF,KAAI;AACF,MAAI,QAAQ,YAAY;AACtB,WAAQ,IAAI,iCAAiC;GAC7C,MAAM,aAAa,MAAM,mBAAmB,IAAI,eAAe;AAE/D,WAAQ,IAAI,sBAAsB;AAClC,WAAQ,IAAI,oBAAoB;AAEhC,QAAK,MAAM,aAAa,YAAY;IAClC,MAAM,SAAS,UAAU,aACrB,oBAAoB,UAAU,WAAW,aAAa,KACtD;AACJ,YAAQ,IAAI,GAAG,OAAO,KAAK,UAAU,OAAO;;SAEzC;AACL,WAAQ,IAAI,0BAA0B;GACtC,MAAM,SAAS,MAAM,cAAc,IAAI,eAAe;AAEtD,OAAI,CAAC,OAAO,SAAS;AACnB,YAAQ,MAAM,qBAAqB,OAAO,OAAO,QAAQ;AACzD,YAAQ,KAAK,EAAE;;AAGjB,OAAI,OAAO,mBAAmB,WAAW,EACvC,SAAQ,IAAI,gDAAgD;QACvD;AACL,YAAQ,IACN,yBAAyB,OAAO,mBAAmB,OAAO,gBAC3D;AACD,SAAK,MAAM,QAAQ,OAAO,mBACxB,SAAQ,IAAI,OAAO,OAAO;;;UAIzB,OAAO;AACd,UAAQ,MACN,UACA,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM,CACvD;AACD,UAAQ,KAAK,EAAE;WACP;AACR,QAAM,GAAG,SAAS","debug_id":"9ca57982-bee9-5f08-aa81-5fb5a7ca8324"}
1
+ {"version":3,"file":"switchboard-migrate-Docb8Cjv.mjs","sources":["../src/services/switchboard-migrate.ts"],"sourcesContent":["import { Kysely, PostgresDialect } from \"kysely\";\nimport { Pool } from \"pg\";\nimport {\n runMigrations,\n getMigrationStatus,\n REACTOR_SCHEMA,\n} from \"@powerhousedao/reactor\";\n\ninterface MigrationOptions {\n dbPath?: string;\n statusOnly?: boolean;\n}\n\nfunction isPostgresUrl(url: string): boolean {\n return url.startsWith(\"postgresql://\") || url.startsWith(\"postgres://\");\n}\n\nexport async function runSwitchboardMigrations(\n options: MigrationOptions,\n): Promise<void> {\n const dbPath =\n options.dbPath ??\n process.env.PH_REACTOR_DATABASE_URL ??\n process.env.DATABASE_URL;\n\n if (!dbPath || !isPostgresUrl(dbPath)) {\n console.log(\"No PostgreSQL URL configured. Skipping migrations.\");\n console.log(\"(PGlite migrations are handled automatically on startup)\");\n return;\n }\n\n console.log(`Database: ${dbPath}`);\n\n const pool = new Pool({ connectionString: dbPath });\n\n const db = new Kysely<any>({\n dialect: new PostgresDialect({ pool }),\n });\n\n try {\n if (options.statusOnly) {\n console.log(\"\\nChecking migration status...\");\n const migrations = await getMigrationStatus(db, REACTOR_SCHEMA);\n\n console.log(\"\\nMigration Status:\");\n console.log(\"=================\");\n\n for (const migration of migrations) {\n const status = migration.executedAt\n ? `[OK] Executed at ${migration.executedAt.toISOString()}`\n : \"[--] Pending\";\n console.log(`${status} - ${migration.name}`);\n }\n } else {\n console.log(\"\\nRunning migrations...\");\n const result = await runMigrations(db, REACTOR_SCHEMA);\n\n if (!result.success) {\n console.error(\"Migration failed:\", result.error?.message);\n process.exit(1);\n }\n\n if (result.migrationsExecuted.length === 0) {\n console.log(\"No migrations to run - database is up to date\");\n } else {\n console.log(\n `Successfully executed ${result.migrationsExecuted.length} migration(s):`,\n );\n for (const name of result.migrationsExecuted) {\n console.log(` - ${name}`);\n }\n }\n }\n } catch (error) {\n console.error(\n \"Error:\",\n error instanceof Error ? error.message : String(error),\n );\n process.exit(1);\n } finally {\n await db.destroy();\n }\n}\n"],"names":[],"mappings":";;;;;;AAaA,SAAS,cAAc,KAAsB;CAC3C,OAAO,IAAI,WAAW,eAAe,KAAK,IAAI,WAAW,aAAa;AACxE;AAEA,eAAsB,yBACpB,SACe;CACf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c05bd"}
@@ -0,0 +1,37 @@
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]="c5e3cd62-660a-5978-8304-6ea0c3f41894")}catch(e){}}();
3
+ import { SWITCHBOARD_PROXY_PATHS, isHtmlNavigation } from "@powerhousedao/shared/connect/origin-placeholder";
4
+ //#region src/utils/switchboard-proxy.ts
5
+ /**
6
+ * Vite proxy rules (dev and preview servers alike) that send the
7
+ * switchboard's paths to `target`, so a browser on Connect's origin reaches
8
+ * the switchboard through it and the served config can name the switchboard
9
+ * as `${origin}` (runner.proxy on the connect host).
10
+ *
11
+ * `/d/<drive>` is both a switchboard endpoint and one of Connect's own
12
+ * routes: a browser navigation there (it accepts HTML) is left to Connect,
13
+ * every other request on the path goes to the switchboard. GraphQL carries
14
+ * the subscriptions websocket, so that rule upgrades too. The Host header
15
+ * is left as the browser sent it: the switchboard builds the URLs it hands
16
+ * out from it, and on the page's origin is where they must point.
17
+ */
18
+ function switchboardProxy(target) {
19
+ const origin = new URL(target).origin;
20
+ const rules = {};
21
+ for (const prefix of SWITCHBOARD_PROXY_PATHS) {
22
+ const key = prefix.endsWith("/") ? `^${escape(prefix)}` : `^${escape(prefix)}(/|$)`;
23
+ rules[key] = {
24
+ target: origin,
25
+ changeOrigin: false,
26
+ ...prefix === "/graphql" ? { ws: true } : {},
27
+ ...prefix === "/d/" ? { bypass: (req) => isHtmlNavigation(req.headers.accept) ? req.url : void 0 } : {}
28
+ };
29
+ }
30
+ return rules;
31
+ }
32
+ const escape = (s) => s.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
33
+ //#endregion
34
+ export { switchboardProxy as t };
35
+
36
+ //# sourceMappingURL=switchboard-proxy-CGfMtENM.mjs.map
37
+ //# debugId=c5e3cd62-660a-5978-8304-6ea0c3f41894
@@ -0,0 +1 @@
1
+ {"version":3,"file":"switchboard-proxy-CGfMtENM.mjs","sources":["../src/utils/switchboard-proxy.ts"],"sourcesContent":["import {\n isHtmlNavigation,\n SWITCHBOARD_PROXY_PATHS,\n} from \"@powerhousedao/shared/connect/origin-placeholder\";\nimport type { ProxyOptions } from \"vite\";\n\n/**\n * Vite proxy rules (dev and preview servers alike) that send the\n * switchboard's paths to `target`, so a browser on Connect's origin reaches\n * the switchboard through it and the served config can name the switchboard\n * as `${origin}` (runner.proxy on the connect host).\n *\n * `/d/<drive>` is both a switchboard endpoint and one of Connect's own\n * routes: a browser navigation there (it accepts HTML) is left to Connect,\n * every other request on the path goes to the switchboard. GraphQL carries\n * the subscriptions websocket, so that rule upgrades too. The Host header\n * is left as the browser sent it: the switchboard builds the URLs it hands\n * out from it, and on the page's origin is where they must point.\n */\nexport function switchboardProxy(target: string): Record<string, ProxyOptions> {\n const origin = new URL(target).origin;\n const rules: Record<string, ProxyOptions> = {};\n for (const prefix of SWITCHBOARD_PROXY_PATHS) {\n const key = prefix.endsWith(\"/\")\n ? `^${escape(prefix)}`\n : `^${escape(prefix)}(/|$)`;\n rules[key] = {\n target: origin,\n changeOrigin: false,\n ...(prefix === \"/graphql\" ? { ws: true } : {}),\n ...(prefix === \"/d/\"\n ? {\n bypass: (req) =>\n isHtmlNavigation(req.headers.accept) ? req.url : undefined,\n }\n : {}),\n };\n }\n return rules;\n}\n\nconst escape = (s: string) => s.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAmBA,SAAgB,iBAAiB,QAA8C;CAC7E,MAAM,SAAS,IAAI,IAAI,MAAM,CAAC,CAAC;CAC/B,MAAM,QAAsC,CAAC;CAC7C,KAAK,MAAM,UAAU,yBAAyB;EAC5C,MAAM,MAAM,OAAO,SAAS,GAAG,IAC3B,IAAI,OAAO,MAAM,MACjB,IAAI,OAAO,MAAM,EAAE;EACvB,MAAM,OAAO;GACX,QAAQ;GACR,cAAc;GACd,GAAI,WAAW,aAAa,EAAE,IAAI,KAAK,IAAI,CAAC;GAC5C,GAAI,WAAW,QACX,EACE,SAAS,QACP,iBAAiB,IAAI,QAAQ,MAAM,IAAI,IAAI,MAAM,KAAA,EACrD,IACA,CAAC;EACP;CACF;CACA,OAAO;AACT;AAEA,MAAM,UAAU,MAAc,EAAE,QAAQ,uBAAuB,MAAM","debug_id":"c5e3cd62-660a-5978-8304-6ea0c3f41894"}
@@ -1,7 +1,8 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="6dc443d3-91f6-5215-973e-7898511565eb")}catch(e){}}();
3
- import { cyan, green, red, yellow } from "colorette";
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){}}();
4
3
  import { promises } from "node:fs";
4
+ import { cyan, green, red, yellow } from "colorette";
5
+ import { defaultStoreDirs } from "@powerhousedao/shared/clis/ph-dir";
5
6
  //#region src/services/switchboard-reset.ts
6
7
  const CONFIRMATION_TOKEN = "reset";
7
8
  function isPostgresUrl(url) {
@@ -18,10 +19,11 @@ function isInteractive() {
18
19
  * caller can refuse.
19
20
  */
20
21
  function resolveResetPaths(options, env = process.env) {
22
+ const defaults = defaultStoreDirs(env);
21
23
  const readModelDbPath = options.dbPath ?? env.DATABASE_URL ?? env.PH_SWITCHBOARD_DATABASE_URL;
22
- const readModelPath = readModelDbPath || ".ph/read-storage";
24
+ const readModelPath = readModelDbPath || defaults.readModel;
23
25
  const reactorDbUrl = options.dbPath ?? env.PH_REACTOR_DATABASE_URL ?? env.PH_SWITCHBOARD_DATABASE_URL;
24
- const reactorPath = reactorDbUrl || "./.ph/reactor-storage";
26
+ const reactorPath = reactorDbUrl || defaults.reactor;
25
27
  const reactorIsPostgres = !!reactorDbUrl && isPostgresUrl(reactorDbUrl);
26
28
  const readModelIsPostgres = !!readModelDbPath && isPostgresUrl(readModelDbPath);
27
29
  let postgresUrl = null;
@@ -83,5 +85,5 @@ async function resetSwitchboardDatabase(options) {
83
85
  //#endregion
84
86
  export { resetSwitchboardDatabase };
85
87
 
86
- //# sourceMappingURL=switchboard-reset-BcQXlcVf.mjs.map
87
- //# debugId=6dc443d3-91f6-5215-973e-7898511565eb
88
+ //# sourceMappingURL=switchboard-reset-MtTB_GAI.mjs.map
89
+ //# debugId=44d0c080-10cc-5316-947d-b0281777aade
@@ -0,0 +1 @@
1
+ {"version":3,"file":"switchboard-reset-MtTB_GAI.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 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 );\n}\n"],"names":["fs"],"mappings":";;;;;;AAeA,MAAM,qBAAqB;AAE3B,SAAgB,cAAc,KAAsB;CAClD,OAAO,IAAI,WAAW,eAAe,KAAK,IAAI,WAAW,aAAa;AACxE;AAEA,SAAS,gBAAyB;CAChC,OAAO,QAAQ,QAAQ,MAAM,KAAK,KAAK,CAAC,QAAQ,IAAI;AACtD;;;;;;;;AASA,SAAgB,kBACd,SACA,MAAyB,QAAQ,KACb;CACpB,MAAM,WAAW,iBAAiB,GAAG;CACrC,MAAM,kBACJ,QAAQ,UAAU,IAAI,gBAAgB,IAAI;CAC5C,MAAM,gBAAgB,mBAAmB,SAAS;CAClD,MAAM,eACJ,QAAQ,UACR,IAAI,2BACJ,IAAI;CACN,MAAM,cAAc,gBAAgB,SAAS;CAE7C,MAAM,oBAAoB,CAAC,CAAC,gBAAgB,cAAc,YAAY;CACtE,MAAM,sBACJ,CAAC,CAAC,mBAAmB,cAAc,eAAe;CAEpD,IAAI,cAA6B;CACjC,IAAI,mBAAmB,cAAc;MAChC,IAAI,qBAAqB,cAAc;CAE5C,OAAO;EACL,YAAY,oBAAoB,OAAO;EACvC,cAAc,sBAAsB,OAAO;EAC3C;CACF;AACF;AAEA,eAAe,wBAA0C;CACvD,MAAM,WAAW,MAAM,OAAO;CAC9B,IAAI;EAMF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+ export { syncProjectConnectRoutes };
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]="a0e16059-68ca-5115-9c0e-68e1b5113d9c")}catch(e){}}();
4
+ //# debugId=a0e16059-68ca-5115-9c0e-68e1b5113d9c
@@ -0,0 +1,25 @@
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]="635b041c-5cc1-56f7-aac5-714511c1dd4c")}catch(e){}}();
3
+ import { existsSync } from "node:fs";
4
+ import { join } from "node:path";
5
+ //#region src/utils/sync-connect-routes.ts
6
+ const OFFERED_ROUTES_MODULE = ".ph/connect-routes.package.ts";
7
+ const HOST_ROUTES_DIR = "hosts/connect/routes";
8
+ const CONNECT_ROUTES_GEN = ".ph/connect-routes.gen.ts";
9
+ /** Writes the tree hosts/connect/routes/ type-checks against; without the
10
+ * folder, a tree there keeps Connect's routes only. Loads builder-tools only
11
+ * for a project with routes or a tree. */
12
+ async function syncProjectConnectRoutes(projectRoot) {
13
+ if (![
14
+ "hosts/connect/routes",
15
+ CONNECT_ROUTES_GEN,
16
+ ".ph/connect-routes.package.ts"
17
+ ].some((p) => existsSync(join(projectRoot, p)))) return;
18
+ const { resolveConnectRoutesDir, syncConnectRoutes } = await import("@powerhousedao/builder-tools");
19
+ await syncConnectRoutes(projectRoot, resolveConnectRoutesDir(projectRoot));
20
+ }
21
+ //#endregion
22
+ export { OFFERED_ROUTES_MODULE as n, syncProjectConnectRoutes as r, HOST_ROUTES_DIR as t };
23
+
24
+ //# sourceMappingURL=sync-connect-routes-t0Slg-P6.mjs.map
25
+ //# debugId=635b041c-5cc1-56f7-aac5-714511c1dd4c
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sync-connect-routes-t0Slg-P6.mjs","sources":["../src/utils/sync-connect-routes.ts"],"sourcesContent":["import { existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\n\n// builder-tools' PACKAGE_ROUTES_MODULE and HOST_ROUTES_DIR, without loading it\n// for packages with no routes.\nexport const OFFERED_ROUTES_MODULE = \".ph/connect-routes.package.ts\";\nexport const HOST_ROUTES_DIR = \"hosts/connect/routes\";\nconst CONNECT_ROUTES_GEN = \".ph/connect-routes.gen.ts\";\n\n/** Writes the tree hosts/connect/routes/ type-checks against; without the\n * folder, a tree there keeps Connect's routes only. Loads builder-tools only\n * for a project with routes or a tree. */\nexport async function syncProjectConnectRoutes(projectRoot: string) {\n const probes = [HOST_ROUTES_DIR, CONNECT_ROUTES_GEN, OFFERED_ROUTES_MODULE];\n if (!probes.some((p) => existsSync(join(projectRoot, p)))) return;\n const { resolveConnectRoutesDir, syncConnectRoutes } =\n await import(\"@powerhousedao/builder-tools\");\n await syncConnectRoutes(projectRoot, resolveConnectRoutesDir(projectRoot));\n}\n"],"names":[],"mappings":";;;;;AAKA,MAAa,wBAAwB;AACrC,MAAa,kBAAkB;AAC/B,MAAM,qBAAqB;;;;AAK3B,eAAsB,yBAAyB,aAAqB;CAElE,IAAI,CAAC;;EAD4B;;CACvB,CAAC,CAAC,MAAM,MAAM,WAAW,KAAK,aAAa,CAAC,CAAC,CAAC,GAAG;CAC3D,MAAM,EAAE,yBAAyB,sBAC/B,MAAM,OAAO;CACf,MAAM,kBAAkB,aAAa,wBAAwB,WAAW,CAAC;AAC3E","debug_id":"635b041c-5cc1-56f7-aac5-714511c1dd4c"}
@@ -1,5 +1,5 @@
1
1
 
2
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="73159d3c-22a7-5dc6-8bd4-7b15f3b94c79")}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]="e3fbf59a-7996-5c5c-9db7-c8d207b68849")}catch(e){}}();
3
3
  import fs from "node:fs";
4
4
  import path, { dirname } from "node:path";
5
5
  import crypto from "node:crypto";
@@ -111,36 +111,8 @@ function updateConfigFile(dependencies, projectPath, task = "install", provider
111
111
  fs.writeFileSync(configPath, JSON.stringify(updatedConfig, null, 2));
112
112
  }
113
113
  /**
114
- * Updates the styles.css file to include imports for newly installed packages
115
- * @param dependencies - Array of dependencies that were installed
116
- * @param projectPath - Path to the project root
117
- */
118
- function updateStylesFile(dependencies, projectPath) {
119
- const stylesPath = path.join(projectPath, "style.css");
120
- if (!fs.existsSync(stylesPath)) {
121
- console.warn("⚠️ Warning: style.css file not found in project root");
122
- return;
123
- }
124
- const currentStyles = fs.readFileSync(stylesPath, "utf-8");
125
- let updatedStyles = currentStyles;
126
- for (const dep of dependencies) {
127
- const cssPath = `./node_modules/${dep.name}/dist/style.css`;
128
- const fullCssPath = path.join(projectPath, cssPath);
129
- const importStatement = `@import '${cssPath}';`;
130
- if (!fs.existsSync(fullCssPath)) {
131
- console.warn(`⚠️ Warning: CSS file not found at ${cssPath}`);
132
- continue;
133
- }
134
- if (currentStyles.includes(importStatement)) continue;
135
- const importLines = currentStyles.split("\n").filter((line) => line.trim().startsWith("@import"));
136
- const lastImport = importLines[importLines.length - 1];
137
- if (lastImport) updatedStyles = currentStyles.replace(lastImport, `${lastImport}\n${importStatement}`);
138
- else updatedStyles = `${importStatement}\n${currentStyles}`;
139
- }
140
- if (updatedStyles !== currentStyles) fs.writeFileSync(stylesPath, updatedStyles);
141
- }
142
- /**
143
- * Removes CSS imports for uninstalled packages from styles.css
114
+ * Removes the CSS imports `ph install --local` used to add to style.css for
115
+ * uninstalled packages; Connect now loads a bundled package's CSS with its code.
144
116
  */
145
117
  function removeStylesImports(dependencies, projectPath) {
146
118
  const stylesPath = path.join(projectPath, "style.css");
@@ -159,7 +131,7 @@ function removeStylesImports(dependencies, projectPath) {
159
131
  if (updatedStyles !== currentStyles) fs.writeFileSync(stylesPath, updatedStyles);
160
132
  }
161
133
  //#endregion
162
- 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, updateStylesFile as p, defaultPathValidation as r, getProjectInfo as s, POWERHOUSE_CONFIG_FILE as t, removeStylesImports as u };
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 };
163
135
 
164
- //# sourceMappingURL=utils-C4isxXSO.mjs.map
165
- //# debugId=73159d3c-22a7-5dc6-8bd4-7b15f3b94c79
136
+ //# sourceMappingURL=utils-9KyRM0mf.mjs.map
137
+ //# debugId=e3fbf59a-7996-5c5c-9db7-c8d207b68849
@@ -1 +1 @@
1
- {"version":3,"file":"utils-C4isxXSO.mjs","sources":["../src/utils.ts"],"sourcesContent":["import type { PowerhouseConfig } from \"@powerhousedao/config\";\nimport crypto from \"node:crypto\";\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\n/**\n * Generates a unique drive ID based on the project path.\n * The same project path will always generate the same ID.\n * @param name - The name prefix for the drive ID (e.g., \"vetra\", \"powerhouse\")\n * @returns A unique drive ID in the format \"{name}-{hash}\"\n */\nexport function generateProjectDriveId(name: string): string {\n const projectInfo = getProjectInfo();\n const hash = crypto\n .createHash(\"sha256\")\n .update(projectInfo.path)\n .digest(\"hex\");\n const shortHash = hash.substring(0, 8);\n return `${name}-${shortHash}`;\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 * Updates the styles.css file to include imports for newly installed packages\n * @param dependencies - Array of dependencies that were installed\n * @param projectPath - Path to the project root\n */\nexport function updateStylesFile(\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 fullCssPath = path.join(projectPath, cssPath);\n const importStatement = `@import '${cssPath}';`;\n\n // Check if the CSS file exists\n if (!fs.existsSync(fullCssPath)) {\n console.warn(`⚠️ Warning: CSS file not found at ${cssPath}`);\n continue;\n }\n\n // Check if import already exists\n if (currentStyles.includes(importStatement)) {\n continue;\n }\n\n // Find the last @import statement\n const importLines = currentStyles\n .split(\"\\n\")\n .filter((line) => line.trim().startsWith(\"@import\"));\n const lastImport = importLines[importLines.length - 1];\n\n if (lastImport) {\n // Insert new import after the last existing import\n updatedStyles = currentStyles.replace(\n lastImport,\n `${lastImport}\\n${importStatement}`,\n );\n } else {\n // If no imports exist, add at the top of the file\n updatedStyles = `${importStatement}\\n${currentStyles}`;\n }\n }\n\n // Only write if changes were made\n if (updatedStyles !== currentStyles) {\n fs.writeFileSync(stylesPath, updatedStyles);\n }\n}\n\n/**\n * Removes CSS imports for uninstalled packages from styles.css\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":";;;;;;;AAKA,MAAa,yBAAyB;AACtC,MAAa,wBAAwB,KAAK,KAAK,SAAS,EAAE,MAAM;AAGhE,MAAa,kBAAkB;CAC7B,KAAK;EACH,kBAAkB;EAClB,gBAAgB;EAChB,kBAAkB;EAClB,iBAAiB;EACjB,UAAU;EACV,eAAe;EACf,eAAe;EAChB;CACD,MAAM;EACJ,kBAAkB;EAClB,gBAAgB;EAChB,kBAAkB;EAClB,iBAAiB;EACjB,UAAU;EACV,eAAe;EACf,eAAe;EAChB;CACD,MAAM;EACJ,kBAAkB;EAClB,gBAAgB;EAChB,kBAAkB;EAClB,iBAAiB;EACjB,UAAU;EACV,eAAe;EACf,eAAe;EAChB;CACD,KAAK;EACH,gBAAgB;EAChB,kBAAkB;EAClB,iBAAiB;EACjB,UAAU;EACV,eAAe;EACf,eAAe;EAChB;CACF;AAYD,SAAgB,wBAAwB;AACtC,QAAO;;AAGT,SAAgB,oBAAoB,KAAa;CAC/C,MAAM,uBAAuB,KAAK,KAAK,KAAK,uBAAuB;AAEnE,QAAO,GAAG,WAAW,qBAAqB;;AAG5C,SAAgB,oBACd,KACA,iBAAiC,uBACjC;CACA,MAAM,kBAAkB,KAAK,KAAK,KAAK,eAAe;AAEtD,KAAI,GAAG,WAAW,gBAAgB,IAAI,eAAe,IAAI,CACvD,QAAO;CAGT,MAAM,YAAY,QAAQ,IAAI;AAE9B,KAAI,cAAc,IAChB,QAAO;AAGT,QAAO,oBAAoB,WAAW,eAAe;;AAGvD,SAAgB,eAAe,OAA8B;CAC3D,MAAM,cAAc,QAAQ,KAAK;AAEjC,KAAI,MACF,S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G,WAAW,WAAW,EAAE;AAC9B,UAAQ,KAAK,uDAAuD;AACpE;;CAGF,MAAM,gBAAgB,GAAG,aAAa,YAAY,QAAQ;CAC1D,IAAI,gBAAgB;AAEpB,MAAK,MAAM,OAAO,cAAc;EAE9B,MAAM,kBAAkB,YADR,kBAAkB,IAAI,KAAK,iBACC;EAG5C,MAAM,QAAQ,cAAc,MAAM,KAAK;EACvC,MAAM,gBAAgB,MAAM,QACzB,SAAS,CAAC,KAAK,MAAM,CAAC,SAAS,gBAAgB,CACjD;AAED,MAAI,cAAc,WAAW,MAAM,OACjC,iBAAgB,cAAc,KAAK,KAAK;;AAK5C,KAAI,kBAAkB,cACpB,IAAG,cAAc,YAAY,cAAc","debug_id":"73159d3c-22a7-5dc6-8bd4-7b15f3b94c79"}
1
+ {"version":3,"file":"utils-9KyRM0mf.mjs","sources":["../src/utils.ts"],"sourcesContent":["import type { PowerhouseConfig } from \"@powerhousedao/config\";\nimport crypto from \"node:crypto\";\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\n/**\n * Generates a unique drive ID based on the project path.\n * The same project path will always generate the same ID.\n * @param name - The name prefix for the drive ID (e.g., \"vetra\", \"powerhouse\")\n * @returns A unique drive ID in the format \"{name}-{hash}\"\n */\nexport function generateProjectDriveId(name: string): string {\n const projectInfo = getProjectInfo();\n const hash = crypto\n .createHash(\"sha256\")\n .update(projectInfo.path)\n .digest(\"hex\");\n const shortHash = hash.substring(0, 8);\n return `${name}-${shortHash}`;\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":";;;;;;;AAKA,MAAa,yBAAyB;AACtC,MAAa,wBAAwB,KAAK,KAAK,QAAQ,GAAG,KAAK;AAG/D,MAAa,kBAAkB;CAC7B,KAAK;EACH,kBAAkB;EAClB,gBAAgB;EAChB,kBAAkB;EAClB,iBAAiB;EACjB,UAAU;EACV,eAAe;EACf,eAAe;CACjB;CACA,MAAM;EACJ,kBAAkB;EAClB,gBAAgB;EAChB,kBAAkB;EAClB,iBAAiB;EACjB,UAAU;EACV,eAAe;EACf,eAAe;CACjB;CACA,MAAM;EACJ,kBAAkB;EAClB,gBAAgB;EAChB,kBAAkB;EAClB,iBAAiB;EACjB,UAAU;EACV,eAAe;EACf,eAAe;CACjB;CACA,KAAK;EACH,gBAAgB;EAChB,kBAAkB;EAClB,iBAAiB;EACjB,UAAU;EACV,eAAe;EACf,eAAe;CACjB;AACF;AAYA,SAAgB,wBAAwB;CACtC,OAAO;AACT;AAEA,SAAgB,oBAAoB,KAAa;CAC/C,MAAM,uBAAuB,KAAK,KAAK,KAAK,sBAAsB;CAElE,OAAO,GAAG,WAAW,oBAAoB;AAC3C;AAEA,SAAgB,oBACd,KACA,iBAAiC,uBACjC;CACA,MAAM,kBAAkB,KAAK,KAAK,KAAK,cAAc;CAErD,IAAI,GAAG,WAAW,eAAe,KAAK,eAAe,GAAG,GACtD,OAAO;CAGT,MAAM,YAAY,QAAQ,GAAG;CAE7B,IAAI,cAAc,KAChB,OAAO;CAGT,OAAO,oBAAoB,WAAW,cAAc;AACtD;AAEA,SAAgB,eAAe,OAA8B;CAC3D,MAAM,cAAc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,YACjC,aACA,sBAAsB,OACtB;CACA,MAAM,aAAa,KAAK,KAAK,aAAa,sBAAsB;CAEhE,IAAI,CAAC,GAAG,WAAW,UAAU,GAC3B,MAAM,IAAI,MACR,uDAAuD,aACzD;CAGF,MAAM,SAAS,KAAK,MAClB,GAAG,aAAa,YAAY,OAAO,CACrC;CAEA,MAAM,gBAAkC;EACtC,GAAG;EACH,UAAU,oBACR,OAAO,UACP,cACA,MACA,QACF;CACF;CAEA,IACE,SAAS,aACT,gBACC,uBAAuB,CAAC,OAAO,uBAChC,aAAa,SAAS,GAEtB,cAAc,qBAAqB;CAGrC,GAAG,cAAc,YAAY,KAAK,UAAU,eAAe,MAAM,CAAC,CAAC;AACrE;;;;;AA0CA,SAAgB,oBACd,cACA,aACA;CACA,MAAM,aAAa,KAAK,KAAK,aAAa,WAAW;CAGrD,IAAI,CAAC,GAAG,WAAW,UAAU,GAAG;EAC9B,QAAQ,KAAK,sDAAsD;EACnE;CACF;CAEA,MAAM,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":"e3fbf59a-7996-5c5c-9db7-c8d207b68849"}
@@ -0,0 +1,4 @@
1
+ import { d as updateConfigFile, u as removeStylesImports } from "./utils-9KyRM0mf.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]="76be3b2a-b7dc-5775-8844-ce31e31fe2d1")}catch(e){}}();
4
+ //# debugId=76be3b2a-b7dc-5775-8844-ce31e31fe2d1
@@ -0,0 +1,71 @@
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]="446e13c5-d36e-5618-9590-90e547fc6953")}catch(e){}}();
3
+ import { t as getVersion } from "./get-version-BBiGShxz.mjs";
4
+ import { f as verifyReleaseApproval, i as revisionFiles, n as publishedFiles, o as packRelease, r as readReleaseApproval, s as packedDigests, u as decisionWithoutApproval } from "./files-D6_euBBn.mjs";
5
+ //#region src/services/release/verify.ts
6
+ /**
7
+ * Compares the package as it is now with its release approval: the files
8
+ * the revision reads, with the output directory and exclusions the approval
9
+ * records, and what `npm pack` publishes, or `published` when the caller
10
+ * already packed it. Throws when either cannot be read.
11
+ */
12
+ function verifyRelease(packageRoot, read = readReleaseApproval(packageRoot), published) {
13
+ if (read.kind !== "found") return decisionWithoutApproval(read);
14
+ const { approval } = read;
15
+ return verifyReleaseApproval(approval, {
16
+ phCliVersion: getVersion(),
17
+ files: revisionFiles(packageRoot, [approval.outDir, ...approval.packageRevision.excluded]),
18
+ publishedFiles: published ?? publishedFiles(packageRoot)
19
+ });
20
+ }
21
+ const HEADLINES = {
22
+ approved: "the release approval matches this package",
23
+ missing: "this package has no release approval",
24
+ unreadable: "the release approval cannot be read",
25
+ stale: "the release approval does not match this package",
26
+ refused: "the release approval records a release check that did not pass"
27
+ };
28
+ /** The decision and each reason on its own line. */
29
+ function renderReleaseDecision(decision) {
30
+ return [`${decision.decision}: ${HEADLINES[decision.decision]}`, ...decision.reasons.map((reason) => ` - ${reason}`)].join("\n");
31
+ }
32
+ /**
33
+ * Checks the release approval before `ph publish` resolves a registry.
34
+ * Without an approval file and without `required`, does nothing, as before
35
+ * approvals existed. Otherwise a decision other than approved is a warning,
36
+ * or with `required` a refusal.
37
+ */
38
+ function checkApprovalBeforePublish(packageRoot, required) {
39
+ const read = readReleaseApproval(packageRoot);
40
+ if (read.kind === "missing" && !required) return { proceed: true };
41
+ let text;
42
+ let packed;
43
+ let approved = false;
44
+ try {
45
+ if (required && read.kind === "found") packed = packRelease(packageRoot);
46
+ const decision = verifyRelease(packageRoot, read, packed && packedDigests(packed));
47
+ approved = decision.decision === "approved";
48
+ text = renderReleaseDecision(decision);
49
+ } catch (error) {
50
+ text = `the release approval could not be checked: ${error instanceof Error ? error.message : String(error)}`;
51
+ }
52
+ if (approved) {
53
+ console.log(`✔ ${text}`);
54
+ return {
55
+ proceed: true,
56
+ packed
57
+ };
58
+ }
59
+ packed?.dispose();
60
+ if (required) {
61
+ console.error(`✘ ${text}\nph publish --require-approval publishes only an approved package. Run ph build --release, then publish again.`);
62
+ return { proceed: false };
63
+ }
64
+ console.warn(`⚠ ${text}\nPublishing anyway. Run ph build --release to approve this package, or pass --require-approval to stop here instead.`);
65
+ return { proceed: true };
66
+ }
67
+ //#endregion
68
+ export { checkApprovalBeforePublish, renderReleaseDecision, verifyRelease };
69
+
70
+ //# sourceMappingURL=verify-l5f7BDmy.mjs.map
71
+ //# debugId=446e13c5-d36e-5618-9590-90e547fc6953
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verify-l5f7BDmy.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,8CAA8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