@powerhousedao/ph-cli 6.2.3-dev.55 → 6.2.3-dev.57

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