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

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-Ckoqw_XU.mjs +231 -0
  23. package/dist/connect-preview-Ckoqw_XU.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-DqR8BcoO.mjs +31 -0
  52. package/dist/generate-piece-action-DqR8BcoO.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-CJulKHJ0.mjs +11 -0
  60. package/dist/get-version-CJulKHJ0.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-Cz9CubZa.mjs +262 -0
  70. package/dist/mcp-Cz9CubZa.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-C4gwBRyw.mjs +4 -0
  81. package/dist/ph-cli-commands-DFmTGL-H.mjs +1610 -0
  82. package/dist/ph-cli-commands-DFmTGL-H.mjs.map +1 -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 +550 -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
package/dist/cli.mjs CHANGED
@@ -1,1189 +1,32 @@
1
1
  #!/usr/bin/env node
2
2
 
3
- !function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="ab6e0f84-63f5-57ba-a18e-7091ccbf13c6")}catch(e){}}();
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]="83ce31d0-0645-5039-b36b-b7427b013283")}catch(e){}}();
4
+ import { t as getVersion } from "./get-version-CJulKHJ0.mjs";
5
+ import { n as phCliCommands } from "./ph-cli-commands-DFmTGL-H.mjs";
6
+ import { t as isUniformRunnersEnabled } from "./feature-flags-xwqcHEWC.mjs";
4
7
  import { initCliTelemetry } from "@powerhousedao/shared/clis/telemetry";
5
8
  import { assertNodeVersion } from "@powerhousedao/shared/clis/utils";
6
- import { boolean, command, flag, multioption, oneOf, option, optional, run, string, subcommands } from "cmd-ts";
7
- import { AGENTS, accessTokenArgs, buildArgs, connectBuildArgs, connectConfigArgs, connectPreviewArgs, connectStudioArgs, debugArgs, initArgs, inspectArgs, installArgs, listArgs, loginArgs, migrateArgs, phCliHelpCommands, publishArgs, registryLoginArgs, switchboardArgs, uninstallArgs, unpublishArgs, vetraArgs } from "@powerhousedao/shared/clis/args";
8
- import { DEFAULT_EXPIRY_SECONDS } from "@powerhousedao/shared/clis/constants";
9
- import { Directory, File } from "cmd-ts/dist/cjs/batteries/fs.js";
10
- import path from "path";
11
- import { PROCESSOR_APPS } from "@powerhousedao/shared/processors";
12
- import { execSync } from "child_process";
13
- import { execSync as execSync$1 } from "node:child_process";
14
- import { createInterface } from "node:readline/promises";
9
+ import { run, subcommands } from "cmd-ts";
10
+ import { phCliHelpCommands } from "@powerhousedao/shared/clis/args";
15
11
  import { bold, yellow } from "colorette";
16
- //#region src/get-version.ts
17
- function getVersion() {
18
- return "6.2.3-dev.8";
19
- }
20
- //#endregion
21
12
  //#region src/utils/constants.ts
22
13
  const PH_CLI_DESCRIPTION = "The Powerhouse CLI (ph-cli) is a command-line interface tool that provides essential commands for managing Powerhouse projects. The tool and it's commands are fundamental for creating, building, and running Document Models as a builder in studio mode.";
14
+ //#endregion
15
+ //#region src/commands/ph-cli-help.ts
16
+ const version$1 = getVersion();
23
17
  const phCliHelp = subcommands({
24
18
  name: "ph-cli",
25
19
  description: PH_CLI_DESCRIPTION,
26
- version: getVersion(),
20
+ version: version$1,
27
21
  cmds: phCliHelpCommands
28
22
  });
29
23
  //#endregion
30
- //#region src/commands/access-token.ts
31
- const accessToken = command({
32
- name: "access-token",
33
- description: `
34
- The access-token command generates a bearer token for API authentication. This token
35
- can be used to authenticate requests to Powerhouse APIs like reactor-api (Switchboard).
36
-
37
- This command:
38
- 1. Uses your CLI's cryptographic identity (DID) to sign a verifiable credential
39
- 2. Creates a JWT bearer token with configurable expiration
40
- 3. Outputs the token to stdout (info to stderr) for easy piping
41
-
42
- Prerequisites:
43
- You must have a cryptographic identity. Run 'ph login' first to:
44
- - Generate a keypair (stored in .ph/.keypair.json)
45
- - Optionally link your Ethereum address (stored in .ph/.renown.json)
46
-
47
- Token Details:
48
- The generated token is a JWT (JSON Web Token) containing:
49
- - Issuer (iss): Your CLI's DID (did:key:...)
50
- - Subject (sub): Your CLI's DID
51
- - Credential Subject: Chain ID, network ID, and address (if authenticated)
52
- - Expiration (exp): Based on --expiry option
53
- - Audience (aud): If --audience is specified
54
-
55
- Output:
56
- - Token information (DID, address, expiry) is printed to stderr
57
- - The token itself is printed to stdout for easy piping/copying
58
-
59
- This allows you to use the command in scripts:
60
- TOKEN=$(ph access-token)
61
- curl -H "Authorization: Bearer $TOKEN" http://localhost:4001/graphql
62
-
63
- Usage with APIs:
64
- Generate token and use with curl
65
- TOKEN=$(ph access-token --expiry 1d)
66
- curl -X POST http://localhost:4001/graphql \\
67
- -H "Content-Type: application/json" \\
68
- -H "Authorization: Bearer $TOKEN" \\
69
- -d '{"query": "{ drives { id name } }"}'
70
-
71
- Export as environment variable
72
- export PH_ACCESS_TOKEN=$(ph access-token)
73
-
74
- Notes:
75
- - Tokens are self-signed using your CLI's private key
76
- - No network request is made; tokens are generated locally
77
- - The recipient API must trust your CLI's DID to accept the token
78
- - For reactor-api, ensure AUTH_ENABLED=true to require authentication
79
- `,
80
- args: accessTokenArgs,
81
- handler: async (args) => {
82
- if (args.debug) console.log(args);
83
- const { generateAccessToken, parseExpiry, formatExpiry } = await import("@renown/sdk/node");
84
- const { getRenown } = await import("./auth-BNkN6kS9.mjs");
85
- const renown = await getRenown();
86
- let expiresIn = DEFAULT_EXPIRY_SECONDS;
87
- if (args.expiry) expiresIn = parseExpiry(args.expiry);
88
- const result = await generateAccessToken(renown, {
89
- expiresIn,
90
- aud: args.audience
91
- });
92
- console.error(`CLI DID: ${result.did}`);
93
- console.error(`ETH Address: ${result.address}`);
94
- console.error(`Token expires in: ${formatExpiry(expiresIn)}`);
95
- console.error("");
96
- console.log(result.token);
97
- process.exit(0);
98
- }
99
- });
100
- //#endregion
101
- //#region src/commands/build.ts
102
- const build$1 = command({
103
- name: "build",
104
- args: buildArgs,
105
- handler: async (args) => {
106
- if (args.debug) console.log(args);
107
- try {
108
- const { runBuild } = await import("./build-C-A5-ipO.mjs");
109
- await runBuild(args);
110
- } catch (error) {
111
- console.error(error);
112
- process.exit(1);
113
- }
114
- }
115
- });
116
- const connect = subcommands({
117
- name: "connect",
118
- description: `Powerhouse Connect commands. Use with \`studio\`, \`build\`, \`preview\`, or \`config\`. Defaults to \`studio\` if not specified.`,
119
- cmds: {
120
- studio: command({
121
- name: "studio",
122
- description: `The studio command starts the Connect Studio, a development environment for building
123
- and testing Powerhouse applications. It provides a visual interface for working with
124
- your project.
125
-
126
- This command:
127
- 1. Starts a local Connect Studio server
128
- 2. Provides a web interface for development
129
- 3. Allows you to interact with your project components
130
- 4. Supports various configuration options for customization
131
- `,
132
- args: connectStudioArgs,
133
- handler: async (args) => {
134
- if (args.debug) console.log(args);
135
- const { runConnectStudio } = await import("./connect-studio-BIQzyq5B.mjs");
136
- await runConnectStudio(args);
137
- }
138
- }),
139
- build: command({
140
- name: "build",
141
- description: `The Connect build command creates a production build with the project's local and
142
- external packages included.
143
-
144
- Runtime-config overrides (all combinable — last wins on collision):
145
- ph connect build Build with the current source config.
146
- ph connect build <key> <value> Build with a positional override applied (e.g. ph connect build connect.renown.url https://renown.staging).
147
- ph connect build --<field> <value> Build with a per-field flag override (e.g. --renown-url https://renown.staging).
148
- ph connect build --json '{"…":"…"}' Build with a bulk override.
149
-
150
- Build has no read mode; passing only <key> without <value> errors out (use \`ph connect config <key>\` to read).
151
- `,
152
- args: connectBuildArgs,
153
- handler: async (args) => {
154
- if (args.debug) console.log(args);
155
- const { runConnectBuild } = await import("./connect-build-WL4axo4z.mjs");
156
- await runConnectBuild(args);
157
- process.exit(0);
158
- }
159
- }),
160
- preview: command({
161
- name: "preview",
162
- description: `The Connect preview command previews a built Connect project.
163
- NOTE: You must run \`ph connect build\` first
164
- `,
165
- args: connectPreviewArgs,
166
- handler: async (args) => {
167
- if (args.debug) console.log(args);
168
- const { runConnectPreview } = await import("./connect-preview-D7ypzFDc.mjs");
169
- await runConnectPreview(args);
170
- }
171
- }),
172
- config: command({
173
- name: "config",
174
- description: `Read or update Connect's runtime configuration (powerhouse.config.json).
175
-
176
- Modes (mutually exclusive — positional, --get, --json, and field flags cannot be combined):
177
- ph connect config List the effective connect.* block (defaults < source).
178
- ph connect config <key> Get the value at the dotted path (e.g. ph connect config connect.renown.url).
179
- ph connect config --get <dotted.path> Same as positional <key> (kept for backward compat).
180
- ph connect config <key> <value> Set a single field and dual-write to source + dist (positional).
181
- ph connect config --<field> <value> Set a single field via per-field flag (e.g. --renown-url https://renown.id).
182
- ph connect config --json '{"…":"…"}' Bulk-set multiple fields and dual-write.
183
-
184
- Writes go to:
185
- - <project>/powerhouse.config.json (source — picked up by the next build)
186
- - <dist-dir>/powerhouse.config.json (if it exists — the currently-served SPA picks it up on refresh)
187
- `,
188
- args: connectConfigArgs,
189
- handler: async (args) => {
190
- const { runConnectConfig } = await import("./connect-config-BWGiW3IB.mjs");
191
- await runConnectConfig(args);
192
- }
193
- })
194
- }
195
- });
196
- //#endregion
197
- //#region src/commands/generate-all.ts
198
- const generateAllCmd = command({
199
- name: "all",
200
- description: "Re-generate all modules in the current project",
201
- args: { extract: flag({
202
- long: "extract",
203
- short: "x",
204
- description: "Instead of generating code, write a spec for every module into specs/ (one-shot migration to documents-as-source-of-truth)"
205
- }) },
206
- handler: async (args) => {
207
- const { startGenerateAll } = await import("./generate-all-DrT4ZxHX.mjs");
208
- await startGenerateAll(args, process.cwd());
209
- process.exit(0);
210
- }
211
- });
212
- //#endregion
213
- //#region src/utils/comma-separated.ts
214
- /** Splits comma-separated values so `-t "a,b"` means the same as `-t a -t b`
215
- * instead of yielding the single value `"a,b"`, which matches nothing. */
216
- function splitCommaSeparated(values) {
217
- return values.flatMap((value) => value.split(",")).map((value) => value.trim()).filter((value) => value.length > 0);
218
- }
219
- /** `multioption` type accepting repeated and/or comma-separated values. */
220
- const CommaSeparatedStrings = { from: (values) => Promise.resolve(splitCommaSeparated(values)) };
221
- //#endregion
222
- //#region src/commands/generate-app.ts
223
- const generateAppCmd = command({
224
- name: "app",
225
- description: "Generate a drive app",
226
- args: {
227
- name: option({
228
- type: optional(string),
229
- long: "name",
230
- short: "n",
231
- description: "The name of the drive app to generate"
232
- }),
233
- allowedDocumentTypes: multioption({
234
- type: optional(CommaSeparatedStrings),
235
- long: "document-types",
236
- short: "t",
237
- description: "The document types allowed by the new app (repeatable or comma-separated)"
238
- }),
239
- document: option({
240
- type: optional(File),
241
- long: "document",
242
- short: "d",
243
- description: "Path to a powerhouse/app spec file (.phd or .json) to drive codegen"
244
- }),
245
- dir: option({
246
- type: optional(Directory),
247
- long: "dir",
248
- description: "Name of the directory of an existing app to re-generate"
249
- }),
250
- disableDragAndDrop: flag({
251
- type: boolean,
252
- long: "disable-drag-and-drop",
253
- description: "Do not allow drag and drop in this drive app.",
254
- defaultValue: () => false,
255
- defaultValueIsSerializable: true
256
- }),
257
- all: flag({
258
- long: "all",
259
- short: "a",
260
- description: "Re-generate all existing apps in the current project"
261
- }),
262
- extract: flag({
263
- long: "extract",
264
- short: "x",
265
- description: "Write a powerhouse/app spec for each existing drive app into specs/apps/"
266
- }),
267
- ...debugArgs
268
- },
269
- handler: async (args) => {
270
- const { startGenerateApp } = await import("./generate-app-DNNqA-H3.mjs");
271
- await startGenerateApp(args, process.cwd());
272
- process.exit(0);
273
- }
274
- });
275
- //#endregion
276
- //#region src/commands/generate-document-model.ts
277
- const generateDocumentModelCmd = command({
278
- name: "document-model",
279
- aliases: ["doc"],
280
- description: "Generate a document model",
281
- args: {
282
- document: option({
283
- type: optional(File),
284
- long: "document",
285
- short: "d",
286
- description: "Path to a document model spec (.phd or .json) to generate from"
287
- }),
288
- dir: option({
289
- type: optional(Directory),
290
- long: "dir",
291
- description: "Name of the directory of an existing document model to re-generate"
292
- }),
293
- all: flag({
294
- long: "all",
295
- short: "a",
296
- description: "Re-generate all existing document models in the current project"
297
- }),
298
- extract: flag({
299
- long: "extract",
300
- short: "x",
301
- description: "Write a powerhouse/document-model spec for each existing document model into specs/document-models/"
302
- }),
303
- ...debugArgs
304
- },
305
- handler: async (args) => {
306
- const { startGenerateDocumentModel } = await import("./generate-document-model-BJXyODfm.mjs");
307
- await startGenerateDocumentModel(args, process.cwd());
308
- process.exit(0);
309
- }
310
- });
311
- //#endregion
312
- //#region src/commands/generate-editor.ts
313
- const generateEditorCmd = command({
314
- name: "editor",
315
- description: "Generate a document editor",
316
- args: {
317
- name: option({
318
- type: optional(string),
319
- long: "name",
320
- short: "n",
321
- description: "The name of the document editor to generate"
322
- }),
323
- documentType: option({
324
- type: optional(string),
325
- long: "document-type",
326
- short: "t",
327
- description: "The document type for the new editor"
328
- }),
329
- document: option({
330
- type: optional(File),
331
- long: "document",
332
- short: "d",
333
- description: "Path to a powerhouse/document-editor spec file (.phd or .json) to drive codegen"
334
- }),
335
- dir: option({
336
- type: optional(Directory),
337
- long: "dir",
338
- description: "Name of the directory of an existing editor to re-generate"
339
- }),
340
- all: flag({
341
- long: "all",
342
- short: "a",
343
- description: "Re-generate all existing editors in the current project"
344
- }),
345
- extract: flag({
346
- long: "extract",
347
- short: "x",
348
- description: "Write a powerhouse/document-editor spec for each existing editor into specs/editors/"
349
- }),
350
- ...debugArgs
351
- },
352
- handler: async (args) => {
353
- const { startGenerateEditor } = await import("./generate-editor-BejvaVVT.mjs");
354
- await startGenerateEditor(args, process.cwd());
355
- process.exit(0);
356
- }
357
- });
358
- //#endregion
359
- //#region src/commands/generate-migration-file.ts
360
- const generateMigrationFileCmd = command({
361
- name: "migration-file",
362
- description: "Generate a migration file",
363
- args: {
364
- migrationFile: option({
365
- type: string,
366
- long: "path",
367
- short: "p",
368
- description: "Path to the migration file"
369
- }),
370
- schemaFile: option({
371
- type: optional(string),
372
- long: "schema-file",
373
- description: "Path to the output file. Defaults to './schema.ts'"
374
- }),
375
- ...debugArgs
376
- },
377
- handler: async ({ migrationFile, schemaFile }) => {
378
- const { generateDBSchema } = await import("@powerhousedao/codegen");
379
- await generateDBSchema({
380
- migrationFile: path.join(process.cwd(), migrationFile),
381
- schemaFile: schemaFile ? path.join(process.cwd(), schemaFile) : void 0
382
- });
383
- process.exit(0);
384
- }
385
- });
386
- const generateProcessorCmd = command({
387
- name: "processor",
388
- description: "Generate a processor",
389
- args: {
390
- name: option({
391
- type: optional(string),
392
- long: "name",
393
- short: "n",
394
- description: "The name of the processor to generate"
395
- }),
396
- type: option({
397
- type: oneOf(["analytics", "relationalDb"]),
398
- long: "type",
399
- description: "The type of processor to generate",
400
- defaultValue: () => "analytics",
401
- defaultValueIsSerializable: true
402
- }),
403
- documentTypes: multioption({
404
- type: CommaSeparatedStrings,
405
- long: "document-types",
406
- short: "t",
407
- description: "The document types the processor will run on (repeatable or comma-separated)",
408
- defaultValue: () => [],
409
- defaultValueIsSerializable: true
410
- }),
411
- apps: multioption({
412
- long: "apps",
413
- type: { from(rawProcessorApps) {
414
- const processorApps = splitCommaSeparated(rawProcessorApps);
415
- if (processorApps.length === 0) throw new Error(`No arguments provided for processor apps. Must be "connect" and/or "switchboard"`);
416
- if (processorApps.length > 2) throw new Error(`Too many arguments provided for processor apps. Must be "connect" and/or "switchboard"`);
417
- const allowed = new Set(PROCESSOR_APPS);
418
- if (!processorApps.every((p) => allowed.has(p))) throw new Error(`Processor apps can only be "connect" and/or "switchboard".`);
419
- return Promise.resolve(processorApps);
420
- } },
421
- description: "Whether the processor will run in switchboard (nodejs), connect (browser), or both",
422
- defaultValue: () => ["switchboard", "connect"],
423
- defaultValueIsSerializable: true
424
- }),
425
- document: option({
426
- type: optional(File),
427
- long: "document",
428
- short: "d",
429
- description: "Path to a powerhouse/processor spec file (.phd or .json) to drive codegen"
430
- }),
431
- dir: option({
432
- type: optional(Directory),
433
- long: "dir",
434
- description: "Name of the directory of an existing processor to re-generate"
435
- }),
436
- all: flag({
437
- long: "all",
438
- short: "a",
439
- description: "Re-generate all existing processors in the current project"
440
- }),
441
- extract: flag({
442
- long: "extract",
443
- short: "x",
444
- description: "Write a powerhouse/processor spec for each existing processor into specs/processors/"
445
- }),
446
- ...debugArgs
447
- },
448
- handler: async (args) => {
449
- const { startGenerateProcessor } = await import("./generate-processor-_WOx-mMe.mjs");
450
- await startGenerateProcessor(args, process.cwd());
451
- process.exit(0);
452
- }
453
- });
454
- //#endregion
455
- //#region src/commands/generate-subgraph.ts
456
- const generateSubgraphCmd = command({
457
- name: "subgraph",
458
- description: "Generate a subgraph",
459
- args: {
460
- name: option({
461
- type: optional(string),
462
- long: "name",
463
- short: "n",
464
- description: "The name of the subgraph to generate"
465
- }),
466
- document: option({
467
- type: optional(File),
468
- long: "document",
469
- short: "d",
470
- description: "Path to a powerhouse/subgraph spec file (.phd or .json) to drive codegen"
471
- }),
472
- dir: option({
473
- type: optional(Directory),
474
- long: "dir",
475
- description: "Name of the directory of an existing subgraph to re-generate"
476
- }),
477
- all: flag({
478
- long: "all",
479
- short: "a",
480
- description: "Re-generate all existing subgraphs in the current project"
481
- }),
482
- extract: flag({
483
- long: "extract",
484
- short: "x",
485
- description: "Write a powerhouse/subgraph spec for each existing subgraph into specs/subgraphs/"
486
- }),
487
- ...debugArgs
488
- },
489
- handler: async (args) => {
490
- const { startGenerateSubgraph } = await import("./generate-subgraph-BsHUstpl.mjs");
491
- await startGenerateSubgraph(args, process.cwd());
492
- process.exit(0);
493
- }
494
- });
495
- //#endregion
496
- //#region src/commands/generate.ts
497
- const generate = subcommands({
498
- name: "generate",
499
- description: `The generate command creates code for Powerhouse modules. It helps you create new code from scratch, or to re-generate existing code in your project.`,
500
- cmds: {
501
- all: generateAllCmd,
502
- "document-model": generateDocumentModelCmd,
503
- editor: generateEditorCmd,
504
- app: generateAppCmd,
505
- processor: generateProcessorCmd,
506
- subgraph: generateSubgraphCmd,
507
- "migration-file": generateMigrationFileCmd
508
- }
509
- });
510
- //#endregion
511
- //#region src/commands/init.ts
512
- const init = command({
513
- name: "init",
514
- description: "Initialize a new project",
515
- args: initArgs,
516
- handler: async (args) => {
517
- if (args.debug) console.log({ args });
518
- const { startInit } = await import("./init-BZP6gvYd.mjs");
519
- await startInit(args);
520
- process.exit(0);
521
- }
522
- });
523
- //#endregion
524
- //#region src/commands/inspect.ts
525
- const inspect = command({
526
- name: "inspect",
527
- description: `
528
- The inspect command examines and provides detailed information about a Powerhouse package.
529
- It helps you understand the structure, dependencies, and configuration of packages in
530
- your project.
531
-
532
- This command:
533
- 1. Analyzes the specified package
534
- 2. Retrieves detailed information about its structure and configuration
535
- 3. Displays package metadata, dependencies, and other relevant information
536
- 4. Helps troubleshoot package-related issues`,
537
- aliases: ["is"],
538
- args: inspectArgs,
539
- handler: async (args) => {
540
- if (args.debug) console.log(args);
541
- const { startInspect } = await import("./inspect-DXjbQEV_.mjs");
542
- startInspect(args);
543
- process.exit(0);
544
- }
545
- });
546
- //#endregion
547
- //#region src/commands/install.ts
548
- const install = command({
549
- name: "install",
550
- aliases: ["add", "i"],
551
- description: `
552
- The install command adds Powerhouse dependencies to your project.
553
-
554
- By default it only registers the package in powerhouse.config.json with
555
- provider "registry" — Connect will load it from the registry CDN at runtime.
556
-
557
- With --local, the package is also installed into node_modules and marked
558
- as provider "local" — it will be bundled into ph connect build so the
559
- preview works without the registry being reachable.
560
-
561
- Resolution order for the registry URL:
562
- --registry flag > PH_REGISTRY_URL env > powerhouse.config.json > default
563
- `,
564
- args: installArgs,
565
- handler: async (args) => {
566
- if (args.debug) console.log(args);
567
- const { getPowerhouseProjectInfo, makeDependenciesWithVersions } = await import("@powerhousedao/shared/clis");
568
- const { projectPath, localProjectPath, globalProjectPath, packageManager, isGlobal } = await getPowerhouseProjectInfo(args);
569
- if (!projectPath) throw new Error(`Could not find project path to install from.`);
570
- const { resolveRegistryUrl } = await import("@powerhousedao/shared/registry");
571
- const registryUrl = resolveRegistryUrl({
572
- registry: args.registry,
573
- projectPath
574
- });
575
- if (args.debug) console.log(">>> registryUrl", registryUrl);
576
- const dependenciesWithVersions = await makeDependenciesWithVersions(args.dependencies, registryUrl);
577
- if (args.debug) {
578
- console.log(">>> parsedDependencies", dependenciesWithVersions);
579
- console.log("\n>>> projectInfo", {
580
- localProjectPath,
581
- globalProjectPath,
582
- packageManager,
583
- isGlobal
584
- });
585
- }
586
- if (args.local) {
587
- if (dependenciesWithVersions.length === 0) throw new Error("--local requires at least one package name (e.g. ph install --local @scope/pkg)");
588
- try {
589
- const specs = dependenciesWithVersions.map((d) => d.version ? `${d.name}@${d.version}` : d.name);
590
- const scopes = /* @__PURE__ */ new Set();
591
- for (const dep of dependenciesWithVersions) if (dep.name.startsWith("@")) {
592
- const scope = dep.name.split("/")[0];
593
- scopes.add(scope);
594
- }
595
- const scopeRegistryArgs = Array.from(scopes).map((scope) => `--${scope}:registry=${registryUrl}`);
596
- const minReleaseAgeArgs = packageManager === "pnpm" ? ["--config.minimum-release-age=0"] : [];
597
- const allowBuildArgs = packageManager === "pnpm" && args.allowBuild.length > 0 ? [`--allow-build=${args.allowBuild.join(",")}`] : [];
598
- const { resolveCommand } = await import("package-manager-detector");
599
- const resolved = resolveCommand(packageManager, "add", [
600
- ...specs,
601
- ...scopeRegistryArgs,
602
- ...minReleaseAgeArgs,
603
- ...allowBuildArgs
604
- ]);
605
- if (!resolved) throw new Error(`Failed to resolve install command for package manager "${packageManager}".`);
606
- const installCommand = `${resolved.command} ${resolved.args.join(" ")}`;
607
- if (scopeRegistryArgs.length > 0) console.log(`Installing dependencies 📦 (routing ${Array.from(scopes).join(", ")} → ${registryUrl})...`);
608
- else console.log("Installing dependencies 📦...");
609
- console.log(`> ${installCommand}`);
610
- execSync(installCommand, {
611
- stdio: "inherit",
612
- cwd: projectPath
613
- });
614
- console.log("Dependency installed successfully 🎉");
615
- } catch (error) {
616
- console.error("❌ Failed to install dependencies");
617
- throw error;
618
- }
619
- }
620
- const { updateConfigFile, updateStylesFile } = await import("./utils-BzwczAW-.mjs");
621
- try {
622
- console.log("⚙️ Updating powerhouse config file...");
623
- updateConfigFile(dependenciesWithVersions, projectPath, "install", args.local ? "local" : "registry", registryUrl, args.registry !== void 0);
624
- console.log("Config file updated successfully 🎉");
625
- } catch (error) {
626
- console.error("❌ Failed to update config file");
627
- throw error;
628
- }
629
- if (args.local) try {
630
- console.log("⚙️ Updating styles.css file...");
631
- updateStylesFile(dependenciesWithVersions, projectPath);
632
- console.log("Styles file updated successfully 🎉");
633
- } catch (error) {
634
- console.error("❌ Failed to update styles file");
635
- throw error;
636
- }
637
- process.exit(0);
638
- }
639
- });
640
- //#endregion
641
- //#region src/commands/list.ts
642
- const list = command({
643
- name: "list",
644
- description: `
645
- The list command displays information about installed Powerhouse packages in your project.
646
- It reads the powerhouse.config.json file and shows the packages that are currently installed.
647
-
648
- This command:
649
- 1. Examines your project configuration
650
- 2. Lists all installed Powerhouse packages
651
- 3. Provides a clear overview of your project's dependencies
652
- 4. Helps you manage and track your Powerhouse components
653
- `,
654
- aliases: ["l"],
655
- args: listArgs,
656
- handler: async (args) => {
657
- if (args.debug) console.log(args);
658
- try {
659
- const { getPowerhouseProjectInfo } = await import("@powerhousedao/shared/clis");
660
- const projectInfo = await getPowerhouseProjectInfo();
661
- const { getConfig } = await import("@powerhousedao/config/node");
662
- const phConfig = getConfig(projectInfo.projectPath + "/powerhouse.config.json");
663
- if (!phConfig.packages || phConfig.packages.length === 0) {
664
- console.log("No packages found in the project");
665
- return;
666
- }
667
- console.log("Installed Packages:\n");
668
- phConfig.packages.forEach((pkg) => {
669
- console.log(pkg.version ? `${pkg.packageName}@${pkg.version}` : pkg.packageName);
670
- });
671
- } catch (_e) {
672
- console.log("No packages found in the project");
673
- }
674
- process.exit(0);
675
- }
676
- });
677
- //#endregion
678
- //#region src/commands/login.ts
679
- const login = command({
680
- name: "login",
681
- description: `
682
- The login command authenticates you with Renown using your Ethereum wallet. This enables
683
- the CLI to act on behalf of your Ethereum identity for authenticated operations.
684
-
685
- This command:
686
- 1. Generates or loads a cryptographic identity (DID) for the CLI
687
- 2. Opens your browser to the Renown authentication page
688
- 3. You authorize the CLI's DID to act on behalf of your Ethereum address
689
- 4. Stores the credentials locally in .ph/.renown.json
690
- `,
691
- args: loginArgs,
692
- handler: async (args) => {
693
- if (args.debug) console.log(args);
694
- const { getRenown } = await import("./auth-BNkN6kS9.mjs");
695
- const renown = await getRenown(args.renownUrl);
696
- if (args.showDid) {
697
- console.log(renown.did);
698
- process.exit(0);
699
- }
700
- if (args.status) {
701
- const { getAuthStatus } = await import("@renown/sdk/node");
702
- const status = getAuthStatus(renown);
703
- if (!status.authenticated || !status.address) {
704
- console.log("Not authenticated with an Ethereum address.");
705
- console.log("Run \"ph login\" to authenticate.");
706
- } else {
707
- console.log("Authenticated");
708
- console.log(` ETH Address: ${status.address}`);
709
- console.log(` User DID: ${status.userDid}`);
710
- console.log(` Chain ID: ${status.chainId}`);
711
- console.log(` CLI DID: ${status.cliDid}`);
712
- console.log(` Authenticated at: ${status.authenticatedAt?.toLocaleString()}`);
713
- console.log(` Renown URL: ${status.baseUrl}`);
714
- }
715
- process.exit(0);
716
- }
717
- if (args.logout) {
718
- await handleLogout();
719
- process.exit(0);
720
- }
721
- const { browserLogin } = await import("@renown/sdk/node");
722
- console.debug("Initializing cryptographic identity...");
723
- console.log(`CLI DID: ${renown.did}`);
724
- try {
725
- const timeoutMs = args.timeout ? args.timeout * 1e3 : void 0;
726
- const result = await browserLogin(renown, {
727
- renownUrl: args.renownUrl,
728
- timeoutMs,
729
- onLoginUrl: (url, sessionId) => {
730
- console.log("Opening browser for authentication...");
731
- console.log(`Session ID: ${sessionId.slice(0, 8)}...`);
732
- console.log(`Login URL: ${url}`);
733
- console.log();
734
- console.log("Waiting for authentication in browser");
735
- console.log(`(timeout in ${(timeoutMs ?? 3e5) / 1e3} seconds)`);
736
- console.log();
737
- console.log("Please connect your wallet and authorize this CLI to act on your behalf.");
738
- console.log();
739
- process.stdout.write("Waiting");
740
- },
741
- onPollTick: () => process.stdout.write("."),
742
- onBrowserOpenFailed: (url) => {
743
- console.error("Failed to open browser automatically.");
744
- console.log(`Please open this URL manually: ${url}`);
745
- }
746
- });
747
- console.log();
748
- console.log();
749
- console.log("Successfully authenticated!");
750
- console.log(` ETH Address: ${result.user.address}`);
751
- console.log(` User DID: ${result.user.did}`);
752
- console.log(` CLI DID: ${result.cliDid}`);
753
- console.log();
754
- console.log("The CLI can now act on behalf of your Ethereum identity.");
755
- } catch (error) {
756
- console.log();
757
- throw error;
758
- }
759
- process.exit(0);
760
- }
761
- });
762
- async function handleLogout() {
763
- const { getRenown } = await import("./auth-BNkN6kS9.mjs");
764
- const renown = await getRenown();
765
- if (!renown.user) {
766
- console.log("Not currently authenticated.");
767
- return;
768
- }
769
- try {
770
- await renown.logout();
771
- console.log("Successfully logged out.");
772
- } catch (error) {
773
- console.error("Failed to clear credentials.");
774
- console.debug(error);
775
- }
776
- }
777
- //#endregion
778
- //#region src/commands/logout.ts
779
- const logout = command({
780
- name: "logout",
781
- description: `
782
- The logout command removes an existing session created with 'ph login'`,
783
- args: {},
784
- handler: async () => {
785
- await handleLogout();
786
- process.exit(0);
787
- }
788
- });
789
- //#endregion
790
- //#region src/commands/migrate.ts
791
- const migrate = command({
792
- name: "migrate",
793
- args: migrateArgs,
794
- description: "Run migrations",
795
- handler: async (args) => {
796
- if (args.debug) console.log(args);
797
- const { startMigrate } = await import("./migrate-jGKfE02L.mjs");
798
- await startMigrate(args);
799
- process.exit(0);
800
- }
801
- });
802
- //#endregion
803
- //#region src/commands/publish.ts
804
- function hasTagFlag(args) {
805
- return args.some((a) => a === "--tag" || a.startsWith("--tag="));
806
- }
807
- function isInteractive() {
808
- return Boolean(process.stdin.isTTY) && !process.env.CI;
809
- }
810
- async function readPrereleaseTag(projectPath) {
811
- try {
812
- const [{ readPackageSync }, { prerelease }] = await Promise.all([import("read-pkg"), import("semver")]);
813
- const pkg = readPackageSync({ cwd: projectPath });
814
- if (!pkg.version) return null;
815
- const parts = prerelease(pkg.version);
816
- if (!parts || parts.length === 0) return null;
817
- const label = String(parts[0]);
818
- if (!/^[a-z][a-z0-9-]*$/i.test(label)) return null;
819
- return {
820
- version: pkg.version,
821
- tag: label
822
- };
823
- } catch {
824
- return null;
825
- }
826
- }
827
- const publish = command({
828
- name: "publish",
829
- description: `
830
- Publish a package to the Powerhouse registry. This is a thin wrapper around npm publish
831
- that automatically sets the registry URL.
832
-
833
- This command:
834
- 1. Resolves the registry URL (--registry flag > PH_REGISTRY_URL env > powerhouse.config.json > default)
835
- 2. Checks authentication with the registry via npm whoami
836
- 3. Forwards all additional arguments to npm publish
837
- `,
838
- args: publishArgs,
839
- handler: async (args) => {
840
- if (args.debug) console.log(args);
841
- const { getPowerhouseProjectInfo } = await import("@powerhousedao/shared/clis");
842
- const { projectPath } = await getPowerhouseProjectInfo();
843
- if (!projectPath) throw new Error("Could not find project path.");
844
- const { checkNpmAuth, npmPublish, resolveRegistryUrl } = await import("@powerhousedao/shared/registry");
845
- const { mintRegistryAuthToken } = await import("./registry-auth-DxEWCJu2.mjs");
846
- const registryUrl = resolveRegistryUrl({
847
- registry: args.registry,
848
- projectPath
849
- });
850
- if (args.debug) console.log(">>> registryUrl", registryUrl);
851
- let authToken;
852
- try {
853
- authToken = await mintRegistryAuthToken(registryUrl, 300);
854
- if (args.debug) console.error(`>>> minted renown token for ${registryUrl} (5m TTL)`);
855
- } catch (err) {
856
- if (args.debug) console.error(`>>> renown token mint skipped: ${err.message}`);
857
- try {
858
- await checkNpmAuth(registryUrl);
859
- } catch {
860
- console.error(`Not authenticated with registry: ${registryUrl}`);
861
- console.error(`Run: ph login (recommended) or npm adduser --registry ${registryUrl}`);
862
- process.exit(1);
863
- }
864
- }
865
- let forwardedArgs = args.forwardedArgs;
866
- if (!hasTagFlag(forwardedArgs)) {
867
- const prereleaseInfo = await readPrereleaseTag(projectPath);
868
- if (prereleaseInfo) {
869
- const { version, tag } = prereleaseInfo;
870
- if (!isInteractive()) {
871
- console.error(`Detected prerelease version ${version}. npm requires an explicit dist-tag for prerelease publishes.`);
872
- console.error(`Re-run with --tag <label> (e.g. --tag ${tag}) to proceed.`);
873
- process.exit(1);
874
- }
875
- const enquirer = await import("enquirer");
876
- let confirmed;
877
- try {
878
- confirmed = (await enquirer.default.prompt({
879
- type: "confirm",
880
- name: "confirmed",
881
- message: `Detected prerelease version ${version}. Publish with --tag ${tag}?`,
882
- initial: true
883
- })).confirmed;
884
- } catch {
885
- confirmed = false;
886
- }
887
- if (!confirmed) {
888
- console.error(`Aborted. To publish manually: npm publish --registry ${registryUrl} --tag <label>`);
889
- process.exit(1);
890
- }
891
- forwardedArgs = [
892
- "--tag",
893
- tag,
894
- ...forwardedArgs
895
- ];
896
- }
897
- }
898
- if (args.debug) console.log(">>> command", `npm publish --registry ${registryUrl} ${forwardedArgs.join(" ")}`);
899
- console.log(`Publishing to ${registryUrl}...`);
900
- const result = await npmPublish({
901
- registryUrl,
902
- cwd: projectPath,
903
- args: forwardedArgs,
904
- authToken
905
- });
906
- if (result.stdout) console.log(result.stdout);
907
- process.exit(0);
908
- }
909
- });
910
- //#endregion
911
- //#region src/commands/registry-login.ts
912
- const registryLogin = command({
913
- name: "registry-login",
914
- description: `
915
- Log in to a Powerhouse registry using your Renown identity. Mints a longer-lived
916
- bearer token (default 30 days) bound to the registry's audience and writes the
917
- token into ~/.npmrc so raw 'npm publish' / 'npm install' work without further
918
- setup.
919
-
920
- Prerequisites:
921
- Run 'ph login' first to establish a Renown identity.
922
-
923
- Usage:
924
- ph registry-login # uses powerhouse.config.json / PH_REGISTRY_URL
925
- ph registry-login --registry https://registry.vetra.io
926
- ph registry-login --expiry 7d
927
- `,
928
- args: registryLoginArgs,
929
- handler: async (args) => {
930
- if (args.debug) console.log(args);
931
- const { getPowerhouseProjectInfo } = await import("@powerhousedao/shared/clis");
932
- const projectPath = (await getPowerhouseProjectInfo().catch(() => null))?.projectPath ?? process.cwd();
933
- const [{ resolveRegistryUrl, writeRegistryAuthToken }, { mintRegistryAuthToken }, { parseExpiry, formatExpiry }] = await Promise.all([
934
- import("@powerhousedao/shared/registry"),
935
- import("./registry-auth-DxEWCJu2.mjs"),
936
- import("@renown/sdk/node")
937
- ]);
938
- const registryUrl = resolveRegistryUrl({
939
- registry: args.registry,
940
- projectPath
941
- });
942
- const expiresIn = parseExpiry(args.expiry);
943
- const npmrcPath = await writeRegistryAuthToken(registryUrl, await mintRegistryAuthToken(registryUrl, expiresIn));
944
- console.log(`Logged in to ${registryUrl}`);
945
- console.log(` Token expires in: ${formatExpiry(expiresIn)}`);
946
- console.log(` Wrote: ${npmrcPath}`);
947
- process.exit(0);
948
- }
949
- });
950
- //#endregion
951
- //#region src/commands/switchboard.ts
952
- const switchboard = command({
953
- name: "switchboard",
954
- aliases: ["reactor"],
955
- description: `
956
- The switchboard command starts a local Switchboard instance, which acts as the document
957
- processing engine for Powerhouse projects. It provides the infrastructure for document
958
- models, processors, and real-time updates.
959
-
960
- This command:
961
- 1. Starts a local switchboard server
962
- 2. Loads document models and processors
963
- 3. Provides an API for document operations
964
- 4. Enables real-time document processing
965
- 5. Can authenticate with remote services using your identity from 'ph login'`,
966
- args: switchboardArgs,
967
- handler: async (args) => {
968
- if (args.debug) console.log(args);
969
- const { basePath, dbPath, migrate, migrateStatus, reset, yes } = args;
970
- if (basePath) process.env.BASE_PATH = basePath;
971
- if (reset) {
972
- const { resetSwitchboardDatabase } = await import("./switchboard-reset-BcQXlcVf.mjs");
973
- await resetSwitchboardDatabase({
974
- dbPath,
975
- yes
976
- });
977
- process.exit(0);
978
- }
979
- if (migrate || migrateStatus) {
980
- const { runSwitchboardMigrations } = await import("./switchboard-migrate-NQ7LHWSi.mjs");
981
- await runSwitchboardMigrations({
982
- dbPath,
983
- statusOnly: migrateStatus
984
- });
985
- process.exit(0);
986
- }
987
- const { startSwitchboard } = await import("./switchboard-iRFugh8I.mjs");
988
- const { defaultDriveUrl, renown } = await startSwitchboard(args);
989
- console.log(" ➜ Switchboard:", defaultDriveUrl);
990
- if (renown) console.log(" ➜ Identity:", renown.did);
991
- }
992
- });
993
- //#endregion
994
- //#region src/commands/uninstall.ts
995
- const uninstall = command({
996
- name: "uninstall",
997
- aliases: ["remove"],
998
- description: `
999
- The uninstall command removes Powerhouse dependencies from your project. It handles the
1000
- removal of packages, updates configuration files, and ensures proper cleanup.
1001
-
1002
- This command:
1003
- 1. Uninstalls specified Powerhouse dependencies using your package manager
1004
- 2. Updates powerhouse.config.json to remove the dependencies
1005
- 3. Supports various uninstallation options and configurations
1006
- 4. Works with ${AGENTS.join(", ")} package managers
1007
- `,
1008
- args: uninstallArgs,
1009
- handler: async (args) => {
1010
- if (args.debug) console.log(args);
1011
- const { getPowerhouseProjectInfo, getPowerhouseProjectUninstallCommand, makeDependenciesWithVersions } = await import("@powerhousedao/shared/clis");
1012
- const { projectPath, localProjectPath, globalProjectPath, packageManager, isGlobal } = await getPowerhouseProjectInfo(args);
1013
- if (!projectPath) throw new Error(`Could not find project path to uninstall from`);
1014
- const dependenciesWithVersions = await makeDependenciesWithVersions(args.dependencies);
1015
- if (args.debug) console.log(">>> parsedDependencies", dependenciesWithVersions);
1016
- if (args.debug) console.log("\n>>> projectInfo", {
1017
- localProjectPath,
1018
- globalProjectPath,
1019
- packageManager,
1020
- isGlobal
1021
- });
1022
- try {
1023
- console.log("Uninstalling dependencies 📦 ...");
1024
- execSync$1(await getPowerhouseProjectUninstallCommand(packageManager, args.dependencies), {
1025
- stdio: "inherit",
1026
- cwd: projectPath
1027
- });
1028
- console.log("Dependency uninstalled successfully 🎉");
1029
- } catch (error) {
1030
- console.error("❌ Failed to uninstall dependencies");
1031
- throw error;
1032
- }
1033
- const { removeStylesImports, updateConfigFile } = await import("./utils-BzwczAW-.mjs");
1034
- try {
1035
- console.log("⚙️ Updating powerhouse config file...");
1036
- updateConfigFile(dependenciesWithVersions, projectPath, "uninstall");
1037
- console.log("Config file updated successfully 🎉");
1038
- } catch (error) {
1039
- console.error("❌ Failed to update config file");
1040
- throw error;
1041
- }
1042
- try {
1043
- console.log("⚙️ Updating styles.css file...");
1044
- removeStylesImports(dependenciesWithVersions, projectPath);
1045
- console.log("Styles file updated successfully 🎉");
1046
- } catch (error) {
1047
- console.error("❌ Failed to update styles file");
1048
- throw error;
1049
- }
1050
- process.exit(0);
1051
- }
1052
- });
1053
- //#endregion
1054
- //#region src/commands/unpublish.ts
1055
- const unpublish = command({
1056
- name: "unpublish",
1057
- description: `
1058
- Unpublish a package from the Powerhouse registry. This is a thin wrapper around
1059
- npm unpublish that automatically targets the Powerhouse registry and never
1060
- reaches npmjs.org.
1061
-
1062
- Forms:
1063
- ph unpublish # unpublish <name>@<version> from cwd's package.json
1064
- ph unpublish <name> # unpublish the whole package (all versions)
1065
- ph unpublish <name>@<version> # unpublish a single version
1066
-
1067
- Flags:
1068
- --registry <url> # override registry URL
1069
- --yes, -y # skip the confirmation prompt
1070
- `,
1071
- args: unpublishArgs,
1072
- handler: async (args) => {
1073
- if (args.debug) console.log(args);
1074
- const { getPowerhouseProjectInfo } = await import("@powerhousedao/shared/clis");
1075
- const { projectPath } = await getPowerhouseProjectInfo();
1076
- if (!projectPath) throw new Error("Could not find project path.");
1077
- const { checkNpmAuth, npmUnpublish, resolveRegistryUrl } = await import("@powerhousedao/shared/registry");
1078
- const registryUrl = resolveRegistryUrl({
1079
- registry: args.registry,
1080
- projectPath
1081
- });
1082
- const spec = await resolveSpec(args.spec, projectPath);
1083
- if (!spec) {
1084
- console.error("No package spec provided and could not read name/version from package.json.");
1085
- process.exit(1);
1086
- }
1087
- if (args.debug) {
1088
- console.log(">>> registryUrl", registryUrl);
1089
- console.log(">>> spec", spec);
1090
- }
1091
- try {
1092
- await checkNpmAuth(registryUrl);
1093
- } catch {
1094
- console.error(`Not authenticated with registry: ${registryUrl}`);
1095
- console.error(`Run: npm adduser --registry ${registryUrl}`);
1096
- process.exit(1);
1097
- }
1098
- if (!args.yes) {
1099
- if (!await confirm(`Unpublish ${spec} from ${registryUrl}? [y/N] `)) {
1100
- console.log("Aborted.");
1101
- process.exit(0);
1102
- }
1103
- }
1104
- if (args.debug) console.log(">>> command", `npm unpublish ${spec} --registry ${registryUrl} --force ${args.forwardedArgs.join(" ")}`);
1105
- console.log(`Unpublishing ${spec} from ${registryUrl}...`);
1106
- try {
1107
- const result = await npmUnpublish({
1108
- registryUrl,
1109
- cwd: projectPath,
1110
- spec,
1111
- args: args.forwardedArgs
1112
- });
1113
- if (result.stdout) console.log(result.stdout);
1114
- process.exit(0);
1115
- } catch (err) {
1116
- console.error(err instanceof Error ? err.message : String(err));
1117
- process.exit(1);
1118
- }
1119
- }
1120
- });
1121
- async function resolveSpec(explicit, projectPath) {
1122
- if (explicit) return explicit;
1123
- try {
1124
- const { readPackageSync } = await import("read-pkg");
1125
- const pkg = readPackageSync({ cwd: projectPath });
1126
- if (!pkg.name) return null;
1127
- return pkg.version ? `${pkg.name}@${pkg.version}` : pkg.name;
1128
- } catch {
1129
- return null;
1130
- }
1131
- }
1132
- async function confirm(prompt) {
1133
- const rl = createInterface({
1134
- input: process.stdin,
1135
- output: process.stdout
1136
- });
1137
- try {
1138
- const answer = await rl.question(prompt);
1139
- return /^y(es)?$/i.test(answer.trim());
1140
- } finally {
1141
- rl.close();
1142
- }
1143
- }
1144
- //#endregion
1145
- //#region src/commands/ph-cli-commands.ts
1146
- const phCliCommands = {
1147
- init,
1148
- generate,
1149
- vetra: command({
1150
- name: "vetra",
1151
- description: `
1152
- The vetra command sets up a Vetra development environment for working with Vetra projects.
1153
- It starts a Vetra Switchboard and optionally Connect Studio, enabling document collaboration
1154
- and real-time processing with a "Vetra" drive or connection to remote drives.
1155
-
1156
- This command:
1157
- 1. Starts a Vetra Switchboard with a "Vetra" drive for document storage
1158
- 2. Optionally connects to remote drives instead of creating a local drive
1159
- 3. Starts Connect Studio pointing to the Switchboard for user interaction (unless disabled)
1160
- 4. Enables real-time updates, collaboration, and code generation`,
1161
- args: vetraArgs,
1162
- handler: async (args) => {
1163
- if (args.debug) console.log(args);
1164
- const { startVetra } = await import("./vetra-DkF6EJMY.mjs");
1165
- await startVetra(args);
1166
- }
1167
- }),
1168
- connect,
1169
- build: build$1,
1170
- publish,
1171
- unpublish,
1172
- "access-token": accessToken,
1173
- "registry-login": registryLogin,
1174
- inspect,
1175
- list,
1176
- migrate,
1177
- switchboard,
1178
- login,
1179
- logout,
1180
- install,
1181
- uninstall
1182
- };
24
+ //#region src/commands/ph-cli.ts
25
+ const version = getVersion();
1183
26
  const phCli = subcommands({
1184
27
  name: "ph-cli",
1185
28
  description: PH_CLI_DESCRIPTION,
1186
- version: getVersion(),
29
+ version,
1187
30
  cmds: phCliCommands
1188
31
  });
1189
32
  //#endregion
@@ -1231,7 +74,11 @@ function printDbRecoveryHint(err) {
1231
74
  //#endregion
1232
75
  //#region src/cli.ts
1233
76
  let sentryClient = void 0;
1234
- const COMMANDS_WITH_SUBCOMMANDS = new Set(["connect", "vetra"]);
77
+ const COMMANDS_WITH_SUBCOMMANDS = /* @__PURE__ */ new Set([
78
+ "connect",
79
+ "vetra",
80
+ "host"
81
+ ]);
1235
82
  function detectPackageManager() {
1236
83
  const ua = process.env.npm_config_user_agent;
1237
84
  if (!ua) return void 0;
@@ -1243,7 +90,14 @@ async function main() {
1243
90
  cliName: "ph-cli",
1244
91
  release: getVersion()
1245
92
  });
1246
- const args = process.argv.slice(2);
93
+ let args = process.argv.slice(2);
94
+ if (isUniformRunnersEnabled()) {
95
+ const { applyRunSugar } = await import("./run-sugar-CRzZsmVo.mjs");
96
+ const { phCliCommands } = await import("./ph-cli-commands-C4gwBRyw.mjs");
97
+ const sugar = applyRunSugar(args, new Set(Object.keys(phCliCommands)), process.cwd());
98
+ if (sugar.warning) console.warn(sugar.warning);
99
+ args = sugar.args;
100
+ }
1247
101
  const command = args[0];
1248
102
  const subcommand = command && COMMANDS_WITH_SUBCOMMANDS.has(command) && args[1] && !args[1].startsWith("-") ? args[1] : void 0;
1249
103
  sentryClient?.attachInvocationContext({
@@ -1263,12 +117,14 @@ async function main() {
1263
117
  "build",
1264
118
  "preview",
1265
119
  "config"
1266
- ].includes(args[1]) && !isHelp) await run(cli, [
1267
- "connect",
1268
- "studio",
1269
- ...restArgs
1270
- ]);
1271
- else await run(cli, args);
120
+ ].includes(args[1]) && !isHelp) {
121
+ const argsWithDefaultConnectSubCommand = [
122
+ "connect",
123
+ "studio",
124
+ ...restArgs
125
+ ];
126
+ await run(cli, argsWithDefaultConnectSubCommand);
127
+ } else await run(cli, args);
1272
128
  }
1273
129
  await main().catch(async (error) => {
1274
130
  const isDebug = process.argv.slice(2).includes("--debug");
@@ -1284,4 +140,4 @@ await main().catch(async (error) => {
1284
140
  export {};
1285
141
 
1286
142
  //# sourceMappingURL=cli.mjs.map
1287
- //# debugId=ab6e0f84-63f5-57ba-a18e-7091ccbf13c6
143
+ //# debugId=83ce31d0-0645-5039-b36b-b7427b013283