@powerhousedao/ph-cli 6.0.2-staging.0 → 6.0.2-staging.10
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/README.md +2 -2
- package/dist/assign-env-vars-W-lZmdMi.mjs +18 -0
- package/dist/assign-env-vars-W-lZmdMi.mjs.map +1 -0
- package/dist/auth-AR3VxAIk.mjs +18 -0
- package/dist/auth-AR3VxAIk.mjs.map +1 -0
- package/dist/auth-BNkN6kS9.mjs +4 -0
- package/dist/build-CqtYNjiI.mjs +4 -0
- package/dist/build-vccTv_Jp.mjs +49 -0
- package/dist/build-vccTv_Jp.mjs.map +1 -0
- package/dist/cli.d.mts +1 -0
- package/dist/cli.mjs +1199 -0
- package/dist/cli.mjs.map +1 -0
- package/dist/connect-build-B7I7HJu0.mjs +38 -0
- package/dist/connect-build-B7I7HJu0.mjs.map +1 -0
- package/dist/connect-preview-CNJkhtxL.mjs +30 -0
- package/dist/connect-preview-CNJkhtxL.mjs.map +1 -0
- package/dist/connect-studio-DTdSFftL.mjs +31 -0
- package/dist/connect-studio-DTdSFftL.mjs.map +1 -0
- package/dist/connect-studio-DySbZFEc.mjs +5 -0
- package/dist/generate-all-Cj8zjFhN.mjs +15 -0
- package/dist/generate-all-Cj8zjFhN.mjs.map +1 -0
- package/dist/generate-app-KE0rbE-b.mjs +38 -0
- package/dist/generate-app-KE0rbE-b.mjs.map +1 -0
- package/dist/generate-document-model-Cut44i6D.mjs +24 -0
- package/dist/generate-document-model-Cut44i6D.mjs.map +1 -0
- package/dist/generate-editor-DmSzWm3W.mjs +38 -0
- package/dist/generate-editor-DmSzWm3W.mjs.map +1 -0
- package/dist/generate-processor-B-fChg4W.mjs +30 -0
- package/dist/generate-processor-B-fChg4W.mjs.map +1 -0
- package/dist/generate-subgraph-C6dWIQzP.mjs +28 -0
- package/dist/generate-subgraph-C6dWIQzP.mjs.map +1 -0
- package/dist/init-Cw_5H_Z1.mjs +128 -0
- package/dist/init-Cw_5H_Z1.mjs.map +1 -0
- package/dist/inspect-BwuBW_zW.mjs +48 -0
- package/dist/inspect-BwuBW_zW.mjs.map +1 -0
- package/dist/migrate-CfgiCNQo.mjs +83 -0
- package/dist/migrate-CfgiCNQo.mjs.map +1 -0
- package/dist/registry-auth-CNH84uo4.mjs +25 -0
- package/dist/registry-auth-CNH84uo4.mjs.map +1 -0
- package/dist/scripts/generate-commands-docs.ts +14 -0
- package/dist/scripts/setup.sh +3 -3
- package/dist/switchboard-CERuSM8r.mjs +75 -0
- package/dist/switchboard-CERuSM8r.mjs.map +1 -0
- package/dist/switchboard-ChH1PMaE.mjs +4 -0
- package/dist/switchboard-migrate-BumRp7rC.mjs +53 -0
- package/dist/switchboard-migrate-BumRp7rC.mjs.map +1 -0
- package/dist/switchboard-reset-1YcJEVqc.mjs +87 -0
- package/dist/switchboard-reset-1YcJEVqc.mjs.map +1 -0
- package/dist/utils-C6581aex.mjs +4 -0
- package/dist/utils-mth8NsDA.mjs +165 -0
- package/dist/utils-mth8NsDA.mjs.map +1 -0
- package/dist/vetra-yCsUKy_u.mjs +425 -0
- package/dist/vetra-yCsUKy_u.mjs.map +1 -0
- package/package.json +31 -26
- package/dist/bundle.d.ts +0 -2
- package/dist/bundle.d.ts.map +0 -1
- package/dist/scripts/generate-commands-docs.d.ts +0 -2
- package/dist/scripts/generate-commands-docs.d.ts.map +0 -1
- package/dist/src/cli.d.ts +0 -3
- package/dist/src/cli.d.ts.map +0 -1
- package/dist/src/cli.js +0 -395510
- package/dist/src/commands/access-token.d.ts +0 -14
- package/dist/src/commands/access-token.d.ts.map +0 -1
- package/dist/src/commands/connect.d.ts +0 -249
- package/dist/src/commands/connect.d.ts.map +0 -1
- package/dist/src/commands/generate.d.ts +0 -62
- package/dist/src/commands/generate.d.ts.map +0 -1
- package/dist/src/commands/index.d.ts +0 -13
- package/dist/src/commands/index.d.ts.map +0 -1
- package/dist/src/commands/inspect.d.ts +0 -12
- package/dist/src/commands/inspect.d.ts.map +0 -1
- package/dist/src/commands/install.d.ts +0 -22
- package/dist/src/commands/install.d.ts.map +0 -1
- package/dist/src/commands/list.d.ts +0 -10
- package/dist/src/commands/list.d.ts.map +0 -1
- package/dist/src/commands/login.d.ts +0 -24
- package/dist/src/commands/login.d.ts.map +0 -1
- package/dist/src/commands/logout.d.ts +0 -6
- package/dist/src/commands/logout.d.ts.map +0 -1
- package/dist/src/commands/migrate.d.ts +0 -12
- package/dist/src/commands/migrate.d.ts.map +0 -1
- package/dist/src/commands/ph-cli-commands.d.ts +0 -419
- package/dist/src/commands/ph-cli-commands.d.ts.map +0 -1
- package/dist/src/commands/ph-cli-help.d.ts +0 -400
- package/dist/src/commands/ph-cli-help.d.ts.map +0 -1
- package/dist/src/commands/ph-cli.d.ts +0 -506
- package/dist/src/commands/ph-cli.d.ts.map +0 -1
- package/dist/src/commands/service.d.ts +0 -12
- package/dist/src/commands/service.d.ts.map +0 -1
- package/dist/src/commands/switchboard.d.ts +0 -46
- package/dist/src/commands/switchboard.d.ts.map +0 -1
- package/dist/src/commands/uninstall.d.ts +0 -22
- package/dist/src/commands/uninstall.d.ts.map +0 -1
- package/dist/src/commands/vetra.d.ts +0 -64
- package/dist/src/commands/vetra.d.ts.map +0 -1
- package/dist/src/get-version.d.ts +0 -2
- package/dist/src/get-version.d.ts.map +0 -1
- package/dist/src/help.d.ts +0 -65
- package/dist/src/help.d.ts.map +0 -1
- package/dist/src/services/auth.d.ts +0 -21
- package/dist/src/services/auth.d.ts.map +0 -1
- package/dist/src/services/connect-build.d.ts +0 -3
- package/dist/src/services/connect-build.d.ts.map +0 -1
- package/dist/src/services/connect-preview.d.ts +0 -3
- package/dist/src/services/connect-preview.d.ts.map +0 -1
- package/dist/src/services/connect-studio.d.ts +0 -4
- package/dist/src/services/connect-studio.d.ts.map +0 -1
- package/dist/src/services/generate.d.ts +0 -3
- package/dist/src/services/generate.d.ts.map +0 -1
- package/dist/src/services/inspect.d.ts +0 -3
- package/dist/src/services/inspect.d.ts.map +0 -1
- package/dist/src/services/migrate.d.ts +0 -3
- package/dist/src/services/migrate.d.ts.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.d.ts +0 -23
- package/dist/src/services/switchboard.d.ts.map +0 -1
- package/dist/src/services/vetra.d.ts +0 -3
- package/dist/src/services/vetra.d.ts.map +0 -1
- package/dist/src/types.d.ts +0 -28
- package/dist/src/types.d.ts.map +0 -1
- package/dist/src/utils/assign-env-vars.d.ts +0 -3
- package/dist/src/utils/assign-env-vars.d.ts.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/constants.d.ts +0 -2
- package/dist/src/utils/constants.d.ts.map +0 -1
- package/dist/src/utils/resolve-connect-dirs.d.ts +0 -5
- package/dist/src/utils/resolve-connect-dirs.d.ts.map +0 -1
- package/dist/src/utils.d.ts +0 -112
- package/dist/src/utils.d.ts.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
|
@@ -0,0 +1,128 @@
|
|
|
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]="1835da68-34a4-5f33-9a4c-08c3b7cb5d9c")}catch(e){}}();
|
|
3
|
+
import { handleMutuallyExclusiveOptions, parsePackageManager, parseTag } from "@powerhousedao/shared/clis";
|
|
4
|
+
import { createProject } from "@powerhousedao/codegen";
|
|
5
|
+
import chalk from "chalk";
|
|
6
|
+
import { kebabCase } from "change-case";
|
|
7
|
+
import enquirer from "enquirer";
|
|
8
|
+
import { clean, valid } from "semver";
|
|
9
|
+
import { createVetraDocument, getVetraDocuments } from "@powerhousedao/common/utils";
|
|
10
|
+
//#region src/utils/validate-remote-drive.ts
|
|
11
|
+
/**
|
|
12
|
+
* Sets up a remote drive for initialization by validating and creating
|
|
13
|
+
* a Vetra document if needed.
|
|
14
|
+
* Returns true if setup succeeds, false if it should stop execution.
|
|
15
|
+
*/
|
|
16
|
+
async function setupRemoteDrive(remoteDriveUrl) {
|
|
17
|
+
try {
|
|
18
|
+
const driveId = remoteDriveUrl.split("/").pop();
|
|
19
|
+
if (!remoteDriveUrl || remoteDriveUrl.trim() === "") {
|
|
20
|
+
console.error("❌ Remote drive URL is required");
|
|
21
|
+
return false;
|
|
22
|
+
}
|
|
23
|
+
const url = new URL(remoteDriveUrl);
|
|
24
|
+
const basePath = url.pathname.replace(/\/d\/[^/]+\/?$/, "");
|
|
25
|
+
const graphqlEndpoint = `${url.protocol}//${url.host}${basePath}/graphql`;
|
|
26
|
+
let documents = await getVetraDocuments(graphqlEndpoint, driveId);
|
|
27
|
+
if (documents.length === 0) {
|
|
28
|
+
console.log("No vetra package document found in the provided drive, creating one...");
|
|
29
|
+
try {
|
|
30
|
+
await createVetraDocument(graphqlEndpoint, driveId, "vetra-package");
|
|
31
|
+
documents = await getVetraDocuments(graphqlEndpoint, driveId);
|
|
32
|
+
if (documents.length === 0) {
|
|
33
|
+
console.error("❌ Failed to create vetra package document in the remote drive");
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
console.log("✅ Vetra package document created successfully");
|
|
37
|
+
} catch (createError) {
|
|
38
|
+
console.error("❌ Failed to create vetra package document:", createError);
|
|
39
|
+
return false;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (documents.length > 1) console.warn("⚠️ Multiple vetra package documents were found in the provided remote drive, this might be an error in your remote drive");
|
|
43
|
+
if (documents.some((doc) => doc.githubUrl)) {
|
|
44
|
+
console.error("❌ The remote drive provided already has been configured with a github url, please use the checkout command instead: ph checkout --remote-drive <remote drive url>");
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
return true;
|
|
48
|
+
} catch (error) {
|
|
49
|
+
console.error("❌ Unable to fetch remote drive info:", error);
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
//#endregion
|
|
54
|
+
//#region src/services/init.ts
|
|
55
|
+
async function startInit(args) {
|
|
56
|
+
const { namePositional, nameOption, packageManager, npm, pnpm, yarn, bun, tag, version, dev, staging, remoteDrive } = args;
|
|
57
|
+
let name = namePositional ?? nameOption;
|
|
58
|
+
if (!name) {
|
|
59
|
+
const { prompt } = enquirer;
|
|
60
|
+
name = (await prompt([{
|
|
61
|
+
type: "input",
|
|
62
|
+
name: "name",
|
|
63
|
+
message: "What is the project name?",
|
|
64
|
+
required: true,
|
|
65
|
+
result: (value) => kebabCase(value)
|
|
66
|
+
}])).name;
|
|
67
|
+
}
|
|
68
|
+
if (!name) throw new Error("You must provide a name for your project.");
|
|
69
|
+
if (version !== void 0 && !valid(clean(version))) throw new Error(`Invalid version: ${version}`);
|
|
70
|
+
handleMutuallyExclusiveOptions({
|
|
71
|
+
tag,
|
|
72
|
+
version,
|
|
73
|
+
dev,
|
|
74
|
+
staging
|
|
75
|
+
}, "versioning strategy");
|
|
76
|
+
handleMutuallyExclusiveOptions({
|
|
77
|
+
npm,
|
|
78
|
+
pnpm,
|
|
79
|
+
yarn,
|
|
80
|
+
bun,
|
|
81
|
+
packageManager
|
|
82
|
+
}, "package manager");
|
|
83
|
+
const parsedPackageManager = parsePackageManager({
|
|
84
|
+
npm,
|
|
85
|
+
pnpm,
|
|
86
|
+
yarn,
|
|
87
|
+
bun,
|
|
88
|
+
packageManager
|
|
89
|
+
}) ?? "npm";
|
|
90
|
+
const parsedTag = parseTag({
|
|
91
|
+
tag,
|
|
92
|
+
dev,
|
|
93
|
+
staging
|
|
94
|
+
});
|
|
95
|
+
try {
|
|
96
|
+
if (remoteDrive) {
|
|
97
|
+
console.log(chalk.blue("\n⏳ Setting up remote drive...\n"));
|
|
98
|
+
await setupRemoteDrive(remoteDrive);
|
|
99
|
+
console.log(chalk.green("\n✅ Remote drive set up."));
|
|
100
|
+
}
|
|
101
|
+
console.log(chalk.bold("\n🚀 Initializing a new project...\n"));
|
|
102
|
+
await createProject({
|
|
103
|
+
...args,
|
|
104
|
+
name,
|
|
105
|
+
packageManager: parsedPackageManager,
|
|
106
|
+
tag: parsedTag
|
|
107
|
+
});
|
|
108
|
+
if (remoteDrive) {
|
|
109
|
+
console.log();
|
|
110
|
+
console.log("To link your project to GitHub:");
|
|
111
|
+
console.log();
|
|
112
|
+
console.log(" 1. Create a new repository on GitHub");
|
|
113
|
+
console.log(` 2. cd ${name}`);
|
|
114
|
+
console.log(" 3. git add . && git commit -m 'Initial commit'");
|
|
115
|
+
console.log(" 4. git remote add origin <your-github-url>");
|
|
116
|
+
console.log(` 5. git push -u origin main`);
|
|
117
|
+
console.log();
|
|
118
|
+
}
|
|
119
|
+
} catch (error) {
|
|
120
|
+
console.error("\n❌ Failed to initialize project: \n");
|
|
121
|
+
throw error;
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
//#endregion
|
|
125
|
+
export { startInit };
|
|
126
|
+
|
|
127
|
+
//# sourceMappingURL=init-Cw_5H_Z1.mjs.map
|
|
128
|
+
//# debugId=1835da68-34a4-5f33-9a4c-08c3b7cb5d9c
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init-Cw_5H_Z1.mjs","sources":["../src/utils/validate-remote-drive.ts","../src/services/init.ts"],"sourcesContent":["import {\n createVetraDocument,\n getVetraDocuments,\n} from \"@powerhousedao/common/utils\";\n\n/**\n * Sets up a remote drive for initialization by validating and creating\n * a Vetra document if needed.\n * Returns true if setup succeeds, false if it should stop execution.\n */\nexport async function setupRemoteDrive(\n remoteDriveUrl: string,\n): Promise<boolean> {\n try {\n // Parse driveId from URL\n const driveId = remoteDriveUrl.split(\"/\").pop();\n\n if (!remoteDriveUrl || remoteDriveUrl.trim() === \"\") {\n console.error(\"❌ Remote drive URL is required\");\n return false;\n }\n\n // Construct GraphQL endpoint from base URL, preserving any subpath\n // prefix (e.g. when the reactor is served behind a proxy at /api/reactor).\n const url = new URL(remoteDriveUrl);\n const basePath = url.pathname.replace(/\\/d\\/[^/]+\\/?$/, \"\");\n const graphqlEndpoint = `${url.protocol}//${url.host}${basePath}/graphql`;\n\n let documents = await getVetraDocuments(graphqlEndpoint, driveId!);\n\n if (documents.length === 0) {\n console.log(\n \"No vetra package document found in the provided drive, creating one...\",\n );\n try {\n await createVetraDocument(graphqlEndpoint, driveId!, \"vetra-package\");\n\n // Re-fetch documents after creation\n documents = await getVetraDocuments(graphqlEndpoint, driveId!);\n\n if (documents.length === 0) {\n console.error(\n \"❌ Failed to create vetra package document in the remote drive\",\n );\n return false;\n }\n\n console.log(\"✅ Vetra package document created successfully\");\n } catch (createError) {\n console.error(\n \"❌ Failed to create vetra package document:\",\n createError,\n );\n return false;\n }\n }\n\n if (documents.length > 1) {\n console.warn(\n \"⚠️ Multiple vetra package documents were found in the provided remote drive, this might be an error in your remote drive\",\n );\n }\n\n const hasGithubUrl = documents.some((doc) => doc.githubUrl);\n\n if (hasGithubUrl) {\n console.error(\n \"❌ The remote drive provided already has been configured with a github url, please use the checkout command instead: ph checkout --remote-drive <remote drive url>\",\n );\n return false;\n }\n\n return true;\n } catch (error) {\n console.error(\"❌ Unable to fetch remote drive info:\", error);\n return false;\n }\n}\n","import { createProject } from \"@powerhousedao/codegen\";\nimport {\n handleMutuallyExclusiveOptions,\n parsePackageManager,\n parseTag,\n} from \"@powerhousedao/shared/clis\";\nimport chalk from \"chalk\";\nimport { kebabCase } from \"change-case\";\nimport enquirer from \"enquirer\";\nimport { clean, valid } from \"semver\";\nimport type { InitArgs } from \"../types.js\";\nimport { setupRemoteDrive } from \"../utils/validate-remote-drive.js\";\n\nexport async function startInit(args: InitArgs) {\n const {\n namePositional,\n nameOption,\n packageManager,\n npm,\n pnpm,\n yarn,\n bun,\n tag,\n version,\n dev,\n staging,\n remoteDrive,\n } = args;\n\n let name = namePositional ?? nameOption;\n if (!name) {\n const { prompt } = enquirer;\n\n const result = await prompt<{ name: string }>([\n {\n type: \"input\",\n name: \"name\",\n message: \"What is the project name?\",\n required: true,\n result: (value) => kebabCase(value),\n },\n ]);\n name = result.name;\n }\n if (!name) {\n throw new Error(\"You must provide a name for your project.\");\n }\n\n if (version !== undefined && !valid(clean(version))) {\n throw new Error(`Invalid version: ${version}`);\n }\n\n handleMutuallyExclusiveOptions(\n {\n tag,\n version,\n dev,\n staging,\n },\n \"versioning strategy\",\n );\n\n handleMutuallyExclusiveOptions(\n {\n npm,\n pnpm,\n yarn,\n bun,\n packageManager,\n },\n \"package manager\",\n );\n\n const parsedPackageManager =\n parsePackageManager({\n npm,\n pnpm,\n yarn,\n bun,\n packageManager,\n }) ?? \"npm\";\n\n const parsedTag = parseTag({\n tag,\n dev,\n staging,\n });\n\n try {\n if (remoteDrive) {\n console.log(chalk.blue(\"\\n⏳ Setting up remote drive...\\n\"));\n await setupRemoteDrive(remoteDrive);\n console.log(chalk.green(\"\\n✅ Remote drive set up.\"));\n }\n\n console.log(chalk.bold(\"\\n🚀 Initializing a new project...\\n\"));\n await createProject({\n ...args,\n name,\n packageManager: parsedPackageManager,\n tag: parsedTag,\n });\n\n if (remoteDrive) {\n console.log();\n console.log(\"To link your project to GitHub:\");\n console.log();\n console.log(\" 1. Create a new repository on GitHub\");\n console.log(` 2. cd ${name}`);\n console.log(\" 3. git add . && git commit -m 'Initial commit'\");\n console.log(\" 4. git remote add origin <your-github-url>\");\n console.log(` 5. git push -u origin main`);\n console.log();\n }\n } catch (error) {\n console.error(\"\\n❌ Failed to initialize project: \\n\");\n throw error;\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;AAUA,eAAsB,iBACpB,gBACkB;AAClB,KAAI;EAEF,MAAM,UAAU,eAAe,MAAM,IAAI,CAAC,KAAK;AAE/C,MAAI,CAAC,kBAAkB,eAAe,MAAM,KAAK,IAAI;AACnD,WAAQ,MAAM,iCAAiC;AAC/C,UAAO;;EAKT,MAAM,MAAM,IAAI,IAAI,eAAe;EACnC,MAAM,WAAW,IAAI,SAAS,QAAQ,kBAAkB,GAAG;EAC3D,MAAM,kBAAkB,GAAG,IAAI,SAAS,IAAI,IAAI,OAAO,SAAS;EAEhE,IAAI,YAAY,MAAM,kBAAkB,iBAAiB,QAAS;AAElE,MAAI,UAAU,WAAW,GAAG;AAC1B,WAAQ,IACN,yEACD;AACD,OAAI;AACF,UAAM,oBAAoB,iBAAiB,SAAU,gBAAgB;AAGrE,gBAAY,MAAM,kBAAkB,iBAAiB,QAAS;AAE9D,QAAI,UAAU,WAAW,GAAG;AAC1B,aAAQ,MACN,gEACD;AACD,YAAO;;AAGT,YAAQ,IAAI,gDAAgD;YACrD,aAAa;AACpB,YAAQ,MACN,8CACA,YACD;AACD,WAAO;;;AAIX,MAAI,UAAU,SAAS,EACrB,SAAQ,KACN,4HACD;AAKH,MAFqB,UAAU,MAAM,QAAQ,IAAI,UAAU,EAEzC;AAChB,WAAQ,MACN,oKACD;AACD,UAAO;;AAGT,SAAO;UACA,OAAO;AACd,UAAQ,MAAM,wCAAwC,MAAM;AAC5D,SAAO;;;;;AC9DX,eAAsB,UAAU,MAAgB;CAC9C,MAAM,EACJ,gBACA,YACA,gBACA,KACA,MACA,MACA,KACA,KACA,SACA,KACA,SACA,gBACE;CAEJ,IAAI,OAAO,kBAAkB;AAC7B,KAAI,CAAC,MAAM;EACT,MAAM,EAAE,WAAW;AAWnB,UATe,MAAM,OAAyB,CAC5C;GACE,MAAM;GACN,MAAM;GACN,SAAS;GACT,UAAU;GACV,SAAS,UAAU,UAAU,MAAM;GACpC,CACF,CAAC,EACY;;AAEhB,KAAI,CAAC,KACH,OAAM,IAAI,MAAM,4CAA4C;AAG9D,KAAI,YAAY,KAAA,KAAa,CAAC,MAAM,MAAM,QAAQ,CAAC,CACjD,OAAM,IAAI,MAAM,oBAAoB,UAAU;AAGhD,gCACE;EACE;EACA;EACA;EACA;EACD,EACD,sBACD;AAED,gCACE;EACE;EACA;EACA;EACA;EACA;EACD,EACD,kBACD;CAED,MAAM,uBACJ,oBAAoB;EAClB;EACA;EACA;EACA;EACA;EACD,CAAC,IAAI;CAER,MAAM,YAAY,SAAS;EACzB;EACA;EACA;EACD,CAAC;AAEF,KAAI;AACF,MAAI,aAAa;AACf,WAAQ,IAAI,MAAM,KAAK,mCAAmC,CAAC;AAC3D,SAAM,iBAAiB,YAAY;AACnC,WAAQ,IAAI,MAAM,MAAM,2BAA2B,CAAC;;AAGtD,UAAQ,IAAI,MAAM,KAAK,uCAAuC,CAAC;AAC/D,QAAM,cAAc;GAClB,GAAG;GACH;GACA,gBAAgB;GAChB,KAAK;GACN,CAAC;AAEF,MAAI,aAAa;AACf,WAAQ,KAAK;AACb,WAAQ,IAAI,kCAAkC;AAC9C,WAAQ,KAAK;AACb,WAAQ,IAAI,yCAAyC;AACrD,WAAQ,IAAI,WAAW,OAAO;AAC9B,WAAQ,IAAI,mDAAmD;AAC/D,WAAQ,IAAI,+CAA+C;AAC3D,WAAQ,IAAI,+BAA+B;AAC3C,WAAQ,KAAK;;UAER,OAAO;AACd,UAAQ,MAAM,uCAAuC;AACrD,QAAM","debug_id":"1835da68-34a4-5f33-9a4c-08c3b7cb5d9c"}
|
|
@@ -0,0 +1,48 @@
|
|
|
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]="f74536d7-164b-57b0-ac72-c4f52831d602")}catch(e){}}();
|
|
3
|
+
import { s as getProjectInfo } from "./utils-mth8NsDA.mjs";
|
|
4
|
+
import fs from "node:fs";
|
|
5
|
+
//#region src/services/inspect.ts
|
|
6
|
+
function startInspect(args) {
|
|
7
|
+
if (args.debug) console.log(">>> command arguments", args);
|
|
8
|
+
const projectInfo = getProjectInfo(args.debug);
|
|
9
|
+
const { packageName } = args;
|
|
10
|
+
if (args.debug) console.log("\n>>> projectInfo", projectInfo);
|
|
11
|
+
try {
|
|
12
|
+
const loadManifest = (path) => JSON.parse(fs.readFileSync(path, "utf-8"));
|
|
13
|
+
const manifest = loadManifest(`${process.cwd()}/node_modules/${packageName}/dist/powerhouse.manifest.json`);
|
|
14
|
+
console.log(manifest.name);
|
|
15
|
+
if (manifest.documentModels) {
|
|
16
|
+
console.log("\nDocument Models:");
|
|
17
|
+
manifest.documentModels.forEach((model) => {
|
|
18
|
+
console.log(`- ${model.name} (${model.id})`);
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
if (manifest.editors) {
|
|
22
|
+
console.log("\nEditors:");
|
|
23
|
+
manifest.editors.forEach((editor) => {
|
|
24
|
+
console.log(`- ${editor.name} (${editor.id})`);
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
if (manifest.processors) {
|
|
28
|
+
console.log("\nProcessors:");
|
|
29
|
+
manifest.processors.forEach((processor) => {
|
|
30
|
+
console.log(`- ${processor.name} (${processor.id})`);
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
if (manifest.subgraphs) {
|
|
34
|
+
console.log("\nSubgraphs:");
|
|
35
|
+
manifest.subgraphs.forEach((subgraph) => {
|
|
36
|
+
console.log(`- ${subgraph.name} (${subgraph.id})`);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
} catch (e) {
|
|
40
|
+
if (args.debug) console.error(e);
|
|
41
|
+
else console.log("No manifest found in the package");
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
//#endregion
|
|
45
|
+
export { startInspect };
|
|
46
|
+
|
|
47
|
+
//# sourceMappingURL=inspect-BwuBW_zW.mjs.map
|
|
48
|
+
//# debugId=f74536d7-164b-57b0-ac72-c4f52831d602
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inspect-BwuBW_zW.mjs","sources":["../src/services/inspect.ts"],"sourcesContent":["import type { Manifest } from \"@powerhousedao/shared/document-model\";\nimport fs from \"node:fs\";\nimport type { InspectArgs } from \"../types.js\";\nimport { getProjectInfo } from \"../utils.js\";\nexport function startInspect(args: InspectArgs) {\n if (args.debug) {\n console.log(\">>> command arguments\", args);\n }\n\n const projectInfo = getProjectInfo(args.debug);\n const { packageName } = args;\n\n if (args.debug) {\n console.log(\"\\n>>> projectInfo\", projectInfo);\n }\n\n try {\n const loadManifest = (path: string) =>\n JSON.parse(fs.readFileSync(path, \"utf-8\")) as Manifest;\n const manifest = loadManifest(\n `${process.cwd()}/node_modules/${packageName}/dist/powerhouse.manifest.json`,\n );\n\n console.log(manifest.name);\n if (manifest.documentModels) {\n console.log(\"\\nDocument Models:\");\n manifest.documentModels.forEach((model) => {\n console.log(`- ${model.name} (${model.id})`);\n });\n }\n\n if (manifest.editors) {\n console.log(\"\\nEditors:\");\n manifest.editors.forEach((editor) => {\n console.log(`- ${editor.name} (${editor.id})`);\n });\n }\n\n if (manifest.processors) {\n console.log(\"\\nProcessors:\");\n manifest.processors.forEach((processor) => {\n console.log(`- ${processor.name} (${processor.id})`);\n });\n }\n\n if (manifest.subgraphs) {\n console.log(\"\\nSubgraphs:\");\n manifest.subgraphs.forEach((subgraph) => {\n console.log(`- ${subgraph.name} (${subgraph.id})`);\n });\n }\n } catch (e) {\n if (args.debug) {\n console.error(e);\n } else {\n console.log(\"No manifest found in the package\");\n }\n }\n}\n"],"names":[],"mappings":";;;;;AAIA,SAAgB,aAAa,MAAmB;AAC9C,KAAI,KAAK,MACP,SAAQ,IAAI,yBAAyB,KAAK;CAG5C,MAAM,cAAc,eAAe,KAAK,MAAM;CAC9C,MAAM,EAAE,gBAAgB;AAExB,KAAI,KAAK,MACP,SAAQ,IAAI,qBAAqB,YAAY;AAG/C,KAAI;EACF,MAAM,gBAAgB,SACpB,KAAK,MAAM,GAAG,aAAa,MAAM,QAAQ,CAAC;EAC5C,MAAM,WAAW,aACf,GAAG,QAAQ,KAAK,CAAC,gBAAgB,YAAY,gCAC9C;AAED,UAAQ,IAAI,SAAS,KAAK;AAC1B,MAAI,SAAS,gBAAgB;AAC3B,WAAQ,IAAI,qBAAqB;AACjC,YAAS,eAAe,SAAS,UAAU;AACzC,YAAQ,IAAI,KAAK,MAAM,KAAK,IAAI,MAAM,GAAG,GAAG;KAC5C;;AAGJ,MAAI,SAAS,SAAS;AACpB,WAAQ,IAAI,aAAa;AACzB,YAAS,QAAQ,SAAS,WAAW;AACnC,YAAQ,IAAI,KAAK,OAAO,KAAK,IAAI,OAAO,GAAG,GAAG;KAC9C;;AAGJ,MAAI,SAAS,YAAY;AACvB,WAAQ,IAAI,gBAAgB;AAC5B,YAAS,WAAW,SAAS,cAAc;AACzC,YAAQ,IAAI,KAAK,UAAU,KAAK,IAAI,UAAU,GAAG,GAAG;KACpD;;AAGJ,MAAI,SAAS,WAAW;AACtB,WAAQ,IAAI,eAAe;AAC3B,YAAS,UAAU,SAAS,aAAa;AACvC,YAAQ,IAAI,KAAK,SAAS,KAAK,IAAI,SAAS,GAAG,GAAG;KAClD;;UAEG,GAAG;AACV,MAAI,KAAK,MACP,SAAQ,MAAM,EAAE;MAEhB,SAAQ,IAAI,mCAAmC","debug_id":"f74536d7-164b-57b0-ac72-c4f52831d602"}
|
|
@@ -0,0 +1,83 @@
|
|
|
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]="b5fd9f68-512b-5441-8970-6d676ff10349")}catch(e){}}();
|
|
3
|
+
import { execSync } from "node:child_process";
|
|
4
|
+
import { dirname, join } from "node:path";
|
|
5
|
+
import { detect, resolveCommand } from "package-manager-detector";
|
|
6
|
+
import { fetchPackageVersionFromNpmRegistry, injectPnpmAllowBuilds } from "@powerhousedao/shared/clis";
|
|
7
|
+
import { readFileSync } from "node:fs";
|
|
8
|
+
import { fileURLToPath } from "node:url";
|
|
9
|
+
//#region src/services/migrate.ts
|
|
10
|
+
function getBundledPhCliVersion() {
|
|
11
|
+
let dir = dirname(fileURLToPath(import.meta.url));
|
|
12
|
+
for (let i = 0; i < 5; i++) {
|
|
13
|
+
try {
|
|
14
|
+
const pkg = JSON.parse(readFileSync(join(dir, "package.json"), "utf8"));
|
|
15
|
+
if (pkg.name === "@powerhousedao/ph-cli") return pkg.version;
|
|
16
|
+
} catch {}
|
|
17
|
+
dir = dirname(dir);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
function resolveCodegenVersion(codegenMod) {
|
|
21
|
+
const getter = codegenMod.getCodegenVersion;
|
|
22
|
+
if (typeof getter === "function") {
|
|
23
|
+
const v = getter();
|
|
24
|
+
if (typeof v === "string") return v;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function assertCodegenMatchesBundled(args) {
|
|
28
|
+
const { codegenVersion, bundledVersion, force } = args;
|
|
29
|
+
if (force) return;
|
|
30
|
+
if (!codegenVersion) throw new Error("@powerhousedao/codegen is older than this ph-cli expects (no version export). Reinstall ph-cli to bring a matching codegen, or re-run with --force.");
|
|
31
|
+
if (bundledVersion && codegenVersion !== bundledVersion) throw new Error(`@powerhousedao/codegen@${codegenVersion} does not match ph-cli@${bundledVersion}. Reinstall to align versions, or re-run with --force.`);
|
|
32
|
+
}
|
|
33
|
+
async function startMigrate({ versionPositional, version, force, debug }) {
|
|
34
|
+
const requested = versionPositional ?? version;
|
|
35
|
+
if (debug) console.log(`[migrate] requested version: ${requested}`);
|
|
36
|
+
let targetVersion;
|
|
37
|
+
try {
|
|
38
|
+
targetVersion = await fetchPackageVersionFromNpmRegistry(`@powerhousedao/ph-cli@${requested}`);
|
|
39
|
+
} catch (error) {
|
|
40
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
41
|
+
if (!force) throw new Error(`Failed to resolve "${requested}" from the npm registry: ${reason}\nRe-run with --force to migrate using the installed version.`, { cause: error });
|
|
42
|
+
if (debug) console.log(`[migrate] failed to resolve target version, --force is set, falling back to bundled codegen: ${reason}`);
|
|
43
|
+
}
|
|
44
|
+
const bundledVersion = getBundledPhCliVersion();
|
|
45
|
+
if (debug) {
|
|
46
|
+
console.log(`[migrate] resolved target version: ${targetVersion ?? "(unknown)"}`);
|
|
47
|
+
console.log(`[migrate] current ph-cli version: ${bundledVersion ?? "(unknown)"}`);
|
|
48
|
+
}
|
|
49
|
+
if (!targetVersion || force || targetVersion === bundledVersion) {
|
|
50
|
+
if (debug) console.log(`[migrate] running migrate from bundled codegen`);
|
|
51
|
+
const codegenMod = await import("@powerhousedao/codegen");
|
|
52
|
+
const codegenVersion = resolveCodegenVersion(codegenMod);
|
|
53
|
+
assertCodegenMatchesBundled({
|
|
54
|
+
codegenVersion,
|
|
55
|
+
bundledVersion,
|
|
56
|
+
force: Boolean(force)
|
|
57
|
+
});
|
|
58
|
+
console.log(`Running migrate with @powerhousedao/codegen@${codegenVersion ?? "unknown"}`);
|
|
59
|
+
await codegenMod.migrate(targetVersion ?? requested);
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const agent = (await detect())?.agent ?? "npm";
|
|
63
|
+
const resolved = resolveCommand(agent, "execute", [
|
|
64
|
+
`@powerhousedao/ph-cli@${targetVersion}`,
|
|
65
|
+
"migrate",
|
|
66
|
+
"--version",
|
|
67
|
+
targetVersion,
|
|
68
|
+
...debug ? ["--debug"] : []
|
|
69
|
+
]);
|
|
70
|
+
if (!resolved) throw new Error(`Failed to resolve execute command for package manager "${agent}".`);
|
|
71
|
+
injectPnpmAllowBuilds(agent, resolved);
|
|
72
|
+
const command = `${resolved.command} ${resolved.args.join(" ")}`;
|
|
73
|
+
if (debug) {
|
|
74
|
+
console.log(`[migrate] detected package manager: ${agent}`);
|
|
75
|
+
console.log(`[migrate] re-executing: ${command}`);
|
|
76
|
+
}
|
|
77
|
+
execSync(command, { stdio: "inherit" });
|
|
78
|
+
}
|
|
79
|
+
//#endregion
|
|
80
|
+
export { startMigrate };
|
|
81
|
+
|
|
82
|
+
//# sourceMappingURL=migrate-CfgiCNQo.mjs.map
|
|
83
|
+
//# debugId=b5fd9f68-512b-5441-8970-6d676ff10349
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate-CfgiCNQo.mjs","sources":["../src/services/migrate.ts"],"sourcesContent":["import {\n fetchPackageVersionFromNpmRegistry,\n injectPnpmAllowBuilds,\n} from \"@powerhousedao/shared/clis\";\nimport { execSync } from \"node:child_process\";\nimport { readFileSync } from \"node:fs\";\nimport { dirname, join } from \"node:path\";\nimport { fileURLToPath } from \"node:url\";\nimport { detect, resolveCommand } from \"package-manager-detector\";\nimport type { MigrateArgs } from \"../types.js\";\n\nfunction getBundledPhCliVersion(): string | undefined {\n let dir = dirname(fileURLToPath(import.meta.url));\n for (let i = 0; i < 5; i++) {\n try {\n const pkg = JSON.parse(\n readFileSync(join(dir, \"package.json\"), \"utf8\"),\n ) as { name?: string; version?: string };\n if (pkg.name === \"@powerhousedao/ph-cli\") return pkg.version;\n } catch {\n // keep walking\n }\n dir = dirname(dir);\n }\n}\n\nexport function resolveCodegenVersion(\n codegenMod: Record<string, unknown>,\n): string | undefined {\n const getter = codegenMod.getCodegenVersion;\n if (typeof getter === \"function\") {\n const v = (getter as () => unknown)();\n if (typeof v === \"string\") return v;\n }\n return undefined;\n}\n\nexport function assertCodegenMatchesBundled(args: {\n codegenVersion: string | undefined;\n bundledVersion: string | undefined;\n force: boolean;\n}): void {\n const { codegenVersion, bundledVersion, force } = args;\n if (force) return;\n if (!codegenVersion) {\n throw new Error(\n `@powerhousedao/codegen is older than this ph-cli expects (no version export). ` +\n `Reinstall ph-cli to bring a matching codegen, or re-run with --force.`,\n );\n }\n if (bundledVersion && codegenVersion !== bundledVersion) {\n throw new Error(\n `@powerhousedao/codegen@${codegenVersion} does not match ph-cli@${bundledVersion}. ` +\n `Reinstall to align versions, or re-run with --force.`,\n );\n }\n}\n\nexport async function startMigrate({\n versionPositional,\n version,\n force,\n debug,\n}: MigrateArgs) {\n const requested = versionPositional ?? version;\n if (debug) console.log(`[migrate] requested version: ${requested}`);\n\n let targetVersion: string | undefined;\n try {\n targetVersion = await fetchPackageVersionFromNpmRegistry(\n `@powerhousedao/ph-cli@${requested}`,\n );\n } catch (error) {\n const reason = error instanceof Error ? error.message : String(error);\n if (!force) {\n throw new Error(\n `Failed to resolve \"${requested}\" from the npm registry: ${reason}\\nRe-run with --force to migrate using the installed version.`,\n { cause: error },\n );\n }\n if (debug) {\n console.log(\n `[migrate] failed to resolve target version, --force is set, falling back to bundled codegen: ${reason}`,\n );\n }\n }\n\n const bundledVersion = getBundledPhCliVersion();\n if (debug) {\n console.log(\n `[migrate] resolved target version: ${targetVersion ?? \"(unknown)\"}`,\n );\n console.log(\n `[migrate] current ph-cli version: ${bundledVersion ?? \"(unknown)\"}`,\n );\n }\n\n if (!targetVersion || force || targetVersion === bundledVersion) {\n if (debug) console.log(`[migrate] running migrate from bundled codegen`);\n const codegenMod = await import(\"@powerhousedao/codegen\");\n const codegenVersion = resolveCodegenVersion(\n codegenMod as unknown as Record<string, unknown>,\n );\n assertCodegenMatchesBundled({\n codegenVersion,\n bundledVersion,\n force: Boolean(force),\n });\n console.log(\n `Running migrate with @powerhousedao/codegen@${codegenVersion ?? \"unknown\"}`,\n );\n await codegenMod.migrate(targetVersion ?? requested);\n return;\n }\n\n const agent = (await detect())?.agent ?? \"npm\";\n const resolved = resolveCommand(agent, \"execute\", [\n `@powerhousedao/ph-cli@${targetVersion}`,\n \"migrate\",\n \"--version\",\n targetVersion,\n ...(debug ? [\"--debug\"] : []),\n ]);\n if (!resolved) {\n throw new Error(\n `Failed to resolve execute command for package manager \"${agent}\".`,\n );\n }\n\n injectPnpmAllowBuilds(agent, resolved);\n\n const command = `${resolved.command} ${resolved.args.join(\" \")}`;\n if (debug) {\n console.log(`[migrate] detected package manager: ${agent}`);\n console.log(`[migrate] re-executing: ${command}`);\n }\n execSync(command, { stdio: \"inherit\" });\n}\n"],"names":[],"mappings":";;;;;;;;;AAWA,SAAS,yBAA6C;CACpD,IAAI,MAAM,QAAQ,cAAc,OAAO,KAAK,IAAI,CAAC;AACjD,MAAK,IAAI,IAAI,GAAG,IAAI,GAAG,KAAK;AAC1B,MAAI;GACF,MAAM,MAAM,KAAK,MACf,aAAa,KAAK,KAAK,eAAe,EAAE,OAAO,CAChD;AACD,OAAI,IAAI,SAAS,wBAAyB,QAAO,IAAI;UAC/C;AAGR,QAAM,QAAQ,IAAI;;;AAItB,SAAgB,sBACd,YACoB;CACpB,MAAM,SAAS,WAAW;AAC1B,KAAI,OAAO,WAAW,YAAY;EAChC,MAAM,IAAK,QAA0B;AACrC,MAAI,OAAO,MAAM,SAAU,QAAO;;;AAKtC,SAAgB,4BAA4B,MAInC;CACP,MAAM,EAAE,gBAAgB,gBAAgB,UAAU;AAClD,KAAI,MAAO;AACX,KAAI,CAAC,eACH,OAAM,IAAI,MACR,sJAED;AAEH,KAAI,kBAAkB,mBAAmB,eACvC,OAAM,IAAI,MACR,0BAA0B,eAAe,yBAAyB,eAAe,wDAElF;;AAIL,eAAsB,aAAa,EACjC,mBACA,SACA,OACA,SACc;CACd,MAAM,YAAY,qBAAqB;AACvC,KAAI,MAAO,SAAQ,IAAI,gCAAgC,YAAY;CAEnE,IAAI;AACJ,KAAI;AACF,kBAAgB,MAAM,mCACpB,yBAAyB,YAC1B;UACM,OAAO;EACd,MAAM,SAAS,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;AACrE,MAAI,CAAC,MACH,OAAM,IAAI,MACR,sBAAsB,UAAU,2BAA2B,OAAO,gEAClE,EAAE,OAAO,OAAO,CACjB;AAEH,MAAI,MACF,SAAQ,IACN,gGAAgG,SACjG;;CAIL,MAAM,iBAAiB,wBAAwB;AAC/C,KAAI,OAAO;AACT,UAAQ,IACN,sCAAsC,iBAAiB,cACxD;AACD,UAAQ,IACN,qCAAqC,kBAAkB,cACxD;;AAGH,KAAI,CAAC,iBAAiB,SAAS,kBAAkB,gBAAgB;AAC/D,MAAI,MAAO,SAAQ,IAAI,iDAAiD;EACxE,MAAM,aAAa,MAAM,OAAO;EAChC,MAAM,iBAAiB,sBACrB,WACD;AACD,8BAA4B;GAC1B;GACA;GACA,OAAO,QAAQ,MAAM;GACtB,CAAC;AACF,UAAQ,IACN,+CAA+C,kBAAkB,YAClE;AACD,QAAM,WAAW,QAAQ,iBAAiB,UAAU;AACpD;;CAGF,MAAM,SAAS,MAAM,QAAQ,GAAG,SAAS;CACzC,MAAM,WAAW,eAAe,OAAO,WAAW;EAChD,yBAAyB;EACzB;EACA;EACA;EACA,GAAI,QAAQ,CAAC,UAAU,GAAG,EAAE;EAC7B,CAAC;AACF,KAAI,CAAC,SACH,OAAM,IAAI,MACR,0DAA0D,MAAM,IACjE;AAGH,uBAAsB,OAAO,SAAS;CAEtC,MAAM,UAAU,GAAG,SAAS,QAAQ,GAAG,SAAS,KAAK,KAAK,IAAI;AAC9D,KAAI,OAAO;AACT,UAAQ,IAAI,uCAAuC,QAAQ;AAC3D,UAAQ,IAAI,2BAA2B,UAAU;;AAEnD,UAAS,SAAS,EAAE,OAAO,WAAW,CAAC","debug_id":"b5fd9f68-512b-5441-8970-6d676ff10349"}
|
|
@@ -0,0 +1,25 @@
|
|
|
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]="2e430ad3-fb2c-5578-8c85-ccce5c5a369e")}catch(e){}}();
|
|
3
|
+
import { t as getRenown } from "./auth-AR3VxAIk.mjs";
|
|
4
|
+
import { generateAccessToken } from "@renown/sdk/node";
|
|
5
|
+
//#region src/services/registry-auth.ts
|
|
6
|
+
/**
|
|
7
|
+
* Mint a Renown bearer token bound to the given registry URL via the JWT
|
|
8
|
+
* `aud` claim. Throws if the user is not authenticated (`ph login` first).
|
|
9
|
+
*
|
|
10
|
+
* The audience binding is what lets the registry distinguish a token minted
|
|
11
|
+
* for it from one minted for a different service or registry.
|
|
12
|
+
*/
|
|
13
|
+
async function mintRegistryAuthToken(registryUrl, expiresInSeconds) {
|
|
14
|
+
const renown = await getRenown();
|
|
15
|
+
if (!renown.user) throw new Error("Not authenticated with Renown. Run 'ph login' first.");
|
|
16
|
+
return (await generateAccessToken(renown, {
|
|
17
|
+
expiresIn: expiresInSeconds,
|
|
18
|
+
aud: registryUrl
|
|
19
|
+
})).token;
|
|
20
|
+
}
|
|
21
|
+
//#endregion
|
|
22
|
+
export { mintRegistryAuthToken };
|
|
23
|
+
|
|
24
|
+
//# sourceMappingURL=registry-auth-CNH84uo4.mjs.map
|
|
25
|
+
//# debugId=2e430ad3-fb2c-5578-8c85-ccce5c5a369e
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"registry-auth-CNH84uo4.mjs","sources":["../src/services/registry-auth.ts"],"sourcesContent":["import { generateAccessToken } from \"@renown/sdk/node\";\nimport { getRenown } from \"./auth.js\";\n\n/**\n * Mint a Renown bearer token bound to the given registry URL via the JWT\n * `aud` claim. Throws if the user is not authenticated (`ph login` first).\n *\n * The audience binding is what lets the registry distinguish a token minted\n * for it from one minted for a different service or registry.\n */\nexport async function mintRegistryAuthToken(\n registryUrl: string,\n expiresInSeconds: number,\n): Promise<string> {\n const renown = await getRenown();\n if (!renown.user) {\n throw new Error(\"Not authenticated with Renown. Run 'ph login' first.\");\n }\n const result = await generateAccessToken(renown, {\n expiresIn: expiresInSeconds,\n aud: registryUrl,\n });\n return result.token;\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AAUA,eAAsB,sBACpB,aACA,kBACiB;CACjB,MAAM,SAAS,MAAM,WAAW;AAChC,KAAI,CAAC,OAAO,KACV,OAAM,IAAI,MAAM,uDAAuD;AAMzE,SAJe,MAAM,oBAAoB,QAAQ;EAC/C,WAAW;EACX,KAAK;EACN,CAAC,EACY","debug_id":"2e430ad3-fb2c-5578-8c85-ccce5c5a369e"}
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import { writeCliDocsMarkdownFile } from "@powerhousedao/codegen/file-builders";
|
|
2
2
|
import { accessToken } from "../src/commands/access-token.js";
|
|
3
3
|
import { build, connect, preview, studio } from "../src/commands/connect.js";
|
|
4
|
+
import { generateAllCmd } from "../src/commands/generate-all.js";
|
|
5
|
+
import { generateAppCmd } from "../src/commands/generate-app.js";
|
|
6
|
+
import { generateDocumentModelCmd } from "../src/commands/generate-document-model.js";
|
|
7
|
+
import { generateEditorCmd } from "../src/commands/generate-editor.js";
|
|
8
|
+
import { generateMigrationFileCmd } from "../src/commands/generate-migration-file.js";
|
|
9
|
+
import { generateProcessorCmd } from "../src/commands/generate-processor.js";
|
|
10
|
+
import { generateSubgraphCmd } from "../src/commands/generate-subgraph.js";
|
|
4
11
|
import { generate } from "../src/commands/generate.js";
|
|
5
12
|
import { inspect } from "../src/commands/inspect.js";
|
|
6
13
|
import { install } from "../src/commands/install.js";
|
|
@@ -14,6 +21,13 @@ import { vetra } from "../src/commands/vetra.js";
|
|
|
14
21
|
|
|
15
22
|
const commands = [
|
|
16
23
|
{ name: "generate", command: generate },
|
|
24
|
+
{ name: "all", command: generateAllCmd },
|
|
25
|
+
{ name: "document-model", command: generateDocumentModelCmd },
|
|
26
|
+
{ name: "editor", command: generateEditorCmd },
|
|
27
|
+
{ name: "app", command: generateAppCmd },
|
|
28
|
+
{ name: "processor", command: generateProcessorCmd },
|
|
29
|
+
{ name: "subgraph", command: generateSubgraphCmd },
|
|
30
|
+
{ name: "migration-file", command: generateMigrationFileCmd },
|
|
17
31
|
{ name: "vetra", command: vetra },
|
|
18
32
|
{ name: "connect", command: connect },
|
|
19
33
|
{ name: "connect studio", command: studio },
|
package/dist/scripts/setup.sh
CHANGED
|
@@ -5,11 +5,11 @@ export NVM_DIR="$HOME/.nvm"
|
|
|
5
5
|
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
|
|
6
6
|
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
|
|
7
7
|
nvm --version
|
|
8
|
-
nvm install
|
|
8
|
+
nvm install 24
|
|
9
9
|
curl -fsSL https://get.pnpm.io/install.sh | sh -
|
|
10
10
|
export PNPM_HOME="/home/$USER/.local/share/pnpm"
|
|
11
|
-
export PATH="$PNPM_HOME:$PATH"
|
|
12
|
-
pnpm
|
|
11
|
+
export PATH="$PNPM_HOME/bin:$PNPM_HOME:$PATH"
|
|
12
|
+
pnpm add -g ph-cmd
|
|
13
13
|
echo ""
|
|
14
14
|
echo " 🎉 Setup Complete! 🎉"
|
|
15
15
|
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
@@ -0,0 +1,75 @@
|
|
|
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]="2b112076-440d-59d6-ac2e-84dc0ffb3cfd")}catch(e){}}();
|
|
3
|
+
import path from "node:path";
|
|
4
|
+
import { startSwitchboard } from "@powerhousedao/switchboard/server";
|
|
5
|
+
//#region src/services/switchboard.ts
|
|
6
|
+
const defaultSwitchboardOptions = {
|
|
7
|
+
port: 4001,
|
|
8
|
+
dbPath: path.join(process.cwd(), ".ph/read-model.db"),
|
|
9
|
+
drive: {
|
|
10
|
+
id: "powerhouse",
|
|
11
|
+
slug: "powerhouse",
|
|
12
|
+
global: {
|
|
13
|
+
name: "Powerhouse",
|
|
14
|
+
icon: "https://ipfs.io/ipfs/QmcaTDBYn8X2psGaXe7iQ6qd8q6oqHLgxvMX9yXf7f9uP7"
|
|
15
|
+
},
|
|
16
|
+
local: {
|
|
17
|
+
availableOffline: true,
|
|
18
|
+
listeners: [],
|
|
19
|
+
sharingType: "public",
|
|
20
|
+
triggers: []
|
|
21
|
+
}
|
|
22
|
+
},
|
|
23
|
+
mcp: true
|
|
24
|
+
};
|
|
25
|
+
function getDefaultVetraSwitchboardOptions(vetraDriveId) {
|
|
26
|
+
return {
|
|
27
|
+
port: 4001,
|
|
28
|
+
dbPath: path.join(process.cwd(), ".ph/read-model.db"),
|
|
29
|
+
drive: {
|
|
30
|
+
id: vetraDriveId,
|
|
31
|
+
slug: vetraDriveId,
|
|
32
|
+
global: {
|
|
33
|
+
name: "Vetra",
|
|
34
|
+
icon: "https://azure-elderly-tortoise-212.mypinata.cloud/ipfs/bafkreibf2xokjqqtomqjd2w2xxmmhvogq4262csevclxh6sbrjgmjfre5u"
|
|
35
|
+
},
|
|
36
|
+
preferredEditor: "vetra-drive-app",
|
|
37
|
+
local: {
|
|
38
|
+
availableOffline: true,
|
|
39
|
+
listeners: [],
|
|
40
|
+
sharingType: "public",
|
|
41
|
+
triggers: []
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
async function startSwitchboard$1(options, logger) {
|
|
47
|
+
const { packages: packagesString, remoteDrives, useVetraDrive, vetraDriveId, useIdentity, keypairPath, requireIdentity, ...serverOptions } = options;
|
|
48
|
+
const defaultOptions = useVetraDrive ? getDefaultVetraSwitchboardOptions(vetraDriveId) : defaultSwitchboardOptions;
|
|
49
|
+
const identity = useIdentity || keypairPath || requireIdentity ? {
|
|
50
|
+
keypairPath,
|
|
51
|
+
requireExisting: requireIdentity
|
|
52
|
+
} : void 0;
|
|
53
|
+
const packages = packagesString?.split(",");
|
|
54
|
+
return await startSwitchboard(remoteDrives.length > 0 ? {
|
|
55
|
+
...defaultOptions,
|
|
56
|
+
drive: void 0,
|
|
57
|
+
...serverOptions,
|
|
58
|
+
remoteDrives,
|
|
59
|
+
identity,
|
|
60
|
+
packages,
|
|
61
|
+
logger
|
|
62
|
+
} : {
|
|
63
|
+
...defaultOptions,
|
|
64
|
+
...serverOptions,
|
|
65
|
+
remoteDrives,
|
|
66
|
+
identity,
|
|
67
|
+
packages,
|
|
68
|
+
logger
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
//#endregion
|
|
72
|
+
export { startSwitchboard$1 as n, defaultSwitchboardOptions as t };
|
|
73
|
+
|
|
74
|
+
//# sourceMappingURL=switchboard-CERuSM8r.mjs.map
|
|
75
|
+
//# debugId=2b112076-440d-59d6-ac2e-84dc0ffb3cfd
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"switchboard-CERuSM8r.mjs","sources":["../src/services/switchboard.ts"],"sourcesContent":["import type {\n IdentityOptions,\n StartServerOptions,\n} from \"@powerhousedao/switchboard/server\";\nimport { startSwitchboard as startSwitchboardServer } from \"@powerhousedao/switchboard/server\";\nimport type { ILogger } from \"document-model\";\nimport path from \"node:path\";\nimport type { SwitchboardArgs } from \"../types.js\";\n\nexport const defaultSwitchboardOptions = {\n port: 4001,\n dbPath: path.join(process.cwd(), \".ph/read-model.db\"),\n drive: {\n id: \"powerhouse\",\n slug: \"powerhouse\",\n global: {\n name: \"Powerhouse\",\n icon: \"https://ipfs.io/ipfs/QmcaTDBYn8X2psGaXe7iQ6qd8q6oqHLgxvMX9yXf7f9uP7\",\n },\n local: {\n availableOffline: true,\n listeners: [],\n sharingType: \"public\",\n triggers: [],\n },\n },\n mcp: true,\n} satisfies StartServerOptions;\n\nfunction getDefaultVetraSwitchboardOptions(\n vetraDriveId: string,\n): Partial<StartServerOptions> {\n return {\n port: 4001,\n dbPath: path.join(process.cwd(), \".ph/read-model.db\"),\n drive: {\n id: vetraDriveId,\n slug: vetraDriveId,\n global: {\n name: \"Vetra\",\n icon: \"https://azure-elderly-tortoise-212.mypinata.cloud/ipfs/bafkreibf2xokjqqtomqjd2w2xxmmhvogq4262csevclxh6sbrjgmjfre5u\",\n },\n preferredEditor: \"vetra-drive-app\",\n local: {\n availableOffline: true,\n listeners: [],\n sharingType: \"public\",\n triggers: [],\n },\n },\n };\n}\n\nexport async function startSwitchboard(\n options: SwitchboardArgs & {\n strictPort?: boolean;\n processorConfig?: Map<string, unknown>;\n },\n logger?: ILogger,\n) {\n const {\n packages: packagesString,\n remoteDrives,\n useVetraDrive,\n vetraDriveId,\n useIdentity,\n keypairPath,\n requireIdentity,\n ...serverOptions\n } = options;\n\n // Choose the appropriate default configuration\n const defaultOptions = useVetraDrive\n ? getDefaultVetraSwitchboardOptions(vetraDriveId)\n : defaultSwitchboardOptions;\n\n // Build identity options if enabled\n const identity: IdentityOptions | undefined =\n useIdentity || keypairPath || requireIdentity\n ? {\n keypairPath,\n requireExisting: requireIdentity,\n }\n : undefined;\n\n const packages = packagesString?.split(\",\");\n\n // Only include the default drive if no remote drives are provided\n const finalOptions =\n remoteDrives.length > 0\n ? {\n ...defaultOptions,\n drive: undefined, // Don't create default drive when syncing with remote\n ...serverOptions,\n remoteDrives,\n identity,\n packages,\n logger,\n }\n : {\n ...defaultOptions,\n ...serverOptions,\n remoteDrives,\n identity,\n packages,\n logger,\n };\n\n const reactor = await startSwitchboardServer(finalOptions);\n\n return reactor;\n}\n"],"names":["startSwitchboard","startSwitchboardServer"],"mappings":";;;;;AASA,MAAa,4BAA4B;CACvC,MAAM;CACN,QAAQ,KAAK,KAAK,QAAQ,KAAK,EAAE,oBAAoB;CACrD,OAAO;EACL,IAAI;EACJ,MAAM;EACN,QAAQ;GACN,MAAM;GACN,MAAM;GACP;EACD,OAAO;GACL,kBAAkB;GAClB,WAAW,EAAE;GACb,aAAa;GACb,UAAU,EAAE;GACb;EACF;CACD,KAAK;CACN;AAED,SAAS,kCACP,cAC6B;AAC7B,QAAO;EACL,MAAM;EACN,QAAQ,KAAK,KAAK,QAAQ,KAAK,EAAE,oBAAoB;EACrD,OAAO;GACL,IAAI;GACJ,MAAM;GACN,QAAQ;IACN,MAAM;IACN,MAAM;IACP;GACD,iBAAiB;GACjB,OAAO;IACL,kBAAkB;IAClB,WAAW,EAAE;IACb,aAAa;IACb,UAAU,EAAE;IACb;GACF;EACF;;AAGH,eAAsBA,mBACpB,SAIA,QACA;CACA,MAAM,EACJ,UAAU,gBACV,cACA,eACA,cACA,aACA,aACA,iBACA,GAAG,kBACD;CAGJ,MAAM,iBAAiB,gBACnB,kCAAkC,aAAa,GAC/C;CAGJ,MAAM,WACJ,eAAe,eAAe,kBAC1B;EACE;EACA,iBAAiB;EAClB,GACD,KAAA;CAEN,MAAM,WAAW,gBAAgB,MAAM,IAAI;AAyB3C,QAFgB,MAAMC,iBAnBpB,aAAa,SAAS,IAClB;EACE,GAAG;EACH,OAAO,KAAA;EACP,GAAG;EACH;EACA;EACA;EACA;EACD,GACD;EACE,GAAG;EACH,GAAG;EACH;EACA;EACA;EACA;EACD,CAEmD","debug_id":"2b112076-440d-59d6-ac2e-84dc0ffb3cfd"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { n as startSwitchboard } from "./switchboard-CERuSM8r.mjs";
|
|
2
|
+
export { startSwitchboard };
|
|
3
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="af9813d0-a104-5bb7-8b08-a5926d55691e")}catch(e){}}();
|
|
4
|
+
//# debugId=af9813d0-a104-5bb7-8b08-a5926d55691e
|
|
@@ -0,0 +1,53 @@
|
|
|
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]="4ec454c2-51e0-5620-85cc-296ec21997cd")}catch(e){}}();
|
|
3
|
+
import { Kysely, PostgresDialect } from "kysely";
|
|
4
|
+
import { Pool } from "pg";
|
|
5
|
+
import { REACTOR_SCHEMA, getMigrationStatus, runMigrations } from "@powerhousedao/reactor";
|
|
6
|
+
//#region src/services/switchboard-migrate.ts
|
|
7
|
+
function isPostgresUrl(url) {
|
|
8
|
+
return url.startsWith("postgresql://") || url.startsWith("postgres://");
|
|
9
|
+
}
|
|
10
|
+
async function runSwitchboardMigrations(options) {
|
|
11
|
+
const dbPath = options.dbPath ?? process.env.PH_REACTOR_DATABASE_URL ?? process.env.DATABASE_URL;
|
|
12
|
+
if (!dbPath || !isPostgresUrl(dbPath)) {
|
|
13
|
+
console.log("No PostgreSQL URL configured. Skipping migrations.");
|
|
14
|
+
console.log("(PGlite migrations are handled automatically on startup)");
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
console.log(`Database: ${dbPath}`);
|
|
18
|
+
const db = new Kysely({ dialect: new PostgresDialect({ pool: new Pool({ connectionString: dbPath }) }) });
|
|
19
|
+
try {
|
|
20
|
+
if (options.statusOnly) {
|
|
21
|
+
console.log("\nChecking migration status...");
|
|
22
|
+
const migrations = await getMigrationStatus(db, REACTOR_SCHEMA);
|
|
23
|
+
console.log("\nMigration Status:");
|
|
24
|
+
console.log("=================");
|
|
25
|
+
for (const migration of migrations) {
|
|
26
|
+
const status = migration.executedAt ? `[OK] Executed at ${migration.executedAt.toISOString()}` : "[--] Pending";
|
|
27
|
+
console.log(`${status} - ${migration.name}`);
|
|
28
|
+
}
|
|
29
|
+
} else {
|
|
30
|
+
console.log("\nRunning migrations...");
|
|
31
|
+
const result = await runMigrations(db, REACTOR_SCHEMA);
|
|
32
|
+
if (!result.success) {
|
|
33
|
+
console.error("Migration failed:", result.error?.message);
|
|
34
|
+
process.exit(1);
|
|
35
|
+
}
|
|
36
|
+
if (result.migrationsExecuted.length === 0) console.log("No migrations to run - database is up to date");
|
|
37
|
+
else {
|
|
38
|
+
console.log(`Successfully executed ${result.migrationsExecuted.length} migration(s):`);
|
|
39
|
+
for (const name of result.migrationsExecuted) console.log(` - ${name}`);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
} catch (error) {
|
|
43
|
+
console.error("Error:", error instanceof Error ? error.message : String(error));
|
|
44
|
+
process.exit(1);
|
|
45
|
+
} finally {
|
|
46
|
+
await db.destroy();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
//#endregion
|
|
50
|
+
export { runSwitchboardMigrations };
|
|
51
|
+
|
|
52
|
+
//# sourceMappingURL=switchboard-migrate-BumRp7rC.mjs.map
|
|
53
|
+
//# debugId=4ec454c2-51e0-5620-85cc-296ec21997cd
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"switchboard-migrate-BumRp7rC.mjs","sources":["../src/services/switchboard-migrate.ts"],"sourcesContent":["import { Kysely, PostgresDialect } from \"kysely\";\nimport { Pool } from \"pg\";\nimport {\n runMigrations,\n getMigrationStatus,\n REACTOR_SCHEMA,\n} from \"@powerhousedao/reactor\";\n\ninterface MigrationOptions {\n dbPath?: string;\n statusOnly?: boolean;\n}\n\nfunction isPostgresUrl(url: string): boolean {\n return url.startsWith(\"postgresql://\") || url.startsWith(\"postgres://\");\n}\n\nexport async function runSwitchboardMigrations(\n options: MigrationOptions,\n): Promise<void> {\n const dbPath =\n options.dbPath ??\n process.env.PH_REACTOR_DATABASE_URL ??\n process.env.DATABASE_URL;\n\n if (!dbPath || !isPostgresUrl(dbPath)) {\n console.log(\"No PostgreSQL URL configured. Skipping migrations.\");\n console.log(\"(PGlite migrations are handled automatically on startup)\");\n return;\n }\n\n console.log(`Database: ${dbPath}`);\n\n const pool = new Pool({ connectionString: dbPath });\n\n const db = new Kysely<any>({\n dialect: new PostgresDialect({ pool }),\n });\n\n try {\n if (options.statusOnly) {\n console.log(\"\\nChecking migration status...\");\n const migrations = await getMigrationStatus(db, REACTOR_SCHEMA);\n\n console.log(\"\\nMigration Status:\");\n console.log(\"=================\");\n\n for (const migration of migrations) {\n const status = migration.executedAt\n ? `[OK] Executed at ${migration.executedAt.toISOString()}`\n : \"[--] Pending\";\n console.log(`${status} - ${migration.name}`);\n }\n } else {\n console.log(\"\\nRunning migrations...\");\n const result = await runMigrations(db, REACTOR_SCHEMA);\n\n if (!result.success) {\n console.error(\"Migration failed:\", result.error?.message);\n process.exit(1);\n }\n\n if (result.migrationsExecuted.length === 0) {\n console.log(\"No migrations to run - database is up to date\");\n } else {\n console.log(\n `Successfully executed ${result.migrationsExecuted.length} migration(s):`,\n );\n for (const name of result.migrationsExecuted) {\n console.log(` - ${name}`);\n }\n }\n }\n } catch (error) {\n console.error(\n \"Error:\",\n error instanceof Error ? error.message : String(error),\n );\n process.exit(1);\n } finally {\n await db.destroy();\n }\n}\n"],"names":[],"mappings":";;;;;;AAaA,SAAS,cAAc,KAAsB;AAC3C,QAAO,IAAI,WAAW,gBAAgB,IAAI,IAAI,WAAW,cAAc;;AAGzE,eAAsB,yBACpB,SACe;CACf,MAAM,SACJ,QAAQ,UACR,QAAQ,IAAI,2BACZ,QAAQ,IAAI;AAEd,KAAI,CAAC,UAAU,CAAC,cAAc,OAAO,EAAE;AACrC,UAAQ,IAAI,qDAAqD;AACjE,UAAQ,IAAI,2DAA2D;AACvE;;AAGF,SAAQ,IAAI,aAAa,SAAS;CAIlC,MAAM,KAAK,IAAI,OAAY,EACzB,SAAS,IAAI,gBAAgB,EAAE,MAHpB,IAAI,KAAK,EAAE,kBAAkB,QAAQ,CAAC,EAGZ,CAAC,EACvC,CAAC;AAEF,KAAI;AACF,MAAI,QAAQ,YAAY;AACtB,WAAQ,IAAI,iCAAiC;GAC7C,MAAM,aAAa,MAAM,mBAAmB,IAAI,eAAe;AAE/D,WAAQ,IAAI,sBAAsB;AAClC,WAAQ,IAAI,oBAAoB;AAEhC,QAAK,MAAM,aAAa,YAAY;IAClC,MAAM,SAAS,UAAU,aACrB,oBAAoB,UAAU,WAAW,aAAa,KACtD;AACJ,YAAQ,IAAI,GAAG,OAAO,KAAK,UAAU,OAAO;;SAEzC;AACL,WAAQ,IAAI,0BAA0B;GACtC,MAAM,SAAS,MAAM,cAAc,IAAI,eAAe;AAEtD,OAAI,CAAC,OAAO,SAAS;AACnB,YAAQ,MAAM,qBAAqB,OAAO,OAAO,QAAQ;AACzD,YAAQ,KAAK,EAAE;;AAGjB,OAAI,OAAO,mBAAmB,WAAW,EACvC,SAAQ,IAAI,gDAAgD;QACvD;AACL,YAAQ,IACN,yBAAyB,OAAO,mBAAmB,OAAO,gBAC3D;AACD,SAAK,MAAM,QAAQ,OAAO,mBACxB,SAAQ,IAAI,OAAO,OAAO;;;UAIzB,OAAO;AACd,UAAQ,MACN,UACA,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM,CACvD;AACD,UAAQ,KAAK,EAAE;WACP;AACR,QAAM,GAAG,SAAS","debug_id":"4ec454c2-51e0-5620-85cc-296ec21997cd"}
|
|
@@ -0,0 +1,87 @@
|
|
|
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]="4438a63d-24ec-57f5-8ae6-4ae3a40a8c6f")}catch(e){}}();
|
|
3
|
+
import { cyan, green, red, yellow } from "colorette";
|
|
4
|
+
import { promises } from "node:fs";
|
|
5
|
+
//#region src/services/switchboard-reset.ts
|
|
6
|
+
const CONFIRMATION_TOKEN = "reset";
|
|
7
|
+
function isPostgresUrl(url) {
|
|
8
|
+
return url.startsWith("postgresql://") || url.startsWith("postgres://");
|
|
9
|
+
}
|
|
10
|
+
function isInteractive() {
|
|
11
|
+
return Boolean(process.stdin.isTTY) && !process.env.CI;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Resolves the on-disk PGlite directories that `--reset` would delete.
|
|
15
|
+
* Mirrors the resolution in apps/switchboard/src/server.mts so we touch the
|
|
16
|
+
* same paths the running switchboard uses. When a Postgres URL is configured
|
|
17
|
+
* the corresponding directory is null and `postgresUrl` is populated so the
|
|
18
|
+
* caller can refuse.
|
|
19
|
+
*/
|
|
20
|
+
function resolveResetPaths(options, env = process.env) {
|
|
21
|
+
const readModelDbPath = options.dbPath ?? env.DATABASE_URL ?? env.PH_SWITCHBOARD_DATABASE_URL;
|
|
22
|
+
const readModelPath = readModelDbPath || ".ph/read-storage";
|
|
23
|
+
const reactorDbUrl = options.dbPath ?? env.PH_REACTOR_DATABASE_URL ?? env.PH_SWITCHBOARD_DATABASE_URL;
|
|
24
|
+
const reactorPath = reactorDbUrl || "./.ph/reactor-storage";
|
|
25
|
+
const reactorIsPostgres = !!reactorDbUrl && isPostgresUrl(reactorDbUrl);
|
|
26
|
+
const readModelIsPostgres = !!readModelDbPath && isPostgresUrl(readModelDbPath);
|
|
27
|
+
let postgresUrl = null;
|
|
28
|
+
if (reactorIsPostgres) postgresUrl = reactorDbUrl;
|
|
29
|
+
else if (readModelIsPostgres) postgresUrl = readModelDbPath;
|
|
30
|
+
return {
|
|
31
|
+
reactorDir: reactorIsPostgres ? null : reactorPath,
|
|
32
|
+
readModelDir: readModelIsPostgres ? null : readModelPath,
|
|
33
|
+
postgresUrl
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
async function promptForConfirmation() {
|
|
37
|
+
const enquirer = await import("enquirer");
|
|
38
|
+
try {
|
|
39
|
+
return (await enquirer.default.prompt({
|
|
40
|
+
type: "input",
|
|
41
|
+
name: "confirmation",
|
|
42
|
+
message: `Type "${CONFIRMATION_TOKEN}" to confirm wiping the local switchboard databases:`
|
|
43
|
+
})).confirmation.trim() === CONFIRMATION_TOKEN;
|
|
44
|
+
} catch {
|
|
45
|
+
return false;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
async function resetSwitchboardDatabase(options) {
|
|
49
|
+
const paths = resolveResetPaths(options);
|
|
50
|
+
if (paths.postgresUrl) {
|
|
51
|
+
console.error(red(`Refusing to reset: a PostgreSQL URL is configured (${paths.postgresUrl}).`));
|
|
52
|
+
console.error(yellow("`ph switchboard --reset` only wipes the local PGlite stores. To reset a Postgres-backed switchboard, drop/recreate the database manually."));
|
|
53
|
+
process.exit(1);
|
|
54
|
+
}
|
|
55
|
+
const targets = [paths.reactorDir, paths.readModelDir].filter((d) => d !== null);
|
|
56
|
+
if (targets.length === 0) {
|
|
57
|
+
console.error(red("No local PGlite directories resolved; nothing to do."));
|
|
58
|
+
process.exit(1);
|
|
59
|
+
}
|
|
60
|
+
console.log(yellow("The following directories will be permanently deleted:"));
|
|
61
|
+
for (const dir of targets) console.log(` - ${dir}`);
|
|
62
|
+
console.log(yellow("This will wipe all local switchboard state. Migrations will re-run on next `ph switchboard`."));
|
|
63
|
+
let confirmed = false;
|
|
64
|
+
if (options.yes) confirmed = true;
|
|
65
|
+
else if (isInteractive()) confirmed = await promptForConfirmation();
|
|
66
|
+
else {
|
|
67
|
+
console.error(red("Refusing to reset in a non-interactive context without --yes. Re-run with --yes to confirm."));
|
|
68
|
+
process.exit(1);
|
|
69
|
+
}
|
|
70
|
+
if (!confirmed) {
|
|
71
|
+
console.error(red("Aborted: confirmation not provided."));
|
|
72
|
+
process.exit(1);
|
|
73
|
+
}
|
|
74
|
+
for (const dir of targets) {
|
|
75
|
+
await promises.rm(dir, {
|
|
76
|
+
recursive: true,
|
|
77
|
+
force: true
|
|
78
|
+
});
|
|
79
|
+
console.log(cyan(`Removed ${dir}`));
|
|
80
|
+
}
|
|
81
|
+
console.log(green("Switchboard local storage reset. Run `ph switchboard` to re-initialize."));
|
|
82
|
+
}
|
|
83
|
+
//#endregion
|
|
84
|
+
export { resetSwitchboardDatabase };
|
|
85
|
+
|
|
86
|
+
//# sourceMappingURL=switchboard-reset-1YcJEVqc.mjs.map
|
|
87
|
+
//# debugId=4438a63d-24ec-57f5-8ae6-4ae3a40a8c6f
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"switchboard-reset-1YcJEVqc.mjs","sources":["../src/services/switchboard-reset.ts"],"sourcesContent":["import { yellow, red, green, cyan } from \"colorette\";\nimport { promises as fs } from \"node:fs\";\n\nexport interface ResetSwitchboardOptions {\n dbPath?: string;\n yes?: boolean;\n}\n\nexport interface ResolvedResetPaths {\n reactorDir: string | null;\n readModelDir: string | null;\n postgresUrl: string | null;\n}\n\nconst CONFIRMATION_TOKEN = \"reset\";\n\nexport function isPostgresUrl(url: string): boolean {\n return url.startsWith(\"postgresql://\") || url.startsWith(\"postgres://\");\n}\n\nfunction isInteractive(): boolean {\n return Boolean(process.stdin.isTTY) && !process.env.CI;\n}\n\n/**\n * Resolves the on-disk PGlite directories that `--reset` would delete.\n * Mirrors the resolution in apps/switchboard/src/server.mts so we touch the\n * same paths the running switchboard uses. When a Postgres URL is configured\n * the corresponding directory is null and `postgresUrl` is populated so the\n * caller can refuse.\n */\nexport function resolveResetPaths(\n options: ResetSwitchboardOptions,\n env: NodeJS.ProcessEnv = process.env,\n): ResolvedResetPaths {\n const readModelDbPath =\n options.dbPath ?? env.DATABASE_URL ?? env.PH_SWITCHBOARD_DATABASE_URL;\n const readModelPath = readModelDbPath || \".ph/read-storage\";\n const reactorDbUrl =\n options.dbPath ??\n env.PH_REACTOR_DATABASE_URL ??\n env.PH_SWITCHBOARD_DATABASE_URL;\n const reactorPath = reactorDbUrl || \"./.ph/reactor-storage\";\n\n const reactorIsPostgres = !!reactorDbUrl && isPostgresUrl(reactorDbUrl);\n const readModelIsPostgres =\n !!readModelDbPath && isPostgresUrl(readModelDbPath);\n\n let postgresUrl: string | null = null;\n if (reactorIsPostgres) postgresUrl = reactorDbUrl as string;\n else if (readModelIsPostgres) postgresUrl = readModelDbPath as string;\n\n return {\n reactorDir: reactorIsPostgres ? null : reactorPath,\n readModelDir: readModelIsPostgres ? null : readModelPath,\n postgresUrl,\n };\n}\n\nasync function promptForConfirmation(): Promise<boolean> {\n const enquirer = await import(\"enquirer\");\n try {\n const answer = await enquirer.default.prompt<{ confirmation: string }>({\n type: \"input\",\n name: \"confirmation\",\n message: `Type \"${CONFIRMATION_TOKEN}\" to confirm wiping the local switchboard databases:`,\n });\n return answer.confirmation.trim() === CONFIRMATION_TOKEN;\n } catch {\n return false;\n }\n}\n\nexport async function resetSwitchboardDatabase(\n options: ResetSwitchboardOptions,\n): Promise<void> {\n const paths = resolveResetPaths(options);\n\n if (paths.postgresUrl) {\n console.error(\n red(\n `Refusing to reset: a PostgreSQL URL is configured (${paths.postgresUrl}).`,\n ),\n );\n console.error(\n yellow(\n \"`ph switchboard --reset` only wipes the local PGlite stores. \" +\n \"To reset a Postgres-backed switchboard, drop/recreate the database manually.\",\n ),\n );\n process.exit(1);\n }\n\n const targets = [paths.reactorDir, paths.readModelDir].filter(\n (d): d is string => d !== null,\n );\n\n if (targets.length === 0) {\n console.error(red(\"No local PGlite directories resolved; nothing to do.\"));\n process.exit(1);\n }\n\n console.log(yellow(\"The following directories will be permanently deleted:\"));\n for (const dir of targets) {\n console.log(` - ${dir}`);\n }\n console.log(\n yellow(\n \"This will wipe all local switchboard state. Migrations will re-run on next `ph switchboard`.\",\n ),\n );\n\n let confirmed = false;\n if (options.yes) {\n confirmed = true;\n } else if (isInteractive()) {\n confirmed = await promptForConfirmation();\n } else {\n console.error(\n red(\n \"Refusing to reset in a non-interactive context without --yes. Re-run with --yes to confirm.\",\n ),\n );\n process.exit(1);\n }\n\n if (!confirmed) {\n console.error(red(\"Aborted: confirmation not provided.\"));\n process.exit(1);\n }\n\n for (const dir of targets) {\n await fs.rm(dir, { recursive: true, force: true });\n console.log(cyan(`Removed ${dir}`));\n }\n\n console.log(\n green(\n \"Switchboard local storage reset. Run `ph switchboard` to re-initialize.\",\n ),\n );\n}\n"],"names":["fs"],"mappings":";;;;;AAcA,MAAM,qBAAqB;AAE3B,SAAgB,cAAc,KAAsB;AAClD,QAAO,IAAI,WAAW,gBAAgB,IAAI,IAAI,WAAW,cAAc;;AAGzE,SAAS,gBAAyB;AAChC,QAAO,QAAQ,QAAQ,MAAM,MAAM,IAAI,CAAC,QAAQ,IAAI;;;;;;;;;AAUtD,SAAgB,kBACd,SACA,MAAyB,QAAQ,KACb;CACpB,MAAM,kBACJ,QAAQ,UAAU,IAAI,gBAAgB,IAAI;CAC5C,MAAM,gBAAgB,mBAAmB;CACzC,MAAM,eACJ,QAAQ,UACR,IAAI,2BACJ,IAAI;CACN,MAAM,cAAc,gBAAgB;CAEpC,MAAM,oBAAoB,CAAC,CAAC,gBAAgB,cAAc,aAAa;CACvE,MAAM,sBACJ,CAAC,CAAC,mBAAmB,cAAc,gBAAgB;CAErD,IAAI,cAA6B;AACjC,KAAI,kBAAmB,eAAc;UAC5B,oBAAqB,eAAc;AAE5C,QAAO;EACL,YAAY,oBAAoB,OAAO;EACvC,cAAc,sBAAsB,OAAO;EAC3C;EACD;;AAGH,eAAe,wBAA0C;CACvD,MAAM,WAAW,MAAM,OAAO;AAC9B,KAAI;AAMF,UALe,MAAM,SAAS,QAAQ,OAAiC;GACrE,MAAM;GACN,MAAM;GACN,SAAS,SAAS,mBAAmB;GACtC,CAAC,EACY,aAAa,MAAM,KAAK;SAChC;AACN,SAAO;;;AAIX,eAAsB,yBACpB,SACe;CACf,MAAM,QAAQ,kBAAkB,QAAQ;AAExC,KAAI,MAAM,aAAa;AACrB,UAAQ,MACN,IACE,sDAAsD,MAAM,YAAY,IACzE,CACF;AACD,UAAQ,MACN,OACE,4IAED,CACF;AACD,UAAQ,KAAK,EAAE;;CAGjB,MAAM,UAAU,CAAC,MAAM,YAAY,MAAM,aAAa,CAAC,QACpD,MAAmB,MAAM,KAC3B;AAED,KAAI,QAAQ,WAAW,GAAG;AACxB,UAAQ,MAAM,IAAI,uDAAuD,CAAC;AAC1E,UAAQ,KAAK,EAAE;;AAGjB,SAAQ,IAAI,OAAO,yDAAyD,CAAC;AAC7E,MAAK,MAAM,OAAO,QAChB,SAAQ,IAAI,OAAO,MAAM;AAE3B,SAAQ,IACN,OACE,+FACD,CACF;CAED,IAAI,YAAY;AAChB,KAAI,QAAQ,IACV,aAAY;UACH,eAAe,CACxB,aAAY,MAAM,uBAAuB;MACpC;AACL,UAAQ,MACN,IACE,8FACD,CACF;AACD,UAAQ,KAAK,EAAE;;AAGjB,KAAI,CAAC,WAAW;AACd,UAAQ,MAAM,IAAI,sCAAsC,CAAC;AACzD,UAAQ,KAAK,EAAE;;AAGjB,MAAK,MAAM,OAAO,SAAS;AACzB,QAAMA,SAAG,GAAG,KAAK;GAAE,WAAW;GAAM,OAAO;GAAM,CAAC;AAClD,UAAQ,IAAI,KAAK,WAAW,MAAM,CAAC;;AAGrC,SAAQ,IACN,MACE,0EACD,CACF","debug_id":"4438a63d-24ec-57f5-8ae6-4ae3a40a8c6f"}
|