@powerhousedao/ph-cli 6.2.3-dev.8 → 6.2.3-dev.80

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 (162) hide show
  1. package/dist/{auth-AR3VxAIk.mjs → auth-BFUq7CvE.mjs} +3 -3
  2. package/dist/{auth-AR3VxAIk.mjs.map → auth-BFUq7CvE.mjs.map} +1 -1
  3. package/dist/auth-CNhbN5UM.mjs +4 -0
  4. package/dist/build-t5pFQx0f.mjs +304 -0
  5. package/dist/build-t5pFQx0f.mjs.map +1 -0
  6. package/dist/build-wvc_NiGr.mjs +4 -0
  7. package/dist/check-ecwBLzrg.mjs +56 -0
  8. package/dist/check-ecwBLzrg.mjs.map +1 -0
  9. package/dist/{cli-connect-override-D3hh4aH_.mjs → cli-connect-override-DW7OYAGx.mjs} +39 -27
  10. package/dist/cli-connect-override-DW7OYAGx.mjs.map +1 -0
  11. package/dist/cli.d.mts +2 -1
  12. package/dist/cli.mjs +35 -1179
  13. package/dist/cli.mjs.map +1 -1
  14. package/dist/compound-C7GuPnTP-Ba4ce2Xa.mjs +2813 -0
  15. package/dist/compound-C7GuPnTP-Ba4ce2Xa.mjs.map +1 -0
  16. package/dist/connect-build-7nmQw9c5.mjs +253 -0
  17. package/dist/connect-build-7nmQw9c5.mjs.map +1 -0
  18. package/dist/{connect-config-BWGiW3IB.mjs → connect-config-CfQwxG8G.mjs} +19 -12
  19. package/dist/connect-config-CfQwxG8G.mjs.map +1 -0
  20. package/dist/connect-plugin-configs-CXN8_KL0.mjs +50 -0
  21. package/dist/connect-plugin-configs-CXN8_KL0.mjs.map +1 -0
  22. package/dist/connect-preview-l0Car-nX.mjs +217 -0
  23. package/dist/connect-preview-l0Car-nX.mjs.map +1 -0
  24. package/dist/connect-studio-Cac3eE_U.mjs +81 -0
  25. package/dist/connect-studio-Cac3eE_U.mjs.map +1 -0
  26. package/dist/connect-studio-Cf6UZvOo.mjs +4 -0
  27. package/dist/dist-DcARVrSg.mjs +643 -0
  28. package/dist/dist-DcARVrSg.mjs.map +1 -0
  29. package/dist/explain-Rx7JW1OU.mjs +230 -0
  30. package/dist/explain-Rx7JW1OU.mjs.map +1 -0
  31. package/dist/export-ZnJeAtLS.mjs +42 -0
  32. package/dist/export-ZnJeAtLS.mjs.map +1 -0
  33. package/dist/feature-flags-xwqcHEWC.mjs +4 -0
  34. package/dist/{generate-all-DrT4ZxHX.mjs → generate-all-5Om0CB4N.mjs} +9 -3
  35. package/dist/generate-all-5Om0CB4N.mjs.map +1 -0
  36. package/dist/generate-app-hm6CJ_4O.mjs +72 -0
  37. package/dist/generate-app-hm6CJ_4O.mjs.map +1 -0
  38. package/dist/generate-desktop-shell-DzEzNspp.mjs +318 -0
  39. package/dist/generate-desktop-shell-DzEzNspp.mjs.map +1 -0
  40. package/dist/generate-document-model-CiW13Vf7.mjs +60 -0
  41. package/dist/generate-document-model-CiW13Vf7.mjs.map +1 -0
  42. package/dist/generate-editor-kTiUOmDW.mjs +64 -0
  43. package/dist/generate-editor-kTiUOmDW.mjs.map +1 -0
  44. package/dist/generate-hosts-BFmPIW2X.mjs +18 -0
  45. package/dist/generate-hosts-BFmPIW2X.mjs.map +1 -0
  46. package/dist/generate-hosts-RWj7WPHZ.mjs +4 -0
  47. package/dist/generate-migration-file-yK8uA70U.mjs +20 -0
  48. package/dist/generate-migration-file-yK8uA70U.mjs.map +1 -0
  49. package/dist/generate-piece-C6ymlErL.mjs +73 -0
  50. package/dist/generate-piece-C6ymlErL.mjs.map +1 -0
  51. package/dist/generate-piece-action-uYRdKtQA.mjs +29 -0
  52. package/dist/generate-piece-action-uYRdKtQA.mjs.map +1 -0
  53. package/dist/generate-piece-trigger-CZaDD-cc.mjs +30 -0
  54. package/dist/generate-piece-trigger-CZaDD-cc.mjs.map +1 -0
  55. package/dist/generate-processor-BVjOsfjJ.mjs +58 -0
  56. package/dist/generate-processor-BVjOsfjJ.mjs.map +1 -0
  57. package/dist/generate-subgraph-CrHbYK91.mjs +64 -0
  58. package/dist/generate-subgraph-CrHbYK91.mjs.map +1 -0
  59. package/dist/get-version-C-oL2owF.mjs +11 -0
  60. package/dist/get-version-C-oL2owF.mjs.map +1 -0
  61. package/dist/index-CJN_BRkc.d.mts +4459 -0
  62. package/dist/index-CJN_BRkc.d.mts.map +1 -0
  63. package/dist/{init-BZP6gvYd.mjs → init-Ch1rCksS.mjs} +16 -12
  64. package/dist/init-Ch1rCksS.mjs.map +1 -0
  65. package/dist/{inspect-DXjbQEV_.mjs → inspect-zWJnBDMJ.mjs} +11 -4
  66. package/dist/inspect-zWJnBDMJ.mjs.map +1 -0
  67. package/dist/install-added-dependencies-DnZFR3aE.mjs +18 -0
  68. package/dist/install-added-dependencies-DnZFR3aE.mjs.map +1 -0
  69. package/dist/mcp-DvyBEajv.mjs +262 -0
  70. package/dist/mcp-DvyBEajv.mjs.map +1 -0
  71. package/dist/member-config-0tHtiVN_.mjs +154 -0
  72. package/dist/member-config-0tHtiVN_.mjs.map +1 -0
  73. package/dist/migrate-CIJaE3iZ.mjs +177 -0
  74. package/dist/migrate-CIJaE3iZ.mjs.map +1 -0
  75. package/dist/module-dir-1avCXsBi.mjs +17 -0
  76. package/dist/module-dir-1avCXsBi.mjs.map +1 -0
  77. package/dist/offered-routes-imports-CQInWI6y.mjs +4 -0
  78. package/dist/offered-routes-imports-CalXK9dh.mjs +96 -0
  79. package/dist/offered-routes-imports-CalXK9dh.mjs.map +1 -0
  80. package/dist/ph-cli-commands-C8eWT5mr.mjs +1600 -0
  81. package/dist/ph-cli-commands-C8eWT5mr.mjs.map +1 -0
  82. package/dist/ph-cli-commands-DviLBBKz.mjs +4 -0
  83. package/dist/precompress-P6cJDPVC.mjs +77 -0
  84. package/dist/precompress-P6cJDPVC.mjs.map +1 -0
  85. package/dist/{registry-auth-DxEWCJu2.mjs → registry-auth-Bm5AR-fB.mjs} +4 -4
  86. package/dist/{registry-auth-DxEWCJu2.mjs.map → registry-auth-Bm5AR-fB.mjs.map} +1 -1
  87. package/dist/run-sugar-CRzZsmVo.mjs +39 -0
  88. package/dist/run-sugar-CRzZsmVo.mjs.map +1 -0
  89. package/dist/runners/connect.d.mts +1153 -0
  90. package/dist/runners/connect.d.mts.map +1 -0
  91. package/dist/runners/connect.mjs +300 -0
  92. package/dist/runners/connect.mjs.map +1 -0
  93. package/dist/runners/switchboard.d.mts +1481 -0
  94. package/dist/runners/switchboard.d.mts.map +1 -0
  95. package/dist/runners/switchboard.mjs +535 -0
  96. package/dist/runners/switchboard.mjs.map +1 -0
  97. package/dist/schemas-ByfuhvAb.mjs +5752 -0
  98. package/dist/schemas-ByfuhvAb.mjs.map +1 -0
  99. package/dist/scripts/emit-runner-schemas.ts +24 -0
  100. package/dist/scripts/generate-commands-docs.ts +12 -0
  101. package/dist/scripts/manage-environment +0 -0
  102. package/dist/scripts/setup.sh +0 -0
  103. package/dist/start-run-CRVBqQ8L.mjs +124 -0
  104. package/dist/start-run-CRVBqQ8L.mjs.map +1 -0
  105. package/dist/superseded-config-CbSTFun2.mjs +53 -0
  106. package/dist/superseded-config-CbSTFun2.mjs.map +1 -0
  107. package/dist/switchboard-B7mvNWcd.mjs +4 -0
  108. package/dist/switchboard-Cqs5IBNF.mjs +168 -0
  109. package/dist/switchboard-Cqs5IBNF.mjs.map +1 -0
  110. package/dist/{switchboard-migrate-NQ7LHWSi.mjs → switchboard-migrate-Docb8Cjv.mjs} +6 -5
  111. package/dist/{switchboard-migrate-NQ7LHWSi.mjs.map → switchboard-migrate-Docb8Cjv.mjs.map} +1 -1
  112. package/dist/switchboard-proxy-CGfMtENM.mjs +37 -0
  113. package/dist/switchboard-proxy-CGfMtENM.mjs.map +1 -0
  114. package/dist/{switchboard-reset-BcQXlcVf.mjs → switchboard-reset-MtTB_GAI.mjs} +8 -6
  115. package/dist/switchboard-reset-MtTB_GAI.mjs.map +1 -0
  116. package/dist/sync-connect-routes-BtAsFPXN.mjs +4 -0
  117. package/dist/sync-connect-routes-t0Slg-P6.mjs +25 -0
  118. package/dist/sync-connect-routes-t0Slg-P6.mjs.map +1 -0
  119. package/dist/{utils-C4isxXSO.mjs → utils-9KyRM0mf.mjs} +6 -34
  120. package/dist/{utils-C4isxXSO.mjs.map → utils-9KyRM0mf.mjs.map} +1 -1
  121. package/dist/utils-DAux4Ga7.mjs +4 -0
  122. package/dist/{vetra-DkF6EJMY.mjs → vetra-DZYtcHqV.mjs} +130 -147
  123. package/dist/vetra-DZYtcHqV.mjs.map +1 -0
  124. package/dist/vetra-launch-DQDZxGTV.mjs +343 -0
  125. package/dist/vetra-launch-DQDZxGTV.mjs.map +1 -0
  126. package/dist/warn-subgraph-type-conflicts-BOHBmThq.mjs +19 -0
  127. package/dist/warn-subgraph-type-conflicts-BOHBmThq.mjs.map +1 -0
  128. package/package.json +42 -18
  129. package/dist/auth-BNkN6kS9.mjs +0 -4
  130. package/dist/build-C-A5-ipO.mjs +0 -4
  131. package/dist/build-uQXq6_HU.mjs +0 -71
  132. package/dist/build-uQXq6_HU.mjs.map +0 -1
  133. package/dist/cli-connect-override-D3hh4aH_.mjs.map +0 -1
  134. package/dist/connect-build-WL4axo4z.mjs +0 -43
  135. package/dist/connect-build-WL4axo4z.mjs.map +0 -1
  136. package/dist/connect-config-BWGiW3IB.mjs.map +0 -1
  137. package/dist/connect-preview-D7ypzFDc.mjs +0 -28
  138. package/dist/connect-preview-D7ypzFDc.mjs.map +0 -1
  139. package/dist/connect-studio-BIQzyq5B.mjs +0 -5
  140. package/dist/connect-studio-D6rfWCNB.mjs +0 -31
  141. package/dist/connect-studio-D6rfWCNB.mjs.map +0 -1
  142. package/dist/generate-all-DrT4ZxHX.mjs.map +0 -1
  143. package/dist/generate-app-DNNqA-H3.mjs +0 -48
  144. package/dist/generate-app-DNNqA-H3.mjs.map +0 -1
  145. package/dist/generate-document-model-BJXyODfm.mjs +0 -34
  146. package/dist/generate-document-model-BJXyODfm.mjs.map +0 -1
  147. package/dist/generate-editor-BejvaVVT.mjs +0 -48
  148. package/dist/generate-editor-BejvaVVT.mjs.map +0 -1
  149. package/dist/generate-processor-_WOx-mMe.mjs +0 -40
  150. package/dist/generate-processor-_WOx-mMe.mjs.map +0 -1
  151. package/dist/generate-subgraph-BsHUstpl.mjs +0 -38
  152. package/dist/generate-subgraph-BsHUstpl.mjs.map +0 -1
  153. package/dist/init-BZP6gvYd.mjs.map +0 -1
  154. package/dist/inspect-DXjbQEV_.mjs.map +0 -1
  155. package/dist/migrate-jGKfE02L.mjs +0 -83
  156. package/dist/migrate-jGKfE02L.mjs.map +0 -1
  157. package/dist/switchboard-CJMoMzWx.mjs +0 -75
  158. package/dist/switchboard-CJMoMzWx.mjs.map +0 -1
  159. package/dist/switchboard-iRFugh8I.mjs +0 -4
  160. package/dist/switchboard-reset-BcQXlcVf.mjs.map +0 -1
  161. package/dist/utils-BzwczAW-.mjs +0 -4
  162. package/dist/vetra-DkF6EJMY.mjs.map +0 -1
@@ -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]="db15036d-53d0-5606-93c4-7b837ec4097e")}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]="e0adf75b-8ecc-5381-891d-b05c3beaf465")}catch(e){}}();
3
3
  import { RenownBuilder } from "@renown/sdk/node";
4
4
  //#region src/services/auth.ts
5
5
  let renownInstance = null;
@@ -14,5 +14,5 @@ async function getRenown(baseUrl) {
14
14
  //#endregion
15
15
  export { getRenown as t };
16
16
 
17
- //# sourceMappingURL=auth-AR3VxAIk.mjs.map
18
- //# debugId=db15036d-53d0-5606-93c4-7b837ec4097e
17
+ //# sourceMappingURL=auth-BFUq7CvE.mjs.map
18
+ //# debugId=e0adf75b-8ecc-5381-891d-b05c3beaf465
@@ -1 +1 @@
1
- {"version":3,"file":"auth-AR3VxAIk.mjs","sources":["../src/services/auth.ts"],"sourcesContent":["import { RenownBuilder, type IRenown } from \"@renown/sdk/node\";\n\n// Singleton instance of Renown\nlet renownInstance: IRenown | null = null;\n\n/**\n * Get or create the Renown instance\n * Uses PH_RENOWN_PRIVATE_KEY env var if set, otherwise generates/loads from file\n */\nexport async function getRenown(baseUrl?: string): Promise<IRenown> {\n if (!renownInstance) {\n renownInstance = await new RenownBuilder(\"ph-cli\", { baseUrl }).build();\n }\n return renownInstance;\n}\n"],"names":[],"mappings":";;;;AAGA,IAAI,iBAAiC;;;;;AAMrC,eAAsB,UAAU,SAAoC;AAClE,KAAI,CAAC,eACH,kBAAiB,MAAM,IAAI,cAAc,UAAU,EAAE,SAAS,CAAC,CAAC,OAAO;AAEzE,QAAO","debug_id":"db15036d-53d0-5606-93c4-7b837ec4097e"}
1
+ {"version":3,"file":"auth-BFUq7CvE.mjs","sources":["../src/services/auth.ts"],"sourcesContent":["import { RenownBuilder, type IRenown } from \"@renown/sdk/node\";\n\n// Singleton instance of Renown\nlet renownInstance: IRenown | null = null;\n\n/**\n * Get or create the Renown instance\n * Uses PH_RENOWN_PRIVATE_KEY env var if set, otherwise generates/loads from file\n */\nexport async function getRenown(baseUrl?: string): Promise<IRenown> {\n if (!renownInstance) {\n renownInstance = await new RenownBuilder(\"ph-cli\", { baseUrl }).build();\n }\n return renownInstance;\n}\n"],"names":[],"mappings":";;;;AAGA,IAAI,iBAAiC;;;;;AAMrC,eAAsB,UAAU,SAAoC;CAClE,IAAI,CAAC,gBACH,iBAAiB,MAAM,IAAI,cAAc,UAAU,EAAE,QAAQ,CAAC,CAAC,CAAC,MAAM;CAExE,OAAO;AACT","debug_id":"e0adf75b-8ecc-5381-891d-b05c3beaf465"}
@@ -0,0 +1,4 @@
1
+ import { t as getRenown } from "./auth-BFUq7CvE.mjs";
2
+ export { getRenown };
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]="45fb987e-a5ce-5497-bf8f-1e389fe18e04")}catch(e){}}();
4
+ //# debugId=45fb987e-a5ce-5497-bf8f-1e389fe18e04
@@ -0,0 +1,304 @@
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]="8bd27820-5036-5c2f-883c-3003ca4a9a6a")}catch(e){}}();
3
+ import { n as OFFERED_ROUTES_MODULE, r as syncProjectConnectRoutes, t as HOST_ROUTES_DIR } from "./sync-connect-routes-t0Slg-P6.mjs";
4
+ import { r as noConnectImports } from "./offered-routes-imports-CalXK9dh.mjs";
5
+ import { existsSync, mkdirSync, readFileSync, readdirSync, writeFileSync } from "node:fs";
6
+ import { join, relative, resolve } from "node:path";
7
+ import { execSync } from "node:child_process";
8
+ import { browserEntry, buildBrowserBuildConfig, buildNodeBuildConfig, findBundledSharedDeps } from "@powerhousedao/shared/build-config";
9
+ import { assertPiecesOutDir, buildPieces, createDetectionCache, expandEntryGlobs, externalDependencyVersions, externalDepsPlugin, pieceListPath, planPieces, projectPath, syncDistManifest, undeclaredExternalDependencies } from "@powerhousedao/shared/build-pieces";
10
+ import { localPackageNames, packageStyleEntry, packageStylesheet } from "@powerhousedao/shared/clis/package-style";
11
+ import { EXTERNALIZABLE_SHARED_SPECIFIERS, findSharedImports } from "@powerhousedao/shared/connect";
12
+ import { nodeFileTrace } from "@vercel/nft";
13
+ import { detect, resolveCommand } from "package-manager-detector";
14
+ import { readPackage } from "read-pkg";
15
+ import { build } from "tsdown";
16
+ //#region src/utils/offered-routes-manifest.ts
17
+ function withOfferedRoutes(json, offers) {
18
+ const manifest = JSON.parse(json);
19
+ if (offers ? manifest.connectRoutes === true : !("connectRoutes" in manifest)) return json;
20
+ if (offers) manifest.connectRoutes = true;
21
+ else delete manifest.connectRoutes;
22
+ return `${JSON.stringify(manifest, null, 2)}\n`;
23
+ }
24
+ const slashes = (path) => path.replaceAll("\\", "/");
25
+ /** Sets `connectRoutes` in the manifest the package's root module imports,
26
+ * leaving the project's file as it is. */
27
+ function offeredRoutesManifest(projectRoot, offers) {
28
+ const manifestPath = slashes(join(projectRoot, "powerhouse.manifest.json"));
29
+ return {
30
+ name: "ph-offered-routes-manifest",
31
+ transform(code, id) {
32
+ if (slashes(id) !== manifestPath) return null;
33
+ return {
34
+ code: withOfferedRoutes(code, offers),
35
+ map: null
36
+ };
37
+ }
38
+ };
39
+ }
40
+ /** Sets `connectRoutes` in the dist copy of the manifest. */
41
+ function markOfferedRoutes(dir, offers) {
42
+ const manifestPath = join(dir, "powerhouse.manifest.json");
43
+ if (!existsSync(manifestPath)) return;
44
+ const json = readFileSync(manifestPath, "utf-8");
45
+ writeFileSync(manifestPath, withOfferedRoutes(json, offers));
46
+ }
47
+ //#endregion
48
+ //#region src/services/build.ts
49
+ function createTraceFiles() {
50
+ const cache = {};
51
+ return (file) => traceFile(file, cache);
52
+ }
53
+ async function traceFile(file, cache) {
54
+ const { fileList, reasons } = await nodeFileTrace([file], {
55
+ base: "/",
56
+ cache
57
+ });
58
+ const absolute = (p) => resolve("/", p);
59
+ return {
60
+ fileList: new Set([...fileList].map(absolute)),
61
+ reasons: new Map([...reasons].map(([p, reason]) => [absolute(p), { parents: new Set([...reason.parents].map(absolute)) }]))
62
+ };
63
+ }
64
+ /**
65
+ * A Powerhouse package's `powerhouse.manifest.json` "name" must match its
66
+ * `package.json` "name" — Connect and the registry resolve installed versions
67
+ * by treating the manifest name as the npm package name, so a mismatch silently
68
+ * breaks resolution. Fail the build early if they diverge. No-op when the
69
+ * project has no manifest (nothing to compare).
70
+ */
71
+ async function assertManifestNameMatchesPackage(projectPath) {
72
+ const manifestPath = join(projectPath, "powerhouse.manifest.json");
73
+ if (!existsSync(manifestPath)) return;
74
+ const { name: packageName } = await readPackage({ cwd: projectPath });
75
+ let manifestName;
76
+ try {
77
+ manifestName = JSON.parse(readFileSync(manifestPath, "utf-8")).name;
78
+ } catch {
79
+ throw new Error(`Failed to parse "powerhouse.manifest.json" at ${manifestPath}. Make sure it is valid JSON.`);
80
+ }
81
+ if (manifestName !== packageName) throw new Error(`Package name mismatch — "package.json" and "powerhouse.manifest.json" must have the same "name":\n package.json "name": ${JSON.stringify(packageName)}\n powerhouse.manifest.json "name": ${JSON.stringify(manifestName)}\n\nUpdate one so they match, then run the build again.`);
82
+ }
83
+ async function runBuild(args) {
84
+ const { outDir } = args;
85
+ const projectRoot = process.cwd();
86
+ await assertManifestNameMatchesPackage(projectRoot);
87
+ const target = {
88
+ projectRoot,
89
+ outDir,
90
+ pieces: planPieces(projectRoot, outDir)
91
+ };
92
+ assertPiecesOutDir(target);
93
+ const sharedDeps = !args.noSharedDeps;
94
+ const agent = (await detect())?.agent ?? "npm";
95
+ await syncProjectConnectRoutes(projectRoot);
96
+ const offersRoutes = existsSync(join(projectRoot, OFFERED_ROUTES_MODULE));
97
+ const typesOk = emitTypes(agent, outDir, projectRoot);
98
+ if (!typesOk && !args.ignoreTypeErrors) await confirmBuildDespiteTypeErrors();
99
+ const detection = createDetectionCache();
100
+ const trace = createTraceFiles();
101
+ const routesEntry = join(projectRoot, OFFERED_ROUTES_MODULE);
102
+ await build({
103
+ ...buildBrowserBuildConfig({
104
+ sharedDeps,
105
+ plugins: [
106
+ externalDepsPlugin(trace, /* @__PURE__ */ new Map(), {
107
+ root: projectRoot,
108
+ browser: true,
109
+ cache: detection
110
+ }),
111
+ offeredRoutesManifest(projectRoot, offersRoutes),
112
+ noConnectImports(routesEntry, join(projectRoot, HOST_ROUTES_DIR))
113
+ ]
114
+ }),
115
+ ...offersRoutes ? { entry: [...browserEntry, { "connect-routes": routesEntry }] } : {},
116
+ outDir: join(outDir, "browser")
117
+ });
118
+ if (sharedDeps) {
119
+ const imported = findSharedImportsInSources(projectRoot, browserEntry);
120
+ const bundled = findBundledSharedDeps(imported, readDistBrowserFiles(join(outDir, "browser")));
121
+ if (bundled.length > 0) console.warn(`⚠ shared deps bundled instead of externalized: ${bundled.join(", ")} — check your neverBundle config`);
122
+ }
123
+ const external = /* @__PURE__ */ new Map();
124
+ await build({
125
+ ...buildNodeBuildConfig({
126
+ sharedDeps,
127
+ plugins: [externalDepsPlugin(trace, external, {
128
+ root: projectRoot,
129
+ ignoreDirs: ["editors"],
130
+ forbidDirs: ["document-models", "scalars"],
131
+ cache: detection
132
+ })]
133
+ }),
134
+ outDir: join(outDir, "node")
135
+ });
136
+ const pkg = await readPackage({ cwd: projectRoot });
137
+ assertExternalDependenciesDeclared(projectRoot, [...external.values()], pkg);
138
+ let built = [];
139
+ if (existsSync(pieceListPath(target))) built = await buildPieces(target, {
140
+ name: pkg.name,
141
+ version: pkg.version,
142
+ license: typeof pkg.license === "string" ? pkg.license : void 0
143
+ }, {
144
+ bundle: build,
145
+ trace,
146
+ cache: detection
147
+ });
148
+ syncDistManifest(target, built, externalDependencyVersions(external.values()));
149
+ markOfferedRoutes(outDir, offersRoutes);
150
+ buildPackageStylesheet(agent, projectRoot, join(outDir, "browser"));
151
+ if (!typesOk) console.warn(`\n${UNSAFE_BUILD_WARNING}`);
152
+ }
153
+ function assertExternalDependenciesDeclared(projectRoot, found, pkg) {
154
+ for (const dep of found) console.log(`${dep.name}@${dep.version} stays external, it needs ${projectPath(projectRoot, dep.file)}`);
155
+ const undeclared = undeclaredExternalDependencies(found, pkg);
156
+ if (undeclared.length === 0) return;
157
+ const lines = undeclared.map((dep) => ` ${dep.name}${dep.importer ? ` (imported by ${projectPath(projectRoot, dep.importer)})` : ""}`);
158
+ throw new Error(`Packages with native addons or WebAssembly modules must be listed in package.json "dependencies", "optionalDependencies" or "peerDependencies":\n${lines.join("\n")}\n\nThey stay external to the build, and installs of this package skip devDependencies.`);
159
+ }
160
+ function declarationsMissing(agent, projectRoot) {
161
+ const showConfig = resolveCommand(agent, "execute-local", ["tsc", "--showConfig"]);
162
+ if (showConfig === null) return false;
163
+ let options;
164
+ try {
165
+ const output = execSync(`${showConfig.command} ${showConfig.args.join(" ")}`, {
166
+ cwd: projectRoot,
167
+ encoding: "utf8",
168
+ stdio: [
169
+ "ignore",
170
+ "pipe",
171
+ "ignore"
172
+ ]
173
+ });
174
+ options = JSON.parse(output).compilerOptions ?? {};
175
+ } catch {
176
+ return false;
177
+ }
178
+ const dir = options.declarationDir ?? options.outDir;
179
+ if (!dir || !(options.declaration || options.composite)) return false;
180
+ const path = resolve(projectRoot, dir);
181
+ return !existsSync(path) || readdirSync(path).length === 0;
182
+ }
183
+ function emitTypes(agent, outDir, projectRoot) {
184
+ const force = declarationsMissing(agent, projectRoot);
185
+ const tscCommand = resolveCommand(agent, "execute-local", [
186
+ "tsc",
187
+ "--build",
188
+ ...force ? ["--force"] : []
189
+ ]);
190
+ if (tscCommand === null) {
191
+ console.error("You need to have typescript installed to use the `build` command.");
192
+ process.exit(1);
193
+ }
194
+ console.log("\n▶ Type-checking and emitting types via tsc...");
195
+ try {
196
+ execSync(`${tscCommand.command} ${tscCommand.args.join(" ")}`, { stdio: "inherit" });
197
+ console.log("✔ Types emitted to", join(outDir, "types"));
198
+ return true;
199
+ } catch {
200
+ return false;
201
+ }
202
+ }
203
+ function buildPackageStylesheet(agent, projectRoot, browserDir) {
204
+ const command = resolveCommand(agent, "execute-local", [
205
+ "tailwindcss",
206
+ "--input",
207
+ "-",
208
+ "--minify"
209
+ ]);
210
+ if (command === null) {
211
+ console.error("You need to have tailwindcss installed to use the `build` command.");
212
+ process.exit(1);
213
+ }
214
+ const stylePath = join(projectRoot, "style.css");
215
+ const style = existsSync(stylePath) ? readFileSync(stylePath, "utf-8") : void 0;
216
+ const compiled = execSync(`${command.command} ${command.args.join(" ")}`, {
217
+ cwd: projectRoot,
218
+ input: packageStyleEntry(style, {
219
+ browserDir: sourcePath(projectRoot, browserDir),
220
+ localPackages: localPackageNames(projectRoot)
221
+ }),
222
+ encoding: "utf-8",
223
+ stdio: [
224
+ "pipe",
225
+ "pipe",
226
+ "inherit"
227
+ ],
228
+ maxBuffer: 67108864
229
+ });
230
+ mkdirSync(join(projectRoot, "dist"), { recursive: true });
231
+ writeFileSync(join(projectRoot, "dist/style.css"), packageStylesheet(compiled));
232
+ }
233
+ function sourcePath(projectRoot, path) {
234
+ return `./${relative(projectRoot, resolve(projectRoot, path)).replaceAll("\\", "/")}`;
235
+ }
236
+ function isInteractive() {
237
+ return Boolean(process.stdin.isTTY) && !process.env.CI;
238
+ }
239
+ const TYPE_ERROR_RISK = "A package built with type errors can load and still fail at runtime.";
240
+ const UNSAFE_BUILD_WARNING = "⚠ Built despite type errors. " + TYPE_ERROR_RISK + " Fix them before you publish or deploy it.";
241
+ async function confirmBuildDespiteTypeErrors() {
242
+ const hint = "Fix them and build again. --ignore-type-errors skips this check, at the risk of shipping that failure.";
243
+ if (!isInteractive()) {
244
+ console.error(`\n✘ tsc reported the type errors above. ${TYPE_ERROR_RISK}\n${hint}`);
245
+ process.exit(1);
246
+ }
247
+ const enquirer = await import("enquirer");
248
+ let confirmed;
249
+ try {
250
+ confirmed = (await enquirer.default.prompt({
251
+ type: "confirm",
252
+ name: "confirmed",
253
+ message: `tsc reported the type errors above. ${TYPE_ERROR_RISK} Build anyway?`,
254
+ initial: false
255
+ })).confirmed;
256
+ } catch {
257
+ confirmed = false;
258
+ }
259
+ if (!confirmed) {
260
+ console.error(`Build cancelled. ${hint}`);
261
+ process.exit(1);
262
+ }
263
+ }
264
+ /**
265
+ * Every shared specifier imported from the entry sources; the post-build
266
+ * scan compares these against the built output.
267
+ *
268
+ * Scoped to the specifiers the build actually externalizes: a specifier the
269
+ * vendor does not publish (the bare `@powerhousedao/shared` root, an
270
+ * unvendored subpath) is deliberately bundled, so reporting it as "bundled
271
+ * instead of externalized" would be a false alarm.
272
+ */
273
+ function findSharedImportsInSources(root, globs) {
274
+ const found = /* @__PURE__ */ new Set();
275
+ for (const file of expandEntryGlobs(root, globs)) {
276
+ const src = readFileSync(file, "utf8");
277
+ for (const spec of findSharedImports(src, EXTERNALIZABLE_SHARED_SPECIFIERS)) found.add(spec);
278
+ }
279
+ return [...found].sort();
280
+ }
281
+ /**
282
+ * The built JS outputs of a browser build (entry files and chunks).
283
+ */
284
+ function readDistBrowserFiles(dir) {
285
+ const out = [];
286
+ if (!existsSync(dir)) return out;
287
+ const walk = (d) => {
288
+ for (const e of readdirSync(d, { withFileTypes: true })) {
289
+ const p = join(d, e.name);
290
+ if (e.isDirectory()) walk(p);
291
+ else if (e.isFile() && e.name.endsWith(".js")) out.push({
292
+ path: p,
293
+ content: readFileSync(p, "utf8")
294
+ });
295
+ }
296
+ };
297
+ walk(dir);
298
+ return out;
299
+ }
300
+ //#endregion
301
+ export { runBuild as i, assertManifestNameMatchesPackage as n, createTraceFiles as r, assertExternalDependenciesDeclared as t };
302
+
303
+ //# sourceMappingURL=build-t5pFQx0f.mjs.map
304
+ //# debugId=8bd27820-5036-5c2f-883c-3003ca4a9a6a
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-t5pFQx0f.mjs","sources":["../src/utils/offered-routes-manifest.ts","../src/services/build.ts"],"sourcesContent":["import { existsSync, readFileSync, writeFileSync } from \"node:fs\";\nimport { join } from \"node:path\";\n\n// The manifest with `connectRoutes` set when the package offers routes; as it\n// is, byte for byte, when the flag is already right.\nfunction withOfferedRoutes(json: string, offers: boolean) {\n const manifest = JSON.parse(json) as { connectRoutes?: boolean };\n if (offers ? manifest.connectRoutes === true : !(\"connectRoutes\" in manifest))\n return json;\n if (offers) manifest.connectRoutes = true;\n else delete manifest.connectRoutes;\n return `${JSON.stringify(manifest, null, 2)}\\n`;\n}\n\nconst slashes = (path: string) => path.replaceAll(\"\\\\\", \"/\");\n\n/** Sets `connectRoutes` in the manifest the package's root module imports,\n * leaving the project's file as it is. */\nexport function offeredRoutesManifest(projectRoot: string, offers: boolean) {\n // Vite's ids use forward slashes on Windows too.\n const manifestPath = slashes(join(projectRoot, \"powerhouse.manifest.json\"));\n return {\n name: \"ph-offered-routes-manifest\",\n transform(code: string, id: string) {\n if (slashes(id) !== manifestPath) return null;\n return { code: withOfferedRoutes(code, offers), map: null };\n },\n };\n}\n\n/** Sets `connectRoutes` in the dist copy of the manifest. */\nexport function markOfferedRoutes(dir: string, offers: boolean) {\n const manifestPath = join(dir, \"powerhouse.manifest.json\");\n if (!existsSync(manifestPath)) return;\n const json = readFileSync(manifestPath, \"utf-8\");\n writeFileSync(manifestPath, withOfferedRoutes(json, offers));\n}\n","import {\n browserEntry,\n buildBrowserBuildConfig,\n buildNodeBuildConfig,\n findBundledSharedDeps,\n} from \"@powerhousedao/shared/build-config\";\nimport type {\n BuiltPiece,\n ExternalDependency,\n TraceFiles,\n} from \"@powerhousedao/shared/build-pieces\";\nimport {\n assertPiecesOutDir,\n buildPieces,\n expandEntryGlobs,\n createDetectionCache,\n externalDependencyVersions,\n projectPath,\n externalDepsPlugin,\n pieceListPath,\n planPieces,\n syncDistManifest,\n undeclaredExternalDependencies,\n} from \"@powerhousedao/shared/build-pieces\";\nimport {\n localPackageNames,\n packageStyleEntry,\n packageStylesheet,\n} from \"@powerhousedao/shared/clis/package-style\";\nimport {\n findSharedImports,\n EXTERNALIZABLE_SHARED_SPECIFIERS,\n} from \"@powerhousedao/shared/connect\";\nimport { execSync } from \"node:child_process\";\nimport {\n existsSync,\n mkdirSync,\n readdirSync,\n readFileSync,\n writeFileSync,\n} from \"node:fs\";\nimport { join, relative, resolve } from \"node:path\";\nimport { nodeFileTrace } from \"@vercel/nft\";\nimport { detect, resolveCommand, type Agent } from \"package-manager-detector\";\nimport { readPackage } from \"read-pkg\";\nimport { build as tsdownBuild } from \"tsdown\";\nimport type { BuildArgs } from \"../types.js\";\nimport { noConnectImports } from \"../utils/offered-routes-imports.js\";\nimport {\n markOfferedRoutes,\n offeredRoutesManifest,\n} from \"../utils/offered-routes-manifest.js\";\nimport {\n HOST_ROUTES_DIR,\n OFFERED_ROUTES_MODULE,\n syncProjectConnectRoutes,\n} from \"../utils/sync-connect-routes.js\";\n\n// nft reports paths relative to its base; from \"/\" that is every path minus its root.\n// One cache per build: the traces of a project's packages share most files.\nexport function createTraceFiles(): TraceFiles {\n const cache = {};\n return (file) => traceFile(file, cache);\n}\n\nexport const traceFiles: TraceFiles = createTraceFiles();\n\nasync function traceFile(file: string, cache: object) {\n const { fileList, reasons } = await nodeFileTrace([file], {\n base: \"/\",\n cache,\n });\n const absolute = (p: string) => resolve(\"/\", p);\n return {\n fileList: new Set([...fileList].map(absolute)),\n reasons: new Map(\n [...reasons].map(([p, reason]) => [\n absolute(p),\n { parents: new Set([...reason.parents].map(absolute)) },\n ]),\n ),\n };\n}\n\n/**\n * A Powerhouse package's `powerhouse.manifest.json` \"name\" must match its\n * `package.json` \"name\" — Connect and the registry resolve installed versions\n * by treating the manifest name as the npm package name, so a mismatch silently\n * breaks resolution. Fail the build early if they diverge. No-op when the\n * project has no manifest (nothing to compare).\n */\nexport async function assertManifestNameMatchesPackage(projectPath: string) {\n const manifestPath = join(projectPath, \"powerhouse.manifest.json\");\n if (!existsSync(manifestPath)) return;\n\n const { name: packageName } = await readPackage({ cwd: projectPath });\n\n let manifestName: unknown;\n try {\n manifestName = (\n JSON.parse(readFileSync(manifestPath, \"utf-8\")) as { name?: unknown }\n ).name;\n } catch {\n throw new Error(\n `Failed to parse \"powerhouse.manifest.json\" at ${manifestPath}. Make sure it is valid JSON.`,\n );\n }\n\n if (manifestName !== packageName) {\n throw new Error(\n `Package name mismatch — \"package.json\" and \"powerhouse.manifest.json\" must have the same \"name\":\\n` +\n ` package.json \"name\": ${JSON.stringify(packageName)}\\n` +\n ` powerhouse.manifest.json \"name\": ${JSON.stringify(manifestName)}\\n\\n` +\n `Update one so they match, then run the build again.`,\n );\n }\n}\n\nexport async function runBuild(args: BuildArgs) {\n const { outDir } = args;\n const projectRoot = process.cwd();\n\n // Fail fast if the manifest name and package.json name have drifted apart.\n await assertManifestNameMatchesPackage(projectRoot);\n\n const target = {\n projectRoot,\n outDir,\n pieces: planPieces(projectRoot, outDir),\n };\n // Before any bundler runs: an out-dir a host will never read from is worth\n // nothing built, and the failure names what the contract is.\n assertPiecesOutDir(target);\n const sharedDeps = !args.noSharedDeps;\n\n const detectResult = await detect();\n const agent = detectResult?.agent ?? \"npm\";\n\n // Project routes type-check against the tree generated from them.\n await syncProjectConnectRoutes(projectRoot);\n // Connect reads the manifest's flag to load the package's routes.\n const offersRoutes = existsSync(join(projectRoot, OFFERED_ROUTES_MODULE));\n\n // Before any bundler runs, so declining leaves nothing half built.\n const typesOk = emitTypes(agent, outDir, projectRoot);\n if (!typesOk && !args.ignoreTypeErrors) {\n await confirmBuildDespiteTypeErrors();\n }\n\n // Shared by the browser, node and piece builds: nothing is traced twice.\n const detection = createDetectionCache();\n const trace = createTraceFiles();\n const routesEntry = join(projectRoot, OFFERED_ROUTES_MODULE);\n // Everything in the browser build is code Connect can load: native fails it.\n await tsdownBuild({\n ...buildBrowserBuildConfig({\n sharedDeps,\n plugins: [\n externalDepsPlugin(trace, new Map(), {\n root: projectRoot,\n browser: true,\n cache: detection,\n }),\n offeredRoutesManifest(projectRoot, offersRoutes),\n noConnectImports(routesEntry, join(projectRoot, HOST_ROUTES_DIR)),\n ],\n }),\n // The offered routes in the package's build: a module both import is one\n // chunk, which other Connects evaluate once. Absolute: a relative entry\n // is a glob, and globs skip `.ph`.\n ...(offersRoutes\n ? { entry: [...browserEntry, { \"connect-routes\": routesEntry }] }\n : {}),\n outDir: join(outDir, \"browser\"),\n });\n\n // Advisory: a shared dep the source imports but the output no longer\n // references as a bare import was inlined despite the external set.\n if (sharedDeps) {\n const imported = findSharedImportsInSources(projectRoot, browserEntry);\n const bundled = findBundledSharedDeps(\n imported,\n readDistBrowserFiles(join(outDir, \"browser\")),\n );\n if (bundled.length > 0) {\n console.warn(\n `⚠ shared deps bundled instead of externalized: ${bundled.join(\", \")} — check your neverBundle config`,\n );\n }\n }\n\n const external = new Map<string, ExternalDependency>();\n await tsdownBuild({\n ...buildNodeBuildConfig({\n sharedDeps,\n plugins: [\n // Editors never run on a host; document models and scalars run in Connect too.\n externalDepsPlugin(trace, external, {\n root: projectRoot,\n ignoreDirs: [\"editors\"],\n forbidDirs: [\"document-models\", \"scalars\"],\n cache: detection,\n }),\n ],\n }),\n outDir: join(outDir, \"node\"),\n });\n const pkg = await readPackage({ cwd: projectRoot });\n assertExternalDependenciesDeclared(projectRoot, [...external.values()], pkg);\n\n // After the node build: it cleans <outDir>/node, where the pieces land. The\n // built list is the gate, so a `bundle:` entry is validated with no piece dir.\n let built: BuiltPiece[] = [];\n if (existsSync(pieceListPath(target))) {\n built = await buildPieces(\n target,\n {\n name: pkg.name,\n version: pkg.version,\n license: typeof pkg.license === \"string\" ? pkg.license : undefined,\n },\n { bundle: tsdownBuild, trace, cache: detection },\n );\n }\n syncDistManifest(\n target,\n built,\n externalDependencyVersions(external.values()),\n );\n markOfferedRoutes(outDir, offersRoutes);\n\n buildPackageStylesheet(agent, projectRoot, join(outDir, \"browser\"));\n\n // Last, so it is the line a finished build leaves on screen.\n if (!typesOk) console.warn(`\\n${UNSAFE_BUILD_WARNING}`);\n}\n\n// A package with a native addon or WebAssembly module stays external, so the\n// package's consumers must install it: devDependencies are skipped by every install.\nexport function assertExternalDependenciesDeclared(\n projectRoot: string,\n found: ExternalDependency[],\n pkg: Parameters<typeof undeclaredExternalDependencies>[1],\n) {\n for (const dep of found) {\n console.log(\n `${dep.name}@${dep.version} stays external, it needs ${projectPath(projectRoot, dep.file)}`,\n );\n }\n const undeclared = undeclaredExternalDependencies(found, pkg);\n if (undeclared.length === 0) return;\n const lines = undeclared.map(\n (dep) =>\n ` ${dep.name}${dep.importer ? ` (imported by ${projectPath(projectRoot, dep.importer)})` : \"\"}`,\n );\n throw new Error(\n `Packages with native addons or WebAssembly modules must be listed in package.json \"dependencies\", \"optionalDependencies\" or \"peerDependencies\":\\n` +\n `${lines.join(\"\\n\")}\\n\\n` +\n `They stay external to the build, and installs of this package skip devDependencies.`,\n );\n}\n\n// tsc's build info outlives a deleted dist; with the declarations gone, tsc\n// would call the project up to date and emit nothing.\nfunction declarationsMissing(agent: Agent, projectRoot: string): boolean {\n const showConfig = resolveCommand(agent, \"execute-local\", [\n \"tsc\",\n \"--showConfig\",\n ]);\n if (showConfig === null) return false;\n let options: {\n declaration?: boolean;\n composite?: boolean;\n declarationDir?: string;\n outDir?: string;\n };\n try {\n const output = execSync(\n `${showConfig.command} ${showConfig.args.join(\" \")}`,\n {\n cwd: projectRoot,\n encoding: \"utf8\",\n stdio: [\"ignore\", \"pipe\", \"ignore\"],\n },\n );\n options =\n (JSON.parse(output) as { compilerOptions?: typeof options })\n .compilerOptions ?? {};\n } catch {\n return false;\n }\n const dir = options.declarationDir ?? options.outDir;\n if (!dir || !(options.declaration || options.composite)) return false;\n const path = resolve(projectRoot, dir);\n return !existsSync(path) || readdirSync(path).length === 0;\n}\n\n// Runs tsc, which checks the project and writes its declarations either way.\n// Returns whether it reported no type errors.\nfunction emitTypes(agent: Agent, outDir: string, projectRoot: string): boolean {\n const force = declarationsMissing(agent, projectRoot);\n const tscCommand = resolveCommand(agent, \"execute-local\", [\n \"tsc\",\n \"--build\",\n ...(force ? [\"--force\"] : []),\n ]);\n if (tscCommand === null) {\n console.error(\n \"You need to have typescript installed to use the `build` command.\",\n );\n process.exit(1);\n }\n console.log(\"\\n▶ Type-checking and emitting types via tsc...\");\n try {\n execSync(`${tscCommand.command} ${tscCommand.args.join(\" \")}`, {\n stdio: \"inherit\",\n });\n console.log(\"✔ Types emitted to\", join(outDir, \"types\"));\n return true;\n } catch {\n return false;\n }\n}\n\n// The classes the browser build uses, and the package's tokens and rules, against\n// Connect's theme: the Connect that loads it has Tailwind's reset and Connect's classes.\nfunction buildPackageStylesheet(\n agent: Agent,\n projectRoot: string,\n browserDir: string,\n) {\n const command = resolveCommand(agent, \"execute-local\", [\n \"tailwindcss\",\n \"--input\",\n \"-\",\n \"--minify\",\n ]);\n if (command === null) {\n console.error(\n \"You need to have tailwindcss installed to use the `build` command.\",\n );\n process.exit(1);\n }\n const stylePath = join(projectRoot, \"style.css\");\n const style = existsSync(stylePath)\n ? readFileSync(stylePath, \"utf-8\")\n : undefined;\n const compiled = execSync(`${command.command} ${command.args.join(\" \")}`, {\n cwd: projectRoot,\n input: packageStyleEntry(style, {\n browserDir: sourcePath(projectRoot, browserDir),\n localPackages: localPackageNames(projectRoot),\n }),\n encoding: \"utf-8\",\n stdio: [\"pipe\", \"pipe\", \"inherit\"],\n // A package that imports large vendor CSS outgrows the 1 MB default.\n maxBuffer: 64 * 1024 * 1024,\n });\n // `ph build` with another out-dir (the switchboard runner's) leaves no dist/.\n mkdirSync(join(projectRoot, \"dist\"), { recursive: true });\n writeFileSync(\n join(projectRoot, \"dist/style.css\"),\n packageStylesheet(compiled),\n );\n}\n\n// A path for `@source`, relative to the project, with forward slashes.\nfunction sourcePath(projectRoot: string, path: string) {\n return `./${relative(projectRoot, resolve(projectRoot, path)).replaceAll(\"\\\\\", \"/\")}`;\n}\n\nfunction isInteractive(): boolean {\n return Boolean(process.stdin.isTTY) && !process.env.CI;\n}\n\nconst TYPE_ERROR_RISK =\n \"A package built with type errors can load and still fail at runtime.\";\n\nconst UNSAFE_BUILD_WARNING =\n \"⚠ Built despite type errors. \" +\n TYPE_ERROR_RISK +\n \" Fix them before you publish or deploy it.\";\n\nasync function confirmBuildDespiteTypeErrors(): Promise<void> {\n const hint =\n \"Fix them and build again. --ignore-type-errors skips this check, at the risk of shipping that failure.\";\n if (!isInteractive()) {\n console.error(\n `\\n✘ tsc reported the type errors above. ${TYPE_ERROR_RISK}\\n${hint}`,\n );\n process.exit(1);\n }\n const enquirer = await import(\"enquirer\");\n let confirmed: boolean;\n try {\n const answer = await enquirer.default.prompt<{ confirmed: boolean }>({\n type: \"confirm\",\n name: \"confirmed\",\n message: `tsc reported the type errors above. ${TYPE_ERROR_RISK} Build anyway?`,\n initial: false,\n });\n confirmed = answer.confirmed;\n } catch {\n // Ctrl-C at the prompt is a decline.\n confirmed = false;\n }\n if (!confirmed) {\n console.error(`Build cancelled. ${hint}`);\n process.exit(1);\n }\n}\n\n/**\n * Every shared specifier imported from the entry sources; the post-build\n * scan compares these against the built output.\n *\n * Scoped to the specifiers the build actually externalizes: a specifier the\n * vendor does not publish (the bare `@powerhousedao/shared` root, an\n * unvendored subpath) is deliberately bundled, so reporting it as \"bundled\n * instead of externalized\" would be a false alarm.\n */\nfunction findSharedImportsInSources(root: string, globs: string[]): string[] {\n const found = new Set<string>();\n for (const file of expandEntryGlobs(root, globs)) {\n const src = readFileSync(file, \"utf8\");\n for (const spec of findSharedImports(\n src,\n EXTERNALIZABLE_SHARED_SPECIFIERS,\n )) {\n found.add(spec);\n }\n }\n return [...found].sort();\n}\n\n/**\n * The built JS outputs of a browser build (entry files and chunks).\n */\nfunction readDistBrowserFiles(\n dir: string,\n): { path: string; content: string }[] {\n const out: { path: string; content: string }[] = [];\n if (!existsSync(dir)) return out;\n const walk = (d: string) => {\n for (const e of readdirSync(d, { withFileTypes: true })) {\n const p = join(d, e.name);\n if (e.isDirectory()) walk(p);\n else if (e.isFile() && e.name.endsWith(\".js\")) {\n out.push({ path: p, content: readFileSync(p, \"utf8\") });\n }\n }\n };\n walk(dir);\n return out;\n}\n"],"names":["tsdownBuild"],"mappings":";;;;;;;;;;;;;;;;AAKA,SAAS,kBAAkB,MAAc,QAAiB;CACxD,MAAM,WAAW,KAAK,MAAM,IAAI;CAChC,IAAI,SAAS,SAAS,kBAAkB,OAAO,EAAE,mBAAmB,WAClE,OAAO;CACT,IAAI,QAAQ,SAAS,gBAAgB;MAChC,OAAO,SAAS;CACrB,OAAO,GAAG,KAAK,UAAU,UAAU,MAAM,CAAC,EAAE;AAC9C;AAEA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E,SAAS;EACX,CAAC,EAAA,CACkB;CACrB,QAAQ;EAEN,YAAY;CACd;CACA,IAAI,CAAC,WAAW;EACd,QAAQ,MAAM,oBAAoB,MAAM;EACxC,QAAQ,KAAK,CAAC;CAChB;AACF;;;;;;;;;;AAWA,SAAS,2BAA2B,MAAc,OAA2B;CAC3E,MAAM,wBAAQ,IAAI,IAAY;CAC9B,KAAK,MAAM,QAAQ,iBAAiB,MAAM,KAAK,GAAG;EAChD,MAAM,MAAM,aAAa,MAAM,MAAM;EACrC,KAAK,MAAM,QAAQ,kBACjB,KACA,gCACF,GACE,MAAM,IAAI,IAAI;CAElB;CACA,OAAO,CAAC,GAAG,KAAK,CAAC,CAAC,KAAK;AACzB;;;;AAKA,SAAS,qBACP,KACqC;CACrC,MAAM,MAA2C,CAAC;CAClD,IAAI,CAAC,WAAW,GAAG,GAAG,OAAO;CAC7B,MAAM,QAAQ,MAAc;EAC1B,KAAK,MAAM,KAAK,YAAY,GAAG,EAAE,eAAe,KAAK,CAAC,GAAG;GACvD,MAAM,IAAI,KAAK,GAAG,EAAE,IAAI;GACxB,IAAI,EAAE,YAAY,GAAG,KAAK,CAAC;QACtB,IAAI,EAAE,OAAO,KAAK,EAAE,KAAK,SAAS,KAAK,GAC1C,IAAI,KAAK;IAAE,MAAM;IAAG,SAAS,aAAa,GAAG,MAAM;GAAE,CAAC;EAE1D;CACF;CACA,KAAK,GAAG;CACR,OAAO;AACT","debug_id":"8bd27820-5036-5c2f-883c-3003ca4a9a6a"}
@@ -0,0 +1,4 @@
1
+ import { i as runBuild } from "./build-t5pFQx0f.mjs";
2
+ export { runBuild };
3
+ !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="038f88af-54f1-5864-b8de-0247a10a30d4")}catch(e){}}();
4
+ //# debugId=038f88af-54f1-5864-b8de-0247a10a30d4
@@ -0,0 +1,56 @@
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]="b756b89a-4a9d-5c16-bf53-f356abf4c1cc")}catch(e){}}();
3
+ import { n as checkHost } from "./dist-DcARVrSg.mjs";
4
+ import { s as rememberShellNames } from "./member-config-0tHtiVN_.mjs";
5
+ import path from "node:path";
6
+ import { envNamesBeforeProjectEnv, loadProjectEnv } from "@powerhousedao/shared/clis/project-env";
7
+ import dotenv from "dotenv";
8
+ import { readFile } from "node:fs/promises";
9
+ import { CALLER_CWD_ENV } from "@powerhousedao/shared/clis/command-names";
10
+ //#region src/services/host/check.ts
11
+ /** Without `envFile`: what `ph run` sees (project .env under process env). */
12
+ async function checkEnv(projectRoot, envFile) {
13
+ if (envFile === void 0) {
14
+ loadProjectEnv(projectRoot);
15
+ const env = { ...process.env };
16
+ rememberShellNames(env, envNamesBeforeProjectEnv() ?? Object.keys(env));
17
+ return env;
18
+ }
19
+ const from = process.env[CALLER_CWD_ENV] ?? process.cwd();
20
+ try {
21
+ return dotenv.parse(await readFile(path.resolve(from, envFile), "utf8"));
22
+ } catch (error) {
23
+ throw new Error(`Cannot read the env file ${envFile}: ${error instanceof Error ? error.message : String(error)}`, { cause: error });
24
+ }
25
+ }
26
+ function formatHostIssues(file, issues, deferred) {
27
+ if (issues.length === 0) return `${file}: ok${deferred > 0 ? `\n ${deferred} output token(s) checked declared-only` : ""}`;
28
+ const byFile = /* @__PURE__ */ new Map();
29
+ for (const issue of issues) byFile.set(issue.file, [...byFile.get(issue.file) ?? [], issue]);
30
+ return [...byFile].map(([at, found]) => {
31
+ return [at, ...found.flatMap((issue) => {
32
+ const where = issue.path ? `${issue.path}: ` : "";
33
+ const line = ` ${issue.stage} ${where}${issue.message.replaceAll("\n", "\n ")}`;
34
+ return issue.hint ? [line, ` hint: ${issue.hint}`] : [line];
35
+ })].join("\n");
36
+ }).join("\n\n");
37
+ }
38
+ /** `ph host check <host>`: every issue `ph run` would hit; exits 1 on any. */
39
+ async function runHostCheck(args) {
40
+ const projectRoot = args.projectRoot ?? process.cwd();
41
+ const env = await checkEnv(projectRoot, args.envFile);
42
+ const { issues, deferred } = await checkHost(args.host, {
43
+ projectRoot,
44
+ env,
45
+ ...args.verb !== void 0 ? { verb: args.verb } : {}
46
+ });
47
+ return {
48
+ output: formatHostIssues(`hosts/${args.host}/host.js`, issues, deferred.length),
49
+ exitCode: issues.length > 0 ? 1 : 0
50
+ };
51
+ }
52
+ //#endregion
53
+ export { runHostCheck };
54
+
55
+ //# sourceMappingURL=check-ecwBLzrg.mjs.map
56
+ //# debugId=b756b89a-4a9d-5c16-bf53-f356abf4c1cc
@@ -0,0 +1 @@
1
+ {"version":3,"file":"check-ecwBLzrg.mjs","sources":["../src/services/host/check.ts"],"sourcesContent":["import { readFile } from \"node:fs/promises\";\nimport path from \"node:path\";\nimport { checkHost, type HostIssue } from \"@powerhousedao/host-core\";\nimport { CALLER_CWD_ENV } from \"@powerhousedao/shared/clis/command-names\";\nimport {\n envNamesBeforeProjectEnv,\n loadProjectEnv,\n} from \"@powerhousedao/shared/clis/project-env\";\nimport dotenv from \"dotenv\";\nimport { rememberShellNames } from \"../../runners/member-config.js\";\n\nexport interface HostCheckArgs {\n host: string;\n envFile?: string;\n verb?: string;\n projectRoot?: string;\n}\n\n/** Without `envFile`: what `ph run` sees (project .env under process env). */\nasync function checkEnv(\n projectRoot: string,\n envFile: string | undefined,\n): Promise<Record<string, string | undefined>> {\n if (envFile === undefined) {\n loadProjectEnv(projectRoot);\n // A snapshot: a .env a runner's checkBoot loads later never reaches it.\n const env = { ...process.env };\n // The switchboard's checkBoot puts the .env's values under the host file.\n rememberShellNames(env, envNamesBeforeProjectEnv() ?? Object.keys(env));\n return env;\n }\n const from = process.env[CALLER_CWD_ENV] ?? process.cwd();\n try {\n return dotenv.parse(await readFile(path.resolve(from, envFile), \"utf8\"));\n } catch (error) {\n throw new Error(\n `Cannot read the env file ${envFile}: ${error instanceof Error ? error.message : String(error)}`,\n { cause: error },\n );\n }\n}\n\nexport function formatHostIssues(\n file: string,\n issues: readonly HostIssue[],\n deferred: number,\n): string {\n if (issues.length === 0) {\n const note =\n deferred > 0\n ? `\\n ${deferred} output token(s) checked declared-only`\n : \"\";\n return `${file}: ok${note}`;\n }\n const byFile = new Map<string, HostIssue[]>();\n for (const issue of issues) {\n byFile.set(issue.file, [...(byFile.get(issue.file) ?? []), issue]);\n }\n const blocks = [...byFile].map(([at, found]) => {\n const lines = found.flatMap((issue) => {\n const where = issue.path ? `${issue.path}: ` : \"\";\n const line = ` ${issue.stage} ${where}${issue.message.replaceAll(\"\\n\", \"\\n \")}`;\n return issue.hint ? [line, ` hint: ${issue.hint}`] : [line];\n });\n return [at, ...lines].join(\"\\n\");\n });\n return blocks.join(\"\\n\\n\");\n}\n\n/** `ph host check <host>`: every issue `ph run` would hit; exits 1 on any. */\nexport async function runHostCheck(\n args: HostCheckArgs,\n): Promise<{ output: string; exitCode: number }> {\n const projectRoot = args.projectRoot ?? process.cwd();\n const env = await checkEnv(projectRoot, args.envFile);\n const { issues, deferred } = await checkHost(args.host, {\n projectRoot,\n env,\n ...(args.verb !== undefined ? { verb: args.verb } : {}),\n });\n return {\n output: formatHostIssues(\n `hosts/${args.host}/host.js`,\n issues,\n deferred.length,\n ),\n exitCode: issues.length > 0 ? 1 : 0,\n };\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAmBA,eAAe,SACb,aACA,SAC6C;CAC7C,IAAI,YAAY,KAAA,GAAW;EACzB,eAAe,WAAW;EAE1B,MAAM,MAAM,EAAE,GAAG,QAAQ,IAAI;EAE7B,mBAAmB,KAAK,yBAAyB,KAAK,OAAO,KAAK,GAAG,CAAC;EACtE,OAAO;CACT;CACA,MAAM,OAAO,QAAQ,IAAI,mBAAmB,QAAQ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,KAAK,WACnB,QACA,SAAS,MACX;EACA,UAAU,OAAO,SAAS,IAAI,IAAI;CACpC;AACF","debug_id":"b756b89a-4a9d-5c16-bf53-f356abf4c1cc"}
@@ -1,5 +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]="1cfb2ec9-21ac-545a-a4fa-c392fd478bc4")}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]="9e90198b-acf2-58dd-bc1d-71082e0cc0e1")}catch(e){}}();
3
+ import { o as mergeDefaultDrives } from "./dist-DcARVrSg.mjs";
3
4
  import { deepMerge, phConnectRuntimeConfigSchema } from "@powerhousedao/shared/connect";
4
5
  import AjvNs from "ajv";
5
6
  import { isPlainObject, stringToPath } from "remeda";
@@ -36,7 +37,10 @@ function normalizeKey(key) {
36
37
  function formatErrors(errors) {
37
38
  if (!errors || errors.length === 0) return "unknown validation error";
38
39
  return errors.map((e) => {
39
- return ` ${e.instancePath || "(root)"} ${e.message ?? ""}`.trim();
40
+ const path = e.instancePath || "(root)";
41
+ const extra = e.params?.additionalProperty;
42
+ const suffix = extra === void 0 ? "" : ` (${JSON.stringify(extra)})`;
43
+ return ` ${path} ${e.message ?? ""}${suffix}`.trim();
40
44
  }).join("\n");
41
45
  }
42
46
  /**
@@ -63,22 +67,29 @@ function validateConnectKeyValue(key, rawValue) {
63
67
  * `connect.*` schema). If present in the payload, it is extracted before
64
68
  * validation so the connect-only blob can be checked against the schema,
65
69
  * then re-attached on the returned object so the caller can route it.
70
+ *
71
+ * `command` prefixes error messages (e.g. "ph connect build").
66
72
  */
67
- function validateConnectPatch(raw) {
73
+ function validateConnectPatch(raw, command = "ph connect config") {
74
+ const label = `${command} --json`;
68
75
  let parsed;
69
76
  try {
70
77
  parsed = JSON.parse(raw);
71
78
  } catch (e) {
72
79
  const msg = e instanceof Error ? e.message : String(e);
73
- throw new Error(`ph connect config --json: invalid JSON (${msg}). Expected a partial connect.* blob, e.g. --json '{"renown":{"url":"..."}}'.`, { cause: e });
80
+ throw new Error(`${label}: invalid JSON (${msg}). Expected a partial connect.* blob, e.g. --json '{"renown":{"url":"..."}}'.`, { cause: e });
81
+ }
82
+ if (!isPlainObject(parsed)) throw new Error(`${label}: payload must be a JSON object, got ${typeof parsed}.`);
83
+ if (Object.prototype.hasOwnProperty.call(parsed, "connect")) {
84
+ const inner = JSON.stringify(parsed.connect);
85
+ throw new Error(`${label}: pass the connect.* block without the "connect" wrapper, e.g. --json '${inner}'.`);
74
86
  }
75
- if (!isPlainObject(parsed)) throw new Error(`ph connect config --json: payload must be a JSON object, got ${typeof parsed}.`);
76
87
  const top = parsed;
77
88
  const hasPackageRegistryUrl = Object.prototype.hasOwnProperty.call(top, "packageRegistryUrl");
78
89
  const packageRegistryUrl = top.packageRegistryUrl;
79
90
  const connectOnly = { ...top };
80
91
  delete connectOnly.packageRegistryUrl;
81
- if (!validateConnect(connectOnly)) throw new Error(`ph connect config --json: validation failed:\n${formatErrors(validateConnect.errors)}`);
92
+ if (!validateConnect(connectOnly)) throw new Error(`${label}: validation failed:\n${formatErrors(validateConnect.errors)}\nExpected a partial connect.* blob with nested keys, e.g. --json '{"app":{"workflowsEnabled":true}}'.`);
82
93
  return hasPackageRegistryUrl ? {
83
94
  ...connectOnly,
84
95
  packageRegistryUrl
@@ -99,21 +110,9 @@ const parseDefaultDrivesUrl = (v) => v.split(",").map((s) => s.trim()).filter(Bo
99
110
  }));
100
111
  //#endregion
101
112
  //#region src/utils/cli-connect-override.ts
102
- /**
103
- * Parse the `--json` payload (if any). Throws on malformed JSON or on a
104
- * non-object root with a clear, command-line-visible error.
105
- */
106
113
  function parseJsonOverride(raw) {
107
114
  if (raw === void 0 || raw === "") return {};
108
- let parsed;
109
- try {
110
- parsed = JSON.parse(raw);
111
- } catch (e) {
112
- const msg = e instanceof Error ? e.message : String(e);
113
- throw new Error(`--json: invalid JSON (${msg}). Expected a partial 'connect.*' blob, e.g. --json '{"renown":{"url":"..."}}'.`, { cause: e });
114
- }
115
- if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) throw new Error(`--json: payload must be a JSON object, got ${typeof parsed}.`);
116
- return parsed;
115
+ return validateConnectPatch(raw, "ph connect build");
117
116
  }
118
117
  function setIfDefined(target, key, value) {
119
118
  if (value !== void 0) target[key] = value;
@@ -132,7 +131,7 @@ function wasFlagExplicitlyPassed(longName) {
132
131
  return process.argv.some((arg) => arg === dashed || arg.startsWith(`${dashed}=`));
133
132
  }
134
133
  /**
135
- * Build a `connect.*` partial from the 19 field flags. Only includes paths
134
+ * Build a `connect.*` partial from the 20 field flags. Only includes paths
136
135
  * the user explicitly set (undefined values are excluded).
137
136
  *
138
137
  * Single source of truth for the flag → JSON-path mapping; consumed by both
@@ -143,6 +142,7 @@ function buildConnectFlagPatch(args) {
143
142
  const app = {};
144
143
  setIfDefined(app, "basePath", args.basePath);
145
144
  setIfDefined(app, "logLevel", args.logLevel);
145
+ setIfDefined(app, "workflowsEnabled", args.workflows);
146
146
  if (Object.keys(app).length > 0) out.app = app;
147
147
  const renown = {};
148
148
  setIfDefined(renown, "url", args.renownUrl);
@@ -156,8 +156,8 @@ function buildConnectFlagPatch(args) {
156
156
  if (Object.keys(packages).length > 0) out.packages = packages;
157
157
  const branding = {};
158
158
  setIfDefined(branding, "appName", args.appName);
159
- if (args.homeBackground !== void 0) branding.homeBackground = args.homeBackground === "" ? null : args.homeBackground;
160
159
  if (Object.keys(branding).length > 0) out.branding = branding;
160
+ if (args.homeBackground !== void 0) out.home = { background: args.homeBackground === "" ? null : args.homeBackground };
161
161
  const sentry = {};
162
162
  if (args.sentryDsn !== void 0) sentry.dsn = args.sentryDsn === "" ? null : args.sentryDsn;
163
163
  setIfDefined(sentry, "env", args.sentryEnv);
@@ -210,6 +210,7 @@ function buildCliConnectOverride(args) {
210
210
  renownSwitchboardUrl: args.renownSwitchboardUrl,
211
211
  allowAddDrive: args.allowAddDrive,
212
212
  externalPackages: args.externalPackages,
213
+ workflows: args.workflows,
213
214
  remoteDrivesEnabled: args.remoteDrivesEnabled,
214
215
  remoteDrivesAllowAdd: args.remoteDrivesAllowAdd,
215
216
  remoteDrivesAllowDelete: args.remoteDrivesAllowDelete,
@@ -258,11 +259,15 @@ function buildCliConnectOverride(args) {
258
259
  * `callerOverride` is supplied by wrappers around studio (notably `ph vetra`,
259
260
  * which sets default drives + preserveStrategy directly). The flag override
260
261
  * deep-merges on top of it: caller choices apply for every flag the user
261
- * didn't type, but an explicitly passed flag (e.g. `--default-drives-url`)
262
- * always wins.
262
+ * didn't type, and an explicitly passed flag wins for its own field —
263
+ * except `drives.defaultDrives`, which merges additively: a flag's drives
264
+ * are appended to the caller's list (de-duplicated by drive identity) rather
265
+ * than replacing it, so vetra's own drives stay in Connect's default set.
266
+ * Without a caller override (plain `ph connect studio`) only the flag can
267
+ * carry defaultDrives, so that command's behavior is unchanged.
263
268
  */
264
269
  function buildStudioConnectOverride(args, callerOverride) {
265
- return [
270
+ const layers = [
266
271
  callerOverride,
267
272
  buildConnectFlagPatch({
268
273
  basePath: wasFlagExplicitlyPassed("base") ? args.connectBasePath : void 0,
@@ -272,10 +277,17 @@ function buildStudioConnectOverride(args, callerOverride) {
272
277
  renownNamespace: args.renownNamespace
273
278
  }),
274
279
  { app: { studioMode: true } }
275
- ].filter((o) => o !== void 0 && Object.keys(o).length > 0).reduce((acc, o) => deepMerge(acc, o), {});
280
+ ].filter((o) => o !== void 0 && Object.keys(o).length > 0);
281
+ const merged = layers.reduce((acc, o) => deepMerge(acc, o), {});
282
+ const driveGroups = layers.map((l) => l.drives?.defaultDrives).filter((d) => Array.isArray(d) && d.length > 0);
283
+ if (driveGroups.length > 1) merged.drives = {
284
+ ...merged.drives,
285
+ defaultDrives: mergeDefaultDrives(...driveGroups)
286
+ };
287
+ return merged;
276
288
  }
277
289
  //#endregion
278
290
  export { parseDefaultDrivesUrl as a, validateConnectKeyValue as c, wasFlagExplicitlyPassed as i, validateConnectPatch as l, buildConnectFlagPatch as n, normalizeKey as o, buildStudioConnectOverride as r, parseCliValue as s, buildCliConnectOverride as t };
279
291
 
280
- //# sourceMappingURL=cli-connect-override-D3hh4aH_.mjs.map
281
- //# debugId=1cfb2ec9-21ac-545a-a4fa-c392fd478bc4
292
+ //# sourceMappingURL=cli-connect-override-DW7OYAGx.mjs.map
293
+ //# debugId=9e90198b-acf2-58dd-bc1d-71082e0cc0e1