@powerhousedao/ph-cli 6.0.0-dev.191 → 6.0.0-dev.192
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/cli.mjs +7 -7
- package/dist/{generate-DXDBhwoJ.mjs → generate-UNkoTojF.mjs} +15 -27
- package/dist/generate-UNkoTojF.mjs.map +1 -0
- package/dist/{init-BsmDWu9-.mjs → init-rIIiKQI4.mjs} +1 -1
- package/dist/{init-BsmDWu9-.mjs.map → init-rIIiKQI4.mjs.map} +1 -1
- package/dist/{inspect-BMrHr09E.mjs → inspect-Qn_mykOH.mjs} +1 -1
- package/dist/{inspect-BMrHr09E.mjs.map → inspect-Qn_mykOH.mjs.map} +1 -1
- package/dist/migrate-Cmd8Ouyk.mjs +11 -0
- package/dist/migrate-Cmd8Ouyk.mjs.map +1 -0
- package/dist/{switchboard-DBqOSS0c.mjs → switchboard-BclxuF4j.mjs} +1 -1
- package/dist/{switchboard-DBqOSS0c.mjs.map → switchboard-BclxuF4j.mjs.map} +1 -1
- package/dist/switchboard-DXF1APL1.mjs +2 -0
- package/dist/{switchboard-migrate-1lOCPmX0.mjs → switchboard-migrate-Cwx-8MnF.mjs} +1 -1
- package/dist/{switchboard-migrate-1lOCPmX0.mjs.map → switchboard-migrate-Cwx-8MnF.mjs.map} +1 -1
- package/dist/{vetra-vUDKNfbX.mjs → vetra-D3mHCtDl.mjs} +2 -2
- package/dist/{vetra-vUDKNfbX.mjs.map → vetra-D3mHCtDl.mjs.map} +1 -1
- package/package.json +14 -13
- package/dist/generate-DXDBhwoJ.mjs.map +0 -1
- package/dist/generate-Dokvf5Zu.mjs +0 -2
- package/dist/migrate-N4b2DpVP.mjs +0 -245
- package/dist/migrate-N4b2DpVP.mjs.map +0 -1
- package/dist/switchboard-Bht39Myv.mjs +0 -2
package/dist/cli.mjs
CHANGED
|
@@ -173,7 +173,7 @@ This command:
|
|
|
173
173
|
args: generateArgs,
|
|
174
174
|
handler: async (args) => {
|
|
175
175
|
if (args.debug) console.log(args);
|
|
176
|
-
const { startGenerate } = await import("./generate-
|
|
176
|
+
const { startGenerate } = await import("./generate-UNkoTojF.mjs");
|
|
177
177
|
await startGenerate(args);
|
|
178
178
|
process.exit(0);
|
|
179
179
|
}
|
|
@@ -186,7 +186,7 @@ const init = command({
|
|
|
186
186
|
args: initArgs,
|
|
187
187
|
handler: async (args) => {
|
|
188
188
|
if (args.debug) console.log({ args });
|
|
189
|
-
const { startInit } = await import("./init-
|
|
189
|
+
const { startInit } = await import("./init-rIIiKQI4.mjs");
|
|
190
190
|
await startInit(args);
|
|
191
191
|
process.exit(0);
|
|
192
192
|
}
|
|
@@ -209,7 +209,7 @@ This command:
|
|
|
209
209
|
args: inspectArgs,
|
|
210
210
|
handler: async (args) => {
|
|
211
211
|
if (args.debug) console.log(args);
|
|
212
|
-
const { startInspect } = await import("./inspect-
|
|
212
|
+
const { startInspect } = await import("./inspect-Qn_mykOH.mjs");
|
|
213
213
|
startInspect(args);
|
|
214
214
|
process.exit(0);
|
|
215
215
|
}
|
|
@@ -453,7 +453,7 @@ const migrate = command({
|
|
|
453
453
|
description: "Run migrations",
|
|
454
454
|
handler: async (args) => {
|
|
455
455
|
if (args.debug) console.log(args);
|
|
456
|
-
const { startMigrate } = await import("./migrate-
|
|
456
|
+
const { startMigrate } = await import("./migrate-Cmd8Ouyk.mjs");
|
|
457
457
|
await startMigrate(args);
|
|
458
458
|
process.exit(0);
|
|
459
459
|
}
|
|
@@ -521,14 +521,14 @@ This command:
|
|
|
521
521
|
const { basePath, dbPath, migrate, migrateStatus } = args;
|
|
522
522
|
if (basePath) process.env.BASE_PATH = basePath;
|
|
523
523
|
if (migrate || migrateStatus) {
|
|
524
|
-
const { runSwitchboardMigrations } = await import("./switchboard-migrate-
|
|
524
|
+
const { runSwitchboardMigrations } = await import("./switchboard-migrate-Cwx-8MnF.mjs");
|
|
525
525
|
await runSwitchboardMigrations({
|
|
526
526
|
dbPath,
|
|
527
527
|
statusOnly: migrateStatus
|
|
528
528
|
});
|
|
529
529
|
process.exit(0);
|
|
530
530
|
}
|
|
531
|
-
const { startSwitchboard } = await import("./switchboard-
|
|
531
|
+
const { startSwitchboard } = await import("./switchboard-DXF1APL1.mjs");
|
|
532
532
|
const { defaultDriveUrl, renown } = await startSwitchboard(args);
|
|
533
533
|
console.log(" ➜ Switchboard:", defaultDriveUrl);
|
|
534
534
|
if (renown) console.log(" ➜ Identity:", renown.did);
|
|
@@ -612,7 +612,7 @@ This command:
|
|
|
612
612
|
args: vetraArgs,
|
|
613
613
|
handler: async (args) => {
|
|
614
614
|
if (args.debug) console.log(args);
|
|
615
|
-
const { startVetra } = await import("./vetra-
|
|
615
|
+
const { startVetra } = await import("./vetra-D3mHCtDl.mjs");
|
|
616
616
|
await startVetra(args);
|
|
617
617
|
}
|
|
618
618
|
}),
|
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { generateApp, generateDBSchema, generateEditor, generateFromFile, generateProcessor, generateSubgraph } from "@powerhousedao/codegen";
|
|
2
|
+
import { buildTsMorphProject } from "@powerhousedao/codegen/utils";
|
|
3
3
|
import path from "path";
|
|
4
4
|
//#region src/services/generate.ts
|
|
5
|
-
async function startGenerate(options) {
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const { documentModelFilePositional, documentModelFileOption, editorName, editorId, documentType, documentTypes, editorDirName, appName, appId, appDirName, allowedDocumentTypes, disableDragAndDrop, processorName, processorType, processorApps, importScriptName, migrationFile, schemaFile, verbose, force, useVersioning: useVersioningFlag, subgraphName, migrateLegacy } = options;
|
|
5
|
+
async function startGenerate(options, projectDir = process.cwd()) {
|
|
6
|
+
const { documentModelFilePositional, documentModelFileOption, editorName, editorId, documentType, documentTypes, editorDirName, appName, appId, appDirName, allowedDocumentTypes, disableDragAndDrop, processorName, processorType, processorApps, migrationFile, schemaFile, subgraphName } = options;
|
|
7
|
+
const project = buildTsMorphProject(projectDir);
|
|
9
8
|
const documentModelFile = documentModelFilePositional ?? documentModelFileOption;
|
|
10
|
-
const useVersioning = useVersioningFlag || migrateLegacy;
|
|
11
9
|
const isDragAndDropEnabled = disableDragAndDrop !== true;
|
|
12
10
|
const filePath = Array.isArray(documentModelFile) ? documentModelFile.join(" ") : documentModelFile;
|
|
13
11
|
const documentTypeFromDocumentTypes = documentTypes?.split(",")[0];
|
|
@@ -19,40 +17,30 @@ async function startGenerate(options) {
|
|
|
19
17
|
editorName,
|
|
20
18
|
editorId,
|
|
21
19
|
editorDirName,
|
|
22
|
-
documentTypes: [documentTypeToUse]
|
|
23
|
-
|
|
24
|
-
});
|
|
20
|
+
documentTypes: [documentTypeToUse]
|
|
21
|
+
}, project);
|
|
25
22
|
} else if (appName !== void 0) await generateApp({
|
|
26
23
|
appName,
|
|
27
24
|
appId,
|
|
28
25
|
appDirName,
|
|
29
26
|
allowedDocumentTypes,
|
|
30
|
-
isDragAndDropEnabled
|
|
31
|
-
|
|
32
|
-
});
|
|
27
|
+
isDragAndDropEnabled
|
|
28
|
+
}, project);
|
|
33
29
|
else if (processorName !== void 0) await generateProcessor({
|
|
34
30
|
processorName,
|
|
35
31
|
processorType,
|
|
36
|
-
skipFormat,
|
|
37
32
|
processorApps,
|
|
38
33
|
documentTypes: [documentTypeToUse].filter((t) => t !== void 0)
|
|
39
|
-
});
|
|
40
|
-
else if (subgraphName !== void 0) await generateSubgraph(subgraphName,
|
|
41
|
-
else if (importScriptName !== void 0) await generateImportScript(importScriptName, config);
|
|
34
|
+
}, project);
|
|
35
|
+
else if (subgraphName !== void 0) await generateSubgraph(subgraphName, project);
|
|
42
36
|
else if (migrationFile !== void 0) await generateDBSchema({
|
|
43
37
|
migrationFile: path.join(process.cwd(), migrationFile),
|
|
44
38
|
schemaFile: schemaFile ? path.join(process.cwd(), schemaFile) : void 0
|
|
45
39
|
});
|
|
46
|
-
else if (filePath !== void 0) await generateFromFile(
|
|
47
|
-
|
|
48
|
-
config,
|
|
49
|
-
options,
|
|
50
|
-
useVersioning,
|
|
51
|
-
migrateLegacy
|
|
52
|
-
});
|
|
53
|
-
else await generate(config, useVersioning, migrateLegacy);
|
|
40
|
+
else if (filePath !== void 0) await generateFromFile(filePath, project);
|
|
41
|
+
await project.save();
|
|
54
42
|
}
|
|
55
43
|
//#endregion
|
|
56
|
-
export { startGenerate
|
|
44
|
+
export { startGenerate };
|
|
57
45
|
|
|
58
|
-
//# sourceMappingURL=generate-
|
|
46
|
+
//# sourceMappingURL=generate-UNkoTojF.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-UNkoTojF.mjs","names":[],"sources":["../src/services/generate.ts"],"sourcesContent":["import {\n generateApp,\n generateDBSchema,\n generateEditor,\n generateFromFile,\n generateProcessor,\n generateSubgraph,\n} from \"@powerhousedao/codegen\";\nimport { buildTsMorphProject } from \"@powerhousedao/codegen/utils\";\nimport path from \"path\";\nimport type { GenerateArgs } from \"../types.js\";\n\nexport async function startGenerate(\n options: GenerateArgs,\n projectDir = process.cwd(),\n) {\n const {\n documentModelFilePositional,\n documentModelFileOption,\n editorName,\n editorId,\n documentType,\n // [DEPRECATED] - should be removed asap\n documentTypes,\n editorDirName,\n appName,\n appId,\n appDirName,\n allowedDocumentTypes,\n disableDragAndDrop,\n processorName,\n processorType,\n processorApps,\n migrationFile,\n schemaFile,\n subgraphName,\n } = options;\n const project = buildTsMorphProject(projectDir);\n\n const documentModelFile =\n documentModelFilePositional ?? documentModelFileOption;\n\n const isDragAndDropEnabled = disableDragAndDrop !== true;\n const filePath = Array.isArray(documentModelFile)\n ? documentModelFile.join(\" \")\n : documentModelFile;\n\n const documentTypeFromDocumentTypes = documentTypes?.split(\",\")[0];\n if (documentTypes) {\n console.warn(\n `[WARNING] --document-types is deprecated. Generated editor code is not set up to use multiple document types. Using the first document type in the list you specified (${documentTypeFromDocumentTypes})`,\n );\n }\n const documentTypeToUse = documentType ?? documentTypeFromDocumentTypes;\n\n if (editorName !== undefined) {\n if (!documentTypeToUse) {\n throw new Error(\n \"Please specify a document type for the generated editor.\",\n );\n }\n await generateEditor(\n {\n editorName,\n editorId,\n editorDirName,\n documentTypes: [documentTypeToUse],\n },\n project,\n );\n } else if (appName !== undefined) {\n await generateApp(\n {\n appName,\n appId,\n appDirName,\n allowedDocumentTypes,\n isDragAndDropEnabled,\n },\n project,\n );\n } else if (processorName !== undefined) {\n await generateProcessor(\n {\n processorName,\n processorType,\n processorApps,\n documentTypes: [documentTypeToUse].filter((t) => t !== undefined),\n },\n project,\n );\n } else if (subgraphName !== undefined) {\n await generateSubgraph(subgraphName, project);\n } else if (migrationFile !== undefined) {\n await generateDBSchema({\n migrationFile: path.join(process.cwd(), migrationFile),\n schemaFile: schemaFile ? path.join(process.cwd(), schemaFile) : undefined,\n });\n } else if (filePath !== undefined) {\n await generateFromFile(filePath, project);\n }\n // calling save once at the end is much faster than saving as we go\n // the ts-morph project already has the updated data for manipulation without saving\n await project.save();\n}\n"],"mappings":";;;;AAYA,eAAsB,cACpB,SACA,aAAa,QAAQ,KAAK,EAC1B;CACA,MAAM,EACJ,6BACA,yBACA,YACA,UACA,cAEA,eACA,eACA,SACA,OACA,YACA,sBACA,oBACA,eACA,eACA,eACA,eACA,YACA,iBACE;CACJ,MAAM,UAAU,oBAAoB,WAAW;CAE/C,MAAM,oBACJ,+BAA+B;CAEjC,MAAM,uBAAuB,uBAAuB;CACpD,MAAM,WAAW,MAAM,QAAQ,kBAAkB,GAC7C,kBAAkB,KAAK,IAAI,GAC3B;CAEJ,MAAM,gCAAgC,eAAe,MAAM,IAAI,CAAC;AAChE,KAAI,cACF,SAAQ,KACN,0KAA0K,8BAA8B,GACzM;CAEH,MAAM,oBAAoB,gBAAgB;AAE1C,KAAI,eAAe,KAAA,GAAW;AAC5B,MAAI,CAAC,kBACH,OAAM,IAAI,MACR,2DACD;AAEH,QAAM,eACJ;GACE;GACA;GACA;GACA,eAAe,CAAC,kBAAkB;GACnC,EACD,QACD;YACQ,YAAY,KAAA,EACrB,OAAM,YACJ;EACE;EACA;EACA;EACA;EACA;EACD,EACD,QACD;UACQ,kBAAkB,KAAA,EAC3B,OAAM,kBACJ;EACE;EACA;EACA;EACA,eAAe,CAAC,kBAAkB,CAAC,QAAQ,MAAM,MAAM,KAAA,EAAU;EAClE,EACD,QACD;UACQ,iBAAiB,KAAA,EAC1B,OAAM,iBAAiB,cAAc,QAAQ;UACpC,kBAAkB,KAAA,EAC3B,OAAM,iBAAiB;EACrB,eAAe,KAAK,KAAK,QAAQ,KAAK,EAAE,cAAc;EACtD,YAAY,aAAa,KAAK,KAAK,QAAQ,KAAK,EAAE,WAAW,GAAG,KAAA;EACjE,CAAC;UACO,aAAa,KAAA,EACtB,OAAM,iBAAiB,UAAU,QAAQ;AAI3C,OAAM,QAAQ,MAAM"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init-
|
|
1
|
+
{"version":3,"file":"init-rIIiKQI4.mjs","names":[],"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\n const url = new URL(remoteDriveUrl);\n const graphqlEndpoint = `${url.protocol}//${url.host}/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"],"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;;EAIT,MAAM,MAAM,IAAI,IAAI,eAAe;EACnC,MAAM,kBAAkB,GAAG,IAAI,SAAS,IAAI,IAAI,KAAK;EAErD,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,Y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;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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inspect-
|
|
1
|
+
{"version":3,"file":"inspect-Qn_mykOH.mjs","names":[],"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"],"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"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { migrate } from "@powerhousedao/codegen";
|
|
2
|
+
//#region src/services/migrate.ts
|
|
3
|
+
async function startMigrate(args) {
|
|
4
|
+
const { version, debug } = args;
|
|
5
|
+
if (debug) console.log({ args });
|
|
6
|
+
await migrate(version);
|
|
7
|
+
}
|
|
8
|
+
//#endregion
|
|
9
|
+
export { startMigrate };
|
|
10
|
+
|
|
11
|
+
//# sourceMappingURL=migrate-Cmd8Ouyk.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate-Cmd8Ouyk.mjs","names":[],"sources":["../src/services/migrate.ts"],"sourcesContent":["import { migrate } from \"@powerhousedao/codegen\";\nimport type { MigrateArgs } from \"../types.js\";\n\nexport async function startMigrate(args: MigrateArgs) {\n const { version, debug } = args;\n if (debug) {\n console.log({ args });\n }\n await migrate(version);\n}\n"],"mappings":";;AAGA,eAAsB,aAAa,MAAmB;CACpD,MAAM,EAAE,SAAS,UAAU;AAC3B,KAAI,MACF,SAAQ,IAAI,EAAE,MAAM,CAAC;AAEvB,OAAM,QAAQ,QAAQ"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"switchboard-
|
|
1
|
+
{"version":3,"file":"switchboard-BclxuF4j.mjs","names":["startSwitchboard","startSwitchboardServer"],"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 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"],"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,SACA,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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"switchboard-migrate-
|
|
1
|
+
{"version":3,"file":"switchboard-migrate-Cwx-8MnF.mjs","names":[],"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"],"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"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as generateProjectDriveId } from "./utils-CFkM2mAC.mjs";
|
|
2
2
|
import "./assign-env-vars-CzHgn5ax.mjs";
|
|
3
3
|
import { t as runConnectStudio } from "./connect-studio-38_NrT_a.mjs";
|
|
4
|
-
import { n as startSwitchboard } from "./switchboard-
|
|
4
|
+
import { n as startSwitchboard } from "./switchboard-BclxuF4j.mjs";
|
|
5
5
|
import { execSync } from "node:child_process";
|
|
6
6
|
import { createLogger } from "vite";
|
|
7
7
|
import { createVetraDocument, getVetraDocuments, setPackageGithubUrl } from "@powerhousedao/common/utils";
|
|
@@ -357,4 +357,4 @@ async function startVetra(args) {
|
|
|
357
357
|
//#endregion
|
|
358
358
|
export { startVetra };
|
|
359
359
|
|
|
360
|
-
//# sourceMappingURL=vetra-
|
|
360
|
+
//# sourceMappingURL=vetra-D3mHCtDl.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vetra-vUDKNfbX.mjs","names":[],"sources":["../src/utils/configure-vetra-github-url.ts","../src/services/vetra.ts"],"sourcesContent":["import {\n createVetraDocument,\n getVetraDocuments,\n setPackageGithubUrl,\n} from \"@powerhousedao/common/utils\";\nimport { red } from \"colorette\";\nimport { execSync } from \"node:child_process\";\nimport { createInterface } from \"node:readline\";\n\n/**\n * Get git remote URL (origin)\n * @returns Git remote URL or null if not configured\n */\nfunction getGitRemoteUrl(): string | null {\n try {\n const url = execSync(\"git remote get-url origin\", {\n encoding: \"utf-8\",\n stdio: [\"pipe\", \"pipe\", \"pipe\"],\n }).trim();\n return url || null;\n } catch {\n return null;\n }\n}\n\n/**\n * Prompt user to enter a custom GitHub URL\n */\nasync function promptForCustomUrl(): Promise<string | null> {\n return new Promise((resolve) => {\n const rl = createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n\n process.stdout.write(\"\\nEnter GitHub URL (or press Enter to skip): \");\n\n rl.on(\"line\", (answer: string) => {\n rl.close();\n const url = answer.trim();\n resolve(url || null);\n });\n });\n}\n\n/**\n * Prompt yes/no question\n */\nasync function promptYesNo(question: string): Promise<boolean> {\n return new Promise((resolve) => {\n const rl = createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n\n process.stdout.write(`\\n${question} (y/n): `);\n\n rl.on(\"line\", (answer: string) => {\n rl.close();\n const response = answer.trim().toLowerCase();\n resolve(response === \"y\" || response === \"yes\");\n });\n });\n}\n\n/**\n * Prompt user to select or enter GitHub URL\n * @param gitRemoteUrl - Git remote URL if available\n * @returns Selected URL or null if skipped\n */\nasync function promptForGithubUrl(\n gitRemoteUrl: string | null,\n): Promise<string | null> {\n return new Promise((resolve) => {\n const rl = createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n\n console.log(\"\\n\" + \"=\".repeat(50));\n console.log(\"🔍 Vetra Package Configuration\");\n console.log(\"=\".repeat(50));\n console.log(\n \"\\nWe detected a Vetra package document in your remote drive without a GitHub URL configured.\",\n );\n console.log(\"\\nWould you like to configure the GitHub URL now?\");\n\n if (gitRemoteUrl) {\n console.log(`\\nGit remote URL detected: ${gitRemoteUrl}`);\n console.log(\"\\nOptions:\");\n console.log(\"1. Use detected URL\");\n console.log(\"2. Enter a different URL\");\n console.log(\"3. Skip configuration\");\n\n process.stdout.write(\"\\nSelect an option (1-3): \");\n\n const handleAnswer = (answer: string) => {\n const choice = answer.trim();\n\n if (choice === \"1\") {\n rl.close();\n resolve(gitRemoteUrl);\n } else if (choice === \"2\") {\n rl.close();\n promptForCustomUrl()\n .then(resolve)\n .catch(() => resolve(null));\n } else if (choice === \"3\") {\n rl.close();\n resolve(null);\n } else {\n process.stdout.write(\"Invalid choice. Select an option (1-3): \");\n }\n };\n\n rl.on(\"line\", handleAnswer);\n } else {\n console.log(\"\\nNo git remote URL detected.\");\n console.log(\"\\nOptions:\");\n console.log(\"1. Enter GitHub URL manually\");\n console.log(\"2. Skip configuration\");\n\n process.stdout.write(\"\\nSelect an option (1-2): \");\n\n const handleAnswer = (answer: string) => {\n const choice = answer.trim();\n\n if (choice === \"1\") {\n rl.close();\n promptForCustomUrl()\n .then(resolve)\n .catch(() => resolve(null));\n } else if (choice === \"2\") {\n rl.close();\n resolve(null);\n } else {\n process.stdout.write(\"Invalid choice. Select an option (1-2): \");\n }\n };\n\n rl.on(\"line\", handleAnswer);\n }\n });\n}\n\n/**\n * Set git remote URL (origin)\n */\nfunction setGitRemoteUrl(url: string): void {\n try {\n execSync(`git remote add origin ${url}`, {\n stdio: \"inherit\",\n });\n console.log(`✅ Git remote origin set to: ${url}`);\n } catch {\n try {\n execSync(`git remote set-url origin ${url}`, {\n stdio: \"inherit\",\n });\n console.log(`✅ Git remote origin updated to: ${url}`);\n } catch {\n console.error(red(`❌ Failed to set git remote URL`));\n }\n }\n}\n\n/**\n * Validates documents and returns the target document to use\n * Warns if multiple documents found\n */\nfunction validateAndSelectDocument<T>(documents: T[]): T | null {\n if (documents.length === 0) {\n return null;\n }\n\n if (documents.length > 1) {\n console.warn(\n `⚠️ Warning: Multiple Vetra documents found (${documents.length}). Using first document.`,\n );\n }\n\n return documents[0];\n}\n\nasync function applyGithubUrlConfiguration(\n graphqlEndpoint: string,\n vetraDriveId: string,\n documentId: string,\n selectedUrl: string,\n shouldSetRemote: boolean,\n): Promise<void> {\n // Set package GitHub URL\n await setPackageGithubUrl(\n graphqlEndpoint,\n vetraDriveId,\n documentId,\n selectedUrl,\n );\n\n console.log(`✅ GitHub URL configured: ${selectedUrl}`);\n\n // Set git remote URL if requested\n if (shouldSetRemote) {\n setGitRemoteUrl(selectedUrl);\n }\n}\n\nfunction logVerbose(message: string, verbose?: boolean): void {\n if (verbose) {\n console.log(message);\n }\n}\n\n/**\n * Sleep for a specified number of milliseconds\n */\nexport function sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\n/**\n * Configure GitHub URL for Vetra documents\n * @param switchboardPort - Port where switchboard is running\n * @param vetraDriveUrl - Remote drive URL\n * @param verbose - Enable verbose logging\n */\nexport async function configureVetraGithubUrl(\n switchboardPort: number,\n vetraDriveUrl: string,\n verbose?: boolean,\n): Promise<void> {\n logVerbose(\"Checking GitHub URL configuration...\", verbose);\n\n try {\n const graphqlEndpoint = `http://localhost:${switchboardPort}/graphql`;\n const vetraDriveId = vetraDriveUrl.split(\"/\").pop();\n if (!vetraDriveId) {\n throw new Error(\"Invalid vetraDriveUrl: unable to extract drive ID\");\n }\n\n const documents = await getVetraDocuments(graphqlEndpoint, vetraDriveId);\n\n // Skip if already configured\n if (documents.some((doc) => doc.githubUrl)) {\n logVerbose(\"GitHub URL already configured, skipping setup\", verbose);\n return;\n }\n\n // Get or create target document\n let targetDocumentId: string;\n const targetDocument = validateAndSelectDocument(documents);\n\n // Collect user input\n const gitRemoteUrl = getGitRemoteUrl();\n const selectedUrl = await promptForGithubUrl(gitRemoteUrl);\n\n if (!selectedUrl) {\n logVerbose(\"GitHub URL configuration skipped\", verbose);\n return;\n }\n\n let shouldSetRemote = false;\n if (selectedUrl !== gitRemoteUrl && !gitRemoteUrl) {\n shouldSetRemote = await promptYesNo(\"Set this as your git remote URL?\");\n }\n\n if (!targetDocument) {\n logVerbose(\"No Vetra documents found, creating new document...\", verbose);\n\n targetDocumentId = await createVetraDocument(\n graphqlEndpoint,\n vetraDriveId,\n \"vetra-package\",\n );\n\n logVerbose(`Created new document: ${targetDocumentId}`, verbose);\n } else {\n targetDocumentId = targetDocument.id;\n }\n\n await applyGithubUrlConfiguration(\n graphqlEndpoint,\n vetraDriveId,\n targetDocumentId,\n selectedUrl,\n shouldSetRemote,\n );\n } catch (error) {\n console.error(\n red(\n `⚠️ GitHub URL configuration failed: ${error instanceof Error ? error.message : String(error)}`,\n ),\n );\n logVerbose(String(error), verbose);\n }\n}\n","import type { VetraProcessorConfigType } from \"@powerhousedao/config\";\nimport { VETRA_PROCESSOR_CONFIG_KEY } from \"@powerhousedao/config\";\nimport type { IReactorClient } from \"@powerhousedao/reactor\";\nimport { addDefaultDrive } from \"@powerhousedao/switchboard/utils\";\nimport { blue, green, red, yellow, type Color } from \"colorette\";\nimport type { ILogger } from \"document-model\";\nimport { childLogger, setLogLevel } from \"document-model\";\nimport { createLogger } from \"vite\";\nimport type { VetraArgs } from \"../types.js\";\nimport { generateProjectDriveId } from \"../utils.js\";\nimport {\n configureVetraGithubUrl,\n sleep,\n} from \"../utils/configure-vetra-github-url.js\";\nimport { runConnectStudio } from \"./connect-studio.js\";\nimport { startSwitchboard } from \"./switchboard.js\";\n\nconst VETRA_DRIVE_NAME = \"vetra\";\n\nconst getDefaultVetraUrl = (port: number) =>\n `http://localhost:${port}/d/${generateProjectDriveId(VETRA_DRIVE_NAME)}`;\n\nconst getDriveId = (driveUrl: string | undefined): string =>\n driveUrl?.split(\"/\").pop() ?? generateProjectDriveId(VETRA_DRIVE_NAME);\n\nfunction createViteLogger(color: Color) {\n const customLogger = createLogger(\"info\");\n const loggerInfo = customLogger.info.bind(customLogger);\n customLogger.info = (msg, options) => {\n loggerInfo(color(msg), options);\n };\n const loggerWarn = customLogger.warn.bind(customLogger);\n customLogger.warn = (msg, options) => {\n loggerWarn(yellow(msg), options);\n };\n const loggerError = customLogger.error.bind(customLogger);\n customLogger.error = (msg, options) => {\n loggerError(red(msg), options);\n };\n\n const loggerWarnOnce = customLogger.warnOnce.bind(customLogger);\n customLogger.warnOnce = (msg, options) => {\n loggerWarnOnce(yellow(msg), options);\n };\n return customLogger;\n}\n\nasync function startVetraPreviewDrive(\n reactor: IReactorClient,\n port: number,\n verbose?: boolean,\n): Promise<string> {\n const previewDriveId = generateProjectDriveId(\"preview\");\n\n const previewDrive = {\n id: previewDriveId,\n slug: previewDriveId,\n global: {\n name: \"Vetra Preview\",\n icon: \"https://azure-elderly-tortoise-212.mypinata.cloud/ipfs/bafkreifddkbopiyvcirf7vaqar74th424r5phlxkdxniirdyg3qgu2ajha\",\n nodes: [],\n },\n local: {\n availableOffline: true,\n listeners: [],\n sharingType: \"public\" as const,\n triggers: [],\n },\n };\n\n const driveUrl = await addDefaultDrive(reactor, previewDrive, port);\n\n if (verbose) {\n console.log(blue(`Vetra Switchboard: Preview drive: ${driveUrl}`));\n }\n return driveUrl;\n}\nasync function startLocalVetraSwitchboard(args: VetraArgs, logger?: ILogger) {\n const {\n connectPort,\n switchboardPort,\n dev,\n packages,\n disableLocalPackages,\n debug,\n httpsKeyFile,\n httpsCertFile,\n remoteDrive,\n interactive,\n watch,\n verbose,\n } = args;\n\n // Convert single remote drive to array if provided\n const remoteDrives = remoteDrive ? [remoteDrive] : [];\n\n const vetraProcessorConfig: VetraProcessorConfigType = {\n interactive,\n driveUrl: remoteDrive ?? getDefaultVetraUrl(connectPort),\n driveId: getDriveId(remoteDrive),\n };\n\n const processorConfig = new Map<string, unknown>();\n processorConfig.set(VETRA_PROCESSOR_CONFIG_KEY, vetraProcessorConfig);\n\n const vetraDriveId = generateProjectDriveId(VETRA_DRIVE_NAME);\n\n try {\n const switchboard = await startSwitchboard(\n {\n ...args,\n useVetraDrive: true, // Use Vetra drive instead of Powerhouse drive\n mcp: true,\n port: switchboardPort,\n dev,\n packages,\n remoteDrives,\n vetraDriveId,\n disableLocalPackages,\n debug,\n httpsKeyFile,\n httpsCertFile,\n basePath: undefined,\n keypairPath: undefined,\n dbPath: undefined,\n useIdentity: undefined,\n migrate: undefined,\n migrateStatus: undefined,\n requireIdentity: undefined,\n },\n logger,\n );\n\n // Add preview drive (only in watch mode)\n let previewDriveUrl: string | null = null;\n if (watch) {\n try {\n previewDriveUrl = await startVetraPreviewDrive(\n switchboard.reactor,\n switchboardPort,\n verbose,\n );\n } catch (error) {\n console.error(error);\n }\n }\n\n if (verbose) {\n console.log(blue(`Vetra Switchboard: Started successfully`));\n if (remoteDrive) {\n console.log(\n blue(`Vetra Switchboard: Syncing with remote drive: ${remoteDrive}`),\n );\n }\n } else {\n console.log();\n console.log(\n blue(`Vetra Switchboard: http://localhost:${switchboardPort}/graphql`),\n );\n console.log(blue(` ➜ Drive URL: ${switchboard.defaultDriveUrl}`));\n if (previewDriveUrl) {\n console.log(blue(` ➜ Preview Drive URL: ${previewDriveUrl}`));\n }\n }\n return {\n driveUrl: switchboard.defaultDriveUrl || \"\",\n previewDriveUrl: previewDriveUrl,\n };\n } catch (error) {\n console.error(\n red(\n `Vetra Switchboard: ${error instanceof Error ? error.message : String(error)}`,\n ),\n );\n throw error instanceof Error ? error : new Error(String(error));\n }\n}\n\nexport async function startVetra(args: VetraArgs) {\n const {\n switchboardPort,\n connectPort,\n verbose,\n remoteDrive,\n disableConnect,\n debug,\n httpsCertFile,\n httpsKeyFile,\n disableLocalPackages,\n host,\n open,\n cors,\n strictPort,\n printUrls,\n bindCLIShortcuts,\n watchTimeout,\n } = args;\n\n const switchboardLogger = childLogger([\"vetra\", \"switchboard\"]);\n\n try {\n // Set default log level to info if not already specified\n if (!process.env.LOG_LEVEL) {\n setLogLevel(\"info\");\n }\n\n if (verbose) {\n switchboardLogger.info(\"Starting Vetra Switchboard...\");\n if (remoteDrive) {\n const source = remoteDrive\n ? \"command line argument\"\n : \"powerhouse.config.json\";\n switchboardLogger.info(`Using vetraUrl from ${source}: ${remoteDrive}`);\n }\n }\n const switchboardResult = await startLocalVetraSwitchboard(\n {\n ...args,\n dev: true, // Vetra always runs in dev mode to load local packages\n httpsKeyFile,\n httpsCertFile,\n disableLocalPackages,\n debug,\n },\n switchboardLogger,\n );\n const driveUrl: string = switchboardResult.driveUrl || remoteDrive || \"\";\n const previewDriveUrl = switchboardResult.previewDriveUrl;\n\n // Configure GitHub URL if remote drive is set\n if (remoteDrive) {\n // give some time for the drive to process initial strands\n await sleep(3000);\n\n await configureVetraGithubUrl(switchboardPort, remoteDrive, verbose);\n\n // give some time for the user to read log messages\n await sleep(2000);\n }\n\n if (verbose) {\n console.log(\"Starting Codegen Reactor...\");\n }\n\n // Start Connect pointing to the drive (unless disabled)\n if (!disableConnect) {\n if (verbose) {\n console.log(\"Starting Connect...\");\n const drives = previewDriveUrl\n ? `${driveUrl}, ${previewDriveUrl}`\n : driveUrl;\n console.log(` ➜ Connect will use drives: ${drives}`);\n }\n console.log();\n console.log(green(`Vetra Connect: http://localhost:${connectPort}`));\n\n const customViteLogger = createViteLogger(green);\n\n await runConnectStudio(\n {\n ...args,\n defaultDrivesUrl: previewDriveUrl\n ? [driveUrl, previewDriveUrl].join(\",\")\n : driveUrl,\n drivesPreserveStrategy: \"preserve-all\",\n port: connectPort,\n disableLocalPackages,\n debug,\n host: host,\n open: open,\n cors: cors,\n strictPort: strictPort,\n printUrls: printUrls,\n bindCLIShortcuts: bindCLIShortcuts,\n watchTimeout: watchTimeout,\n },\n customViteLogger,\n );\n }\n } catch (error) {\n console.error(error);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAaA,SAAS,kBAAiC;AACxC,KAAI;AAKF,SAJY,SAAS,6BAA6B;GAChD,UAAU;GACV,OAAO;IAAC;IAAQ;IAAQ;IAAO;GAChC,CAAC,CAAC,MAAM,IACK;SACR;AACN,SAAO;;;;;;AAOX,eAAe,qBAA6C;AAC1D,QAAO,IAAI,SAAS,YAAY;EAC9B,MAAM,KAAK,gBAAgB;GACzB,OAAO,QAAQ;GACf,QAAQ,QAAQ;GACjB,CAAC;AAEF,UAAQ,OAAO,MAAM,gDAAgD;AAErE,KAAG,GAAG,SAAS,WAAmB;AAChC,MAAG,OAAO;AAEV,WADY,OAAO,MAAM,IACV,KAAK;IACpB;GACF;;;;;AAMJ,eAAe,YAAY,UAAoC;AAC7D,QAAO,IAAI,SAAS,YAAY;EAC9B,MAAM,KAAK,gBAAgB;GACzB,OAAO,QAAQ;GACf,QAAQ,QAAQ;GACjB,CAAC;AAEF,UAAQ,OAAO,MAAM,KAAK,SAAS,UAAU;AAE7C,KAAG,GAAG,SAAS,WAAmB;AAChC,MAAG,OAAO;GACV,MAAM,WAAW,OAAO,MAAM,CAAC,aAAa;AAC5C,WAAQ,aAAa,OAAO,aAAa,MAAM;IAC/C;GACF;;;;;;;AAQJ,eAAe,mBACb,cACwB;AACxB,QAAO,IAAI,SAAS,YAAY;EAC9B,MAAM,KAAK,gBAAgB;GACzB,OAAO,QAAQ;GACf,QAAQ,QAAQ;GACjB,CAAC;AAEF,UAAQ,IAAI,OAAO,IAAI,OAAO,GAAG,CAAC;AAClC,UAAQ,IAAI,iCAAiC;AAC7C,UAAQ,IAAI,IAAI,OAAO,GAAG,CAAC;AAC3B,UAAQ,IACN,+FACD;AACD,UAAQ,IAAI,oDA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1
|
+
{"version":3,"file":"vetra-D3mHCtDl.mjs","names":[],"sources":["../src/utils/configure-vetra-github-url.ts","../src/services/vetra.ts"],"sourcesContent":["import {\n createVetraDocument,\n getVetraDocuments,\n setPackageGithubUrl,\n} from \"@powerhousedao/common/utils\";\nimport { red } from \"colorette\";\nimport { execSync } from \"node:child_process\";\nimport { createInterface } from \"node:readline\";\n\n/**\n * Get git remote URL (origin)\n * @returns Git remote URL or null if not configured\n */\nfunction getGitRemoteUrl(): string | null {\n try {\n const url = execSync(\"git remote get-url origin\", {\n encoding: \"utf-8\",\n stdio: [\"pipe\", \"pipe\", \"pipe\"],\n }).trim();\n return url || null;\n } catch {\n return null;\n }\n}\n\n/**\n * Prompt user to enter a custom GitHub URL\n */\nasync function promptForCustomUrl(): Promise<string | null> {\n return new Promise((resolve) => {\n const rl = createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n\n process.stdout.write(\"\\nEnter GitHub URL (or press Enter to skip): \");\n\n rl.on(\"line\", (answer: string) => {\n rl.close();\n const url = answer.trim();\n resolve(url || null);\n });\n });\n}\n\n/**\n * Prompt yes/no question\n */\nasync function promptYesNo(question: string): Promise<boolean> {\n return new Promise((resolve) => {\n const rl = createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n\n process.stdout.write(`\\n${question} (y/n): `);\n\n rl.on(\"line\", (answer: string) => {\n rl.close();\n const response = answer.trim().toLowerCase();\n resolve(response === \"y\" || response === \"yes\");\n });\n });\n}\n\n/**\n * Prompt user to select or enter GitHub URL\n * @param gitRemoteUrl - Git remote URL if available\n * @returns Selected URL or null if skipped\n */\nasync function promptForGithubUrl(\n gitRemoteUrl: string | null,\n): Promise<string | null> {\n return new Promise((resolve) => {\n const rl = createInterface({\n input: process.stdin,\n output: process.stdout,\n });\n\n console.log(\"\\n\" + \"=\".repeat(50));\n console.log(\"🔍 Vetra Package Configuration\");\n console.log(\"=\".repeat(50));\n console.log(\n \"\\nWe detected a Vetra package document in your remote drive without a GitHub URL configured.\",\n );\n console.log(\"\\nWould you like to configure the GitHub URL now?\");\n\n if (gitRemoteUrl) {\n console.log(`\\nGit remote URL detected: ${gitRemoteUrl}`);\n console.log(\"\\nOptions:\");\n console.log(\"1. Use detected URL\");\n console.log(\"2. Enter a different URL\");\n console.log(\"3. Skip configuration\");\n\n process.stdout.write(\"\\nSelect an option (1-3): \");\n\n const handleAnswer = (answer: string) => {\n const choice = answer.trim();\n\n if (choice === \"1\") {\n rl.close();\n resolve(gitRemoteUrl);\n } else if (choice === \"2\") {\n rl.close();\n promptForCustomUrl()\n .then(resolve)\n .catch(() => resolve(null));\n } else if (choice === \"3\") {\n rl.close();\n resolve(null);\n } else {\n process.stdout.write(\"Invalid choice. Select an option (1-3): \");\n }\n };\n\n rl.on(\"line\", handleAnswer);\n } else {\n console.log(\"\\nNo git remote URL detected.\");\n console.log(\"\\nOptions:\");\n console.log(\"1. Enter GitHub URL manually\");\n console.log(\"2. Skip configuration\");\n\n process.stdout.write(\"\\nSelect an option (1-2): \");\n\n const handleAnswer = (answer: string) => {\n const choice = answer.trim();\n\n if (choice === \"1\") {\n rl.close();\n promptForCustomUrl()\n .then(resolve)\n .catch(() => resolve(null));\n } else if (choice === \"2\") {\n rl.close();\n resolve(null);\n } else {\n process.stdout.write(\"Invalid choice. Select an option (1-2): \");\n }\n };\n\n rl.on(\"line\", handleAnswer);\n }\n });\n}\n\n/**\n * Set git remote URL (origin)\n */\nfunction setGitRemoteUrl(url: string): void {\n try {\n execSync(`git remote add origin ${url}`, {\n stdio: \"inherit\",\n });\n console.log(`✅ Git remote origin set to: ${url}`);\n } catch {\n try {\n execSync(`git remote set-url origin ${url}`, {\n stdio: \"inherit\",\n });\n console.log(`✅ Git remote origin updated to: ${url}`);\n } catch {\n console.error(red(`❌ Failed to set git remote URL`));\n }\n }\n}\n\n/**\n * Validates documents and returns the target document to use\n * Warns if multiple documents found\n */\nfunction validateAndSelectDocument<T>(documents: T[]): T | null {\n if (documents.length === 0) {\n return null;\n }\n\n if (documents.length > 1) {\n console.warn(\n `⚠️ Warning: Multiple Vetra documents found (${documents.length}). Using first document.`,\n );\n }\n\n return documents[0];\n}\n\nasync function applyGithubUrlConfiguration(\n graphqlEndpoint: string,\n vetraDriveId: string,\n documentId: string,\n selectedUrl: string,\n shouldSetRemote: boolean,\n): Promise<void> {\n // Set package GitHub URL\n await setPackageGithubUrl(\n graphqlEndpoint,\n vetraDriveId,\n documentId,\n selectedUrl,\n );\n\n console.log(`✅ GitHub URL configured: ${selectedUrl}`);\n\n // Set git remote URL if requested\n if (shouldSetRemote) {\n setGitRemoteUrl(selectedUrl);\n }\n}\n\nfunction logVerbose(message: string, verbose?: boolean): void {\n if (verbose) {\n console.log(message);\n }\n}\n\n/**\n * Sleep for a specified number of milliseconds\n */\nexport function sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\n/**\n * Configure GitHub URL for Vetra documents\n * @param switchboardPort - Port where switchboard is running\n * @param vetraDriveUrl - Remote drive URL\n * @param verbose - Enable verbose logging\n */\nexport async function configureVetraGithubUrl(\n switchboardPort: number,\n vetraDriveUrl: string,\n verbose?: boolean,\n): Promise<void> {\n logVerbose(\"Checking GitHub URL configuration...\", verbose);\n\n try {\n const graphqlEndpoint = `http://localhost:${switchboardPort}/graphql`;\n const vetraDriveId = vetraDriveUrl.split(\"/\").pop();\n if (!vetraDriveId) {\n throw new Error(\"Invalid vetraDriveUrl: unable to extract drive ID\");\n }\n\n const documents = await getVetraDocuments(graphqlEndpoint, vetraDriveId);\n\n // Skip if already configured\n if (documents.some((doc) => doc.githubUrl)) {\n logVerbose(\"GitHub URL already configured, skipping setup\", verbose);\n return;\n }\n\n // Get or create target document\n let targetDocumentId: string;\n const targetDocument = validateAndSelectDocument(documents);\n\n // Collect user input\n const gitRemoteUrl = getGitRemoteUrl();\n const selectedUrl = await promptForGithubUrl(gitRemoteUrl);\n\n if (!selectedUrl) {\n logVerbose(\"GitHub URL configuration skipped\", verbose);\n return;\n }\n\n let shouldSetRemote = false;\n if (selectedUrl !== gitRemoteUrl && !gitRemoteUrl) {\n shouldSetRemote = await promptYesNo(\"Set this as your git remote URL?\");\n }\n\n if (!targetDocument) {\n logVerbose(\"No Vetra documents found, creating new document...\", verbose);\n\n targetDocumentId = await createVetraDocument(\n graphqlEndpoint,\n vetraDriveId,\n \"vetra-package\",\n );\n\n logVerbose(`Created new document: ${targetDocumentId}`, verbose);\n } else {\n targetDocumentId = targetDocument.id;\n }\n\n await applyGithubUrlConfiguration(\n graphqlEndpoint,\n vetraDriveId,\n targetDocumentId,\n selectedUrl,\n shouldSetRemote,\n );\n } catch (error) {\n console.error(\n red(\n `⚠️ GitHub URL configuration failed: ${error instanceof Error ? error.message : String(error)}`,\n ),\n );\n logVerbose(String(error), verbose);\n }\n}\n","import type { VetraProcessorConfigType } from \"@powerhousedao/config\";\nimport { VETRA_PROCESSOR_CONFIG_KEY } from \"@powerhousedao/config\";\nimport type { IReactorClient } from \"@powerhousedao/reactor\";\nimport { addDefaultDrive } from \"@powerhousedao/switchboard/utils\";\nimport { blue, green, red, yellow, type Color } from \"colorette\";\nimport type { ILogger } from \"document-model\";\nimport { childLogger, setLogLevel } from \"document-model\";\nimport { createLogger } from \"vite\";\nimport type { VetraArgs } from \"../types.js\";\nimport { generateProjectDriveId } from \"../utils.js\";\nimport {\n configureVetraGithubUrl,\n sleep,\n} from \"../utils/configure-vetra-github-url.js\";\nimport { runConnectStudio } from \"./connect-studio.js\";\nimport { startSwitchboard } from \"./switchboard.js\";\n\nconst VETRA_DRIVE_NAME = \"vetra\";\n\nconst getDefaultVetraUrl = (port: number) =>\n `http://localhost:${port}/d/${generateProjectDriveId(VETRA_DRIVE_NAME)}`;\n\nconst getDriveId = (driveUrl: string | undefined): string =>\n driveUrl?.split(\"/\").pop() ?? generateProjectDriveId(VETRA_DRIVE_NAME);\n\nfunction createViteLogger(color: Color) {\n const customLogger = createLogger(\"info\");\n const loggerInfo = customLogger.info.bind(customLogger);\n customLogger.info = (msg, options) => {\n loggerInfo(color(msg), options);\n };\n const loggerWarn = customLogger.warn.bind(customLogger);\n customLogger.warn = (msg, options) => {\n loggerWarn(yellow(msg), options);\n };\n const loggerError = customLogger.error.bind(customLogger);\n customLogger.error = (msg, options) => {\n loggerError(red(msg), options);\n };\n\n const loggerWarnOnce = customLogger.warnOnce.bind(customLogger);\n customLogger.warnOnce = (msg, options) => {\n loggerWarnOnce(yellow(msg), options);\n };\n return customLogger;\n}\n\nasync function startVetraPreviewDrive(\n reactor: IReactorClient,\n port: number,\n verbose?: boolean,\n): Promise<string> {\n const previewDriveId = generateProjectDriveId(\"preview\");\n\n const previewDrive = {\n id: previewDriveId,\n slug: previewDriveId,\n global: {\n name: \"Vetra Preview\",\n icon: \"https://azure-elderly-tortoise-212.mypinata.cloud/ipfs/bafkreifddkbopiyvcirf7vaqar74th424r5phlxkdxniirdyg3qgu2ajha\",\n nodes: [],\n },\n local: {\n availableOffline: true,\n listeners: [],\n sharingType: \"public\" as const,\n triggers: [],\n },\n };\n\n const driveUrl = await addDefaultDrive(reactor, previewDrive, port);\n\n if (verbose) {\n console.log(blue(`Vetra Switchboard: Preview drive: ${driveUrl}`));\n }\n return driveUrl;\n}\nasync function startLocalVetraSwitchboard(args: VetraArgs, logger?: ILogger) {\n const {\n connectPort,\n switchboardPort,\n dev,\n packages,\n disableLocalPackages,\n debug,\n httpsKeyFile,\n httpsCertFile,\n remoteDrive,\n interactive,\n watch,\n verbose,\n } = args;\n\n // Convert single remote drive to array if provided\n const remoteDrives = remoteDrive ? [remoteDrive] : [];\n\n const vetraProcessorConfig: VetraProcessorConfigType = {\n interactive,\n driveUrl: remoteDrive ?? getDefaultVetraUrl(connectPort),\n driveId: getDriveId(remoteDrive),\n };\n\n const processorConfig = new Map<string, unknown>();\n processorConfig.set(VETRA_PROCESSOR_CONFIG_KEY, vetraProcessorConfig);\n\n const vetraDriveId = generateProjectDriveId(VETRA_DRIVE_NAME);\n\n try {\n const switchboard = await startSwitchboard(\n {\n ...args,\n useVetraDrive: true, // Use Vetra drive instead of Powerhouse drive\n mcp: true,\n port: switchboardPort,\n dev,\n packages,\n remoteDrives,\n vetraDriveId,\n disableLocalPackages,\n debug,\n httpsKeyFile,\n httpsCertFile,\n basePath: undefined,\n keypairPath: undefined,\n dbPath: undefined,\n useIdentity: undefined,\n migrate: undefined,\n migrateStatus: undefined,\n requireIdentity: undefined,\n },\n logger,\n );\n\n // Add preview drive (only in watch mode)\n let previewDriveUrl: string | null = null;\n if (watch) {\n try {\n previewDriveUrl = await startVetraPreviewDrive(\n switchboard.reactor,\n switchboardPort,\n verbose,\n );\n } catch (error) {\n console.error(error);\n }\n }\n\n if (verbose) {\n console.log(blue(`Vetra Switchboard: Started successfully`));\n if (remoteDrive) {\n console.log(\n blue(`Vetra Switchboard: Syncing with remote drive: ${remoteDrive}`),\n );\n }\n } else {\n console.log();\n console.log(\n blue(`Vetra Switchboard: http://localhost:${switchboardPort}/graphql`),\n );\n console.log(blue(` ➜ Drive URL: ${switchboard.defaultDriveUrl}`));\n if (previewDriveUrl) {\n console.log(blue(` ➜ Preview Drive URL: ${previewDriveUrl}`));\n }\n }\n return {\n driveUrl: switchboard.defaultDriveUrl || \"\",\n previewDriveUrl: previewDriveUrl,\n };\n } catch (error) {\n console.error(\n red(\n `Vetra Switchboard: ${error instanceof Error ? error.message : String(error)}`,\n ),\n );\n throw error instanceof Error ? error : new Error(String(error));\n }\n}\n\nexport async function startVetra(args: VetraArgs) {\n const {\n switchboardPort,\n connectPort,\n verbose,\n remoteDrive,\n disableConnect,\n debug,\n httpsCertFile,\n httpsKeyFile,\n disableLocalPackages,\n host,\n open,\n cors,\n strictPort,\n printUrls,\n bindCLIShortcuts,\n watchTimeout,\n } = args;\n\n const switchboardLogger = childLogger([\"vetra\", \"switchboard\"]);\n\n try {\n // Set default log level to info if not already specified\n if (!process.env.LOG_LEVEL) {\n setLogLevel(\"info\");\n }\n\n if (verbose) {\n switchboardLogger.info(\"Starting Vetra Switchboard...\");\n if (remoteDrive) {\n const source = remoteDrive\n ? \"command line argument\"\n : \"powerhouse.config.json\";\n switchboardLogger.info(`Using vetraUrl from ${source}: ${remoteDrive}`);\n }\n }\n const switchboardResult = await startLocalVetraSwitchboard(\n {\n ...args,\n dev: true, // Vetra always runs in dev mode to load local packages\n httpsKeyFile,\n httpsCertFile,\n disableLocalPackages,\n debug,\n },\n switchboardLogger,\n );\n const driveUrl: string = switchboardResult.driveUrl || remoteDrive || \"\";\n const previewDriveUrl = switchboardResult.previewDriveUrl;\n\n // Configure GitHub URL if remote drive is set\n if (remoteDrive) {\n // give some time for the drive to process initial strands\n await sleep(3000);\n\n await configureVetraGithubUrl(switchboardPort, remoteDrive, verbose);\n\n // give some time for the user to read log messages\n await sleep(2000);\n }\n\n if (verbose) {\n console.log(\"Starting Codegen Reactor...\");\n }\n\n // Start Connect pointing to the drive (unless disabled)\n if (!disableConnect) {\n if (verbose) {\n console.log(\"Starting Connect...\");\n const drives = previewDriveUrl\n ? `${driveUrl}, ${previewDriveUrl}`\n : driveUrl;\n console.log(` ➜ Connect will use drives: ${drives}`);\n }\n console.log();\n console.log(green(`Vetra Connect: http://localhost:${connectPort}`));\n\n const customViteLogger = createViteLogger(green);\n\n await runConnectStudio(\n {\n ...args,\n defaultDrivesUrl: previewDriveUrl\n ? [driveUrl, previewDriveUrl].join(\",\")\n : driveUrl,\n drivesPreserveStrategy: \"preserve-all\",\n port: connectPort,\n disableLocalPackages,\n debug,\n host: host,\n open: open,\n cors: cors,\n strictPort: strictPort,\n printUrls: printUrls,\n bindCLIShortcuts: bindCLIShortcuts,\n watchTimeout: watchTimeout,\n },\n customViteLogger,\n );\n }\n } catch (error) {\n console.error(error);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AAaA,SAAS,kBAAiC;AACxC,KAAI;AAKF,SAJY,SAAS,6BAA6B;GAChD,UAAU;GACV,OAAO;IAAC;IAAQ;IAAQ;IAAO;GAChC,CAAC,CAAC,MAAM,IACK;SACR;AAC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B,KAAK,gCAAgC;AACvD,OAAI,aAAa;IACf,MAAM,SAAS,cACX,0BACA;AACJ,sBAAkB,KAAK,uBAAuB,OAAO,IAAI,cAAc;;;EAG3E,MAAM,oBAAoB,MAAM,2BAC9B;GACE,GAAG;GACH,KAAK;GACL;GACA;GACA;GACA;GACD,EACD,kBACD;EACD,MAAM,WAAmB,kBAAkB,YAAY,eAAe;EACtE,MAAM,kBAAkB,kBAAkB;AAG1C,MAAI,aAAa;AAEf,SAAM,MAAM,IAAK;AAEjB,SAAM,wBAAwB,iBAAiB,aAAa,QAAQ;AAGpE,SAAM,MAAM,IAAK;;AAGnB,MAAI,QACF,SAAQ,IAAI,8BAA8B;AAI5C,MAAI,CAAC,gBAAgB;AACnB,OAAI,SAAS;AACX,YAAQ,IAAI,sBAAsB;IAClC,MAAM,SAAS,kBACX,GAAG,SAAS,IAAI,oBAChB;AACJ,YAAQ,IAAI,iCAAiC,SAAS;;AAExD,WAAQ,KAAK;AACb,WAAQ,IAAI,MAAM,mCAAmC,cAAc,CAAC;GAEpE,MAAM,mBAAmB,iBAAiB,MAAM;AAEhD,SAAM,iBACJ;IACE,GAAG;IACH,kBAAkB,kBACd,CAAC,UAAU,gBAAgB,CAAC,KAAK,IAAI,GACrC;IACJ,wBAAwB;IACxB,MAAM;IACN;IACA;IACM;IACA;IACA;IACM;IACD;IACO;IACJ;IACf,EACD,iBACD;;UAEI,OAAO;AACd,UAAQ,MAAM,MAAM"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerhousedao/ph-cli",
|
|
3
|
-
"version": "6.0.0-dev.
|
|
3
|
+
"version": "6.0.0-dev.192",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"type": "module",
|
|
@@ -23,33 +23,34 @@
|
|
|
23
23
|
"keywords": [],
|
|
24
24
|
"author": "",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"tsdown": "0.21.1",
|
|
27
26
|
"@tsdown/css": "0.21.1",
|
|
28
|
-
"vite": "8.0.8",
|
|
29
27
|
"chalk": "5.6.2",
|
|
30
28
|
"change-case": "5.4.4",
|
|
31
29
|
"cmd-ts": "0.15.0",
|
|
32
|
-
"enquirer": "2.4.1",
|
|
33
30
|
"colorette": "2.0.20",
|
|
31
|
+
"enquirer": "2.4.1",
|
|
34
32
|
"kysely": "0.28.16",
|
|
35
33
|
"package-manager-detector": "1.6.0",
|
|
36
34
|
"pg": "8.18.0",
|
|
37
35
|
"read-pkg": "10.1.0",
|
|
38
36
|
"semver": "7.7.4",
|
|
39
37
|
"ts-morph": "27.0.2",
|
|
38
|
+
"tsdown": "0.21.1",
|
|
39
|
+
"vite": "8.0.8",
|
|
40
40
|
"write-package": "7.2.0",
|
|
41
|
-
"@powerhousedao/
|
|
42
|
-
"
|
|
43
|
-
"@powerhousedao/
|
|
44
|
-
"@powerhousedao/
|
|
45
|
-
"@powerhousedao/
|
|
46
|
-
"@powerhousedao/
|
|
47
|
-
"@
|
|
48
|
-
"@powerhousedao/
|
|
49
|
-
"
|
|
41
|
+
"@powerhousedao/codegen": "6.0.0-dev.192",
|
|
42
|
+
"@powerhousedao/builder-tools": "6.0.0-dev.192",
|
|
43
|
+
"@powerhousedao/common": "6.0.0-dev.192",
|
|
44
|
+
"@powerhousedao/config": "6.0.0-dev.192",
|
|
45
|
+
"@powerhousedao/reactor": "6.0.0-dev.192",
|
|
46
|
+
"@powerhousedao/shared": "6.0.0-dev.192",
|
|
47
|
+
"@renown/sdk": "6.0.0-dev.192",
|
|
48
|
+
"@powerhousedao/switchboard": "6.0.0-dev.192",
|
|
49
|
+
"document-model": "6.0.0-dev.192"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@types/node": "25.2.3",
|
|
53
|
+
"@types/npm-registry-fetch": "^8.0.9",
|
|
53
54
|
"@types/pg": "8.16.0",
|
|
54
55
|
"copyfiles": "2.4.1"
|
|
55
56
|
},
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generate-DXDBhwoJ.mjs","names":["generateCode"],"sources":["../src/services/generate.ts"],"sourcesContent":["import {\n generateApp,\n generate as generateCode,\n generateDBSchema,\n generateEditor,\n generateFromFile,\n generateImportScript,\n generateProcessor,\n generateSubgraph,\n} from \"@powerhousedao/codegen\";\nimport { getConfig } from \"@powerhousedao/config/node\";\nimport path from \"path\";\nimport type { GenerateArgs } from \"../types.js\";\n\nexport async function startGenerate(options: GenerateArgs) {\n const config = getConfig();\n const { skipFormat } = config;\n const {\n documentModelFilePositional,\n documentModelFileOption,\n editorName,\n editorId,\n documentType,\n // [DEPRECATED] - should be removed asap\n documentTypes,\n editorDirName,\n appName,\n appId,\n appDirName,\n allowedDocumentTypes,\n disableDragAndDrop,\n processorName,\n processorType,\n processorApps,\n importScriptName,\n migrationFile,\n schemaFile,\n verbose,\n force,\n useVersioning: useVersioningFlag,\n subgraphName,\n migrateLegacy,\n } = options;\n\n const documentModelFile =\n documentModelFilePositional ?? documentModelFileOption;\n\n const useVersioning = useVersioningFlag || migrateLegacy;\n const isDragAndDropEnabled = disableDragAndDrop !== true;\n const filePath = Array.isArray(documentModelFile)\n ? documentModelFile.join(\" \")\n : documentModelFile;\n\n const documentTypeFromDocumentTypes = documentTypes?.split(\",\")[0];\n if (documentTypes) {\n console.warn(\n `[WARNING] --document-types is deprecated. Generated editor code is not set up to use multiple document types. Using the first document type in the list you specified (${documentTypeFromDocumentTypes})`,\n );\n }\n const documentTypeToUse = documentType ?? documentTypeFromDocumentTypes;\n\n if (editorName !== undefined) {\n if (!documentTypeToUse) {\n throw new Error(\n \"Please specify a document type for the generated editor.\",\n );\n }\n await generateEditor({\n editorName,\n editorId,\n editorDirName,\n documentTypes: [documentTypeToUse],\n skipFormat,\n });\n } else if (appName !== undefined) {\n await generateApp({\n appName,\n appId,\n appDirName,\n allowedDocumentTypes,\n isDragAndDropEnabled,\n skipFormat,\n });\n } else if (processorName !== undefined) {\n await generateProcessor({\n processorName,\n processorType,\n skipFormat,\n processorApps,\n documentTypes: [documentTypeToUse].filter((t) => t !== undefined),\n });\n } else if (subgraphName !== undefined) {\n await generateSubgraph(subgraphName, filePath || null, config);\n } else if (importScriptName !== undefined) {\n await generateImportScript(importScriptName, config);\n } else if (migrationFile !== undefined) {\n await generateDBSchema({\n migrationFile: path.join(process.cwd(), migrationFile),\n schemaFile: schemaFile ? path.join(process.cwd(), schemaFile) : undefined,\n });\n } else if (filePath !== undefined) {\n await generateFromFile({\n path: filePath,\n config,\n options,\n useVersioning,\n migrateLegacy,\n });\n } else {\n await generateCode(config, useVersioning, migrateLegacy);\n }\n}\n"],"mappings":";;;;AAcA,eAAsB,cAAc,SAAuB;CACzD,MAAM,SAAS,WAAW;CAC1B,MAAM,EAAE,eAAe;CACvB,MAAM,EACJ,6BACA,yBACA,YACA,UACA,cAEA,eACA,eACA,SACA,OACA,YACA,sBACA,oBACA,eACA,eACA,eACA,kBACA,eACA,YACA,SACA,OACA,eAAe,mBACf,cACA,kBACE;CAEJ,MAAM,oBACJ,+BAA+B;CAEjC,MAAM,gBAAgB,qBAAqB;CAC3C,MAAM,uBAAuB,uBAAuB;CACpD,MAAM,WAAW,MAAM,QAAQ,kBAAkB,GAC7C,kBAAkB,KAAK,IAAI,GAC3B;CAEJ,MAAM,gCAAgC,eAAe,MAAM,IAAI,CAAC;AAChE,KAAI,cACF,SAAQ,KACN,0KAA0K,8BAA8B,GACzM;CAEH,MAAM,oBAAoB,gBAAgB;AAE1C,KAAI,eAAe,KAAA,GAAW;AAC5B,MAAI,CAAC,kBACH,OAAM,IAAI,MACR,2DACD;AAEH,QAAM,eAAe;GACnB;GACA;GACA;GACA,eAAe,CAAC,kBAAkB;GAClC;GACD,CAAC;YACO,YAAY,KAAA,EACrB,OAAM,YAAY;EAChB;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;UACO,kBAAkB,KAAA,EAC3B,OAAM,kBAAkB;EACtB;EACA;EACA;EACA;EACA,eAAe,CAAC,kBAAkB,CAAC,QAAQ,MAAM,MAAM,KAAA,EAAU;EAClE,CAAC;UACO,iBAAiB,KAAA,EAC1B,OAAM,iBAAiB,cAAc,YAAY,MAAM,OAAO;UACrD,qBAAqB,KAAA,EAC9B,OAAM,qBAAqB,kBAAkB,OAAO;UAC3C,kBAAkB,KAAA,EAC3B,OAAM,iBAAiB;EACrB,eAAe,KAAK,KAAK,QAAQ,KAAK,EAAE,cAAc;EACtD,YAAY,aAAa,KAAK,KAAK,QAAQ,KAAK,EAAE,WAAW,GAAG,KAAA;EACjE,CAAC;UACO,aAAa,KAAA,EACtB,OAAM,iBAAiB;EACrB,MAAM;EACN;EACA;EACA;EACA;EACD,CAAC;KAEF,OAAMA,SAAa,QAAQ,eAAe,cAAc"}
|
|
@@ -1,245 +0,0 @@
|
|
|
1
|
-
import { t as startGenerate } from "./generate-DXDBhwoJ.mjs";
|
|
2
|
-
import { existsSync, readdirSync } from "node:fs";
|
|
3
|
-
import path from "path";
|
|
4
|
-
import { connectEntrypointTemplate, dockerfileTemplate, indexHtmlTemplate, indexTsTemplate, nginxConfTemplate, packageJsonExportsTemplate, packageJsonScriptsTemplate, switchboardEntrypointTemplate, syncAndPublishWorkflowTemplate, tsConfigTemplate } from "@powerhousedao/codegen/templates";
|
|
5
|
-
import { mkdir, readdir, stat, writeFile } from "node:fs/promises";
|
|
6
|
-
import { readPackage } from "read-pkg";
|
|
7
|
-
import { Project, SyntaxKind } from "ts-morph";
|
|
8
|
-
import { writePackage } from "write-package";
|
|
9
|
-
//#region src/services/migrate.ts
|
|
10
|
-
async function startMigrate(_args) {
|
|
11
|
-
await migratePackageJson();
|
|
12
|
-
await migrateTsConfig();
|
|
13
|
-
await migrateIndexHtml();
|
|
14
|
-
await migrateCIFiles();
|
|
15
|
-
await runGenerateOnAllDocumentModels();
|
|
16
|
-
await runGenerateOnAllEditors();
|
|
17
|
-
const project = new Project({
|
|
18
|
-
tsConfigFilePath: path.resolve("tsconfig.json"),
|
|
19
|
-
compilerOptions: { verbatimModuleSyntax: false }
|
|
20
|
-
});
|
|
21
|
-
deleteLegacyEditorDirIndexFiles(project);
|
|
22
|
-
migrateEditorFiles(project);
|
|
23
|
-
migrateRootIndex(project);
|
|
24
|
-
removeZDotSchemaUsage(project);
|
|
25
|
-
removeCreatorsUsage(project);
|
|
26
|
-
removeUtilsDefaultExportUsage(project);
|
|
27
|
-
fixImports(project);
|
|
28
|
-
}
|
|
29
|
-
/** Ensure that the project package.json has the correct scripts and exports. */
|
|
30
|
-
async function migratePackageJson() {
|
|
31
|
-
const packageJson = await readPackage();
|
|
32
|
-
const existingScripts = packageJson.scripts;
|
|
33
|
-
const existingExports = !!packageJson.exports && !Array.isArray(packageJson.exports) && typeof packageJson.exports !== "string" ? packageJson.exports : {};
|
|
34
|
-
const newScripts = {
|
|
35
|
-
...existingScripts,
|
|
36
|
-
...packageJsonScriptsTemplate
|
|
37
|
-
};
|
|
38
|
-
const newExports = {
|
|
39
|
-
...existingExports,
|
|
40
|
-
...packageJsonExportsTemplate
|
|
41
|
-
};
|
|
42
|
-
packageJson.scripts = newScripts;
|
|
43
|
-
packageJson.exports = newExports;
|
|
44
|
-
await writePackage(packageJson);
|
|
45
|
-
}
|
|
46
|
-
/** Ensure that the project index.html matches the boilerplate index.html. */
|
|
47
|
-
async function migrateIndexHtml() {
|
|
48
|
-
await writeFile(path.join(process.cwd(), "index.html"), indexHtmlTemplate);
|
|
49
|
-
}
|
|
50
|
-
/** Ensure that the project tsconfig.json matches the boilerplate tsconfig.json. */
|
|
51
|
-
async function migrateTsConfig() {
|
|
52
|
-
await writeFile(path.join(process.cwd(), "tsconfig.json"), tsConfigTemplate);
|
|
53
|
-
}
|
|
54
|
-
/** Check if a file exists */
|
|
55
|
-
async function fileExists(filePath) {
|
|
56
|
-
try {
|
|
57
|
-
await stat(filePath);
|
|
58
|
-
return true;
|
|
59
|
-
} catch {
|
|
60
|
-
return false;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
/** Write a file with optional warning if it already exists */
|
|
64
|
-
async function writeFileWithWarning(filePath, content) {
|
|
65
|
-
if (await fileExists(filePath)) console.warn(`Warning: Overwriting existing file: ${filePath}`);
|
|
66
|
-
await writeFile(filePath, content);
|
|
67
|
-
}
|
|
68
|
-
/** Add CI/CD workflow and Docker files to the project. */
|
|
69
|
-
async function migrateCIFiles() {
|
|
70
|
-
const cwd = process.cwd();
|
|
71
|
-
try {
|
|
72
|
-
await mkdir(path.join(cwd, ".github/workflows"), { recursive: true });
|
|
73
|
-
await mkdir(path.join(cwd, "docker"), { recursive: true });
|
|
74
|
-
await writeFileWithWarning(path.join(cwd, ".github/workflows/sync-and-publish.yml"), syncAndPublishWorkflowTemplate);
|
|
75
|
-
await writeFileWithWarning(path.join(cwd, "Dockerfile"), dockerfileTemplate);
|
|
76
|
-
await writeFileWithWarning(path.join(cwd, "docker/nginx.conf"), nginxConfTemplate);
|
|
77
|
-
await writeFileWithWarning(path.join(cwd, "docker/connect-entrypoint.sh"), connectEntrypointTemplate);
|
|
78
|
-
await writeFileWithWarning(path.join(cwd, "docker/switchboard-entrypoint.sh"), switchboardEntrypointTemplate);
|
|
79
|
-
} catch (error) {
|
|
80
|
-
console.error("Error migrating CI files:", error);
|
|
81
|
-
throw error;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
/** Ensure that the project index.ts file uses the new exports for editors and document models */
|
|
85
|
-
function migrateRootIndex(project) {
|
|
86
|
-
const indexPath = path.join(process.cwd(), "index.ts");
|
|
87
|
-
let source = project.getSourceFile(indexPath);
|
|
88
|
-
if (!source) source = project.createSourceFile(indexPath);
|
|
89
|
-
source.replaceWithText(indexTsTemplate);
|
|
90
|
-
project.saveSync();
|
|
91
|
-
}
|
|
92
|
-
/** Ensure that the project's editor.tsx files use default exports for lazy loading */
|
|
93
|
-
function migrateEditorFiles(project) {
|
|
94
|
-
const editorsPath = path.join(process.cwd(), "editors");
|
|
95
|
-
const dirs = readdirSync(editorsPath, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
|
|
96
|
-
for (const dir of dirs) {
|
|
97
|
-
const editorFilePath = path.join(editorsPath, dir, "editor.tsx");
|
|
98
|
-
const source = project.getSourceFile(editorFilePath);
|
|
99
|
-
if (!source) continue;
|
|
100
|
-
const replaceNamedExportWithDefaultExport = source.getFullText().replace("export function Editor", "export default function Editor");
|
|
101
|
-
source.replaceWithText(replaceNamedExportWithDefaultExport);
|
|
102
|
-
project.saveSync();
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
/** Delete the legacy index files in editor directories which are now replaced by module.ts files */
|
|
106
|
-
function deleteLegacyEditorDirIndexFiles(project) {
|
|
107
|
-
const editorsPath = path.join(process.cwd(), "editors");
|
|
108
|
-
const dirs = readdirSync(editorsPath, { withFileTypes: true }).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
|
|
109
|
-
for (const dir of dirs) {
|
|
110
|
-
const indexFilePath = path.join(editorsPath, dir, "index.ts");
|
|
111
|
-
const source = project.getSourceFile(indexFilePath);
|
|
112
|
-
if (!source) continue;
|
|
113
|
-
source.delete();
|
|
114
|
-
project.saveSync();
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
/** Remove usage of the `z` re-export of document model schemas which caused naming conflicts */
|
|
118
|
-
function removeZDotSchemaUsage(project) {
|
|
119
|
-
const sourceFiles = project.getSourceFiles();
|
|
120
|
-
for (const sourceFile of sourceFiles) {
|
|
121
|
-
const path = sourceFile.getFilePath();
|
|
122
|
-
if (!path.includes(process.cwd())) continue;
|
|
123
|
-
if (path.includes("zod.ts")) continue;
|
|
124
|
-
const text = sourceFile.getFullText();
|
|
125
|
-
if (/import\s+(?:\{\s*z\s*\}|z)\s+from\s+['"]zod['"]/.test(text)) continue;
|
|
126
|
-
const withoutZDot = text.replace(/z\./g, "");
|
|
127
|
-
sourceFile.replaceWithText(withoutZDot);
|
|
128
|
-
project.saveSync();
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
/** Remove usage of the `creators` as an aliased full module export which is no longer needed */
|
|
132
|
-
function removeCreatorsUsage(project) {
|
|
133
|
-
const sourceFiles = project.getSourceFiles();
|
|
134
|
-
for (const sourceFile of sourceFiles) {
|
|
135
|
-
if (!sourceFile.getFilePath().includes(process.cwd())) continue;
|
|
136
|
-
const creatorsInvocations = sourceFile.getStatements().filter((statement) => statement.getKind() === SyntaxKind.PropertyAccessExpression).filter((statement) => statement.getText().includes("creators."));
|
|
137
|
-
for (const creatorInvocation of creatorsInvocations) {
|
|
138
|
-
const withoutCreators = creatorInvocation.getText().replace(/creators\./g, "");
|
|
139
|
-
creatorInvocation.replaceWithText(withoutCreators);
|
|
140
|
-
project.saveSync();
|
|
141
|
-
}
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
/** Remove usage of the `utils` import which is no longer exported as a default import */
|
|
145
|
-
function removeUtilsDefaultExportUsage(project) {
|
|
146
|
-
const sourceFiles = project.getSourceFiles();
|
|
147
|
-
for (const sourceFile of sourceFiles) {
|
|
148
|
-
if (!sourceFile.getFilePath().includes(process.cwd())) continue;
|
|
149
|
-
const statement = sourceFile.getImportDeclarations().find((importDeclaration) => importDeclaration.getText().includes("import utils"));
|
|
150
|
-
if (statement) {
|
|
151
|
-
statement.remove();
|
|
152
|
-
project.saveSync();
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
/** Fix missing imports in the project */
|
|
157
|
-
function fixImports(project) {
|
|
158
|
-
const sourceFiles = project.getSourceFiles();
|
|
159
|
-
for (const sourceFile of sourceFiles) {
|
|
160
|
-
if (!sourceFile.getFilePath().includes(process.cwd())) continue;
|
|
161
|
-
sourceFile.fixMissingImports(void 0, {
|
|
162
|
-
importModuleSpecifierPreference: "project-relative",
|
|
163
|
-
autoImportSpecifierExcludeRegexes: ["document-model", "document-drive"],
|
|
164
|
-
importModuleSpecifierEnding: "js",
|
|
165
|
-
preferTypeOnlyAutoImports: false
|
|
166
|
-
});
|
|
167
|
-
sourceFile.fixUnusedIdentifiers();
|
|
168
|
-
project.saveSync();
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
/** Run the generate command on all document models */
|
|
172
|
-
async function runGenerateOnAllDocumentModels() {
|
|
173
|
-
await startGenerate({});
|
|
174
|
-
}
|
|
175
|
-
/** Run the generate command on all editors */
|
|
176
|
-
async function runGenerateOnAllEditors() {
|
|
177
|
-
const editorsPath = path.join(process.cwd(), "editors");
|
|
178
|
-
const dirs = (await readdir(editorsPath, { withFileTypes: true })).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
|
|
179
|
-
for (const dir of dirs) {
|
|
180
|
-
const moduleFilePath = path.join(editorsPath, dir, "module.ts");
|
|
181
|
-
const indexFilePath = path.join(editorsPath, dir, "index.ts");
|
|
182
|
-
const hasModuleFile = existsSync(moduleFilePath);
|
|
183
|
-
const hasIndexFile = existsSync(indexFilePath);
|
|
184
|
-
if (!hasModuleFile && !hasIndexFile) continue;
|
|
185
|
-
const { id, name, documentTypes, isApp } = extractEditorModuleInfo(hasModuleFile ? moduleFilePath : indexFilePath);
|
|
186
|
-
if (!name) throw new Error(`Editor ${dir} is missing name`);
|
|
187
|
-
if (!id) throw new Error(`Editor ${dir} is missing id`);
|
|
188
|
-
if (isApp) {
|
|
189
|
-
const configFilePath = path.join(editorsPath, dir, "config.ts");
|
|
190
|
-
await startGenerate({
|
|
191
|
-
appName: name,
|
|
192
|
-
appId: id,
|
|
193
|
-
appDirName: dir,
|
|
194
|
-
allowedDocumentTypes: existsSync(configFilePath) ? extractAllowedDocumentTypes(configFilePath) : void 0
|
|
195
|
-
});
|
|
196
|
-
} else await startGenerate({
|
|
197
|
-
editorName: name,
|
|
198
|
-
editorId: id,
|
|
199
|
-
editorDirName: dir,
|
|
200
|
-
documentType: documentTypes?.[0]
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
|
-
}
|
|
204
|
-
/** Extract the name, id, document types, and whether the editor is a app from the editor module */
|
|
205
|
-
function extractEditorModuleInfo(filePath) {
|
|
206
|
-
const variable = getVariableDeclarationByTypeName(new Project({
|
|
207
|
-
tsConfigFilePath: path.resolve("tsconfig.json"),
|
|
208
|
-
compilerOptions: { verbatimModuleSyntax: false }
|
|
209
|
-
}).getSourceFileOrThrow(filePath), "EditorModule")?.getInitializerIfKind(SyntaxKind.ObjectLiteralExpression);
|
|
210
|
-
const documentTypes = getObjectProperty(variable, "documentTypes", SyntaxKind.ArrayLiteralExpression)?.getElements().map((element) => element.getText()).map((text) => text.replace(/["']/g, ""));
|
|
211
|
-
const configProperty = getObjectProperty(variable, "config", SyntaxKind.ObjectLiteralExpression);
|
|
212
|
-
return {
|
|
213
|
-
id: getStringLiteralValue(getObjectProperty(configProperty, "id", SyntaxKind.StringLiteral)),
|
|
214
|
-
name: getStringLiteralValue(getObjectProperty(configProperty, "name", SyntaxKind.StringLiteral)),
|
|
215
|
-
documentTypes,
|
|
216
|
-
isApp: documentTypes?.includes("powerhouse/document-drive")
|
|
217
|
-
};
|
|
218
|
-
}
|
|
219
|
-
/** Extract the allowed document types from the app config */
|
|
220
|
-
function extractAllowedDocumentTypes(filePath) {
|
|
221
|
-
const sourceFile = new Project({
|
|
222
|
-
tsConfigFilePath: path.resolve("tsconfig.json"),
|
|
223
|
-
compilerOptions: { verbatimModuleSyntax: false }
|
|
224
|
-
}).getSourceFile(filePath);
|
|
225
|
-
if (!sourceFile) return;
|
|
226
|
-
const configVariable = getVariableDeclarationByTypeName(sourceFile, "PHAppConfig")?.getInitializerIfKind(SyntaxKind.ObjectLiteralExpression);
|
|
227
|
-
if (!configVariable) return;
|
|
228
|
-
return getArrayLiteralExpressionElementsText(getObjectProperty(configVariable, "allowedDocumentTypes", SyntaxKind.ArrayLiteralExpression));
|
|
229
|
-
}
|
|
230
|
-
function getVariableDeclarationByTypeName(sourceFile, typeName) {
|
|
231
|
-
return sourceFile.getVariableDeclarations().find((declaration) => declaration.getType().getText().includes(typeName));
|
|
232
|
-
}
|
|
233
|
-
function getStringLiteralValue(stringLiteral) {
|
|
234
|
-
return stringLiteral?.getText().replace(/["']/g, "");
|
|
235
|
-
}
|
|
236
|
-
function getObjectProperty(object, propertyName, propertyType) {
|
|
237
|
-
return object?.getProperty(propertyName)?.asKind(SyntaxKind.PropertyAssignment)?.getChildren().find((child) => child.getKind() === propertyType)?.asKind(propertyType);
|
|
238
|
-
}
|
|
239
|
-
function getArrayLiteralExpressionElementsText(arrayLiteralExpression) {
|
|
240
|
-
return arrayLiteralExpression?.getElements().map((element) => element.getText()).map((text) => text.replace(/["']/g, ""));
|
|
241
|
-
}
|
|
242
|
-
//#endregion
|
|
243
|
-
export { startMigrate };
|
|
244
|
-
|
|
245
|
-
//# sourceMappingURL=migrate-N4b2DpVP.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"migrate-N4b2DpVP.mjs","names":[],"sources":["../src/services/migrate.ts"],"sourcesContent":["import {\n connectEntrypointTemplate,\n dockerfileTemplate,\n indexHtmlTemplate,\n indexTsTemplate,\n nginxConfTemplate,\n packageJsonExportsTemplate,\n packageJsonScriptsTemplate,\n switchboardEntrypointTemplate,\n syncAndPublishWorkflowTemplate,\n tsConfigTemplate,\n} from \"@powerhousedao/codegen/templates\";\nimport { existsSync, readdirSync } from \"node:fs\";\nimport { mkdir, readdir, stat, writeFile } from \"node:fs/promises\";\nimport path from \"path\";\nimport { readPackage } from \"read-pkg\";\nimport type {\n ArrayLiteralExpression,\n ObjectLiteralExpression,\n SourceFile,\n StringLiteral,\n} from \"ts-morph\";\nimport { Project, SyntaxKind } from \"ts-morph\";\nimport { writePackage } from \"write-package\";\nimport type { GenerateArgs, MigrateArgs } from \"../types.js\";\nimport { startGenerate } from \"./generate.js\";\n\nexport async function startMigrate(_args: MigrateArgs) {\n await migratePackageJson();\n await migrateTsConfig();\n await migrateIndexHtml();\n await migrateCIFiles();\n await runGenerateOnAllDocumentModels();\n await runGenerateOnAllEditors();\n const project = new Project({\n tsConfigFilePath: path.resolve(\"tsconfig.json\"),\n compilerOptions: {\n verbatimModuleSyntax: false,\n },\n });\n deleteLegacyEditorDirIndexFiles(project);\n migrateEditorFiles(project);\n migrateRootIndex(project);\n removeZDotSchemaUsage(project);\n removeCreatorsUsage(project);\n removeUtilsDefaultExportUsage(project);\n fixImports(project);\n}\n\n/** Ensure that the project package.json has the correct scripts and exports. */\nasync function migratePackageJson() {\n const packageJson = await readPackage();\n const existingScripts = packageJson.scripts;\n const existingExports =\n !!packageJson.exports &&\n !Array.isArray(packageJson.exports) &&\n typeof packageJson.exports !== \"string\"\n ? packageJson.exports\n : {};\n const newScripts = {\n ...existingScripts,\n ...packageJsonScriptsTemplate,\n };\n const newExports = {\n ...existingExports,\n ...packageJsonExportsTemplate,\n };\n packageJson.scripts = newScripts;\n packageJson.exports = newExports;\n await writePackage(packageJson);\n}\n\n/** Ensure that the project index.html matches the boilerplate index.html. */\nasync function migrateIndexHtml() {\n const indexHtmlPath = path.join(process.cwd(), \"index.html\");\n await writeFile(indexHtmlPath, indexHtmlTemplate);\n}\n\n/** Ensure that the project tsconfig.json matches the boilerplate tsconfig.json. */\nasync function migrateTsConfig() {\n const tsConfigPath = path.join(process.cwd(), \"tsconfig.json\");\n await writeFile(tsConfigPath, tsConfigTemplate);\n}\n\n/** Check if a file exists */\nasync function fileExists(filePath: string): Promise<boolean> {\n try {\n await stat(filePath);\n return true;\n } catch {\n return false;\n }\n}\n\n/** Write a file with optional warning if it already exists */\nasync function writeFileWithWarning(\n filePath: string,\n content: string,\n): Promise<void> {\n const exists = await fileExists(filePath);\n if (exists) {\n console.warn(`Warning: Overwriting existing file: ${filePath}`);\n }\n await writeFile(filePath, content);\n}\n\n/** Add CI/CD workflow and Docker files to the project. */\nasync function migrateCIFiles() {\n const cwd = process.cwd();\n\n try {\n // Create directories if they don't exist\n await mkdir(path.join(cwd, \".github/workflows\"), { recursive: true });\n await mkdir(path.join(cwd, \"docker\"), { recursive: true });\n\n // Write CI/CD workflow\n await writeFileWithWarning(\n path.join(cwd, \".github/workflows/sync-and-publish.yml\"),\n syncAndPublishWorkflowTemplate,\n );\n\n // Write Docker files\n await writeFileWithWarning(\n path.join(cwd, \"Dockerfile\"),\n dockerfileTemplate,\n );\n await writeFileWithWarning(\n path.join(cwd, \"docker/nginx.conf\"),\n nginxConfTemplate,\n );\n await writeFileWithWarning(\n path.join(cwd, \"docker/connect-entrypoint.sh\"),\n connectEntrypointTemplate,\n );\n await writeFileWithWarning(\n path.join(cwd, \"docker/switchboard-entrypoint.sh\"),\n switchboardEntrypointTemplate,\n );\n } catch (error) {\n console.error(\"Error migrating CI files:\", error);\n throw error;\n }\n}\n\n/** Ensure that the project index.ts file uses the new exports for editors and document models */\nfunction migrateRootIndex(project: Project) {\n const indexPath = path.join(process.cwd(), \"index.ts\");\n let source = project.getSourceFile(indexPath);\n if (!source) {\n source = project.createSourceFile(indexPath);\n }\n source.replaceWithText(indexTsTemplate);\n project.saveSync();\n}\n\n/** Ensure that the project's editor.tsx files use default exports for lazy loading */\nfunction migrateEditorFiles(project: Project) {\n const editorsPath = path.join(process.cwd(), \"editors\");\n const dirs = readdirSync(editorsPath, { withFileTypes: true })\n .filter((entry) => entry.isDirectory())\n .map((entry) => entry.name);\n for (const dir of dirs) {\n const editorFilePath = path.join(editorsPath, dir, \"editor.tsx\");\n const source = project.getSourceFile(editorFilePath);\n if (!source) continue;\n const text = source.getFullText();\n const replaceNamedExportWithDefaultExport = text.replace(\n \"export function Editor\",\n \"export default function Editor\",\n );\n source.replaceWithText(replaceNamedExportWithDefaultExport);\n project.saveSync();\n }\n}\n\n/** Delete the legacy index files in editor directories which are now replaced by module.ts files */\nfunction deleteLegacyEditorDirIndexFiles(project: Project) {\n const editorsPath = path.join(process.cwd(), \"editors\");\n const dirs = readdirSync(editorsPath, { withFileTypes: true })\n .filter((entry) => entry.isDirectory())\n .map((entry) => entry.name);\n for (const dir of dirs) {\n const indexFilePath = path.join(editorsPath, dir, \"index.ts\");\n const source = project.getSourceFile(indexFilePath);\n if (!source) continue;\n source.delete();\n project.saveSync();\n }\n}\n\n/** Remove usage of the `z` re-export of document model schemas which caused naming conflicts */\nfunction removeZDotSchemaUsage(project: Project) {\n const sourceFiles = project.getSourceFiles();\n for (const sourceFile of sourceFiles) {\n const path = sourceFile.getFilePath();\n if (!path.includes(process.cwd())) continue;\n if (path.includes(\"zod.ts\")) continue;\n const text = sourceFile.getFullText();\n if (/import\\s+(?:\\{\\s*z\\s*\\}|z)\\s+from\\s+['\"]zod['\"]/.test(text)) continue;\n const withoutZDot = text.replace(/z\\./g, \"\");\n sourceFile.replaceWithText(withoutZDot);\n project.saveSync();\n }\n}\n\n/** Remove usage of the `creators` as an aliased full module export which is no longer needed */\nfunction removeCreatorsUsage(project: Project) {\n const sourceFiles = project.getSourceFiles();\n for (const sourceFile of sourceFiles) {\n const path = sourceFile.getFilePath();\n if (!path.includes(process.cwd())) continue;\n const creatorsInvocations = sourceFile\n .getStatements()\n .filter(\n (statement) =>\n statement.getKind() === SyntaxKind.PropertyAccessExpression,\n )\n .filter((statement) => statement.getText().includes(\"creators.\"));\n for (const creatorInvocation of creatorsInvocations) {\n const withoutCreators = creatorInvocation\n .getText()\n .replace(/creators\\./g, \"\");\n creatorInvocation.replaceWithText(withoutCreators);\n project.saveSync();\n }\n }\n}\n\n/** Remove usage of the `utils` import which is no longer exported as a default import */\nfunction removeUtilsDefaultExportUsage(project: Project) {\n const sourceFiles = project.getSourceFiles();\n for (const sourceFile of sourceFiles) {\n const path = sourceFile.getFilePath();\n if (!path.includes(process.cwd())) continue;\n const statement = sourceFile\n .getImportDeclarations()\n .find((importDeclaration) =>\n importDeclaration.getText().includes(\"import utils\"),\n );\n if (statement) {\n statement.remove();\n project.saveSync();\n }\n }\n}\n\n/** Fix missing imports in the project */\nfunction fixImports(project: Project) {\n const sourceFiles = project.getSourceFiles();\n for (const sourceFile of sourceFiles) {\n const path = sourceFile.getFilePath();\n if (!path.includes(process.cwd())) continue;\n sourceFile.fixMissingImports(undefined, {\n importModuleSpecifierPreference: \"project-relative\",\n autoImportSpecifierExcludeRegexes: [\"document-model\", \"document-drive\"],\n importModuleSpecifierEnding: \"js\",\n preferTypeOnlyAutoImports: false,\n });\n sourceFile.fixUnusedIdentifiers();\n\n project.saveSync();\n }\n}\n\n/** Run the generate command on all document models */\nasync function runGenerateOnAllDocumentModels() {\n await startGenerate({} as GenerateArgs);\n}\n\n/** Run the generate command on all editors */\nasync function runGenerateOnAllEditors() {\n const editorsPath = path.join(process.cwd(), \"editors\");\n const dirs = (await readdir(editorsPath, { withFileTypes: true }))\n .filter((entry) => entry.isDirectory())\n .map((entry) => entry.name);\n for (const dir of dirs) {\n const moduleFilePath = path.join(editorsPath, dir, \"module.ts\");\n const indexFilePath = path.join(editorsPath, dir, \"index.ts\");\n const hasModuleFile = existsSync(moduleFilePath);\n const hasIndexFile = existsSync(indexFilePath);\n if (!hasModuleFile && !hasIndexFile) {\n continue;\n }\n const filePathToUse = hasModuleFile ? moduleFilePath : indexFilePath;\n const { id, name, documentTypes, isApp } =\n extractEditorModuleInfo(filePathToUse);\n\n if (!name) {\n throw new Error(`Editor ${dir} is missing name`);\n }\n if (!id) {\n throw new Error(`Editor ${dir} is missing id`);\n }\n if (isApp) {\n const configFilePath = path.join(editorsPath, dir, \"config.ts\");\n const hasConfigFile = existsSync(configFilePath);\n const allowedDocumentTypes = hasConfigFile\n ? extractAllowedDocumentTypes(configFilePath)\n : undefined;\n const args = {\n appName: name,\n appId: id,\n appDirName: dir,\n allowedDocumentTypes,\n } as GenerateArgs;\n await startGenerate(args);\n } else {\n const args = {\n editorName: name,\n editorId: id,\n editorDirName: dir,\n documentType: documentTypes?.[0],\n } as GenerateArgs;\n await startGenerate(args);\n }\n }\n}\n\n/** Extract the name, id, document types, and whether the editor is a app from the editor module */\nfunction extractEditorModuleInfo(filePath: string) {\n const project = new Project({\n tsConfigFilePath: path.resolve(\"tsconfig.json\"),\n compilerOptions: {\n verbatimModuleSyntax: false,\n },\n });\n const sourceFile = project.getSourceFileOrThrow(filePath);\n const moduleDeclaration = getVariableDeclarationByTypeName(\n sourceFile,\n \"EditorModule\",\n );\n\n const variable = moduleDeclaration?.getInitializerIfKind(\n SyntaxKind.ObjectLiteralExpression,\n );\n const documentTypes = getObjectProperty(\n variable,\n \"documentTypes\",\n SyntaxKind.ArrayLiteralExpression,\n )\n ?.getElements()\n .map((element) => element.getText())\n .map((text) => text.replace(/[\"']/g, \"\"));\n\n const configProperty = getObjectProperty(\n variable,\n \"config\",\n SyntaxKind.ObjectLiteralExpression,\n );\n\n const id = getStringLiteralValue(\n getObjectProperty(configProperty, \"id\", SyntaxKind.StringLiteral),\n );\n\n const name = getStringLiteralValue(\n getObjectProperty(configProperty, \"name\", SyntaxKind.StringLiteral),\n );\n const isApp = documentTypes?.includes(\"powerhouse/document-drive\");\n return { id, name, documentTypes, isApp };\n}\n\n/** Extract the allowed document types from the app config */\nfunction extractAllowedDocumentTypes(filePath: string) {\n const project = new Project({\n tsConfigFilePath: path.resolve(\"tsconfig.json\"),\n compilerOptions: {\n verbatimModuleSyntax: false,\n },\n });\n const sourceFile = project.getSourceFile(filePath);\n if (!sourceFile) return;\n const configVariableDeclaration = getVariableDeclarationByTypeName(\n sourceFile,\n \"PHAppConfig\",\n );\n const configVariable = configVariableDeclaration?.getInitializerIfKind(\n SyntaxKind.ObjectLiteralExpression,\n );\n if (!configVariable) return;\n const allowedDocumentTypes = getArrayLiteralExpressionElementsText(\n getObjectProperty(\n configVariable,\n \"allowedDocumentTypes\",\n SyntaxKind.ArrayLiteralExpression,\n ),\n );\n return allowedDocumentTypes;\n}\n\nfunction getVariableDeclarationByTypeName(\n sourceFile: SourceFile,\n typeName: string,\n) {\n const variableDeclarations = sourceFile.getVariableDeclarations();\n return variableDeclarations.find((declaration) =>\n declaration.getType().getText().includes(typeName),\n );\n}\n\nfunction getStringLiteralValue(stringLiteral: StringLiteral | undefined) {\n return stringLiteral?.getText().replace(/[\"']/g, \"\");\n}\n\nfunction getObjectProperty<T extends SyntaxKind>(\n object: ObjectLiteralExpression | undefined,\n propertyName: string,\n propertyType: T,\n) {\n return object\n ?.getProperty(propertyName)\n ?.asKind(SyntaxKind.PropertyAssignment)\n ?.getChildren()\n .find((child) => child.getKind() === propertyType)\n ?.asKind(propertyType);\n}\n\nfunction getArrayLiteralExpressionElementsText(\n arrayLiteralExpression: ArrayLiteralExpression | undefined,\n) {\n return arrayLiteralExpression\n ?.getElements()\n .map((element) => element.getText())\n .map((text) => text.replace(/[\"']/g, \"\"));\n}\n"],"mappings":";;;;;;;;;AA2BA,eAAsB,aAAa,OAAoB;AACrD,OAAM,oBAAoB;AAC1B,OAAM,iBAAiB;AACvB,OAAM,kBAAkB;AACxB,OAAM,gBAAgB;AACtB,OAAM,gCAAgC;AACtC,OAAM,yBAAyB;CAC/B,MAAM,UAAU,IAAI,QAAQ;EAC1B,kBAAkB,KAAK,QAAQ,gBAAgB;EAC/C,iBAAiB,EACf,sBAAsB,OACvB;EACF,CAAC;AACF,iCAAgC,QAAQ;AACxC,oBAAmB,QAAQ;AAC3B,kBAAiB,QAAQ;AACzB,uBAAsB,QAAQ;AAC9B,qBAAoB,QAAQ;AAC5B,+BAA8B,QAAQ;AACtC,YAAW,QAAQ;;;AAIrB,eAAe,qBAAqB;CAClC,MAAM,cAAc,MAAM,aAAa;CACvC,MAAM,kBAAkB,YAAY;CACpC,MAAM,kBACJ,CAAC,CAAC,YAAY,WACd,CAAC,MAAM,QAAQ,YAAY,QAAQ,IACnC,OAAO,YAAY,YAAY,WAC3B,YAAY,UACZ,EAAE;CACR,MAAM,aAAa;EACjB,GAAG;EACH,GAAG;EACJ;CACD,MAAM,aAAa;EACjB,GAAG;EACH,GAAG;EACJ;AACD,aAAY,UAAU;AACtB,aAAY,UAAU;AACtB,OAAM,aAAa,YAAY;;;AAIjC,eAAe,mBAAmB;AAEhC,OAAM,UADgB,KAAK,KAAK,QAAQ,KAAK,EAAE,aAAa,EAC7B,kBAA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