@powerhousedao/codegen 0.0.3 → 0.0.4
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/package.json +16 -3
- package/dist/cli.d.ts +0 -2
- package/dist/cli.js +0 -40
- package/dist/codegen/.hygen/templates/powerhouse/generate-document-model/index.d.ts +0 -26
- package/dist/codegen/.hygen/templates/powerhouse/generate-document-model/index.js +0 -43
- package/dist/codegen/.hygen/templates/powerhouse/generate-document-model-module/index.d.ts +0 -21
- package/dist/codegen/.hygen/templates/powerhouse/generate-document-model-module/index.js +0 -24
- package/dist/codegen/.hygen/templates/powerhouse/generate-editor/index.d.ts +0 -19
- package/dist/codegen/.hygen/templates/powerhouse/generate-editor/index.js +0 -15
- package/dist/codegen/graphql.d.ts +0 -8
- package/dist/codegen/graphql.js +0 -94
- package/dist/codegen/hygen.d.ts +0 -12
- package/dist/codegen/hygen.js +0 -98
- package/dist/codegen/index.d.ts +0 -5
- package/dist/codegen/index.js +0 -86
- package/dist/codegen/utils.d.ts +0 -2
- package/dist/codegen/utils.js +0 -37
- package/dist/create-lib/index.d.ts +0 -2
- package/dist/create-lib/index.js +0 -127
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -18
- package/dist/utils.d.ts +0 -27
- package/dist/utils.js +0 -91
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@powerhousedao/codegen",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.4",
|
|
4
4
|
"license": "AGPL-3.0-only",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -18,7 +18,10 @@
|
|
|
18
18
|
"build": "yarn clean && tsc && yarn copy-files",
|
|
19
19
|
"build:create-lib": "tsc --project src/create-lib/tsconfig.json",
|
|
20
20
|
"publish:create-lib": "yarn publish --cwd ./src/create-lib/",
|
|
21
|
-
"start": "ts-node src/cli.ts"
|
|
21
|
+
"start": "ts-node src/cli.ts",
|
|
22
|
+
"check-types": "tsc --noEmit",
|
|
23
|
+
"lint": "eslint . && yarn check-types",
|
|
24
|
+
"lint:fix": "eslint . --fix"
|
|
22
25
|
},
|
|
23
26
|
"dependencies": {
|
|
24
27
|
"@acaldas/graphql-codegen-typescript-validation-schema": "^0.12.3",
|
|
@@ -36,9 +39,19 @@
|
|
|
36
39
|
"typescript": "^5.3.3"
|
|
37
40
|
},
|
|
38
41
|
"devDependencies": {
|
|
42
|
+
"@commitlint/cli": "^18.4.4",
|
|
43
|
+
"@commitlint/config-conventional": "^18.4.4",
|
|
44
|
+
"@total-typescript/ts-reset": "^0.5.1",
|
|
45
|
+
"@typescript-eslint/eslint-plugin": "^6.19.0",
|
|
46
|
+
"@typescript-eslint/parser": "^6.19.0",
|
|
39
47
|
"copyfiles": "^2.4.1",
|
|
48
|
+
"eslint": "^8.56.0",
|
|
49
|
+
"eslint-config-prettier": "^9.1.0",
|
|
50
|
+
"eslint-plugin-prettier": "^5.1.3",
|
|
40
51
|
"graphql": "^16.8.1",
|
|
41
|
-
"
|
|
52
|
+
"husky": "^8.0.3",
|
|
53
|
+
"lint-staged": "^15.2.0",
|
|
54
|
+
"prettier": "^3.2.4",
|
|
42
55
|
"prettier-plugin-organize-imports": "^3.2.4",
|
|
43
56
|
"rimraf": "^5.0.5",
|
|
44
57
|
"ts-node": "^10.9.2"
|
package/dist/cli.d.ts
DELETED
package/dist/cli.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
#! /usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
const index_1 = require("./codegen/index");
|
|
5
|
-
const utils_1 = require("./utils");
|
|
6
|
-
async function parseCommand(argv) {
|
|
7
|
-
const args = (0, utils_1.parseArgs)(argv, {
|
|
8
|
-
'--editor': String,
|
|
9
|
-
'-e': '--editor',
|
|
10
|
-
'--document-types': String,
|
|
11
|
-
});
|
|
12
|
-
const editorName = args['--editor'];
|
|
13
|
-
return {
|
|
14
|
-
editor: !!editorName,
|
|
15
|
-
editorName,
|
|
16
|
-
documentTypes: args['--document-types'],
|
|
17
|
-
arg: args._,
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
async function main() {
|
|
21
|
-
const argv = process.argv.slice(2);
|
|
22
|
-
const baseConfig = (0, utils_1.getConfig)();
|
|
23
|
-
const argsConfig = (0, utils_1.parseConfig)(argv);
|
|
24
|
-
const config = { ...baseConfig, ...argsConfig };
|
|
25
|
-
if (config.interactive) {
|
|
26
|
-
const result = await (0, utils_1.promptDirectories)(config);
|
|
27
|
-
Object.assign(config, result);
|
|
28
|
-
}
|
|
29
|
-
const command = await parseCommand(argv);
|
|
30
|
-
if (command.editor) {
|
|
31
|
-
await (0, index_1.generateEditor)(command.editorName, command.documentTypes?.split(/[|,;]/g) ?? [], config);
|
|
32
|
-
}
|
|
33
|
-
else if (command.arg.length === 2) {
|
|
34
|
-
await (0, index_1.generateFromFile)(command.arg[1], config);
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
await (0, index_1.generate)(config);
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
main();
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
export type Args = {
|
|
2
|
-
documentModel: string;
|
|
3
|
-
rootDir: string;
|
|
4
|
-
};
|
|
5
|
-
declare const _default: {
|
|
6
|
-
params: ({ args }: {
|
|
7
|
-
args: Args;
|
|
8
|
-
}) => {
|
|
9
|
-
rootDir: string;
|
|
10
|
-
documentModel: string;
|
|
11
|
-
documentTypeId: string;
|
|
12
|
-
documentType: string;
|
|
13
|
-
extension: string;
|
|
14
|
-
modules: {
|
|
15
|
-
name: string;
|
|
16
|
-
__typename?: "Module" | undefined;
|
|
17
|
-
description: import("document-model/document-model").Maybe<string>;
|
|
18
|
-
id: string;
|
|
19
|
-
operations: import("document-model/document-model").Operation[];
|
|
20
|
-
}[];
|
|
21
|
-
initialGlobalState: string;
|
|
22
|
-
initialLocalState: string;
|
|
23
|
-
fileExtension: string;
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
export default _default;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const change_case_1 = require("change-case");
|
|
4
|
-
function documentModelToString(documentModel) {
|
|
5
|
-
return JSON.stringify({
|
|
6
|
-
...documentModel,
|
|
7
|
-
specifications: documentModel.specifications.map(s => ({
|
|
8
|
-
...s,
|
|
9
|
-
state: Object.keys(s.state).reduce((values, scope) => {
|
|
10
|
-
const state = s.state[scope];
|
|
11
|
-
return {
|
|
12
|
-
...values,
|
|
13
|
-
[scope]: {
|
|
14
|
-
...state,
|
|
15
|
-
// initial value has to be stringified twice
|
|
16
|
-
// as it is expected to be a string
|
|
17
|
-
initialValue: JSON.stringify(state.initialValue),
|
|
18
|
-
},
|
|
19
|
-
};
|
|
20
|
-
}, {}),
|
|
21
|
-
})),
|
|
22
|
-
}, null, 4);
|
|
23
|
-
}
|
|
24
|
-
exports.default = {
|
|
25
|
-
params: ({ args }) => {
|
|
26
|
-
const documentModel = JSON.parse(args.documentModel);
|
|
27
|
-
const latestSpec = documentModel.specifications[documentModel.specifications.length - 1];
|
|
28
|
-
return {
|
|
29
|
-
rootDir: args.rootDir,
|
|
30
|
-
documentModel: documentModelToString(documentModel),
|
|
31
|
-
documentTypeId: documentModel.id,
|
|
32
|
-
documentType: documentModel.name,
|
|
33
|
-
extension: documentModel.extension,
|
|
34
|
-
modules: latestSpec.modules.map(m => ({
|
|
35
|
-
...m,
|
|
36
|
-
name: (0, change_case_1.paramCase)(m.name),
|
|
37
|
-
})),
|
|
38
|
-
initialGlobalState: latestSpec.state.global.initialValue,
|
|
39
|
-
initialLocalState: latestSpec.state.local.initialValue ?? "{}",
|
|
40
|
-
fileExtension: documentModel.extension,
|
|
41
|
-
};
|
|
42
|
-
},
|
|
43
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { Args } from '../generate-document-model';
|
|
2
|
-
type ModuleArgs = Args & {
|
|
3
|
-
module: string;
|
|
4
|
-
};
|
|
5
|
-
declare const _default: {
|
|
6
|
-
params: ({ args }: {
|
|
7
|
-
args: ModuleArgs;
|
|
8
|
-
}) => {
|
|
9
|
-
rootDir: string;
|
|
10
|
-
documentType: string;
|
|
11
|
-
module: string;
|
|
12
|
-
actions: {
|
|
13
|
-
name: import("document-model/document-model").Maybe<string>;
|
|
14
|
-
hasInput: boolean;
|
|
15
|
-
hasAttachment: boolean | undefined;
|
|
16
|
-
scope: import("document-model/document").OperationScope;
|
|
17
|
-
state: string;
|
|
18
|
-
}[];
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
export default _default;
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const change_case_1 = require("change-case");
|
|
4
|
-
exports.default = {
|
|
5
|
-
params: ({ args }) => {
|
|
6
|
-
const documentModel = JSON.parse(args.documentModel);
|
|
7
|
-
const latestSpec = documentModel.specifications[documentModel.specifications.length - 1];
|
|
8
|
-
const filteredModules = latestSpec.modules.filter(m => m.name === args.module);
|
|
9
|
-
return {
|
|
10
|
-
rootDir: args.rootDir,
|
|
11
|
-
documentType: documentModel.name,
|
|
12
|
-
module: (0, change_case_1.paramCase)(args.module),
|
|
13
|
-
actions: filteredModules.length > 0
|
|
14
|
-
? filteredModules[0].operations.map(a => ({
|
|
15
|
-
name: a.name,
|
|
16
|
-
hasInput: a.schema !== null,
|
|
17
|
-
hasAttachment: a.schema?.includes(': Attachment'),
|
|
18
|
-
scope: a.scope || 'global',
|
|
19
|
-
state: a.scope === 'global' ? '' : a.scope, // the state this action affects
|
|
20
|
-
}))
|
|
21
|
-
: [],
|
|
22
|
-
};
|
|
23
|
-
},
|
|
24
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export type Args = {
|
|
2
|
-
name: string;
|
|
3
|
-
rootDir: string;
|
|
4
|
-
documentModelsDir: string;
|
|
5
|
-
documentTypes: string;
|
|
6
|
-
documentTypesMap: string;
|
|
7
|
-
};
|
|
8
|
-
declare const _default: {
|
|
9
|
-
params: ({ args }: {
|
|
10
|
-
args: Args;
|
|
11
|
-
}) => {
|
|
12
|
-
rootDir: string;
|
|
13
|
-
documentModelsDir: string;
|
|
14
|
-
name: string;
|
|
15
|
-
documentTypes: string[];
|
|
16
|
-
documentTypesMap: any;
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
export default _default;
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.default = {
|
|
4
|
-
params: ({ args }) => {
|
|
5
|
-
return {
|
|
6
|
-
rootDir: args.rootDir,
|
|
7
|
-
documentModelsDir: args.documentModelsDir,
|
|
8
|
-
name: args.name,
|
|
9
|
-
documentTypes: args.documentTypes
|
|
10
|
-
.split(',')
|
|
11
|
-
.filter(type => type !== ''),
|
|
12
|
-
documentTypesMap: JSON.parse(args.documentTypesMap),
|
|
13
|
-
};
|
|
14
|
-
},
|
|
15
|
-
};
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
export declare const generateSchema: (model: string, dir: string, { watch, format }?: {
|
|
2
|
-
watch?: boolean | undefined;
|
|
3
|
-
format?: boolean | undefined;
|
|
4
|
-
}) => Promise<any>;
|
|
5
|
-
export declare const generateSchemas: (dir: string, { watch, format }?: {
|
|
6
|
-
watch?: boolean | undefined;
|
|
7
|
-
format?: boolean | undefined;
|
|
8
|
-
}) => Promise<any>;
|
package/dist/codegen/graphql.js
DELETED
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateSchemas = exports.generateSchema = void 0;
|
|
4
|
-
const cli_1 = require("@graphql-codegen/cli");
|
|
5
|
-
const fs_1 = require("fs");
|
|
6
|
-
const getDirectories = (source) => (0, fs_1.readdirSync)(source, { withFileTypes: true })
|
|
7
|
-
.filter(dirent => dirent.isDirectory())
|
|
8
|
-
.map(dirent => dirent.name);
|
|
9
|
-
const tsConfig = {
|
|
10
|
-
strict: true,
|
|
11
|
-
strictScalars: true,
|
|
12
|
-
scalars: {
|
|
13
|
-
Unknown: 'unknown',
|
|
14
|
-
DateTime: 'string',
|
|
15
|
-
Attachment: 'string',
|
|
16
|
-
Address: '`${string}:0x${string}`',
|
|
17
|
-
},
|
|
18
|
-
enumsAsTypes: true,
|
|
19
|
-
allowEnumStringTypes: true,
|
|
20
|
-
avoidOptionals: {
|
|
21
|
-
field: true,
|
|
22
|
-
},
|
|
23
|
-
useIndexSignature: true,
|
|
24
|
-
noSchemaStitching: true,
|
|
25
|
-
skipTypename: true,
|
|
26
|
-
// maybeValue: "T | null | undefined",
|
|
27
|
-
inputMaybeValue: 'T | null | undefined',
|
|
28
|
-
};
|
|
29
|
-
function schemaConfig(name, dir) {
|
|
30
|
-
return {
|
|
31
|
-
[`${dir}/${name}/gen/schema/types.ts`]: {
|
|
32
|
-
schema: [
|
|
33
|
-
{
|
|
34
|
-
[`${dir}/${name}/schema.graphql`]: {
|
|
35
|
-
skipGraphQLImport: false,
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
],
|
|
39
|
-
plugins: ['typescript'],
|
|
40
|
-
config: tsConfig,
|
|
41
|
-
},
|
|
42
|
-
[`${dir}/${name}/gen/schema/zod.ts`]: {
|
|
43
|
-
schema: `${dir}/${name}/schema.graphql`,
|
|
44
|
-
plugins: ['@acaldas/graphql-codegen-typescript-validation-schema'],
|
|
45
|
-
config: {
|
|
46
|
-
importFrom: `./types`,
|
|
47
|
-
schema: 'zod',
|
|
48
|
-
...tsConfig,
|
|
49
|
-
scalarSchemas: {
|
|
50
|
-
Unknown: 'z.unknown()',
|
|
51
|
-
DateTime: 'z.string().datetime()',
|
|
52
|
-
Attachment: 'z.string()',
|
|
53
|
-
Address: 'z.custom<`${string}:0x${string}`>((val) => /^[a-zA-Z0-9]+:0x[a-fA-F0-9]{40}$/.test(val as string))',
|
|
54
|
-
},
|
|
55
|
-
directives: {
|
|
56
|
-
equals: {
|
|
57
|
-
value: ['regex', '/^$1$/'],
|
|
58
|
-
},
|
|
59
|
-
},
|
|
60
|
-
withObjectType: true,
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
};
|
|
64
|
-
}
|
|
65
|
-
const generateSchema = (model, dir, { watch = false, format = false } = {}) => {
|
|
66
|
-
const documentModelConfig = schemaConfig(model, dir);
|
|
67
|
-
const config = {
|
|
68
|
-
overwrite: true,
|
|
69
|
-
generates: documentModelConfig,
|
|
70
|
-
watch,
|
|
71
|
-
hooks: {
|
|
72
|
-
afterOneFileWrite: format ? ['prettier --ignore-path --write'] : [],
|
|
73
|
-
},
|
|
74
|
-
};
|
|
75
|
-
return (0, cli_1.generate)(config, true);
|
|
76
|
-
};
|
|
77
|
-
exports.generateSchema = generateSchema;
|
|
78
|
-
const generateSchemas = (dir, { watch = false, format = false } = {}) => {
|
|
79
|
-
const documentModels = getDirectories(dir);
|
|
80
|
-
const documentModelConfigs = documentModels.reduce((obj, model) => ({
|
|
81
|
-
...obj,
|
|
82
|
-
...schemaConfig(model, dir),
|
|
83
|
-
}), {});
|
|
84
|
-
const config = {
|
|
85
|
-
overwrite: true,
|
|
86
|
-
generates: documentModelConfigs,
|
|
87
|
-
watch,
|
|
88
|
-
hooks: {
|
|
89
|
-
afterOneFileWrite: format ? ['prettier --ignore-path --write'] : [],
|
|
90
|
-
},
|
|
91
|
-
};
|
|
92
|
-
return (0, cli_1.generate)(config, true);
|
|
93
|
-
};
|
|
94
|
-
exports.generateSchemas = generateSchemas;
|
package/dist/codegen/hygen.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { DocumentModel } from 'document-model';
|
|
2
|
-
export declare function generateAll(dir: string, { watch, format }?: {
|
|
3
|
-
watch?: boolean | undefined;
|
|
4
|
-
format?: boolean | undefined;
|
|
5
|
-
}): Promise<void>;
|
|
6
|
-
export declare function generateDocumentModel(documentModel: DocumentModel.DocumentModelState, dir: string, { watch, format }?: {
|
|
7
|
-
watch?: boolean | undefined;
|
|
8
|
-
format?: boolean | undefined;
|
|
9
|
-
}): Promise<void>;
|
|
10
|
-
export declare function generateEditor(name: string, documentTypes: string[], documentTypesMap: Record<string, string>, dir: string, documentModelsDir: string, { format }?: {
|
|
11
|
-
format?: boolean | undefined;
|
|
12
|
-
}): Promise<void>;
|
package/dist/codegen/hygen.js
DELETED
|
@@ -1,98 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.generateEditor = exports.generateDocumentModel = exports.generateAll = void 0;
|
|
7
|
-
const hygen_1 = require("hygen");
|
|
8
|
-
const path_1 = __importDefault(require("path"));
|
|
9
|
-
const fs_1 = __importDefault(require("fs"));
|
|
10
|
-
const utils_1 = require("./utils");
|
|
11
|
-
const logger = new hygen_1.Logger(console.log.bind(console));
|
|
12
|
-
const defaultTemplates = path_1.default.join(__dirname, '.hygen', 'templates');
|
|
13
|
-
async function run(args, { watch = false, format = false } = {}) {
|
|
14
|
-
const result = await (0, hygen_1.runner)(args, {
|
|
15
|
-
templates: defaultTemplates,
|
|
16
|
-
cwd: process.cwd(),
|
|
17
|
-
logger,
|
|
18
|
-
createPrompter: () => {
|
|
19
|
-
return require('enquirer');
|
|
20
|
-
},
|
|
21
|
-
exec: (action, body) => {
|
|
22
|
-
const opts = body && body.length > 0 ? { input: body } : {};
|
|
23
|
-
return require('execa').shell(action, opts);
|
|
24
|
-
},
|
|
25
|
-
debug: !!process.env.DEBUG,
|
|
26
|
-
});
|
|
27
|
-
if (format) {
|
|
28
|
-
const execa = await import('execa');
|
|
29
|
-
result.actions
|
|
30
|
-
.filter(action => ['added', 'inject'].includes(action.status))
|
|
31
|
-
.forEach(action => {
|
|
32
|
-
execa.$ `prettier --ignore-path --write ${action.subject.replace('.', process.cwd())}`;
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
return result;
|
|
36
|
-
}
|
|
37
|
-
async function generateAll(dir, { watch = false, format = false } = {}) {
|
|
38
|
-
const files = fs_1.default.readdirSync(dir, { withFileTypes: true });
|
|
39
|
-
for (const directory of files.filter(f => f.isDirectory())) {
|
|
40
|
-
const documentModelPath = path_1.default.join(dir, directory.name, `${directory.name}.json`);
|
|
41
|
-
if (!fs_1.default.existsSync(documentModelPath)) {
|
|
42
|
-
continue;
|
|
43
|
-
}
|
|
44
|
-
try {
|
|
45
|
-
const documentModel = await (0, utils_1.loadDocumentModel)(documentModelPath);
|
|
46
|
-
await generateDocumentModel(documentModel, dir, { watch, format });
|
|
47
|
-
}
|
|
48
|
-
catch (error) {
|
|
49
|
-
console.error(directory.name, error);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
exports.generateAll = generateAll;
|
|
54
|
-
async function generateDocumentModel(documentModel, dir, { watch = false, format = false } = {}) {
|
|
55
|
-
// Generate the singular files for the document model logic
|
|
56
|
-
await run([
|
|
57
|
-
'powerhouse',
|
|
58
|
-
'generate-document-model',
|
|
59
|
-
'--document-model',
|
|
60
|
-
JSON.stringify(documentModel),
|
|
61
|
-
'--root-dir',
|
|
62
|
-
dir,
|
|
63
|
-
], { watch, format });
|
|
64
|
-
// Generate the module-specific files for the document model logic
|
|
65
|
-
const latestSpec = documentModel.specifications[documentModel.specifications.length - 1];
|
|
66
|
-
const modules = latestSpec.modules.map(m => m.name);
|
|
67
|
-
for (let i = 0; i < modules.length; i++) {
|
|
68
|
-
await run([
|
|
69
|
-
'powerhouse',
|
|
70
|
-
'generate-document-model-module',
|
|
71
|
-
'--document-model',
|
|
72
|
-
JSON.stringify(documentModel),
|
|
73
|
-
'--root-dir',
|
|
74
|
-
dir,
|
|
75
|
-
'--module',
|
|
76
|
-
modules[i],
|
|
77
|
-
], { watch, format });
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
exports.generateDocumentModel = generateDocumentModel;
|
|
81
|
-
async function generateEditor(name, documentTypes, documentTypesMap, dir, documentModelsDir, { format = false } = {}) {
|
|
82
|
-
// Generate the singular files for the document model logic
|
|
83
|
-
await run([
|
|
84
|
-
'powerhouse',
|
|
85
|
-
'generate-editor',
|
|
86
|
-
'--name',
|
|
87
|
-
name,
|
|
88
|
-
'--root-dir',
|
|
89
|
-
dir,
|
|
90
|
-
'--document-types',
|
|
91
|
-
documentTypes.join(','),
|
|
92
|
-
'--document-types-map',
|
|
93
|
-
JSON.stringify(documentTypesMap),
|
|
94
|
-
'--document-models-dir',
|
|
95
|
-
documentModelsDir,
|
|
96
|
-
], { format });
|
|
97
|
-
}
|
|
98
|
-
exports.generateEditor = generateEditor;
|
package/dist/codegen/index.d.ts
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
#! /usr/bin/env node
|
|
2
|
-
import type { PowerhouseConfig } from '../utils';
|
|
3
|
-
export declare function generate(config: PowerhouseConfig): Promise<void>;
|
|
4
|
-
export declare function generateFromFile(path: string, config: PowerhouseConfig): Promise<void>;
|
|
5
|
-
export declare function generateEditor(name: string, documentTypes: string[], config: PowerhouseConfig): Promise<void>;
|
package/dist/codegen/index.js
DELETED
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
#! /usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
-
};
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.generateEditor = exports.generateFromFile = exports.generate = void 0;
|
|
8
|
-
const hygen_1 = require("./hygen");
|
|
9
|
-
const graphql_1 = require("./graphql");
|
|
10
|
-
const fs_1 = __importDefault(require("fs"));
|
|
11
|
-
const path_1 = require("path");
|
|
12
|
-
const change_case_1 = require("change-case");
|
|
13
|
-
const utils_1 = require("./utils");
|
|
14
|
-
function generateGraphqlSchema(documentModel) {
|
|
15
|
-
const spec = documentModel.specifications[documentModel.specifications.length - 1];
|
|
16
|
-
if (!spec) {
|
|
17
|
-
console.log(`No spec found for ${documentModel.id}`);
|
|
18
|
-
return;
|
|
19
|
-
}
|
|
20
|
-
const { modules, state: { global, local }, } = spec;
|
|
21
|
-
const schemas = [
|
|
22
|
-
global.schema,
|
|
23
|
-
local.schema,
|
|
24
|
-
...modules
|
|
25
|
-
.map(module => [
|
|
26
|
-
`# ${module.name}`,
|
|
27
|
-
...module.operations.map(op => op.schema),
|
|
28
|
-
])
|
|
29
|
-
.flat()
|
|
30
|
-
.filter(schema => schema && schema.length > 0),
|
|
31
|
-
];
|
|
32
|
-
return schemas.join('\n\n');
|
|
33
|
-
}
|
|
34
|
-
function getDocumentTypesMap(dir) {
|
|
35
|
-
const documentTypesMap = {};
|
|
36
|
-
fs_1.default.readdirSync(dir, { withFileTypes: true })
|
|
37
|
-
.filter(dirent => dirent.isDirectory())
|
|
38
|
-
.map(dirent => dirent.name)
|
|
39
|
-
.forEach(name => {
|
|
40
|
-
const specPath = (0, path_1.resolve)(dir, name, `${name}.json`);
|
|
41
|
-
if (!fs_1.default.existsSync(specPath)) {
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
const specRaw = fs_1.default.readFileSync(specPath, 'utf-8');
|
|
45
|
-
try {
|
|
46
|
-
const spec = JSON.parse(specRaw);
|
|
47
|
-
if (spec.id) {
|
|
48
|
-
documentTypesMap[spec.id] = (0, change_case_1.pascalCase)(name);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
catch { }
|
|
52
|
-
});
|
|
53
|
-
return documentTypesMap;
|
|
54
|
-
}
|
|
55
|
-
async function generate(config) {
|
|
56
|
-
const { format, watch } = config;
|
|
57
|
-
await (0, graphql_1.generateSchemas)(config.documentModelsDir, { format, watch });
|
|
58
|
-
await (0, hygen_1.generateAll)(config.documentModelsDir, { format, watch });
|
|
59
|
-
}
|
|
60
|
-
exports.generate = generate;
|
|
61
|
-
async function generateFromFile(path, config) {
|
|
62
|
-
// load document model spec from file
|
|
63
|
-
const documentModel = await (0, utils_1.loadDocumentModel)(path);
|
|
64
|
-
const name = (0, change_case_1.paramCase)(documentModel.name);
|
|
65
|
-
// create document model folder and spec as json
|
|
66
|
-
fs_1.default.mkdirSync((0, path_1.join)(config.documentModelsDir, name), { recursive: true });
|
|
67
|
-
fs_1.default.writeFileSync((0, path_1.join)(config.documentModelsDir, name, `${name}.json`), JSON.stringify(documentModel, null, 4));
|
|
68
|
-
// bundle graphql schemas together
|
|
69
|
-
const schemaStr = generateGraphqlSchema(documentModel);
|
|
70
|
-
if (schemaStr) {
|
|
71
|
-
fs_1.default.writeFileSync((0, path_1.join)(config.documentModelsDir, name, `schema.graphql`), schemaStr);
|
|
72
|
-
}
|
|
73
|
-
await (0, graphql_1.generateSchema)(name, config.documentModelsDir, config);
|
|
74
|
-
await (0, hygen_1.generateDocumentModel)(documentModel, config.documentModelsDir, config);
|
|
75
|
-
}
|
|
76
|
-
exports.generateFromFile = generateFromFile;
|
|
77
|
-
async function generateEditor(name, documentTypes, config) {
|
|
78
|
-
const { documentModelsDir, format } = config;
|
|
79
|
-
const docummentTypesMap = getDocumentTypesMap(documentModelsDir);
|
|
80
|
-
let invalidType = documentTypes.find(type => !Object.keys(docummentTypesMap).includes(type));
|
|
81
|
-
if (invalidType) {
|
|
82
|
-
throw new Error(`Document model for ${invalidType} not found`);
|
|
83
|
-
}
|
|
84
|
-
return (0, hygen_1.generateEditor)(name, documentTypes, docummentTypesMap, config.editorsDir, config.documentModelsDir, { format });
|
|
85
|
-
}
|
|
86
|
-
exports.generateEditor = generateEditor;
|
package/dist/codegen/utils.d.ts
DELETED
package/dist/codegen/utils.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.loadDocumentModel = void 0;
|
|
7
|
-
const document_model_1 = require("document-model/document-model");
|
|
8
|
-
const fs_1 = __importDefault(require("fs"));
|
|
9
|
-
async function loadDocumentModel(path) {
|
|
10
|
-
let documentModel;
|
|
11
|
-
try {
|
|
12
|
-
if (!path) {
|
|
13
|
-
throw new Error('Document model file not specified');
|
|
14
|
-
}
|
|
15
|
-
else if (path.endsWith('.zip')) {
|
|
16
|
-
const file = await document_model_1.utils.loadFromFile(path);
|
|
17
|
-
documentModel = file.state.global;
|
|
18
|
-
}
|
|
19
|
-
else if (path.endsWith('.json')) {
|
|
20
|
-
const data = fs_1.default.readFileSync(path, 'utf-8');
|
|
21
|
-
const document = JSON.parse(data);
|
|
22
|
-
// z.DocumentModelStateSchema().parse(document);
|
|
23
|
-
documentModel = document;
|
|
24
|
-
}
|
|
25
|
-
else {
|
|
26
|
-
throw new Error('File type not supported. Must be zip or json.');
|
|
27
|
-
}
|
|
28
|
-
return documentModel;
|
|
29
|
-
}
|
|
30
|
-
catch (error) {
|
|
31
|
-
// @ts-ignore
|
|
32
|
-
throw error.code === 'MODULE_NOT_FOUND'
|
|
33
|
-
? new Error(`Document model not found.`)
|
|
34
|
-
: error;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
exports.loadDocumentModel = loadDocumentModel;
|
package/dist/create-lib/index.js
DELETED
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
#! /usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
4
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
5
|
-
};
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
const path_1 = __importDefault(require("path"));
|
|
8
|
-
const util_1 = __importDefault(require("util"));
|
|
9
|
-
const fs_1 = __importDefault(require("fs"));
|
|
10
|
-
const child_process_1 = require("child_process");
|
|
11
|
-
const utils_1 = require("../utils");
|
|
12
|
-
const enquirer_1 = require("enquirer");
|
|
13
|
-
const exec = util_1.default.promisify(child_process_1.exec);
|
|
14
|
-
const BOILERPLATE_REPO = 'https://github.com/powerhouse-inc/document-model-boilerplate.git';
|
|
15
|
-
function isUsingYarn() {
|
|
16
|
-
return (process.env.npm_config_user_agent || '').indexOf('yarn') === 0;
|
|
17
|
-
}
|
|
18
|
-
function buildPackageJson(appPath, projectName) {
|
|
19
|
-
const packageJson = JSON.parse(fs_1.default.readFileSync(path_1.default.join(appPath, 'package.json'), 'utf-8'));
|
|
20
|
-
const newPackage = {
|
|
21
|
-
...packageJson,
|
|
22
|
-
name: projectName,
|
|
23
|
-
version: '1.0.0',
|
|
24
|
-
description: '',
|
|
25
|
-
};
|
|
26
|
-
fs_1.default.writeFileSync(path_1.default.join(appPath, 'package.json'), JSON.stringify(newPackage, null, 2), 'utf8');
|
|
27
|
-
}
|
|
28
|
-
function buildPowerhouseConfig(appPath, documentModelsDir, editorsDir) {
|
|
29
|
-
const filePath = path_1.default.join(appPath, 'powerhouse.config.json');
|
|
30
|
-
const packageJson = JSON.parse(fs_1.default.readFileSync(filePath, 'utf-8'));
|
|
31
|
-
const newPackage = {
|
|
32
|
-
...packageJson,
|
|
33
|
-
documentModelsDir,
|
|
34
|
-
editorsDir,
|
|
35
|
-
};
|
|
36
|
-
fs_1.default.writeFileSync(filePath, JSON.stringify(newPackage, null, 2), 'utf8');
|
|
37
|
-
}
|
|
38
|
-
function buildIndex(appPath, documentModelsDir, editorsDir) {
|
|
39
|
-
fs_1.default.writeFileSync(path_1.default.join(appPath, 'index.ts'), `import * as documentModelsExports from '${documentModelsDir}';
|
|
40
|
-
import * as editorsExports from '${editorsDir}';
|
|
41
|
-
|
|
42
|
-
export const documentModels = Object.values(documentModelsExports);
|
|
43
|
-
export const editors = Object.values(editorsExports);`, 'utf8');
|
|
44
|
-
}
|
|
45
|
-
async function runCmd(command) {
|
|
46
|
-
try {
|
|
47
|
-
const { stdout, stderr } = await exec(command);
|
|
48
|
-
console.log(stdout);
|
|
49
|
-
console.log(stderr);
|
|
50
|
-
}
|
|
51
|
-
catch (error) {
|
|
52
|
-
console.log('\x1b[31m', error, '\x1b[0m');
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
async function init() {
|
|
56
|
-
const args = (0, utils_1.parseArgs)(process.argv.slice(2), utils_1.configSpec);
|
|
57
|
-
// checks if a project name was provided
|
|
58
|
-
let projectName = args._.shift();
|
|
59
|
-
if (!projectName) {
|
|
60
|
-
const result = await (0, enquirer_1.prompt)([
|
|
61
|
-
{
|
|
62
|
-
type: 'input',
|
|
63
|
-
name: 'projectName',
|
|
64
|
-
message: 'What is the project name?',
|
|
65
|
-
required: true,
|
|
66
|
-
},
|
|
67
|
-
]);
|
|
68
|
-
if (!result.projectName) {
|
|
69
|
-
console.log('\x1b[31m', 'You have to provide name to your app.');
|
|
70
|
-
process.exit(1);
|
|
71
|
-
}
|
|
72
|
-
projectName = result.projectName;
|
|
73
|
-
}
|
|
74
|
-
const { documentModelsDir, editorsDir } = args['--interactive']
|
|
75
|
-
? await (0, utils_1.promptDirectories)()
|
|
76
|
-
: utils_1.DEFAULT_CONFIG;
|
|
77
|
-
const appPath = path_1.default.join(process.cwd(), projectName);
|
|
78
|
-
try {
|
|
79
|
-
fs_1.default.mkdirSync(appPath);
|
|
80
|
-
}
|
|
81
|
-
catch (err) {
|
|
82
|
-
if (err.code === 'EEXIST') {
|
|
83
|
-
console.log('\x1b[31m', `The folder ${projectName} already exists in the current directory, please give it another name.`, '\x1b[0m');
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
console.log(err);
|
|
87
|
-
}
|
|
88
|
-
process.exit(1);
|
|
89
|
-
}
|
|
90
|
-
createProject(projectName, documentModelsDir, editorsDir);
|
|
91
|
-
}
|
|
92
|
-
async function createProject(projectName, documentModelsDir, editorsDir) {
|
|
93
|
-
try {
|
|
94
|
-
const useYarn = isUsingYarn();
|
|
95
|
-
console.log('\x1b[33m', 'Downloading the project structure...', '\x1b[0m');
|
|
96
|
-
await runCmd(`git clone --depth 1 ${BOILERPLATE_REPO} ${projectName}`);
|
|
97
|
-
const appPath = path_1.default.join(process.cwd(), projectName);
|
|
98
|
-
process.chdir(appPath);
|
|
99
|
-
console.log('\x1b[34m', 'Installing dependencies...', '\x1b[0m');
|
|
100
|
-
await runCmd(useYarn ? 'yarn install' : 'npm install');
|
|
101
|
-
console.log();
|
|
102
|
-
fs_1.default.rmSync(path_1.default.join(appPath, './.git'), { recursive: true });
|
|
103
|
-
await runCmd('git init');
|
|
104
|
-
try {
|
|
105
|
-
fs_1.default.mkdirSync(path_1.default.join(appPath, documentModelsDir));
|
|
106
|
-
fs_1.default.mkdirSync(path_1.default.join(appPath, editorsDir));
|
|
107
|
-
}
|
|
108
|
-
catch (error) {
|
|
109
|
-
if (!error.message.includes('EEXIST')) {
|
|
110
|
-
throw error;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
buildPackageJson(appPath, projectName);
|
|
114
|
-
buildPowerhouseConfig(appPath, documentModelsDir, editorsDir);
|
|
115
|
-
buildIndex(appPath, documentModelsDir, editorsDir);
|
|
116
|
-
console.log('\x1b[32m', 'The installation is done!', '\x1b[0m');
|
|
117
|
-
console.log();
|
|
118
|
-
console.log('\x1b[34m', 'You can start by typing:');
|
|
119
|
-
console.log(` cd ${projectName}`);
|
|
120
|
-
console.log(useYarn ? ' yarn generate' : ' npm run generate', '\x1b[0m');
|
|
121
|
-
console.log();
|
|
122
|
-
}
|
|
123
|
-
catch (error) {
|
|
124
|
-
console.log(error);
|
|
125
|
-
}
|
|
126
|
-
}
|
|
127
|
-
init();
|
package/dist/index.d.ts
DELETED
package/dist/index.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./codegen"), exports);
|
|
18
|
-
__exportStar(require("./utils"), exports);
|
package/dist/utils.d.ts
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import arg from 'arg';
|
|
2
|
-
import { generateMock as zodGenerateMock } from '@anatine/zod-mock';
|
|
3
|
-
export type PowerhouseConfig = {
|
|
4
|
-
documentModelsDir: string;
|
|
5
|
-
editorsDir: string;
|
|
6
|
-
interactive?: boolean;
|
|
7
|
-
format?: boolean;
|
|
8
|
-
watch?: boolean;
|
|
9
|
-
};
|
|
10
|
-
export declare const DEFAULT_CONFIG: PowerhouseConfig;
|
|
11
|
-
export declare const configSpec: {
|
|
12
|
-
readonly '--document-models': StringConstructor;
|
|
13
|
-
readonly '--editors': StringConstructor;
|
|
14
|
-
readonly '--interactive': BooleanConstructor;
|
|
15
|
-
readonly '--format': BooleanConstructor;
|
|
16
|
-
readonly '--watch': BooleanConstructor;
|
|
17
|
-
readonly '-i': "--interactive";
|
|
18
|
-
readonly '-f': "--format";
|
|
19
|
-
readonly '-w': "--watch";
|
|
20
|
-
};
|
|
21
|
-
export declare function getConfig(): PowerhouseConfig;
|
|
22
|
-
export declare function writeConfig(config: PowerhouseConfig): void;
|
|
23
|
-
export declare function parseArgs<T extends arg.Spec>(argv: string[], spec: T): arg.Result<T>;
|
|
24
|
-
export declare function parseConfig(argv: string[]): Partial<PowerhouseConfig>;
|
|
25
|
-
export declare function promptDirectories(config?: PowerhouseConfig): Promise<Pick<PowerhouseConfig, "documentModelsDir" | "editorsDir">>;
|
|
26
|
-
export type generateMockTypeFn = typeof zodGenerateMock;
|
|
27
|
-
export declare const generateMock: generateMockTypeFn;
|
package/dist/utils.js
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.generateMock = exports.promptDirectories = exports.parseConfig = exports.parseArgs = exports.writeConfig = exports.getConfig = exports.configSpec = exports.DEFAULT_CONFIG = void 0;
|
|
7
|
-
const enquirer_1 = require("enquirer");
|
|
8
|
-
const arg_1 = __importDefault(require("arg"));
|
|
9
|
-
const node_fs_1 = require("node:fs");
|
|
10
|
-
const zod_mock_1 = require("@anatine/zod-mock");
|
|
11
|
-
const DEFAULT_DOCUMENT_MODELS_DIR = './document-models';
|
|
12
|
-
const DEFAULT_EDITORS_DIR = './editors';
|
|
13
|
-
exports.DEFAULT_CONFIG = {
|
|
14
|
-
documentModelsDir: DEFAULT_DOCUMENT_MODELS_DIR,
|
|
15
|
-
editorsDir: DEFAULT_EDITORS_DIR,
|
|
16
|
-
};
|
|
17
|
-
exports.configSpec = {
|
|
18
|
-
'--document-models': String,
|
|
19
|
-
'--editors': String,
|
|
20
|
-
'--interactive': Boolean,
|
|
21
|
-
'--format': Boolean,
|
|
22
|
-
'--watch': Boolean,
|
|
23
|
-
'-i': '--interactive',
|
|
24
|
-
'-f': '--format',
|
|
25
|
-
'-w': '--watch',
|
|
26
|
-
};
|
|
27
|
-
function getConfig() {
|
|
28
|
-
let config = { ...exports.DEFAULT_CONFIG };
|
|
29
|
-
try {
|
|
30
|
-
const configStr = (0, node_fs_1.readFileSync)('./powerhouse.config.json', 'utf-8');
|
|
31
|
-
let userConfig = JSON.parse(configStr);
|
|
32
|
-
config = { ...config, ...userConfig };
|
|
33
|
-
}
|
|
34
|
-
catch { }
|
|
35
|
-
return config;
|
|
36
|
-
}
|
|
37
|
-
exports.getConfig = getConfig;
|
|
38
|
-
function writeConfig(config) {
|
|
39
|
-
(0, node_fs_1.writeFileSync)('./powerhouse.config.json', JSON.stringify(config, null, 4));
|
|
40
|
-
}
|
|
41
|
-
exports.writeConfig = writeConfig;
|
|
42
|
-
function parseArgs(argv, spec) {
|
|
43
|
-
const args = (0, arg_1.default)(spec, {
|
|
44
|
-
permissive: true,
|
|
45
|
-
argv,
|
|
46
|
-
});
|
|
47
|
-
return args;
|
|
48
|
-
}
|
|
49
|
-
exports.parseArgs = parseArgs;
|
|
50
|
-
function parseConfig(argv) {
|
|
51
|
-
const config = {};
|
|
52
|
-
const args = parseArgs(argv, exports.configSpec);
|
|
53
|
-
if ('--document-models' in args) {
|
|
54
|
-
config.documentModelsDir = args['--document-models'];
|
|
55
|
-
}
|
|
56
|
-
if ('--editors' in args) {
|
|
57
|
-
config.editorsDir = args['--editors'];
|
|
58
|
-
}
|
|
59
|
-
if ('--format' in args) {
|
|
60
|
-
config.format = true;
|
|
61
|
-
}
|
|
62
|
-
if ('--interactive' in args) {
|
|
63
|
-
config.interactive = true;
|
|
64
|
-
}
|
|
65
|
-
if ('--watch' in args) {
|
|
66
|
-
config.watch = true;
|
|
67
|
-
}
|
|
68
|
-
return config;
|
|
69
|
-
}
|
|
70
|
-
exports.parseConfig = parseConfig;
|
|
71
|
-
async function promptDirectories(config = exports.DEFAULT_CONFIG) {
|
|
72
|
-
return (0, enquirer_1.prompt)([
|
|
73
|
-
{
|
|
74
|
-
type: 'input',
|
|
75
|
-
name: 'documentModelsDir',
|
|
76
|
-
message: 'Where to place the Document Models?',
|
|
77
|
-
initial: config.documentModelsDir,
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
type: 'input',
|
|
81
|
-
name: 'editorsDir',
|
|
82
|
-
message: 'Where to place the Editors?',
|
|
83
|
-
initial: config.editorsDir,
|
|
84
|
-
},
|
|
85
|
-
]);
|
|
86
|
-
}
|
|
87
|
-
exports.promptDirectories = promptDirectories;
|
|
88
|
-
const generateMock = (zodRef, options) => {
|
|
89
|
-
return (0, zod_mock_1.generateMock)(zodRef, options);
|
|
90
|
-
};
|
|
91
|
-
exports.generateMock = generateMock;
|