@powerhousedao/ph-cli 6.0.0-dev.109 → 6.0.0-dev.110
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 +2 -2
- package/dist/generate-CixMA2Ic.mjs +2 -0
- package/dist/{generate-howgVbAT.mjs → generate-_W54RXOa.mjs} +3 -8
- package/dist/generate-_W54RXOa.mjs.map +1 -0
- package/dist/{migrate-DErTQPCC.mjs → migrate-8KFwMxaP.mjs} +10 -12
- package/dist/migrate-8KFwMxaP.mjs.map +1 -0
- package/package.json +10 -10
- package/dist/generate-D7rJ2-Y6.mjs +0 -2
- package/dist/generate-howgVbAT.mjs.map +0 -1
- package/dist/migrate-DErTQPCC.mjs.map +0 -1
package/dist/cli.mjs
CHANGED
|
@@ -204,7 +204,7 @@ This command:
|
|
|
204
204
|
args: generateArgs,
|
|
205
205
|
handler: async (args) => {
|
|
206
206
|
if (args.debug) console.log(args);
|
|
207
|
-
const { startGenerate } = await import("./generate-
|
|
207
|
+
const { startGenerate } = await import("./generate-CixMA2Ic.mjs");
|
|
208
208
|
await startGenerate(args);
|
|
209
209
|
process.exit(0);
|
|
210
210
|
}
|
|
@@ -519,7 +519,7 @@ const migrate = command({
|
|
|
519
519
|
description: "Run migrations",
|
|
520
520
|
handler: async (args) => {
|
|
521
521
|
if (args.debug) console.log(args);
|
|
522
|
-
const { startMigrate } = await import("./migrate-
|
|
522
|
+
const { startMigrate } = await import("./migrate-8KFwMxaP.mjs");
|
|
523
523
|
await startMigrate(args);
|
|
524
524
|
process.exit(0);
|
|
525
525
|
}
|
|
@@ -5,10 +5,9 @@ import { generate, generateDBSchema, generateDriveEditor, generateEditor, genera
|
|
|
5
5
|
async function startGenerate(options) {
|
|
6
6
|
const config = getConfig();
|
|
7
7
|
const { skipFormat } = config;
|
|
8
|
-
const { documentModelFilePositional, documentModelFileOption, editorName, editorId, documentType, documentTypes, editorDirName, driveEditorName, driveEditorId, driveEditorDirName, allowedDocumentTypes, disableDragAndDrop, processorName, processorType, processorApps, importScriptName, migrationFile, schemaFile, verbose, force, useVersioning: useVersioningFlag,
|
|
8
|
+
const { documentModelFilePositional, documentModelFileOption, editorName, editorId, documentType, documentTypes, editorDirName, driveEditorName, driveEditorId, driveEditorDirName, allowedDocumentTypes, disableDragAndDrop, processorName, processorType, processorApps, importScriptName, migrationFile, schemaFile, verbose, force, useVersioning: useVersioningFlag, subgraphName, migrateLegacy } = options;
|
|
9
9
|
const documentModelFile = documentModelFilePositional ?? documentModelFileOption;
|
|
10
10
|
const useVersioning = useVersioningFlag || migrateLegacy;
|
|
11
|
-
const useTsMorph = useVersioning || !useHygen;
|
|
12
11
|
const isDragAndDropEnabled = disableDragAndDrop !== true;
|
|
13
12
|
const specifiedPackageName = void 0;
|
|
14
13
|
const filePath = Array.isArray(documentModelFile) ? documentModelFile.join(" ") : documentModelFile;
|
|
@@ -22,7 +21,6 @@ async function startGenerate(options) {
|
|
|
22
21
|
editorId,
|
|
23
22
|
editorDirName,
|
|
24
23
|
documentTypes: [documentTypeToUse],
|
|
25
|
-
useTsMorph,
|
|
26
24
|
skipFormat,
|
|
27
25
|
specifiedPackageName
|
|
28
26
|
});
|
|
@@ -32,7 +30,6 @@ async function startGenerate(options) {
|
|
|
32
30
|
driveEditorDirName,
|
|
33
31
|
allowedDocumentTypes,
|
|
34
32
|
isDragAndDropEnabled,
|
|
35
|
-
useTsMorph,
|
|
36
33
|
skipFormat,
|
|
37
34
|
specifiedPackageName
|
|
38
35
|
});
|
|
@@ -40,7 +37,6 @@ async function startGenerate(options) {
|
|
|
40
37
|
processorName,
|
|
41
38
|
processorType,
|
|
42
39
|
skipFormat,
|
|
43
|
-
useTsMorph,
|
|
44
40
|
processorApps,
|
|
45
41
|
documentTypes: [documentTypeToUse].filter((t) => t !== void 0)
|
|
46
42
|
});
|
|
@@ -56,14 +52,13 @@ async function startGenerate(options) {
|
|
|
56
52
|
else if (filePath !== void 0) await generateFromFile({
|
|
57
53
|
path: filePath,
|
|
58
54
|
config,
|
|
59
|
-
useTsMorph,
|
|
60
55
|
options,
|
|
61
56
|
useVersioning,
|
|
62
57
|
migrateLegacy
|
|
63
58
|
});
|
|
64
|
-
else await generate(config,
|
|
59
|
+
else await generate(config, useVersioning, migrateLegacy);
|
|
65
60
|
}
|
|
66
61
|
//#endregion
|
|
67
62
|
export { startGenerate as t };
|
|
68
63
|
|
|
69
|
-
//# sourceMappingURL=generate-
|
|
64
|
+
//# sourceMappingURL=generate-_W54RXOa.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-_W54RXOa.mjs","names":["generateCode"],"sources":["../src/services/generate.ts"],"sourcesContent":["import {\n generate as generateCode,\n generateDBSchema,\n generateDriveEditor,\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 driveEditorName,\n driveEditorId,\n driveEditorDirName,\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 specifiedPackageName = undefined;\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 specifiedPackageName,\n });\n } else if (driveEditorName !== undefined) {\n await generateDriveEditor({\n driveEditorName,\n driveEditorId,\n driveEditorDirName,\n allowedDocumentTypes,\n isDragAndDropEnabled,\n skipFormat,\n specifiedPackageName,\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 verbose,\n force,\n });\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,iBACA,eACA,oBACA,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,uBAAuB,KAAA;CAC7B,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;GACA;GACD,CAAC;YACO,oBAAoB,KAAA,EAC7B,OAAM,oBAAoB;EACxB;EACA;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,QAAQ;EAC7D;EACA;EACD,CAAC;UACO,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,4 +1,4 @@
|
|
|
1
|
-
import { t as startGenerate } from "./generate-
|
|
1
|
+
import { t as startGenerate } from "./generate-_W54RXOa.mjs";
|
|
2
2
|
import path from "path";
|
|
3
3
|
import { existsSync, readdirSync } from "node:fs";
|
|
4
4
|
import { connectEntrypointTemplate, dockerfileTemplate, indexHtmlTemplate, indexTsTemplate, nginxConfTemplate, packageJsonExportsTemplate, packageJsonScriptsTemplate, switchboardEntrypointTemplate, syncAndPublishWorkflowTemplate, tsConfigTemplate } from "@powerhousedao/codegen/templates";
|
|
@@ -7,13 +7,13 @@ import { readPackage } from "read-pkg";
|
|
|
7
7
|
import { Project, SyntaxKind } from "ts-morph";
|
|
8
8
|
import { writePackage } from "write-package";
|
|
9
9
|
//#region src/services/migrate.ts
|
|
10
|
-
async function startMigrate(
|
|
10
|
+
async function startMigrate(_args) {
|
|
11
11
|
await migratePackageJson();
|
|
12
12
|
await migrateTsConfig();
|
|
13
13
|
await migrateIndexHtml();
|
|
14
14
|
await migrateCIFiles();
|
|
15
|
-
await runGenerateOnAllDocumentModels(
|
|
16
|
-
await runGenerateOnAllEditors(
|
|
15
|
+
await runGenerateOnAllDocumentModels();
|
|
16
|
+
await runGenerateOnAllEditors();
|
|
17
17
|
const project = new Project({
|
|
18
18
|
tsConfigFilePath: path.resolve("tsconfig.json"),
|
|
19
19
|
compilerOptions: { verbatimModuleSyntax: false }
|
|
@@ -169,11 +169,11 @@ function fixImports(project) {
|
|
|
169
169
|
}
|
|
170
170
|
}
|
|
171
171
|
/** Run the generate command on all document models */
|
|
172
|
-
async function runGenerateOnAllDocumentModels(
|
|
173
|
-
await startGenerate({
|
|
172
|
+
async function runGenerateOnAllDocumentModels() {
|
|
173
|
+
await startGenerate({});
|
|
174
174
|
}
|
|
175
175
|
/** Run the generate command on all editors */
|
|
176
|
-
async function runGenerateOnAllEditors(
|
|
176
|
+
async function runGenerateOnAllEditors() {
|
|
177
177
|
const editorsPath = path.join(process.cwd(), "editors");
|
|
178
178
|
const dirs = (await readdir(editorsPath, { withFileTypes: true })).filter((entry) => entry.isDirectory()).map((entry) => entry.name);
|
|
179
179
|
for (const dir of dirs) {
|
|
@@ -191,15 +191,13 @@ async function runGenerateOnAllEditors(useHygen) {
|
|
|
191
191
|
driveEditorName: name,
|
|
192
192
|
driveEditorId: id,
|
|
193
193
|
driveEditorDirName: dir,
|
|
194
|
-
allowedDocumentTypes: existsSync(configFilePath) ? extractAllowedDocumentTypes(configFilePath) : void 0
|
|
195
|
-
useHygen
|
|
194
|
+
allowedDocumentTypes: existsSync(configFilePath) ? extractAllowedDocumentTypes(configFilePath) : void 0
|
|
196
195
|
});
|
|
197
196
|
} else await startGenerate({
|
|
198
197
|
editorName: name,
|
|
199
198
|
editorId: id,
|
|
200
199
|
editorDirName: dir,
|
|
201
|
-
documentType: documentTypes?.[0]
|
|
202
|
-
useHygen
|
|
200
|
+
documentType: documentTypes?.[0]
|
|
203
201
|
});
|
|
204
202
|
}
|
|
205
203
|
}
|
|
@@ -244,4 +242,4 @@ function getArrayLiteralExpressionElementsText(arrayLiteralExpression) {
|
|
|
244
242
|
//#endregion
|
|
245
243
|
export { startMigrate };
|
|
246
244
|
|
|
247
|
-
//# sourceMappingURL=migrate-
|
|
245
|
+
//# sourceMappingURL=migrate-8KFwMxaP.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"migrate-8KFwMxaP.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, isDriveEditor } =\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 (isDriveEditor) {\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 driveEditorName: name,\n driveEditorId: id,\n driveEditorDirName: 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 drive editor 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 isDriveEditor = documentTypes?.includes(\"powerhouse/document-drive\");\n return { id, name, documentTypes, isDriveEditor };\n}\n\n/** Extract the allowed document types from the drive editor 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 \"PHDriveEditorConfig\",\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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ACrB,UACA,UACA,WAAW,wBACZ;AAUD,QAAO;EAAE,IARE,sBACT,kBAAkB,gBAAgB,MAAM,WAAW,cAAc,CAClE;EAMY,MAJA,sBACX,kBAAkB,gBAAgB,QAAQ,WAAW,cAAc,CACpE;EAEkB;EAAe,eADZ,eAAe,SAAS,4BAA4B;EACzB;;;AAInD,SAAS,4BAA4B,UAAkB;CAOrD,MAAM,aANU,IAAI,QAAQ;EAC1B,kBAAkB,KAAK,QAAQ,gBAAgB;EAC/C,iBAAiB,EACf,sBAAsB,OACvB;EACF,CAAC,CACyB,cAAc,SAAS;AAClD,KAAI,CAAC,WAAY;CAKjB,MAAM,iBAJ4B,iCAChC,YACA,sBACD,EACiD,qBAChD,WAAW,wBACZ;AACD,KAAI,CAAC,eAAgB;AAQrB,QAP6B,sCAC3B,kBACE,gBACA,wBACA,WAAW,uBACZ,CACF;;AAIH,SAAS,iCACP,YACA,UACA;AAEA,QAD6B,WAAW,yBAAyB,CACrC,MAAM,gBAChC,YAAY,SAAS,CAAC,SAAS,CAAC,SAAS,SAAS,CACnD;;AAGH,SAAS,sBAAsB,eAA0C;AACvE,QAAO,eAAe,SAAS,CAAC,QAAQ,SAAS,GAAG;;AAGtD,SAAS,kBACP,QACA,cACA,cACA;AACA,QAAO,QACH,YAAY,aAAa,EACzB,OAAO,WAAW,mBAAmB,EACrC,aAAa,CACd,MAAM,UAAU,MAAM,SAAS,KAAK,aAAa,EAChD,OAAO,aAAa;;AAG1B,SAAS,sCACP,wBACA;AACA,QAAO,wBACH,aAAa,CACd,KAAK,YAAY,QAAQ,SAAS,CAAC,CACnC,KAAK,SAAS,KAAK,QAAQ,SAAS,GAAG,CAAC"}
|
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.110",
|
|
4
4
|
"description": "",
|
|
5
5
|
"license": "AGPL-3.0-only",
|
|
6
6
|
"type": "module",
|
|
@@ -33,15 +33,15 @@
|
|
|
33
33
|
"read-pkg": "10.1.0",
|
|
34
34
|
"ts-morph": "27.0.2",
|
|
35
35
|
"write-package": "7.2.0",
|
|
36
|
-
"@powerhousedao/codegen": "6.0.0-dev.
|
|
37
|
-
"
|
|
38
|
-
"
|
|
39
|
-
"@powerhousedao/
|
|
40
|
-
"@powerhousedao/reactor": "6.0.0-dev.
|
|
41
|
-
"@powerhousedao/shared": "6.0.0-dev.
|
|
42
|
-
"@powerhousedao/switchboard": "6.0.0-dev.
|
|
43
|
-
"@powerhousedao/builder-tools": "6.0.0-dev.
|
|
44
|
-
"@renown/sdk": "6.0.0-dev.
|
|
36
|
+
"@powerhousedao/codegen": "6.0.0-dev.110",
|
|
37
|
+
"document-model": "6.0.0-dev.110",
|
|
38
|
+
"@powerhousedao/common": "6.0.0-dev.110",
|
|
39
|
+
"@powerhousedao/config": "6.0.0-dev.110",
|
|
40
|
+
"@powerhousedao/reactor": "6.0.0-dev.110",
|
|
41
|
+
"@powerhousedao/shared": "6.0.0-dev.110",
|
|
42
|
+
"@powerhousedao/switchboard": "6.0.0-dev.110",
|
|
43
|
+
"@powerhousedao/builder-tools": "6.0.0-dev.110",
|
|
44
|
+
"@renown/sdk": "6.0.0-dev.110"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@types/node": "25.2.3",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"generate-howgVbAT.mjs","names":["generateCode"],"sources":["../src/services/generate.ts"],"sourcesContent":["import {\n generate as generateCode,\n generateDBSchema,\n generateDriveEditor,\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 driveEditorName,\n driveEditorId,\n driveEditorDirName,\n allowedDocumentTypes,\n disableDragAndDrop,\n processorName,\n processorType,\n processorApps,\n importScriptName,\n migrationFile,\n schemaFile,\n verbose,\n force,\n useVersioning: useVersioningFlag,\n useHygen,\n subgraphName,\n migrateLegacy,\n } = options;\n\n const documentModelFile =\n documentModelFilePositional ?? documentModelFileOption;\n\n const useVersioning = useVersioningFlag || migrateLegacy;\n const useTsMorph = useVersioning || !useHygen;\n const isDragAndDropEnabled = disableDragAndDrop !== true;\n const specifiedPackageName = undefined;\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 useTsMorph,\n skipFormat,\n specifiedPackageName,\n });\n } else if (driveEditorName !== undefined) {\n await generateDriveEditor({\n driveEditorName,\n driveEditorId,\n driveEditorDirName,\n allowedDocumentTypes,\n isDragAndDropEnabled,\n useTsMorph,\n skipFormat,\n specifiedPackageName,\n });\n } else if (processorName !== undefined) {\n await generateProcessor({\n processorName,\n processorType,\n skipFormat,\n useTsMorph,\n processorApps,\n documentTypes: [documentTypeToUse].filter((t) => t !== undefined),\n });\n } else if (subgraphName !== undefined) {\n await generateSubgraph(subgraphName, filePath || null, config, {\n verbose,\n force,\n });\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 useTsMorph,\n options,\n useVersioning,\n migrateLegacy,\n });\n } else {\n await generateCode(config, useTsMorph, 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,iBACA,eACA,oBACA,sBACA,oBACA,eACA,eACA,eACA,kBACA,eACA,YACA,SACA,OACA,eAAe,mBACf,UACA,cACA,kBACE;CAEJ,MAAM,oBACJ,+BAA+B;CAEjC,MAAM,gBAAgB,qBAAqB;CAC3C,MAAM,aAAa,iBAAiB,CAAC;CACrC,MAAM,uBAAuB,uBAAuB;CACpD,MAAM,uBAAuB,KAAA;CAC7B,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;GACA;GACA;GACD,CAAC;YACO,oBAAoB,KAAA,EAC7B,OAAM,oBAAoB;EACxB;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;UACO,kBAAkB,KAAA,EAC3B,OAAM,kBAAkB;EACtB;EACA;EACA;EACA;EACA;EACA,eAAe,CAAC,kBAAkB,CAAC,QAAQ,MAAM,MAAM,KAAA,EAAU;EAClE,CAAC;UACO,iBAAiB,KAAA,EAC1B,OAAM,iBAAiB,cAAc,YAAY,MAAM,QAAQ;EAC7D;EACA;EACD,CAAC;UACO,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;EACA;EACD,CAAC;KAEF,OAAMA,SAAa,QAAQ,YAAY,eAAe,cAAc"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"migrate-DErTQPCC.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({ useHygen = false }: MigrateArgs) {\n await migratePackageJson();\n await migrateTsConfig();\n await migrateIndexHtml();\n await migrateCIFiles();\n await runGenerateOnAllDocumentModels(useHygen);\n await runGenerateOnAllEditors(useHygen);\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(useHygen: boolean) {\n await startGenerate({\n useHygen,\n } as GenerateArgs);\n}\n\n/** Run the generate command on all editors */\nasync function runGenerateOnAllEditors(useHygen: boolean) {\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, isDriveEditor } =\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 (isDriveEditor) {\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 driveEditorName: name,\n driveEditorId: id,\n driveEditorDirName: dir,\n allowedDocumentTypes,\n useHygen,\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 useHygen,\n } as GenerateArgs;\n await startGenerate(args);\n }\n }\n}\n\n/** Extract the name, id, document types, and whether the editor is a drive editor 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 isDriveEditor = documentTypes?.includes(\"powerhouse/document-drive\");\n return { id, name, documentTypes, isDriveEditor };\n}\n\n/** Extract the allowed document types from the drive editor 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 \"PHDriveEditorConfig\",\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,EAAE,WAAW,SAAsB;AACpE,OAAM,oBAAoB;AAC1B,OAAM,iBAAiB;AACvB,OAAM,kBAAkB;AACxB,OAAM,gBAAgB;AACtB,OAAM,+BAA+B,SAAS;AAC9C,OAAM,wBAAwB,SAAS;CACvC,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,OA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