@gadmin2n/prisma-react-generator 0.0.62 → 0.0.64
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/generator/generate-ui-config.js +13 -12
- package/dist/generator/index.js +0 -3
- package/dist/index.js +11 -8
- package/package.json +1 -1
|
@@ -81,29 +81,32 @@ function loadConfigFromDirectory(allModels, enums = []) {
|
|
|
81
81
|
console.log(`Created new config file: config/ui/${model.name}.ts`);
|
|
82
82
|
});
|
|
83
83
|
console.log('Compile UI config files ...');
|
|
84
|
+
const outDirAbs = path.resolve('../node_modules/.cache/gadmin-ui-config');
|
|
85
|
+
fs.rmSync(outDirAbs, { recursive: true, force: true });
|
|
86
|
+
fs.mkdirSync(outDirAbs, { recursive: true });
|
|
84
87
|
const tempTsConfig = {
|
|
85
88
|
compilerOptions: {
|
|
86
89
|
moduleResolution: 'node',
|
|
87
90
|
esModuleInterop: true,
|
|
88
|
-
outDir:
|
|
91
|
+
outDir: outDirAbs,
|
|
92
|
+
rootDir: configDirAbs,
|
|
89
93
|
},
|
|
90
|
-
include: ['
|
|
91
|
-
exclude: ['
|
|
94
|
+
include: [path.join(configDirAbs, '*.ts')],
|
|
95
|
+
exclude: [path.join(configDirAbs, '*.d.ts')],
|
|
92
96
|
};
|
|
93
|
-
const tempTsConfigPath = path.join(
|
|
97
|
+
const tempTsConfigPath = path.join(outDirAbs, '_tsconfig.tmp.json');
|
|
94
98
|
fs.writeFileSync(tempTsConfigPath, JSON.stringify(tempTsConfig, null, 2));
|
|
95
|
-
const { code } = shell.
|
|
96
|
-
fs.unlinkSync(tempTsConfigPath);
|
|
99
|
+
const { code } = shell.exec(`tsc -p "${tempTsConfigPath}"`);
|
|
97
100
|
if (code !== 0) {
|
|
98
|
-
shell.cd('../../server');
|
|
99
101
|
process.exit(code);
|
|
100
102
|
}
|
|
101
103
|
const modelsConfig = {};
|
|
102
104
|
let pageActions = null;
|
|
103
105
|
let PAGE_SIZE = 10;
|
|
104
|
-
const jsFiles = fs
|
|
106
|
+
const jsFiles = fs
|
|
107
|
+
.readdirSync(outDirAbs)
|
|
105
108
|
.filter((file) => file.endsWith('.js') && !file.startsWith('_'));
|
|
106
|
-
const commonJsPath = path.join(
|
|
109
|
+
const commonJsPath = path.join(outDirAbs, '_common.js');
|
|
107
110
|
if (fs.existsSync(commonJsPath)) {
|
|
108
111
|
delete require.cache[require.resolve(commonJsPath)];
|
|
109
112
|
const commonModule = require(commonJsPath);
|
|
@@ -115,7 +118,7 @@ function loadConfigFromDirectory(allModels, enums = []) {
|
|
|
115
118
|
}
|
|
116
119
|
}
|
|
117
120
|
jsFiles.forEach((file) => {
|
|
118
|
-
const jsFilePath = path.join(
|
|
121
|
+
const jsFilePath = path.join(outDirAbs, file);
|
|
119
122
|
delete require.cache[require.resolve(jsFilePath)];
|
|
120
123
|
const moduleExports = require(jsFilePath);
|
|
121
124
|
Object.keys(moduleExports).forEach((key) => {
|
|
@@ -130,8 +133,6 @@ function loadConfigFromDirectory(allModels, enums = []) {
|
|
|
130
133
|
}
|
|
131
134
|
});
|
|
132
135
|
});
|
|
133
|
-
shell.rm('-rf', '*.js');
|
|
134
|
-
shell.cd('../../server');
|
|
135
136
|
if (!pageActions) {
|
|
136
137
|
pageActions = {
|
|
137
138
|
hasDetailPage: true,
|
package/dist/generator/index.js
CHANGED
|
@@ -6,7 +6,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.run = void 0;
|
|
7
7
|
const node_path_1 = __importDefault(require("node:path"));
|
|
8
8
|
const case_1 = require("case");
|
|
9
|
-
const sdk_1 = require("@prisma/sdk");
|
|
10
9
|
const template_helpers_1 = require("./template-helpers");
|
|
11
10
|
const field_classifiers_1 = require("./field-classifiers");
|
|
12
11
|
const generate_resources_1 = require("./generate-resources");
|
|
@@ -51,7 +50,6 @@ const run = ({ output, dmmf, ...options }) => {
|
|
|
51
50
|
const enums = dmmf.schema.enumTypes.model;
|
|
52
51
|
const uiConfig = (0, generate_ui_config_1.addNewModelsConfig)(allModels, enums);
|
|
53
52
|
const modelUIFiles = allModels.map((model) => {
|
|
54
|
-
sdk_1.logger.info(`Processing Model ${model.name}`);
|
|
55
53
|
const modelDirName = transformFileNameCase(model.name);
|
|
56
54
|
const configFile = {
|
|
57
55
|
fileName: node_path_1.default.join(output, 'props', modelDirName, `config.ts`),
|
|
@@ -73,7 +71,6 @@ const run = ({ output, dmmf, ...options }) => {
|
|
|
73
71
|
}),
|
|
74
72
|
};
|
|
75
73
|
if (existingPageModels === null || existingPageModels === void 0 ? void 0 : existingPageModels.has(modelDirName)) {
|
|
76
|
-
sdk_1.logger.info(`Skipping page generation for Model ${model.name} (already exists in routes/)`);
|
|
77
74
|
return [configFile, modelFile];
|
|
78
75
|
}
|
|
79
76
|
const createPageFile = {
|
package/dist/index.js
CHANGED
|
@@ -22,7 +22,8 @@ const stringToBoolean = (input, defaultValue = false) => {
|
|
|
22
22
|
};
|
|
23
23
|
exports.stringToBoolean = stringToBoolean;
|
|
24
24
|
const generate = (options) => {
|
|
25
|
-
const output =
|
|
25
|
+
const output = process.env.GADMIN_WEB_STAGING ||
|
|
26
|
+
(0, sdk_1.parseEnvValue)(options.generator.output);
|
|
26
27
|
const { fileNamingStyle = 'camel', pagesDir, } = options.generator.config;
|
|
27
28
|
const supportedFileNamingStyles = ['kebab', 'camel', 'pascal', 'snake'];
|
|
28
29
|
const isSupportedFileNamingStyle = (style) => supportedFileNamingStyles.includes(style);
|
|
@@ -32,13 +33,15 @@ const generate = (options) => {
|
|
|
32
33
|
.join(', ')}.`);
|
|
33
34
|
}
|
|
34
35
|
const existingPageModels = new Set();
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
36
|
+
const resolvedPagesDir = process.env.GADMIN_WEB_ROUTES_DIR
|
|
37
|
+
? process.env.GADMIN_WEB_ROUTES_DIR
|
|
38
|
+
: pagesDir
|
|
39
|
+
? node_path_1.default.resolve(node_path_1.default.dirname(options.schemaPath), pagesDir)
|
|
40
|
+
: null;
|
|
41
|
+
if (resolvedPagesDir && (0, node_fs_1.existsSync)(resolvedPagesDir)) {
|
|
42
|
+
(0, node_fs_1.readdirSync)(resolvedPagesDir, { withFileTypes: true })
|
|
43
|
+
.filter((e) => e.isDirectory())
|
|
44
|
+
.forEach((e) => existingPageModels.add(e.name));
|
|
42
45
|
}
|
|
43
46
|
const results = (0, generator_1.run)({
|
|
44
47
|
output,
|
package/package.json
CHANGED