@powerhousedao/codegen 0.5.0 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.d.ts +0 -1
- package/dist/cli.js +45 -35
- package/dist/cli.js.map +1 -0
- package/dist/codegen/.hygen/templates/powerhouse/generate-document-model/index.js +64 -53
- package/dist/codegen/.hygen/templates/powerhouse/generate-document-model/index.js.map +1 -0
- package/dist/codegen/.hygen/templates/powerhouse/generate-document-model-module/index.js +31 -24
- package/dist/codegen/.hygen/templates/powerhouse/generate-document-model-module/index.js.map +1 -0
- package/dist/codegen/.hygen/templates/powerhouse/generate-editor/index.js +16 -14
- package/dist/codegen/.hygen/templates/powerhouse/generate-editor/index.js.map +1 -0
- package/dist/codegen/graphql.js +90 -82
- package/dist/codegen/graphql.js.map +1 -0
- package/dist/codegen/hygen.js +100 -86
- package/dist/codegen/hygen.js.map +1 -0
- package/dist/codegen/index.js +89 -77
- package/dist/codegen/index.js.map +1 -0
- package/dist/codegen/utils.js +30 -33
- package/dist/codegen/utils.js.map +1 -0
- package/dist/create-lib/command.js +17 -25
- package/dist/create-lib/command.js.map +1 -0
- package/dist/create-lib/index.js +8 -120
- package/dist/create-lib/index.js.map +1 -0
- package/dist/create-lib/init.js +136 -0
- package/dist/create-lib/init.js.map +1 -0
- package/dist/{create-lib/index.d.ts → create-lib.d.ts} +0 -1
- package/dist/graphql.d.ts +18 -0
- package/dist/hygen.d.ts +15 -0
- package/dist/index.d.ts +10 -2
- package/dist/index.js +21 -18
- package/dist/index.js.map +1 -0
- package/dist/utils/cli.js +80 -75
- package/dist/utils/cli.js.map +1 -0
- package/dist/utils/index.js +31 -18
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/mock.js +8 -5
- package/dist/utils/mock.js.map +1 -0
- package/dist/utils.d.ts +37 -0
- package/package.json +11 -5
- package/dist/codegen/.hygen/templates/powerhouse/generate-document-model/index.d.ts +0 -27
- package/dist/codegen/.hygen/templates/powerhouse/generate-document-model-module/index.d.ts +0 -23
- package/dist/codegen/.hygen/templates/powerhouse/generate-editor/index.d.ts +0 -19
- package/dist/codegen/graphql.d.ts +0 -8
- package/dist/codegen/hygen.d.ts +0 -12
- package/dist/codegen/index.d.ts +0 -5
- package/dist/codegen/utils.d.ts +0 -2
- package/dist/create-lib/command.d.ts +0 -4
- package/dist/utils/cli.d.ts +0 -24
- package/dist/utils/index.d.ts +0 -2
- package/dist/utils/mock.d.ts +0 -3
package/dist/create-lib/index.js
CHANGED
|
@@ -1,122 +1,10 @@
|
|
|
1
1
|
#! /usr/bin/env node
|
|
2
|
-
|
|
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 child_process_1 = require("child_process");
|
|
8
|
-
const enquirer_1 = require("enquirer");
|
|
9
|
-
const fs_1 = __importDefault(require("fs"));
|
|
10
|
-
const path_1 = __importDefault(require("path"));
|
|
11
|
-
const cli_1 = require("../utils/cli");
|
|
12
|
-
const command_1 = require("./command");
|
|
13
|
-
const BOILERPLATE_REPO = "https://github.com/powerhouse-inc/document-model-boilerplate.git";
|
|
14
|
-
const packageManager = (0, command_1.getPackageManager)(process.env.npm_config_user_agent);
|
|
15
|
-
const isNpm = packageManager === "npm";
|
|
16
|
-
function buildPackageJson(appPath, projectName) {
|
|
17
|
-
const packageJson = JSON.parse(fs_1.default.readFileSync(path_1.default.join(appPath, "package.json"), "utf-8"));
|
|
18
|
-
const newPackage = {
|
|
19
|
-
...packageJson,
|
|
20
|
-
name: projectName,
|
|
21
|
-
version: "1.0.0",
|
|
22
|
-
description: "",
|
|
23
|
-
};
|
|
24
|
-
fs_1.default.writeFileSync(path_1.default.join(appPath, "package.json"), JSON.stringify(newPackage, null, 2), "utf8");
|
|
25
|
-
}
|
|
26
|
-
function buildPowerhouseConfig(appPath, documentModelsDir, editorsDir) {
|
|
27
|
-
const filePath = path_1.default.join(appPath, "powerhouse.config.json");
|
|
28
|
-
const packageJson = JSON.parse(fs_1.default.readFileSync(filePath, "utf-8"));
|
|
29
|
-
const newPackage = {
|
|
30
|
-
...packageJson,
|
|
31
|
-
documentModelsDir,
|
|
32
|
-
editorsDir,
|
|
33
|
-
};
|
|
34
|
-
fs_1.default.writeFileSync(filePath, JSON.stringify(newPackage, null, 2), "utf8");
|
|
35
|
-
}
|
|
36
|
-
function buildIndex(appPath, documentModelsDir, editorsDir) {
|
|
37
|
-
fs_1.default.writeFileSync(path_1.default.join(appPath, "index.ts"), `import * as documentModelsExports from '${documentModelsDir}';
|
|
38
|
-
import * as editorsExports from '${editorsDir}';
|
|
2
|
+
'use strict';
|
|
39
3
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
catch (error) {
|
|
48
|
-
console.log("\x1b[31m", error, "\x1b[0m");
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
async function init() {
|
|
52
|
-
const args = (0, cli_1.parseArgs)(process.argv.slice(2), cli_1.configSpec);
|
|
53
|
-
// checks if a project name was provided
|
|
54
|
-
let projectName = args._.shift();
|
|
55
|
-
if (!projectName) {
|
|
56
|
-
const result = await (0, enquirer_1.prompt)([
|
|
57
|
-
{
|
|
58
|
-
type: "input",
|
|
59
|
-
name: "projectName",
|
|
60
|
-
message: "What is the project name?",
|
|
61
|
-
required: true,
|
|
62
|
-
},
|
|
63
|
-
]);
|
|
64
|
-
if (!result.projectName) {
|
|
65
|
-
console.log("\x1b[31m", "You have to provide name to your app.");
|
|
66
|
-
process.exit(1);
|
|
67
|
-
}
|
|
68
|
-
projectName = result.projectName;
|
|
69
|
-
}
|
|
70
|
-
const { documentModelsDir, editorsDir } = args["--interactive"]
|
|
71
|
-
? await (0, cli_1.promptDirectories)()
|
|
72
|
-
: cli_1.DEFAULT_CONFIG;
|
|
73
|
-
const appPath = path_1.default.join(process.cwd(), projectName);
|
|
74
|
-
try {
|
|
75
|
-
fs_1.default.mkdirSync(appPath);
|
|
76
|
-
}
|
|
77
|
-
catch (err) {
|
|
78
|
-
if (err.code === "EEXIST") {
|
|
79
|
-
console.log("\x1b[31m", `The folder ${projectName} already exists in the current directory, please give it another name.`, "\x1b[0m");
|
|
80
|
-
}
|
|
81
|
-
else {
|
|
82
|
-
console.log(err);
|
|
83
|
-
}
|
|
84
|
-
process.exit(1);
|
|
85
|
-
}
|
|
86
|
-
createProject(projectName, documentModelsDir, editorsDir);
|
|
87
|
-
}
|
|
88
|
-
function createProject(projectName, documentModelsDir, editorsDir) {
|
|
89
|
-
try {
|
|
90
|
-
console.log("\x1b[33m", "Downloading the project structure...", "\x1b[0m");
|
|
91
|
-
runCmd(`git clone --depth 1 ${BOILERPLATE_REPO} ${projectName}`);
|
|
92
|
-
const appPath = path_1.default.join(process.cwd(), projectName);
|
|
93
|
-
process.chdir(appPath);
|
|
94
|
-
console.log("\x1b[34m", "Installing dependencies...", "\x1b[0m");
|
|
95
|
-
runCmd(`${packageManager} install`);
|
|
96
|
-
fs_1.default.rmSync(path_1.default.join(appPath, "./.git"), { recursive: true });
|
|
97
|
-
runCmd("git init");
|
|
98
|
-
try {
|
|
99
|
-
fs_1.default.mkdirSync(path_1.default.join(appPath, documentModelsDir));
|
|
100
|
-
fs_1.default.writeFileSync(path_1.default.join(appPath, documentModelsDir, "index.ts"), "");
|
|
101
|
-
fs_1.default.mkdirSync(path_1.default.join(appPath, editorsDir));
|
|
102
|
-
fs_1.default.writeFileSync(path_1.default.join(appPath, editorsDir, "index.ts"), "");
|
|
103
|
-
}
|
|
104
|
-
catch (error) {
|
|
105
|
-
if (!error.message.includes("EEXIST")) {
|
|
106
|
-
throw error;
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
buildPackageJson(appPath, projectName);
|
|
110
|
-
buildPowerhouseConfig(appPath, documentModelsDir, editorsDir);
|
|
111
|
-
buildIndex(appPath, documentModelsDir, editorsDir);
|
|
112
|
-
console.log("\x1b[32m", "The installation is done!", "\x1b[0m");
|
|
113
|
-
console.log();
|
|
114
|
-
console.log("\x1b[34m", "You can start by typing:");
|
|
115
|
-
console.log(` cd ${projectName}`);
|
|
116
|
-
console.log(isNpm ? " npm run generate" : ` ${packageManager} generate`, "\x1b[0m");
|
|
117
|
-
}
|
|
118
|
-
catch (error) {
|
|
119
|
-
console.log(error);
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
init();
|
|
4
|
+
var init = require('./init');
|
|
5
|
+
|
|
6
|
+
init.init().catch((e) => {
|
|
7
|
+
throw e;
|
|
8
|
+
});
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/create-lib/index.ts"],"names":["init"],"mappings":";;;;;AAIAA,SAAK,EAAA,CAAE,KAAM,CAAA,CAAC,CAAe,KAAA;AAC3B,EAAM,MAAA,CAAA,CAAA;AACR,CAAC,CAAA","file":"index.js","sourcesContent":["#! /usr/bin/env node\n\nimport { init } from \"./init\";\n\ninit().catch((e: unknown) => {\n throw e;\n});\n"]}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var child_process = require('child_process');
|
|
4
|
+
var enquirer = require('enquirer');
|
|
5
|
+
var fs = require('node:fs');
|
|
6
|
+
var path = require('path');
|
|
7
|
+
var cli = require('../utils/cli');
|
|
8
|
+
var command = require('./command');
|
|
9
|
+
|
|
10
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
11
|
+
|
|
12
|
+
var fs__default = /*#__PURE__*/_interopDefault(fs);
|
|
13
|
+
var path__default = /*#__PURE__*/_interopDefault(path);
|
|
14
|
+
|
|
15
|
+
const BOILERPLATE_REPO = "https://github.com/powerhouse-inc/document-model-boilerplate.git";
|
|
16
|
+
const packageManager = command.getPackageManager(process.env.npm_config_user_agent);
|
|
17
|
+
const isNpm = packageManager === "npm";
|
|
18
|
+
function buildPackageJson(appPath, projectName) {
|
|
19
|
+
const packageJson = JSON.parse(
|
|
20
|
+
fs__default.default.readFileSync(path__default.default.join(appPath, "package.json"), "utf-8")
|
|
21
|
+
);
|
|
22
|
+
const newPackage = {
|
|
23
|
+
...packageJson,
|
|
24
|
+
name: projectName,
|
|
25
|
+
version: "1.0.0",
|
|
26
|
+
description: ""
|
|
27
|
+
};
|
|
28
|
+
fs__default.default.writeFileSync(
|
|
29
|
+
path__default.default.join(appPath, "package.json"),
|
|
30
|
+
JSON.stringify(newPackage, null, 2),
|
|
31
|
+
"utf8"
|
|
32
|
+
);
|
|
33
|
+
}
|
|
34
|
+
function buildPowerhouseConfig(appPath, documentModelsDir, editorsDir) {
|
|
35
|
+
const filePath = path__default.default.join(appPath, "powerhouse.config.json");
|
|
36
|
+
const packageJson = JSON.parse(fs__default.default.readFileSync(filePath, "utf-8"));
|
|
37
|
+
const newPackage = {
|
|
38
|
+
...packageJson,
|
|
39
|
+
documentModelsDir,
|
|
40
|
+
editorsDir
|
|
41
|
+
};
|
|
42
|
+
fs__default.default.writeFileSync(filePath, JSON.stringify(newPackage, null, 2), "utf8");
|
|
43
|
+
}
|
|
44
|
+
function buildIndex(appPath, documentModelsDir, editorsDir) {
|
|
45
|
+
fs__default.default.writeFileSync(
|
|
46
|
+
path__default.default.join(appPath, "index.ts"),
|
|
47
|
+
`import * as documentModelsExports from '${documentModelsDir}';
|
|
48
|
+
import * as editorsExports from '${editorsDir}';
|
|
49
|
+
|
|
50
|
+
export const documentModels = Object.values(documentModelsExports);
|
|
51
|
+
export const editors = Object.values(editorsExports);`,
|
|
52
|
+
"utf8"
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
function runCmd(command) {
|
|
56
|
+
try {
|
|
57
|
+
child_process.execSync(command, { stdio: "inherit" });
|
|
58
|
+
} catch (error) {
|
|
59
|
+
console.log("\x1B[31m", error, "\x1B[0m");
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
async function init(_args) {
|
|
63
|
+
const args = _args || cli.parseArgs(process.argv.slice(2), cli.configSpec);
|
|
64
|
+
let projectName = args._.shift();
|
|
65
|
+
if (!projectName) {
|
|
66
|
+
const result = await enquirer.prompt([
|
|
67
|
+
{
|
|
68
|
+
type: "input",
|
|
69
|
+
name: "projectName",
|
|
70
|
+
message: "What is the project name?",
|
|
71
|
+
required: true
|
|
72
|
+
}
|
|
73
|
+
]);
|
|
74
|
+
if (!result.projectName) {
|
|
75
|
+
console.log("\x1B[31m", "You have to provide name to your app.");
|
|
76
|
+
process.exit(1);
|
|
77
|
+
}
|
|
78
|
+
projectName = result.projectName;
|
|
79
|
+
}
|
|
80
|
+
const { documentModelsDir, editorsDir } = args["--interactive"] ? await cli.promptDirectories() : cli.DEFAULT_CONFIG;
|
|
81
|
+
const appPath = path__default.default.join(process.cwd(), projectName);
|
|
82
|
+
try {
|
|
83
|
+
fs__default.default.mkdirSync(appPath);
|
|
84
|
+
} catch (err) {
|
|
85
|
+
if (err.code === "EEXIST") {
|
|
86
|
+
console.log(
|
|
87
|
+
"\x1B[31m",
|
|
88
|
+
`The folder ${projectName} already exists in the current directory, please give it another name.`,
|
|
89
|
+
"\x1B[0m"
|
|
90
|
+
);
|
|
91
|
+
} else {
|
|
92
|
+
console.log(err);
|
|
93
|
+
}
|
|
94
|
+
process.exit(1);
|
|
95
|
+
}
|
|
96
|
+
createProject(projectName, documentModelsDir, editorsDir);
|
|
97
|
+
}
|
|
98
|
+
function createProject(projectName, documentModelsDir, editorsDir) {
|
|
99
|
+
try {
|
|
100
|
+
console.log("\x1B[33m", "Downloading the project structure...", "\x1B[0m");
|
|
101
|
+
runCmd(`git clone --depth 1 ${BOILERPLATE_REPO} ${projectName}`);
|
|
102
|
+
const appPath = path__default.default.join(process.cwd(), projectName);
|
|
103
|
+
process.chdir(appPath);
|
|
104
|
+
console.log("\x1B[34m", "Installing dependencies...", "\x1B[0m");
|
|
105
|
+
runCmd(`${packageManager} install`);
|
|
106
|
+
fs__default.default.rmSync(path__default.default.join(appPath, "./.git"), { recursive: true });
|
|
107
|
+
runCmd("git init");
|
|
108
|
+
try {
|
|
109
|
+
fs__default.default.mkdirSync(path__default.default.join(appPath, documentModelsDir));
|
|
110
|
+
fs__default.default.writeFileSync(path__default.default.join(appPath, documentModelsDir, "index.ts"), "");
|
|
111
|
+
fs__default.default.mkdirSync(path__default.default.join(appPath, editorsDir));
|
|
112
|
+
fs__default.default.writeFileSync(path__default.default.join(appPath, editorsDir, "index.ts"), "");
|
|
113
|
+
} catch (error) {
|
|
114
|
+
if (!error.message.includes("EEXIST")) {
|
|
115
|
+
throw error;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
buildPackageJson(appPath, projectName);
|
|
119
|
+
buildPowerhouseConfig(appPath, documentModelsDir, editorsDir);
|
|
120
|
+
buildIndex(appPath, documentModelsDir, editorsDir);
|
|
121
|
+
console.log("\x1B[32m", "The installation is done!", "\x1B[0m");
|
|
122
|
+
console.log();
|
|
123
|
+
console.log("\x1B[34m", "You can start by typing:");
|
|
124
|
+
console.log(` cd ${projectName}`);
|
|
125
|
+
console.log(
|
|
126
|
+
isNpm ? " npm run generate" : ` ${packageManager} generate`,
|
|
127
|
+
"\x1B[0m"
|
|
128
|
+
);
|
|
129
|
+
} catch (error) {
|
|
130
|
+
console.log(error);
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
exports.init = init;
|
|
135
|
+
//# sourceMappingURL=init.js.map
|
|
136
|
+
//# sourceMappingURL=init.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/create-lib/init.ts"],"names":["getPackageManager","fs","path","execSync","parseArgs","configSpec","prompt","promptDirectories","DEFAULT_CONFIG"],"mappings":";;;;;;;;;;;;;;AAaA,MAAM,gBACJ,GAAA,kEAAA,C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AA,CAAA,GAAA;AAAA,MACN,KAAA,GAAQ,sBAAyB,GAAA,CAAA,IAAA,EAAO,cAAc,CAAA,SAAA,CAAA;AAAA,MACtD,SAAA;AAAA,KACF,CAAA;AAAA,WACO,KAAO,EAAA;AACd,IAAA,OAAA,CAAQ,IAAI,KAAK,CAAA,CAAA;AAAA,GACnB;AACF","file":"init.js","sourcesContent":["import arg from \"arg\";\nimport { execSync } from \"child_process\";\nimport { prompt } from \"enquirer\";\nimport fs from \"node:fs\";\nimport path from \"path\";\nimport {\n DEFAULT_CONFIG,\n configSpec,\n parseArgs,\n promptDirectories,\n} from \"../utils/cli\";\nimport { getPackageManager } from \"./command\";\n\nconst BOILERPLATE_REPO =\n \"https://github.com/powerhouse-inc/document-model-boilerplate.git\";\n\nconst packageManager = getPackageManager(process.env.npm_config_user_agent);\nconst isNpm = packageManager === \"npm\";\n\nfunction buildPackageJson(appPath: string, projectName: string) {\n const packageJson = JSON.parse(\n fs.readFileSync(path.join(appPath, \"package.json\"), \"utf-8\"),\n ) as Record<string, any>;\n const newPackage = {\n ...packageJson,\n name: projectName,\n version: \"1.0.0\",\n description: \"\",\n };\n\n fs.writeFileSync(\n path.join(appPath, \"package.json\"),\n JSON.stringify(newPackage, null, 2),\n \"utf8\",\n );\n}\n\nfunction buildPowerhouseConfig(\n appPath: string,\n documentModelsDir: string,\n editorsDir: string,\n) {\n const filePath = path.join(appPath, \"powerhouse.config.json\");\n const packageJson = JSON.parse(fs.readFileSync(filePath, \"utf-8\")) as Record<\n string,\n any\n >;\n const newPackage = {\n ...packageJson,\n documentModelsDir,\n editorsDir,\n };\n\n fs.writeFileSync(filePath, JSON.stringify(newPackage, null, 2), \"utf8\");\n}\n\nfunction buildIndex(\n appPath: string,\n documentModelsDir: string,\n editorsDir: string,\n) {\n fs.writeFileSync(\n path.join(appPath, \"index.ts\"),\n `import * as documentModelsExports from '${documentModelsDir}';\n import * as editorsExports from '${editorsDir}';\n\n export const documentModels = Object.values(documentModelsExports);\n export const editors = Object.values(editorsExports);`,\n \"utf8\",\n );\n}\n\nfunction runCmd(command: string) {\n try {\n execSync(command, { stdio: \"inherit\" });\n } catch (error) {\n console.log(\"\\x1b[31m\", error, \"\\x1b[0m\");\n }\n}\n\nexport async function init(_args?: arg.Result<typeof configSpec>) {\n const args = _args || parseArgs(process.argv.slice(2), configSpec);\n\n // checks if a project name was provided\n let projectName = args._.shift();\n if (!projectName) {\n const result = await prompt<{ projectName: string }>([\n {\n type: \"input\",\n name: \"projectName\",\n message: \"What is the project name?\",\n required: true,\n },\n ]);\n if (!result.projectName) {\n console.log(\"\\x1b[31m\", \"You have to provide name to your app.\");\n process.exit(1);\n }\n projectName = result.projectName;\n }\n\n const { documentModelsDir, editorsDir } = args[\"--interactive\"]\n ? await promptDirectories()\n : DEFAULT_CONFIG;\n\n const appPath = path.join(process.cwd(), projectName);\n\n try {\n fs.mkdirSync(appPath);\n } catch (err) {\n if ((err as { code: string }).code === \"EEXIST\") {\n console.log(\n \"\\x1b[31m\",\n `The folder ${projectName} already exists in the current directory, please give it another name.`,\n \"\\x1b[0m\",\n );\n } else {\n console.log(err);\n }\n process.exit(1);\n }\n\n createProject(projectName, documentModelsDir, editorsDir);\n}\n\nfunction createProject(\n projectName: string,\n documentModelsDir: string,\n editorsDir: string,\n) {\n try {\n console.log(\"\\x1b[33m\", \"Downloading the project structure...\", \"\\x1b[0m\");\n runCmd(`git clone --depth 1 ${BOILERPLATE_REPO} ${projectName}`);\n\n const appPath = path.join(process.cwd(), projectName);\n process.chdir(appPath);\n\n console.log(\"\\x1b[34m\", \"Installing dependencies...\", \"\\x1b[0m\");\n runCmd(`${packageManager} install`);\n\n fs.rmSync(path.join(appPath, \"./.git\"), { recursive: true });\n runCmd(\"git init\");\n\n try {\n fs.mkdirSync(path.join(appPath, documentModelsDir));\n fs.writeFileSync(path.join(appPath, documentModelsDir, \"index.ts\"), \"\");\n fs.mkdirSync(path.join(appPath, editorsDir));\n fs.writeFileSync(path.join(appPath, editorsDir, \"index.ts\"), \"\");\n } catch (error) {\n if (!(error as Error).message.includes(\"EEXIST\")) {\n throw error;\n }\n }\n buildPackageJson(appPath, projectName);\n buildPowerhouseConfig(appPath, documentModelsDir, editorsDir);\n buildIndex(appPath, documentModelsDir, editorsDir);\n\n console.log(\"\\x1b[32m\", \"The installation is done!\", \"\\x1b[0m\");\n console.log();\n\n console.log(\"\\x1b[34m\", \"You can start by typing:\");\n console.log(` cd ${projectName}`);\n console.log(\n isNpm ? \" npm run generate\" : ` ${packageManager} generate`,\n \"\\x1b[0m\",\n );\n } catch (error) {\n console.log(error);\n }\n}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { CodegenConfig } from '@graphql-codegen/cli';
|
|
2
|
+
import { TypeScriptPluginConfig } from '@graphql-codegen/typescript';
|
|
3
|
+
import { plugin } from '@acaldas/graphql-codegen-typescript-validation-schema';
|
|
4
|
+
|
|
5
|
+
declare const tsConfig: TypeScriptPluginConfig;
|
|
6
|
+
type ValidationSchemaConfigType = Parameters<typeof plugin>[2];
|
|
7
|
+
declare const validationConfig: ValidationSchemaConfigType;
|
|
8
|
+
declare function schemaConfig(name: string, dir: string): CodegenConfig["generates"];
|
|
9
|
+
declare const generateSchema: (model: string, dir: string, { watch, format }?: {
|
|
10
|
+
watch?: boolean | undefined;
|
|
11
|
+
format?: boolean | undefined;
|
|
12
|
+
}) => Promise<any>;
|
|
13
|
+
declare const generateSchemas: (dir: string, { watch, format }?: {
|
|
14
|
+
watch?: boolean | undefined;
|
|
15
|
+
format?: boolean | undefined;
|
|
16
|
+
}) => Promise<any>;
|
|
17
|
+
|
|
18
|
+
export { type ValidationSchemaConfigType, generateSchema, generateSchemas, schemaConfig, tsConfig, validationConfig };
|
package/dist/hygen.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { DocumentModel } from 'document-model';
|
|
2
|
+
|
|
3
|
+
declare function generateAll(dir: string, { watch, format }?: {
|
|
4
|
+
watch?: boolean | undefined;
|
|
5
|
+
format?: boolean | undefined;
|
|
6
|
+
}): Promise<void>;
|
|
7
|
+
declare function generateDocumentModel(documentModel: DocumentModel.DocumentModelState, dir: string, { watch, format }?: {
|
|
8
|
+
watch?: boolean | undefined;
|
|
9
|
+
format?: boolean | undefined;
|
|
10
|
+
}): Promise<void>;
|
|
11
|
+
declare function generateEditor(name: string, documentTypes: string[], documentTypesMap: Record<string, string>, dir: string, documentModelsDir: string, { format }?: {
|
|
12
|
+
format?: boolean | undefined;
|
|
13
|
+
}): Promise<void>;
|
|
14
|
+
|
|
15
|
+
export { generateAll, generateDocumentModel, generateEditor };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
export
|
|
1
|
+
import { PowerhouseConfig } from './utils.js';
|
|
2
|
+
export { DEFAULT_CONFIG, configSpec, createProject, generateMock, generateMockTypeFn, getConfig, getPackageManager, parseArgs, parseConfig, promptDirectories, writeConfig } from './utils.js';
|
|
3
|
+
import 'arg';
|
|
4
|
+
import '@anatine/zod-mock';
|
|
5
|
+
|
|
6
|
+
declare function generate(config: PowerhouseConfig): Promise<void>;
|
|
7
|
+
declare function generateFromFile(path: string, config: PowerhouseConfig): Promise<void>;
|
|
8
|
+
declare function generateEditor(name: string, documentTypes: string[], config: PowerhouseConfig): Promise<void>;
|
|
9
|
+
|
|
10
|
+
export { PowerhouseConfig, generate, generateEditor, generateFromFile };
|
package/dist/index.js
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
})
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var codegen = require('./codegen');
|
|
4
|
+
var utils = require('./utils');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
Object.keys(codegen).forEach(function (k) {
|
|
9
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () { return codegen[k]; }
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
Object.keys(utils).forEach(function (k) {
|
|
15
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
16
|
+
enumerable: true,
|
|
17
|
+
get: function () { return utils[k]; }
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js","sourcesContent":[]}
|
package/dist/utils/cli.js
CHANGED
|
@@ -1,88 +1,93 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
exports.promptDirectories = promptDirectories;
|
|
12
|
-
const arg_1 = __importDefault(require("arg"));
|
|
13
|
-
const enquirer_1 = require("enquirer");
|
|
14
|
-
const node_fs_1 = require("node:fs");
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var arg = require('arg');
|
|
4
|
+
var enquirer = require('enquirer');
|
|
5
|
+
var node_fs = require('node:fs');
|
|
6
|
+
|
|
7
|
+
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
8
|
+
|
|
9
|
+
var arg__default = /*#__PURE__*/_interopDefault(arg);
|
|
10
|
+
|
|
15
11
|
const DEFAULT_DOCUMENT_MODELS_DIR = "./document-models";
|
|
16
12
|
const DEFAULT_EDITORS_DIR = "./editors";
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
const DEFAULT_CONFIG = {
|
|
14
|
+
documentModelsDir: DEFAULT_DOCUMENT_MODELS_DIR,
|
|
15
|
+
editorsDir: DEFAULT_EDITORS_DIR
|
|
20
16
|
};
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
17
|
+
const 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"
|
|
30
26
|
};
|
|
31
27
|
function getConfig() {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return config;
|
|
28
|
+
let config = { ...DEFAULT_CONFIG };
|
|
29
|
+
try {
|
|
30
|
+
const configStr = node_fs.readFileSync("./powerhouse.config.json", "utf-8");
|
|
31
|
+
const userConfig = JSON.parse(configStr);
|
|
32
|
+
config = { ...config, ...userConfig };
|
|
33
|
+
} catch {
|
|
34
|
+
console.warn("No powerhouse.config.json found, using defaults");
|
|
35
|
+
}
|
|
36
|
+
return config;
|
|
42
37
|
}
|
|
43
38
|
function writeConfig(config) {
|
|
44
|
-
|
|
39
|
+
node_fs.writeFileSync("./powerhouse.config.json", JSON.stringify(config, null, 4));
|
|
45
40
|
}
|
|
46
41
|
function parseArgs(argv, spec) {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
42
|
+
const args = arg__default.default(spec, {
|
|
43
|
+
permissive: true,
|
|
44
|
+
argv
|
|
45
|
+
});
|
|
46
|
+
return args;
|
|
52
47
|
}
|
|
53
48
|
function parseConfig(argv) {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
49
|
+
const config = {};
|
|
50
|
+
const args = parseArgs(argv, configSpec);
|
|
51
|
+
if ("--document-models" in args) {
|
|
52
|
+
config.documentModelsDir = args["--document-models"];
|
|
53
|
+
}
|
|
54
|
+
if ("--editors" in args) {
|
|
55
|
+
config.editorsDir = args["--editors"];
|
|
56
|
+
}
|
|
57
|
+
if ("--format" in args) {
|
|
58
|
+
config.format = true;
|
|
59
|
+
}
|
|
60
|
+
if ("--interactive" in args) {
|
|
61
|
+
config.interactive = true;
|
|
62
|
+
}
|
|
63
|
+
if ("--watch" in args) {
|
|
64
|
+
config.watch = true;
|
|
65
|
+
}
|
|
66
|
+
return config;
|
|
72
67
|
}
|
|
73
|
-
async function promptDirectories(config =
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
68
|
+
async function promptDirectories(config = DEFAULT_CONFIG) {
|
|
69
|
+
return enquirer.prompt([
|
|
70
|
+
{
|
|
71
|
+
type: "input",
|
|
72
|
+
name: "documentModelsDir",
|
|
73
|
+
message: "Where to place the Document Models?",
|
|
74
|
+
initial: config.documentModelsDir
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
type: "input",
|
|
78
|
+
name: "editorsDir",
|
|
79
|
+
message: "Where to place the Editors?",
|
|
80
|
+
initial: config.editorsDir
|
|
81
|
+
}
|
|
82
|
+
]);
|
|
88
83
|
}
|
|
84
|
+
|
|
85
|
+
exports.DEFAULT_CONFIG = DEFAULT_CONFIG;
|
|
86
|
+
exports.configSpec = configSpec;
|
|
87
|
+
exports.getConfig = getConfig;
|
|
88
|
+
exports.parseArgs = parseArgs;
|
|
89
|
+
exports.parseConfig = parseConfig;
|
|
90
|
+
exports.promptDirectories = promptDirectories;
|
|
91
|
+
exports.writeConfig = writeConfig;
|
|
92
|
+
//# sourceMappingURL=cli.js.map
|
|
93
|
+
//# sourceMappingURL=cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/utils/cli.ts"],"names":["readFileSync","writeFileSync","arg","prompt"],"mappings":";;;;;;;;;;AAYA,MAAM,2BAA8B,GAAA,mBAAA,CAAA;AACpC,MAAM,mBAAsB,GAAA,WAAA,CAAA;AAErB,MAAM,cAAmC,GAAA;AAAA,EAC9C,iBAAmB,EAAA,2BAAA;AAAA,EACnB,UAAY,EAAA,mBAAA;AACd,EAAA;AAEO,MAAM,UAAa,GAAA;AAAA,EACxB,mBAAqB,EAAA,MAAA;AAAA,EACrB,WAAa,EAAA,MAAA;AAAA,EACb,eAAiB,EAAA,OAAA;AAAA,EACjB,UAAY,EAAA,OAAA;AAAA,EACZ,SAAW,EAAA,OAAA;AAAA,EACX,IAAM,EAAA,eAAA;AAAA,EACN,IAAM,EAAA,UAAA;AAAA,EACN,IAAM,EAAA,SAAA;AACR,EAAA;AAEO,SAAS,SAAY,GAAA;AAC1B,EAAI,IAAA,MAAA,GAA2B,EAAE,GAAG,cAAe,EAAA,CAAA;AACnD,EAAI,IAAA;AACF,IAAM,MAAA,SAAA,GAAYA,oBAAa,CAAA,0BAAA,EAA4B,OAAO,CAAA,CAAA;AAClE,IAAM,MAAA,UAAA,GAAa,IAAK,CAAA,KAAA,CAAM,SAAS,CAAA,CAAA;AACvC,IAAA,MAAA,GAAS,EAAE,GAAG,MAAQ,EAAA,GAAG,UAAW,EAAA,CAAA;AAAA,GAC9B,CAAA,MAAA;AACN,IAAA,OAAA,CAAQ,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A,MACE,IAAM,EAAA,OAAA;AAAA,MACN,IAAM,EAAA,mBAAA;AAAA,MACN,OAAS,EAAA,qCAAA;AAAA,MACT,SAAS,MAAO,CAAA,iBAAA;AAAA,KAClB;AAAA,IACA;AAAA,MACE,IAAM,EAAA,OAAA;AAAA,MACN,IAAM,EAAA,YAAA;AAAA,MACN,OAAS,EAAA,6BAAA;AAAA,MACT,SAAS,MAAO,CAAA,UAAA;AAAA,KAClB;AAAA,GACD,CAAA,CAAA;AACH","file":"cli.js","sourcesContent":["import arg from \"arg\";\nimport { prompt } from \"enquirer\";\nimport { readFileSync, writeFileSync } from \"node:fs\";\n\nexport type PowerhouseConfig = {\n documentModelsDir: string;\n editorsDir: string;\n interactive?: boolean;\n format?: boolean;\n watch?: boolean;\n};\n\nconst DEFAULT_DOCUMENT_MODELS_DIR = \"./document-models\";\nconst DEFAULT_EDITORS_DIR = \"./editors\";\n\nexport const DEFAULT_CONFIG: PowerhouseConfig = {\n documentModelsDir: DEFAULT_DOCUMENT_MODELS_DIR,\n editorsDir: DEFAULT_EDITORS_DIR,\n};\n\nexport const configSpec = {\n \"--document-models\": String,\n \"--editors\": String,\n \"--interactive\": Boolean,\n \"--format\": Boolean,\n \"--watch\": Boolean,\n \"-i\": \"--interactive\",\n \"-f\": \"--format\",\n \"-w\": \"--watch\",\n} as const;\n\nexport function getConfig() {\n let config: PowerhouseConfig = { ...DEFAULT_CONFIG };\n try {\n const configStr = readFileSync(\"./powerhouse.config.json\", \"utf-8\");\n const userConfig = JSON.parse(configStr) as PowerhouseConfig;\n config = { ...config, ...userConfig };\n } catch {\n console.warn(\"No powerhouse.config.json found, using defaults\");\n }\n return config;\n}\n\nexport function writeConfig(config: PowerhouseConfig) {\n writeFileSync(\"./powerhouse.config.json\", JSON.stringify(config, null, 4));\n}\n\nexport function parseArgs<T extends arg.Spec>(argv: string[], spec: T) {\n const args = arg(spec, {\n permissive: true,\n argv,\n });\n\n return args;\n}\n\nexport function parseConfig(argv: string[]) {\n const config: Partial<PowerhouseConfig> = {};\n const args = parseArgs(argv, configSpec);\n\n if (\"--document-models\" in args) {\n config.documentModelsDir = args[\"--document-models\"];\n }\n\n if (\"--editors\" in args) {\n config.editorsDir = args[\"--editors\"];\n }\n\n if (\"--format\" in args) {\n config.format = true;\n }\n if (\"--interactive\" in args) {\n config.interactive = true;\n }\n if (\"--watch\" in args) {\n config.watch = true;\n }\n\n return config;\n}\n\nexport async function promptDirectories(\n config: PowerhouseConfig = DEFAULT_CONFIG,\n) {\n return prompt<Pick<PowerhouseConfig, \"documentModelsDir\" | \"editorsDir\">>([\n {\n type: \"input\",\n name: \"documentModelsDir\",\n message: \"Where to place the Document Models?\",\n initial: config.documentModelsDir,\n },\n {\n type: \"input\",\n name: \"editorsDir\",\n message: \"Where to place the Editors?\",\n initial: config.editorsDir,\n },\n ]);\n}\n"]}
|
package/dist/utils/index.js
CHANGED
|
@@ -1,18 +1,31 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var cli = require('./cli');
|
|
4
|
+
var mock = require('./mock');
|
|
5
|
+
var init = require('../create-lib/init');
|
|
6
|
+
var command = require('../create-lib/command');
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
Object.defineProperty(exports, "createProject", {
|
|
11
|
+
enumerable: true,
|
|
12
|
+
get: function () { return init.init; }
|
|
13
|
+
});
|
|
14
|
+
Object.defineProperty(exports, "getPackageManager", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function () { return command.getPackageManager; }
|
|
17
|
+
});
|
|
18
|
+
Object.keys(cli).forEach(function (k) {
|
|
19
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
20
|
+
enumerable: true,
|
|
21
|
+
get: function () { return cli[k]; }
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
Object.keys(mock).forEach(function (k) {
|
|
25
|
+
if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function () { return mock[k]; }
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
//# sourceMappingURL=index.js.map
|
|
31
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"names":[],"mappings":"","file":"index.js","sourcesContent":[]}
|
package/dist/utils/mock.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var zodMock = require('@anatine/zod-mock');
|
|
4
|
+
|
|
5
5
|
const generateMock = (zodRef, options) => {
|
|
6
|
-
|
|
6
|
+
return zodMock.generateMock(zodRef, options);
|
|
7
7
|
};
|
|
8
|
+
|
|
8
9
|
exports.generateMock = generateMock;
|
|
10
|
+
//# sourceMappingURL=mock.js.map
|
|
11
|
+
//# sourceMappingURL=mock.js.map
|