@powerhousedao/codegen 4.1.0-dev.8 → 4.1.0-dev.81
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 +0 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-custom-subgraph/index.js +10 -0
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-custom-subgraph/resolvers.esm.t +17 -0
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-custom-subgraph/schema.esm.t +16 -0
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/documentModel.esm.t +2 -2
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/index.esm.t +8 -2
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/index.js +69 -54
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/ph-factories.esm.t +93 -0
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/reducer.esm.t +9 -4
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/rootIndex.esm.t +6 -7
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/types.esm.t +20 -8
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/utils.esm.t +19 -26
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-module/creators.esm.t +1 -1
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-module/customTest.esm.t +2 -2
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-module/error.esm.t +6 -10
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-module/index.js +52 -27
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-subgraph/index.js +21 -20
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-subgraph/resolvers.esm.t +64 -51
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-subgraph/schema.esm.t +3 -3
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/components/CreateDocument.esm.t +39 -28
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/components/DriveExplorer.esm.t +201 -219
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/components/FolderTree.esm.t +95 -72
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/config.esm.t +10 -0
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/editor.esm.t +10 -71
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/index.esm.t +5 -10
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/index.js +12 -0
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-editor/editor.esm.t +87 -20
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-editor/hooks.esm.t +16 -0
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-editor/index.esm.t +5 -12
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-editor/index.js +28 -15
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-import-script/index.js +8 -10
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-analytics/factory.esm.t +5 -4
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-analytics/index.esm.t +5 -9
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-analytics/index.js +13 -15
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-analytics/lib.esm.t +8 -6
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-analytics/lib.inject_call.esm.t +1 -1
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-analytics/lib.inject_import.esm.t +1 -1
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-relationalDb/factory.esm.t +6 -5
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-relationalDb/index.esm.t +7 -9
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-relationalDb/index.js +13 -15
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-relationalDb/lib.esm.t +8 -9
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-relationalDb/lib.inject_call.esm.t +2 -2
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-relationalDb/lib.inject_import.esm.t +1 -1
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-relationalDb/migrations.esm.t +2 -2
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-relationalDb/schema.esm.t +10 -2
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-subgraph/index.esm.t +5 -36
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-subgraph/index.js +9 -11
- package/dist/src/codegen/generate.d.ts +33 -0
- package/dist/src/codegen/generate.d.ts.map +1 -0
- package/dist/src/codegen/generate.js +207 -0
- package/dist/src/codegen/generate.js.map +1 -0
- package/dist/src/codegen/graphql.d.ts +2 -2
- package/dist/src/codegen/graphql.d.ts.map +1 -1
- package/dist/src/codegen/graphql.js +1 -1
- package/dist/src/codegen/graphql.js.map +1 -1
- package/dist/src/codegen/hygen.d.ts +18 -11
- package/dist/src/codegen/hygen.d.ts.map +1 -1
- package/dist/src/codegen/hygen.js +55 -17
- package/dist/src/codegen/hygen.js.map +1 -1
- package/dist/src/codegen/index.d.ts +6 -32
- package/dist/src/codegen/index.d.ts.map +1 -1
- package/dist/src/codegen/index.js +6 -182
- package/dist/src/codegen/index.js.map +1 -1
- package/dist/src/codegen/types.d.ts +9 -0
- package/dist/src/codegen/types.d.ts.map +1 -0
- package/dist/src/codegen/types.js +2 -0
- package/dist/src/codegen/types.js.map +1 -0
- package/dist/src/codegen/utils.d.ts +5 -2
- package/dist/src/codegen/utils.d.ts.map +1 -1
- package/dist/src/codegen/utils.js +42 -4
- package/dist/src/codegen/utils.js.map +1 -1
- package/dist/src/create-lib/create-project.d.ts.map +1 -1
- package/dist/src/create-lib/create-project.js +17 -2
- package/dist/src/create-lib/create-project.js.map +1 -1
- package/dist/src/index.d.ts +5 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +5 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/ts-morph-generator/core/FileGenerator.d.ts +2 -3
- package/dist/src/ts-morph-generator/core/FileGenerator.d.ts.map +1 -1
- package/dist/src/ts-morph-generator/core/FileGenerator.js.map +1 -1
- package/dist/src/ts-morph-generator/core/GenerationContext.d.ts +18 -8
- package/dist/src/ts-morph-generator/core/GenerationContext.d.ts.map +1 -1
- package/dist/src/ts-morph-generator/core/ReducerGenerator.d.ts +12 -0
- package/dist/src/ts-morph-generator/core/ReducerGenerator.d.ts.map +1 -0
- package/dist/src/ts-morph-generator/core/ReducerGenerator.js +140 -0
- package/dist/src/ts-morph-generator/core/ReducerGenerator.js.map +1 -0
- package/dist/src/ts-morph-generator/core/TSMorphCodeGenerator.d.ts +4 -3
- package/dist/src/ts-morph-generator/core/TSMorphCodeGenerator.d.ts.map +1 -1
- package/dist/src/ts-morph-generator/core/TSMorphCodeGenerator.js +11 -10
- package/dist/src/ts-morph-generator/core/TSMorphCodeGenerator.js.map +1 -1
- package/dist/src/ts-morph-generator/index.d.ts +2 -2
- package/dist/src/ts-morph-generator/index.d.ts.map +1 -1
- package/dist/src/ts-morph-generator/index.js +2 -2
- package/dist/src/ts-morph-generator/index.js.map +1 -1
- package/dist/src/ts-morph-generator/utilities/DirectoryManager.d.ts +2 -2
- package/dist/src/ts-morph-generator/utilities/DirectoryManager.d.ts.map +1 -1
- package/dist/src/ts-morph-generator/utilities/ImportManager.d.ts +1 -1
- package/dist/src/ts-morph-generator/utilities/ImportManager.d.ts.map +1 -1
- package/dist/src/utils/index.d.ts +0 -1
- package/dist/src/utils/index.d.ts.map +1 -1
- package/dist/src/utils/index.js +0 -1
- package/dist/src/utils/index.js.map +1 -1
- package/dist/src/utils/validation.d.ts +6 -6
- package/dist/src/utils/validation.d.ts.map +1 -1
- package/dist/src/utils/validation.js +2 -2
- package/dist/src/utils/validation.js.map +1 -1
- package/dist/tsconfig.lib.tsbuildinfo +1 -1
- package/package.json +25 -27
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/index.d.ts +0 -25
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/index.d.ts.map +0 -1
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/index.js.map +0 -1
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model/object.esm.t +0 -49
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-module/index.d.ts +0 -23
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-module/index.d.ts.map +0 -1
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-module/index.js.map +0 -1
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-module/object.esm.t +0 -37
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-subgraph/index.d.ts +0 -22
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-subgraph/index.d.ts.map +0 -1
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-document-model-subgraph/index.js.map +0 -1
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/components/EditorContainer.esm.t +0 -124
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/components/FileItemsGrid.esm.t +0 -44
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/components/FolderItemsGrid.esm.t +0 -96
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/hooks/useSelectedFolderChildren.esm.t +0 -35
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/hooks/useTransformedNodes.esm.t +0 -35
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-drive-editor/types/css.d.esm.t +0 -8
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-editor/index.d.ts +0 -20
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-editor/index.d.ts.map +0 -1
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-editor/index.js.map +0 -1
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-import-script/index.d.ts +0 -14
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-import-script/index.d.ts.map +0 -1
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-import-script/index.js.map +0 -1
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-analytics/index.d.ts +0 -20
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-analytics/index.d.ts.map +0 -1
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-analytics/index.js.map +0 -1
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-relationalDb/index.d.ts +0 -20
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-relationalDb/index.d.ts.map +0 -1
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-processor-relationalDb/index.js.map +0 -1
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-subgraph/index.d.ts +0 -16
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-subgraph/index.d.ts.map +0 -1
- package/dist/src/codegen/.hygen/templates/powerhouse/generate-subgraph/index.js.map +0 -1
- package/dist/src/ts-morph-generator/core/index.d.ts +0 -4
- package/dist/src/ts-morph-generator/core/index.d.ts.map +0 -1
- package/dist/src/ts-morph-generator/core/index.js +0 -4
- package/dist/src/ts-morph-generator/core/index.js.map +0 -1
- package/dist/src/ts-morph-generator/file-generators/ReducerGenerator.d.ts +0 -9
- package/dist/src/ts-morph-generator/file-generators/ReducerGenerator.d.ts.map +0 -1
- package/dist/src/ts-morph-generator/file-generators/ReducerGenerator.js +0 -69
- package/dist/src/ts-morph-generator/file-generators/ReducerGenerator.js.map +0 -1
- package/dist/src/ts-morph-generator/file-generators/index.d.ts +0 -2
- package/dist/src/ts-morph-generator/file-generators/index.d.ts.map +0 -1
- package/dist/src/ts-morph-generator/file-generators/index.js +0 -2
- package/dist/src/ts-morph-generator/file-generators/index.js.map +0 -1
- package/dist/src/utils/package-manager.d.ts +0 -5
- package/dist/src/utils/package-manager.d.ts.map +0 -1
- package/dist/src/utils/package-manager.js +0 -17
- package/dist/src/utils/package-manager.js.map +0 -1
- package/dist/tsconfig.hygen.tsbuildinfo +0 -1
|
@@ -1,11 +1,10 @@
|
|
|
1
|
+
import { loadDocumentModel, TSMorphCodeGenerator, } from "@powerhousedao/codegen";
|
|
1
2
|
import { pascalCase } from "change-case";
|
|
2
3
|
import { Logger, runner } from "hygen";
|
|
3
4
|
import fs from "node:fs";
|
|
4
5
|
import { createRequire } from "node:module";
|
|
5
6
|
import path from "node:path";
|
|
6
7
|
import { fileURLToPath } from "node:url";
|
|
7
|
-
import { TSMorphCodeGenerator } from "../ts-morph-generator/core/TSMorphCodeGenerator.js";
|
|
8
|
-
import { loadDocumentModel } from "./utils.js";
|
|
9
8
|
const require = createRequire(import.meta.url);
|
|
10
9
|
const __dirname = import.meta.dirname || path.dirname(fileURLToPath(import.meta.url));
|
|
11
10
|
const defaultTemplates = path.join(__dirname, ".hygen", "templates");
|
|
@@ -18,12 +17,10 @@ export async function run(args, { watch = false, skipFormat = false, verbose = t
|
|
|
18
17
|
cwd: process.cwd(),
|
|
19
18
|
logger,
|
|
20
19
|
createPrompter: () => {
|
|
21
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
22
20
|
return require("enquirer");
|
|
23
21
|
},
|
|
24
22
|
exec: (action, body) => {
|
|
25
23
|
const opts = body && body.length > 0 ? { input: body } : {};
|
|
26
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
|
|
27
24
|
return require("execa").shell(action, opts);
|
|
28
25
|
},
|
|
29
26
|
debug: !!process.env.DEBUG,
|
|
@@ -34,7 +31,7 @@ export async function run(args, { watch = false, skipFormat = false, verbose = t
|
|
|
34
31
|
actions
|
|
35
32
|
.filter((action) => ["added", "inject"].includes(action.status))
|
|
36
33
|
.forEach((action) => {
|
|
37
|
-
execa.$ `prettier --ignore-path --write ${action.subject.replace(".", process.cwd())}`.catch((err) => {
|
|
34
|
+
execa.$ `npx prettier --ignore-path --write ${action.subject.replace(".", process.cwd())}`.catch((err) => {
|
|
38
35
|
if (verbose) {
|
|
39
36
|
console.log(err);
|
|
40
37
|
}
|
|
@@ -43,7 +40,7 @@ export async function run(args, { watch = false, skipFormat = false, verbose = t
|
|
|
43
40
|
}
|
|
44
41
|
return result;
|
|
45
42
|
}
|
|
46
|
-
export async function generateAll(dir, { watch = false, skipFormat = false, verbose = true } = {}) {
|
|
43
|
+
export async function generateAll(dir, { watch = false, skipFormat = false, verbose = true, force = true } = {}) {
|
|
47
44
|
const files = fs.readdirSync(dir, { withFileTypes: true });
|
|
48
45
|
const documentModelStates = [];
|
|
49
46
|
for (const directory of files.filter((f) => f.isDirectory())) {
|
|
@@ -54,11 +51,12 @@ export async function generateAll(dir, { watch = false, skipFormat = false, verb
|
|
|
54
51
|
try {
|
|
55
52
|
const documentModel = await loadDocumentModel(documentModelPath);
|
|
56
53
|
documentModelStates.push(documentModel);
|
|
57
|
-
await
|
|
54
|
+
await hygenGenerateDocumentModel(documentModel, dir, {
|
|
58
55
|
watch,
|
|
59
56
|
skipFormat,
|
|
60
57
|
verbose,
|
|
61
58
|
generateReducers: false,
|
|
59
|
+
force,
|
|
62
60
|
});
|
|
63
61
|
}
|
|
64
62
|
catch (error) {
|
|
@@ -71,10 +69,11 @@ export async function generateAll(dir, { watch = false, skipFormat = false, verb
|
|
|
71
69
|
const documentModelDir = path.basename(dir);
|
|
72
70
|
const generator = new TSMorphCodeGenerator(projectDir, documentModelStates, {
|
|
73
71
|
directories: { documentModelDir },
|
|
72
|
+
forceUpdate: force,
|
|
74
73
|
});
|
|
75
74
|
await generator.generateReducers();
|
|
76
75
|
}
|
|
77
|
-
export async function
|
|
76
|
+
export async function hygenGenerateDocumentModel(documentModelState, dir, { watch = false, skipFormat = false, verbose = true, generateReducers = true, force = true, } = {}) {
|
|
78
77
|
const projectDir = path.dirname(dir);
|
|
79
78
|
const documentModelDir = path.basename(dir);
|
|
80
79
|
// Generate the singular files for the document model logic
|
|
@@ -101,13 +100,13 @@ export async function generateDocumentModel(documentModelState, dir, { watch = f
|
|
|
101
100
|
], { watch, skipFormat, verbose });
|
|
102
101
|
}
|
|
103
102
|
if (generateReducers) {
|
|
104
|
-
const generator = new TSMorphCodeGenerator(projectDir, [documentModelState], { directories: { documentModelDir } });
|
|
103
|
+
const generator = new TSMorphCodeGenerator(projectDir, [documentModelState], { directories: { documentModelDir }, forceUpdate: force });
|
|
105
104
|
await generator.generateReducers();
|
|
106
105
|
}
|
|
107
106
|
}
|
|
108
|
-
export async function
|
|
107
|
+
export async function hygenGenerateEditor(name, documentTypes, documentTypesMap, dir, documentModelsDir, { skipFormat = false, verbose = true } = {}, editorId) {
|
|
109
108
|
// Generate the singular files for the document model logic
|
|
110
|
-
|
|
109
|
+
const args = [
|
|
111
110
|
"powerhouse",
|
|
112
111
|
"generate-editor",
|
|
113
112
|
"--name",
|
|
@@ -120,9 +119,13 @@ export async function generateEditor(name, documentTypes, documentTypesMap, dir,
|
|
|
120
119
|
JSON.stringify(documentTypesMap),
|
|
121
120
|
"--document-models-dir",
|
|
122
121
|
documentModelsDir,
|
|
123
|
-
]
|
|
122
|
+
];
|
|
123
|
+
if (editorId) {
|
|
124
|
+
args.push("--editor-id", editorId);
|
|
125
|
+
}
|
|
126
|
+
await run(args, { skipFormat, verbose });
|
|
124
127
|
}
|
|
125
|
-
export async function
|
|
128
|
+
export async function hygenGenerateProcessor(name, documentTypes, documentTypesMap, outDir, documentModelsDir, type, { skipFormat = false, verbose = true } = {}) {
|
|
126
129
|
// Generate the singular files for the document model logic
|
|
127
130
|
const processorType = type === "relationalDb" ? "relationalDb" : "analytics";
|
|
128
131
|
await run([
|
|
@@ -142,7 +145,7 @@ export async function generateProcessor(name, documentTypes, documentTypesMap, o
|
|
|
142
145
|
documentModelsDir,
|
|
143
146
|
], { skipFormat, verbose });
|
|
144
147
|
}
|
|
145
|
-
export async function
|
|
148
|
+
export async function hygenGenerateSubgraph(name, documentModel, dir, { skipFormat = false, verbose = true } = {}) {
|
|
146
149
|
const params = [
|
|
147
150
|
"powerhouse",
|
|
148
151
|
`generate-subgraph`,
|
|
@@ -171,8 +174,18 @@ export async function generateSubgraph(name, documentModel, dir, { skipFormat =
|
|
|
171
174
|
dir,
|
|
172
175
|
], { skipFormat, verbose });
|
|
173
176
|
}
|
|
177
|
+
else {
|
|
178
|
+
await run([
|
|
179
|
+
"powerhouse",
|
|
180
|
+
"generate-custom-subgraph",
|
|
181
|
+
"--subgraph",
|
|
182
|
+
name,
|
|
183
|
+
"--root-dir",
|
|
184
|
+
dir,
|
|
185
|
+
], { skipFormat, verbose });
|
|
186
|
+
}
|
|
174
187
|
}
|
|
175
|
-
export async function
|
|
188
|
+
export async function hygenGenerateImportScript(name, dir, { skipFormat = false, verbose = true } = {}) {
|
|
176
189
|
// Generate the singular files for the document model logic
|
|
177
190
|
await run([
|
|
178
191
|
"powerhouse",
|
|
@@ -185,8 +198,33 @@ export async function generateImportScript(name, dir, { skipFormat = false, verb
|
|
|
185
198
|
dir,
|
|
186
199
|
], { skipFormat, verbose });
|
|
187
200
|
}
|
|
188
|
-
|
|
201
|
+
/*
|
|
202
|
+
name: string,
|
|
203
|
+
dir: string,
|
|
204
|
+
{ skipFormat = false } = {},
|
|
205
|
+
appId?: string,
|
|
206
|
+
editorOptions?: {
|
|
207
|
+
documentTypes: string[];
|
|
208
|
+
},
|
|
209
|
+
*/
|
|
210
|
+
export async function hygenGenerateDriveEditor(options) {
|
|
211
|
+
const { name, dir, appId, skipFormat, allowedDocumentTypes, isDragAndDropEnabled, } = options;
|
|
212
|
+
const allowedDocumentTypesString = JSON.stringify(allowedDocumentTypes?.split(",") ?? []);
|
|
189
213
|
// Generate the drive editor files
|
|
190
|
-
|
|
214
|
+
const args = [
|
|
215
|
+
"powerhouse",
|
|
216
|
+
"generate-drive-editor",
|
|
217
|
+
"--name",
|
|
218
|
+
name,
|
|
219
|
+
"--root-dir",
|
|
220
|
+
dir,
|
|
221
|
+
"--app-id",
|
|
222
|
+
appId,
|
|
223
|
+
"--allowed-document-types",
|
|
224
|
+
allowedDocumentTypesString,
|
|
225
|
+
"--is-drag-and-drop-enabled",
|
|
226
|
+
isDragAndDropEnabled ? "true" : "false",
|
|
227
|
+
];
|
|
228
|
+
await run(args, { skipFormat });
|
|
191
229
|
}
|
|
192
230
|
//# sourceMappingURL=hygen.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hygen.js","sourceRoot":"","sources":["../../../src/codegen/hygen.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"hygen.js","sourceRoot":"","sources":["../../../src/codegen/hygen.ts"],"names":[],"mappings":"AACA,OAAO,EACL,iBAAiB,EACjB,oBAAoB,GACrB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AACvC,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAE/C,MAAM,SAAS,GACb,MAAM,CAAC,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;AACtE,MAAM,gBAAgB,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,EAAE,WAAW,CAAC,CAAC;AAErE,MAAM,CAAC,KAAK,UAAU,GAAG,CACvB,IAAc,EACd,EAAE,KAAK,GAAG,K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AAC,CAAC,OAAO;KACxC,CAAC;IAEF,MAAM,GAAG,CAAC,IAAI,EAAE,EAAE,UAAU,EAAE,CAAC,CAAC;AAClC,CAAC"}
|
|
@@ -1,33 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export
|
|
4
|
-
export
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export declare function generate(config: PowerhouseConfig): Promise<void>;
|
|
8
|
-
export declare function generateFromFile(path: string, config: PowerhouseConfig, options?: CodegenOptions): Promise<void>;
|
|
9
|
-
/**
|
|
10
|
-
* Generates code from a DocumentModelDocument object directly.
|
|
11
|
-
*
|
|
12
|
-
* @remarks
|
|
13
|
-
* This function performs the same code generation as generateFromFile but takes
|
|
14
|
-
* a DocumentModelDocument object directly instead of loading from a file. This allows for
|
|
15
|
-
* programmatic code generation without file I/O.
|
|
16
|
-
*
|
|
17
|
-
* @param documentModelDocument - The DocumentModelDocument object containing the document model
|
|
18
|
-
* @param config - The PowerhouseConfig configuration object
|
|
19
|
-
* @param options - Optional configuration for generation behavior (verbose logging, etc.)
|
|
20
|
-
* @returns A promise that resolves when code generation is complete
|
|
21
|
-
*/
|
|
22
|
-
export declare function generateFromDocument(documentModelState: DocumentModelState, config: PowerhouseConfig, options?: CodegenOptions): Promise<void>;
|
|
23
|
-
export declare function generateEditor(name: string, documentTypes: string[], config: PowerhouseConfig): Promise<void>;
|
|
24
|
-
export declare function generateSubgraphFromDocumentModel(name: string, documentModel: DocumentModelState, config: PowerhouseConfig, options?: CodegenOptions): Promise<void>;
|
|
25
|
-
export declare function generateSubgraph(name: string, file: string | null, config: PowerhouseConfig, options?: CodegenOptions): Promise<void>;
|
|
26
|
-
export declare function generateProcessor(name: string, type: "analytics" | "relationalDb", documentTypes: string[], config: PowerhouseConfig): Promise<void>;
|
|
27
|
-
export type DocumentTypesMap = Record<string, {
|
|
28
|
-
name: string;
|
|
29
|
-
importPath: string;
|
|
30
|
-
}>;
|
|
31
|
-
export declare function generateDriveEditor(name: string, config: PowerhouseConfig): Promise<void>;
|
|
32
|
-
export declare function generateImportScript(name: string, config: PowerhouseConfig): Promise<void>;
|
|
1
|
+
export * from "./generate.js";
|
|
2
|
+
export * from "./graphql.js";
|
|
3
|
+
export * from "./hygen.js";
|
|
4
|
+
export * from "./kysely.js";
|
|
5
|
+
export * from "./types.js";
|
|
6
|
+
export * from "./utils.js";
|
|
33
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/codegen/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/codegen/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC"}
|
|
@@ -1,183 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import { loadDocumentModel } from "./utils.js";
|
|
8
|
-
export { generateDBSchema } from "./kysely.js";
|
|
9
|
-
function generateGraphqlSchema(documentModel) {
|
|
10
|
-
const spec = documentModel.specifications[documentModel.specifications.length - 1];
|
|
11
|
-
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
12
|
-
if (!spec) {
|
|
13
|
-
throw new Error(`No spec found for ${documentModel.id}`);
|
|
14
|
-
}
|
|
15
|
-
const { modules, state: { global, local }, } = spec;
|
|
16
|
-
const schemas = [
|
|
17
|
-
global.schema,
|
|
18
|
-
local.schema,
|
|
19
|
-
...modules
|
|
20
|
-
.map((module) => [
|
|
21
|
-
`# ${module.name}`,
|
|
22
|
-
...module.operations.map((op) => op.schema),
|
|
23
|
-
])
|
|
24
|
-
.flat()
|
|
25
|
-
.filter((schema) => schema && schema.length > 0),
|
|
26
|
-
];
|
|
27
|
-
return schemas.join("\n\n");
|
|
28
|
-
}
|
|
29
|
-
// returns map of document model id to document model name in pascal case and import path
|
|
30
|
-
async function getDocumentTypesMap(dir, pathOrigin = "../../") {
|
|
31
|
-
const documentTypesMap = {};
|
|
32
|
-
// add document types from provided dir
|
|
33
|
-
if (fs.existsSync(dir)) {
|
|
34
|
-
fs.readdirSync(dir, { withFileTypes: true })
|
|
35
|
-
.filter((dirent) => dirent.isDirectory())
|
|
36
|
-
.map((dirent) => dirent.name)
|
|
37
|
-
.forEach((name) => {
|
|
38
|
-
const specPath = resolve(dir, name, `${name}.json`);
|
|
39
|
-
if (!fs.existsSync(specPath)) {
|
|
40
|
-
return;
|
|
41
|
-
}
|
|
42
|
-
const specRaw = fs.readFileSync(specPath, "utf-8");
|
|
43
|
-
try {
|
|
44
|
-
const spec = JSON.parse(specRaw);
|
|
45
|
-
if (spec.id) {
|
|
46
|
-
documentTypesMap[spec.id] = {
|
|
47
|
-
name: pascalCase(name),
|
|
48
|
-
importPath: join(pathOrigin, dir, name),
|
|
49
|
-
};
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
catch {
|
|
53
|
-
console.error(`Failed to parse ${specPath}`);
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
}
|
|
57
|
-
// add documents from document-model-libs if lib is installed
|
|
58
|
-
try {
|
|
59
|
-
/* eslint-disable */
|
|
60
|
-
// @ts-ignore-error TS2307 this import is expected to fail if document-model-libs is not available
|
|
61
|
-
const documentModels = await import("document-model-libs/document-models");
|
|
62
|
-
Object.keys(documentModels).forEach((name) => {
|
|
63
|
-
const documentModel = documentModels[name];
|
|
64
|
-
documentTypesMap[documentModel.documentModel.id] = {
|
|
65
|
-
name,
|
|
66
|
-
importPath: `document-model-libs/${paramCase(name)}`,
|
|
67
|
-
};
|
|
68
|
-
});
|
|
69
|
-
/* eslint-enable */
|
|
70
|
-
}
|
|
71
|
-
catch {
|
|
72
|
-
/* document-model-libs is not available */
|
|
73
|
-
}
|
|
74
|
-
return documentTypesMap;
|
|
75
|
-
}
|
|
76
|
-
export async function generate(config) {
|
|
77
|
-
const { skipFormat, watch } = config;
|
|
78
|
-
await generateSchemas(config.documentModelsDir, { skipFormat, watch });
|
|
79
|
-
await generateAll(config.documentModelsDir, { skipFormat, watch });
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Generates code from a DocumentModelState.
|
|
83
|
-
*
|
|
84
|
-
* @remarks
|
|
85
|
-
* This is the core generation function that both generateFromFile and generateFromDocument
|
|
86
|
-
* use internally. It handles the actual code generation from a DocumentModelState object.
|
|
87
|
-
*
|
|
88
|
-
* @param documentModel - The DocumentModelState containing the document model specification
|
|
89
|
-
* @param config - The PowerhouseConfig configuration object
|
|
90
|
-
* @param filePath - Optional file path for generateSubgraph (null if not from file)
|
|
91
|
-
* @param options - Optional configuration for generation behavior
|
|
92
|
-
* @returns A promise that resolves when code generation is complete
|
|
93
|
-
*/
|
|
94
|
-
async function generateFromDocumentModel(documentModel, config, filePath, options = {}) {
|
|
95
|
-
// Derive verbose from config.logLevel if not explicitly provided
|
|
96
|
-
// Show hygen logs for verbose, debug, and info levels (default behavior before ts-morph)
|
|
97
|
-
const { verbose = config.logLevel === "verbose" ||
|
|
98
|
-
config.logLevel === "debug" ||
|
|
99
|
-
config.logLevel === "info", } = options;
|
|
100
|
-
const name = paramCase(documentModel.name);
|
|
101
|
-
// create document model folder and spec as json
|
|
102
|
-
fs.mkdirSync(join(config.documentModelsDir, name), { recursive: true });
|
|
103
|
-
fs.writeFileSync(join(config.documentModelsDir, name, `${name}.json`), JSON.stringify(documentModel, null, 4));
|
|
104
|
-
// bundle graphql schemas together
|
|
105
|
-
const schemaStr = [
|
|
106
|
-
typeDefs.join("\n"), // inject ph scalars
|
|
107
|
-
generateGraphqlSchema(documentModel),
|
|
108
|
-
].join("\n");
|
|
109
|
-
if (schemaStr) {
|
|
110
|
-
fs.writeFileSync(join(config.documentModelsDir, name, `schema.graphql`), schemaStr);
|
|
111
|
-
}
|
|
112
|
-
await generateSchema(name, config.documentModelsDir, {
|
|
113
|
-
skipFormat: config.skipFormat,
|
|
114
|
-
verbose,
|
|
115
|
-
});
|
|
116
|
-
await generateDocumentModel(documentModel, config.documentModelsDir, {
|
|
117
|
-
skipFormat: config.skipFormat,
|
|
118
|
-
verbose,
|
|
119
|
-
});
|
|
120
|
-
await generateSubgraph(name, filePath || null, config, { verbose });
|
|
121
|
-
}
|
|
122
|
-
export async function generateFromFile(path, config, options = {}) {
|
|
123
|
-
// load document model spec from file
|
|
124
|
-
const documentModel = await loadDocumentModel(path);
|
|
125
|
-
// delegate to shared generation function
|
|
126
|
-
await generateFromDocumentModel(documentModel, config, path, options);
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* Generates code from a DocumentModelDocument object directly.
|
|
130
|
-
*
|
|
131
|
-
* @remarks
|
|
132
|
-
* This function performs the same code generation as generateFromFile but takes
|
|
133
|
-
* a DocumentModelDocument object directly instead of loading from a file. This allows for
|
|
134
|
-
* programmatic code generation without file I/O.
|
|
135
|
-
*
|
|
136
|
-
* @param documentModelDocument - The DocumentModelDocument object containing the document model
|
|
137
|
-
* @param config - The PowerhouseConfig configuration object
|
|
138
|
-
* @param options - Optional configuration for generation behavior (verbose logging, etc.)
|
|
139
|
-
* @returns A promise that resolves when code generation is complete
|
|
140
|
-
*/
|
|
141
|
-
export async function generateFromDocument(documentModelState, config, options = {}) {
|
|
142
|
-
// delegate to shared generation function
|
|
143
|
-
await generateFromDocumentModel(documentModelState, config, null, options);
|
|
144
|
-
}
|
|
145
|
-
export async function generateEditor(name, documentTypes, config) {
|
|
146
|
-
const pathOrigin = "../../";
|
|
147
|
-
const { documentModelsDir, skipFormat } = config;
|
|
148
|
-
const documentTypesMap = await getDocumentTypesMap(documentModelsDir, pathOrigin);
|
|
149
|
-
const invalidType = documentTypes.find((type) => !Object.keys(documentTypesMap).includes(type));
|
|
150
|
-
if (invalidType) {
|
|
151
|
-
throw new Error(`Document model for ${invalidType} not found`);
|
|
152
|
-
}
|
|
153
|
-
return _generateEditor(name, documentTypes, documentTypesMap, config.editorsDir, config.documentModelsDir, { skipFormat });
|
|
154
|
-
}
|
|
155
|
-
export async function generateSubgraphFromDocumentModel(name, documentModel, config, options = {}) {
|
|
156
|
-
return _generateSubgraph(name, documentModel, config.subgraphsDir, {
|
|
157
|
-
skipFormat: config.skipFormat,
|
|
158
|
-
verbose: options.verbose,
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
export async function generateSubgraph(name, file, config, options = {}) {
|
|
162
|
-
return _generateSubgraph(name, file !== null ? await loadDocumentModel(file) : null, config.subgraphsDir, { skipFormat: config.skipFormat, verbose: options.verbose });
|
|
163
|
-
}
|
|
164
|
-
export async function generateProcessor(name, type, documentTypes, config) {
|
|
165
|
-
const { documentModelsDir, skipFormat } = config;
|
|
166
|
-
const documentTypesMap = await getDocumentTypesMap(documentModelsDir);
|
|
167
|
-
const invalidType = documentTypes.find((type) => !Object.keys(documentTypesMap).includes(type));
|
|
168
|
-
if (invalidType) {
|
|
169
|
-
throw new Error(`Document model for ${invalidType} not found`);
|
|
170
|
-
}
|
|
171
|
-
return _generateProcessor(name, documentTypes, documentTypesMap, config.processorsDir, config.documentModelsDir, type, { skipFormat });
|
|
172
|
-
}
|
|
173
|
-
export async function generateDriveEditor(name, config) {
|
|
174
|
-
return _generateDriveEditor(name, config.editorsDir, {
|
|
175
|
-
skipFormat: config.skipFormat,
|
|
176
|
-
});
|
|
177
|
-
}
|
|
178
|
-
export async function generateImportScript(name, config) {
|
|
179
|
-
return _generateImportScript(name, config.importScriptsDir, {
|
|
180
|
-
skipFormat: config.skipFormat,
|
|
181
|
-
});
|
|
182
|
-
}
|
|
1
|
+
export * from "./generate.js";
|
|
2
|
+
export * from "./graphql.js";
|
|
3
|
+
export * from "./hygen.js";
|
|
4
|
+
export * from "./kysely.js";
|
|
5
|
+
export * from "./types.js";
|
|
6
|
+
export * from "./utils.js";
|
|
183
7
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/codegen/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/codegen/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC;AAC7B,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/codegen/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,GAAG;IAC3B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,MAAM,CACnC,MAAM,EACN;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CACrC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/codegen/types.ts"],"names":[],"mappings":""}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import type { DocumentTypesMap } from "@powerhousedao/codegen";
|
|
2
|
+
import type { DocumentModelGlobalState } from "document-model";
|
|
3
|
+
export declare function loadDocumentModel(path: string): Promise<DocumentModelGlobalState>;
|
|
3
4
|
export declare function formatWithPrettierBeforeWrite(outputFile: string, content: string): Promise<string>;
|
|
5
|
+
/** returns map of document model id to document model name in pascal case and import path */
|
|
6
|
+
export declare function getDocumentTypesMap(dir: string, pathOrigin?: string): DocumentTypesMap;
|
|
4
7
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/codegen/utils.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/codegen/utils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAE/D,OAAO,KAAK,EAEV,wBAAwB,EACzB,MAAM,gBAAgB,CAAC;AAOxB,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,MAAM,GACX,OAAO,CAAC,wBAAwB,CAAC,CAyBnC;AAED,wBAAsB,6BAA6B,CACjD,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,mBAMhB;AAED,6FAA6F;AAC7F,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,MAAM,EACX,UAAU,SAAW,GACpB,gBAAgB,CAmClB"}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { pascalCase } from "change-case";
|
|
2
|
+
import { documentModelReducer } from "document-model";
|
|
3
|
+
import { baseLoadFromFile } from "document-model/node";
|
|
2
4
|
import fs from "node:fs";
|
|
5
|
+
import { join, resolve } from "node:path";
|
|
3
6
|
import { format } from "prettier";
|
|
4
7
|
export async function loadDocumentModel(path) {
|
|
5
8
|
let documentModel;
|
|
@@ -7,8 +10,8 @@ export async function loadDocumentModel(path) {
|
|
|
7
10
|
if (!path) {
|
|
8
11
|
throw new Error("Document model file not specified");
|
|
9
12
|
}
|
|
10
|
-
else if (path.endsWith(".zip")) {
|
|
11
|
-
const file = await
|
|
13
|
+
else if (path.endsWith(".zip") || path.endsWith(".phd")) {
|
|
14
|
+
const file = await baseLoadFromFile(path, documentModelReducer);
|
|
12
15
|
documentModel = file.state.global;
|
|
13
16
|
}
|
|
14
17
|
else if (path.endsWith(".json")) {
|
|
@@ -22,7 +25,7 @@ export async function loadDocumentModel(path) {
|
|
|
22
25
|
}
|
|
23
26
|
}
|
|
24
27
|
else {
|
|
25
|
-
throw new Error("File type not supported. Must be zip or json.");
|
|
28
|
+
throw new Error("File type not supported. Must be zip, phd, or json.");
|
|
26
29
|
}
|
|
27
30
|
return documentModel;
|
|
28
31
|
}
|
|
@@ -38,4 +41,39 @@ export async function formatWithPrettierBeforeWrite(outputFile, content) {
|
|
|
38
41
|
});
|
|
39
42
|
return modifiedContent;
|
|
40
43
|
}
|
|
44
|
+
/** returns map of document model id to document model name in pascal case and import path */
|
|
45
|
+
export function getDocumentTypesMap(dir, pathOrigin = "../../") {
|
|
46
|
+
const documentTypesMap = {
|
|
47
|
+
"powerhouse/document-model": {
|
|
48
|
+
name: "DocumentModel",
|
|
49
|
+
importPath: `document-model`,
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
// add document types from provided dir
|
|
53
|
+
if (fs.existsSync(dir)) {
|
|
54
|
+
fs.readdirSync(dir, { withFileTypes: true })
|
|
55
|
+
.filter((dirent) => dirent.isDirectory())
|
|
56
|
+
.map((dirent) => dirent.name)
|
|
57
|
+
.forEach((name) => {
|
|
58
|
+
const specPath = resolve(dir, name, `${name}.json`);
|
|
59
|
+
if (!fs.existsSync(specPath)) {
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
const specRaw = fs.readFileSync(specPath, "utf-8");
|
|
63
|
+
try {
|
|
64
|
+
const spec = JSON.parse(specRaw);
|
|
65
|
+
if (spec.id) {
|
|
66
|
+
documentTypesMap[spec.id] = {
|
|
67
|
+
name: pascalCase(name),
|
|
68
|
+
importPath: join(pathOrigin, dir, name, "index.js"),
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
console.error(`Failed to parse ${specPath}`);
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
return documentTypesMap;
|
|
78
|
+
}
|
|
41
79
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/codegen/utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/codegen/utils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAKzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACtD,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAElC,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,IAAY;IAEZ,IAAI,aAAuC,CAAC;IAC5C,IAAI,CAAC;QACH,IAAI,CAAC,IAAI,EAAE,CAAC;YACV,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;QACvD,CAAC;aAAM,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;YAC1D,MAAM,IAAI,GAAG,MAAM,gBAAgB,CAAC,IAAI,EAAE,oBAAoB,CAAC,CAAC;YAChE,aAAa,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;QACpC,CAAC;aAAM,IAAI,IAAI,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;YAClC,MAAM,IAAI,GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YAC5C,MAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAA0B,CAAC;YAC7D,IAAI,OAAO,IAAI,UAAU,EAAE,CAAC;gBAC1B,aAAa,GAAG,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC;YAC1C,CAAC;iBAAM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EAAE,CAAC;gBAC7B,OAAO;YACT,CAAC;YAED,MAAM,OAAO,GAAG,EAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;YACnD,IAAI,CAAC;gBACH,MAAM,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAA6B,CAAC;gBAC7D,IAAI,IAAI,CAAC,EAAE,EAAE,CAAC;oBACZ,gBAAgB,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG;wBAC1B,IAAI,EAAE,UAAU,CAAC,IAAI,CAAC;wBACtB,UAAU,EAAE,IAAI,CAAC,UAAU,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,CAAC;qBACpD,CAAC;gBACJ,CAAC;YACH,CAAC;YAAC,MAAM,CAAC;gBACP,OAAO,CAAC,KAAK,CAAC,mBAAmB,QAAQ,EAAE,CAAC,CAAC;YAC/C,CAAC;QACH,CAAC,CAAC,CAAC;IACP,CAAC;IAED,OAAO,gBAAgB,CAAC;AAC1B,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-project.d.ts","sourceRoot":"","sources":["../../../src/create-lib/create-project.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"create-project.d.ts","sourceRoot":"","sources":["../../../src/create-lib/create-project.ts"],"names":[],"mappings":"AAsCA,eAAO,MAAM,iBAAiB;;;;;;;;;;CAUpB,CAAC;AAEX,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,OAAO,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAqED,wBAAgB,YAAY,CAAC,IAAI,EAAE;IACjC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB,UAWA;AAUD,wBAAgB,OAAO,kBAQtB;AAED,wBAAsB,aAAa,CAAC,OAAO,EAAE,qBAAqB,iBAmDjE"}
|
|
@@ -1,10 +1,25 @@
|
|
|
1
|
-
import { parseArgs, promptDirectories } from "
|
|
2
|
-
import { getPackageManager } from "#utils/package-manager";
|
|
1
|
+
import { parseArgs, promptDirectories } from "@powerhousedao/codegen";
|
|
3
2
|
import { execSync } from "child_process";
|
|
4
3
|
import enquirer from "enquirer";
|
|
5
4
|
import fs from "node:fs";
|
|
6
5
|
import path from "path";
|
|
7
6
|
const BOILERPLATE_REPO = "https://github.com/powerhouse-inc/document-model-boilerplate.git";
|
|
7
|
+
const packageManagers = ["npm", "yarn", "pnpm", "bun"];
|
|
8
|
+
const defaultPackageManager = "npm";
|
|
9
|
+
function getPackageManager(userAgent) {
|
|
10
|
+
if (!userAgent) {
|
|
11
|
+
return defaultPackageManager;
|
|
12
|
+
}
|
|
13
|
+
const pkgSpec = userAgent.split(" ")[0];
|
|
14
|
+
const pkgSpecArr = pkgSpec.split("/");
|
|
15
|
+
const name = pkgSpecArr[0];
|
|
16
|
+
if (packageManagers.includes(name)) {
|
|
17
|
+
return name;
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
return defaultPackageManager;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
8
23
|
const envPackageManager = getPackageManager(process.env.npm_config_user_agent);
|
|
9
24
|
const defaultDirectories = {
|
|
10
25
|
documentModelsDir: "./document-models",
|