@powerhousedao/ph-cli 6.0.0-dev.22 → 6.0.0-dev.220

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 (305) hide show
  1. package/dist/assign-env-vars-DZMMuzB2.mjs +15 -0
  2. package/dist/assign-env-vars-DZMMuzB2.mjs.map +1 -0
  3. package/dist/auth-BtzNlVSv.mjs +2 -0
  4. package/dist/auth-DFjfbgA-.mjs +15 -0
  5. package/dist/auth-DFjfbgA-.mjs.map +1 -0
  6. package/dist/build-DIv8xMX2.mjs +46 -0
  7. package/dist/build-DIv8xMX2.mjs.map +1 -0
  8. package/dist/cli-CFWMyGVU.mjs +140 -0
  9. package/dist/cli-CFWMyGVU.mjs.map +1 -0
  10. package/dist/cli.d.mts +1 -0
  11. package/dist/cli.mjs +923 -0
  12. package/dist/cli.mjs.map +1 -0
  13. package/dist/connect-build-BXuIuTCu.mjs +35 -0
  14. package/dist/connect-build-BXuIuTCu.mjs.map +1 -0
  15. package/dist/connect-preview-CaEiWmqU.mjs +27 -0
  16. package/dist/connect-preview-CaEiWmqU.mjs.map +1 -0
  17. package/dist/connect-studio-BaqbrWYQ.mjs +28 -0
  18. package/dist/connect-studio-BaqbrWYQ.mjs.map +1 -0
  19. package/dist/connect-studio-Dndkp0Q_.mjs +3 -0
  20. package/dist/generate-all-DaXXjoms.mjs +12 -0
  21. package/dist/generate-all-DaXXjoms.mjs.map +1 -0
  22. package/dist/generate-app-GvQeAG4w.mjs +35 -0
  23. package/dist/generate-app-GvQeAG4w.mjs.map +1 -0
  24. package/dist/generate-document-model-Dnik0rKd.mjs +21 -0
  25. package/dist/generate-document-model-Dnik0rKd.mjs.map +1 -0
  26. package/dist/generate-editor-BNN2OmmX.mjs +35 -0
  27. package/dist/generate-editor-BNN2OmmX.mjs.map +1 -0
  28. package/dist/generate-processor-CCSW2Ed2.mjs +26 -0
  29. package/dist/generate-processor-CCSW2Ed2.mjs.map +1 -0
  30. package/dist/generate-subgraph-B-d3J6hU.mjs +24 -0
  31. package/dist/generate-subgraph-B-d3J6hU.mjs.map +1 -0
  32. package/dist/init-BgKiiFju.mjs +124 -0
  33. package/dist/init-BgKiiFju.mjs.map +1 -0
  34. package/dist/inspect-czss6pZb.mjs +45 -0
  35. package/dist/inspect-czss6pZb.mjs.map +1 -0
  36. package/dist/logout-DcpByE5i.mjs +230 -0
  37. package/dist/logout-DcpByE5i.mjs.map +1 -0
  38. package/dist/migrate-DLEG7ehb.mjs +11 -0
  39. package/dist/migrate-DLEG7ehb.mjs.map +1 -0
  40. package/dist/scripts/generate-commands-docs.ts +16 -8
  41. package/dist/switchboard-2B5VC_cr.mjs +2 -0
  42. package/dist/switchboard-DGbd-EPx.mjs +72 -0
  43. package/dist/switchboard-DGbd-EPx.mjs.map +1 -0
  44. package/dist/switchboard-migrate-81jhmuWu.mjs +50 -0
  45. package/dist/switchboard-migrate-81jhmuWu.mjs.map +1 -0
  46. package/dist/utils-C6_gv4nB.mjs +162 -0
  47. package/dist/utils-C6_gv4nB.mjs.map +1 -0
  48. package/dist/vetra--a0x272X.mjs +420 -0
  49. package/dist/vetra--a0x272X.mjs.map +1 -0
  50. package/package.json +44 -46
  51. package/dist/scripts/generate-commands-docs.d.ts +0 -2
  52. package/dist/scripts/generate-commands-docs.d.ts.map +0 -1
  53. package/dist/scripts/generate-commands-docs.js +0 -47
  54. package/dist/scripts/generate-commands-docs.js.map +0 -1
  55. package/dist/scripts/generate-docs-legacy.d.ts +0 -2
  56. package/dist/scripts/generate-docs-legacy.d.ts.map +0 -1
  57. package/dist/scripts/generate-docs-legacy.js +0 -72
  58. package/dist/scripts/generate-docs-legacy.js.map +0 -1
  59. package/dist/scripts/generate-docs-legacy.ts +0 -84
  60. package/dist/scripts/generate-version.d.ts +0 -2
  61. package/dist/scripts/generate-version.d.ts.map +0 -1
  62. package/dist/scripts/generate-version.js +0 -13
  63. package/dist/scripts/generate-version.js.map +0 -1
  64. package/dist/scripts/generate-version.ts +0 -22
  65. package/dist/src/cli.d.ts +0 -3
  66. package/dist/src/cli.d.ts.map +0 -1
  67. package/dist/src/cli.js +0 -29
  68. package/dist/src/cli.js.map +0 -1
  69. package/dist/src/cli.old.d.ts +0 -3
  70. package/dist/src/cli.old.d.ts.map +0 -1
  71. package/dist/src/cli.old.js +0 -43
  72. package/dist/src/cli.old.js.map +0 -1
  73. package/dist/src/commands/access-token.d.ts +0 -14
  74. package/dist/src/commands/access-token.d.ts.map +0 -1
  75. package/dist/src/commands/access-token.js +0 -142
  76. package/dist/src/commands/access-token.js.map +0 -1
  77. package/dist/src/commands/connect.d.ts +0 -249
  78. package/dist/src/commands/connect.d.ts.map +0 -1
  79. package/dist/src/commands/connect.js +0 -60
  80. package/dist/src/commands/connect.js.map +0 -1
  81. package/dist/src/commands/generate.d.ts +0 -58
  82. package/dist/src/commands/generate.d.ts.map +0 -1
  83. package/dist/src/commands/generate.js +0 -25
  84. package/dist/src/commands/generate.js.map +0 -1
  85. package/dist/src/commands/get-package-manager.d.ts +0 -30
  86. package/dist/src/commands/get-package-manager.d.ts.map +0 -1
  87. package/dist/src/commands/get-package-manager.js +0 -8
  88. package/dist/src/commands/get-package-manager.js.map +0 -1
  89. package/dist/src/commands/index.d.ts +0 -13
  90. package/dist/src/commands/index.d.ts.map +0 -1
  91. package/dist/src/commands/index.js +0 -25
  92. package/dist/src/commands/index.js.map +0 -1
  93. package/dist/src/commands/inspect.d.ts +0 -12
  94. package/dist/src/commands/inspect.d.ts.map +0 -1
  95. package/dist/src/commands/inspect.js +0 -27
  96. package/dist/src/commands/inspect.js.map +0 -1
  97. package/dist/src/commands/install.d.ts +0 -22
  98. package/dist/src/commands/install.d.ts.map +0 -1
  99. package/dist/src/commands/install.js +0 -75
  100. package/dist/src/commands/install.js.map +0 -1
  101. package/dist/src/commands/legacy/access-token.old.d.ts +0 -9
  102. package/dist/src/commands/legacy/access-token.old.d.ts.map +0 -1
  103. package/dist/src/commands/legacy/access-token.old.js +0 -110
  104. package/dist/src/commands/legacy/access-token.old.js.map +0 -1
  105. package/dist/src/commands/legacy/connect.old.d.ts +0 -19
  106. package/dist/src/commands/legacy/connect.old.d.ts.map +0 -1
  107. package/dist/src/commands/legacy/connect.old.js +0 -85
  108. package/dist/src/commands/legacy/connect.old.js.map +0 -1
  109. package/dist/src/commands/legacy/generate.old.d.ts +0 -9
  110. package/dist/src/commands/legacy/generate.old.d.ts.map +0 -1
  111. package/dist/src/commands/legacy/generate.old.js +0 -41
  112. package/dist/src/commands/legacy/generate.old.js.map +0 -1
  113. package/dist/src/commands/legacy/help.old.d.ts +0 -3
  114. package/dist/src/commands/legacy/help.old.d.ts.map +0 -1
  115. package/dist/src/commands/legacy/help.old.js +0 -9
  116. package/dist/src/commands/legacy/help.old.js.map +0 -1
  117. package/dist/src/commands/legacy/inspect.old.d.ts +0 -6
  118. package/dist/src/commands/legacy/inspect.old.d.ts.map +0 -1
  119. package/dist/src/commands/legacy/inspect.old.js +0 -21
  120. package/dist/src/commands/legacy/inspect.old.js.map +0 -1
  121. package/dist/src/commands/legacy/install.old.d.ts +0 -15
  122. package/dist/src/commands/legacy/install.old.d.ts.map +0 -1
  123. package/dist/src/commands/legacy/install.old.js +0 -127
  124. package/dist/src/commands/legacy/install.old.js.map +0 -1
  125. package/dist/src/commands/legacy/login.old.d.ts +0 -12
  126. package/dist/src/commands/legacy/login.old.d.ts.map +0 -1
  127. package/dist/src/commands/legacy/login.old.js +0 -208
  128. package/dist/src/commands/legacy/login.old.js.map +0 -1
  129. package/dist/src/commands/legacy/migrate.old.d.ts +0 -11
  130. package/dist/src/commands/legacy/migrate.old.d.ts.map +0 -1
  131. package/dist/src/commands/legacy/migrate.old.js +0 -15
  132. package/dist/src/commands/legacy/migrate.old.js.map +0 -1
  133. package/dist/src/commands/legacy/service.old.d.ts +0 -5
  134. package/dist/src/commands/legacy/service.old.d.ts.map +0 -1
  135. package/dist/src/commands/legacy/service.old.js +0 -67
  136. package/dist/src/commands/legacy/service.old.js.map +0 -1
  137. package/dist/src/commands/legacy/switchboard.old.d.ts +0 -9
  138. package/dist/src/commands/legacy/switchboard.old.d.ts.map +0 -1
  139. package/dist/src/commands/legacy/switchboard.old.js +0 -78
  140. package/dist/src/commands/legacy/switchboard.old.js.map +0 -1
  141. package/dist/src/commands/legacy/uninstall.old.d.ts +0 -15
  142. package/dist/src/commands/legacy/uninstall.old.d.ts.map +0 -1
  143. package/dist/src/commands/legacy/uninstall.old.js +0 -120
  144. package/dist/src/commands/legacy/uninstall.old.js.map +0 -1
  145. package/dist/src/commands/legacy/vetra.old.d.ts +0 -23
  146. package/dist/src/commands/legacy/vetra.old.d.ts.map +0 -1
  147. package/dist/src/commands/legacy/vetra.old.js +0 -35
  148. package/dist/src/commands/legacy/vetra.old.js.map +0 -1
  149. package/dist/src/commands/list.d.ts +0 -10
  150. package/dist/src/commands/list.d.ts.map +0 -1
  151. package/dist/src/commands/list.js +0 -42
  152. package/dist/src/commands/list.js.map +0 -1
  153. package/dist/src/commands/list.old.d.ts +0 -9
  154. package/dist/src/commands/list.old.d.ts.map +0 -1
  155. package/dist/src/commands/list.old.js +0 -36
  156. package/dist/src/commands/list.old.js.map +0 -1
  157. package/dist/src/commands/login.d.ts +0 -20
  158. package/dist/src/commands/login.d.ts.map +0 -1
  159. package/dist/src/commands/login.js +0 -209
  160. package/dist/src/commands/login.js.map +0 -1
  161. package/dist/src/commands/migrate.d.ts +0 -12
  162. package/dist/src/commands/migrate.d.ts.map +0 -1
  163. package/dist/src/commands/migrate.js +0 -16
  164. package/dist/src/commands/migrate.js.map +0 -1
  165. package/dist/src/commands/ph-cli-commands.d.ts +0 -410
  166. package/dist/src/commands/ph-cli-commands.d.ts.map +0 -1
  167. package/dist/src/commands/ph-cli-commands.js +0 -25
  168. package/dist/src/commands/ph-cli-commands.js.map +0 -1
  169. package/dist/src/commands/ph-cli-help.d.ts +0 -396
  170. package/dist/src/commands/ph-cli-help.d.ts.map +0 -1
  171. package/dist/src/commands/ph-cli-help.js +0 -12
  172. package/dist/src/commands/ph-cli-help.js.map +0 -1
  173. package/dist/src/commands/ph-cli.d.ts +0 -490
  174. package/dist/src/commands/ph-cli.d.ts.map +0 -1
  175. package/dist/src/commands/ph-cli.js +0 -12
  176. package/dist/src/commands/ph-cli.js.map +0 -1
  177. package/dist/src/commands/register-commands.d.ts +0 -5
  178. package/dist/src/commands/register-commands.d.ts.map +0 -1
  179. package/dist/src/commands/register-commands.js +0 -32
  180. package/dist/src/commands/register-commands.js.map +0 -1
  181. package/dist/src/commands/service.d.ts +0 -12
  182. package/dist/src/commands/service.d.ts.map +0 -1
  183. package/dist/src/commands/service.js +0 -79
  184. package/dist/src/commands/service.js.map +0 -1
  185. package/dist/src/commands/switchboard.d.ts +0 -46
  186. package/dist/src/commands/switchboard.d.ts.map +0 -1
  187. package/dist/src/commands/switchboard.js +0 -43
  188. package/dist/src/commands/switchboard.js.map +0 -1
  189. package/dist/src/commands/uninstall.d.ts +0 -22
  190. package/dist/src/commands/uninstall.d.ts.map +0 -1
  191. package/dist/src/commands/uninstall.js +0 -71
  192. package/dist/src/commands/uninstall.js.map +0 -1
  193. package/dist/src/commands/vetra.d.ts +0 -64
  194. package/dist/src/commands/vetra.d.ts.map +0 -1
  195. package/dist/src/commands/vetra.js +0 -24
  196. package/dist/src/commands/vetra.js.map +0 -1
  197. package/dist/src/get-version.d.ts +0 -2
  198. package/dist/src/get-version.d.ts.map +0 -1
  199. package/dist/src/get-version.js +0 -7
  200. package/dist/src/get-version.js.map +0 -1
  201. package/dist/src/help.d.ts +0 -65
  202. package/dist/src/help.d.ts.map +0 -1
  203. package/dist/src/help.js +0 -770
  204. package/dist/src/help.js.map +0 -1
  205. package/dist/src/index.d.ts +0 -4
  206. package/dist/src/index.d.ts.map +0 -1
  207. package/dist/src/index.js +0 -4
  208. package/dist/src/index.js.map +0 -1
  209. package/dist/src/services/auth.d.ts +0 -69
  210. package/dist/src/services/auth.d.ts.map +0 -1
  211. package/dist/src/services/auth.js +0 -171
  212. package/dist/src/services/auth.js.map +0 -1
  213. package/dist/src/services/connect.d.ts +0 -5
  214. package/dist/src/services/connect.d.ts.map +0 -1
  215. package/dist/src/services/connect.js +0 -90
  216. package/dist/src/services/connect.js.map +0 -1
  217. package/dist/src/services/generate.d.ts +0 -3
  218. package/dist/src/services/generate.d.ts.map +0 -1
  219. package/dist/src/services/generate.js +0 -80
  220. package/dist/src/services/generate.js.map +0 -1
  221. package/dist/src/services/inspect.d.ts +0 -3
  222. package/dist/src/services/inspect.d.ts.map +0 -1
  223. package/dist/src/services/inspect.js +0 -50
  224. package/dist/src/services/inspect.js.map +0 -1
  225. package/dist/src/services/legacy/connect.old.d.ts +0 -2
  226. package/dist/src/services/legacy/connect.old.d.ts.map +0 -1
  227. package/dist/src/services/legacy/connect.old.js +0 -2
  228. package/dist/src/services/legacy/connect.old.js.map +0 -1
  229. package/dist/src/services/legacy/generate.old.d.ts +0 -30
  230. package/dist/src/services/legacy/generate.old.d.ts.map +0 -1
  231. package/dist/src/services/legacy/generate.old.js +0 -107
  232. package/dist/src/services/legacy/generate.old.js.map +0 -1
  233. package/dist/src/services/legacy/inspect.old.d.ts +0 -5
  234. package/dist/src/services/legacy/inspect.old.d.ts.map +0 -1
  235. package/dist/src/services/legacy/inspect.old.js +0 -49
  236. package/dist/src/services/legacy/inspect.old.js.map +0 -1
  237. package/dist/src/services/legacy/migrate.old.d.ts +0 -3
  238. package/dist/src/services/legacy/migrate.old.d.ts.map +0 -1
  239. package/dist/src/services/legacy/migrate.old.js +0 -289
  240. package/dist/src/services/legacy/migrate.old.js.map +0 -1
  241. package/dist/src/services/legacy/switchboard.old.d.ts +0 -54
  242. package/dist/src/services/legacy/switchboard.old.d.ts.map +0 -1
  243. package/dist/src/services/legacy/switchboard.old.js +0 -79
  244. package/dist/src/services/legacy/switchboard.old.js.map +0 -1
  245. package/dist/src/services/legacy/vetra.old.d.ts +0 -15
  246. package/dist/src/services/legacy/vetra.old.d.ts.map +0 -1
  247. package/dist/src/services/legacy/vetra.old.js +0 -176
  248. package/dist/src/services/legacy/vetra.old.js.map +0 -1
  249. package/dist/src/services/migrate.d.ts +0 -3
  250. package/dist/src/services/migrate.d.ts.map +0 -1
  251. package/dist/src/services/migrate.js +0 -327
  252. package/dist/src/services/migrate.js.map +0 -1
  253. package/dist/src/services/switchboard-migrate.d.ts +0 -7
  254. package/dist/src/services/switchboard-migrate.d.ts.map +0 -1
  255. package/dist/src/services/switchboard-migrate.js +0 -60
  256. package/dist/src/services/switchboard-migrate.js.map +0 -1
  257. package/dist/src/services/switchboard.d.ts +0 -22
  258. package/dist/src/services/switchboard.d.ts.map +0 -1
  259. package/dist/src/services/switchboard.js +0 -77
  260. package/dist/src/services/switchboard.js.map +0 -1
  261. package/dist/src/services/vetra.d.ts +0 -3
  262. package/dist/src/services/vetra.d.ts.map +0 -1
  263. package/dist/src/services/vetra.js +0 -169
  264. package/dist/src/services/vetra.js.map +0 -1
  265. package/dist/src/types.d.ts +0 -31
  266. package/dist/src/types.d.ts.map +0 -1
  267. package/dist/src/types.js +0 -2
  268. package/dist/src/types.js.map +0 -1
  269. package/dist/src/utils/configure-vetra-github-url.d.ts +0 -12
  270. package/dist/src/utils/configure-vetra-github-url.d.ts.map +0 -1
  271. package/dist/src/utils/configure-vetra-github-url.js +0 -230
  272. package/dist/src/utils/configure-vetra-github-url.js.map +0 -1
  273. package/dist/src/utils/constants.d.ts +0 -2
  274. package/dist/src/utils/constants.d.ts.map +0 -1
  275. package/dist/src/utils/constants.js +0 -2
  276. package/dist/src/utils/constants.js.map +0 -1
  277. package/dist/src/utils/file-system.d.ts +0 -2
  278. package/dist/src/utils/file-system.d.ts.map +0 -1
  279. package/dist/src/utils/file-system.js +0 -15
  280. package/dist/src/utils/file-system.js.map +0 -1
  281. package/dist/src/utils/index.d.ts +0 -3
  282. package/dist/src/utils/index.d.ts.map +0 -1
  283. package/dist/src/utils/index.js +0 -3
  284. package/dist/src/utils/index.js.map +0 -1
  285. package/dist/src/utils/projects.d.ts +0 -19
  286. package/dist/src/utils/projects.d.ts.map +0 -1
  287. package/dist/src/utils/projects.js +0 -93
  288. package/dist/src/utils/projects.js.map +0 -1
  289. package/dist/src/utils.d.ts +0 -112
  290. package/dist/src/utils.d.ts.map +0 -1
  291. package/dist/src/utils.js +0 -261
  292. package/dist/src/utils.js.map +0 -1
  293. package/dist/src/version.d.ts +0 -2
  294. package/dist/src/version.d.ts.map +0 -1
  295. package/dist/src/version.js +0 -3
  296. package/dist/src/version.js.map +0 -1
  297. package/dist/test/utils.test.d.ts +0 -2
  298. package/dist/test/utils.test.d.ts.map +0 -1
  299. package/dist/test/utils.test.js +0 -133
  300. package/dist/test/utils.test.js.map +0 -1
  301. package/dist/tsconfig.tsbuildinfo +0 -1
  302. package/dist/vitest.config.d.ts +0 -3
  303. package/dist/vitest.config.d.ts.map +0 -1
  304. package/dist/vitest.config.js +0 -7
  305. package/dist/vitest.config.js.map +0 -1
package/dist/cli.mjs ADDED
@@ -0,0 +1,923 @@
1
+ #!/usr/bin/env node
2
+ import { a as getVersion, i as accessToken, n as login, r as list, t as logout } from "./logout-DcpByE5i.mjs";
3
+ import { t as runBuild } from "./build-DIv8xMX2.mjs";
4
+ import { a as updateStylesFile, i as updateConfigFile, r as removeStylesImports } from "./utils-C6_gv4nB.mjs";
5
+ import { t as getRenown } from "./auth-DFjfbgA-.mjs";
6
+ import { assertNodeVersion, buildArgs, captureCliError, codeArgs, connectBuildArgs, connectPreviewArgs, connectStudioArgs, debugArgs, getPowerhouseProjectInfo, getPowerhouseProjectUninstallCommand, initArgs, initCliTelemetry, inspectArgs, installArgs, makeDependenciesWithVersions, migrateArgs, phCliHelpCommands, publishArgs, registryLoginArgs, switchboardArgs, uninstallArgs, unpublishArgs, vetraArgs } from "@powerhousedao/shared/clis";
7
+ import { array, boolean, command, flag, multioption, oneOf, option, optional, run, string, subcommands } from "cmd-ts";
8
+ import { AGENTS, resolveCommand } from "package-manager-detector";
9
+ import { Directory, File } from "cmd-ts/dist/cjs/batteries/fs.js";
10
+ import { generateDBSchema } from "@powerhousedao/codegen";
11
+ import path from "path";
12
+ import { PROCESSOR_APPS } from "@powerhousedao/shared/processors";
13
+ import { checkNpmAuth, npmPublish, npmUnpublish, resolveRegistryUrl, writeRegistryAuthToken } from "@powerhousedao/shared/registry";
14
+ import { execSync } from "child_process";
15
+ import { readPackageSync } from "read-pkg";
16
+ import { prerelease } from "semver";
17
+ import { generateAccessToken } from "@renown/sdk/node";
18
+ import { createInterface } from "node:readline/promises";
19
+ //#region src/utils/constants.ts
20
+ 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.";
21
+ const phCliHelp = subcommands({
22
+ name: "ph-cli",
23
+ description: PH_CLI_DESCRIPTION,
24
+ version: getVersion(),
25
+ cmds: phCliHelpCommands
26
+ });
27
+ //#endregion
28
+ //#region src/commands/build.ts
29
+ const build$1 = command({
30
+ name: "build",
31
+ args: buildArgs,
32
+ handler: async (args) => {
33
+ if (args.debug) console.log(args);
34
+ try {
35
+ await runBuild(args);
36
+ } catch (error) {
37
+ console.error(error);
38
+ process.exit(1);
39
+ }
40
+ }
41
+ });
42
+ //#endregion
43
+ //#region src/commands/code.ts
44
+ const code = command({
45
+ name: "code",
46
+ description: `
47
+ Open the Powerhouse coding agent — a REPL backed by Mastra that has every
48
+ installed Powerhouse tool available as an agent tool.
49
+
50
+ Examples:
51
+ ph code Start the interactive REPL.
52
+ ph code "list my installed packs" One-shot agent prompt.
53
+ `,
54
+ args: codeArgs,
55
+ handler: async (args) => {
56
+ const { buildPhCodeCli } = await import("./cli-CFWMyGVU.mjs");
57
+ const cli = buildPhCodeCli();
58
+ const argv = [
59
+ "node",
60
+ "ph-code",
61
+ ...args.rest.length === 0 ? ["-i"] : args.rest
62
+ ];
63
+ await cli.run(argv);
64
+ }
65
+ });
66
+ const connect = subcommands({
67
+ name: "connect",
68
+ description: `Powerhouse Connect commands. Use with \`studio\`, \`build\` or \`preview\`. Defaults to \`studio\` if not specified.`,
69
+ cmds: {
70
+ studio: command({
71
+ name: "studio",
72
+ description: `The studio command starts the Connect Studio, a development environment for building
73
+ and testing Powerhouse applications. It provides a visual interface for working with
74
+ your project.
75
+
76
+ This command:
77
+ 1. Starts a local Connect Studio server
78
+ 2. Provides a web interface for development
79
+ 3. Allows you to interact with your project components
80
+ 4. Supports various configuration options for customization
81
+ `,
82
+ args: connectStudioArgs,
83
+ handler: async (args) => {
84
+ if (args.debug) console.log(args);
85
+ const { runConnectStudio } = await import("./connect-studio-Dndkp0Q_.mjs");
86
+ await runConnectStudio(args);
87
+ }
88
+ }),
89
+ build: command({
90
+ name: "build",
91
+ description: `The Connect build command creates a production build with the project's local and
92
+ external packages included
93
+ `,
94
+ args: connectBuildArgs,
95
+ handler: async (args) => {
96
+ if (args.debug) console.log(args);
97
+ const { runConnectBuild } = await import("./connect-build-BXuIuTCu.mjs");
98
+ await runConnectBuild(args);
99
+ process.exit(0);
100
+ }
101
+ }),
102
+ preview: command({
103
+ name: "preview",
104
+ description: `The Connect preview command previews a built Connect project.
105
+ NOTE: You must run \`ph connect build\` first
106
+ `,
107
+ args: connectPreviewArgs,
108
+ handler: async (args) => {
109
+ if (args.debug) console.log(args);
110
+ const { runConnectPreview } = await import("./connect-preview-CaEiWmqU.mjs");
111
+ await runConnectPreview(args);
112
+ }
113
+ })
114
+ }
115
+ });
116
+ //#endregion
117
+ //#region src/commands/generate-all.ts
118
+ const generateAllCmd = command({
119
+ name: "all",
120
+ description: "Re-generate all modules in the current project",
121
+ args: {},
122
+ handler: async () => {
123
+ const { startGenerateAll } = await import("./generate-all-DaXXjoms.mjs");
124
+ await startGenerateAll(process.cwd());
125
+ process.exit(0);
126
+ }
127
+ });
128
+ //#endregion
129
+ //#region src/commands/generate-app.ts
130
+ const generateAppCmd = command({
131
+ name: "app",
132
+ description: "Generate a drive app",
133
+ args: {
134
+ name: option({
135
+ type: optional(string),
136
+ long: "name",
137
+ short: "n",
138
+ description: "The name of the drive app to generate"
139
+ }),
140
+ allowedDocumentTypes: multioption({
141
+ type: optional(array(string)),
142
+ long: "document-types",
143
+ short: "t",
144
+ description: "The document types allowed by the new app"
145
+ }),
146
+ dir: option({
147
+ type: optional(Directory),
148
+ long: "dir",
149
+ short: "d",
150
+ description: "Name of the directory of an existing app to re-generate"
151
+ }),
152
+ disableDragAndDrop: flag({
153
+ type: boolean,
154
+ long: "disable-drag-and-drop",
155
+ description: "Do not allow drag and drop in this drive app.",
156
+ defaultValue: () => false,
157
+ defaultValueIsSerializable: true
158
+ }),
159
+ all: flag({
160
+ long: "all",
161
+ short: "a",
162
+ description: "Re-generate all existing apps in the current project"
163
+ }),
164
+ ...debugArgs
165
+ },
166
+ handler: async (args) => {
167
+ const { startGenerateApp } = await import("./generate-app-GvQeAG4w.mjs");
168
+ await startGenerateApp(args, process.cwd());
169
+ process.exit(0);
170
+ }
171
+ });
172
+ //#endregion
173
+ //#region src/commands/generate-document-model.ts
174
+ const generateDocumentModelCmd = command({
175
+ name: "document-model",
176
+ aliases: ["doc"],
177
+ description: "Generate a document model",
178
+ args: {
179
+ file: option({
180
+ type: optional(File),
181
+ long: "file",
182
+ short: "f",
183
+ description: "Path to the file to generate the document model from"
184
+ }),
185
+ dir: option({
186
+ type: optional(Directory),
187
+ long: "dir",
188
+ short: "d",
189
+ description: "Name of the directory of an existing document model to re-generate"
190
+ }),
191
+ all: flag({
192
+ long: "all",
193
+ short: "a",
194
+ description: "Re-generate all existing document models in the current project"
195
+ }),
196
+ ...debugArgs
197
+ },
198
+ handler: async (args) => {
199
+ const { startGenerateDocumentModel } = await import("./generate-document-model-Dnik0rKd.mjs");
200
+ await startGenerateDocumentModel(args, process.cwd());
201
+ process.exit(0);
202
+ }
203
+ });
204
+ //#endregion
205
+ //#region src/commands/generate-editor.ts
206
+ const generateEditorCmd = command({
207
+ name: "editor",
208
+ description: "Generate a document editor",
209
+ args: {
210
+ name: option({
211
+ type: optional(string),
212
+ long: "name",
213
+ short: "n",
214
+ description: "The name of the document editor to generate"
215
+ }),
216
+ documentType: option({
217
+ type: optional(string),
218
+ long: "document-type",
219
+ short: "t",
220
+ description: "The document type for the new editor"
221
+ }),
222
+ dir: option({
223
+ type: optional(Directory),
224
+ long: "dir",
225
+ short: "d",
226
+ description: "Name of the directory of an existing editor to re-generate"
227
+ }),
228
+ all: flag({
229
+ long: "all",
230
+ short: "a",
231
+ description: "Re-generate all existing editors in the current project"
232
+ }),
233
+ ...debugArgs
234
+ },
235
+ handler: async (args) => {
236
+ const { startGenerateEditor } = await import("./generate-editor-BNN2OmmX.mjs");
237
+ await startGenerateEditor(args, process.cwd());
238
+ process.exit(0);
239
+ }
240
+ });
241
+ //#endregion
242
+ //#region src/commands/generate-migration-file.ts
243
+ const generateMigrationFileCmd = command({
244
+ name: "migration-file",
245
+ description: "Generate a migration file",
246
+ args: {
247
+ migrationFile: option({
248
+ type: string,
249
+ long: "path",
250
+ short: "p",
251
+ description: "Path to the migration file"
252
+ }),
253
+ schemaFile: option({
254
+ type: optional(string),
255
+ long: "schema-file",
256
+ description: "Path to the output file. Defaults to './schema.ts'"
257
+ }),
258
+ ...debugArgs
259
+ },
260
+ handler: async ({ migrationFile, schemaFile }) => {
261
+ await generateDBSchema({
262
+ migrationFile: path.join(process.cwd(), migrationFile),
263
+ schemaFile: schemaFile ? path.join(process.cwd(), schemaFile) : void 0
264
+ });
265
+ process.exit(0);
266
+ }
267
+ });
268
+ const generateProcessorCmd = command({
269
+ name: "processor",
270
+ description: "Generate a processor",
271
+ args: {
272
+ name: option({
273
+ type: optional(string),
274
+ long: "name",
275
+ short: "n",
276
+ description: "The name of the processor to generate"
277
+ }),
278
+ type: option({
279
+ type: oneOf(["analytics", "relationalDb"]),
280
+ long: "type",
281
+ description: "The type of processor to generate",
282
+ defaultValue: () => "analytics",
283
+ defaultValueIsSerializable: true
284
+ }),
285
+ documentTypes: multioption({
286
+ type: array(string),
287
+ long: "document-types",
288
+ short: "t",
289
+ description: "The document types the processor will run on",
290
+ defaultValue: () => [],
291
+ defaultValueIsSerializable: true
292
+ }),
293
+ apps: multioption({
294
+ long: "apps",
295
+ type: { from(processorApps) {
296
+ if (processorApps.length === 0) throw new Error(`No arguments provided for processor apps. Must be "connect" and/or "switchboard"`);
297
+ if (processorApps.length > 2) throw new Error(`Too many arguments provided for processor apps. Must be "connect" and/or "switchboard"`);
298
+ const allowed = new Set(PROCESSOR_APPS);
299
+ if (!processorApps.every((p) => allowed.has(p))) throw new Error(`Processor apps can only be "connect" and/or "switchboard".`);
300
+ return Promise.resolve(processorApps);
301
+ } },
302
+ description: "Whether the processor will run in switchboard (nodejs), connect (browser), or both",
303
+ defaultValue: () => ["switchboard", "connect"],
304
+ defaultValueIsSerializable: true
305
+ }),
306
+ dir: option({
307
+ type: optional(Directory),
308
+ long: "dir",
309
+ short: "d",
310
+ description: "Name of the directory of an existing processor to re-generate"
311
+ }),
312
+ all: flag({
313
+ long: "all",
314
+ short: "a",
315
+ description: "Re-generate all existing processors in the current project"
316
+ }),
317
+ ...debugArgs
318
+ },
319
+ handler: async (args) => {
320
+ const { startGenerateProcessor } = await import("./generate-processor-CCSW2Ed2.mjs");
321
+ await startGenerateProcessor(args, process.cwd());
322
+ process.exit(0);
323
+ }
324
+ });
325
+ //#endregion
326
+ //#region src/commands/generate-subgraph.ts
327
+ const generateSubgraphCmd = command({
328
+ name: "subgraph",
329
+ description: "Generate a subgraph",
330
+ args: {
331
+ name: option({
332
+ type: optional(string),
333
+ long: "name",
334
+ short: "n",
335
+ description: "The name of the subgraph to generate"
336
+ }),
337
+ dir: option({
338
+ type: optional(Directory),
339
+ long: "dir",
340
+ short: "d",
341
+ description: "Name of the directory of an existing subgraph to re-generate"
342
+ }),
343
+ all: flag({
344
+ long: "all",
345
+ short: "a",
346
+ description: "Re-generate all existing subgraphs in the current project"
347
+ }),
348
+ ...debugArgs
349
+ },
350
+ handler: async (args) => {
351
+ const { startGenerateSubgraph } = await import("./generate-subgraph-B-d3J6hU.mjs");
352
+ await startGenerateSubgraph(args, process.cwd());
353
+ process.exit(0);
354
+ }
355
+ });
356
+ //#endregion
357
+ //#region src/commands/generate.ts
358
+ const generate = subcommands({
359
+ name: "generate",
360
+ 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.`,
361
+ cmds: {
362
+ all: generateAllCmd,
363
+ "document-model": generateDocumentModelCmd,
364
+ editor: generateEditorCmd,
365
+ app: generateAppCmd,
366
+ processor: generateProcessorCmd,
367
+ subgraph: generateSubgraphCmd,
368
+ "migration-file": generateMigrationFileCmd
369
+ }
370
+ });
371
+ //#endregion
372
+ //#region src/commands/init.ts
373
+ const init = command({
374
+ name: "init",
375
+ description: "Initialize a new project",
376
+ args: initArgs,
377
+ handler: async (args) => {
378
+ if (args.debug) console.log({ args });
379
+ const { startInit } = await import("./init-BgKiiFju.mjs");
380
+ await startInit(args);
381
+ process.exit(0);
382
+ }
383
+ });
384
+ //#endregion
385
+ //#region src/commands/inspect.ts
386
+ const inspect = command({
387
+ name: "inspect",
388
+ description: `
389
+ The inspect command examines and provides detailed information about a Powerhouse package.
390
+ It helps you understand the structure, dependencies, and configuration of packages in
391
+ your project.
392
+
393
+ This command:
394
+ 1. Analyzes the specified package
395
+ 2. Retrieves detailed information about its structure and configuration
396
+ 3. Displays package metadata, dependencies, and other relevant information
397
+ 4. Helps troubleshoot package-related issues`,
398
+ aliases: ["is"],
399
+ args: inspectArgs,
400
+ handler: async (args) => {
401
+ if (args.debug) console.log(args);
402
+ const { startInspect } = await import("./inspect-czss6pZb.mjs");
403
+ startInspect(args);
404
+ process.exit(0);
405
+ }
406
+ });
407
+ //#endregion
408
+ //#region src/commands/install.ts
409
+ const install = command({
410
+ name: "install",
411
+ aliases: ["add", "i"],
412
+ description: `
413
+ The install command adds Powerhouse dependencies to your project.
414
+
415
+ By default it only registers the package in powerhouse.config.json with
416
+ provider "registry" — Connect will load it from the registry CDN at runtime.
417
+
418
+ With --local, the package is also installed into node_modules and marked
419
+ as provider "local" — it will be bundled into ph connect build so the
420
+ preview works without the registry being reachable.
421
+
422
+ Resolution order for the registry URL:
423
+ --registry flag > PH_REGISTRY_URL env > powerhouse.config.json > default
424
+ `,
425
+ args: installArgs,
426
+ handler: async (args) => {
427
+ if (args.debug) console.log(args);
428
+ const { projectPath, localProjectPath, globalProjectPath, packageManager, isGlobal } = await getPowerhouseProjectInfo(args);
429
+ if (!projectPath) throw new Error(`Could not find project path to install from.`);
430
+ const registryUrl = resolveRegistryUrl({
431
+ registry: args.registry,
432
+ projectPath
433
+ });
434
+ if (args.debug) console.log(">>> registryUrl", registryUrl);
435
+ const dependenciesWithVersions = await makeDependenciesWithVersions(args.dependencies, registryUrl);
436
+ if (args.debug) {
437
+ console.log(">>> parsedDependencies", dependenciesWithVersions);
438
+ console.log("\n>>> projectInfo", {
439
+ localProjectPath,
440
+ globalProjectPath,
441
+ packageManager,
442
+ isGlobal
443
+ });
444
+ }
445
+ if (args.local) {
446
+ if (dependenciesWithVersions.length === 0) throw new Error("--local requires at least one package name (e.g. ph install --local @scope/pkg)");
447
+ try {
448
+ const specs = dependenciesWithVersions.map((d) => d.version ? `${d.name}@${d.version}` : d.name);
449
+ const scopes = /* @__PURE__ */ new Set();
450
+ for (const dep of dependenciesWithVersions) if (dep.name.startsWith("@")) {
451
+ const scope = dep.name.split("/")[0];
452
+ scopes.add(scope);
453
+ }
454
+ const scopeRegistryArgs = Array.from(scopes).map((scope) => `--${scope}:registry=${registryUrl}`);
455
+ const resolved = resolveCommand(packageManager, "add", [...specs, ...scopeRegistryArgs]);
456
+ if (!resolved) throw new Error(`Failed to resolve install command for package manager "${packageManager}".`);
457
+ const installCommand = `${resolved.command} ${resolved.args.join(" ")}`;
458
+ if (scopeRegistryArgs.length > 0) console.log(`Installing dependencies 📦 (routing ${Array.from(scopes).join(", ")} → ${registryUrl})...`);
459
+ else console.log("Installing dependencies 📦...");
460
+ console.log(`> ${installCommand}`);
461
+ execSync(installCommand, {
462
+ stdio: "inherit",
463
+ cwd: projectPath
464
+ });
465
+ console.log("Dependency installed successfully 🎉");
466
+ } catch (error) {
467
+ console.error("❌ Failed to install dependencies");
468
+ throw error;
469
+ }
470
+ }
471
+ try {
472
+ console.log("⚙️ Updating powerhouse config file...");
473
+ updateConfigFile(dependenciesWithVersions, projectPath, "install", args.local ? "local" : "registry", registryUrl);
474
+ console.log("Config file updated successfully 🎉");
475
+ } catch (error) {
476
+ console.error("❌ Failed to update config file");
477
+ throw error;
478
+ }
479
+ if (args.local) try {
480
+ console.log("⚙️ Updating styles.css file...");
481
+ updateStylesFile(dependenciesWithVersions, projectPath);
482
+ console.log("Styles file updated successfully 🎉");
483
+ } catch (error) {
484
+ console.error("❌ Failed to update styles file");
485
+ throw error;
486
+ }
487
+ process.exit(0);
488
+ }
489
+ });
490
+ //#endregion
491
+ //#region src/commands/migrate.ts
492
+ const migrate$1 = command({
493
+ name: "migrate",
494
+ args: migrateArgs,
495
+ description: "Run migrations",
496
+ handler: async (args) => {
497
+ if (args.debug) console.log(args);
498
+ const { startMigrate } = await import("./migrate-DLEG7ehb.mjs");
499
+ await startMigrate(args);
500
+ process.exit(0);
501
+ }
502
+ });
503
+ //#endregion
504
+ //#region src/services/registry-auth.ts
505
+ /**
506
+ * Mint a Renown bearer token bound to the given registry URL via the JWT
507
+ * `aud` claim. Throws if the user is not authenticated (`ph login` first).
508
+ *
509
+ * The audience binding is what lets the registry distinguish a token minted
510
+ * for it from one minted for a different service or registry.
511
+ */
512
+ async function mintRegistryAuthToken(registryUrl, expiresInSeconds) {
513
+ const renown = await getRenown();
514
+ if (!renown.user) throw new Error("Not authenticated with Renown. Run 'ph login' first.");
515
+ return (await generateAccessToken(renown, {
516
+ expiresIn: expiresInSeconds,
517
+ aud: registryUrl
518
+ })).token;
519
+ }
520
+ //#endregion
521
+ //#region src/commands/publish.ts
522
+ function hasTagFlag(args) {
523
+ return args.some((a) => a === "--tag" || a.startsWith("--tag="));
524
+ }
525
+ function isInteractive() {
526
+ return Boolean(process.stdin.isTTY) && !process.env.CI;
527
+ }
528
+ function readPrereleaseTag(projectPath) {
529
+ try {
530
+ const pkg = readPackageSync({ cwd: projectPath });
531
+ if (!pkg.version) return null;
532
+ const parts = prerelease(pkg.version);
533
+ if (!parts || parts.length === 0) return null;
534
+ const label = String(parts[0]);
535
+ if (!/^[a-z][a-z0-9-]*$/i.test(label)) return null;
536
+ return {
537
+ version: pkg.version,
538
+ tag: label
539
+ };
540
+ } catch {
541
+ return null;
542
+ }
543
+ }
544
+ const publish = command({
545
+ name: "publish",
546
+ description: `
547
+ Publish a package to the Powerhouse registry. This is a thin wrapper around npm publish
548
+ that automatically sets the registry URL.
549
+
550
+ This command:
551
+ 1. Resolves the registry URL (--registry flag > PH_REGISTRY_URL env > powerhouse.config.json > default)
552
+ 2. Checks authentication with the registry via npm whoami
553
+ 3. Forwards all additional arguments to npm publish
554
+ `,
555
+ args: publishArgs,
556
+ handler: async (args) => {
557
+ if (args.debug) console.log(args);
558
+ const { projectPath } = await getPowerhouseProjectInfo();
559
+ if (!projectPath) throw new Error("Could not find project path.");
560
+ const registryUrl = resolveRegistryUrl({
561
+ registry: args.registry,
562
+ projectPath
563
+ });
564
+ if (args.debug) console.log(">>> registryUrl", registryUrl);
565
+ let authToken;
566
+ try {
567
+ authToken = await mintRegistryAuthToken(registryUrl, 300);
568
+ if (args.debug) console.error(`>>> minted renown token for ${registryUrl} (5m TTL)`);
569
+ } catch (err) {
570
+ if (args.debug) console.error(`>>> renown token mint skipped: ${err.message}`);
571
+ try {
572
+ await checkNpmAuth(registryUrl);
573
+ } catch {
574
+ console.error(`Not authenticated with registry: ${registryUrl}`);
575
+ console.error(`Run: ph login (recommended) or npm adduser --registry ${registryUrl}`);
576
+ process.exit(1);
577
+ }
578
+ }
579
+ let forwardedArgs = args.forwardedArgs;
580
+ if (!hasTagFlag(forwardedArgs)) {
581
+ const prereleaseInfo = readPrereleaseTag(projectPath);
582
+ if (prereleaseInfo) {
583
+ const { version, tag } = prereleaseInfo;
584
+ if (!isInteractive()) {
585
+ console.error(`Detected prerelease version ${version}. npm requires an explicit dist-tag for prerelease publishes.`);
586
+ console.error(`Re-run with --tag <label> (e.g. --tag ${tag}) to proceed.`);
587
+ process.exit(1);
588
+ }
589
+ const enquirer = await import("enquirer");
590
+ let confirmed = false;
591
+ try {
592
+ confirmed = (await enquirer.default.prompt({
593
+ type: "confirm",
594
+ name: "confirmed",
595
+ message: `Detected prerelease version ${version}. Publish with --tag ${tag}?`,
596
+ initial: true
597
+ })).confirmed;
598
+ } catch {
599
+ confirmed = false;
600
+ }
601
+ if (!confirmed) {
602
+ console.error(`Aborted. To publish manually: npm publish --registry ${registryUrl} --tag <label>`);
603
+ process.exit(1);
604
+ }
605
+ forwardedArgs = [
606
+ "--tag",
607
+ tag,
608
+ ...forwardedArgs
609
+ ];
610
+ }
611
+ }
612
+ if (args.debug) console.log(">>> command", `npm publish --registry ${registryUrl} ${forwardedArgs.join(" ")}`);
613
+ console.log(`Publishing to ${registryUrl}...`);
614
+ const result = await npmPublish({
615
+ registryUrl,
616
+ cwd: projectPath,
617
+ args: forwardedArgs,
618
+ authToken
619
+ });
620
+ if (result.stdout) console.log(result.stdout);
621
+ process.exit(0);
622
+ }
623
+ });
624
+ //#endregion
625
+ //#region src/commands/registry-login.ts
626
+ const registryLogin = command({
627
+ name: "registry-login",
628
+ description: `
629
+ Log in to a Powerhouse registry using your Renown identity. Mints a longer-lived
630
+ bearer token (default 30 days) bound to the registry's audience and writes the
631
+ token into ~/.npmrc so raw 'npm publish' / 'npm install' work without further
632
+ setup.
633
+
634
+ Prerequisites:
635
+ Run 'ph login' first to establish a Renown identity.
636
+
637
+ Usage:
638
+ ph registry-login # uses powerhouse.config.json / PH_REGISTRY_URL
639
+ ph registry-login --registry https://registry.dev.vetra.io
640
+ ph registry-login --expiry 7d
641
+ `,
642
+ args: registryLoginArgs,
643
+ handler: async (args) => {
644
+ if (args.debug) console.log(args);
645
+ const projectPath = (await getPowerhouseProjectInfo().catch(() => null))?.projectPath ?? process.cwd();
646
+ const registryUrl = resolveRegistryUrl({
647
+ registry: args.registry,
648
+ projectPath
649
+ });
650
+ const { parseExpiry, formatExpiry } = await import("@renown/sdk/node");
651
+ const expiresIn = parseExpiry(args.expiry);
652
+ const npmrcPath = await writeRegistryAuthToken(registryUrl, await mintRegistryAuthToken(registryUrl, expiresIn));
653
+ console.log(`Logged in to ${registryUrl}`);
654
+ console.log(` Token expires in: ${formatExpiry(expiresIn)}`);
655
+ console.log(` Wrote: ${npmrcPath}`);
656
+ process.exit(0);
657
+ }
658
+ });
659
+ //#endregion
660
+ //#region src/commands/switchboard.ts
661
+ const switchboard = command({
662
+ name: "switchboard",
663
+ aliases: ["reactor"],
664
+ description: `
665
+ The switchboard command starts a local Switchboard instance, which acts as the document
666
+ processing engine for Powerhouse projects. It provides the infrastructure for document
667
+ models, processors, and real-time updates.
668
+
669
+ This command:
670
+ 1. Starts a local switchboard server
671
+ 2. Loads document models and processors
672
+ 3. Provides an API for document operations
673
+ 4. Enables real-time document processing
674
+ 5. Can authenticate with remote services using your identity from 'ph login'`,
675
+ args: switchboardArgs,
676
+ handler: async (args) => {
677
+ if (args.debug) console.log(args);
678
+ const { basePath, dbPath, migrate, migrateStatus } = args;
679
+ if (basePath) process.env.BASE_PATH = basePath;
680
+ if (migrate || migrateStatus) {
681
+ const { runSwitchboardMigrations } = await import("./switchboard-migrate-81jhmuWu.mjs");
682
+ await runSwitchboardMigrations({
683
+ dbPath,
684
+ statusOnly: migrateStatus
685
+ });
686
+ process.exit(0);
687
+ }
688
+ const { startSwitchboard } = await import("./switchboard-2B5VC_cr.mjs");
689
+ const { defaultDriveUrl, renown } = await startSwitchboard(args);
690
+ console.log(" ➜ Switchboard:", defaultDriveUrl);
691
+ if (renown) console.log(" ➜ Identity:", renown.did);
692
+ }
693
+ });
694
+ //#endregion
695
+ //#region src/commands/uninstall.ts
696
+ const uninstall = command({
697
+ name: "uninstall",
698
+ aliases: ["remove"],
699
+ description: `
700
+ The uninstall command removes Powerhouse dependencies from your project. It handles the
701
+ removal of packages, updates configuration files, and ensures proper cleanup.
702
+
703
+ This command:
704
+ 1. Uninstalls specified Powerhouse dependencies using your package manager
705
+ 2. Updates powerhouse.config.json to remove the dependencies
706
+ 3. Supports various uninstallation options and configurations
707
+ 4. Works with ${AGENTS.join(", ")} package managers
708
+ `,
709
+ args: uninstallArgs,
710
+ handler: async (args) => {
711
+ if (args.debug) console.log(args);
712
+ const { projectPath, localProjectPath, globalProjectPath, packageManager, isGlobal } = await getPowerhouseProjectInfo(args);
713
+ if (!projectPath) throw new Error(`Could not find project path to uninstall from`);
714
+ const dependenciesWithVersions = await makeDependenciesWithVersions(args.dependencies);
715
+ if (args.debug) console.log(">>> parsedDependencies", dependenciesWithVersions);
716
+ if (args.debug) console.log("\n>>> projectInfo", {
717
+ localProjectPath,
718
+ globalProjectPath,
719
+ packageManager,
720
+ isGlobal
721
+ });
722
+ try {
723
+ console.log("Uninstalling dependencies 📦 ...");
724
+ execSync(await getPowerhouseProjectUninstallCommand(packageManager), {
725
+ stdio: "inherit",
726
+ cwd: projectPath
727
+ });
728
+ console.log("Dependency uninstalled successfully 🎉");
729
+ } catch (error) {
730
+ console.error("❌ Failed to uninstall dependencies");
731
+ throw error;
732
+ }
733
+ try {
734
+ console.log("⚙️ Updating powerhouse config file...");
735
+ updateConfigFile(dependenciesWithVersions, projectPath, "uninstall");
736
+ console.log("Config file updated successfully 🎉");
737
+ } catch (error) {
738
+ console.error("❌ Failed to update config file");
739
+ throw error;
740
+ }
741
+ try {
742
+ console.log("⚙️ Updating styles.css file...");
743
+ removeStylesImports(dependenciesWithVersions, projectPath);
744
+ console.log("Styles file updated successfully 🎉");
745
+ } catch (error) {
746
+ console.error("❌ Failed to update styles file");
747
+ throw error;
748
+ }
749
+ process.exit(0);
750
+ }
751
+ });
752
+ //#endregion
753
+ //#region src/commands/unpublish.ts
754
+ const unpublish = command({
755
+ name: "unpublish",
756
+ description: `
757
+ Unpublish a package from the Powerhouse registry. This is a thin wrapper around
758
+ npm unpublish that automatically targets the Powerhouse registry and never
759
+ reaches npmjs.org.
760
+
761
+ Forms:
762
+ ph unpublish # unpublish <name>@<version> from cwd's package.json
763
+ ph unpublish <name> # unpublish the whole package (all versions)
764
+ ph unpublish <name>@<version> # unpublish a single version
765
+
766
+ Flags:
767
+ --registry <url> # override registry URL
768
+ --yes, -y # skip the confirmation prompt
769
+ `,
770
+ args: unpublishArgs,
771
+ handler: async (args) => {
772
+ if (args.debug) console.log(args);
773
+ const { projectPath } = await getPowerhouseProjectInfo();
774
+ if (!projectPath) throw new Error("Could not find project path.");
775
+ const registryUrl = resolveRegistryUrl({
776
+ registry: args.registry,
777
+ projectPath
778
+ });
779
+ const spec = resolveSpec(args.spec, projectPath);
780
+ if (!spec) {
781
+ console.error("No package spec provided and could not read name/version from package.json.");
782
+ process.exit(1);
783
+ }
784
+ if (args.debug) {
785
+ console.log(">>> registryUrl", registryUrl);
786
+ console.log(">>> spec", spec);
787
+ }
788
+ try {
789
+ await checkNpmAuth(registryUrl);
790
+ } catch {
791
+ console.error(`Not authenticated with registry: ${registryUrl}`);
792
+ console.error(`Run: npm adduser --registry ${registryUrl}`);
793
+ process.exit(1);
794
+ }
795
+ if (!args.yes) {
796
+ if (!await confirm(`Unpublish ${spec} from ${registryUrl}? [y/N] `)) {
797
+ console.log("Aborted.");
798
+ process.exit(0);
799
+ }
800
+ }
801
+ if (args.debug) console.log(">>> command", `npm unpublish ${spec} --registry ${registryUrl} --force ${args.forwardedArgs.join(" ")}`);
802
+ console.log(`Unpublishing ${spec} from ${registryUrl}...`);
803
+ try {
804
+ const result = await npmUnpublish({
805
+ registryUrl,
806
+ cwd: projectPath,
807
+ spec,
808
+ args: args.forwardedArgs
809
+ });
810
+ if (result.stdout) console.log(result.stdout);
811
+ process.exit(0);
812
+ } catch (err) {
813
+ console.error(err instanceof Error ? err.message : String(err));
814
+ process.exit(1);
815
+ }
816
+ }
817
+ });
818
+ function resolveSpec(explicit, projectPath) {
819
+ if (explicit) return explicit;
820
+ try {
821
+ const pkg = readPackageSync({ cwd: projectPath });
822
+ if (!pkg.name) return null;
823
+ return pkg.version ? `${pkg.name}@${pkg.version}` : pkg.name;
824
+ } catch {
825
+ return null;
826
+ }
827
+ }
828
+ async function confirm(prompt) {
829
+ const rl = createInterface({
830
+ input: process.stdin,
831
+ output: process.stdout
832
+ });
833
+ try {
834
+ const answer = await rl.question(prompt);
835
+ return /^y(es)?$/i.test(answer.trim());
836
+ } finally {
837
+ rl.close();
838
+ }
839
+ }
840
+ //#endregion
841
+ //#region src/commands/ph-cli-commands.ts
842
+ const phCliCommands = {
843
+ init,
844
+ code,
845
+ generate,
846
+ vetra: command({
847
+ name: "vetra",
848
+ description: `
849
+ The vetra command sets up a Vetra development environment for working with Vetra projects.
850
+ It starts a Vetra Switchboard and optionally Connect Studio, enabling document collaboration
851
+ and real-time processing with a "Vetra" drive or connection to remote drives.
852
+
853
+ This command:
854
+ 1. Starts a Vetra Switchboard with a "Vetra" drive for document storage
855
+ 2. Optionally connects to remote drives instead of creating a local drive
856
+ 3. Starts Connect Studio pointing to the Switchboard for user interaction (unless disabled)
857
+ 4. Enables real-time updates, collaboration, and code generation`,
858
+ args: vetraArgs,
859
+ handler: async (args) => {
860
+ if (args.debug) console.log(args);
861
+ const { startVetra } = await import("./vetra--a0x272X.mjs");
862
+ await startVetra(args);
863
+ }
864
+ }),
865
+ connect,
866
+ build: build$1,
867
+ publish,
868
+ unpublish,
869
+ "access-token": accessToken,
870
+ "registry-login": registryLogin,
871
+ inspect,
872
+ list,
873
+ migrate: migrate$1,
874
+ switchboard,
875
+ login,
876
+ logout,
877
+ install,
878
+ uninstall
879
+ };
880
+ const phCli = subcommands({
881
+ name: "ph-cli",
882
+ description: PH_CLI_DESCRIPTION,
883
+ version: getVersion(),
884
+ cmds: phCliCommands
885
+ });
886
+ //#endregion
887
+ //#region src/cli.ts
888
+ async function main() {
889
+ assertNodeVersion();
890
+ await initCliTelemetry({
891
+ cliName: "ph-cli",
892
+ release: getVersion()
893
+ });
894
+ const args = process.argv.slice(2);
895
+ const hasNoArgs = args.length === 0;
896
+ const isHelp = args.some((arg) => arg === "--help" || arg === "-h");
897
+ const isTopLevelHelp = isHelp && args.length === 1;
898
+ const cli = hasNoArgs || isTopLevelHelp ? phCliHelp : phCli;
899
+ const [command, ...restArgs] = args;
900
+ if (command === "connect" && ![
901
+ "studio",
902
+ "build",
903
+ "preview"
904
+ ].includes(args[1]) && !isHelp) await run(cli, [
905
+ "connect",
906
+ "studio",
907
+ ...restArgs
908
+ ]);
909
+ else await run(cli, args);
910
+ }
911
+ await main().catch(async (error) => {
912
+ const isDebug = process.argv.slice(2).includes("--debug");
913
+ await captureCliError(error);
914
+ if (isDebug) throw error;
915
+ if (error instanceof Error) {
916
+ console.error(error.message);
917
+ process.exit(1);
918
+ } else throw error;
919
+ });
920
+ //#endregion
921
+ export {};
922
+
923
+ //# sourceMappingURL=cli.mjs.map