@powerhousedao/ph-cli 6.0.0-dev.135 → 6.0.0-dev.137

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 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-BgT8nwCT.mjs");
207
+ const { startGenerate } = await import("./generate-CMQGYRrW.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-M5sBkyDW.mjs");
522
+ const { startMigrate } = await import("./migrate-DzLTX506.mjs");
523
523
  await startMigrate(args);
524
524
  process.exit(0);
525
525
  }
@@ -0,0 +1,2 @@
1
+ import { t as startGenerate } from "./generate-Dq80G8n4.mjs";
2
+ export { startGenerate };
@@ -1,11 +1,11 @@
1
1
  import path from "path";
2
2
  import { getConfig } from "@powerhousedao/config/node";
3
- import { generate, generateDBSchema, generateDriveEditor, generateEditor, generateFromFile, generateImportScript, generateProcessor, generateSubgraph } from "@powerhousedao/codegen";
3
+ import { generate, generateApp, generateDBSchema, generateEditor, generateFromFile, generateImportScript, generateProcessor, generateSubgraph } from "@powerhousedao/codegen";
4
4
  //#region src/services/generate.ts
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, subgraphName, migrateLegacy } = options;
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;
9
9
  const documentModelFile = documentModelFilePositional ?? documentModelFileOption;
10
10
  const useVersioning = useVersioningFlag || migrateLegacy;
11
11
  const isDragAndDropEnabled = disableDragAndDrop !== true;
@@ -22,10 +22,10 @@ async function startGenerate(options) {
22
22
  documentTypes: [documentTypeToUse],
23
23
  skipFormat
24
24
  });
25
- } else if (driveEditorName !== void 0) await generateDriveEditor({
26
- driveEditorName,
27
- driveEditorId,
28
- driveEditorDirName,
25
+ } else if (appName !== void 0) await generateApp({
26
+ appName,
27
+ appId,
28
+ appDirName,
29
29
  allowedDocumentTypes,
30
30
  isDragAndDropEnabled,
31
31
  skipFormat
@@ -55,4 +55,4 @@ async function startGenerate(options) {
55
55
  //#endregion
56
56
  export { startGenerate as t };
57
57
 
58
- //# sourceMappingURL=generate-D7MhepEK.mjs.map
58
+ //# sourceMappingURL=generate-Dq80G8n4.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generate-Dq80G8n4.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,4 +1,4 @@
1
- import { t as startGenerate } from "./generate-D7MhepEK.mjs";
1
+ import { t as startGenerate } from "./generate-Dq80G8n4.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";
@@ -182,15 +182,15 @@ async function runGenerateOnAllEditors() {
182
182
  const hasModuleFile = existsSync(moduleFilePath);
183
183
  const hasIndexFile = existsSync(indexFilePath);
184
184
  if (!hasModuleFile && !hasIndexFile) continue;
185
- const { id, name, documentTypes, isDriveEditor } = extractEditorModuleInfo(hasModuleFile ? moduleFilePath : indexFilePath);
185
+ const { id, name, documentTypes, isApp } = extractEditorModuleInfo(hasModuleFile ? moduleFilePath : indexFilePath);
186
186
  if (!name) throw new Error(`Editor ${dir} is missing name`);
187
187
  if (!id) throw new Error(`Editor ${dir} is missing id`);
188
- if (isDriveEditor) {
188
+ if (isApp) {
189
189
  const configFilePath = path.join(editorsPath, dir, "config.ts");
190
190
  await startGenerate({
191
- driveEditorName: name,
192
- driveEditorId: id,
193
- driveEditorDirName: dir,
191
+ appName: name,
192
+ appId: id,
193
+ appDirName: dir,
194
194
  allowedDocumentTypes: existsSync(configFilePath) ? extractAllowedDocumentTypes(configFilePath) : void 0
195
195
  });
196
196
  } else await startGenerate({
@@ -201,7 +201,7 @@ async function runGenerateOnAllEditors() {
201
201
  });
202
202
  }
203
203
  }
204
- /** Extract the name, id, document types, and whether the editor is a drive editor from the editor module */
204
+ /** Extract the name, id, document types, and whether the editor is a app from the editor module */
205
205
  function extractEditorModuleInfo(filePath) {
206
206
  const variable = getVariableDeclarationByTypeName(new Project({
207
207
  tsConfigFilePath: path.resolve("tsconfig.json"),
@@ -213,17 +213,17 @@ function extractEditorModuleInfo(filePath) {
213
213
  id: getStringLiteralValue(getObjectProperty(configProperty, "id", SyntaxKind.StringLiteral)),
214
214
  name: getStringLiteralValue(getObjectProperty(configProperty, "name", SyntaxKind.StringLiteral)),
215
215
  documentTypes,
216
- isDriveEditor: documentTypes?.includes("powerhouse/document-drive")
216
+ isApp: documentTypes?.includes("powerhouse/document-drive")
217
217
  };
218
218
  }
219
- /** Extract the allowed document types from the drive editor config */
219
+ /** Extract the allowed document types from the app config */
220
220
  function extractAllowedDocumentTypes(filePath) {
221
221
  const sourceFile = new Project({
222
222
  tsConfigFilePath: path.resolve("tsconfig.json"),
223
223
  compilerOptions: { verbatimModuleSyntax: false }
224
224
  }).getSourceFile(filePath);
225
225
  if (!sourceFile) return;
226
- const configVariable = getVariableDeclarationByTypeName(sourceFile, "PHDriveEditorConfig")?.getInitializerIfKind(SyntaxKind.ObjectLiteralExpression);
226
+ const configVariable = getVariableDeclarationByTypeName(sourceFile, "PHAppConfig")?.getInitializerIfKind(SyntaxKind.ObjectLiteralExpression);
227
227
  if (!configVariable) return;
228
228
  return getArrayLiteralExpressionElementsText(getObjectProperty(configVariable, "allowedDocumentTypes", SyntaxKind.ArrayLiteralExpression));
229
229
  }
@@ -242,4 +242,4 @@ function getArrayLiteralExpressionElementsText(arrayLiteralExpression) {
242
242
  //#endregion
243
243
  export { startMigrate };
244
244
 
245
- //# sourceMappingURL=migrate-M5sBkyDW.mjs.map
245
+ //# sourceMappingURL=migrate-DzLTX506.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"migrate-DzLTX506.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,YA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
1
  {
2
2
  "name": "@powerhousedao/ph-cli",
3
- "version": "6.0.0-dev.135",
3
+ "version": "6.0.0-dev.137",
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.135",
37
- "document-model": "6.0.0-dev.135",
38
- "@powerhousedao/common": "6.0.0-dev.135",
39
- "@powerhousedao/reactor": "6.0.0-dev.135",
40
- "@powerhousedao/config": "6.0.0-dev.135",
41
- "@powerhousedao/builder-tools": "6.0.0-dev.135",
42
- "@powerhousedao/switchboard": "6.0.0-dev.135",
43
- "@renown/sdk": "6.0.0-dev.135",
44
- "@powerhousedao/shared": "6.0.0-dev.135"
36
+ "@powerhousedao/codegen": "6.0.0-dev.137",
37
+ "document-model": "6.0.0-dev.137",
38
+ "@powerhousedao/common": "6.0.0-dev.137",
39
+ "@powerhousedao/config": "6.0.0-dev.137",
40
+ "@powerhousedao/reactor": "6.0.0-dev.137",
41
+ "@powerhousedao/switchboard": "6.0.0-dev.137",
42
+ "@powerhousedao/builder-tools": "6.0.0-dev.137",
43
+ "@renown/sdk": "6.0.0-dev.137",
44
+ "@powerhousedao/shared": "6.0.0-dev.137"
45
45
  },
46
46
  "devDependencies": {
47
47
  "@types/node": "25.2.3",
@@ -1,2 +0,0 @@
1
- import { t as startGenerate } from "./generate-D7MhepEK.mjs";
2
- export { startGenerate };
@@ -1 +0,0 @@
1
- {"version":3,"file":"generate-D7MhepEK.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 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 (driveEditorName !== undefined) {\n await generateDriveEditor({\n driveEditorName,\n driveEditorId,\n driveEditorDirName,\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,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,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,oBAAoB,KAAA,EAC7B,OAAM,oBAAoB;EACxB;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 +0,0 @@
1
- {"version":3,"file":"migrate-M5sBkyDW.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;AACtB,aAAY,UAAU;AACtB,OAAM,aAAa,YAAY;;;AAIjC,eAAe,mBAAmB;AAEhC,OAAM,UADgB,KAAK,KAAK,QAAQ,KAAK,EAAE,aAAa,EAC7B,kBAAkB;;;AAInD,eAAe,kBAAkB;AAE/B,OAAM,UADe,KAAK,KAAK,QAAQ,KAAK,EAAE,gBAAgB,EAChC,iBAAiB;;;AAIjD,eAAe,WAAW,UAAoC;AAC5D,KAAI;AACF,QAAM,KAAK,SAAS;AACpB,SAAO;SACD;AACN,SAAO;;;;AAKX,eAAe,qBACb,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