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