@powerhousedao/codegen 6.0.0-dev.134 → 6.0.0-dev.136
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/{file-builders-DTtl0nnu.mjs → file-builders-DRzXbZTI.mjs} +190 -198
- package/dist/file-builders-DRzXbZTI.mjs.map +1 -0
- package/dist/{index-bxxFsCxV.d.mts → index-CHAnPBj2.d.mts} +26 -29
- package/dist/index-CHAnPBj2.d.mts.map +1 -0
- package/dist/index.d.mts +6 -9
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +14 -29
- package/dist/index.mjs.map +1 -1
- package/dist/src/file-builders/index.d.mts +3 -3
- package/dist/src/file-builders/index.mjs +3 -3
- package/dist/src/templates/index.d.mts +49 -49
- package/dist/src/templates/index.d.mts.map +1 -1
- package/dist/src/templates/index.mjs +2 -2
- package/dist/src/utils/index.d.mts +2 -4
- package/dist/src/utils/index.d.mts.map +1 -1
- package/dist/src/utils/index.mjs +3 -3
- package/dist/src/utils/index.mjs.map +1 -1
- package/dist/{templates-CKdxigVj.mjs → templates-DBvz_qPL.mjs} +522 -522
- package/dist/templates-DBvz_qPL.mjs.map +1 -0
- package/dist/{types-BcTGclWR.d.mts → types-e2ztuDtG.d.mts} +1 -3
- package/dist/types-e2ztuDtG.d.mts.map +1 -0
- package/package.json +3 -3
- package/dist/file-builders-DTtl0nnu.mjs.map +0 -1
- package/dist/index-bxxFsCxV.d.mts.map +0 -1
- package/dist/templates-CKdxigVj.mjs.map +0 -1
- package/dist/types-BcTGclWR.d.mts.map +0 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { A as documentModelHooksFileTemplate, Bt as appDriveContentsFileTemplate, D as documentModelSrcIndexFileTemplate, E as documentModelSrcUtilsTemplate, F as documentModelPhFactoriesFileTemplate, Ft as folderTreeFileTemplate, G as documentModelGenControllerFileTemplate, H as documentModelDocumentTypeTemplate, I as documentModelOperationsModuleOperationsFileTemplate, It as appFoldersFileTemplate, J as documentEditorModuleFileTemplate, K as documentModelGenActionsFileTemplate, L as documentModelOperationsModuleErrorFileTemplate, Lt as appFilesFileTemplate, M as documentModelGenTypesTemplate, Mt as appEditorFileTemplate, N as documentModelSchemaIndexTemplate, Nt as appConfigFileTemplate, O as documentModelModuleFileTemplate, P as documentModelGenReducerFileTemplate, Pt as driveExplorerNavigationBreadcrumbsFileTemplate, R as documentModelOperationsModuleCreatorsFileTemplate, Rt as emptyStateFileTemplate, S as makeActionImportNames, T as documentModelTestFileTemplate, U as documentModelDocumentSchemaFileTemplate, V as documentModelGenIndexFileTemplate, Vt as createDocumentFileTemplate, W as documentModelGenCreatorsFileTemplate, X as docsFromCliHelpTemplate, Y as documentEditorEditorFileTemplate, _ as analyticsFactoryTemplate, a as subgraphLibFileTemplate, b as upgradeManifestTemplate, c as relationalDbProcessorTemplate, d as relationalDbFactoryTemplate, g as analyticsIndexTemplate, h as analyticsProcessorTemplate, i as customSubgraphSchemaTemplate, j as documentModelGenUtilsTemplate, k as documentModelIndexTemplate, l as relationalDbMigrationsTemplate, lt as packageJsonTemplate, m as factoryBuildersTemplate, n as documentModelSubgraphSchemaTemplate, o as subgraphIndexFileTemplate, q as documentModelRootActionsFileTemplate, r as customSubgraphResolversTemplate, s as relationalDbSchemaTemplate, t as documentModelSubgraphResolversTemplate, u as relationalDbIndexTemplate, v as documentModelUtilsTemplate, w as makeTestCaseForAction, y as upgradeTransitionTemplate, z as documentModelOperationModuleActionsFileTemplate, zt as driveExplorerFileTemplate } from "./templates-DBvz_qPL.mjs";
|
|
2
2
|
import { getDocumentModelDirName, getDocumentModelOperationsModuleVariableNames, getDocumentModelVariableNames, getEditorVariableNames } from "./src/name-builders/index.mjs";
|
|
3
3
|
import { applyGraphQLTypePrefixes, buildObjectLiteral, buildTsMorphProject, ensureDirectoriesExist, extractTypeNames, formatSourceFileWithPrettier, getDocumentTypeMetadata, getInitialStates, getObjectLiteral, getOrCreateDirectory, getOrCreateSourceFile, getPreviousVersionSourceFile, getVariableDeclarationByTypeName } from "./src/utils/index.mjs";
|
|
4
4
|
import { VERSIONED_DEPENDENCIES, VERSIONED_DEV_DEPENDENCIES, directoryExists, fileExists, makeVersionedDependencies } from "@powerhousedao/shared/clis";
|
|
@@ -311,47 +311,8 @@ const generateSchemas = async (inDir, { watch = false, skipFormat = false, write
|
|
|
311
311
|
}));
|
|
312
312
|
};
|
|
313
313
|
//#endregion
|
|
314
|
-
//#region src/file-builders/boilerplate/package.json.ts
|
|
315
|
-
async function buildBoilerplatePackageJson(args) {
|
|
316
|
-
const { name, tag, version, workspace } = args;
|
|
317
|
-
return packageJsonTemplate(name, await makeVersionedDependencies({
|
|
318
|
-
names: VERSIONED_DEPENDENCIES,
|
|
319
|
-
tag,
|
|
320
|
-
version
|
|
321
|
-
}), await makeVersionedDependencies({
|
|
322
|
-
names: VERSIONED_DEV_DEPENDENCIES,
|
|
323
|
-
tag,
|
|
324
|
-
version
|
|
325
|
-
}));
|
|
326
|
-
}
|
|
327
|
-
//#endregion
|
|
328
|
-
//#region src/file-builders/clis/generate-cli-docs.ts
|
|
329
|
-
function getCommandHelpInfo(entry) {
|
|
330
|
-
return {
|
|
331
|
-
name: entry.name,
|
|
332
|
-
description: entry.command.description ?? "",
|
|
333
|
-
helpTopics: entry.command.helpTopics?.() ?? []
|
|
334
|
-
};
|
|
335
|
-
}
|
|
336
|
-
function getCommandsHelpInfo(entries) {
|
|
337
|
-
return entries.map(getCommandHelpInfo);
|
|
338
|
-
}
|
|
339
|
-
function makeCliDocsFromHelp(args) {
|
|
340
|
-
const { cliDescription, docsIntroduction, docsTitle, entries } = args;
|
|
341
|
-
return stripVTControlCharacters(docsFromCliHelpTemplate({
|
|
342
|
-
cliDescription,
|
|
343
|
-
docsIntroduction,
|
|
344
|
-
docsTitle,
|
|
345
|
-
commandsHelpInfo: getCommandsHelpInfo(entries)
|
|
346
|
-
}));
|
|
347
|
-
}
|
|
348
|
-
async function writeCliDocsMarkdownFile(args) {
|
|
349
|
-
const { filePath, ...restArgs } = args;
|
|
350
|
-
await writeFile(filePath, makeCliDocsFromHelp(restArgs), { encoding: "utf-8" });
|
|
351
|
-
}
|
|
352
|
-
//#endregion
|
|
353
314
|
//#region src/file-builders/editor-common.ts
|
|
354
|
-
/** Generates the `module.ts` file for a document editor or
|
|
315
|
+
/** Generates the `module.ts` file for a document editor or app */
|
|
355
316
|
function makeEditorModuleFile({ project, editorDirPath, editorName, documentModelId, editorId, legacyMultipleDocumentTypes }) {
|
|
356
317
|
if (documentModelId && !!legacyMultipleDocumentTypes) throw new Error("Cannot specify both documentModelId and legacyMultipleDocumentTypes");
|
|
357
318
|
const { sourceFile } = getOrCreateSourceFile(project, path$1.join(editorDirPath, "module.ts"));
|
|
@@ -525,9 +486,188 @@ function makeUpgradeManifestsExport({ project, modulesDirPath, outputFilePath, v
|
|
|
525
486
|
(outputSourceFile.addVariableStatement(variableStatementInput).getDeclarations().at(0)?.getInitializerIfKind(SyntaxKind.ArrayLiteralExpression))?.addElements(manifests.map((m) => m.aliasedName), { useNewLines: true });
|
|
526
487
|
}
|
|
527
488
|
//#endregion
|
|
489
|
+
//#region src/file-builders/app.ts
|
|
490
|
+
/** Generates a app with the configs for `allowedDocumentModelIds` and `isDragAndDropEnabled` */
|
|
491
|
+
async function tsMorphGenerateApp({ projectDir, editorDir, editorName, editorId, allowedDocumentModelIds, isDragAndDropEnabled }) {
|
|
492
|
+
const documentModelsDirPath = path$1.join(projectDir, "document-models");
|
|
493
|
+
const documentModelsSourceFilesPath = path$1.join(documentModelsDirPath, "/**/*");
|
|
494
|
+
const editorsDirPath = path$1.join(projectDir, "editors");
|
|
495
|
+
const editorSourceFilesPath = path$1.join(editorsDirPath, "/**/*");
|
|
496
|
+
const editorDirPath = path$1.join(editorsDirPath, editorDir);
|
|
497
|
+
const editorComponentsDirPath = path$1.join(editorDirPath, "components");
|
|
498
|
+
const project = buildTsMorphProject(projectDir);
|
|
499
|
+
await ensureDirectoriesExist(project, documentModelsDirPath, editorsDirPath, editorDirPath, editorComponentsDirPath);
|
|
500
|
+
project.addSourceFilesAtPaths(documentModelsSourceFilesPath);
|
|
501
|
+
project.addSourceFilesAtPaths(editorSourceFilesPath);
|
|
502
|
+
await makeNavigationBreadcrumbsFile({
|
|
503
|
+
project,
|
|
504
|
+
editorComponentsDirPath
|
|
505
|
+
});
|
|
506
|
+
await makeCreateDocumentFile({
|
|
507
|
+
project,
|
|
508
|
+
editorComponentsDirPath
|
|
509
|
+
});
|
|
510
|
+
await makeEmptyStateFile({
|
|
511
|
+
project,
|
|
512
|
+
editorComponentsDirPath
|
|
513
|
+
});
|
|
514
|
+
await makeFoldersFile({
|
|
515
|
+
project,
|
|
516
|
+
editorComponentsDirPath
|
|
517
|
+
});
|
|
518
|
+
await makeFolderTreeFile({
|
|
519
|
+
project,
|
|
520
|
+
editorComponentsDirPath
|
|
521
|
+
});
|
|
522
|
+
await makeFilesFile({
|
|
523
|
+
project,
|
|
524
|
+
editorComponentsDirPath
|
|
525
|
+
});
|
|
526
|
+
await makeDriveExplorerFile({
|
|
527
|
+
project,
|
|
528
|
+
editorComponentsDirPath
|
|
529
|
+
});
|
|
530
|
+
await makeDriveContentsFile({
|
|
531
|
+
project,
|
|
532
|
+
editorComponentsDirPath
|
|
533
|
+
});
|
|
534
|
+
await makeAppComponent({
|
|
535
|
+
project,
|
|
536
|
+
editorDirPath
|
|
537
|
+
});
|
|
538
|
+
await makeAppConfigFile({
|
|
539
|
+
project,
|
|
540
|
+
allowedDocumentModelIds,
|
|
541
|
+
isDragAndDropEnabled,
|
|
542
|
+
editorDirPath
|
|
543
|
+
});
|
|
544
|
+
makeEditorModuleFile({
|
|
545
|
+
project,
|
|
546
|
+
editorName,
|
|
547
|
+
editorId,
|
|
548
|
+
editorDirPath,
|
|
549
|
+
documentModelId: "powerhouse/document-drive"
|
|
550
|
+
});
|
|
551
|
+
await makeEditorsModulesFile(project, projectDir);
|
|
552
|
+
await project.save();
|
|
553
|
+
}
|
|
554
|
+
async function makeAppComponent({ project, editorDirPath }) {
|
|
555
|
+
const { alreadyExists, sourceFile } = getOrCreateSourceFile(project, path$1.join(editorDirPath, "editor.tsx"));
|
|
556
|
+
if (alreadyExists) {
|
|
557
|
+
const editorFunction = sourceFile.getFunction("Editor");
|
|
558
|
+
if (editorFunction) {
|
|
559
|
+
if (!editorFunction.isDefaultExport()) editorFunction.setIsDefaultExport(true);
|
|
560
|
+
return;
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
const template = appEditorFileTemplate();
|
|
564
|
+
sourceFile.replaceWithText(template);
|
|
565
|
+
await formatSourceFileWithPrettier(sourceFile);
|
|
566
|
+
}
|
|
567
|
+
async function makeAppConfigFile({ project, editorDirPath, allowedDocumentModelIds, isDragAndDropEnabled }) {
|
|
568
|
+
const { sourceFile } = getOrCreateSourceFile(project, path$1.join(editorDirPath, "config.ts"));
|
|
569
|
+
const allowedDocumentTypesString = JSON.stringify(allowedDocumentModelIds);
|
|
570
|
+
const template = appConfigFileTemplate({
|
|
571
|
+
isDragAndDropEnabledString: isDragAndDropEnabled ? "true" : "false",
|
|
572
|
+
allowedDocumentTypesString
|
|
573
|
+
});
|
|
574
|
+
sourceFile.replaceWithText(template);
|
|
575
|
+
await formatSourceFileWithPrettier(sourceFile);
|
|
576
|
+
}
|
|
577
|
+
async function makeDriveContentsFile({ project, editorComponentsDirPath }) {
|
|
578
|
+
const { alreadyExists, sourceFile } = getOrCreateSourceFile(project, path$1.join(editorComponentsDirPath, "DriveContents.tsx"));
|
|
579
|
+
if (alreadyExists) return;
|
|
580
|
+
const template = appDriveContentsFileTemplate();
|
|
581
|
+
sourceFile.replaceWithText(template);
|
|
582
|
+
await formatSourceFileWithPrettier(sourceFile);
|
|
583
|
+
}
|
|
584
|
+
async function makeNavigationBreadcrumbsFile({ project, editorComponentsDirPath }) {
|
|
585
|
+
const { alreadyExists, sourceFile } = getOrCreateSourceFile(project, path$1.join(editorComponentsDirPath, "NavigationBreadcrumbs.tsx"));
|
|
586
|
+
if (alreadyExists) return;
|
|
587
|
+
sourceFile.replaceWithText(driveExplorerNavigationBreadcrumbsFileTemplate());
|
|
588
|
+
await formatSourceFileWithPrettier(sourceFile);
|
|
589
|
+
}
|
|
590
|
+
async function makeFoldersFile({ project, editorComponentsDirPath }) {
|
|
591
|
+
const { alreadyExists, sourceFile } = getOrCreateSourceFile(project, path$1.join(editorComponentsDirPath, "Folders.tsx"));
|
|
592
|
+
if (alreadyExists) return;
|
|
593
|
+
const template = appFoldersFileTemplate();
|
|
594
|
+
sourceFile.replaceWithText(template);
|
|
595
|
+
await formatSourceFileWithPrettier(sourceFile);
|
|
596
|
+
}
|
|
597
|
+
async function makeFilesFile({ project, editorComponentsDirPath }) {
|
|
598
|
+
const { alreadyExists, sourceFile } = getOrCreateSourceFile(project, path$1.join(editorComponentsDirPath, "Files.tsx"));
|
|
599
|
+
if (alreadyExists) return;
|
|
600
|
+
const template = appFilesFileTemplate();
|
|
601
|
+
sourceFile.replaceWithText(template);
|
|
602
|
+
await formatSourceFileWithPrettier(sourceFile);
|
|
603
|
+
}
|
|
604
|
+
async function makeDriveExplorerFile({ project, editorComponentsDirPath }) {
|
|
605
|
+
const { alreadyExists, sourceFile } = getOrCreateSourceFile(project, path$1.join(editorComponentsDirPath, "DriveExplorer.tsx"));
|
|
606
|
+
if (alreadyExists) return;
|
|
607
|
+
sourceFile.replaceWithText(driveExplorerFileTemplate);
|
|
608
|
+
await formatSourceFileWithPrettier(sourceFile);
|
|
609
|
+
}
|
|
610
|
+
async function makeFolderTreeFile({ project, editorComponentsDirPath }) {
|
|
611
|
+
const { alreadyExists, sourceFile } = getOrCreateSourceFile(project, path$1.join(editorComponentsDirPath, "FolderTree.tsx"));
|
|
612
|
+
if (alreadyExists) return;
|
|
613
|
+
sourceFile.replaceWithText(folderTreeFileTemplate);
|
|
614
|
+
await formatSourceFileWithPrettier(sourceFile);
|
|
615
|
+
}
|
|
616
|
+
async function makeEmptyStateFile({ project, editorComponentsDirPath }) {
|
|
617
|
+
const { alreadyExists, sourceFile } = getOrCreateSourceFile(project, path$1.join(editorComponentsDirPath, "EmptyState.tsx"));
|
|
618
|
+
if (alreadyExists) return;
|
|
619
|
+
sourceFile.replaceWithText(emptyStateFileTemplate);
|
|
620
|
+
await formatSourceFileWithPrettier(sourceFile);
|
|
621
|
+
}
|
|
622
|
+
async function makeCreateDocumentFile({ project, editorComponentsDirPath }) {
|
|
623
|
+
const { alreadyExists, sourceFile } = getOrCreateSourceFile(project, path$1.join(editorComponentsDirPath, "CreateDocument.tsx"));
|
|
624
|
+
if (alreadyExists) return;
|
|
625
|
+
sourceFile.replaceWithText(createDocumentFileTemplate);
|
|
626
|
+
await formatSourceFileWithPrettier(sourceFile);
|
|
627
|
+
}
|
|
628
|
+
//#endregion
|
|
629
|
+
//#region src/file-builders/boilerplate/package.json.ts
|
|
630
|
+
async function buildBoilerplatePackageJson(args) {
|
|
631
|
+
const { name, tag, version, workspace } = args;
|
|
632
|
+
return packageJsonTemplate(name, await makeVersionedDependencies({
|
|
633
|
+
names: VERSIONED_DEPENDENCIES,
|
|
634
|
+
tag,
|
|
635
|
+
version
|
|
636
|
+
}), await makeVersionedDependencies({
|
|
637
|
+
names: VERSIONED_DEV_DEPENDENCIES,
|
|
638
|
+
tag,
|
|
639
|
+
version
|
|
640
|
+
}));
|
|
641
|
+
}
|
|
642
|
+
//#endregion
|
|
643
|
+
//#region src/file-builders/clis/generate-cli-docs.ts
|
|
644
|
+
function getCommandHelpInfo(entry) {
|
|
645
|
+
return {
|
|
646
|
+
name: entry.name,
|
|
647
|
+
description: entry.command.description ?? "",
|
|
648
|
+
helpTopics: entry.command.helpTopics?.() ?? []
|
|
649
|
+
};
|
|
650
|
+
}
|
|
651
|
+
function getCommandsHelpInfo(entries) {
|
|
652
|
+
return entries.map(getCommandHelpInfo);
|
|
653
|
+
}
|
|
654
|
+
function makeCliDocsFromHelp(args) {
|
|
655
|
+
const { cliDescription, docsIntroduction, docsTitle, entries } = args;
|
|
656
|
+
return stripVTControlCharacters(docsFromCliHelpTemplate({
|
|
657
|
+
cliDescription,
|
|
658
|
+
docsIntroduction,
|
|
659
|
+
docsTitle,
|
|
660
|
+
commandsHelpInfo: getCommandsHelpInfo(entries)
|
|
661
|
+
}));
|
|
662
|
+
}
|
|
663
|
+
async function writeCliDocsMarkdownFile(args) {
|
|
664
|
+
const { filePath, ...restArgs } = args;
|
|
665
|
+
await writeFile(filePath, makeCliDocsFromHelp(restArgs), { encoding: "utf-8" });
|
|
666
|
+
}
|
|
667
|
+
//#endregion
|
|
528
668
|
//#region src/file-builders/document-editor.ts
|
|
529
669
|
/** Generates a document editor for the given `documentModelId` (also called `documentType`) */
|
|
530
|
-
async function tsMorphGenerateDocumentEditor({
|
|
670
|
+
async function tsMorphGenerateDocumentEditor({ projectDir, editorDir, editorName, editorId, documentModelId }) {
|
|
531
671
|
const documentModelsDirPath = path$1.join(projectDir, "document-models");
|
|
532
672
|
const editorsDirPath = path$1.join(projectDir, "editors");
|
|
533
673
|
const editorDirPath = path$1.join(editorsDirPath, editorDir);
|
|
@@ -540,7 +680,6 @@ async function tsMorphGenerateDocumentEditor({ packageName, projectDir, editorDi
|
|
|
540
680
|
project.addSourceFilesAtPaths(editorSourceFilesPath);
|
|
541
681
|
const documentTypeMetadata = getDocumentTypeMetadata({
|
|
542
682
|
project,
|
|
543
|
-
packageName,
|
|
544
683
|
documentModelId,
|
|
545
684
|
documentModelsDirPath
|
|
546
685
|
});
|
|
@@ -1207,7 +1346,7 @@ function makeUpgradeReducerExports(specVersions) {
|
|
|
1207
1346
|
* If `useVersioning` is set to true, it will generate versioned document model code
|
|
1208
1347
|
* for each `specification` in the `documentModelState`
|
|
1209
1348
|
*/
|
|
1210
|
-
async function tsMorphGenerateDocumentModel({ projectDir,
|
|
1349
|
+
async function tsMorphGenerateDocumentModel({ projectDir, documentModelState, useVersioning, migrateLegacy }) {
|
|
1211
1350
|
if (migrateLegacy) await migrateLegacyToVersioned(path$1.join(projectDir, "document-models", getDocumentModelDirName(documentModelState)));
|
|
1212
1351
|
const project = buildTsMorphProject(projectDir);
|
|
1213
1352
|
const documentModelsSourceFilesPath = path$1.join(projectDir, "document-models/**/*");
|
|
@@ -1234,7 +1373,6 @@ async function tsMorphGenerateDocumentModel({ projectDir, packageName, documentM
|
|
|
1234
1373
|
project,
|
|
1235
1374
|
version,
|
|
1236
1375
|
useVersioning: true,
|
|
1237
|
-
packageName,
|
|
1238
1376
|
documentModelState,
|
|
1239
1377
|
projectDir,
|
|
1240
1378
|
documentModelsDirPath,
|
|
@@ -1279,7 +1417,6 @@ async function tsMorphGenerateDocumentModel({ projectDir, packageName, documentM
|
|
|
1279
1417
|
project,
|
|
1280
1418
|
useVersioning: false,
|
|
1281
1419
|
version: latestVersion,
|
|
1282
|
-
packageName,
|
|
1283
1420
|
documentModelState,
|
|
1284
1421
|
projectDir,
|
|
1285
1422
|
documentModelsDirPath,
|
|
@@ -1291,7 +1428,7 @@ async function tsMorphGenerateDocumentModel({ projectDir, packageName, documentM
|
|
|
1291
1428
|
await project.save();
|
|
1292
1429
|
}
|
|
1293
1430
|
/** Generates document model code for a given `specification` from a `documentModelState` object */
|
|
1294
|
-
async function generateDocumentModelForSpec({ project, projectDir,
|
|
1431
|
+
async function generateDocumentModelForSpec({ project, projectDir, documentModelState, documentModelPackageImportPath, documentModelsDirPath, documentModelDirName, documentModelDirPath, useVersioning, version, ...documentModelVariableNames }) {
|
|
1295
1432
|
const specification = documentModelState.specifications.find((spec) => spec.version === version);
|
|
1296
1433
|
if (!specification) throw new Error(`Document model specifications array is misconfigured, no specification found for version: ${version}`);
|
|
1297
1434
|
const versionDirName = useVersioning ? `v${version}` : "";
|
|
@@ -1312,7 +1449,6 @@ async function generateDocumentModelForSpec({ project, projectDir, packageName,
|
|
|
1312
1449
|
const fileMakerArgs = {
|
|
1313
1450
|
project,
|
|
1314
1451
|
projectDir,
|
|
1315
|
-
packageName,
|
|
1316
1452
|
version,
|
|
1317
1453
|
useVersioning,
|
|
1318
1454
|
documentTypeId,
|
|
@@ -1398,149 +1534,9 @@ async function persistCustomFilesFromPreviousVersion(args) {
|
|
|
1398
1534
|
}
|
|
1399
1535
|
}
|
|
1400
1536
|
//#endregion
|
|
1401
|
-
//#region src/file-builders/drive-editor.ts
|
|
1402
|
-
/** Generates a drive editor with the configs for `allowedDocumentModelIds` and `isDragAndDropEnabled` */
|
|
1403
|
-
async function tsMorphGenerateDriveEditor({ projectDir, editorDir, editorName, editorId, allowedDocumentModelIds, isDragAndDropEnabled }) {
|
|
1404
|
-
const documentModelsDirPath = path$1.join(projectDir, "document-models");
|
|
1405
|
-
const documentModelsSourceFilesPath = path$1.join(documentModelsDirPath, "/**/*");
|
|
1406
|
-
const editorsDirPath = path$1.join(projectDir, "editors");
|
|
1407
|
-
const editorSourceFilesPath = path$1.join(editorsDirPath, "/**/*");
|
|
1408
|
-
const editorDirPath = path$1.join(editorsDirPath, editorDir);
|
|
1409
|
-
const editorComponentsDirPath = path$1.join(editorDirPath, "components");
|
|
1410
|
-
const project = buildTsMorphProject(projectDir);
|
|
1411
|
-
await ensureDirectoriesExist(project, documentModelsDirPath, editorsDirPath, editorDirPath, editorComponentsDirPath);
|
|
1412
|
-
project.addSourceFilesAtPaths(documentModelsSourceFilesPath);
|
|
1413
|
-
project.addSourceFilesAtPaths(editorSourceFilesPath);
|
|
1414
|
-
await makeNavigationBreadcrumbsFile({
|
|
1415
|
-
project,
|
|
1416
|
-
editorComponentsDirPath
|
|
1417
|
-
});
|
|
1418
|
-
await makeCreateDocumentFile({
|
|
1419
|
-
project,
|
|
1420
|
-
editorComponentsDirPath
|
|
1421
|
-
});
|
|
1422
|
-
await makeEmptyStateFile({
|
|
1423
|
-
project,
|
|
1424
|
-
editorComponentsDirPath
|
|
1425
|
-
});
|
|
1426
|
-
await makeFoldersFile({
|
|
1427
|
-
project,
|
|
1428
|
-
editorComponentsDirPath
|
|
1429
|
-
});
|
|
1430
|
-
await makeFolderTreeFile({
|
|
1431
|
-
project,
|
|
1432
|
-
editorComponentsDirPath
|
|
1433
|
-
});
|
|
1434
|
-
await makeFilesFile({
|
|
1435
|
-
project,
|
|
1436
|
-
editorComponentsDirPath
|
|
1437
|
-
});
|
|
1438
|
-
await makeDriveExplorerFile({
|
|
1439
|
-
project,
|
|
1440
|
-
editorComponentsDirPath
|
|
1441
|
-
});
|
|
1442
|
-
await makeDriveContentsFile({
|
|
1443
|
-
project,
|
|
1444
|
-
editorComponentsDirPath
|
|
1445
|
-
});
|
|
1446
|
-
await makeDriveEditorComponent({
|
|
1447
|
-
project,
|
|
1448
|
-
editorDirPath
|
|
1449
|
-
});
|
|
1450
|
-
await makeDriveEditorConfigFile({
|
|
1451
|
-
project,
|
|
1452
|
-
allowedDocumentModelIds,
|
|
1453
|
-
isDragAndDropEnabled,
|
|
1454
|
-
editorDirPath
|
|
1455
|
-
});
|
|
1456
|
-
makeEditorModuleFile({
|
|
1457
|
-
project,
|
|
1458
|
-
editorName,
|
|
1459
|
-
editorId,
|
|
1460
|
-
editorDirPath,
|
|
1461
|
-
documentModelId: "powerhouse/document-drive"
|
|
1462
|
-
});
|
|
1463
|
-
await makeEditorsModulesFile(project, projectDir);
|
|
1464
|
-
await project.save();
|
|
1465
|
-
}
|
|
1466
|
-
async function makeDriveEditorComponent({ project, editorDirPath }) {
|
|
1467
|
-
const { alreadyExists, sourceFile } = getOrCreateSourceFile(project, path$1.join(editorDirPath, "editor.tsx"));
|
|
1468
|
-
if (alreadyExists) {
|
|
1469
|
-
const editorFunction = sourceFile.getFunction("Editor");
|
|
1470
|
-
if (editorFunction) {
|
|
1471
|
-
if (!editorFunction.isDefaultExport()) editorFunction.setIsDefaultExport(true);
|
|
1472
|
-
return;
|
|
1473
|
-
}
|
|
1474
|
-
}
|
|
1475
|
-
const template = driveEditorEditorFileTemplate();
|
|
1476
|
-
sourceFile.replaceWithText(template);
|
|
1477
|
-
await formatSourceFileWithPrettier(sourceFile);
|
|
1478
|
-
}
|
|
1479
|
-
async function makeDriveEditorConfigFile({ project, editorDirPath, allowedDocumentModelIds, isDragAndDropEnabled }) {
|
|
1480
|
-
const { sourceFile } = getOrCreateSourceFile(project, path$1.join(editorDirPath, "config.ts"));
|
|
1481
|
-
const allowedDocumentTypesString = JSON.stringify(allowedDocumentModelIds);
|
|
1482
|
-
const template = driveEditorConfigFileTemplate({
|
|
1483
|
-
isDragAndDropEnabledString: isDragAndDropEnabled ? "true" : "false",
|
|
1484
|
-
allowedDocumentTypesString
|
|
1485
|
-
});
|
|
1486
|
-
sourceFile.replaceWithText(template);
|
|
1487
|
-
await formatSourceFileWithPrettier(sourceFile);
|
|
1488
|
-
}
|
|
1489
|
-
async function makeDriveContentsFile({ project, editorComponentsDirPath }) {
|
|
1490
|
-
const { alreadyExists, sourceFile } = getOrCreateSourceFile(project, path$1.join(editorComponentsDirPath, "DriveContents.tsx"));
|
|
1491
|
-
if (alreadyExists) return;
|
|
1492
|
-
const template = driveEditorDriveContentsFileTemplate();
|
|
1493
|
-
sourceFile.replaceWithText(template);
|
|
1494
|
-
await formatSourceFileWithPrettier(sourceFile);
|
|
1495
|
-
}
|
|
1496
|
-
async function makeNavigationBreadcrumbsFile({ project, editorComponentsDirPath }) {
|
|
1497
|
-
const { alreadyExists, sourceFile } = getOrCreateSourceFile(project, path$1.join(editorComponentsDirPath, "NavigationBreadcrumbs.tsx"));
|
|
1498
|
-
if (alreadyExists) return;
|
|
1499
|
-
sourceFile.replaceWithText(driveExplorerNavigationBreadcrumbsFileTemplate());
|
|
1500
|
-
await formatSourceFileWithPrettier(sourceFile);
|
|
1501
|
-
}
|
|
1502
|
-
async function makeFoldersFile({ project, editorComponentsDirPath }) {
|
|
1503
|
-
const { alreadyExists, sourceFile } = getOrCreateSourceFile(project, path$1.join(editorComponentsDirPath, "Folders.tsx"));
|
|
1504
|
-
if (alreadyExists) return;
|
|
1505
|
-
const template = driveEditorFoldersFileTemplate();
|
|
1506
|
-
sourceFile.replaceWithText(template);
|
|
1507
|
-
await formatSourceFileWithPrettier(sourceFile);
|
|
1508
|
-
}
|
|
1509
|
-
async function makeFilesFile({ project, editorComponentsDirPath }) {
|
|
1510
|
-
const { alreadyExists, sourceFile } = getOrCreateSourceFile(project, path$1.join(editorComponentsDirPath, "Files.tsx"));
|
|
1511
|
-
if (alreadyExists) return;
|
|
1512
|
-
const template = driveEditorFilesFileTemplate();
|
|
1513
|
-
sourceFile.replaceWithText(template);
|
|
1514
|
-
await formatSourceFileWithPrettier(sourceFile);
|
|
1515
|
-
}
|
|
1516
|
-
async function makeDriveExplorerFile({ project, editorComponentsDirPath }) {
|
|
1517
|
-
const { alreadyExists, sourceFile } = getOrCreateSourceFile(project, path$1.join(editorComponentsDirPath, "DriveExplorer.tsx"));
|
|
1518
|
-
if (alreadyExists) return;
|
|
1519
|
-
sourceFile.replaceWithText(driveExplorerFileTemplate);
|
|
1520
|
-
await formatSourceFileWithPrettier(sourceFile);
|
|
1521
|
-
}
|
|
1522
|
-
async function makeFolderTreeFile({ project, editorComponentsDirPath }) {
|
|
1523
|
-
const { alreadyExists, sourceFile } = getOrCreateSourceFile(project, path$1.join(editorComponentsDirPath, "FolderTree.tsx"));
|
|
1524
|
-
if (alreadyExists) return;
|
|
1525
|
-
sourceFile.replaceWithText(folderTreeFileTemplate);
|
|
1526
|
-
await formatSourceFileWithPrettier(sourceFile);
|
|
1527
|
-
}
|
|
1528
|
-
async function makeEmptyStateFile({ project, editorComponentsDirPath }) {
|
|
1529
|
-
const { alreadyExists, sourceFile } = getOrCreateSourceFile(project, path$1.join(editorComponentsDirPath, "EmptyState.tsx"));
|
|
1530
|
-
if (alreadyExists) return;
|
|
1531
|
-
sourceFile.replaceWithText(emptyStateFileTemplate);
|
|
1532
|
-
await formatSourceFileWithPrettier(sourceFile);
|
|
1533
|
-
}
|
|
1534
|
-
async function makeCreateDocumentFile({ project, editorComponentsDirPath }) {
|
|
1535
|
-
const { alreadyExists, sourceFile } = getOrCreateSourceFile(project, path$1.join(editorComponentsDirPath, "CreateDocument.tsx"));
|
|
1536
|
-
if (alreadyExists) return;
|
|
1537
|
-
sourceFile.replaceWithText(createDocumentFileTemplate);
|
|
1538
|
-
await formatSourceFileWithPrettier(sourceFile);
|
|
1539
|
-
}
|
|
1540
|
-
//#endregion
|
|
1541
1537
|
//#region src/file-builders/subgraph.ts
|
|
1542
1538
|
async function tsMorphGenerateSubgraph(args) {
|
|
1543
|
-
const { subgraphsDir, subgraphName,
|
|
1539
|
+
const { subgraphsDir, subgraphName, documentModel } = args;
|
|
1544
1540
|
const project = new Project({
|
|
1545
1541
|
skipAddingFilesFromTsConfig: true,
|
|
1546
1542
|
skipLoadingLibFiles: true
|
|
@@ -1563,10 +1559,7 @@ async function tsMorphGenerateSubgraph(args) {
|
|
|
1563
1559
|
kebabCaseName
|
|
1564
1560
|
});
|
|
1565
1561
|
await makeBaseSubgraphLibFile(project, subgraphDir);
|
|
1566
|
-
if (documentModel !== null) await makeDocumentModelSubgraphFiles(project, subgraphDir,
|
|
1567
|
-
documentModel,
|
|
1568
|
-
packageName
|
|
1569
|
-
});
|
|
1562
|
+
if (documentModel !== null) await makeDocumentModelSubgraphFiles(project, subgraphDir, documentModel);
|
|
1570
1563
|
else await makeCustomSubgraphFiles(project, subgraphDir, {
|
|
1571
1564
|
pascalCaseName,
|
|
1572
1565
|
camelCaseName
|
|
@@ -1594,15 +1587,14 @@ async function makeCustomSubgraphFiles(project, dirPath, v) {
|
|
|
1594
1587
|
await formatSourceFileWithPrettier(resolvers.sourceFile);
|
|
1595
1588
|
}
|
|
1596
1589
|
}
|
|
1597
|
-
async function makeDocumentModelSubgraphFiles(project, dirPath,
|
|
1598
|
-
const { documentModel, packageName } = args;
|
|
1590
|
+
async function makeDocumentModelSubgraphFiles(project, dirPath, documentModel) {
|
|
1599
1591
|
const latestSpec = documentModel.specifications[documentModel.specifications.length - 1];
|
|
1600
1592
|
const documentType = documentModel.name;
|
|
1601
1593
|
const pascalCaseDocumentType = pascalCase(documentType);
|
|
1602
1594
|
const camelCaseDocumentType = camelCase(documentType);
|
|
1603
1595
|
const phDocumentTypeName = `${pascalCaseDocumentType}Document`;
|
|
1604
1596
|
const documentTypeVariableName = `${camelCaseDocumentType}DocumentType`;
|
|
1605
|
-
const documentModelDir =
|
|
1597
|
+
const documentModelDir = `document-models/${kebabCase(documentType)}`;
|
|
1606
1598
|
const stateSchema = latestSpec.state.global.schema;
|
|
1607
1599
|
const stateTypeNames = extractTypeNames(stateSchema);
|
|
1608
1600
|
const modules = latestSpec.modules.filter((m) => m.name !== null).map((m) => ({
|
|
@@ -1656,6 +1648,6 @@ async function makeSubgraphsIndexFile({ projectDir }) {
|
|
|
1656
1648
|
await project.save();
|
|
1657
1649
|
}
|
|
1658
1650
|
//#endregion
|
|
1659
|
-
export { tsMorphGenerateProcessor as C, scalarsValidation as S,
|
|
1651
|
+
export { tsMorphGenerateProcessor as C, scalarsValidation as S, makeEditorModuleFile as _, getCommandHelpInfo as a, generateTypesAndZodSchemasFromGraphql as b, writeCliDocsMarkdownFile as c, makeDocumentModelModulesFile as d, makeEditorsModulesFile as f, makeLegacyIndexFile as g, makeUpgradeManifestsFile as h, tsMorphGenerateDocumentEditor as i, buildBoilerplatePackageJson as l, makeUpgradeManifestsExport as m, tsMorphGenerateSubgraph as n, getCommandsHelpInfo as o, makeModulesFile as p, tsMorphGenerateDocumentModel as r, makeCliDocsFromHelp as s, makeSubgraphsIndexFile as t, tsMorphGenerateApp as u, generateDocumentModelZodSchemas as v, scalars as x, generateSchemas as y };
|
|
1660
1652
|
|
|
1661
|
-
//# sourceMappingURL=file-builders-
|
|
1653
|
+
//# sourceMappingURL=file-builders-DRzXbZTI.mjs.map
|