@powerhousedao/ph-cli 6.0.0-dev.18 → 6.0.0-dev.180

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 (291) hide show
  1. package/dist/assign-env-vars-CzHgn5ax.mjs +15 -0
  2. package/dist/assign-env-vars-CzHgn5ax.mjs.map +1 -0
  3. package/dist/auth-wgUd0D0V.mjs +15 -0
  4. package/dist/auth-wgUd0D0V.mjs.map +1 -0
  5. package/dist/build-BflSHYLP.mjs +33 -0
  6. package/dist/build-BflSHYLP.mjs.map +1 -0
  7. package/dist/cli.d.mts +1 -0
  8. package/dist/cli.mjs +654 -0
  9. package/dist/cli.mjs.map +1 -0
  10. package/dist/connect-build-CrnmJlav.mjs +21 -0
  11. package/dist/connect-build-CrnmJlav.mjs.map +1 -0
  12. package/dist/connect-preview-4Xe7Lm1V.mjs +27 -0
  13. package/dist/connect-preview-4Xe7Lm1V.mjs.map +1 -0
  14. package/dist/connect-studio-38_NrT_a.mjs +28 -0
  15. package/dist/connect-studio-38_NrT_a.mjs.map +1 -0
  16. package/dist/connect-studio-DuH6WcoA.mjs +3 -0
  17. package/dist/generate-CMQGYRrW.mjs +2 -0
  18. package/dist/generate-Dq80G8n4.mjs +58 -0
  19. package/dist/generate-Dq80G8n4.mjs.map +1 -0
  20. package/dist/init-BsmDWu9-.mjs +124 -0
  21. package/dist/init-BsmDWu9-.mjs.map +1 -0
  22. package/dist/inspect-Dl8KWl3u.mjs +45 -0
  23. package/dist/inspect-Dl8KWl3u.mjs.map +1 -0
  24. package/dist/migrate-CMNF8puQ.mjs +245 -0
  25. package/dist/migrate-CMNF8puQ.mjs.map +1 -0
  26. package/dist/scripts/generate-commands-docs.ts +2 -8
  27. package/dist/switchboard-Bht39Myv.mjs +2 -0
  28. package/dist/switchboard-DBqOSS0c.mjs +72 -0
  29. package/dist/switchboard-DBqOSS0c.mjs.map +1 -0
  30. package/dist/switchboard-migrate-1lOCPmX0.mjs +50 -0
  31. package/dist/switchboard-migrate-1lOCPmX0.mjs.map +1 -0
  32. package/dist/utils-DbFSkp_Q.mjs +161 -0
  33. package/dist/utils-DbFSkp_Q.mjs.map +1 -0
  34. package/dist/vetra-CuBxTrw7.mjs +360 -0
  35. package/dist/vetra-CuBxTrw7.mjs.map +1 -0
  36. package/package.json +37 -46
  37. package/dist/scripts/generate-commands-docs.d.ts +0 -2
  38. package/dist/scripts/generate-commands-docs.d.ts.map +0 -1
  39. package/dist/scripts/generate-commands-docs.js +0 -47
  40. package/dist/scripts/generate-commands-docs.js.map +0 -1
  41. package/dist/scripts/generate-docs-legacy.d.ts +0 -2
  42. package/dist/scripts/generate-docs-legacy.d.ts.map +0 -1
  43. package/dist/scripts/generate-docs-legacy.js +0 -72
  44. package/dist/scripts/generate-docs-legacy.js.map +0 -1
  45. package/dist/scripts/generate-docs-legacy.ts +0 -84
  46. package/dist/scripts/generate-version.d.ts +0 -2
  47. package/dist/scripts/generate-version.d.ts.map +0 -1
  48. package/dist/scripts/generate-version.js +0 -13
  49. package/dist/scripts/generate-version.js.map +0 -1
  50. package/dist/scripts/generate-version.ts +0 -22
  51. package/dist/src/cli.d.ts +0 -3
  52. package/dist/src/cli.d.ts.map +0 -1
  53. package/dist/src/cli.js +0 -29
  54. package/dist/src/cli.js.map +0 -1
  55. package/dist/src/cli.old.d.ts +0 -3
  56. package/dist/src/cli.old.d.ts.map +0 -1
  57. package/dist/src/cli.old.js +0 -43
  58. package/dist/src/cli.old.js.map +0 -1
  59. package/dist/src/commands/access-token.d.ts +0 -14
  60. package/dist/src/commands/access-token.d.ts.map +0 -1
  61. package/dist/src/commands/access-token.js +0 -142
  62. package/dist/src/commands/access-token.js.map +0 -1
  63. package/dist/src/commands/connect.d.ts +0 -249
  64. package/dist/src/commands/connect.d.ts.map +0 -1
  65. package/dist/src/commands/connect.js +0 -60
  66. package/dist/src/commands/connect.js.map +0 -1
  67. package/dist/src/commands/generate.d.ts +0 -58
  68. package/dist/src/commands/generate.d.ts.map +0 -1
  69. package/dist/src/commands/generate.js +0 -25
  70. package/dist/src/commands/generate.js.map +0 -1
  71. package/dist/src/commands/get-package-manager.d.ts +0 -30
  72. package/dist/src/commands/get-package-manager.d.ts.map +0 -1
  73. package/dist/src/commands/get-package-manager.js +0 -8
  74. package/dist/src/commands/get-package-manager.js.map +0 -1
  75. package/dist/src/commands/index.d.ts +0 -13
  76. package/dist/src/commands/index.d.ts.map +0 -1
  77. package/dist/src/commands/index.js +0 -25
  78. package/dist/src/commands/index.js.map +0 -1
  79. package/dist/src/commands/inspect.d.ts +0 -12
  80. package/dist/src/commands/inspect.d.ts.map +0 -1
  81. package/dist/src/commands/inspect.js +0 -27
  82. package/dist/src/commands/inspect.js.map +0 -1
  83. package/dist/src/commands/install.d.ts +0 -22
  84. package/dist/src/commands/install.d.ts.map +0 -1
  85. package/dist/src/commands/install.js +0 -75
  86. package/dist/src/commands/install.js.map +0 -1
  87. package/dist/src/commands/legacy/access-token.old.d.ts +0 -9
  88. package/dist/src/commands/legacy/access-token.old.d.ts.map +0 -1
  89. package/dist/src/commands/legacy/access-token.old.js +0 -110
  90. package/dist/src/commands/legacy/access-token.old.js.map +0 -1
  91. package/dist/src/commands/legacy/connect.old.d.ts +0 -19
  92. package/dist/src/commands/legacy/connect.old.d.ts.map +0 -1
  93. package/dist/src/commands/legacy/connect.old.js +0 -85
  94. package/dist/src/commands/legacy/connect.old.js.map +0 -1
  95. package/dist/src/commands/legacy/generate.old.d.ts +0 -9
  96. package/dist/src/commands/legacy/generate.old.d.ts.map +0 -1
  97. package/dist/src/commands/legacy/generate.old.js +0 -41
  98. package/dist/src/commands/legacy/generate.old.js.map +0 -1
  99. package/dist/src/commands/legacy/help.old.d.ts +0 -3
  100. package/dist/src/commands/legacy/help.old.d.ts.map +0 -1
  101. package/dist/src/commands/legacy/help.old.js +0 -9
  102. package/dist/src/commands/legacy/help.old.js.map +0 -1
  103. package/dist/src/commands/legacy/inspect.old.d.ts +0 -6
  104. package/dist/src/commands/legacy/inspect.old.d.ts.map +0 -1
  105. package/dist/src/commands/legacy/inspect.old.js +0 -21
  106. package/dist/src/commands/legacy/inspect.old.js.map +0 -1
  107. package/dist/src/commands/legacy/install.old.d.ts +0 -15
  108. package/dist/src/commands/legacy/install.old.d.ts.map +0 -1
  109. package/dist/src/commands/legacy/install.old.js +0 -127
  110. package/dist/src/commands/legacy/install.old.js.map +0 -1
  111. package/dist/src/commands/legacy/login.old.d.ts +0 -12
  112. package/dist/src/commands/legacy/login.old.d.ts.map +0 -1
  113. package/dist/src/commands/legacy/login.old.js +0 -208
  114. package/dist/src/commands/legacy/login.old.js.map +0 -1
  115. package/dist/src/commands/legacy/migrate.old.d.ts +0 -11
  116. package/dist/src/commands/legacy/migrate.old.d.ts.map +0 -1
  117. package/dist/src/commands/legacy/migrate.old.js +0 -15
  118. package/dist/src/commands/legacy/migrate.old.js.map +0 -1
  119. package/dist/src/commands/legacy/service.old.d.ts +0 -5
  120. package/dist/src/commands/legacy/service.old.d.ts.map +0 -1
  121. package/dist/src/commands/legacy/service.old.js +0 -67
  122. package/dist/src/commands/legacy/service.old.js.map +0 -1
  123. package/dist/src/commands/legacy/switchboard.old.d.ts +0 -9
  124. package/dist/src/commands/legacy/switchboard.old.d.ts.map +0 -1
  125. package/dist/src/commands/legacy/switchboard.old.js +0 -78
  126. package/dist/src/commands/legacy/switchboard.old.js.map +0 -1
  127. package/dist/src/commands/legacy/uninstall.old.d.ts +0 -15
  128. package/dist/src/commands/legacy/uninstall.old.d.ts.map +0 -1
  129. package/dist/src/commands/legacy/uninstall.old.js +0 -120
  130. package/dist/src/commands/legacy/uninstall.old.js.map +0 -1
  131. package/dist/src/commands/legacy/vetra.old.d.ts +0 -23
  132. package/dist/src/commands/legacy/vetra.old.d.ts.map +0 -1
  133. package/dist/src/commands/legacy/vetra.old.js +0 -35
  134. package/dist/src/commands/legacy/vetra.old.js.map +0 -1
  135. package/dist/src/commands/list.d.ts +0 -10
  136. package/dist/src/commands/list.d.ts.map +0 -1
  137. package/dist/src/commands/list.js +0 -42
  138. package/dist/src/commands/list.js.map +0 -1
  139. package/dist/src/commands/list.old.d.ts +0 -9
  140. package/dist/src/commands/list.old.d.ts.map +0 -1
  141. package/dist/src/commands/list.old.js +0 -36
  142. package/dist/src/commands/list.old.js.map +0 -1
  143. package/dist/src/commands/login.d.ts +0 -20
  144. package/dist/src/commands/login.d.ts.map +0 -1
  145. package/dist/src/commands/login.js +0 -209
  146. package/dist/src/commands/login.js.map +0 -1
  147. package/dist/src/commands/migrate.d.ts +0 -12
  148. package/dist/src/commands/migrate.d.ts.map +0 -1
  149. package/dist/src/commands/migrate.js +0 -16
  150. package/dist/src/commands/migrate.js.map +0 -1
  151. package/dist/src/commands/ph-cli-commands.d.ts +0 -410
  152. package/dist/src/commands/ph-cli-commands.d.ts.map +0 -1
  153. package/dist/src/commands/ph-cli-commands.js +0 -25
  154. package/dist/src/commands/ph-cli-commands.js.map +0 -1
  155. package/dist/src/commands/ph-cli-help.d.ts +0 -396
  156. package/dist/src/commands/ph-cli-help.d.ts.map +0 -1
  157. package/dist/src/commands/ph-cli-help.js +0 -12
  158. package/dist/src/commands/ph-cli-help.js.map +0 -1
  159. package/dist/src/commands/ph-cli.d.ts +0 -490
  160. package/dist/src/commands/ph-cli.d.ts.map +0 -1
  161. package/dist/src/commands/ph-cli.js +0 -12
  162. package/dist/src/commands/ph-cli.js.map +0 -1
  163. package/dist/src/commands/register-commands.d.ts +0 -5
  164. package/dist/src/commands/register-commands.d.ts.map +0 -1
  165. package/dist/src/commands/register-commands.js +0 -32
  166. package/dist/src/commands/register-commands.js.map +0 -1
  167. package/dist/src/commands/service.d.ts +0 -12
  168. package/dist/src/commands/service.d.ts.map +0 -1
  169. package/dist/src/commands/service.js +0 -79
  170. package/dist/src/commands/service.js.map +0 -1
  171. package/dist/src/commands/switchboard.d.ts +0 -46
  172. package/dist/src/commands/switchboard.d.ts.map +0 -1
  173. package/dist/src/commands/switchboard.js +0 -43
  174. package/dist/src/commands/switchboard.js.map +0 -1
  175. package/dist/src/commands/uninstall.d.ts +0 -22
  176. package/dist/src/commands/uninstall.d.ts.map +0 -1
  177. package/dist/src/commands/uninstall.js +0 -71
  178. package/dist/src/commands/uninstall.js.map +0 -1
  179. package/dist/src/commands/vetra.d.ts +0 -64
  180. package/dist/src/commands/vetra.d.ts.map +0 -1
  181. package/dist/src/commands/vetra.js +0 -24
  182. package/dist/src/commands/vetra.js.map +0 -1
  183. package/dist/src/get-version.d.ts +0 -2
  184. package/dist/src/get-version.d.ts.map +0 -1
  185. package/dist/src/get-version.js +0 -7
  186. package/dist/src/get-version.js.map +0 -1
  187. package/dist/src/help.d.ts +0 -65
  188. package/dist/src/help.d.ts.map +0 -1
  189. package/dist/src/help.js +0 -770
  190. package/dist/src/help.js.map +0 -1
  191. package/dist/src/index.d.ts +0 -4
  192. package/dist/src/index.d.ts.map +0 -1
  193. package/dist/src/index.js +0 -4
  194. package/dist/src/index.js.map +0 -1
  195. package/dist/src/services/auth.d.ts +0 -69
  196. package/dist/src/services/auth.d.ts.map +0 -1
  197. package/dist/src/services/auth.js +0 -171
  198. package/dist/src/services/auth.js.map +0 -1
  199. package/dist/src/services/connect.d.ts +0 -5
  200. package/dist/src/services/connect.d.ts.map +0 -1
  201. package/dist/src/services/connect.js +0 -90
  202. package/dist/src/services/connect.js.map +0 -1
  203. package/dist/src/services/generate.d.ts +0 -3
  204. package/dist/src/services/generate.d.ts.map +0 -1
  205. package/dist/src/services/generate.js +0 -80
  206. package/dist/src/services/generate.js.map +0 -1
  207. package/dist/src/services/inspect.d.ts +0 -3
  208. package/dist/src/services/inspect.d.ts.map +0 -1
  209. package/dist/src/services/inspect.js +0 -50
  210. package/dist/src/services/inspect.js.map +0 -1
  211. package/dist/src/services/legacy/connect.old.d.ts +0 -2
  212. package/dist/src/services/legacy/connect.old.d.ts.map +0 -1
  213. package/dist/src/services/legacy/connect.old.js +0 -2
  214. package/dist/src/services/legacy/connect.old.js.map +0 -1
  215. package/dist/src/services/legacy/generate.old.d.ts +0 -30
  216. package/dist/src/services/legacy/generate.old.d.ts.map +0 -1
  217. package/dist/src/services/legacy/generate.old.js +0 -107
  218. package/dist/src/services/legacy/generate.old.js.map +0 -1
  219. package/dist/src/services/legacy/inspect.old.d.ts +0 -5
  220. package/dist/src/services/legacy/inspect.old.d.ts.map +0 -1
  221. package/dist/src/services/legacy/inspect.old.js +0 -49
  222. package/dist/src/services/legacy/inspect.old.js.map +0 -1
  223. package/dist/src/services/legacy/migrate.old.d.ts +0 -3
  224. package/dist/src/services/legacy/migrate.old.d.ts.map +0 -1
  225. package/dist/src/services/legacy/migrate.old.js +0 -289
  226. package/dist/src/services/legacy/migrate.old.js.map +0 -1
  227. package/dist/src/services/legacy/switchboard.old.d.ts +0 -54
  228. package/dist/src/services/legacy/switchboard.old.d.ts.map +0 -1
  229. package/dist/src/services/legacy/switchboard.old.js +0 -79
  230. package/dist/src/services/legacy/switchboard.old.js.map +0 -1
  231. package/dist/src/services/legacy/vetra.old.d.ts +0 -15
  232. package/dist/src/services/legacy/vetra.old.d.ts.map +0 -1
  233. package/dist/src/services/legacy/vetra.old.js +0 -176
  234. package/dist/src/services/legacy/vetra.old.js.map +0 -1
  235. package/dist/src/services/migrate.d.ts +0 -3
  236. package/dist/src/services/migrate.d.ts.map +0 -1
  237. package/dist/src/services/migrate.js +0 -327
  238. package/dist/src/services/migrate.js.map +0 -1
  239. package/dist/src/services/switchboard-migrate.d.ts +0 -7
  240. package/dist/src/services/switchboard-migrate.d.ts.map +0 -1
  241. package/dist/src/services/switchboard-migrate.js +0 -60
  242. package/dist/src/services/switchboard-migrate.js.map +0 -1
  243. package/dist/src/services/switchboard.d.ts +0 -22
  244. package/dist/src/services/switchboard.d.ts.map +0 -1
  245. package/dist/src/services/switchboard.js +0 -77
  246. package/dist/src/services/switchboard.js.map +0 -1
  247. package/dist/src/services/vetra.d.ts +0 -3
  248. package/dist/src/services/vetra.d.ts.map +0 -1
  249. package/dist/src/services/vetra.js +0 -169
  250. package/dist/src/services/vetra.js.map +0 -1
  251. package/dist/src/types.d.ts +0 -31
  252. package/dist/src/types.d.ts.map +0 -1
  253. package/dist/src/types.js +0 -2
  254. package/dist/src/types.js.map +0 -1
  255. package/dist/src/utils/configure-vetra-github-url.d.ts +0 -12
  256. package/dist/src/utils/configure-vetra-github-url.d.ts.map +0 -1
  257. package/dist/src/utils/configure-vetra-github-url.js +0 -230
  258. package/dist/src/utils/configure-vetra-github-url.js.map +0 -1
  259. package/dist/src/utils/constants.d.ts +0 -2
  260. package/dist/src/utils/constants.d.ts.map +0 -1
  261. package/dist/src/utils/constants.js +0 -2
  262. package/dist/src/utils/constants.js.map +0 -1
  263. package/dist/src/utils/file-system.d.ts +0 -2
  264. package/dist/src/utils/file-system.d.ts.map +0 -1
  265. package/dist/src/utils/file-system.js +0 -15
  266. package/dist/src/utils/file-system.js.map +0 -1
  267. package/dist/src/utils/index.d.ts +0 -3
  268. package/dist/src/utils/index.d.ts.map +0 -1
  269. package/dist/src/utils/index.js +0 -3
  270. package/dist/src/utils/index.js.map +0 -1
  271. package/dist/src/utils/projects.d.ts +0 -19
  272. package/dist/src/utils/projects.d.ts.map +0 -1
  273. package/dist/src/utils/projects.js +0 -93
  274. package/dist/src/utils/projects.js.map +0 -1
  275. package/dist/src/utils.d.ts +0 -112
  276. package/dist/src/utils.d.ts.map +0 -1
  277. package/dist/src/utils.js +0 -261
  278. package/dist/src/utils.js.map +0 -1
  279. package/dist/src/version.d.ts +0 -2
  280. package/dist/src/version.d.ts.map +0 -1
  281. package/dist/src/version.js +0 -3
  282. package/dist/src/version.js.map +0 -1
  283. package/dist/test/utils.test.d.ts +0 -2
  284. package/dist/test/utils.test.d.ts.map +0 -1
  285. package/dist/test/utils.test.js +0 -133
  286. package/dist/test/utils.test.js.map +0 -1
  287. package/dist/tsconfig.tsbuildinfo +0 -1
  288. package/dist/vitest.config.d.ts +0 -3
  289. package/dist/vitest.config.d.ts.map +0 -1
  290. package/dist/vitest.config.js +0 -7
  291. package/dist/vitest.config.js.map +0 -1
package/dist/cli.mjs ADDED
@@ -0,0 +1,654 @@
1
+ #!/usr/bin/env node
2
+ import { t as runBuild } from "./build-BflSHYLP.mjs";
3
+ import { a as updateStylesFile, i as updateConfigFile, r as removeStylesImports } from "./utils-DbFSkp_Q.mjs";
4
+ import { DEFAULT_EXPIRY_SECONDS, accessTokenArgs, assertNodeVersion, buildArgs, connectBuildArgs, connectPreviewArgs, connectStudioArgs, generateArgs, getConfig, getPowerhouseProjectInfo, getPowerhouseProjectInstallCommand, getPowerhouseProjectUninstallCommand, initArgs, inspectArgs, installArgs, listArgs, loginArgs, makeDependenciesWithVersions, migrateArgs, phCliHelpCommands, publishArgs, switchboardArgs, uninstallArgs, vetraArgs } from "@powerhousedao/shared/clis";
5
+ import { command, run, subcommands } from "cmd-ts";
6
+ import { AGENTS } from "package-manager-detector";
7
+ import { DEFAULT_REGISTRY_URL } from "@powerhousedao/config";
8
+ import { execSync } from "child_process";
9
+ import { join } from "path";
10
+ import { getConfig as getConfig$1 } from "@powerhousedao/config/node";
11
+ import { checkNpmAuth, npmPublish, resolveRegistryUrl } from "@powerhousedao/shared/registry";
12
+ //#region src/get-version.ts
13
+ function getVersion() {
14
+ return process.env.WORKSPACE_VERSION || process.env.npm_package_version || "unknown";
15
+ }
16
+ //#endregion
17
+ //#region src/utils/constants.ts
18
+ 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.";
19
+ const phCliHelp = subcommands({
20
+ name: "ph-cli",
21
+ description: PH_CLI_DESCRIPTION,
22
+ version: getVersion(),
23
+ cmds: phCliHelpCommands
24
+ });
25
+ //#endregion
26
+ //#region src/commands/access-token.ts
27
+ const accessToken = command({
28
+ name: "access-token",
29
+ description: `
30
+ The access-token command generates a bearer token for API authentication. This token
31
+ can be used to authenticate requests to Powerhouse APIs like reactor-api (Switchboard).
32
+
33
+ This command:
34
+ 1. Uses your CLI's cryptographic identity (DID) to sign a verifiable credential
35
+ 2. Creates a JWT bearer token with configurable expiration
36
+ 3. Outputs the token to stdout (info to stderr) for easy piping
37
+
38
+ Prerequisites:
39
+ You must have a cryptographic identity. Run 'ph login' first to:
40
+ - Generate a keypair (stored in .ph/.keypair.json)
41
+ - Optionally link your Ethereum address (stored in .ph/.renown.json)
42
+
43
+ Token Details:
44
+ The generated token is a JWT (JSON Web Token) containing:
45
+ - Issuer (iss): Your CLI's DID (did:key:...)
46
+ - Subject (sub): Your CLI's DID
47
+ - Credential Subject: Chain ID, network ID, and address (if authenticated)
48
+ - Expiration (exp): Based on --expiry option
49
+ - Audience (aud): If --audience is specified
50
+
51
+ Output:
52
+ - Token information (DID, address, expiry) is printed to stderr
53
+ - The token itself is printed to stdout for easy piping/copying
54
+
55
+ This allows you to use the command in scripts:
56
+ TOKEN=$(ph access-token)
57
+ curl -H "Authorization: Bearer $TOKEN" http://localhost:4001/graphql
58
+
59
+ Usage with APIs:
60
+ Generate token and use with curl
61
+ TOKEN=$(ph access-token --expiry 1d)
62
+ curl -X POST http://localhost:4001/graphql \\
63
+ -H "Content-Type: application/json" \\
64
+ -H "Authorization: Bearer $TOKEN" \\
65
+ -d '{"query": "{ drives { id name } }"}'
66
+
67
+ Export as environment variable
68
+ export PH_ACCESS_TOKEN=$(ph access-token)
69
+
70
+ Notes:
71
+ - Tokens are self-signed using your CLI's private key
72
+ - No network request is made; tokens are generated locally
73
+ - The recipient API must trust your CLI's DID to accept the token
74
+ - For reactor-api, ensure AUTH_ENABLED=true to require authentication
75
+ `,
76
+ args: accessTokenArgs,
77
+ handler: async (args) => {
78
+ if (args.debug) console.log(args);
79
+ const { generateAccessToken, parseExpiry, formatExpiry } = await import("@renown/sdk/node");
80
+ const { getRenown } = await import("./auth-wgUd0D0V.mjs");
81
+ const renown = await getRenown();
82
+ let expiresIn = DEFAULT_EXPIRY_SECONDS;
83
+ if (args.expiry) expiresIn = parseExpiry(args.expiry);
84
+ const result = await generateAccessToken(renown, {
85
+ expiresIn,
86
+ aud: args.audience
87
+ });
88
+ console.error(`CLI DID: ${result.did}`);
89
+ console.error(`ETH Address: ${result.address}`);
90
+ console.error(`Token expires in: ${formatExpiry(expiresIn)}`);
91
+ console.error("");
92
+ console.log(result.token);
93
+ process.exit(0);
94
+ }
95
+ });
96
+ //#endregion
97
+ //#region src/commands/build.ts
98
+ const build$1 = command({
99
+ name: "build",
100
+ args: buildArgs,
101
+ handler: async (args) => {
102
+ if (args.debug) console.log(args);
103
+ try {
104
+ await runBuild(args);
105
+ } catch (error) {
106
+ console.error(error);
107
+ process.exit(1);
108
+ }
109
+ }
110
+ });
111
+ const connect = subcommands({
112
+ name: "connect",
113
+ description: `Powerhouse Connect commands. Use with \`studio\`, \`build\` or \`preview\`. Defaults to \`studio\` if not specified.`,
114
+ cmds: {
115
+ studio: command({
116
+ name: "studio",
117
+ description: `The studio command starts the Connect Studio, a development environment for building
118
+ and testing Powerhouse applications. It provides a visual interface for working with
119
+ your project.
120
+
121
+ This command:
122
+ 1. Starts a local Connect Studio server
123
+ 2. Provides a web interface for development
124
+ 3. Allows you to interact with your project components
125
+ 4. Supports various configuration options for customization
126
+ `,
127
+ args: connectStudioArgs,
128
+ handler: async (args) => {
129
+ if (args.debug) console.log(args);
130
+ const { runConnectStudio } = await import("./connect-studio-DuH6WcoA.mjs");
131
+ await runConnectStudio(args);
132
+ }
133
+ }),
134
+ build: command({
135
+ name: "build",
136
+ description: `The Connect build command creates a production build with the project's local and
137
+ external packages included
138
+ `,
139
+ args: connectBuildArgs,
140
+ handler: async (args) => {
141
+ if (args.debug) console.log(args);
142
+ const { runConnectBuild } = await import("./connect-build-CrnmJlav.mjs");
143
+ await runConnectBuild(args);
144
+ process.exit(0);
145
+ }
146
+ }),
147
+ preview: command({
148
+ name: "preview",
149
+ description: `The Connect preview command previews a built Connect project.
150
+ NOTE: You must run \`ph connect build\` first
151
+ `,
152
+ args: connectPreviewArgs,
153
+ handler: async (args) => {
154
+ if (args.debug) console.log(args);
155
+ const { runConnectPreview } = await import("./connect-preview-4Xe7Lm1V.mjs");
156
+ await runConnectPreview(args);
157
+ }
158
+ })
159
+ }
160
+ });
161
+ //#endregion
162
+ //#region src/commands/generate.ts
163
+ const generate = command({
164
+ name: "generate",
165
+ description: `
166
+ The generate command creates code from document models. It helps you build editors,
167
+ processors, and other components based on your document model files.
168
+
169
+ This command:
170
+ 1. Reads document model definitions
171
+ 2. Generates code for specified components (editors, processors, etc.)
172
+ 3. Supports customization of output and generation options
173
+ 4. Can watch files for changes and regenerate code automatically
174
+ `,
175
+ args: generateArgs,
176
+ handler: async (args) => {
177
+ if (args.debug) console.log(args);
178
+ const { startGenerate } = await import("./generate-CMQGYRrW.mjs");
179
+ await startGenerate(args);
180
+ process.exit(0);
181
+ }
182
+ });
183
+ //#endregion
184
+ //#region src/commands/init.ts
185
+ const init = command({
186
+ name: "init",
187
+ description: "Initialize a new project",
188
+ args: initArgs,
189
+ handler: async (args) => {
190
+ if (args.debug) console.log({ args });
191
+ const { startInit } = await import("./init-BsmDWu9-.mjs");
192
+ await startInit(args);
193
+ process.exit(0);
194
+ }
195
+ });
196
+ //#endregion
197
+ //#region src/commands/inspect.ts
198
+ const inspect = command({
199
+ name: "inspect",
200
+ description: `
201
+ The inspect command examines and provides detailed information about a Powerhouse package.
202
+ It helps you understand the structure, dependencies, and configuration of packages in
203
+ your project.
204
+
205
+ This command:
206
+ 1. Analyzes the specified package
207
+ 2. Retrieves detailed information about its structure and configuration
208
+ 3. Displays package metadata, dependencies, and other relevant information
209
+ 4. Helps troubleshoot package-related issues`,
210
+ aliases: ["is"],
211
+ args: inspectArgs,
212
+ handler: async (args) => {
213
+ if (args.debug) console.log(args);
214
+ const { startInspect } = await import("./inspect-Dl8KWl3u.mjs");
215
+ startInspect(args);
216
+ process.exit(0);
217
+ }
218
+ });
219
+ //#endregion
220
+ //#region src/commands/install.ts
221
+ const install = command({
222
+ name: "install",
223
+ aliases: ["add", "i"],
224
+ description: `
225
+ The install command adds Powerhouse dependencies to your project. It installs packages
226
+ from the Powerhouse registry by default and updates configuration files.
227
+
228
+ This command:
229
+ 1. Resolves the registry URL (--registry flag > powerhouse.config.json > PH_REGISTRY_URL env > default)
230
+ 2. Installs the package using your package manager with the resolved registry
231
+ 3. Updates powerhouse.config.json to include the new dependencies
232
+ 4. Updates style.css with CSS imports if applicable
233
+ `,
234
+ args: installArgs,
235
+ handler: async (args) => {
236
+ if (args.debug) console.log(args);
237
+ const { projectPath, localProjectPath, globalProjectPath, packageManager, isGlobal } = await getPowerhouseProjectInfo(args);
238
+ if (!projectPath) throw new Error(`Could not find project path to install from.`);
239
+ const config = getConfig(join(projectPath, "powerhouse.config.json"));
240
+ const registryUrl = args.registry ?? config.packageRegistryUrl ?? process.env.PH_REGISTRY_URL ?? DEFAULT_REGISTRY_URL;
241
+ if (args.debug) console.log(">>> registryUrl", registryUrl);
242
+ const dependenciesWithVersions = await makeDependenciesWithVersions(args.dependencies, registryUrl);
243
+ if (args.debug) console.log(">>> parsedDependencies", dependenciesWithVersions);
244
+ if (args.debug) console.log("\n>>> projectInfo", {
245
+ localProjectPath,
246
+ globalProjectPath,
247
+ packageManager,
248
+ isGlobal
249
+ });
250
+ try {
251
+ console.log(`installing dependencies 📦 from ${registryUrl}...`);
252
+ execSync(getPowerhouseProjectInstallCommand(packageManager, ["--registry", registryUrl]), {
253
+ stdio: "inherit",
254
+ cwd: projectPath
255
+ });
256
+ console.log("Dependency installed successfully 🎉");
257
+ } catch (error) {
258
+ console.error("❌ Failed to install dependencies");
259
+ throw error;
260
+ }
261
+ if (args.debug) {
262
+ console.log("\n>>> updateConfigFile arguments:");
263
+ console.log(">>> dependencies", args.dependencies);
264
+ console.log(">>> projectPath", projectPath);
265
+ }
266
+ try {
267
+ console.log("⚙️ Updating powerhouse config file...");
268
+ updateConfigFile(dependenciesWithVersions, projectPath, "install");
269
+ console.log("Config file updated successfully 🎉");
270
+ } catch (error) {
271
+ console.error("❌ Failed to update config file");
272
+ throw error;
273
+ }
274
+ try {
275
+ console.log("⚙️ Updating styles.css file...");
276
+ updateStylesFile(dependenciesWithVersions, projectPath);
277
+ console.log("Styles file updated successfully 🎉");
278
+ } catch (error) {
279
+ console.error("❌ Failed to update styles file");
280
+ throw error;
281
+ }
282
+ process.exit(0);
283
+ }
284
+ });
285
+ //#endregion
286
+ //#region src/commands/list.ts
287
+ const list = command({
288
+ name: "list",
289
+ description: `
290
+ The list command displays information about installed Powerhouse packages in your project.
291
+ It reads the powerhouse.config.json file and shows the packages that are currently installed.
292
+
293
+ This command:
294
+ 1. Examines your project configuration
295
+ 2. Lists all installed Powerhouse packages
296
+ 3. Provides a clear overview of your project's dependencies
297
+ 4. Helps you manage and track your Powerhouse components
298
+ `,
299
+ aliases: ["l"],
300
+ args: listArgs,
301
+ handler: async (args) => {
302
+ if (args.debug) console.log(args);
303
+ try {
304
+ const projectInfo = await getPowerhouseProjectInfo();
305
+ console.log("\n>>> projectInfo", projectInfo);
306
+ const phConfig = getConfig$1(projectInfo.projectPath + "/powerhouse.config.json");
307
+ if (!phConfig.packages || phConfig.packages.length === 0) {
308
+ console.log("No packages found in the project");
309
+ return;
310
+ }
311
+ console.log("Installed Packages:\n");
312
+ phConfig.packages.forEach((pkg) => {
313
+ console.log(pkg.packageName);
314
+ });
315
+ } catch (e) {
316
+ console.log("No packages found in the project");
317
+ }
318
+ process.exit(0);
319
+ }
320
+ });
321
+ //#endregion
322
+ //#region src/commands/login.ts
323
+ const login = command({
324
+ name: "login",
325
+ description: `
326
+ The login command authenticates you with Renown using your Ethereum wallet. This enables
327
+ the CLI to act on behalf of your Ethereum identity for authenticated operations.
328
+
329
+ This command:
330
+ 1. Generates or loads a cryptographic identity (DID) for the CLI
331
+ 2. Opens your browser to the Renown authentication page
332
+ 3. You authorize the CLI's DID to act on behalf of your Ethereum address
333
+ 4. Stores the credentials locally in .ph/.renown.json
334
+ `,
335
+ args: loginArgs,
336
+ handler: async (args) => {
337
+ if (args.debug) console.log(args);
338
+ const { getRenown } = await import("./auth-wgUd0D0V.mjs");
339
+ const renown = await getRenown(args.renownUrl);
340
+ if (args.showDid) {
341
+ console.log(renown.did);
342
+ process.exit(0);
343
+ }
344
+ if (args.status) {
345
+ const { getAuthStatus } = await import("@renown/sdk/node");
346
+ const status = getAuthStatus(renown);
347
+ if (!status.authenticated || !status.address) {
348
+ console.log("Not authenticated with an Ethereum address.");
349
+ console.log("Run \"ph login\" to authenticate.");
350
+ } else {
351
+ console.log("Authenticated");
352
+ console.log(` ETH Address: ${status.address}`);
353
+ console.log(` User DID: ${status.userDid}`);
354
+ console.log(` Chain ID: ${status.chainId}`);
355
+ console.log(` CLI DID: ${status.cliDid}`);
356
+ console.log(` Authenticated at: ${status.authenticatedAt?.toLocaleString()}`);
357
+ console.log(` Renown URL: ${status.baseUrl}`);
358
+ }
359
+ process.exit(0);
360
+ }
361
+ if (args.logout) {
362
+ await handleLogout();
363
+ process.exit(0);
364
+ }
365
+ const { browserLogin } = await import("@renown/sdk/node");
366
+ console.debug("Initializing cryptographic identity...");
367
+ console.log(`CLI DID: ${renown.did}`);
368
+ try {
369
+ const timeoutMs = args.timeout ? args.timeout * 1e3 : void 0;
370
+ const result = await browserLogin(renown, {
371
+ renownUrl: args.renownUrl,
372
+ timeoutMs,
373
+ onLoginUrl: (url, sessionId) => {
374
+ console.log("Opening browser for authentication...");
375
+ console.log(`Session ID: ${sessionId.slice(0, 8)}...`);
376
+ console.log(`Login URL: ${url}`);
377
+ console.log();
378
+ console.log("Waiting for authentication in browser");
379
+ console.log(`(timeout in ${(timeoutMs ?? 3e5) / 1e3} seconds)`);
380
+ console.log();
381
+ console.log("Please connect your wallet and authorize this CLI to act on your behalf.");
382
+ console.log();
383
+ process.stdout.write("Waiting");
384
+ },
385
+ onPollTick: () => process.stdout.write("."),
386
+ onBrowserOpenFailed: (url) => {
387
+ console.error("Failed to open browser automatically.");
388
+ console.log(`Please open this URL manually: ${url}`);
389
+ }
390
+ });
391
+ console.log();
392
+ console.log();
393
+ console.log("Successfully authenticated!");
394
+ console.log(` ETH Address: ${result.user.address}`);
395
+ console.log(` User DID: ${result.user.did}`);
396
+ console.log(` CLI DID: ${result.cliDid}`);
397
+ console.log();
398
+ console.log("The CLI can now act on behalf of your Ethereum identity.");
399
+ } catch (error) {
400
+ console.log();
401
+ throw error;
402
+ }
403
+ process.exit(0);
404
+ }
405
+ });
406
+ async function handleLogout() {
407
+ const { getRenown } = await import("./auth-wgUd0D0V.mjs");
408
+ const renown = await getRenown();
409
+ if (!renown.user) {
410
+ console.log("Not currently authenticated.");
411
+ return;
412
+ }
413
+ try {
414
+ await renown.logout();
415
+ console.log("Successfully logged out.");
416
+ } catch (error) {
417
+ console.error("Failed to clear credentials.");
418
+ console.debug(error);
419
+ }
420
+ }
421
+ //#endregion
422
+ //#region src/commands/logout.ts
423
+ const logout = command({
424
+ name: "logout",
425
+ description: `
426
+ The logout command removes an existing session created with 'ph login'`,
427
+ args: {},
428
+ handler: async () => {
429
+ await handleLogout();
430
+ process.exit(0);
431
+ }
432
+ });
433
+ //#endregion
434
+ //#region src/commands/migrate.ts
435
+ const migrate = command({
436
+ name: "migrate",
437
+ args: migrateArgs,
438
+ description: "Run migrations",
439
+ handler: async (args) => {
440
+ if (args.debug) console.log(args);
441
+ const { startMigrate } = await import("./migrate-CMNF8puQ.mjs");
442
+ await startMigrate(args);
443
+ process.exit(0);
444
+ }
445
+ });
446
+ //#endregion
447
+ //#region src/commands/publish.ts
448
+ const publish = command({
449
+ name: "publish",
450
+ description: `
451
+ Publish a package to the Powerhouse registry. This is a thin wrapper around npm publish
452
+ that automatically sets the registry URL.
453
+
454
+ This command:
455
+ 1. Resolves the registry URL (--registry flag > PH_REGISTRY_URL env > powerhouse.config.json > default)
456
+ 2. Checks authentication with the registry via npm whoami
457
+ 3. Forwards all additional arguments to npm publish
458
+ `,
459
+ args: publishArgs,
460
+ handler: async (args) => {
461
+ if (args.debug) console.log(args);
462
+ const { projectPath } = await getPowerhouseProjectInfo();
463
+ if (!projectPath) throw new Error("Could not find project path.");
464
+ const registryUrl = resolveRegistryUrl({
465
+ registry: args.registry,
466
+ projectPath
467
+ });
468
+ if (args.debug) console.log(">>> registryUrl", registryUrl);
469
+ try {
470
+ await checkNpmAuth(registryUrl);
471
+ } catch {
472
+ console.error(`Not authenticated with registry: ${registryUrl}`);
473
+ console.error(`Run: npm adduser --registry ${registryUrl}`);
474
+ process.exit(1);
475
+ }
476
+ if (args.debug) console.log(">>> command", `npm publish --registry ${registryUrl} ${args.forwardedArgs.join(" ")}`);
477
+ console.log(`Publishing to ${registryUrl}...`);
478
+ const result = await npmPublish({
479
+ registryUrl,
480
+ cwd: projectPath,
481
+ args: args.forwardedArgs
482
+ });
483
+ if (result.stdout) console.log(result.stdout);
484
+ process.exit(0);
485
+ }
486
+ });
487
+ //#endregion
488
+ //#region src/commands/switchboard.ts
489
+ const switchboard = command({
490
+ name: "switchboard",
491
+ aliases: ["reactor"],
492
+ description: `
493
+ The switchboard command starts a local Switchboard instance, which acts as the document
494
+ processing engine for Powerhouse projects. It provides the infrastructure for document
495
+ models, processors, and real-time updates.
496
+
497
+ This command:
498
+ 1. Starts a local switchboard server
499
+ 2. Loads document models and processors
500
+ 3. Provides an API for document operations
501
+ 4. Enables real-time document processing
502
+ 5. Can authenticate with remote services using your identity from 'ph login'`,
503
+ args: switchboardArgs,
504
+ handler: async (args) => {
505
+ if (args.debug) console.log(args);
506
+ const { basePath, dbPath, migrate, migrateStatus } = args;
507
+ if (basePath) process.env.BASE_PATH = basePath;
508
+ if (migrate || migrateStatus) {
509
+ const { runSwitchboardMigrations } = await import("./switchboard-migrate-1lOCPmX0.mjs");
510
+ await runSwitchboardMigrations({
511
+ dbPath,
512
+ statusOnly: migrateStatus
513
+ });
514
+ process.exit(0);
515
+ }
516
+ const { startSwitchboard } = await import("./switchboard-Bht39Myv.mjs");
517
+ const { defaultDriveUrl, renown } = await startSwitchboard(args);
518
+ console.log(" ➜ Switchboard:", defaultDriveUrl);
519
+ if (renown) console.log(" ➜ Identity:", renown.did);
520
+ }
521
+ });
522
+ //#endregion
523
+ //#region src/commands/uninstall.ts
524
+ const uninstall = command({
525
+ name: "uninstall",
526
+ aliases: ["remove"],
527
+ description: `
528
+ The uninstall command removes Powerhouse dependencies from your project. It handles the
529
+ removal of packages, updates configuration files, and ensures proper cleanup.
530
+
531
+ This command:
532
+ 1. Uninstalls specified Powerhouse dependencies using your package manager
533
+ 2. Updates powerhouse.config.json to remove the dependencies
534
+ 3. Supports various uninstallation options and configurations
535
+ 4. Works with ${AGENTS.join(", ")} package managers
536
+ `,
537
+ args: uninstallArgs,
538
+ handler: async (args) => {
539
+ if (args.debug) console.log(args);
540
+ const { projectPath, localProjectPath, globalProjectPath, packageManager, isGlobal } = await getPowerhouseProjectInfo(args);
541
+ if (!projectPath) throw new Error(`Could not find project path to uninstall from`);
542
+ const dependenciesWithVersions = await makeDependenciesWithVersions(args.dependencies);
543
+ if (args.debug) console.log(">>> parsedDependencies", dependenciesWithVersions);
544
+ if (args.debug) console.log("\n>>> projectInfo", {
545
+ localProjectPath,
546
+ globalProjectPath,
547
+ packageManager,
548
+ isGlobal
549
+ });
550
+ try {
551
+ console.log("Uninstalling dependencies 📦 ...");
552
+ execSync(await getPowerhouseProjectUninstallCommand(packageManager), {
553
+ stdio: "inherit",
554
+ cwd: projectPath
555
+ });
556
+ console.log("Dependency uninstalled successfully 🎉");
557
+ } catch (error) {
558
+ console.error("❌ Failed to uninstall dependencies");
559
+ throw error;
560
+ }
561
+ try {
562
+ console.log("⚙️ Updating powerhouse config file...");
563
+ updateConfigFile(dependenciesWithVersions, projectPath, "uninstall");
564
+ console.log("Config file updated successfully 🎉");
565
+ } catch (error) {
566
+ console.error("❌ Failed to update config file");
567
+ throw error;
568
+ }
569
+ try {
570
+ console.log("⚙️ Updating styles.css file...");
571
+ removeStylesImports(dependenciesWithVersions, projectPath);
572
+ console.log("Styles file updated successfully 🎉");
573
+ } catch (error) {
574
+ console.error("❌ Failed to update styles file");
575
+ throw error;
576
+ }
577
+ process.exit(0);
578
+ }
579
+ });
580
+ //#endregion
581
+ //#region src/commands/ph-cli-commands.ts
582
+ const phCliCommands = {
583
+ init,
584
+ generate,
585
+ vetra: command({
586
+ name: "vetra",
587
+ description: `
588
+ The vetra command sets up a Vetra development environment for working with Vetra projects.
589
+ It starts a Vetra Switchboard and optionally Connect Studio, enabling document collaboration
590
+ and real-time processing with a "Vetra" drive or connection to remote drives.
591
+
592
+ This command:
593
+ 1. Starts a Vetra Switchboard with a "Vetra" drive for document storage
594
+ 2. Optionally connects to remote drives instead of creating a local drive
595
+ 3. Starts Connect Studio pointing to the Switchboard for user interaction (unless disabled)
596
+ 4. Enables real-time updates, collaboration, and code generation`,
597
+ args: vetraArgs,
598
+ handler: async (args) => {
599
+ if (args.debug) console.log(args);
600
+ const { startVetra } = await import("./vetra-CuBxTrw7.mjs");
601
+ await startVetra(args);
602
+ }
603
+ }),
604
+ connect,
605
+ build: build$1,
606
+ publish,
607
+ "access-token": accessToken,
608
+ inspect,
609
+ list,
610
+ migrate,
611
+ switchboard,
612
+ login,
613
+ logout,
614
+ install,
615
+ uninstall
616
+ };
617
+ const phCli = subcommands({
618
+ name: "ph-cli",
619
+ description: PH_CLI_DESCRIPTION,
620
+ version: getVersion(),
621
+ cmds: phCliCommands
622
+ });
623
+ //#endregion
624
+ //#region src/cli.ts
625
+ async function main() {
626
+ assertNodeVersion();
627
+ const args = process.argv.slice(2);
628
+ const hasNoArgs = args.length === 0;
629
+ const isHelp = args.some((arg) => arg === "--help" || arg === "-h");
630
+ const isTopLevelHelp = isHelp && args.length === 1;
631
+ const cli = hasNoArgs || isTopLevelHelp ? phCliHelp : phCli;
632
+ const [command, ...restArgs] = args;
633
+ if (command === "connect" && ![
634
+ "studio",
635
+ "build",
636
+ "preview"
637
+ ].includes(args[1]) && !isHelp) await run(cli, [
638
+ "connect",
639
+ "studio",
640
+ ...restArgs
641
+ ]);
642
+ else await run(cli, args);
643
+ }
644
+ await main().catch((error) => {
645
+ if (process.argv.slice(2).includes("--debug")) throw error;
646
+ if (error instanceof Error) {
647
+ console.error(error.message);
648
+ process.exit(1);
649
+ } else throw error;
650
+ });
651
+ //#endregion
652
+ export {};
653
+
654
+ //# sourceMappingURL=cli.mjs.map