@powerhousedao/ph-cli 6.4.0-next.2 → 6.4.0-next.5
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/README.md +6 -5
- package/dist/auth-5bqHASGL.mjs +4 -0
- package/dist/auth-DYknkWfW.mjs +23 -0
- package/dist/auth-DYknkWfW.mjs.map +1 -0
- package/dist/{build-C7RBpPwa.mjs → build-CBKlv5E3.mjs} +6 -6
- package/dist/{build-C7RBpPwa.mjs.map → build-CBKlv5E3.mjs.map} +1 -1
- package/dist/build-Dr1lnv4h.mjs +4 -0
- package/dist/{check-1Hfe0lVO.mjs → check-CW81vbe9.mjs} +4 -4
- package/dist/{check-1Hfe0lVO.mjs.map → check-CW81vbe9.mjs.map} +1 -1
- package/dist/{check-MBdw9Lbm.mjs → check-Cx_AeBQe.mjs} +7 -7
- package/dist/check-Cx_AeBQe.mjs.map +1 -0
- package/dist/{check-ClxYRer4.mjs → check-DhFd9tO8.mjs} +3 -3
- package/dist/{cli-connect-override-DsuuectH.mjs → cli-connect-override-DKxY3lCi.mjs} +4 -4
- package/dist/{cli-connect-override-DsuuectH.mjs.map → cli-connect-override-DKxY3lCi.mjs.map} +1 -1
- package/dist/cli.mjs +9 -8
- package/dist/cli.mjs.map +1 -1
- package/dist/{compound-Q9sZSEZF-zZWzQ7VC.mjs → compound-g6x_KkWp-Bs7olmlI.mjs} +464 -360
- package/dist/compound-g6x_KkWp-Bs7olmlI.mjs.map +1 -0
- package/dist/{connect-build-DAnGPSF5.mjs → connect-build-DpGUrtct.mjs} +5 -5
- package/dist/{connect-build-DAnGPSF5.mjs.map → connect-build-DpGUrtct.mjs.map} +1 -1
- package/dist/{connect-config-C0QZ7zTf.mjs → connect-config-BpzwJln3.mjs} +4 -4
- package/dist/{connect-config-C0QZ7zTf.mjs.map → connect-config-BpzwJln3.mjs.map} +1 -1
- package/dist/{connect-preview-BvxXGo_W.mjs → connect-preview-B_E4SIV6.mjs} +21 -4
- package/dist/connect-preview-B_E4SIV6.mjs.map +1 -0
- package/dist/connect-studio-BPZOcwUM.mjs +214 -0
- package/dist/connect-studio-BPZOcwUM.mjs.map +1 -0
- package/dist/credentials-CmtYywgk.mjs +132 -0
- package/dist/credentials-CmtYywgk.mjs.map +1 -0
- package/dist/definitions-worker.mjs +4 -4
- package/dist/definitions-worker.mjs.map +1 -1
- package/dist/dev-host-CM-Jg2kY.mjs +19 -0
- package/dist/dev-host-CM-Jg2kY.mjs.map +1 -0
- package/dist/{dist-CRR5Anp2.mjs → dist-DPj_FB8H.mjs} +5 -5
- package/dist/dist-DPj_FB8H.mjs.map +1 -0
- package/dist/{explain-BfOC7Ngv.mjs → explain-DQ5ymlco.mjs} +5 -5
- package/dist/{explain-BfOC7Ngv.mjs.map → explain-DQ5ymlco.mjs.map} +1 -1
- package/dist/{export-CdTqYviH.mjs → export-CzeF8pob.mjs} +4 -4
- package/dist/{export-CdTqYviH.mjs.map → export-CzeF8pob.mjs.map} +1 -1
- package/dist/{generate-all-HujZHqCG.mjs → generate-all-B9MwWXlq.mjs} +6 -21
- package/dist/generate-all-B9MwWXlq.mjs.map +1 -0
- package/dist/{generate-app-hm6CJ_4O.mjs → generate-app-C7n0j8Ak.mjs} +5 -18
- package/dist/generate-app-C7n0j8Ak.mjs.map +1 -0
- package/dist/{generate-document-model-BiD6ovXc.mjs → generate-document-model-D3LKY1D7.mjs} +11 -35
- package/dist/generate-document-model-D3LKY1D7.mjs.map +1 -0
- package/dist/{generate-editor-DBj_Pxwa.mjs → generate-editor-DKuRUeIt.mjs} +5 -18
- package/dist/generate-editor-DKuRUeIt.mjs.map +1 -0
- package/dist/{generate-processor-BVjOsfjJ.mjs → generate-processor-CwJvJDpd.mjs} +5 -18
- package/dist/generate-processor-CwJvJDpd.mjs.map +1 -0
- package/dist/{generate-subgraph-DJZCr0Tk.mjs → generate-subgraph-Q1VLh3SC.mjs} +13 -39
- package/dist/generate-subgraph-Q1VLh3SC.mjs.map +1 -0
- package/dist/{get-version-DAYhm6MX.mjs → get-version-CTP__ORu.mjs} +4 -4
- package/dist/{get-version-DAYhm6MX.mjs.map → get-version-CTP__ORu.mjs.map} +1 -1
- package/dist/identity-DXZFeQfC.mjs +137 -0
- package/dist/identity-DXZFeQfC.mjs.map +1 -0
- package/dist/{index-Bs1PfL3W.d.mts → index-aosqo7aM.d.mts} +5 -4
- package/dist/index-aosqo7aM.d.mts.map +1 -0
- package/dist/{inspect-CulIpVsF.mjs → inspect-BgKI8Fhd.mjs} +6 -6
- package/dist/{inspect-CulIpVsF.mjs.map → inspect-BgKI8Fhd.mjs.map} +1 -1
- package/dist/{keyframes-bFo9iDhT.mjs → keyframes-BkeORfEu.mjs} +4 -4
- package/dist/{keyframes-bFo9iDhT.mjs.map → keyframes-BkeORfEu.mjs.map} +1 -1
- package/dist/{mcp-rtMGg307.mjs → mcp-gcG7SW9L.mjs} +152 -10
- package/dist/mcp-gcG7SW9L.mjs.map +1 -0
- package/dist/{migrate-CWCJP19Q.mjs → migrate-BaWZhorc.mjs} +4 -4
- package/dist/{migrate-CWCJP19Q.mjs.map → migrate-BaWZhorc.mjs.map} +1 -1
- package/dist/{migrate-document-models-DTxM7D7p.mjs → migrate-document-models-DYmkJzq3.mjs} +5 -6
- package/dist/migrate-document-models-DYmkJzq3.mjs.map +1 -0
- package/dist/{migrate-subgraphs-_yRnF7xt.mjs → migrate-subgraphs-BUgTeHcm.mjs} +6 -7
- package/dist/migrate-subgraphs-BUgTeHcm.mjs.map +1 -0
- package/dist/migrate-subgraphs-ChhXynqd.mjs +4 -0
- package/dist/{ph-cli-commands-FLZClR4x.mjs → ph-cli-commands-B5VkGW99.mjs} +179 -190
- package/dist/ph-cli-commands-B5VkGW99.mjs.map +1 -0
- package/dist/ph-cli-commands-CGXSo1wx.mjs +4 -0
- package/dist/{registry-auth-Bm5AR-fB.mjs → registry-auth-C8D5cno2.mjs} +4 -4
- package/dist/{registry-auth-Bm5AR-fB.mjs.map → registry-auth-C8D5cno2.mjs.map} +1 -1
- package/dist/render-BQE20Cnd.mjs +4 -0
- package/dist/{render-SVfj3m8A.mjs → render-CQdi685k.mjs} +6 -6
- package/dist/render-CQdi685k.mjs.map +1 -0
- package/dist/{run-LRGy7zGo.mjs → run-C6Vha5VN.mjs} +3 -3
- package/dist/{run--de_-WAz.mjs → run-sVzTTEUx.mjs} +5 -36
- package/dist/run-sVzTTEUx.mjs.map +1 -0
- package/dist/{run-sugar-DUiDFl_T.mjs → run-sugar-BuxOaRzE.mjs} +16 -8
- package/dist/run-sugar-BuxOaRzE.mjs.map +1 -0
- package/dist/{run-sugar-YDxw0iV9.mjs → run-sugar-Dz-rpeMO.mjs} +3 -3
- package/dist/runners/connect.d.mts +20 -3
- package/dist/runners/connect.d.mts.map +1 -1
- package/dist/runners/connect.mjs +37 -15
- package/dist/runners/connect.mjs.map +1 -1
- package/dist/runners/switchboard.d.mts +1 -1
- package/dist/runners/switchboard.mjs +3 -3
- package/dist/scripts/generate-commands-docs.ts +12 -0
- package/dist/{subgraphs-7OYWwP-C.mjs → subgraphs-Bm9NHTCn.mjs} +5 -38
- package/dist/subgraphs-Bm9NHTCn.mjs.map +1 -0
- package/dist/{sugar-checks-BFu3sfFJ.mjs → sugar-checks-DL-J3l2y.mjs} +16 -15
- package/dist/sugar-checks-DL-J3l2y.mjs.map +1 -0
- package/dist/{verify-Dkb6K1fc.mjs → verify-BLn76w09.mjs} +4 -4
- package/dist/{verify-Dkb6K1fc.mjs.map → verify-BLn76w09.mjs.map} +1 -1
- package/dist/{vetra-gateway-BMzq0mqX.mjs → vetra-gateway-D30pZgha.mjs} +5 -5
- package/dist/{vetra-gateway-BMzq0mqX.mjs.map → vetra-gateway-D30pZgha.mjs.map} +1 -1
- package/dist/vetra-gateway-DE5Hc0Fp.mjs +4 -0
- package/dist/vetra-host-0rSW35_r.mjs +230 -0
- package/dist/vetra-host-0rSW35_r.mjs.map +1 -0
- package/dist/{vetra-launcher-Dq0tWyNW.mjs → vetra-launcher-6NKfi6Au.mjs} +56 -13
- package/dist/vetra-launcher-6NKfi6Au.mjs.map +1 -0
- package/dist/vetra-launcher-XMk_Hv0c.mjs +4 -0
- package/dist/{vetra-instance-CLUzbtbh.mjs → vetra-runtime-Bk6CW-BE.mjs} +6 -24
- package/dist/vetra-runtime-Bk6CW-BE.mjs.map +1 -0
- package/dist/warn-subgraph-type-conflicts-BZ4NwLx5.mjs +131 -0
- package/dist/warn-subgraph-type-conflicts-BZ4NwLx5.mjs.map +1 -0
- package/package.json +17 -16
- package/dist/auth-BFUq7CvE.mjs +0 -18
- package/dist/auth-BFUq7CvE.mjs.map +0 -1
- package/dist/auth-CNhbN5UM.mjs +0 -4
- package/dist/build-BUpe1j4m.mjs +0 -4
- package/dist/check-MBdw9Lbm.mjs.map +0 -1
- package/dist/compound-Q9sZSEZF-zZWzQ7VC.mjs.map +0 -1
- package/dist/connect-preview-BvxXGo_W.mjs.map +0 -1
- package/dist/connect-studio-BUth3UYP.mjs +0 -106
- package/dist/connect-studio-BUth3UYP.mjs.map +0 -1
- package/dist/dist-CRR5Anp2.mjs.map +0 -1
- package/dist/generate-all-HujZHqCG.mjs.map +0 -1
- package/dist/generate-app-hm6CJ_4O.mjs.map +0 -1
- package/dist/generate-document-model-BiD6ovXc.mjs.map +0 -1
- package/dist/generate-editor-DBj_Pxwa.mjs.map +0 -1
- package/dist/generate-processor-BVjOsfjJ.mjs.map +0 -1
- package/dist/generate-subgraph-DJZCr0Tk.mjs.map +0 -1
- package/dist/index-Bs1PfL3W.d.mts.map +0 -1
- package/dist/mcp-rtMGg307.mjs.map +0 -1
- package/dist/migrate-document-models-DTxM7D7p.mjs.map +0 -1
- package/dist/migrate-subgraphs-DcJjLMFd.mjs +0 -4
- package/dist/migrate-subgraphs-_yRnF7xt.mjs.map +0 -1
- package/dist/ph-cli-commands-CRwA1aVX.mjs +0 -4
- package/dist/ph-cli-commands-FLZClR4x.mjs.map +0 -1
- package/dist/render-3M3DwFzO.mjs +0 -4
- package/dist/render-SVfj3m8A.mjs.map +0 -1
- package/dist/run--de_-WAz.mjs.map +0 -1
- package/dist/run-sugar-DUiDFl_T.mjs.map +0 -1
- package/dist/subgraphs-7OYWwP-C.mjs.map +0 -1
- package/dist/sugar-checks-BFu3sfFJ.mjs.map +0 -1
- package/dist/vetra-gateway-BP6Catg4.mjs +0 -4
- package/dist/vetra-host-C37IGwBM.mjs +0 -94
- package/dist/vetra-host-C37IGwBM.mjs.map +0 -1
- package/dist/vetra-instance-CLUzbtbh.mjs.map +0 -1
- package/dist/vetra-launcher-CJ01qmS1.mjs +0 -4
- package/dist/vetra-launcher-Dq0tWyNW.mjs.map +0 -1
- package/dist/warn-subgraph-type-conflicts-BOHBmThq.mjs +0 -19
- package/dist/warn-subgraph-type-conflicts-BOHBmThq.mjs.map +0 -1
|
@@ -1,28 +1,13 @@
|
|
|
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]="
|
|
3
|
-
import {
|
|
4
|
-
import { t as warnSubgraphTypeConflicts } from "./warn-subgraph-type-conflicts-
|
|
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]="19ce57c6-f865-5a10-92bc-2d47a2188201")}catch(e){}}();
|
|
3
|
+
import { R as probeHostsFolder } from "./compound-g6x_KkWp-Bs7olmlI.mjs";
|
|
4
|
+
import { t as warnSubgraphTypeConflicts } from "./warn-subgraph-type-conflicts-BZ4NwLx5.mjs";
|
|
5
5
|
import { t as startGenerateHosts } from "./generate-hosts-BFmPIW2X.mjs";
|
|
6
6
|
import { modelGeneration } from "@powerhousedao/codegen";
|
|
7
7
|
import { buildTsMorphProject } from "@powerhousedao/codegen/utils";
|
|
8
|
-
import { extractAllDocuments, saveSpec } from "@powerhousedao/vetra/codegen";
|
|
9
8
|
//#region src/services/generate-all.ts
|
|
10
|
-
async function startGenerateAll(
|
|
9
|
+
async function startGenerateAll(projectDir) {
|
|
11
10
|
const project = buildTsMorphProject(projectDir);
|
|
12
|
-
if (args.extract) {
|
|
13
|
-
const all = extractAllDocuments(project);
|
|
14
|
-
for (const doc of [
|
|
15
|
-
...all.documentModels,
|
|
16
|
-
...all.editors,
|
|
17
|
-
...all.processors,
|
|
18
|
-
...all.subgraphs,
|
|
19
|
-
...all.apps
|
|
20
|
-
]) {
|
|
21
|
-
const path = await saveSpec(doc, projectDir);
|
|
22
|
-
console.log(`Wrote ${path}`);
|
|
23
|
-
}
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
11
|
await modelGeneration.generateAll(project);
|
|
27
12
|
await project.save();
|
|
28
13
|
await warnSubgraphTypeConflicts(projectDir);
|
|
@@ -31,5 +16,5 @@ async function startGenerateAll(args, projectDir) {
|
|
|
31
16
|
//#endregion
|
|
32
17
|
export { startGenerateAll };
|
|
33
18
|
|
|
34
|
-
//# sourceMappingURL=generate-all-
|
|
35
|
-
//# debugId=
|
|
19
|
+
//# sourceMappingURL=generate-all-B9MwWXlq.mjs.map
|
|
20
|
+
//# debugId=19ce57c6-f865-5a10-92bc-2d47a2188201
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-all-B9MwWXlq.mjs","sources":["../src/services/generate-all.ts"],"sourcesContent":["import { modelGeneration } from \"@powerhousedao/codegen\";\nimport { buildTsMorphProject } from \"@powerhousedao/codegen/utils\";\nimport { probeHostsFolder } from \"@powerhousedao/host-core\";\nimport { warnSubgraphTypeConflicts } from \"../utils/warn-subgraph-type-conflicts.js\";\nimport { startGenerateHosts } from \"./generate-hosts.js\";\n\nexport async function startGenerateAll(projectDir: string) {\n const project = buildTsMorphProject(projectDir);\n await modelGeneration.generateAll(project);\n await project.save();\n await warnSubgraphTypeConflicts(projectDir);\n if (\n probeHostsFolder(projectDir).kind === \"present\" &&\n !(await startGenerateHosts(projectDir))\n ) {\n process.exitCode = 1;\n }\n}\n"],"names":[],"mappings":";;;;;;;;AAMA,eAAsB,iBAAiB,YAAoB;CACzD,MAAM,UAAU,oBAAoB,UAAU;CAC9C,MAAM,gBAAgB,YAAY,OAAO;CACzC,MAAM,QAAQ,KAAK;CACnB,MAAM,0BAA0B,UAAU;CAC1C,IACE,iBAAiB,UAAU,CAAC,CAAC,SAAS,aACtC,CAAE,MAAM,mBAAmB,UAAU,GAErC,QAAQ,WAAW;AAEvB","debug_id":"19ce57c6-f865-5a10-92bc-2d47a2188201"}
|
|
@@ -1,26 +1,16 @@
|
|
|
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]="b86b085e-d6be-53cb-bc30-7a4457d62ae3")}catch(e){}}();
|
|
3
3
|
import { t as resolveModuleDirName } from "./module-dir-1avCXsBi.mjs";
|
|
4
4
|
import { existsSync } from "node:fs";
|
|
5
5
|
import { join } from "node:path";
|
|
6
6
|
import { generateAllApps, generateApp } from "@powerhousedao/codegen";
|
|
7
7
|
import { buildTsMorphProject, getAppMetadata, getEditorMetadata } from "@powerhousedao/codegen/utils";
|
|
8
|
-
import { extractAppDocuments, generateAppFromDocument, getDocument, saveSpec } from "@powerhousedao/vetra/codegen";
|
|
9
8
|
//#region src/services/generate-app.ts
|
|
10
9
|
const MODULE_FILE_EXPECTATION = "an EditorModule with string literals for config.id, config.name and documentTypes";
|
|
11
10
|
async function startGenerateApp(args, projectDir) {
|
|
12
|
-
const { name, allowedDocumentTypes = [], disableDragAndDrop,
|
|
11
|
+
const { name, allowedDocumentTypes = [], disableDragAndDrop, dir, all, debug } = args;
|
|
13
12
|
if (debug) console.log({ args });
|
|
14
13
|
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
14
|
if (all) {
|
|
25
15
|
const { apps, unreadableDirs } = await generateAllApps(project);
|
|
26
16
|
await project.save();
|
|
@@ -28,9 +18,6 @@ async function startGenerateApp(args, projectDir) {
|
|
|
28
18
|
for (const app of apps) console.log(`Regenerated app "${app.name}" in editors/${app.dirName}`);
|
|
29
19
|
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
20
|
return;
|
|
31
|
-
} else if (document) {
|
|
32
|
-
const doc = await getDocument(document);
|
|
33
|
-
await generateAppFromDocument(doc, project);
|
|
34
21
|
} else if (name) await generateApp({
|
|
35
22
|
appName: name,
|
|
36
23
|
allowedDocumentTypes,
|
|
@@ -51,7 +38,7 @@ async function startGenerateApp(args, projectDir) {
|
|
|
51
38
|
console.log(`Regenerated app "${appName}" in editors/${appDirName}`);
|
|
52
39
|
return;
|
|
53
40
|
} else {
|
|
54
|
-
console.log("Please specify one of `name`, `
|
|
41
|
+
console.log("Please specify one of `name`, `dir`, or `all`.");
|
|
55
42
|
return;
|
|
56
43
|
}
|
|
57
44
|
await project.save();
|
|
@@ -68,5 +55,5 @@ function resolveAppDirName(project, projectDir, dir) {
|
|
|
68
55
|
//#endregion
|
|
69
56
|
export { startGenerateApp };
|
|
70
57
|
|
|
71
|
-
//# sourceMappingURL=generate-app-
|
|
72
|
-
//# debugId=
|
|
58
|
+
//# sourceMappingURL=generate-app-C7n0j8Ak.mjs.map
|
|
59
|
+
//# debugId=b86b085e-d6be-53cb-bc30-7a4457d62ae3
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-app-C7n0j8Ak.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 { 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 dir,\n all,\n debug,\n } = args;\n if (debug) {\n console.log({ args });\n }\n const project = buildTsMorphProject(projectDir);\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 (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(\"Please specify one of `name`, `dir`, or `all`.\");\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":";;;;;;;;AAWA,MAAM,0BACJ;AAEF,eAAsB,iBACpB,MACA,YACA;CACA,MAAM,EACJ,MACA,uBAAuB,CAAC,GACxB,oBACA,KACA,KACA,UACE;CACJ,IAAI,OACF,QAAQ,IAAI,EAAE,KAAK,CAAC;CAEtB,MAAM,UAAU,oBAAoB,UAAU;CAC9C,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,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,IAAI,gDAAgD;EAC5D;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":"b86b085e-d6be-53cb-bc30-7a4457d62ae3"}
|
|
@@ -1,6 +1,6 @@
|
|
|
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]="
|
|
3
|
-
import { t as warnSubgraphTypeConflicts } from "./warn-subgraph-type-conflicts-
|
|
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]="5187a467-142e-5020-8a3f-c60f48df6fe7")}catch(e){}}();
|
|
3
|
+
import { t as warnSubgraphTypeConflicts } from "./warn-subgraph-type-conflicts-BZ4NwLx5.mjs";
|
|
4
4
|
import { t as resolveModuleDirName } from "./module-dir-1avCXsBi.mjs";
|
|
5
5
|
import { existsSync } from "node:fs";
|
|
6
6
|
import { join, relative } from "node:path";
|
|
@@ -8,7 +8,6 @@ import { loadDocumentModel, modelGeneration } from "@powerhousedao/codegen";
|
|
|
8
8
|
import { handleMutuallyExclusiveOptions } from "@powerhousedao/shared/clis";
|
|
9
9
|
import { buildTsMorphProject, documentModelsDirOf } from "@powerhousedao/codegen/utils";
|
|
10
10
|
import { readPackage } from "read-pkg";
|
|
11
|
-
import { extractDocumentModelDocuments, getDocument, saveSpec } from "@powerhousedao/vetra/codegen";
|
|
12
11
|
import { capitalCase, kebabCase } from "change-case";
|
|
13
12
|
//#region src/services/definitions/code-first-scaffold.ts
|
|
14
13
|
async function scaffoldCodeFirstDocumentModel(generation, name, projectDir, project) {
|
|
@@ -52,48 +51,29 @@ function modelsDirOf(projectDir) {
|
|
|
52
51
|
return relative(projectDir, documentModelsDirOf(projectDir).path).replaceAll("\\", "/");
|
|
53
52
|
}
|
|
54
53
|
async function startGenerateDocumentModel(args, projectDir) {
|
|
55
|
-
const {
|
|
54
|
+
const { dir, all, name, debug } = args;
|
|
56
55
|
if (debug) console.log({ args });
|
|
57
|
-
if (name !== void 0 && !codeFirst) throw new Error("--name creates a code-first document model. Pass --code-first.");
|
|
58
|
-
if (codeFirst && name === void 0) throw new Error("--code-first only chooses how --name creates a model. Existing models of both styles are discovered without it; drop --code-first. To convert a schema-first model, run ph migrate --document-model <dir>.");
|
|
59
56
|
const project = buildTsMorphProject(projectDir);
|
|
60
57
|
if (name !== void 0) {
|
|
61
58
|
handleMutuallyExclusiveOptions({
|
|
62
59
|
"--name": name,
|
|
63
|
-
"--document": document,
|
|
64
60
|
"--dir": dir,
|
|
65
|
-
"--all": all || void 0
|
|
66
|
-
"--extract": extract || void 0
|
|
61
|
+
"--all": all || void 0
|
|
67
62
|
}, "generation mode");
|
|
68
63
|
await scaffoldCodeFirstDocumentModel(modelGeneration, name, projectDir, project);
|
|
69
64
|
return;
|
|
70
65
|
}
|
|
71
|
-
if (extract) {
|
|
72
|
-
const docs = extractDocumentModelDocuments(project);
|
|
73
|
-
for (const doc of docs) {
|
|
74
|
-
const path = await saveSpec(doc, projectDir);
|
|
75
|
-
console.log(`Wrote ${path}`);
|
|
76
|
-
}
|
|
77
|
-
return;
|
|
78
|
-
}
|
|
79
66
|
if (all) {
|
|
80
67
|
const { documentModels, unreadableDirs, codeFirstDocumentModels } = await modelGeneration.generateAllDocumentModels(project);
|
|
81
68
|
await project.save();
|
|
82
69
|
if (documentModels.length === 0 && unreadableDirs.length === 0 && codeFirstDocumentModels.length === 0) console.log(`No document models found in ${modelsDirOf(projectDir)}/.`);
|
|
83
70
|
for (const { name } of documentModels) console.log(`Regenerated document model "${name}"`);
|
|
84
|
-
for (const { name } of codeFirstDocumentModels) console.log(`Updated the exports of
|
|
85
|
-
for (const dirName of unreadableDirs) console.warn(`Skipped ${modelsDirOf(projectDir)}/${dirName}: it has no readable ${dirName}.json, and no index.ts in it exports a
|
|
71
|
+
for (const { name } of codeFirstDocumentModels) console.log(`Updated the exports of document model "${name}"`);
|
|
72
|
+
for (const dirName of unreadableDirs) console.warn(`Skipped ${modelsDirOf(projectDir)}/${dirName}: it has no readable ${dirName}.json, and no index.ts in it exports a document model with a definition. Kept the manifest's document models.`);
|
|
86
73
|
await warnSubgraphTypeConflicts(projectDir);
|
|
87
74
|
return;
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
const doc = await getDocument(document);
|
|
91
|
-
await modelGeneration.generateDocumentModel(doc.state.global, project);
|
|
92
|
-
} else {
|
|
93
|
-
const state = await loadDocumentModel(document);
|
|
94
|
-
await modelGeneration.generateDocumentModel(state, project);
|
|
95
|
-
}
|
|
96
|
-
} else if (dir) {
|
|
75
|
+
}
|
|
76
|
+
if (dir) {
|
|
97
77
|
const modelsDir = modelsDirOf(projectDir);
|
|
98
78
|
const dirName = resolveModuleDirName(projectDir, modelsDir, dir, "my-document-model");
|
|
99
79
|
const specPath = join(projectDir, modelsDir, dirName, `${dirName}.json`);
|
|
@@ -104,15 +84,11 @@ async function startGenerateDocumentModel(args, projectDir) {
|
|
|
104
84
|
console.log(`Regenerated document model "${state.name}" in ${modelsDir}/${dirName}`);
|
|
105
85
|
await warnSubgraphTypeConflicts(projectDir);
|
|
106
86
|
return;
|
|
107
|
-
} else {
|
|
108
|
-
console.log("Please specify one of `document`, `dir`, `all`, or `extract`.");
|
|
109
|
-
return;
|
|
110
87
|
}
|
|
111
|
-
|
|
112
|
-
await warnSubgraphTypeConflicts(projectDir);
|
|
88
|
+
console.log("Please specify one of `name`, `dir`, or `all`.");
|
|
113
89
|
}
|
|
114
90
|
//#endregion
|
|
115
91
|
export { startGenerateDocumentModel };
|
|
116
92
|
|
|
117
|
-
//# sourceMappingURL=generate-document-model-
|
|
118
|
-
//# debugId=
|
|
93
|
+
//# sourceMappingURL=generate-document-model-D3LKY1D7.mjs.map
|
|
94
|
+
//# debugId=5187a467-142e-5020-8a3f-c60f48df6fe7
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-document-model-D3LKY1D7.mjs","sources":["../src/services/definitions/code-first-scaffold.ts","../src/services/generate-document-model.ts"],"sourcesContent":["import type { ModelGeneration } from \"@powerhousedao/codegen\";\nimport { capitalCase, kebabCase } from \"change-case\";\nimport { existsSync } from \"node:fs\";\nimport { join } from \"node:path\";\nimport { readPackage } from \"read-pkg\";\nimport type { Project } from \"ts-morph\";\n\nexport async function scaffoldCodeFirstDocumentModel(\n generation: ModelGeneration,\n name: string,\n projectDir: string,\n project: Project,\n) {\n const modelName = name.trim();\n if (modelName === \"\") {\n throw new Error(\"--name needs a document model name.\");\n }\n const namespace = await documentTypeNamespace(projectDir);\n const documentType = `${namespace}/${kebabCase(modelName)}`;\n const editorName = `${capitalCase(modelName)} Editor`;\n const editorDirName = kebabCase(editorName);\n if (existsSync(join(projectDir, \"editors\", editorDirName))) {\n throw new Error(\n `editors/${editorDirName} already exists. Choose another --name, or move that editor first.`,\n );\n }\n\n const result = await generation.scaffoldDocumentModel(\n {\n name: modelName,\n documentType,\n author: { name: namespace, website: null },\n },\n project,\n );\n for (const path of result.written) {\n console.log(`Wrote ${path}`);\n }\n\n await generation.generateEditor(\n {\n editorName,\n documentTypes: [documentType],\n editorId: editorDirName,\n editorDirName,\n },\n project,\n );\n await project.save();\n console.log(`Generated editor \"${editorName}\" in editors/${editorDirName}`);\n}\n\nasync function documentTypeNamespace(projectDir: string) {\n const { name } = await readPackage({ cwd: projectDir, normalize: false });\n if (!name) {\n throw new Error(\n \"--name puts the document type under the package name. Add a name to package.json.\",\n );\n }\n return name.replace(/^@/, \"\").replaceAll(\"/\", \"-\");\n}\n","import { loadDocumentModel, modelGeneration } from \"@powerhousedao/codegen\";\nimport {\n buildTsMorphProject,\n documentModelsDirOf,\n} from \"@powerhousedao/codegen/utils\";\nimport { handleMutuallyExclusiveOptions } from \"@powerhousedao/shared/clis\";\nimport { existsSync } from \"node:fs\";\nimport { join, relative } 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\";\nimport { scaffoldCodeFirstDocumentModel } from \"./definitions/code-first-scaffold.js\";\n\n/** The configured documentModelsDir, package-relative, for messages and paths. */\nfunction modelsDirOf(projectDir: string) {\n return relative(projectDir, documentModelsDirOf(projectDir).path).replaceAll(\n \"\\\\\",\n \"/\",\n );\n}\n\nexport async function startGenerateDocumentModel(\n args: GenerateDocumentModelArgs,\n projectDir: string,\n) {\n const { dir, all, name, debug } = args;\n if (debug) {\n console.log({ args });\n }\n const project = buildTsMorphProject(projectDir);\n if (name !== undefined) {\n handleMutuallyExclusiveOptions(\n {\n \"--name\": name,\n \"--dir\": dir,\n \"--all\": all || undefined,\n },\n \"generation mode\",\n );\n await scaffoldCodeFirstDocumentModel(\n modelGeneration,\n name,\n projectDir,\n project,\n );\n return;\n }\n if (all) {\n const { documentModels, unreadableDirs, codeFirstDocumentModels } =\n await modelGeneration.generateAllDocumentModels(project);\n await project.save();\n if (\n documentModels.length === 0 &&\n unreadableDirs.length === 0 &&\n codeFirstDocumentModels.length === 0\n ) {\n console.log(`No document models found in ${modelsDirOf(projectDir)}/.`);\n }\n for (const { name } of documentModels) {\n console.log(`Regenerated document model \"${name}\"`);\n }\n for (const { name } of codeFirstDocumentModels) {\n console.log(`Updated the exports of document model \"${name}\"`);\n }\n for (const dirName of unreadableDirs) {\n console.warn(\n `Skipped ${modelsDirOf(projectDir)}/${dirName}: it has no readable ${dirName}.json, and no index.ts in it exports a document model with a definition. Kept the manifest's document models.`,\n );\n }\n await warnSubgraphTypeConflicts(projectDir);\n return;\n }\n if (dir) {\n const modelsDir = modelsDirOf(projectDir);\n const dirName = resolveModuleDirName(\n projectDir,\n modelsDir,\n dir,\n \"my-document-model\",\n );\n const specPath = join(projectDir, modelsDir, dirName, `${dirName}.json`);\n if (!existsSync(specPath)) {\n throw new Error(`${modelsDir}/${dirName} has no ${dirName}.json.`);\n }\n const state = await loadDocumentModel(specPath);\n await modelGeneration.generateDocumentModel(state, project);\n await project.save();\n console.log(\n `Regenerated document model \"${state.name}\" in ${modelsDir}/${dirName}`,\n );\n await warnSubgraphTypeConflicts(projectDir);\n return;\n }\n console.log(\"Please specify one of `name`, `dir`, or `all`.\");\n}\n"],"names":[],"mappings":";;;;;;;;;;;;AAOA,eAAsB,+BACpB,YACA,MACA,YACA,SACA;CACA,MAAM,YAAY,KAAK,KAAK;CAC5B,IAAI,cAAc,IAChB,MAAM,IAAI,MAAM,qCAAqC;CAEvD,MAAM,YAAY,MAAM,sBAAsB,UAAU;CACxD,MAAM,eAAe,GAAG,UAAU,GAAG,UAAU,SAAS;CACxD,MAAM,aAAa,GAAG,YAAY,SAAS,EAAE;CAC7C,MAAM,gBAAgB,UAAU,UAAU;CAC1C,IAAI,WAAW,KAAK,YAAY,WAAW,aAAa,CAAC,GACvD,MAAM,IAAI,MACR,WAAW,cAAc,mEAC3B;CAGF,MAAM,SAAS,MAAM,WAAW,sBAC9B;EACE,MAAM;EACN;EACA,QAAQ;GAAE,MAAM;GAAW,SAAS;EAAK;CAC3C,GACA,OACF;CACA,KAAK,MAAM,QAAQ,OAAO,SACxB,QAAQ,IAAI,SAAS,MAAM;CAG7B,MAAM,WAAW,eACf;EACE;EACA,eAAe,CAAC,YAAY;EAC5B,UAAU;EACV;CACF,GACA,OACF;CACA,MAAM,QAAQ,KAAK;CACnB,QAAQ,IAAI,qBAAqB,WAAW,eAAe,eAAe;AAC5E;AAEA,eAAe,sBAAsB,YAAoB;CACvD,MAAM,EAAE,SAAS,MAAM,YAAY;EAAE,KAAK;EAAY,WAAW;CAAM,CAAC;CACxE,IAAI,CAAC,MACH,MAAM,IAAI,MACR,mFACF;CAEF,OAAO,KAAK,QAAQ,MAAM,EAAE,CAAC,CAAC,WAAW,KAAK,GAAG;AACnD;;;;AC9CA,SAAS,YAAY,YAAoB;CACvC,OAAO,SAAS,YAAY,oBAAoB,UAAU,CAAC,CAAC,IAAI,CAAC,CAAC,WAChE,MACA,GACF;AACF;AAEA,eAAsB,2BACpB,MACA,YACA;CACA,MAAM,EAAE,KAAK,KAAK,MAAM,UAAU;CAClC,IAAI,OACF,QAAQ,IAAI,EAAE,KAAK,CAAC;CAEtB,MAAM,UAAU,oBAAoB,UAAU;CAC9C,IAAI,SAAS,KAAA,GAAW;EACtB,+BACE;GACE,UAAU;GACV,SAAS;GACT,SAAS,OAAO,KAAA;EAClB,GACA,iBACF;EACA,MAAM,+BACJ,iBACA,MACA,YACA,OACF;EACA;CACF;CACA,IAAI,KAAK;EACP,MAAM,EAAE,gBAAgB,gBAAgB,4BACtC,MAAM,gBAAgB,0BAA0B,OAAO;EACzD,MAAM,QAAQ,KAAK;EACnB,IACE,eAAe,WAAW,KAC1B,eAAe,WAAW,KAC1B,wBAAwB,WAAW,GAEnC,QAAQ,IAAI,+BAA+B,YAAY,UAAU,EAAE,GAAG;EAExE,KAAK,MAAM,EAAE,UAAU,gBACrB,QAAQ,IAAI,+BAA+B,KAAK,EAAE;EAEpD,KAAK,MAAM,EAAE,UAAU,yBACrB,QAAQ,IAAI,0CAA0C,KAAK,EAAE;EAE/D,KAAK,MAAM,WAAW,gBACpB,QAAQ,KACN,WAAW,YAAY,UAAU,EAAE,GAAG,QAAQ,uBAAuB,QAAQ,8GAC/E;EAEF,MAAM,0BAA0B,UAAU;EAC1C;CACF;CACA,IAAI,KAAK;EACP,MAAM,YAAY,YAAY,UAAU;EACxC,MAAM,UAAU,qBACd,YACA,WACA,KACA,mBACF;EACA,MAAM,WAAW,KAAK,YAAY,WAAW,SAAS,GAAG,QAAQ,MAAM;EACvE,IAAI,CAAC,WAAW,QAAQ,GACtB,MAAM,IAAI,MAAM,GAAG,UAAU,GAAG,QAAQ,UAAU,QAAQ,OAAO;EAEnE,MAAM,QAAQ,MAAM,kBAAkB,QAAQ;EAC9C,MAAM,gBAAgB,sBAAsB,OAAO,OAAO;EAC1D,MAAM,QAAQ,KAAK;EACnB,QAAQ,IACN,+BAA+B,MAAM,KAAK,OAAO,UAAU,GAAG,SAChE;EACA,MAAM,0BAA0B,UAAU;EAC1C;CACF;CACA,QAAQ,IAAI,gDAAgD;AAC9D","debug_id":"5187a467-142e-5020-8a3f-c60f48df6fe7"}
|
|
@@ -1,35 +1,22 @@
|
|
|
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]="7a309a30-d5b4-555b-a827-2872f00f888f")}catch(e){}}();
|
|
3
3
|
import { t as resolveModuleDirName } from "./module-dir-1avCXsBi.mjs";
|
|
4
4
|
import { existsSync } from "node:fs";
|
|
5
5
|
import { join } from "node:path";
|
|
6
6
|
import { modelGeneration } from "@powerhousedao/codegen";
|
|
7
7
|
import { buildTsMorphProject, getEditorMetadata } from "@powerhousedao/codegen/utils";
|
|
8
|
-
import { extractEditorDocuments, generateEditorFromDocument, getDocument, saveSpec } from "@powerhousedao/vetra/codegen";
|
|
9
8
|
//#region src/services/generate-editor.ts
|
|
10
9
|
const MODULE_FILE_EXPECTATION = "an EditorModule with string literals for config.id, config.name and documentTypes";
|
|
11
10
|
async function startGenerateEditor(args, projectDir) {
|
|
12
|
-
const { name, documentType,
|
|
11
|
+
const { name, documentType, dir, all, debug } = args;
|
|
13
12
|
if (debug) console.log({ args });
|
|
14
13
|
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
14
|
const report = [];
|
|
25
15
|
if (all) {
|
|
26
16
|
const { editors, unreadableDirs } = await modelGeneration.generateAllEditors(project);
|
|
27
17
|
if (editors.length === 0 && unreadableDirs.length === 0) report.push("No document editors found in editors/.");
|
|
28
18
|
for (const editor of editors) report.push(`Regenerated editor "${editor.name}" in editors/${editor.dirName}`);
|
|
29
19
|
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
20
|
} else if (name) {
|
|
34
21
|
if (!documentType) throw new Error("Please specify a document type for the new editor to generate.");
|
|
35
22
|
await modelGeneration.generateEditor({
|
|
@@ -51,7 +38,7 @@ async function startGenerateEditor(args, projectDir) {
|
|
|
51
38
|
}, project);
|
|
52
39
|
report.push(`Regenerated editor "${editorName}" in editors/${editorDirName}`);
|
|
53
40
|
} else {
|
|
54
|
-
console.log("Please specify one of `name`, `
|
|
41
|
+
console.log("Please specify one of `name`, `dir`, or `all`.");
|
|
55
42
|
return;
|
|
56
43
|
}
|
|
57
44
|
await project.save();
|
|
@@ -60,5 +47,5 @@ async function startGenerateEditor(args, projectDir) {
|
|
|
60
47
|
//#endregion
|
|
61
48
|
export { startGenerateEditor };
|
|
62
49
|
|
|
63
|
-
//# sourceMappingURL=generate-editor-
|
|
64
|
-
//# debugId=
|
|
50
|
+
//# sourceMappingURL=generate-editor-DKuRUeIt.mjs.map
|
|
51
|
+
//# debugId=7a309a30-d5b4-555b-a827-2872f00f888f
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-editor-DKuRUeIt.mjs","sources":["../src/services/generate-editor.ts"],"sourcesContent":["import { modelGeneration } from \"@powerhousedao/codegen\";\nimport {\n buildTsMorphProject,\n getEditorMetadata,\n} from \"@powerhousedao/codegen/utils\";\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, dir, all, debug } = args;\n if (debug) {\n console.log({ args });\n }\n const project = buildTsMorphProject(projectDir);\n const report: string[] = [];\n if (all) {\n const { editors, unreadableDirs } =\n await modelGeneration.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 (name) {\n if (!documentType) {\n throw new Error(\n \"Please specify a document type for the new editor to generate.\",\n );\n }\n await modelGeneration.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 modelGeneration.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(\"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}\n"],"names":[],"mappings":";;;;;;;;AAUA,MAAM,0BACJ;AAEF,eAAsB,oBACpB,MACA,YACA;CACA,MAAM,EAAE,MAAM,cAAc,KAAK,KAAK,UAAU;CAChD,IAAI,OACF,QAAQ,IAAI,EAAE,KAAK,CAAC;CAEtB,MAAM,UAAU,oBAAoB,UAAU;CAC9C,MAAM,SAAmB,CAAC;CAC1B,IAAI,KAAK;EACP,MAAM,EAAE,SAAS,mBACf,MAAM,gBAAgB,mBAAmB,OAAO;EAClD,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,MAAM;EACf,IAAI,CAAC,cACH,MAAM,IAAI,MACR,gEACF;EAEF,MAAM,gBAAgB,eACpB;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,gBAAgB,eACpB;GACE;GACA;GACA;GACA;EACF,GACA,OACF;EACA,OAAO,KACL,uBAAuB,WAAW,eAAe,eACnD;CACF,OAAO;EACL,QAAQ,IAAI,gDAAgD;EAC5D;CACF;CACA,MAAM,QAAQ,KAAK;CACnB,KAAK,MAAM,QAAQ,QACjB,QAAQ,IAAI,IAAI;AAEpB","debug_id":"7a309a30-d5b4-555b-a827-2872f00f888f"}
|
|
@@ -1,34 +1,21 @@
|
|
|
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]="88ec1831-447a-539d-bae5-93d4d91db5af")}catch(e){}}();
|
|
3
3
|
import { t as installAddedDependencies$1 } from "./install-added-dependencies-DnZFR3aE.mjs";
|
|
4
4
|
import { t as resolveModuleDirName } from "./module-dir-1avCXsBi.mjs";
|
|
5
5
|
import { existsSync } from "node:fs";
|
|
6
6
|
import { join } from "node:path";
|
|
7
7
|
import { detectFeatures, generateAllProcessors, generateProcessor, syncFeatureDependencies } from "@powerhousedao/codegen";
|
|
8
8
|
import { buildTsMorphProject, getProcessorMetadata } from "@powerhousedao/codegen/utils";
|
|
9
|
-
import { extractProcessorDocuments, generateProcessorFromDocument, getDocument, saveSpec } from "@powerhousedao/vetra/codegen";
|
|
10
9
|
//#region src/services/generate-processor.ts
|
|
11
10
|
async function startGenerateProcessor(args, projectDir) {
|
|
12
|
-
const { name: processorName, type: processorType, apps: processorApps, documentTypes,
|
|
11
|
+
const { name: processorName, type: processorType, apps: processorApps, documentTypes, dir, all, debug } = args;
|
|
13
12
|
if (debug) console.log({ args });
|
|
14
13
|
const project = buildTsMorphProject(projectDir);
|
|
15
|
-
if (extract) {
|
|
16
|
-
const docs = extractProcessorDocuments(project);
|
|
17
|
-
if (docs.length === 0) console.log("No processors found in processors/.");
|
|
18
|
-
for (const doc of docs) {
|
|
19
|
-
const path = await saveSpec(doc, projectDir);
|
|
20
|
-
console.log(`Wrote ${path}`);
|
|
21
|
-
}
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
14
|
const report = [];
|
|
25
15
|
if (all) {
|
|
26
16
|
const processors = await generateAllProcessors(project);
|
|
27
17
|
if (processors.length === 0) report.push("No processors found in processors/.");
|
|
28
18
|
for (const { processorName } of processors) report.push(`Regenerated processor in processors/${processorName}`);
|
|
29
|
-
} else if (document) {
|
|
30
|
-
const doc = await getDocument(document);
|
|
31
|
-
await generateProcessorFromDocument(doc, project);
|
|
32
19
|
} else if (processorName) await generateProcessor({
|
|
33
20
|
processorName,
|
|
34
21
|
processorApps,
|
|
@@ -43,7 +30,7 @@ async function startGenerateProcessor(args, projectDir) {
|
|
|
43
30
|
await generateProcessor(processorArgs, project);
|
|
44
31
|
report.push(`Regenerated processor in processors/${processorDirName}`);
|
|
45
32
|
} else {
|
|
46
|
-
console.log("Please specify one of `name`, `
|
|
33
|
+
console.log("Please specify one of `name`, `dir`, or `all`.");
|
|
47
34
|
return;
|
|
48
35
|
}
|
|
49
36
|
await project.save();
|
|
@@ -54,5 +41,5 @@ async function startGenerateProcessor(args, projectDir) {
|
|
|
54
41
|
//#endregion
|
|
55
42
|
export { startGenerateProcessor };
|
|
56
43
|
|
|
57
|
-
//# sourceMappingURL=generate-processor-
|
|
58
|
-
//# debugId=
|
|
44
|
+
//# sourceMappingURL=generate-processor-CwJvJDpd.mjs.map
|
|
45
|
+
//# debugId=88ec1831-447a-539d-bae5-93d4d91db5af
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-processor-CwJvJDpd.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 { 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 dir,\n all,\n debug,\n } = args;\n if (debug) {\n console.log({ args });\n }\n const project = buildTsMorphProject(projectDir);\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 (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(\"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":["installAddedDependencies"],"mappings":";;;;;;;;;AAgBA,eAAsB,uBACpB,MACA,YACA;CACA,MAAM,EACJ,MAAM,eACN,MAAM,eACN,MAAM,eACN,eACA,KACA,KACA,UACE;CACJ,IAAI,OACF,QAAQ,IAAI,EAAE,KAAK,CAAC;CAEtB,MAAM,UAAU,oBAAoB,UAAU;CAC9C,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,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,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,MAAMA,2BAAyB,OAAO,YAAY,KAAK,WAAW;AACpE","debug_id":"88ec1831-447a-539d-bae5-93d4d91db5af"}
|
|
@@ -1,13 +1,12 @@
|
|
|
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]="b7dd8da1-5da0-5f0c-934e-afd9a52da5e1")}catch(e){}}();
|
|
3
3
|
import { t as installAddedDependencies$1 } from "./install-added-dependencies-DnZFR3aE.mjs";
|
|
4
|
-
import { t as warnSubgraphTypeConflicts } from "./warn-subgraph-type-conflicts-
|
|
4
|
+
import { n as findSubgraphNameConflict, t as warnSubgraphTypeConflicts } from "./warn-subgraph-type-conflicts-BZ4NwLx5.mjs";
|
|
5
5
|
import { t as resolveModuleDirName } from "./module-dir-1avCXsBi.mjs";
|
|
6
6
|
import { existsSync } from "node:fs";
|
|
7
7
|
import { join } from "node:path";
|
|
8
8
|
import { detectFeatures, generateAllSubgraphs, generateSubgraph, generateSubgraphDir, syncFeatureDependencies } from "@powerhousedao/codegen";
|
|
9
9
|
import { buildTsMorphProject, subgraphDirStyle } from "@powerhousedao/codegen/utils";
|
|
10
|
-
import { extractSubgraphDocuments, findSubgraphNameConflict, generateSubgraphFromDocument, getDocument, saveSpec } from "@powerhousedao/vetra/codegen";
|
|
11
10
|
import { kebabCase } from "change-case";
|
|
12
11
|
//#region src/services/generate-subgraph.ts
|
|
13
12
|
const INDEX_FILE_EXPECTATION = {
|
|
@@ -18,51 +17,26 @@ async function assertSubgraphNameFree(projectDir, name) {
|
|
|
18
17
|
const conflict = await findSubgraphNameConflict(projectDir, name);
|
|
19
18
|
if (conflict) throw new Error(conflict);
|
|
20
19
|
}
|
|
21
|
-
/**
|
|
22
|
-
*
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
if (!existsSync(join(subgraphsDir, dirName, "index.ts")) || subgraphDirStyle(subgraphsDir, dirName) !== "schema-first") return void 0;
|
|
28
|
-
return `subgraphs/${dirName} is schema-first; --code-first only applies to new subgraphs. To convert it, run ph migrate --subgraph ${dirName}.`;
|
|
20
|
+
/** Codegen reads a directory's form from its index.ts. When that file is
|
|
21
|
+
* gone, lib.ts or resolvers.ts still marks a legacy subgraph: only the legacy
|
|
22
|
+
* subgraph generator writes them. */
|
|
23
|
+
function holdsLegacySubgraphFiles(projectDir, name) {
|
|
24
|
+
const dir = join(projectDir, "subgraphs", kebabCase(name));
|
|
25
|
+
return ["lib.ts", "resolvers.ts"].some((file) => existsSync(join(dir, file)));
|
|
29
26
|
}
|
|
30
27
|
async function startGenerateSubgraph(args, projectDir) {
|
|
31
|
-
const { name,
|
|
28
|
+
const { name, dir, all, debug } = args;
|
|
32
29
|
if (debug) console.log({ args });
|
|
33
30
|
const project = buildTsMorphProject(projectDir);
|
|
34
|
-
if (extract) {
|
|
35
|
-
const docs = extractSubgraphDocuments(project);
|
|
36
|
-
if (docs.length === 0) console.log("No subgraphs found in subgraphs/.");
|
|
37
|
-
for (const doc of docs) {
|
|
38
|
-
const path = await saveSpec(doc, projectDir);
|
|
39
|
-
console.log(`Wrote ${path}`);
|
|
40
|
-
}
|
|
41
|
-
return;
|
|
42
|
-
}
|
|
43
31
|
const report = [];
|
|
44
32
|
if (all) {
|
|
45
33
|
const { subgraphNames, unreadableDirs } = await generateAllSubgraphs(project);
|
|
46
34
|
if (subgraphNames.length === 0 && unreadableDirs.length === 0) report.push("No subgraphs found in subgraphs/.");
|
|
47
35
|
for (const subgraphName of subgraphNames) report.push(`Regenerated subgraph "${subgraphName}"`);
|
|
48
36
|
for (const dirName of unreadableDirs) console.warn(`Skipped subgraphs/${dirName}: expected its index.ts to export ${INDEX_FILE_EXPECTATION[subgraphDirStyle(join(projectDir, "subgraphs"), dirName)]}. Kept the manifest's subgraphs.`);
|
|
49
|
-
} else if (document) {
|
|
50
|
-
const doc = await getDocument(document);
|
|
51
|
-
const notice = codeFirstOnSchemaFirst(args, projectDir, doc.state.global.name);
|
|
52
|
-
if (notice) {
|
|
53
|
-
console.log(notice);
|
|
54
|
-
return;
|
|
55
|
-
}
|
|
56
|
-
await assertSubgraphNameFree(projectDir, doc.state.global.name);
|
|
57
|
-
await generateSubgraphFromDocument(doc, project, { codeFirst: args.codeFirst });
|
|
58
37
|
} else if (name) {
|
|
59
|
-
const notice = codeFirstOnSchemaFirst(args, projectDir, name);
|
|
60
|
-
if (notice) {
|
|
61
|
-
console.log(notice);
|
|
62
|
-
return;
|
|
63
|
-
}
|
|
64
38
|
await assertSubgraphNameFree(projectDir, name);
|
|
65
|
-
await generateSubgraph(name, project, { codeFirst:
|
|
39
|
+
await generateSubgraph(name, project, { codeFirst: !holdsLegacySubgraphFiles(projectDir, name) });
|
|
66
40
|
} else if (dir) {
|
|
67
41
|
const dirName = resolveModuleDirName(projectDir, "subgraphs", dir, "my-subgraph");
|
|
68
42
|
if (!existsSync(join(projectDir, "subgraphs", dirName, "index.ts"))) throw new Error(`subgraphs/${dirName} has no index.ts.`);
|
|
@@ -70,7 +44,7 @@ async function startGenerateSubgraph(args, projectDir) {
|
|
|
70
44
|
if (!subgraphName) throw new Error(`Could not read subgraphs/${dirName}/index.ts: expected ${INDEX_FILE_EXPECTATION[style]}.`);
|
|
71
45
|
report.push(`Regenerated subgraph "${subgraphName}"`);
|
|
72
46
|
} else {
|
|
73
|
-
console.log("Please specify one of `name`, `
|
|
47
|
+
console.log("Please specify one of `name`, `dir`, or `all`.");
|
|
74
48
|
return;
|
|
75
49
|
}
|
|
76
50
|
await project.save();
|
|
@@ -82,5 +56,5 @@ async function startGenerateSubgraph(args, projectDir) {
|
|
|
82
56
|
//#endregion
|
|
83
57
|
export { startGenerateSubgraph };
|
|
84
58
|
|
|
85
|
-
//# sourceMappingURL=generate-subgraph-
|
|
86
|
-
//# debugId=
|
|
59
|
+
//# sourceMappingURL=generate-subgraph-Q1VLh3SC.mjs.map
|
|
60
|
+
//# debugId=b7dd8da1-5da0-5f0c-934e-afd9a52da5e1
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generate-subgraph-Q1VLh3SC.mjs","sources":["../src/services/generate-subgraph.ts"],"sourcesContent":["import {\n detectFeatures,\n generateAllSubgraphs,\n generateSubgraph,\n generateSubgraphDir,\n syncFeatureDependencies,\n} from \"@powerhousedao/codegen\";\nimport {\n buildTsMorphProject,\n subgraphDirStyle,\n type SubgraphStyle,\n} from \"@powerhousedao/codegen/utils\";\nimport { kebabCase } from \"change-case\";\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 { findSubgraphNameConflict } from \"../utils/subgraph-type-lint.js\";\nimport { warnSubgraphTypeConflicts } from \"../utils/warn-subgraph-type-conflicts.js\";\n\nconst INDEX_FILE_EXPECTATION = {\n \"schema-first\": \"a class extending BaseSubgraph with a string literal `name`\",\n \"code-first\":\n \"a class extending Subgraph with a string literal `static subgraphName`\",\n} satisfies Record<SubgraphStyle, string>;\n\nasync function assertSubgraphNameFree(projectDir: string, name: string) {\n const conflict = await findSubgraphNameConflict(projectDir, name);\n if (conflict) throw new Error(conflict);\n}\n\n/** Codegen reads a directory's form from its index.ts. When that file is\n * gone, lib.ts or resolvers.ts still marks a legacy subgraph: only the legacy\n * subgraph generator writes them. */\nfunction holdsLegacySubgraphFiles(projectDir: string, name: string) {\n const dir = join(projectDir, \"subgraphs\", kebabCase(name));\n return [\"lib.ts\", \"resolvers.ts\"].some((file) => existsSync(join(dir, file)));\n}\n\nexport async function startGenerateSubgraph(\n args: GenerateSubgraphArgs,\n projectDir: string,\n) {\n const { name, dir, all, debug } = args;\n if (debug) {\n console.log({ args });\n }\n const project = buildTsMorphProject(projectDir);\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[subgraphDirStyle(join(projectDir, \"subgraphs\"), dirName)]}. Kept the manifest's subgraphs.`,\n );\n }\n } else if (name) {\n await assertSubgraphNameFree(projectDir, name);\n await generateSubgraph(name, project, {\n codeFirst: !holdsLegacySubgraphFiles(projectDir, name),\n });\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, style } = await generateSubgraphDir(dirName, project);\n if (!subgraphName) {\n throw new Error(\n `Could not read subgraphs/${dirName}/index.ts: expected ${INDEX_FILE_EXPECTATION[style]}.`,\n );\n }\n report.push(`Regenerated subgraph \"${subgraphName}\"`);\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 await warnSubgraphTypeConflicts(projectDir);\n const added = await syncFeatureDependencies(\n detectFeatures(projectDir),\n projectDir,\n );\n await installAddedDependencies(added, projectDir, args.skipInstall);\n}\n"],"names":["installAddedDependencies"],"mappings":";;;;;;;;;;;AAqBA,MAAM,yBAAyB;CAC7B,gBAAgB;CAChB,cACE;AACJ;AAEA,eAAe,uBAAuB,YAAoB,MAAc;CACtE,MAAM,WAAW,MAAM,yBAAyB,YAAY,IAAI;CAChE,IAAI,UAAU,MAAM,IAAI,MAAM,QAAQ;AACxC;;;;AAKA,SAAS,yBAAyB,YAAoB,MAAc;CAClE,MAAM,MAAM,KAAK,YAAY,aAAa,UAAU,IAAI,CAAC;CACzD,OAAO,CAAC,UAAU,cAAc,CAAC,CAAC,MAAM,SAAS,WAAW,KAAK,KAAK,IAAI,CAAC,CAAC;AAC9E;AAEA,eAAsB,sBACpB,MACA,YACA;CACA,MAAM,EAAE,MAAM,KAAK,KAAK,UAAU;CAClC,IAAI,OACF,QAAQ,IAAI,EAAE,KAAK,CAAC;CAEtB,MAAM,UAAU,oBAAoB,UAAU;CAC9C,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,iBAAiB,KAAK,YAAY,WAAW,GAAG,OAAO,GAAG,iCACpJ;CAEJ,OAAO,IAAI,MAAM;EACf,MAAM,uBAAuB,YAAY,IAAI;EAC7C,MAAM,iBAAiB,MAAM,SAAS,EACpC,WAAW,CAAC,yBAAyB,YAAY,IAAI,EACvD,CAAC;CACH,OAAO,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,cAAc,UAAU,MAAM,oBAAoB,SAAS,OAAO;EAC1E,IAAI,CAAC,cACH,MAAM,IAAI,MACR,4BAA4B,QAAQ,sBAAsB,uBAAuB,OAAO,EAC1F;EAEF,OAAO,KAAK,yBAAyB,aAAa,EAAE;CACtD,OAAO;EACL,QAAQ,IAAI,gDAAgD;EAC5D;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,MAAMA,2BAAyB,OAAO,YAAY,KAAK,WAAW;AACpE","debug_id":"b7dd8da1-5da0-5f0c-934e-afd9a52da5e1"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
//#region src/get-version.ts
|
|
2
2
|
|
|
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]="
|
|
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]="7b15c1d5-e9e7-5d18-9bf0-80f3184cc19d")}catch(e){}}();
|
|
4
4
|
function getVersion() {
|
|
5
|
-
return "6.4.0-next.
|
|
5
|
+
return "6.4.0-next.5";
|
|
6
6
|
}
|
|
7
7
|
//#endregion
|
|
8
8
|
export { getVersion as t };
|
|
9
9
|
|
|
10
|
-
//# sourceMappingURL=get-version-
|
|
11
|
-
//# debugId=
|
|
10
|
+
//# sourceMappingURL=get-version-CTP__ORu.mjs.map
|
|
11
|
+
//# debugId=7b15c1d5-e9e7-5d18-9bf0-80f3184cc19d
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-version-
|
|
1
|
+
{"version":3,"file":"get-version-CTP__ORu.mjs","sources":["../src/get-version.ts"],"sourcesContent":["declare const CLI_VERSION: string | undefined;\ndeclare const CLI_GIT_SHA: string | undefined;\n\nexport function getVersion() {\n if (typeof CLI_VERSION !== \"undefined\") return CLI_VERSION;\n return (\n process.env.WORKSPACE_VERSION ||\n process.env.npm_package_version ||\n \"unknown\"\n );\n}\n\nexport function getGitHash() {\n if (typeof CLI_GIT_SHA !== \"undefined\") return CLI_GIT_SHA;\n return process.env.WORKSPACE_GIT_SHA || \"unknown\";\n}\n"],"names":[],"mappings":";;;AAGA,SAAgB,aAAa;CACa,OAAA;AAM1C","debug_id":"7b15c1d5-e9e7-5d18-9bf0-80f3184cc19d"}
|