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