nsgm-cli 2.1.13 → 2.1.15
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 +394 -156
- package/client/components/Button.tsx +3 -5
- package/client/components/ClientProviders.tsx +29 -0
- package/client/components/LanguageSwitcher.tsx +59 -0
- package/client/components/SSRSafeAntdProvider.tsx +24 -0
- package/client/components/SuppressHydrationWarnings.tsx +55 -0
- package/client/components/__tests__/Button.test.tsx +10 -10
- package/client/layout/index.tsx +153 -185
- package/client/redux/reducers.ts +1 -1
- package/client/redux/store.ts +2 -1
- package/client/redux/template/manage/actions.ts +77 -88
- package/client/redux/template/manage/reducers.ts +25 -37
- package/client/redux/template/manage/types.ts +1 -1
- package/client/service/template/manage.ts +20 -21
- package/client/styled/common.ts +12 -14
- package/client/styled/layout/index.ts +234 -120
- package/client/styled/template/manage.ts +102 -14
- package/client/utils/common.ts +23 -21
- package/client/utils/cookie.ts +18 -19
- package/client/utils/fetch.ts +64 -100
- package/client/utils/i18n.ts +68 -0
- package/client/utils/menu.tsx +42 -23
- package/client/utils/navigation.ts +58 -0
- package/client/utils/sso.ts +74 -84
- package/client/utils/suppressWarnings.ts +32 -0
- package/eslint.config.js +53 -19
- package/generation/README.md +25 -6
- package/generation/__tests__/example.test.js +41 -0
- package/generation/client/redux/reducers.ts +1 -1
- package/generation/client/utils/menu.tsx +36 -23
- package/generation/env +3 -0
- package/generation/env.example +3 -0
- package/generation/eslint.config.js +112 -0
- package/generation/gitignore +6 -1
- package/generation/jest.config.js +40 -0
- package/generation/next.config.js +7 -3
- package/generation/package.json +28 -4
- package/generation/tsconfig.json +6 -19
- package/jest.config.js +23 -6
- package/lib/args.js +9 -1
- package/lib/cli/app.d.ts +28 -0
- package/lib/cli/app.js +99 -0
- package/lib/cli/commands/build.d.ts +2 -0
- package/lib/cli/commands/build.js +29 -0
- package/lib/cli/commands/create.d.ts +2 -0
- package/lib/cli/commands/create.js +113 -0
- package/lib/cli/commands/delete.d.ts +3 -0
- package/lib/cli/commands/delete.js +151 -0
- package/lib/cli/commands/export.d.ts +2 -0
- package/lib/cli/commands/export.js +42 -0
- package/lib/cli/commands/help.d.ts +2 -0
- package/lib/cli/commands/help.js +42 -0
- package/lib/cli/commands/init.d.ts +2 -0
- package/lib/cli/commands/init.js +115 -0
- package/lib/cli/commands/server.d.ts +3 -0
- package/lib/cli/commands/server.js +26 -0
- package/lib/cli/commands/upgrade.d.ts +2 -0
- package/lib/cli/commands/upgrade.js +38 -0
- package/lib/cli/commands/version.d.ts +2 -0
- package/lib/cli/commands/version.js +24 -0
- package/lib/cli/index.d.ts +16 -0
- package/lib/cli/index.js +33 -0
- package/lib/cli/parser.d.ts +22 -0
- package/lib/cli/parser.js +115 -0
- package/lib/cli/registry.d.ts +33 -0
- package/lib/cli/registry.js +81 -0
- package/lib/cli/types/project.d.ts +10 -0
- package/lib/cli/types/project.js +2 -0
- package/lib/cli/types.d.ts +31 -0
- package/lib/cli/types.js +20 -0
- package/lib/cli/utils/console.d.ts +62 -0
- package/lib/cli/utils/console.js +148 -0
- package/lib/cli/utils/index.d.ts +2 -0
- package/lib/cli/utils/index.js +7 -0
- package/lib/cli/utils/prompt.d.ts +83 -0
- package/lib/cli/utils/prompt.js +327 -0
- package/lib/constants.d.ts +65 -0
- package/lib/constants.js +177 -0
- package/lib/generate.d.ts +25 -3
- package/lib/generate.js +98 -621
- package/lib/generate_create.d.ts +9 -0
- package/lib/generate_create.js +329 -0
- package/lib/generate_delete.d.ts +8 -0
- package/lib/generate_delete.js +233 -0
- package/lib/generate_init.d.ts +56 -0
- package/lib/generate_init.js +612 -0
- package/lib/generators/base-generator.d.ts +47 -0
- package/lib/generators/base-generator.js +92 -0
- package/lib/generators/file-generator.d.ts +48 -0
- package/lib/generators/file-generator.js +455 -0
- package/lib/generators/generator-factory.d.ts +20 -0
- package/lib/generators/generator-factory.js +25 -0
- package/lib/generators/i18n-generator.d.ts +51 -0
- package/lib/generators/i18n-generator.js +320 -0
- package/lib/generators/page-generator.d.ts +45 -0
- package/lib/generators/page-generator.js +578 -0
- package/lib/generators/resolver-generator.d.ts +14 -0
- package/lib/generators/resolver-generator.js +342 -0
- package/lib/generators/schema-generator.d.ts +7 -0
- package/lib/generators/schema-generator.js +57 -0
- package/lib/generators/service-generator.d.ts +11 -0
- package/lib/generators/service-generator.js +233 -0
- package/lib/generators/sql-generator.d.ts +8 -0
- package/lib/generators/sql-generator.js +52 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.js +14 -173
- package/lib/server/csrf.js +9 -16
- package/lib/server/db.js +6 -7
- package/lib/server/graphql.js +5 -6
- package/lib/server/plugins/date.js +1 -1
- package/lib/server/utils/graphql-cache.js +3 -3
- package/lib/tsconfig.build.tsbuildinfo +1 -1
- package/lib/utils/project-config.d.ts +5 -0
- package/lib/utils/project-config.js +145 -0
- package/lib/utils.js +1 -1
- package/next-i18next.config.js +18 -0
- package/next.config.js +61 -18
- package/package.json +16 -8
- package/pages/_app.tsx +77 -33
- package/pages/_document.tsx +78 -21
- package/pages/_error.tsx +66 -0
- package/pages/index.tsx +109 -47
- package/pages/login.tsx +66 -41
- package/pages/template/manage.tsx +162 -151
- package/public/fonts/font-awesome.min.css +4 -0
- package/public/fonts/fontawesome-webfont.woff +0 -0
- package/public/fonts/fontawesome-webfont.woff2 +0 -0
- package/public/locales/en-US/common.json +48 -0
- package/public/locales/en-US/home.json +57 -0
- package/public/locales/en-US/layout.json +22 -0
- package/public/locales/en-US/login.json +13 -0
- package/public/locales/en-US/template.json +42 -0
- package/public/locales/ja-JP/common.json +48 -0
- package/public/locales/ja-JP/home.json +57 -0
- package/public/locales/ja-JP/layout.json +22 -0
- package/public/locales/ja-JP/login.json +13 -0
- package/public/locales/ja-JP/template.json +42 -0
- package/public/locales/zh-CN/common.json +48 -0
- package/public/locales/zh-CN/home.json +57 -0
- package/public/locales/zh-CN/layout.json +22 -0
- package/public/locales/zh-CN/login.json +13 -0
- package/public/locales/zh-CN/template.json +42 -0
- package/public/slbhealthcheck.html +1 -1
- package/server/apis/template.js +0 -2
- package/server/utils/validation.js +163 -0
- package/types/i18next.d.ts +10 -0
- package/generation/eslintrc.js +0 -16
|
@@ -0,0 +1,327 @@
|
|
|
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.Prompt = void 0;
|
|
7
|
+
const inquirer_1 = __importDefault(require("inquirer"));
|
|
8
|
+
const console_1 = require("./console");
|
|
9
|
+
/**
|
|
10
|
+
* 交互式提示工具类
|
|
11
|
+
*/
|
|
12
|
+
class Prompt {
|
|
13
|
+
/**
|
|
14
|
+
* 确认提示
|
|
15
|
+
*/
|
|
16
|
+
static async confirm(message, defaultValue = false) {
|
|
17
|
+
const { confirmed } = await inquirer_1.default.prompt({
|
|
18
|
+
type: 'confirm',
|
|
19
|
+
name: 'confirmed',
|
|
20
|
+
message,
|
|
21
|
+
default: defaultValue,
|
|
22
|
+
});
|
|
23
|
+
return confirmed;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* 输入提示
|
|
27
|
+
*/
|
|
28
|
+
static async input(message, defaultValue, validate) {
|
|
29
|
+
const config = {
|
|
30
|
+
type: 'input',
|
|
31
|
+
name: 'value',
|
|
32
|
+
message,
|
|
33
|
+
validate: validate || (() => true),
|
|
34
|
+
};
|
|
35
|
+
if (defaultValue !== undefined) {
|
|
36
|
+
config.default = defaultValue;
|
|
37
|
+
}
|
|
38
|
+
const { value } = await inquirer_1.default.prompt(config);
|
|
39
|
+
return value;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* 密码输入
|
|
43
|
+
*/
|
|
44
|
+
static async password(message, validate) {
|
|
45
|
+
const { value } = await inquirer_1.default.prompt({
|
|
46
|
+
type: 'password',
|
|
47
|
+
name: 'value',
|
|
48
|
+
message,
|
|
49
|
+
validate: validate || (() => true),
|
|
50
|
+
});
|
|
51
|
+
return value;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* 单选提示
|
|
55
|
+
*/
|
|
56
|
+
static async select(message, choices) {
|
|
57
|
+
const { selected } = await inquirer_1.default.prompt({
|
|
58
|
+
type: 'list',
|
|
59
|
+
name: 'selected',
|
|
60
|
+
message,
|
|
61
|
+
choices,
|
|
62
|
+
});
|
|
63
|
+
return selected;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* 多选提示
|
|
67
|
+
*/
|
|
68
|
+
static async multiSelect(message, choices) {
|
|
69
|
+
const { selected } = await inquirer_1.default.prompt({
|
|
70
|
+
type: 'checkbox',
|
|
71
|
+
name: 'selected',
|
|
72
|
+
message,
|
|
73
|
+
choices,
|
|
74
|
+
});
|
|
75
|
+
return selected;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* 自定义提示
|
|
79
|
+
*/
|
|
80
|
+
static async custom(questions) {
|
|
81
|
+
return await inquirer_1.default.prompt(questions);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* 项目初始化向导
|
|
85
|
+
*/
|
|
86
|
+
static async initWizard() {
|
|
87
|
+
console_1.Console.title('🚀 NSGM 项目初始化向导');
|
|
88
|
+
console_1.Console.newLine();
|
|
89
|
+
const answers = await inquirer_1.default.prompt([
|
|
90
|
+
{
|
|
91
|
+
type: 'input',
|
|
92
|
+
name: 'projectName',
|
|
93
|
+
message: '项目目录:',
|
|
94
|
+
default: 'my-nsgm-project',
|
|
95
|
+
validate: (input) => {
|
|
96
|
+
if (!input.trim())
|
|
97
|
+
return '项目目录不能为空';
|
|
98
|
+
// 允许路径格式,包括相对路径和绝对路径
|
|
99
|
+
if (!/^[a-zA-Z0-9\-_./\\]+$/.test(input))
|
|
100
|
+
return '项目目录只能包含字母、数字、横线、下划线和路径分隔符';
|
|
101
|
+
return true;
|
|
102
|
+
},
|
|
103
|
+
},
|
|
104
|
+
{
|
|
105
|
+
type: 'input',
|
|
106
|
+
name: 'description',
|
|
107
|
+
message: '项目描述:',
|
|
108
|
+
default: 'A NSGM fullstack project',
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
type: 'input',
|
|
112
|
+
name: 'author',
|
|
113
|
+
message: '作者:',
|
|
114
|
+
default: 'Your Name',
|
|
115
|
+
},
|
|
116
|
+
]);
|
|
117
|
+
// 设置默认配置
|
|
118
|
+
const result = {
|
|
119
|
+
...answers,
|
|
120
|
+
database: true,
|
|
121
|
+
features: ['nextjs', 'styled-components', 'graphql', 'mysql', 'typescript', 'eslint'],
|
|
122
|
+
};
|
|
123
|
+
return result;
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* 控制器创建向导
|
|
127
|
+
*/
|
|
128
|
+
static async createControllerWizard() {
|
|
129
|
+
console_1.Console.title('📝 创建控制器向导 (包含完整CRUD + 导入导出 + 批量删除功能)');
|
|
130
|
+
console_1.Console.newLine();
|
|
131
|
+
const answers = await inquirer_1.default.prompt([
|
|
132
|
+
{
|
|
133
|
+
type: 'input',
|
|
134
|
+
name: 'dictionary',
|
|
135
|
+
message: '项目目录:',
|
|
136
|
+
default: '.',
|
|
137
|
+
validate: (input) => {
|
|
138
|
+
if (!input.trim())
|
|
139
|
+
return '项目目录不能为空';
|
|
140
|
+
return true;
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
type: 'input',
|
|
145
|
+
name: 'controller',
|
|
146
|
+
message: '控制器名称:',
|
|
147
|
+
validate: (input) => {
|
|
148
|
+
if (!input.trim())
|
|
149
|
+
return '控制器名称不能为空';
|
|
150
|
+
if (!/^[a-zA-Z][a-zA-Z0-9]*$/.test(input))
|
|
151
|
+
return '控制器名称必须以字母开头,只能包含字母和数字';
|
|
152
|
+
return true;
|
|
153
|
+
},
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
type: 'input',
|
|
157
|
+
name: 'description',
|
|
158
|
+
message: '控制器描述:',
|
|
159
|
+
default: (answers) => `${answers.controller} 控制器`,
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
type: 'confirm',
|
|
163
|
+
name: 'useCustomFields',
|
|
164
|
+
message: '是否自定义字段配置?(默认字段: id, name, create_date, update_date)',
|
|
165
|
+
default: false,
|
|
166
|
+
},
|
|
167
|
+
]);
|
|
168
|
+
// 设置默认action为manage(包含完整的CRUD + 导入 + 导出 + 批量删除功能)
|
|
169
|
+
answers.action = 'manage';
|
|
170
|
+
answers.includeDatabase = true;
|
|
171
|
+
if (answers.useCustomFields) {
|
|
172
|
+
// 如果用户选择自定义字段,收集字段定义
|
|
173
|
+
answers.fields = await this.collectFieldDefinitions();
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
// 使用默认字段配置
|
|
177
|
+
answers.fields = [
|
|
178
|
+
{ name: 'id', type: 'integer', required: true, comment: '主键', isPrimaryKey: true, isAutoIncrement: true },
|
|
179
|
+
{
|
|
180
|
+
name: 'name',
|
|
181
|
+
type: 'varchar',
|
|
182
|
+
length: 100,
|
|
183
|
+
required: true,
|
|
184
|
+
comment: '名称',
|
|
185
|
+
showInList: true,
|
|
186
|
+
showInForm: true,
|
|
187
|
+
searchable: true,
|
|
188
|
+
},
|
|
189
|
+
{ name: 'create_date', type: 'timestamp', required: true, comment: '创建时间', isSystemField: true },
|
|
190
|
+
{ name: 'update_date', type: 'timestamp', required: true, comment: '更新时间', isSystemField: true },
|
|
191
|
+
];
|
|
192
|
+
}
|
|
193
|
+
return answers;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* 收集字段定义 (简化版本)
|
|
197
|
+
*/
|
|
198
|
+
static async collectFieldDefinitions() {
|
|
199
|
+
const fields = [];
|
|
200
|
+
// 默认添加ID字段
|
|
201
|
+
fields.push({
|
|
202
|
+
name: 'id',
|
|
203
|
+
type: 'integer',
|
|
204
|
+
required: true,
|
|
205
|
+
comment: '主键',
|
|
206
|
+
isPrimaryKey: true,
|
|
207
|
+
isAutoIncrement: true,
|
|
208
|
+
});
|
|
209
|
+
console_1.Console.info('💡 输入字段信息,输入空白字段名结束添加');
|
|
210
|
+
let fieldIndex = 1;
|
|
211
|
+
while (true) {
|
|
212
|
+
const fieldName = await this.input(`字段${fieldIndex} 名称 (留空结束):`);
|
|
213
|
+
if (!fieldName.trim())
|
|
214
|
+
break;
|
|
215
|
+
// 验证字段名
|
|
216
|
+
if (!/^[a-zA-Z_][a-zA-Z0-9_]*$/.test(fieldName)) {
|
|
217
|
+
console_1.Console.error('字段名称格式无效,请重新输入');
|
|
218
|
+
continue;
|
|
219
|
+
}
|
|
220
|
+
if (fields.some((f) => f.name === fieldName) || ['create_date', 'update_date'].includes(fieldName)) {
|
|
221
|
+
console_1.Console.error('字段名称已存在或为系统保留字段,请重新输入');
|
|
222
|
+
continue;
|
|
223
|
+
}
|
|
224
|
+
// 简化的字段类型选择
|
|
225
|
+
const fieldType = await this.select('字段类型:', [
|
|
226
|
+
'varchar',
|
|
227
|
+
'text',
|
|
228
|
+
'integer',
|
|
229
|
+
'decimal',
|
|
230
|
+
'boolean',
|
|
231
|
+
'date',
|
|
232
|
+
'datetime',
|
|
233
|
+
]);
|
|
234
|
+
// 只对需要长度的类型询问长度
|
|
235
|
+
let length;
|
|
236
|
+
if (fieldType === 'varchar') {
|
|
237
|
+
length = await this.input('字符串长度:', '255');
|
|
238
|
+
}
|
|
239
|
+
else if (fieldType === 'decimal') {
|
|
240
|
+
length = await this.input('小数精度 (如: 10,2):', '10,2');
|
|
241
|
+
}
|
|
242
|
+
// 简化配置:只询问是否必填和注释
|
|
243
|
+
const required = await this.confirm('是否必填:', true);
|
|
244
|
+
const comment = await this.input('字段注释:', fieldName);
|
|
245
|
+
const field = {
|
|
246
|
+
name: fieldName,
|
|
247
|
+
type: fieldType,
|
|
248
|
+
required,
|
|
249
|
+
comment,
|
|
250
|
+
showInList: true, // 默认在列表显示
|
|
251
|
+
showInForm: true, // 默认在表单显示
|
|
252
|
+
searchable: fieldType === 'varchar', // varchar类型默认可搜索
|
|
253
|
+
};
|
|
254
|
+
// 只有当length有值时才添加
|
|
255
|
+
if (length) {
|
|
256
|
+
field.length = length;
|
|
257
|
+
}
|
|
258
|
+
fields.push(field);
|
|
259
|
+
fieldIndex++;
|
|
260
|
+
}
|
|
261
|
+
// 自动添加系统字段
|
|
262
|
+
fields.push({
|
|
263
|
+
name: 'create_date',
|
|
264
|
+
type: 'timestamp',
|
|
265
|
+
required: true,
|
|
266
|
+
comment: '创建时间',
|
|
267
|
+
isSystemField: true,
|
|
268
|
+
}, {
|
|
269
|
+
name: 'update_date',
|
|
270
|
+
type: 'timestamp',
|
|
271
|
+
required: true,
|
|
272
|
+
comment: '更新时间',
|
|
273
|
+
isSystemField: true,
|
|
274
|
+
});
|
|
275
|
+
return fields;
|
|
276
|
+
}
|
|
277
|
+
/**
|
|
278
|
+
* 控制器删除向导
|
|
279
|
+
*/
|
|
280
|
+
static async deleteControllerWizard() {
|
|
281
|
+
console_1.Console.title('🗑️ 删除控制器向导');
|
|
282
|
+
console_1.Console.newLine();
|
|
283
|
+
const answers = await inquirer_1.default.prompt([
|
|
284
|
+
{
|
|
285
|
+
type: 'input',
|
|
286
|
+
name: 'dictionary',
|
|
287
|
+
message: '项目目录:',
|
|
288
|
+
default: '.',
|
|
289
|
+
validate: (input) => {
|
|
290
|
+
if (!input.trim())
|
|
291
|
+
return '项目目录不能为空';
|
|
292
|
+
return true;
|
|
293
|
+
},
|
|
294
|
+
},
|
|
295
|
+
{
|
|
296
|
+
type: 'input',
|
|
297
|
+
name: 'controller',
|
|
298
|
+
message: '控制器名称:',
|
|
299
|
+
validate: (input) => {
|
|
300
|
+
if (!input.trim())
|
|
301
|
+
return '控制器名称不能为空';
|
|
302
|
+
if (!/^[a-zA-Z][a-zA-Z0-9]*$/.test(input))
|
|
303
|
+
return '控制器名称必须以字母开头,只能包含字母和数字';
|
|
304
|
+
return true;
|
|
305
|
+
},
|
|
306
|
+
},
|
|
307
|
+
{
|
|
308
|
+
type: 'list',
|
|
309
|
+
name: 'action',
|
|
310
|
+
message: '删除范围:',
|
|
311
|
+
choices: [
|
|
312
|
+
{ name: '删除所有相关文件', value: 'all' },
|
|
313
|
+
{ name: '仅删除指定操作', value: 'manage' },
|
|
314
|
+
],
|
|
315
|
+
default: 'all',
|
|
316
|
+
},
|
|
317
|
+
{
|
|
318
|
+
type: 'confirm',
|
|
319
|
+
name: 'deleteDatabase',
|
|
320
|
+
message: '是否同时删除数据库表?',
|
|
321
|
+
default: false,
|
|
322
|
+
},
|
|
323
|
+
]);
|
|
324
|
+
return answers;
|
|
325
|
+
}
|
|
326
|
+
}
|
|
327
|
+
exports.Prompt = Prompt;
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
declare const sourceFolder: string;
|
|
2
|
+
declare const destFolder: string;
|
|
3
|
+
declare const isLocal: boolean;
|
|
4
|
+
declare const mysqlUser: any, mysqlPassword: any, mysqlHost: any, mysqlPort: any, mysqlDatabase: any;
|
|
5
|
+
declare const generationPath = "../generation";
|
|
6
|
+
declare const clientPathSource = "../client";
|
|
7
|
+
declare const clientPath = "./client";
|
|
8
|
+
declare const serverPathSource = "../server";
|
|
9
|
+
declare const serverPath = "./server";
|
|
10
|
+
declare const pagesPathSource = "../pages";
|
|
11
|
+
declare const pagesPath = "./pages";
|
|
12
|
+
declare const publicPathSource = "../public";
|
|
13
|
+
declare const publicPath = "./public";
|
|
14
|
+
declare const scriptsPathSource = "../scripts";
|
|
15
|
+
declare const scriptsPath = "./scripts";
|
|
16
|
+
declare const typesPathSource = "../types";
|
|
17
|
+
declare const typesPath = "./types";
|
|
18
|
+
declare const reduxPath = "/redux";
|
|
19
|
+
declare const servicePath = "/service";
|
|
20
|
+
declare const styledPath = "/styled";
|
|
21
|
+
declare const styledLayoutPath = "/layout";
|
|
22
|
+
declare const utilsPath = "/utils";
|
|
23
|
+
declare const layoutPath = "/layout";
|
|
24
|
+
declare const componentsPath = "/components";
|
|
25
|
+
declare const modulesPath = "/modules";
|
|
26
|
+
declare const apisPath = "/apis";
|
|
27
|
+
declare const sqlPath = "/sql";
|
|
28
|
+
declare const utilsMenuPath = "/menu.tsx";
|
|
29
|
+
declare const reduxReducersPath = "/reducers.ts";
|
|
30
|
+
declare const slbHealthCheckPath = "/slbhealthcheck.html";
|
|
31
|
+
declare const packagePath = "/package.json";
|
|
32
|
+
declare const restPath = "/rest.js";
|
|
33
|
+
declare const sourceGenerationPath: string;
|
|
34
|
+
declare const sourceClientPath: string;
|
|
35
|
+
declare const sourceClientPathGeneration: string;
|
|
36
|
+
declare const sourceServerPath: string;
|
|
37
|
+
declare const sourceServerPathGeneration: string;
|
|
38
|
+
declare const sourcePagesPath: string;
|
|
39
|
+
declare const sourcePublicPath: string;
|
|
40
|
+
declare const sourceScriptsPath: string;
|
|
41
|
+
declare const sourceTypesPath: string;
|
|
42
|
+
declare const projectClientPath: string;
|
|
43
|
+
declare const projectPublicPath: string;
|
|
44
|
+
declare const destClientPath: string;
|
|
45
|
+
declare const destClientReduxPath: string;
|
|
46
|
+
declare const destClientServicePath: string;
|
|
47
|
+
declare const destClientStyledPath: string;
|
|
48
|
+
declare const destClientStyledLayoutPath: string;
|
|
49
|
+
declare const destClientUtilsPath: string;
|
|
50
|
+
declare const destClientLayoutPath: string;
|
|
51
|
+
declare const destServerPath: string;
|
|
52
|
+
declare const destServerModulesPath: string;
|
|
53
|
+
declare const destServerApisPath: string;
|
|
54
|
+
declare const destServerSqlPath: string;
|
|
55
|
+
declare const destServerUtilsPath: string;
|
|
56
|
+
declare const destPagesPath: string;
|
|
57
|
+
declare const destPublicPath: string;
|
|
58
|
+
declare const destScriptsPath: string;
|
|
59
|
+
declare const destTypesPath: string;
|
|
60
|
+
declare const destClientUtilsMenuPath: string;
|
|
61
|
+
declare const destClientReduxReducersAllPath: string;
|
|
62
|
+
declare const destPublicHealthCheckPath: string;
|
|
63
|
+
declare const destPackagePath: string;
|
|
64
|
+
declare const destServerRestPath: string;
|
|
65
|
+
export { sourceFolder, destFolder, isLocal, generationPath, clientPathSource, clientPath, serverPathSource, serverPath, pagesPathSource, pagesPath, publicPathSource, publicPath, scriptsPathSource, scriptsPath, typesPathSource, typesPath, reduxPath, servicePath, styledPath, styledLayoutPath, utilsPath, layoutPath, componentsPath, modulesPath, apisPath, sqlPath, utilsMenuPath, reduxReducersPath, slbHealthCheckPath, packagePath, restPath, sourceGenerationPath, sourceClientPath, sourceClientPathGeneration, sourceServerPath, sourceServerPathGeneration, sourcePagesPath, sourcePublicPath, sourceScriptsPath, sourceTypesPath, projectClientPath, projectPublicPath, destClientPath, destClientReduxPath, destClientServicePath, destClientStyledPath, destClientStyledLayoutPath, destClientUtilsPath, destClientLayoutPath, destServerPath, destServerModulesPath, destServerApisPath, destServerSqlPath, destServerUtilsPath, destPagesPath, destPublicPath, destScriptsPath, destTypesPath, destClientUtilsMenuPath, destClientReduxReducersAllPath, destPublicHealthCheckPath, destPackagePath, destServerRestPath, mysqlUser, mysqlPassword, mysqlHost, mysqlPort, mysqlDatabase, };
|
package/lib/constants.js
ADDED
|
@@ -0,0 +1,177 @@
|
|
|
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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.destServerPath = exports.destClientLayoutPath = exports.destClientUtilsPath = exports.destClientStyledLayoutPath = exports.destClientStyledPath = exports.destClientServicePath = exports.destClientReduxPath = exports.destClientPath = exports.projectPublicPath = exports.projectClientPath = exports.sourceTypesPath = exports.sourceScriptsPath = exports.sourcePublicPath = exports.sourcePagesPath = exports.sourceServerPathGeneration = exports.sourceServerPath = exports.sourceClientPathGeneration = exports.sourceClientPath = exports.sourceGenerationPath = exports.restPath = exports.packagePath = exports.slbHealthCheckPath = exports.reduxReducersPath = exports.utilsMenuPath = exports.sqlPath = exports.apisPath = exports.modulesPath = exports.componentsPath = exports.layoutPath = exports.utilsPath = exports.styledLayoutPath = exports.styledPath = exports.servicePath = exports.reduxPath = exports.typesPath = exports.typesPathSource = exports.scriptsPath = exports.scriptsPathSource = exports.publicPath = exports.publicPathSource = exports.pagesPath = exports.pagesPathSource = exports.serverPath = exports.serverPathSource = exports.clientPath = exports.clientPathSource = exports.generationPath = exports.isLocal = exports.destFolder = exports.sourceFolder = void 0;
|
|
40
|
+
exports.mysqlDatabase = exports.mysqlPort = exports.mysqlHost = exports.mysqlPassword = exports.mysqlUser = exports.destServerRestPath = exports.destPackagePath = exports.destPublicHealthCheckPath = exports.destClientReduxReducersAllPath = exports.destClientUtilsMenuPath = exports.destTypesPath = exports.destScriptsPath = exports.destPublicPath = exports.destPagesPath = exports.destServerUtilsPath = exports.destServerSqlPath = exports.destServerApisPath = exports.destServerModulesPath = void 0;
|
|
41
|
+
const path_1 = __importStar(require("path"));
|
|
42
|
+
const db_1 = __importDefault(require("./server/db"));
|
|
43
|
+
const sourceFolder = __dirname;
|
|
44
|
+
exports.sourceFolder = sourceFolder;
|
|
45
|
+
const destFolder = process.cwd();
|
|
46
|
+
exports.destFolder = destFolder;
|
|
47
|
+
const isLocal = sourceFolder === (0, path_1.resolve)(`${destFolder}/lib`);
|
|
48
|
+
exports.isLocal = isLocal;
|
|
49
|
+
const { getMysqlConfig } = db_1.default;
|
|
50
|
+
const { mysqlOptions } = getMysqlConfig();
|
|
51
|
+
const { user: mysqlUser, password: mysqlPassword, host: mysqlHost, port: mysqlPort, database: mysqlDatabase, } = mysqlOptions;
|
|
52
|
+
exports.mysqlUser = mysqlUser;
|
|
53
|
+
exports.mysqlPassword = mysqlPassword;
|
|
54
|
+
exports.mysqlHost = mysqlHost;
|
|
55
|
+
exports.mysqlPort = mysqlPort;
|
|
56
|
+
exports.mysqlDatabase = mysqlDatabase;
|
|
57
|
+
const generationPath = '../generation';
|
|
58
|
+
exports.generationPath = generationPath;
|
|
59
|
+
const clientPathSource = '../client';
|
|
60
|
+
exports.clientPathSource = clientPathSource;
|
|
61
|
+
const clientPath = './client';
|
|
62
|
+
exports.clientPath = clientPath;
|
|
63
|
+
const serverPathSource = '../server';
|
|
64
|
+
exports.serverPathSource = serverPathSource;
|
|
65
|
+
const serverPath = './server';
|
|
66
|
+
exports.serverPath = serverPath;
|
|
67
|
+
const pagesPathSource = '../pages';
|
|
68
|
+
exports.pagesPathSource = pagesPathSource;
|
|
69
|
+
const pagesPath = './pages';
|
|
70
|
+
exports.pagesPath = pagesPath;
|
|
71
|
+
const publicPathSource = '../public';
|
|
72
|
+
exports.publicPathSource = publicPathSource;
|
|
73
|
+
const publicPath = './public';
|
|
74
|
+
exports.publicPath = publicPath;
|
|
75
|
+
const scriptsPathSource = '../scripts';
|
|
76
|
+
exports.scriptsPathSource = scriptsPathSource;
|
|
77
|
+
const scriptsPath = './scripts';
|
|
78
|
+
exports.scriptsPath = scriptsPath;
|
|
79
|
+
const typesPathSource = '../types';
|
|
80
|
+
exports.typesPathSource = typesPathSource;
|
|
81
|
+
const typesPath = './types';
|
|
82
|
+
exports.typesPath = typesPath;
|
|
83
|
+
const reduxPath = '/redux';
|
|
84
|
+
exports.reduxPath = reduxPath;
|
|
85
|
+
const servicePath = '/service';
|
|
86
|
+
exports.servicePath = servicePath;
|
|
87
|
+
const styledPath = '/styled';
|
|
88
|
+
exports.styledPath = styledPath;
|
|
89
|
+
const styledLayoutPath = '/layout';
|
|
90
|
+
exports.styledLayoutPath = styledLayoutPath;
|
|
91
|
+
const utilsPath = '/utils';
|
|
92
|
+
exports.utilsPath = utilsPath;
|
|
93
|
+
const layoutPath = '/layout';
|
|
94
|
+
exports.layoutPath = layoutPath;
|
|
95
|
+
const componentsPath = '/components';
|
|
96
|
+
exports.componentsPath = componentsPath;
|
|
97
|
+
const modulesPath = '/modules';
|
|
98
|
+
exports.modulesPath = modulesPath;
|
|
99
|
+
const apisPath = '/apis';
|
|
100
|
+
exports.apisPath = apisPath;
|
|
101
|
+
const sqlPath = '/sql';
|
|
102
|
+
exports.sqlPath = sqlPath;
|
|
103
|
+
const utilsMenuPath = '/menu.tsx';
|
|
104
|
+
exports.utilsMenuPath = utilsMenuPath;
|
|
105
|
+
const reduxReducersPath = '/reducers.ts';
|
|
106
|
+
exports.reduxReducersPath = reduxReducersPath;
|
|
107
|
+
const slbHealthCheckPath = '/slbhealthcheck.html';
|
|
108
|
+
exports.slbHealthCheckPath = slbHealthCheckPath;
|
|
109
|
+
const packagePath = '/package.json';
|
|
110
|
+
exports.packagePath = packagePath;
|
|
111
|
+
const restPath = '/rest.js';
|
|
112
|
+
exports.restPath = restPath;
|
|
113
|
+
const sourceGenerationPath = path_1.default.join(sourceFolder, generationPath);
|
|
114
|
+
exports.sourceGenerationPath = sourceGenerationPath;
|
|
115
|
+
const sourceClientPath = path_1.default.join(sourceFolder, clientPathSource);
|
|
116
|
+
exports.sourceClientPath = sourceClientPath;
|
|
117
|
+
const sourceClientPathGeneration = path_1.default.join(sourceGenerationPath, clientPath);
|
|
118
|
+
exports.sourceClientPathGeneration = sourceClientPathGeneration;
|
|
119
|
+
const sourceServerPath = path_1.default.join(sourceFolder, serverPathSource);
|
|
120
|
+
exports.sourceServerPath = sourceServerPath;
|
|
121
|
+
const sourceServerPathGeneration = path_1.default.join(sourceGenerationPath, serverPath);
|
|
122
|
+
exports.sourceServerPathGeneration = sourceServerPathGeneration;
|
|
123
|
+
const sourcePagesPath = path_1.default.join(sourceFolder, pagesPathSource);
|
|
124
|
+
exports.sourcePagesPath = sourcePagesPath;
|
|
125
|
+
const sourcePublicPath = path_1.default.join(sourceFolder, publicPathSource);
|
|
126
|
+
exports.sourcePublicPath = sourcePublicPath;
|
|
127
|
+
const sourceScriptsPath = path_1.default.join(sourceFolder, scriptsPathSource);
|
|
128
|
+
exports.sourceScriptsPath = sourceScriptsPath;
|
|
129
|
+
const sourceTypesPath = path_1.default.join(sourceFolder, typesPathSource);
|
|
130
|
+
exports.sourceTypesPath = sourceTypesPath;
|
|
131
|
+
// 当前项目的实际文件路径(用于复制现有文件)
|
|
132
|
+
const projectClientPath = path_1.default.join(destFolder, clientPath);
|
|
133
|
+
exports.projectClientPath = projectClientPath;
|
|
134
|
+
const projectPublicPath = path_1.default.join(destFolder, publicPath);
|
|
135
|
+
exports.projectPublicPath = projectPublicPath;
|
|
136
|
+
const destClientPath = path_1.default.join(destFolder, clientPath);
|
|
137
|
+
exports.destClientPath = destClientPath;
|
|
138
|
+
const destClientReduxPath = (0, path_1.resolve)(destClientPath + reduxPath);
|
|
139
|
+
exports.destClientReduxPath = destClientReduxPath;
|
|
140
|
+
const destClientServicePath = (0, path_1.resolve)(destClientPath + servicePath);
|
|
141
|
+
exports.destClientServicePath = destClientServicePath;
|
|
142
|
+
const destClientStyledPath = (0, path_1.resolve)(destClientPath + styledPath);
|
|
143
|
+
exports.destClientStyledPath = destClientStyledPath;
|
|
144
|
+
const destClientStyledLayoutPath = (0, path_1.resolve)(destClientStyledPath + styledLayoutPath);
|
|
145
|
+
exports.destClientStyledLayoutPath = destClientStyledLayoutPath;
|
|
146
|
+
const destClientUtilsPath = (0, path_1.resolve)(destClientPath + utilsPath);
|
|
147
|
+
exports.destClientUtilsPath = destClientUtilsPath;
|
|
148
|
+
const destClientLayoutPath = (0, path_1.resolve)(destClientPath + layoutPath);
|
|
149
|
+
exports.destClientLayoutPath = destClientLayoutPath;
|
|
150
|
+
const destServerPath = path_1.default.join(destFolder, serverPath);
|
|
151
|
+
exports.destServerPath = destServerPath;
|
|
152
|
+
const destServerModulesPath = (0, path_1.resolve)(destServerPath + modulesPath);
|
|
153
|
+
exports.destServerModulesPath = destServerModulesPath;
|
|
154
|
+
const destServerApisPath = (0, path_1.resolve)(destServerPath + apisPath);
|
|
155
|
+
exports.destServerApisPath = destServerApisPath;
|
|
156
|
+
const destServerSqlPath = (0, path_1.resolve)(destServerPath + sqlPath);
|
|
157
|
+
exports.destServerSqlPath = destServerSqlPath;
|
|
158
|
+
const destServerUtilsPath = (0, path_1.resolve)(destServerPath + utilsPath);
|
|
159
|
+
exports.destServerUtilsPath = destServerUtilsPath;
|
|
160
|
+
const destPagesPath = path_1.default.join(destFolder, pagesPath);
|
|
161
|
+
exports.destPagesPath = destPagesPath;
|
|
162
|
+
const destPublicPath = path_1.default.join(destFolder, publicPath);
|
|
163
|
+
exports.destPublicPath = destPublicPath;
|
|
164
|
+
const destScriptsPath = path_1.default.join(destFolder, scriptsPath);
|
|
165
|
+
exports.destScriptsPath = destScriptsPath;
|
|
166
|
+
const destTypesPath = path_1.default.join(destFolder, typesPath);
|
|
167
|
+
exports.destTypesPath = destTypesPath;
|
|
168
|
+
const destClientUtilsMenuPath = (0, path_1.resolve)(destClientUtilsPath + utilsMenuPath);
|
|
169
|
+
exports.destClientUtilsMenuPath = destClientUtilsMenuPath;
|
|
170
|
+
const destClientReduxReducersAllPath = (0, path_1.resolve)(destClientReduxPath + reduxReducersPath);
|
|
171
|
+
exports.destClientReduxReducersAllPath = destClientReduxReducersAllPath;
|
|
172
|
+
const destPublicHealthCheckPath = (0, path_1.resolve)(destPublicPath + slbHealthCheckPath);
|
|
173
|
+
exports.destPublicHealthCheckPath = destPublicHealthCheckPath;
|
|
174
|
+
const destPackagePath = (0, path_1.resolve)(destFolder + packagePath);
|
|
175
|
+
exports.destPackagePath = destPackagePath;
|
|
176
|
+
const destServerRestPath = (0, path_1.resolve)(destServerPath + restPath);
|
|
177
|
+
exports.destServerRestPath = destServerRestPath;
|
package/lib/generate.d.ts
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { ProjectConfig } from './cli/types/project';
|
|
2
|
+
import { FieldDefinition } from './cli/utils/prompt';
|
|
3
|
+
/**
|
|
4
|
+
* 初始化项目文件和目录结构
|
|
5
|
+
* @param dictionary 目标目录名称,空字符串表示当前目录
|
|
6
|
+
* @param upgradeFlag 是否为升级模式,升级模式下不会安装依赖
|
|
7
|
+
* @param projectConfig 项目配置信息(可选)
|
|
8
|
+
*/
|
|
9
|
+
export declare const initFiles: (dictionary: string, upgradeFlag?: boolean, projectConfig?: ProjectConfig) => void;
|
|
10
|
+
/**
|
|
11
|
+
* 创建控制器相关文件
|
|
12
|
+
* @param controller 控制器名称
|
|
13
|
+
* @param action 动作名称
|
|
14
|
+
* @param dictionary 目标目录名称,空字符串表示当前目录
|
|
15
|
+
* @param fields 字段定义数组
|
|
16
|
+
*/
|
|
17
|
+
export declare const createFiles: (controller: string, action: string, dictionary?: string, fields?: FieldDefinition[]) => void;
|
|
18
|
+
/**
|
|
19
|
+
* 删除控制器相关文件
|
|
20
|
+
* @param controller 控制器名称
|
|
21
|
+
* @param action 动作名称
|
|
22
|
+
* @param deleteDBFlag 是否删除数据库相关文件
|
|
23
|
+
* @param dictionary 目标目录名称,空字符串表示当前目录
|
|
24
|
+
*/
|
|
25
|
+
export declare const deleteFiles: (controller: string, action: string, deleteDBFlag?: boolean, dictionary?: string) => void;
|