@powerhousedao/ph-cli 6.0.0-dev.24 → 6.0.0-dev.240

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