@powerhousedao/ph-cli 6.2.3-dev.72 → 6.2.3-dev.73
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 +3 -3
- package/dist/generate-app-hm6CJ_4O.mjs +72 -0
- package/dist/generate-app-hm6CJ_4O.mjs.map +1 -0
- package/dist/{generate-document-model-BfFIQ35q.mjs → generate-document-model-CiW13Vf7.mjs} +23 -9
- package/dist/generate-document-model-CiW13Vf7.mjs.map +1 -0
- package/dist/generate-editor-kTiUOmDW.mjs +64 -0
- package/dist/generate-editor-kTiUOmDW.mjs.map +1 -0
- package/dist/{generate-piece-QTt-ddt2.mjs → generate-piece-U3tP-Sex.mjs} +14 -6
- package/dist/generate-piece-U3tP-Sex.mjs.map +1 -0
- package/dist/{generate-processor-DBtTkgo5.mjs → generate-processor-B9Umgjy9.mjs} +18 -7
- package/dist/generate-processor-B9Umgjy9.mjs.map +1 -0
- package/dist/{generate-subgraph-CVlTo7qk.mjs → generate-subgraph-BeGR9Y_k.mjs} +21 -8
- package/dist/generate-subgraph-BeGR9Y_k.mjs.map +1 -0
- package/dist/module-dir-1avCXsBi.mjs +17 -0
- package/dist/module-dir-1avCXsBi.mjs.map +1 -0
- package/dist/{ph-cli-commands-DSAhaETu.mjs → ph-cli-commands-CpHLMDM3.mjs} +28 -23
- package/dist/ph-cli-commands-CpHLMDM3.mjs.map +1 -0
- package/dist/ph-cli-commands-rrEBvLx4.mjs +4 -0
- package/package.json +13 -13
- package/dist/generate-app-BTs1u-9l.mjs +0 -50
- package/dist/generate-app-BTs1u-9l.mjs.map +0 -1
- package/dist/generate-document-model-BfFIQ35q.mjs.map +0 -1
- package/dist/generate-editor-CW7Do69u.mjs +0 -50
- package/dist/generate-editor-CW7Do69u.mjs.map +0 -1
- package/dist/generate-piece-QTt-ddt2.mjs.map +0 -1
- package/dist/generate-processor-DBtTkgo5.mjs.map +0 -1
- package/dist/generate-subgraph-CVlTo7qk.mjs.map +0 -1
- package/dist/ph-cli-commands-DSAhaETu.mjs.map +0 -1
- package/dist/ph-cli-commands-d5XjMWW0.mjs +0 -4
package/dist/cli.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="d751098f-ddb0-5813-9f72-4bdc5e15a867")}catch(e){}}();
|
|
4
|
-
import { n as phCliCommands } from "./ph-cli-commands-
|
|
4
|
+
import { n as phCliCommands } from "./ph-cli-commands-CpHLMDM3.mjs";
|
|
5
5
|
import { t as isUniformRunnersEnabled } from "./feature-flags-xwqcHEWC.mjs";
|
|
6
6
|
import { initCliTelemetry } from "@powerhousedao/shared/clis/telemetry";
|
|
7
7
|
import { assertNodeVersion } from "@powerhousedao/shared/clis/utils";
|
|
@@ -10,7 +10,7 @@ import { phCliHelpCommands } from "@powerhousedao/shared/clis/args";
|
|
|
10
10
|
import { bold, yellow } from "colorette";
|
|
11
11
|
//#region src/get-version.ts
|
|
12
12
|
function getVersion() {
|
|
13
|
-
return "6.2.3-dev.
|
|
13
|
+
return "6.2.3-dev.73";
|
|
14
14
|
}
|
|
15
15
|
//#endregion
|
|
16
16
|
//#region src/utils/constants.ts
|
|
@@ -93,7 +93,7 @@ async function main() {
|
|
|
93
93
|
let args = process.argv.slice(2);
|
|
94
94
|
if (isUniformRunnersEnabled()) {
|
|
95
95
|
const { applyRunSugar } = await import("./run-sugar-Ns53R6lU.mjs");
|
|
96
|
-
const { phCliCommands } = await import("./ph-cli-commands-
|
|
96
|
+
const { phCliCommands } = await import("./ph-cli-commands-rrEBvLx4.mjs");
|
|
97
97
|
const sugar = applyRunSugar(args, new Set(Object.keys(phCliCommands)), process.cwd());
|
|
98
98
|
if (sugar.warning) console.warn(sugar.warning);
|
|
99
99
|
args = sugar.args;
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="598034cf-aa42-5189-8607-4625d64996ff")}catch(e){}}();
|
|
3
|
+
import { t as resolveModuleDirName } from "./module-dir-1avCXsBi.mjs";
|
|
4
|
+
import { existsSync } from "node:fs";
|
|
5
|
+
import { join } from "node:path";
|
|
6
|
+
import { generateAllApps, generateApp } from "@powerhousedao/codegen";
|
|
7
|
+
import { buildTsMorphProject, getAppMetadata, getEditorMetadata } from "@powerhousedao/codegen/utils";
|
|
8
|
+
import { extractAppDocuments, generateAppFromDocument, getDocument, saveSpec } from "@powerhousedao/vetra/codegen";
|
|
9
|
+
//#region src/services/generate-app.ts
|
|
10
|
+
const MODULE_FILE_EXPECTATION = "an EditorModule with string literals for config.id, config.name and documentTypes";
|
|
11
|
+
async function startGenerateApp(args, projectDir) {
|
|
12
|
+
const { name, allowedDocumentTypes = [], disableDragAndDrop, document, dir, all, extract, debug } = args;
|
|
13
|
+
if (debug) console.log({ args });
|
|
14
|
+
const project = buildTsMorphProject(projectDir);
|
|
15
|
+
if (extract) {
|
|
16
|
+
const docs = extractAppDocuments(project);
|
|
17
|
+
if (docs.length === 0) console.log("No drive apps found in editors/.");
|
|
18
|
+
for (const doc of docs) {
|
|
19
|
+
const path = await saveSpec(doc, projectDir);
|
|
20
|
+
console.log(`Wrote ${path}`);
|
|
21
|
+
}
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
if (all) {
|
|
25
|
+
const { apps, unreadableDirs } = await generateAllApps(project);
|
|
26
|
+
await project.save();
|
|
27
|
+
if (apps.length === 0 && unreadableDirs.length === 0) console.log("No drive apps found in editors/.");
|
|
28
|
+
for (const app of apps) console.log(`Regenerated app "${app.name}" in editors/${app.dirName}`);
|
|
29
|
+
for (const dirName of unreadableDirs) console.warn(`Skipped editors/${dirName}: expected its module.ts to export ${MODULE_FILE_EXPECTATION}. Kept the manifest's apps.`);
|
|
30
|
+
return;
|
|
31
|
+
} else if (document) {
|
|
32
|
+
const doc = await getDocument(document);
|
|
33
|
+
await generateAppFromDocument(doc, project);
|
|
34
|
+
} else if (name) await generateApp({
|
|
35
|
+
appName: name,
|
|
36
|
+
allowedDocumentTypes,
|
|
37
|
+
isDragAndDropEnabled: !disableDragAndDrop
|
|
38
|
+
}, project);
|
|
39
|
+
else if (dir) {
|
|
40
|
+
const appMetadata = getAppMetadata(project, resolveAppDirName(project, projectDir, dir));
|
|
41
|
+
if (!appMetadata) throw new Error(`Failed to get data for app in dir "${dir}"`);
|
|
42
|
+
const { name: appName, id: appId, dirName: appDirName, allowedDocumentTypes, isDragAndDropEnabled } = appMetadata;
|
|
43
|
+
await generateApp({
|
|
44
|
+
appName,
|
|
45
|
+
appId,
|
|
46
|
+
appDirName,
|
|
47
|
+
allowedDocumentTypes,
|
|
48
|
+
isDragAndDropEnabled
|
|
49
|
+
}, project);
|
|
50
|
+
await project.save();
|
|
51
|
+
console.log(`Regenerated app "${appName}" in editors/${appDirName}`);
|
|
52
|
+
return;
|
|
53
|
+
} else {
|
|
54
|
+
console.log("Please specify one of `name`, `document`, `dir`, `all`, or `extract`.");
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
await project.save();
|
|
58
|
+
}
|
|
59
|
+
/** The app directory that `--dir` names, checked to hold a drive app's module.ts */
|
|
60
|
+
function resolveAppDirName(project, projectDir, dir) {
|
|
61
|
+
const dirName = resolveModuleDirName(projectDir, "editors", dir, "my-app");
|
|
62
|
+
if (!existsSync(join(projectDir, "editors", dirName, "module.ts"))) throw new Error(`editors/${dirName} has no module.ts.`);
|
|
63
|
+
const editorMetadata = getEditorMetadata(project, dirName);
|
|
64
|
+
if (!editorMetadata) throw new Error(`Could not read editors/${dirName}/module.ts: expected ${MODULE_FILE_EXPECTATION}.`);
|
|
65
|
+
if (!editorMetadata.documentTypes.includes("powerhouse/document-drive")) throw new Error(`editors/${dirName} is a document editor, not a drive app: its documentTypes don't include "powerhouse/document-drive". Use \`ph-cli generate editor --dir ${dirName}\` instead.`);
|
|
66
|
+
return dirName;
|
|
67
|
+
}
|
|
68
|
+
//#endregion
|
|
69
|
+
export { startGenerateApp };
|
|
70
|
+
|
|
71
|
+
//# sourceMappingURL=generate-app-hm6CJ_4O.mjs.map
|
|
72
|
+
//# debugId=598034cf-aa42-5189-8607-4625d64996ff
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-app-hm6CJ_4O.mjs","sources":["../src/services/generate-app.ts"],"sourcesContent":["import { generateAllApps, generateApp } from \"@powerhousedao/codegen\";\nimport {\n buildTsMorphProject,\n getAppMetadata,\n getEditorMetadata,\n} from \"@powerhousedao/codegen/utils\";\nimport {\n extractAppDocuments,\n generateAppFromDocument,\n getDocument,\n saveSpec,\n} from \"@powerhousedao/vetra/codegen\";\nimport type { AppModuleDocument } from \"@powerhousedao/vetra/document-models/app-module\";\nimport { existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport type { GenerateAppArgs } from \"../types.js\";\nimport { resolveModuleDirName } from \"../utils/module-dir.js\";\n\nconst MODULE_FILE_EXPECTATION =\n \"an EditorModule with string literals for config.id, config.name and documentTypes\";\n\nexport async function startGenerateApp(\n args: GenerateAppArgs,\n projectDir: string,\n) {\n const {\n name,\n allowedDocumentTypes = [],\n disableDragAndDrop,\n document,\n dir,\n all,\n extract,\n debug,\n } = args;\n if (debug) {\n console.log({ args });\n }\n const project = buildTsMorphProject(projectDir);\n if (extract) {\n const docs = extractAppDocuments(project);\n if (docs.length === 0) {\n console.log(\"No drive apps found in editors/.\");\n }\n for (const doc of docs) {\n const path = await saveSpec(doc, projectDir);\n console.log(`Wrote ${path}`);\n }\n return;\n }\n if (all) {\n const { apps, unreadableDirs } = await generateAllApps(project);\n await project.save();\n if (apps.length === 0 && unreadableDirs.length === 0) {\n console.log(\"No drive apps found in editors/.\");\n }\n for (const app of apps) {\n console.log(`Regenerated app \"${app.name}\" in editors/${app.dirName}`);\n }\n for (const dirName of unreadableDirs) {\n console.warn(\n `Skipped editors/${dirName}: expected its module.ts to export ${MODULE_FILE_EXPECTATION}. Kept the manifest's apps.`,\n );\n }\n return;\n } else if (document) {\n const doc = (await getDocument(document)) as AppModuleDocument;\n await generateAppFromDocument(doc, project);\n } else if (name) {\n await generateApp(\n {\n appName: name,\n allowedDocumentTypes,\n isDragAndDropEnabled: !disableDragAndDrop,\n },\n project,\n );\n } else if (dir) {\n const appMetadata = getAppMetadata(\n project,\n resolveAppDirName(project, projectDir, dir),\n );\n if (!appMetadata) {\n throw new Error(`Failed to get data for app in dir \"${dir}\"`);\n }\n const {\n name: appName,\n id: appId,\n dirName: appDirName,\n allowedDocumentTypes,\n isDragAndDropEnabled,\n } = appMetadata;\n\n await generateApp(\n {\n appName,\n appId,\n appDirName,\n allowedDocumentTypes,\n isDragAndDropEnabled,\n },\n project,\n );\n await project.save();\n console.log(`Regenerated app \"${appName}\" in editors/${appDirName}`);\n return;\n } else {\n console.log(\n \"Please specify one of `name`, `document`, `dir`, `all`, or `extract`.\",\n );\n return;\n }\n await project.save();\n}\n\n/** The app directory that `--dir` names, checked to hold a drive app's module.ts */\nfunction resolveAppDirName(\n project: ReturnType<typeof buildTsMorphProject>,\n projectDir: string,\n dir: string,\n) {\n const dirName = resolveModuleDirName(projectDir, \"editors\", dir, \"my-app\");\n if (!existsSync(join(projectDir, \"editors\", dirName, \"module.ts\"))) {\n throw new Error(`editors/${dirName} has no module.ts.`);\n }\n const editorMetadata = getEditorMetadata(project, dirName);\n if (!editorMetadata) {\n throw new Error(\n `Could not read editors/${dirName}/module.ts: expected ${MODULE_FILE_EXPECTATION}.`,\n );\n }\n if (!editorMetadata.documentTypes.includes(\"powerhouse/document-drive\")) {\n throw new Error(\n `editors/${dirName} is a document editor, not a drive app: its documentTypes don't include \"powerhouse/document-drive\". Use \\`ph-cli generate editor --dir ${dirName}\\` instead.`,\n );\n }\n return dirName;\n}\n"],"names":[],"mappings":";;;;;;;;;AAkBA,MAAM,0BACJ;AAEF,eAAsB,iBACpB,MACA,YACA;CACA,MAAM,EACJ,MACA,uBAAuB,CAAC,GACxB,oBACA,UACA,KACA,KACA,SACA,UACE;CACJ,IAAI,OACF,QAAQ,IAAI,EAAE,KAAK,CAAC;CAEtB,MAAM,UAAU,oBAAoB,UAAU;CAC9C,IAAI,SAAS;EACX,MAAM,OAAO,oBAAoB,OAAO;EACxC,IAAI,KAAK,WAAW,GAClB,QAAQ,IAAI,kCAAkC;EAEhD,KAAK,MAAM,OAAO,MAAM;GACtB,MAAM,OAAO,MAAM,SAAS,KAAK,UAAU;GAC3C,QAAQ,IAAI,SAAS,MAAM;EAC7B;EACA;CACF;CACA,IAAI,KAAK;EACP,MAAM,EAAE,MAAM,mBAAmB,MAAM,gBAAgB,OAAO;EAC9D,MAAM,QAAQ,KAAK;EACnB,IAAI,KAAK,WAAW,KAAK,eAAe,WAAW,GACjD,QAAQ,IAAI,kCAAkC;EAEhD,KAAK,MAAM,OAAO,MAChB,QAAQ,IAAI,oBAAoB,IAAI,KAAK,eAAe,IAAI,SAAS;EAEvE,KAAK,MAAM,WAAW,gBACpB,QAAQ,KACN,mBAAmB,QAAQ,qCAAqC,wBAAwB,4BAC1F;EAEF;CACF,OAAO,IAAI,UAAU;EACnB,MAAM,MAAO,MAAM,YAAY,QAAQ;EACvC,MAAM,wBAAwB,KAAK,OAAO;CAC5C,OAAO,IAAI,MACT,MAAM,YACJ;EACE,SAAS;EACT;EACA,sBAAsB,CAAC;CACzB,GACA,OACF;MACK,IAAI,KAAK;EACd,MAAM,cAAc,eAClB,SACA,kBAAkB,SAAS,YAAY,GAAG,CAC5C;EACA,IAAI,CAAC,aACH,MAAM,IAAI,MAAM,sCAAsC,IAAI,EAAE;EAE9D,MAAM,EACJ,MAAM,SACN,IAAI,OACJ,SAAS,YACT,sBACA,yBACE;EAEJ,MAAM,YACJ;GACE;GACA;GACA;GACA;GACA;EACF,GACA,OACF;EACA,MAAM,QAAQ,KAAK;EACnB,QAAQ,IAAI,oBAAoB,QAAQ,eAAe,YAAY;EACnE;CACF,OAAO;EACL,QAAQ,IACN,uEACF;EACA;CACF;CACA,MAAM,QAAQ,KAAK;AACrB;;AAGA,SAAS,kBACP,SACA,YACA,KACA;CACA,MAAM,UAAU,qBAAqB,YAAY,WAAW,KAAK,QAAQ;CACzE,IAAI,CAAC,WAAW,KAAK,YAAY,WAAW,SAAS,WAAW,CAAC,GAC/D,MAAM,IAAI,MAAM,WAAW,QAAQ,mBAAmB;CAExD,MAAM,iBAAiB,kBAAkB,SAAS,OAAO;CACzD,IAAI,CAAC,gBACH,MAAM,IAAI,MACR,0BAA0B,QAAQ,uBAAuB,wBAAwB,EACnF;CAEF,IAAI,CAAC,eAAe,cAAc,SAAS,2BAA2B,GACpE,MAAM,IAAI,MACR,WAAW,QAAQ,0IAA0I,QAAQ,YACvK;CAEF,OAAO;AACT","debug_id":"598034cf-aa42-5189-8607-4625d64996ff"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="ed8e6868-4817-5728-b076-e0cac26aea80")}catch(e){}}();
|
|
3
3
|
import { t as warnSubgraphTypeConflicts } from "./warn-subgraph-type-conflicts-BOHBmThq.mjs";
|
|
4
|
-
import {
|
|
4
|
+
import { t as resolveModuleDirName } from "./module-dir-1avCXsBi.mjs";
|
|
5
|
+
import { existsSync } from "node:fs";
|
|
6
|
+
import { join } from "node:path";
|
|
5
7
|
import { generateAllDocumentModels, generateDocumentModel, loadDocumentModel } from "@powerhousedao/codegen";
|
|
6
8
|
import { buildTsMorphProject } from "@powerhousedao/codegen/utils";
|
|
7
9
|
import { extractDocumentModelDocuments, generateDocumentModelFromDocument, getDocument, saveSpec } from "@powerhousedao/vetra/codegen";
|
|
@@ -18,8 +20,15 @@ async function startGenerateDocumentModel(args, projectDir) {
|
|
|
18
20
|
}
|
|
19
21
|
return;
|
|
20
22
|
}
|
|
21
|
-
if (all)
|
|
22
|
-
|
|
23
|
+
if (all) {
|
|
24
|
+
const { documentModels, unreadableDirs } = await generateAllDocumentModels(project);
|
|
25
|
+
await project.save();
|
|
26
|
+
if (documentModels.length === 0 && unreadableDirs.length === 0) console.log("No document models found in document-models/.");
|
|
27
|
+
for (const { name } of documentModels) console.log(`Regenerated document model "${name}"`);
|
|
28
|
+
for (const dirName of unreadableDirs) console.warn(`Skipped document-models/${dirName}: expected a valid document model spec at document-models/${dirName}/${dirName}.json. Kept the manifest's document models.`);
|
|
29
|
+
await warnSubgraphTypeConflicts(projectDir);
|
|
30
|
+
return;
|
|
31
|
+
} else if (document) {
|
|
23
32
|
if (document.endsWith(".phd")) {
|
|
24
33
|
const doc = await getDocument(document);
|
|
25
34
|
await generateDocumentModelFromDocument(doc, project);
|
|
@@ -28,10 +37,15 @@ async function startGenerateDocumentModel(args, projectDir) {
|
|
|
28
37
|
await generateDocumentModel(state, project);
|
|
29
38
|
}
|
|
30
39
|
} else if (dir) {
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
|
|
40
|
+
const dirName = resolveModuleDirName(projectDir, "document-models", dir, "my-document-model");
|
|
41
|
+
const specPath = join(projectDir, "document-models", dirName, `${dirName}.json`);
|
|
42
|
+
if (!existsSync(specPath)) throw new Error(`document-models/${dirName} has no ${dirName}.json.`);
|
|
43
|
+
const state = await loadDocumentModel(specPath);
|
|
34
44
|
await generateDocumentModel(state, project);
|
|
45
|
+
await project.save();
|
|
46
|
+
console.log(`Regenerated document model "${state.name}" in document-models/${dirName}`);
|
|
47
|
+
await warnSubgraphTypeConflicts(projectDir);
|
|
48
|
+
return;
|
|
35
49
|
} else {
|
|
36
50
|
console.log("Please specify one of `document`, `dir`, `all`, or `extract`.");
|
|
37
51
|
return;
|
|
@@ -42,5 +56,5 @@ async function startGenerateDocumentModel(args, projectDir) {
|
|
|
42
56
|
//#endregion
|
|
43
57
|
export { startGenerateDocumentModel };
|
|
44
58
|
|
|
45
|
-
//# sourceMappingURL=generate-document-model-
|
|
46
|
-
//# debugId=
|
|
59
|
+
//# sourceMappingURL=generate-document-model-CiW13Vf7.mjs.map
|
|
60
|
+
//# debugId=ed8e6868-4817-5728-b076-e0cac26aea80
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-document-model-CiW13Vf7.mjs","sources":["../src/services/generate-document-model.ts"],"sourcesContent":["import {\n generateAllDocumentModels,\n generateDocumentModel,\n loadDocumentModel,\n} from \"@powerhousedao/codegen\";\nimport { buildTsMorphProject } from \"@powerhousedao/codegen/utils\";\nimport {\n extractDocumentModelDocuments,\n generateDocumentModelFromDocument,\n getDocument,\n saveSpec,\n} from \"@powerhousedao/vetra/codegen\";\nimport type { DocumentModelDocument } from \"@powerhousedao/shared/document-model\";\nimport { existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport type { GenerateDocumentModelArgs } from \"../types.js\";\nimport { resolveModuleDirName } from \"../utils/module-dir.js\";\nimport { warnSubgraphTypeConflicts } from \"../utils/warn-subgraph-type-conflicts.js\";\n\nexport async function startGenerateDocumentModel(\n args: GenerateDocumentModelArgs,\n projectDir: string,\n) {\n const { document, dir, all, extract, debug } = args;\n if (debug) {\n console.log({ args });\n }\n const project = buildTsMorphProject(projectDir);\n if (extract) {\n const docs = extractDocumentModelDocuments(project);\n for (const doc of docs) {\n const path = await saveSpec(doc, projectDir);\n console.log(`Wrote ${path}`);\n }\n return;\n }\n if (all) {\n const { documentModels, unreadableDirs } =\n await generateAllDocumentModels(project);\n await project.save();\n if (documentModels.length === 0 && unreadableDirs.length === 0) {\n console.log(\"No document models found in document-models/.\");\n }\n for (const { name } of documentModels) {\n console.log(`Regenerated document model \"${name}\"`);\n }\n for (const dirName of unreadableDirs) {\n console.warn(\n `Skipped document-models/${dirName}: expected a valid document model spec at document-models/${dirName}/${dirName}.json. Kept the manifest's document models.`,\n );\n }\n await warnSubgraphTypeConflicts(projectDir);\n return;\n } else if (document) {\n if (document.endsWith(\".phd\")) {\n const doc = (await getDocument(document)) as DocumentModelDocument;\n await generateDocumentModelFromDocument(doc, project);\n } else {\n const state = await loadDocumentModel(document);\n await generateDocumentModel(state, project);\n }\n } else if (dir) {\n const dirName = resolveModuleDirName(\n projectDir,\n \"document-models\",\n dir,\n \"my-document-model\",\n );\n const specPath = join(\n projectDir,\n \"document-models\",\n dirName,\n `${dirName}.json`,\n );\n if (!existsSync(specPath)) {\n throw new Error(`document-models/${dirName} has no ${dirName}.json.`);\n }\n const state = await loadDocumentModel(specPath);\n await generateDocumentModel(state, project);\n await project.save();\n console.log(\n `Regenerated document model \"${state.name}\" in document-models/${dirName}`,\n );\n await warnSubgraphTypeConflicts(projectDir);\n return;\n } else {\n console.log(\n \"Please specify one of `document`, `dir`, `all`, or `extract`.\",\n );\n return;\n }\n await project.save();\n await warnSubgraphTypeConflicts(projectDir);\n}\n"],"names":[],"mappings":";;;;;;;;;;AAmBA,eAAsB,2BACpB,MACA,YACA;CACA,MAAM,EAAE,UAAU,KAAK,KAAK,SAAS,UAAU;CAC/C,IAAI,OACF,QAAQ,IAAI,EAAE,KAAK,CAAC;CAEtB,MAAM,UAAU,oBAAoB,UAAU;CAC9C,IAAI,SAAS;EACX,MAAM,OAAO,8BAA8B,OAAO;EAClD,KAAK,MAAM,OAAO,MAAM;GACtB,MAAM,OAAO,MAAM,SAAS,KAAK,UAAU;GAC3C,QAAQ,IAAI,SAAS,MAAM;EAC7B;EACA;CACF;CACA,IAAI,KAAK;EACP,MAAM,EAAE,gBAAgB,mBACtB,MAAM,0BAA0B,OAAO;EACzC,MAAM,QAAQ,KAAK;EACnB,IAAI,eAAe,WAAW,KAAK,eAAe,WAAW,GAC3D,QAAQ,IAAI,+CAA+C;EAE7D,KAAK,MAAM,EAAE,UAAU,gBACrB,QAAQ,IAAI,+BAA+B,KAAK,EAAE;EAEpD,KAAK,MAAM,WAAW,gBACpB,QAAQ,KACN,2BAA2B,QAAQ,4DAA4D,QAAQ,GAAG,QAAQ,4CACpH;EAEF,MAAM,0BAA0B,UAAU;EAC1C;CACF,OAAO,IAAI,UAAU;EACnB,IAAI,SAAS,SAAS,MAAM,GAAG;GAC7B,MAAM,MAAO,MAAM,YAAY,QAAQ;GACvC,MAAM,kCAAkC,KAAK,OAAO;EACtD,OAAO;GACL,MAAM,QAAQ,MAAM,kBAAkB,QAAQ;GAC9C,MAAM,sBAAsB,OAAO,OAAO;EAC5C;CACF,OAAO,IAAI,KAAK;EACd,MAAM,UAAU,qBACd,YACA,mBACA,KACA,mBACF;EACA,MAAM,WAAW,KACf,YACA,mBACA,SACA,GAAG,QAAQ,MACb;EACA,IAAI,CAAC,WAAW,QAAQ,GACtB,MAAM,IAAI,MAAM,mBAAmB,QAAQ,UAAU,QAAQ,OAAO;EAEtE,MAAM,QAAQ,MAAM,kBAAkB,QAAQ;EAC9C,MAAM,sBAAsB,OAAO,OAAO;EAC1C,MAAM,QAAQ,KAAK;EACnB,QAAQ,IACN,+BAA+B,MAAM,KAAK,uBAAuB,SACnE;EACA,MAAM,0BAA0B,UAAU;EAC1C;CACF,OAAO;EACL,QAAQ,IACN,+DACF;EACA;CACF;CACA,MAAM,QAAQ,KAAK;CACnB,MAAM,0BAA0B,UAAU;AAC5C","debug_id":"ed8e6868-4817-5728-b076-e0cac26aea80"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="11ae2fde-9c6a-568f-8ad1-312bdab3f1d0")}catch(e){}}();
|
|
3
|
+
import { t as resolveModuleDirName } from "./module-dir-1avCXsBi.mjs";
|
|
4
|
+
import { existsSync } from "node:fs";
|
|
5
|
+
import { join } from "node:path";
|
|
6
|
+
import { generateAllEditors, generateEditor } from "@powerhousedao/codegen";
|
|
7
|
+
import { buildTsMorphProject, getEditorMetadata } from "@powerhousedao/codegen/utils";
|
|
8
|
+
import { extractEditorDocuments, generateEditorFromDocument, getDocument, saveSpec } from "@powerhousedao/vetra/codegen";
|
|
9
|
+
//#region src/services/generate-editor.ts
|
|
10
|
+
const MODULE_FILE_EXPECTATION = "an EditorModule with string literals for config.id, config.name and documentTypes";
|
|
11
|
+
async function startGenerateEditor(args, projectDir) {
|
|
12
|
+
const { name, documentType, document, dir, all, extract, debug } = args;
|
|
13
|
+
if (debug) console.log({ args });
|
|
14
|
+
const project = buildTsMorphProject(projectDir);
|
|
15
|
+
if (extract) {
|
|
16
|
+
const docs = extractEditorDocuments(project);
|
|
17
|
+
if (docs.length === 0) console.log("No document editors found in editors/.");
|
|
18
|
+
for (const doc of docs) {
|
|
19
|
+
const path = await saveSpec(doc, projectDir);
|
|
20
|
+
console.log(`Wrote ${path}`);
|
|
21
|
+
}
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
const report = [];
|
|
25
|
+
if (all) {
|
|
26
|
+
const { editors, unreadableDirs } = await generateAllEditors(project);
|
|
27
|
+
if (editors.length === 0 && unreadableDirs.length === 0) report.push("No document editors found in editors/.");
|
|
28
|
+
for (const editor of editors) report.push(`Regenerated editor "${editor.name}" in editors/${editor.dirName}`);
|
|
29
|
+
for (const dirName of unreadableDirs) console.warn(`Skipped editors/${dirName}: expected its module.ts to export ${MODULE_FILE_EXPECTATION}. Kept the manifest's editors.`);
|
|
30
|
+
} else if (document) {
|
|
31
|
+
const doc = await getDocument(document);
|
|
32
|
+
await generateEditorFromDocument(doc, project);
|
|
33
|
+
} else if (name) {
|
|
34
|
+
if (!documentType) throw new Error("Please specify a document type for the new editor to generate.");
|
|
35
|
+
await generateEditor({
|
|
36
|
+
editorName: name,
|
|
37
|
+
documentTypes: [documentType]
|
|
38
|
+
}, project);
|
|
39
|
+
} else if (dir) {
|
|
40
|
+
const dirName = resolveModuleDirName(projectDir, "editors", dir, "my-editor");
|
|
41
|
+
if (!existsSync(join(projectDir, "editors", dirName, "module.ts"))) throw new Error(`editors/${dirName} has no module.ts.`);
|
|
42
|
+
const editorArgs = getEditorMetadata(project, dirName);
|
|
43
|
+
if (!editorArgs) throw new Error(`Could not read editors/${dirName}/module.ts: expected ${MODULE_FILE_EXPECTATION}.`);
|
|
44
|
+
if (editorArgs.documentTypes.includes("powerhouse/document-drive")) throw new Error(`editors/${dirName} is a drive app, not a document editor. Use \`ph-cli generate app --dir ${dirName}\` instead.`);
|
|
45
|
+
const { name: editorName, id: editorId, dirName: editorDirName, documentTypes } = editorArgs;
|
|
46
|
+
await generateEditor({
|
|
47
|
+
editorName,
|
|
48
|
+
editorId,
|
|
49
|
+
editorDirName,
|
|
50
|
+
documentTypes
|
|
51
|
+
}, project);
|
|
52
|
+
report.push(`Regenerated editor "${editorName}" in editors/${editorDirName}`);
|
|
53
|
+
} else {
|
|
54
|
+
console.log("Please specify one of `name`, `document`, `dir`, `all`, or `extract`.");
|
|
55
|
+
return;
|
|
56
|
+
}
|
|
57
|
+
await project.save();
|
|
58
|
+
for (const line of report) console.log(line);
|
|
59
|
+
}
|
|
60
|
+
//#endregion
|
|
61
|
+
export { startGenerateEditor };
|
|
62
|
+
|
|
63
|
+
//# sourceMappingURL=generate-editor-kTiUOmDW.mjs.map
|
|
64
|
+
//# debugId=11ae2fde-9c6a-568f-8ad1-312bdab3f1d0
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-editor-kTiUOmDW.mjs","sources":["../src/services/generate-editor.ts"],"sourcesContent":["import { generateAllEditors, generateEditor } from \"@powerhousedao/codegen\";\nimport {\n buildTsMorphProject,\n getEditorMetadata,\n} from \"@powerhousedao/codegen/utils\";\nimport {\n extractEditorDocuments,\n generateEditorFromDocument,\n getDocument,\n saveSpec,\n} from \"@powerhousedao/vetra/codegen\";\nimport type { DocumentEditorDocument } from \"@powerhousedao/vetra/document-models/document-editor\";\nimport { existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport type { GenerateEditorArgs } from \"../types.js\";\nimport { resolveModuleDirName } from \"../utils/module-dir.js\";\n\nconst MODULE_FILE_EXPECTATION =\n \"an EditorModule with string literals for config.id, config.name and documentTypes\";\n\nexport async function startGenerateEditor(\n args: GenerateEditorArgs,\n projectDir: string,\n) {\n const { name, documentType, document, dir, all, extract, debug } = args;\n if (debug) {\n console.log({ args });\n }\n const project = buildTsMorphProject(projectDir);\n if (extract) {\n const docs = extractEditorDocuments(project);\n if (docs.length === 0) {\n console.log(\"No document editors found in editors/.\");\n }\n for (const doc of docs) {\n const path = await saveSpec(doc, projectDir);\n console.log(`Wrote ${path}`);\n }\n return;\n }\n const report: string[] = [];\n if (all) {\n const { editors, unreadableDirs } = await generateAllEditors(project);\n if (editors.length === 0 && unreadableDirs.length === 0) {\n report.push(\"No document editors found in editors/.\");\n }\n for (const editor of editors) {\n report.push(\n `Regenerated editor \"${editor.name}\" in editors/${editor.dirName}`,\n );\n }\n for (const dirName of unreadableDirs) {\n console.warn(\n `Skipped editors/${dirName}: expected its module.ts to export ${MODULE_FILE_EXPECTATION}. Kept the manifest's editors.`,\n );\n }\n } else if (document) {\n const doc = (await getDocument(document)) as DocumentEditorDocument;\n await generateEditorFromDocument(doc, project);\n } else if (name) {\n if (!documentType) {\n throw new Error(\n \"Please specify a document type for the new editor to generate.\",\n );\n }\n await generateEditor(\n { editorName: name, documentTypes: [documentType] },\n project,\n );\n } else if (dir) {\n const dirName = resolveModuleDirName(\n projectDir,\n \"editors\",\n dir,\n \"my-editor\",\n );\n if (!existsSync(join(projectDir, \"editors\", dirName, \"module.ts\"))) {\n throw new Error(`editors/${dirName} has no module.ts.`);\n }\n const editorArgs = getEditorMetadata(project, dirName);\n if (!editorArgs) {\n throw new Error(\n `Could not read editors/${dirName}/module.ts: expected ${MODULE_FILE_EXPECTATION}.`,\n );\n }\n if (editorArgs.documentTypes.includes(\"powerhouse/document-drive\")) {\n throw new Error(\n `editors/${dirName} is a drive app, not a document editor. Use \\`ph-cli generate app --dir ${dirName}\\` instead.`,\n );\n }\n const {\n name: editorName,\n id: editorId,\n dirName: editorDirName,\n documentTypes,\n } = editorArgs;\n await generateEditor(\n {\n editorName,\n editorId,\n editorDirName,\n documentTypes,\n },\n project,\n );\n report.push(\n `Regenerated editor \"${editorName}\" in editors/${editorDirName}`,\n );\n } else {\n console.log(\n \"Please specify one of `name`, `document`, `dir`, `all`, or `extract`.\",\n );\n return;\n }\n await project.save();\n for (const line of report) {\n console.log(line);\n }\n}\n"],"names":[],"mappings":";;;;;;;;;AAiBA,MAAM,0BACJ;AAEF,eAAsB,oBACpB,MACA,YACA;CACA,MAAM,EAAE,MAAM,cAAc,UAAU,KAAK,KAAK,SAAS,UAAU;CACnE,IAAI,OACF,QAAQ,IAAI,EAAE,KAAK,CAAC;CAEtB,MAAM,UAAU,oBAAoB,UAAU;CAC9C,IAAI,SAAS;EACX,MAAM,OAAO,uBAAuB,OAAO;EAC3C,IAAI,KAAK,WAAW,GAClB,QAAQ,IAAI,wCAAwC;EAEtD,KAAK,MAAM,OAAO,MAAM;GACtB,MAAM,OAAO,MAAM,SAAS,KAAK,UAAU;GAC3C,QAAQ,IAAI,SAAS,MAAM;EAC7B;EACA;CACF;CACA,MAAM,SAAmB,CAAC;CAC1B,IAAI,KAAK;EACP,MAAM,EAAE,SAAS,mBAAmB,MAAM,mBAAmB,OAAO;EACpE,IAAI,QAAQ,WAAW,KAAK,eAAe,WAAW,GACpD,OAAO,KAAK,wCAAwC;EAEtD,KAAK,MAAM,UAAU,SACnB,OAAO,KACL,uBAAuB,OAAO,KAAK,eAAe,OAAO,SAC3D;EAEF,KAAK,MAAM,WAAW,gBACpB,QAAQ,KACN,mBAAmB,QAAQ,qCAAqC,wBAAwB,+BAC1F;CAEJ,OAAO,IAAI,UAAU;EACnB,MAAM,MAAO,MAAM,YAAY,QAAQ;EACvC,MAAM,2BAA2B,KAAK,OAAO;CAC/C,OAAO,IAAI,MAAM;EACf,IAAI,CAAC,cACH,MAAM,IAAI,MACR,gEACF;EAEF,MAAM,eACJ;GAAE,YAAY;GAAM,eAAe,CAAC,YAAY;EAAE,GAClD,OACF;CACF,OAAO,IAAI,KAAK;EACd,MAAM,UAAU,qBACd,YACA,WACA,KACA,WACF;EACA,IAAI,CAAC,WAAW,KAAK,YAAY,WAAW,SAAS,WAAW,CAAC,GAC/D,MAAM,IAAI,MAAM,WAAW,QAAQ,mBAAmB;EAExD,MAAM,aAAa,kBAAkB,SAAS,OAAO;EACrD,IAAI,CAAC,YACH,MAAM,IAAI,MACR,0BAA0B,QAAQ,uBAAuB,wBAAwB,EACnF;EAEF,IAAI,WAAW,cAAc,SAAS,2BAA2B,GAC/D,MAAM,IAAI,MACR,WAAW,QAAQ,0EAA0E,QAAQ,YACvG;EAEF,MAAM,EACJ,MAAM,YACN,IAAI,UACJ,SAAS,eACT,kBACE;EACJ,MAAM,eACJ;GACE;GACA;GACA;GACA;EACF,GACA,OACF;EACA,OAAO,KACL,uBAAuB,WAAW,eAAe,eACnD;CACF,OAAO;EACL,QAAQ,IACN,uEACF;EACA;CACF;CACA,MAAM,QAAQ,KAAK;CACnB,KAAK,MAAM,QAAQ,QACjB,QAAQ,IAAI,IAAI;AAEpB","debug_id":"11ae2fde-9c6a-568f-8ad1-312bdab3f1d0"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="1aba504c-2944-592a-becb-44b39f8dac04")}catch(e){}}();
|
|
3
3
|
import { t as installAddedDependencies } from "./install-added-dependencies-DVSbzler.mjs";
|
|
4
|
-
import {
|
|
4
|
+
import { t as resolveModuleDirName } from "./module-dir-1avCXsBi.mjs";
|
|
5
|
+
import { existsSync } from "node:fs";
|
|
6
|
+
import { join } from "node:path";
|
|
5
7
|
import { readPackage } from "read-pkg";
|
|
6
8
|
import { detectFeatures, generateAllPieces, generatePiece, syncFeatureDependencies } from "@powerhousedao/codegen";
|
|
7
9
|
import { buildTsMorphProject, readPiecesList } from "@powerhousedao/codegen/utils";
|
|
@@ -35,9 +37,14 @@ async function startGeneratePiece(args, projectDir) {
|
|
|
35
37
|
if (debug) console.log({ args });
|
|
36
38
|
const project = buildTsMorphProject(projectDir);
|
|
37
39
|
const name = namePositional ?? nameOption;
|
|
40
|
+
const report = [];
|
|
38
41
|
if (all) await generateAllPieces(project);
|
|
39
|
-
else if (dir)
|
|
40
|
-
|
|
42
|
+
else if (dir) {
|
|
43
|
+
const dirName = resolveModuleDirName(projectDir, "pieces", dir, "my-piece");
|
|
44
|
+
if (!existsSync(join(projectDir, "pieces", dirName, "index.ts"))) throw new Error(`pieces/${dirName} has no index.ts.`);
|
|
45
|
+
await generateAllPieces(project, dirName);
|
|
46
|
+
report.push(`Re-registered the piece in pieces/${dirName}`);
|
|
47
|
+
} else if (name) {
|
|
41
48
|
const pieceId = await resolvePieceId({
|
|
42
49
|
project,
|
|
43
50
|
projectDir,
|
|
@@ -55,11 +62,12 @@ async function startGeneratePiece(args, projectDir) {
|
|
|
55
62
|
return;
|
|
56
63
|
}
|
|
57
64
|
await project.save();
|
|
65
|
+
for (const line of report) console.log(line);
|
|
58
66
|
const added = await syncFeatureDependencies(detectFeatures(projectDir), projectDir);
|
|
59
67
|
await installAddedDependencies(added, projectDir, args.skipInstall);
|
|
60
68
|
}
|
|
61
69
|
//#endregion
|
|
62
70
|
export { startGeneratePiece };
|
|
63
71
|
|
|
64
|
-
//# sourceMappingURL=generate-piece-
|
|
65
|
-
//# debugId=
|
|
72
|
+
//# sourceMappingURL=generate-piece-U3tP-Sex.mjs.map
|
|
73
|
+
//# debugId=1aba504c-2944-592a-becb-44b39f8dac04
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-piece-U3tP-Sex.mjs","sources":["../src/services/generate-piece.ts"],"sourcesContent":["import {\n detectFeatures,\n generateAllPieces,\n generatePiece,\n syncFeatureDependencies,\n} from \"@powerhousedao/codegen\";\nimport { derivePieceId } from \"@powerhousedao/codegen/name-builders\";\nimport {\n buildTsMorphProject,\n readPiecesList,\n} from \"@powerhousedao/codegen/utils\";\nimport { kebabCase } from \"change-case\";\nimport enquirer from \"enquirer\";\nimport { existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { readPackage } from \"read-pkg\";\nimport type { Project } from \"ts-morph\";\nimport type { GeneratePieceArgs } from \"../types.js\";\nimport { installAddedDependencies } from \"../utils/install-added-dependencies.js\";\nimport { resolveModuleDirName } from \"../utils/module-dir.js\";\n\n// The id a block type will name, asked for only where deriving one would claim\n// a namespace nobody owns; CI, with no TTY, takes the derived value.\nasync function resolvePieceId(v: {\n project: Project;\n projectDir: string;\n pieceName: string;\n id?: string;\n}): Promise<string> {\n if (v.id) return v.id;\n const pkg = await readPackage({ cwd: v.projectDir, normalize: false });\n const { id, needsConfirmation } = derivePieceId({\n packageName: pkg.name ?? \"\",\n slug: kebabCase(v.pieceName),\n hasOtherPieces: readPiecesList(v.project).length > 0,\n });\n if (!needsConfirmation || !process.stdin.isTTY) return id;\n const { prompt } = enquirer;\n const result = await prompt<{ pieceId: string }>([\n {\n type: \"input\",\n name: \"pieceId\",\n message:\n \"What id should this piece have? A workflow step names it as its pieceName.\",\n initial: id,\n required: true,\n },\n ]);\n return result.pieceId || id;\n}\n\nexport async function startGeneratePiece(\n args: GeneratePieceArgs,\n projectDir: string,\n) {\n const {\n namePositional,\n name: nameOption,\n id,\n auth,\n description,\n dir,\n all,\n debug,\n } = args;\n if (debug) {\n console.log({ args });\n }\n const project = buildTsMorphProject(projectDir);\n const name = namePositional ?? nameOption;\n const report: string[] = [];\n if (all) {\n await generateAllPieces(project);\n } else if (dir) {\n const dirName = resolveModuleDirName(projectDir, \"pieces\", dir, \"my-piece\");\n if (!existsSync(join(projectDir, \"pieces\", dirName, \"index.ts\"))) {\n throw new Error(`pieces/${dirName} has no index.ts.`);\n }\n await generateAllPieces(project, dirName);\n report.push(`Re-registered the piece in pieces/${dirName}`);\n } else if (name) {\n const pieceId = await resolvePieceId({\n project,\n projectDir,\n pieceName: name,\n id,\n });\n await generatePiece(\n { pieceName: name, pieceId, auth, description },\n project,\n );\n } else {\n console.log(\"Please specify one of `name`, `dir`, or `all`.\");\n return;\n }\n await project.save();\n for (const line of report) {\n console.log(line);\n }\n const added = await syncFeatureDependencies(\n detectFeatures(projectDir),\n projectDir,\n );\n await installAddedDependencies(added, projectDir, args.skipInstall);\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;AAuBA,eAAe,eAAe,GAKV;CAClB,IAAI,EAAE,IAAI,OAAO,EAAE;CACnB,MAAM,MAAM,MAAM,YAAY;EAAE,KAAK,EAAE;EAAY,WAAW;CAAM,CAAC;CACrE,MAAM,EAAE,IAAI,sBAAsB,cAAc;EAC9C,aAAa,IAAI,QAAQ;EACzB,MAAM,UAAU,EAAE,SAAS;EAC3B,gBAAgB,eAAe,EAAE,OAAO,CAAC,CAAC,SAAS;CACrD,CAAC;CACD,IAAI,CAAC,qBAAqB,CAAC,QAAQ,MAAM,OAAO,OAAO;CACvD,MAAM,EAAE,WAAW;CAWnB,QAAO,MAVc,OAA4B,CAC/C;EACE,MAAM;EACN,MAAM;EACN,SACE;EACF,SAAS;EACT,UAAU;CACZ,CACF,CAAC,EAAA,CACa,WAAW;AAC3B;AAEA,eAAsB,mBACpB,MACA,YACA;CACA,MAAM,EACJ,gBACA,MAAM,YACN,IACA,MACA,aACA,KACA,KACA,UACE;CACJ,IAAI,OACF,QAAQ,IAAI,EAAE,KAAK,CAAC;CAEtB,MAAM,UAAU,oBAAoB,UAAU;CAC9C,MAAM,OAAO,kBAAkB;CAC/B,MAAM,SAAmB,CAAC;CAC1B,IAAI,KACF,MAAM,kBAAkB,OAAO;MAC1B,IAAI,KAAK;EACd,MAAM,UAAU,qBAAqB,YAAY,UAAU,KAAK,UAAU;EAC1E,IAAI,CAAC,WAAW,KAAK,YAAY,UAAU,SAAS,UAAU,CAAC,GAC7D,MAAM,IAAI,MAAM,UAAU,QAAQ,kBAAkB;EAEtD,MAAM,kBAAkB,SAAS,OAAO;EACxC,OAAO,KAAK,qCAAqC,SAAS;CAC5D,OAAO,IAAI,MAAM;EACf,MAAM,UAAU,MAAM,eAAe;GACnC;GACA;GACA,WAAW;GACX;EACF,CAAC;EACD,MAAM,cACJ;GAAE,WAAW;GAAM;GAAS;GAAM;EAAY,GAC9C,OACF;CACF,OAAO;EACL,QAAQ,IAAI,gDAAgD;EAC5D;CACF;CACA,MAAM,QAAQ,KAAK;CACnB,KAAK,MAAM,QAAQ,QACjB,QAAQ,IAAI,IAAI;CAElB,MAAM,QAAQ,MAAM,wBAClB,eAAe,UAAU,GACzB,UACF;CACA,MAAM,yBAAyB,OAAO,YAAY,KAAK,WAAW;AACpE","debug_id":"1aba504c-2944-592a-becb-44b39f8dac04"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="270c8100-4562-54e0-9f31-7c40fbc0e5cf")}catch(e){}}();
|
|
3
3
|
import { t as installAddedDependencies } from "./install-added-dependencies-DVSbzler.mjs";
|
|
4
|
-
import {
|
|
4
|
+
import { t as resolveModuleDirName } from "./module-dir-1avCXsBi.mjs";
|
|
5
|
+
import { existsSync } from "node:fs";
|
|
6
|
+
import { join } from "node:path";
|
|
5
7
|
import { detectFeatures, generateAllProcessors, generateProcessor, syncFeatureDependencies } from "@powerhousedao/codegen";
|
|
6
8
|
import { buildTsMorphProject, getProcessorMetadata } from "@powerhousedao/codegen/utils";
|
|
7
9
|
import { extractProcessorDocuments, generateProcessorFromDocument, getDocument, saveSpec } from "@powerhousedao/vetra/codegen";
|
|
@@ -12,14 +14,19 @@ async function startGenerateProcessor(args, projectDir) {
|
|
|
12
14
|
const project = buildTsMorphProject(projectDir);
|
|
13
15
|
if (extract) {
|
|
14
16
|
const docs = extractProcessorDocuments(project);
|
|
17
|
+
if (docs.length === 0) console.log("No processors found in processors/.");
|
|
15
18
|
for (const doc of docs) {
|
|
16
19
|
const path = await saveSpec(doc, projectDir);
|
|
17
20
|
console.log(`Wrote ${path}`);
|
|
18
21
|
}
|
|
19
22
|
return;
|
|
20
23
|
}
|
|
21
|
-
|
|
22
|
-
|
|
24
|
+
const report = [];
|
|
25
|
+
if (all) {
|
|
26
|
+
const processors = await generateAllProcessors(project);
|
|
27
|
+
if (processors.length === 0) report.push("No processors found in processors/.");
|
|
28
|
+
for (const { processorName } of processors) report.push(`Regenerated processor in processors/${processorName}`);
|
|
29
|
+
} else if (document) {
|
|
23
30
|
const doc = await getDocument(document);
|
|
24
31
|
await generateProcessorFromDocument(doc, project);
|
|
25
32
|
} else if (processorName) await generateProcessor({
|
|
@@ -29,19 +36,23 @@ async function startGenerateProcessor(args, projectDir) {
|
|
|
29
36
|
documentTypes
|
|
30
37
|
}, project);
|
|
31
38
|
else if (dir) {
|
|
32
|
-
const processorDirName =
|
|
39
|
+
const processorDirName = resolveModuleDirName(projectDir, "processors", dir, "my-processor");
|
|
40
|
+
const processorDir = join(projectDir, "processors", processorDirName);
|
|
41
|
+
if (!["processor.ts", "index.ts"].some((file) => existsSync(join(processorDir, file)))) throw new Error(`processors/${processorDirName} has no processor.ts or index.ts.`);
|
|
33
42
|
const processorArgs = getProcessorMetadata(project, processorDirName);
|
|
34
43
|
await generateProcessor(processorArgs, project);
|
|
44
|
+
report.push(`Regenerated processor in processors/${processorDirName}`);
|
|
35
45
|
} else {
|
|
36
46
|
console.log("Please specify one of `name`, `document`, `dir`, `all`, or `extract`.");
|
|
37
47
|
return;
|
|
38
48
|
}
|
|
39
49
|
await project.save();
|
|
50
|
+
for (const line of report) console.log(line);
|
|
40
51
|
const added = await syncFeatureDependencies(detectFeatures(projectDir), projectDir);
|
|
41
52
|
await installAddedDependencies(added, projectDir, args.skipInstall);
|
|
42
53
|
}
|
|
43
54
|
//#endregion
|
|
44
55
|
export { startGenerateProcessor };
|
|
45
56
|
|
|
46
|
-
//# sourceMappingURL=generate-processor-
|
|
47
|
-
//# debugId=
|
|
57
|
+
//# sourceMappingURL=generate-processor-B9Umgjy9.mjs.map
|
|
58
|
+
//# debugId=270c8100-4562-54e0-9f31-7c40fbc0e5cf
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-processor-B9Umgjy9.mjs","sources":["../src/services/generate-processor.ts"],"sourcesContent":["import {\n detectFeatures,\n generateAllProcessors,\n generateProcessor,\n syncFeatureDependencies,\n} from \"@powerhousedao/codegen\";\nimport {\n buildTsMorphProject,\n getProcessorMetadata,\n} from \"@powerhousedao/codegen/utils\";\nimport {\n extractProcessorDocuments,\n generateProcessorFromDocument,\n getDocument,\n saveSpec,\n} from \"@powerhousedao/vetra/codegen\";\nimport type { ProcessorModuleDocument } from \"@powerhousedao/vetra/document-models/processor-module\";\nimport { existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport type { GenerateProcessorArgs } from \"../types.js\";\nimport { installAddedDependencies } from \"../utils/install-added-dependencies.js\";\nimport { resolveModuleDirName } from \"../utils/module-dir.js\";\n\nexport async function startGenerateProcessor(\n args: GenerateProcessorArgs,\n projectDir: string,\n) {\n const {\n name: processorName,\n type: processorType,\n apps: processorApps,\n documentTypes,\n document,\n dir,\n all,\n extract,\n debug,\n } = args;\n if (debug) {\n console.log({ args });\n }\n const project = buildTsMorphProject(projectDir);\n if (extract) {\n const docs = extractProcessorDocuments(project);\n if (docs.length === 0) {\n console.log(\"No processors found in processors/.\");\n }\n for (const doc of docs) {\n const path = await saveSpec(doc, projectDir);\n console.log(`Wrote ${path}`);\n }\n return;\n }\n const report: string[] = [];\n if (all) {\n const processors = await generateAllProcessors(project);\n if (processors.length === 0) {\n report.push(\"No processors found in processors/.\");\n }\n for (const { processorName } of processors) {\n report.push(`Regenerated processor in processors/${processorName}`);\n }\n } else if (document) {\n const doc = (await getDocument(document)) as ProcessorModuleDocument;\n await generateProcessorFromDocument(doc, project);\n } else if (processorName) {\n await generateProcessor(\n {\n processorName,\n processorApps,\n processorType,\n documentTypes,\n },\n project,\n );\n } else if (dir) {\n const processorDirName = resolveModuleDirName(\n projectDir,\n \"processors\",\n dir,\n \"my-processor\",\n );\n const processorDir = join(projectDir, \"processors\", processorDirName);\n if (\n ![\"processor.ts\", \"index.ts\"].some((file) =>\n existsSync(join(processorDir, file)),\n )\n ) {\n throw new Error(\n `processors/${processorDirName} has no processor.ts or index.ts.`,\n );\n }\n const processorArgs = getProcessorMetadata(project, processorDirName);\n await generateProcessor(processorArgs, project);\n report.push(`Regenerated processor in processors/${processorDirName}`);\n } else {\n console.log(\n \"Please specify one of `name`, `document`, `dir`, `all`, or `extract`.\",\n );\n return;\n }\n await project.save();\n for (const line of report) {\n console.log(line);\n }\n const added = await syncFeatureDependencies(\n detectFeatures(projectDir),\n projectDir,\n );\n await installAddedDependencies(added, projectDir, args.skipInstall);\n}\n"],"names":[],"mappings":";;;;;;;;;;AAuBA,eAAsB,uBACpB,MACA,YACA;CACA,MAAM,EACJ,MAAM,eACN,MAAM,eACN,MAAM,eACN,eACA,UACA,KACA,KACA,SACA,UACE;CACJ,IAAI,OACF,QAAQ,IAAI,EAAE,KAAK,CAAC;CAEtB,MAAM,UAAU,oBAAoB,UAAU;CAC9C,IAAI,SAAS;EACX,MAAM,OAAO,0BAA0B,OAAO;EAC9C,IAAI,KAAK,WAAW,GAClB,QAAQ,IAAI,qCAAqC;EAEnD,KAAK,MAAM,OAAO,MAAM;GACtB,MAAM,OAAO,MAAM,SAAS,KAAK,UAAU;GAC3C,QAAQ,IAAI,SAAS,MAAM;EAC7B;EACA;CACF;CACA,MAAM,SAAmB,CAAC;CAC1B,IAAI,KAAK;EACP,MAAM,aAAa,MAAM,sBAAsB,OAAO;EACtD,IAAI,WAAW,WAAW,GACxB,OAAO,KAAK,qCAAqC;EAEnD,KAAK,MAAM,EAAE,mBAAmB,YAC9B,OAAO,KAAK,uCAAuC,eAAe;CAEtE,OAAO,IAAI,UAAU;EACnB,MAAM,MAAO,MAAM,YAAY,QAAQ;EACvC,MAAM,8BAA8B,KAAK,OAAO;CAClD,OAAO,IAAI,eACT,MAAM,kBACJ;EACE;EACA;EACA;EACA;CACF,GACA,OACF;MACK,IAAI,KAAK;EACd,MAAM,mBAAmB,qBACvB,YACA,cACA,KACA,cACF;EACA,MAAM,eAAe,KAAK,YAAY,cAAc,gBAAgB;EACpE,IACE,CAAC,CAAC,gBAAgB,UAAU,CAAC,CAAC,MAAM,SAClC,WAAW,KAAK,cAAc,IAAI,CAAC,CACrC,GAEA,MAAM,IAAI,MACR,cAAc,iBAAiB,kCACjC;EAEF,MAAM,gBAAgB,qBAAqB,SAAS,gBAAgB;EACpE,MAAM,kBAAkB,eAAe,OAAO;EAC9C,OAAO,KAAK,uCAAuC,kBAAkB;CACvE,OAAO;EACL,QAAQ,IACN,uEACF;EACA;CACF;CACA,MAAM,QAAQ,KAAK;CACnB,KAAK,MAAM,QAAQ,QACjB,QAAQ,IAAI,IAAI;CAElB,MAAM,QAAQ,MAAM,wBAClB,eAAe,UAAU,GACzB,UACF;CACA,MAAM,yBAAyB,OAAO,YAAY,KAAK,WAAW;AACpE","debug_id":"270c8100-4562-54e0-9f31-7c40fbc0e5cf"}
|
|
@@ -1,38 +1,51 @@
|
|
|
1
1
|
|
|
2
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="e75ebbd3-fa30-5c62-9b7a-7953917922a7")}catch(e){}}();
|
|
3
3
|
import { t as installAddedDependencies } from "./install-added-dependencies-DVSbzler.mjs";
|
|
4
4
|
import { t as warnSubgraphTypeConflicts } from "./warn-subgraph-type-conflicts-BOHBmThq.mjs";
|
|
5
|
-
import {
|
|
5
|
+
import { t as resolveModuleDirName } from "./module-dir-1avCXsBi.mjs";
|
|
6
|
+
import { existsSync } from "node:fs";
|
|
7
|
+
import { join } from "node:path";
|
|
6
8
|
import { detectFeatures, generateAllSubgraphs, generateSubgraph, syncFeatureDependencies } from "@powerhousedao/codegen";
|
|
7
9
|
import { buildTsMorphProject, getSubgraphMetadata } from "@powerhousedao/codegen/utils";
|
|
8
10
|
import { extractSubgraphDocuments, generateSubgraphFromDocument, getDocument, saveSpec } from "@powerhousedao/vetra/codegen";
|
|
9
11
|
//#region src/services/generate-subgraph.ts
|
|
12
|
+
const INDEX_FILE_EXPECTATION = "a class extending BaseSubgraph with a string literal `name`";
|
|
10
13
|
async function startGenerateSubgraph(args, projectDir) {
|
|
11
14
|
const { name, document, dir, all, extract, debug } = args;
|
|
12
15
|
if (debug) console.log({ args });
|
|
13
16
|
const project = buildTsMorphProject(projectDir);
|
|
14
17
|
if (extract) {
|
|
15
18
|
const docs = extractSubgraphDocuments(project);
|
|
19
|
+
if (docs.length === 0) console.log("No subgraphs found in subgraphs/.");
|
|
16
20
|
for (const doc of docs) {
|
|
17
21
|
const path = await saveSpec(doc, projectDir);
|
|
18
22
|
console.log(`Wrote ${path}`);
|
|
19
23
|
}
|
|
20
24
|
return;
|
|
21
25
|
}
|
|
22
|
-
|
|
23
|
-
|
|
26
|
+
const report = [];
|
|
27
|
+
if (all) {
|
|
28
|
+
const { subgraphNames, unreadableDirs } = await generateAllSubgraphs(project);
|
|
29
|
+
if (subgraphNames.length === 0 && unreadableDirs.length === 0) report.push("No subgraphs found in subgraphs/.");
|
|
30
|
+
for (const subgraphName of subgraphNames) report.push(`Regenerated subgraph "${subgraphName}"`);
|
|
31
|
+
for (const dirName of unreadableDirs) console.warn(`Skipped subgraphs/${dirName}: expected its index.ts to export ${INDEX_FILE_EXPECTATION}. Kept the manifest's subgraphs.`);
|
|
32
|
+
} else if (document) {
|
|
24
33
|
const doc = await getDocument(document);
|
|
25
34
|
await generateSubgraphFromDocument(doc, project);
|
|
26
35
|
} else if (name) await generateSubgraph(name, project);
|
|
27
36
|
else if (dir) {
|
|
28
|
-
const
|
|
29
|
-
if (!
|
|
37
|
+
const dirName = resolveModuleDirName(projectDir, "subgraphs", dir, "my-subgraph");
|
|
38
|
+
if (!existsSync(join(projectDir, "subgraphs", dirName, "index.ts"))) throw new Error(`subgraphs/${dirName} has no index.ts.`);
|
|
39
|
+
const { subgraphName } = getSubgraphMetadata(project, dirName);
|
|
40
|
+
if (!subgraphName) throw new Error(`Could not read subgraphs/${dirName}/index.ts: expected ${INDEX_FILE_EXPECTATION}.`);
|
|
30
41
|
await generateSubgraph(subgraphName, project);
|
|
42
|
+
report.push(`Regenerated subgraph "${subgraphName}"`);
|
|
31
43
|
} else {
|
|
32
44
|
console.log("Please specify one of `name`, `document`, `dir`, `all`, or `extract`.");
|
|
33
45
|
return;
|
|
34
46
|
}
|
|
35
47
|
await project.save();
|
|
48
|
+
for (const line of report) console.log(line);
|
|
36
49
|
await warnSubgraphTypeConflicts(projectDir);
|
|
37
50
|
const added = await syncFeatureDependencies(detectFeatures(projectDir), projectDir);
|
|
38
51
|
await installAddedDependencies(added, projectDir, args.skipInstall);
|
|
@@ -40,5 +53,5 @@ async function startGenerateSubgraph(args, projectDir) {
|
|
|
40
53
|
//#endregion
|
|
41
54
|
export { startGenerateSubgraph };
|
|
42
55
|
|
|
43
|
-
//# sourceMappingURL=generate-subgraph-
|
|
44
|
-
//# debugId=
|
|
56
|
+
//# sourceMappingURL=generate-subgraph-BeGR9Y_k.mjs.map
|
|
57
|
+
//# debugId=e75ebbd3-fa30-5c62-9b7a-7953917922a7
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-subgraph-BeGR9Y_k.mjs","sources":["../src/services/generate-subgraph.ts"],"sourcesContent":["import {\n detectFeatures,\n generateAllSubgraphs,\n generateSubgraph,\n syncFeatureDependencies,\n} from \"@powerhousedao/codegen\";\nimport {\n buildTsMorphProject,\n getSubgraphMetadata,\n} from \"@powerhousedao/codegen/utils\";\nimport {\n extractSubgraphDocuments,\n generateSubgraphFromDocument,\n getDocument,\n saveSpec,\n} from \"@powerhousedao/vetra/codegen\";\nimport type { SubgraphModuleDocument } from \"@powerhousedao/vetra/document-models/subgraph-module\";\nimport { existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport type { GenerateSubgraphArgs } from \"../types.js\";\nimport { installAddedDependencies } from \"../utils/install-added-dependencies.js\";\nimport { resolveModuleDirName } from \"../utils/module-dir.js\";\nimport { warnSubgraphTypeConflicts } from \"../utils/warn-subgraph-type-conflicts.js\";\n\nconst INDEX_FILE_EXPECTATION =\n \"a class extending BaseSubgraph with a string literal `name`\";\n\nexport async function startGenerateSubgraph(\n args: GenerateSubgraphArgs,\n projectDir: string,\n) {\n const { name, document, dir, all, extract, debug } = args;\n if (debug) {\n console.log({ args });\n }\n const project = buildTsMorphProject(projectDir);\n if (extract) {\n const docs = extractSubgraphDocuments(project);\n if (docs.length === 0) {\n console.log(\"No subgraphs found in subgraphs/.\");\n }\n for (const doc of docs) {\n const path = await saveSpec(doc, projectDir);\n console.log(`Wrote ${path}`);\n }\n return;\n }\n const report: string[] = [];\n if (all) {\n const { subgraphNames, unreadableDirs } =\n await generateAllSubgraphs(project);\n if (subgraphNames.length === 0 && unreadableDirs.length === 0) {\n report.push(\"No subgraphs found in subgraphs/.\");\n }\n for (const subgraphName of subgraphNames) {\n report.push(`Regenerated subgraph \"${subgraphName}\"`);\n }\n for (const dirName of unreadableDirs) {\n console.warn(\n `Skipped subgraphs/${dirName}: expected its index.ts to export ${INDEX_FILE_EXPECTATION}. Kept the manifest's subgraphs.`,\n );\n }\n } else if (document) {\n const doc = (await getDocument(document)) as SubgraphModuleDocument;\n await generateSubgraphFromDocument(doc, project);\n } else if (name) {\n await generateSubgraph(name, project);\n } else if (dir) {\n const dirName = resolveModuleDirName(\n projectDir,\n \"subgraphs\",\n dir,\n \"my-subgraph\",\n );\n if (!existsSync(join(projectDir, \"subgraphs\", dirName, \"index.ts\"))) {\n throw new Error(`subgraphs/${dirName} has no index.ts.`);\n }\n const { subgraphName } = getSubgraphMetadata(project, dirName);\n if (!subgraphName) {\n throw new Error(\n `Could not read subgraphs/${dirName}/index.ts: expected ${INDEX_FILE_EXPECTATION}.`,\n );\n }\n await generateSubgraph(subgraphName, project);\n report.push(`Regenerated subgraph \"${subgraphName}\"`);\n } else {\n console.log(\n \"Please specify one of `name`, `document`, `dir`, `all`, or `extract`.\",\n );\n return;\n }\n await project.save();\n for (const line of report) {\n console.log(line);\n }\n await warnSubgraphTypeConflicts(projectDir);\n const added = await syncFeatureDependencies(\n detectFeatures(projectDir),\n projectDir,\n );\n await installAddedDependencies(added, projectDir, args.skipInstall);\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAwBA,MAAM,yBACJ;AAEF,eAAsB,sBACpB,MACA,YACA;CACA,MAAM,EAAE,MAAM,UAAU,KAAK,KAAK,SAAS,UAAU;CACrD,IAAI,OACF,QAAQ,IAAI,EAAE,KAAK,CAAC;CAEtB,MAAM,UAAU,oBAAoB,UAAU;CAC9C,IAAI,SAAS;EACX,MAAM,OAAO,yBAAyB,OAAO;EAC7C,IAAI,KAAK,WAAW,GAClB,QAAQ,IAAI,mCAAmC;EAEjD,KAAK,MAAM,OAAO,MAAM;GACtB,MAAM,OAAO,MAAM,SAAS,KAAK,UAAU;GAC3C,QAAQ,IAAI,SAAS,MAAM;EAC7B;EACA;CACF;CACA,MAAM,SAAmB,CAAC;CAC1B,IAAI,KAAK;EACP,MAAM,EAAE,eAAe,mBACrB,MAAM,qBAAqB,OAAO;EACpC,IAAI,cAAc,WAAW,KAAK,eAAe,WAAW,GAC1D,OAAO,KAAK,mCAAmC;EAEjD,KAAK,MAAM,gBAAgB,eACzB,OAAO,KAAK,yBAAyB,aAAa,EAAE;EAEtD,KAAK,MAAM,WAAW,gBACpB,QAAQ,KACN,qBAAqB,QAAQ,oCAAoC,uBAAuB,iCAC1F;CAEJ,OAAO,IAAI,UAAU;EACnB,MAAM,MAAO,MAAM,YAAY,QAAQ;EACvC,MAAM,6BAA6B,KAAK,OAAO;CACjD,OAAO,IAAI,MACT,MAAM,iBAAiB,MAAM,OAAO;MAC/B,IAAI,KAAK;EACd,MAAM,UAAU,qBACd,YACA,aACA,KACA,aACF;EACA,IAAI,CAAC,WAAW,KAAK,YAAY,aAAa,SAAS,UAAU,CAAC,GAChE,MAAM,IAAI,MAAM,aAAa,QAAQ,kBAAkB;EAEzD,MAAM,EAAE,iBAAiB,oBAAoB,SAAS,OAAO;EAC7D,IAAI,CAAC,cACH,MAAM,IAAI,MACR,4BAA4B,QAAQ,sBAAsB,uBAAuB,EACnF;EAEF,MAAM,iBAAiB,cAAc,OAAO;EAC5C,OAAO,KAAK,yBAAyB,aAAa,EAAE;CACtD,OAAO;EACL,QAAQ,IACN,uEACF;EACA;CACF;CACA,MAAM,QAAQ,KAAK;CACnB,KAAK,MAAM,QAAQ,QACjB,QAAQ,IAAI,IAAI;CAElB,MAAM,0BAA0B,UAAU;CAC1C,MAAM,QAAQ,MAAM,wBAClB,eAAe,UAAU,GACzB,UACF;CACA,MAAM,yBAAyB,OAAO,YAAY,KAAK,WAAW;AACpE","debug_id":"e75ebbd3-fa30-5c62-9b7a-7953917922a7"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
|
|
2
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="b019bb65-d519-5dd7-bf0e-4c90f1c91ce5")}catch(e){}}();
|
|
3
|
+
import { existsSync, statSync } from "node:fs";
|
|
4
|
+
import { basename, dirname, join, resolve } from "node:path";
|
|
5
|
+
//#region src/utils/module-dir.ts
|
|
6
|
+
/** The directory in `<modulesDir>/` that `--dir` names, by name or by a path to it or a file in it */
|
|
7
|
+
function resolveModuleDirName(projectDir, modulesDir, dir, example) {
|
|
8
|
+
const modulesPath = join(projectDir, modulesDir);
|
|
9
|
+
const moduleDir = [resolve(projectDir, dir), join(modulesPath, dir)].filter((candidate) => existsSync(candidate)).map((candidate) => statSync(candidate).isDirectory() ? candidate : dirname(candidate)).find((candidate) => dirname(candidate) === modulesPath);
|
|
10
|
+
if (!moduleDir) throw new Error(`No directory in ${modulesDir}/ for --dir "${dir}": expected its name ("${example}") or its path ("${modulesDir}/${example}").`);
|
|
11
|
+
return basename(moduleDir);
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { resolveModuleDirName as t };
|
|
15
|
+
|
|
16
|
+
//# sourceMappingURL=module-dir-1avCXsBi.mjs.map
|
|
17
|
+
//# debugId=b019bb65-d519-5dd7-bf0e-4c90f1c91ce5
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module-dir-1avCXsBi.mjs","sources":["../src/utils/module-dir.ts"],"sourcesContent":["import { existsSync, statSync } from \"node:fs\";\nimport { basename, dirname, join, resolve } from \"node:path\";\n\n/** The directory in `<modulesDir>/` that `--dir` names, by name or by a path to it or a file in it */\nexport function resolveModuleDirName(\n projectDir: string,\n modulesDir:\n | \"document-models\"\n | \"editors\"\n | \"pieces\"\n | \"processors\"\n | \"subgraphs\",\n dir: string,\n example: string,\n) {\n const modulesPath = join(projectDir, modulesDir);\n const moduleDir = [resolve(projectDir, dir), join(modulesPath, dir)]\n .filter((candidate) => existsSync(candidate))\n .map((candidate) =>\n statSync(candidate).isDirectory() ? candidate : dirname(candidate),\n )\n .find((candidate) => dirname(candidate) === modulesPath);\n if (!moduleDir) {\n throw new Error(\n `No directory in ${modulesDir}/ for --dir \"${dir}\": expected its name (\"${example}\") or its path (\"${modulesDir}/${example}\").`,\n );\n }\n return basename(moduleDir);\n}\n"],"names":[],"mappings":";;;;;;AAIA,SAAgB,qBACd,YACA,YAMA,KACA,SACA;CACA,MAAM,cAAc,KAAK,YAAY,UAAU;CAC/C,MAAM,YAAY,CAAC,QAAQ,YAAY,GAAG,GAAG,KAAK,aAAa,GAAG,CAAC,CAAC,CACjE,QAAQ,cAAc,WAAW,SAAS,CAAC,CAAC,CAC5C,KAAK,cACJ,SAAS,SAAS,CAAC,CAAC,YAAY,IAAI,YAAY,QAAQ,SAAS,CACnE,CAAC,CACA,MAAM,cAAc,QAAQ,SAAS,MAAM,WAAW;CACzD,IAAI,CAAC,WACH,MAAM,IAAI,MACR,mBAAmB,WAAW,eAAe,IAAI,yBAAyB,QAAQ,mBAAmB,WAAW,GAAG,QAAQ,IAC7H;CAEF,OAAO,SAAS,SAAS;AAC3B","debug_id":"b019bb65-d519-5dd7-bf0e-4c90f1c91ce5"}
|