@powerhousedao/ph-cli 6.0.0-dev.25 → 6.0.0-dev.250

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