nsgm-cli 2.1.32 → 2.1.33
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.
|
@@ -53,6 +53,7 @@ const deleteModuleFiles = (paths) => {
|
|
|
53
53
|
];
|
|
54
54
|
directoriesToDelete.forEach((dir) => (0, utils_2.rmdirSync)(dir));
|
|
55
55
|
filesToDelete.forEach((file) => (0, utils_2.rmFileSync)(file));
|
|
56
|
+
console.log(`✅ 已删除 ${directoriesToDelete.length} 个目录和 ${filesToDelete.length} 个文件`);
|
|
56
57
|
};
|
|
57
58
|
/**
|
|
58
59
|
* 清理 reducers 配置
|
|
@@ -70,13 +71,14 @@ const cleanupReducers = (controller, reducersPath) => {
|
|
|
70
71
|
shelljs_1.default.sed("-i", /\{\s*,\s*\}/, "{}", reducersPath);
|
|
71
72
|
// 标准化空行
|
|
72
73
|
shelljs_1.default.sed("-i", /\n\s*\n\s*\n/g, "\n\n", reducersPath);
|
|
74
|
+
console.log(`✅ 已清理 reducers 配置: ${controller}`);
|
|
73
75
|
};
|
|
74
76
|
/**
|
|
75
77
|
* 清理菜单配置
|
|
76
78
|
*/
|
|
77
79
|
const cleanupMenu = (controller, menuPath) => {
|
|
78
|
-
//
|
|
79
|
-
shelljs_1.default.sed("-i", new RegExp(`,?\\s*\\{\\s*//\\s*${controller}_\\w+_start[\\s\\S]*?//\\s*${controller}_\\w+_end\\s
|
|
80
|
+
// 删除所有匹配的菜单项(匹配多行结构)
|
|
81
|
+
shelljs_1.default.sed("-i", new RegExp(`,?\\s*\\{\\s*//\\s*${controller}_\\w+_start[\\s\\S]*?//\\s*${controller}_\\w+_end[\\s\\S]*?\\n\\s*\\}\\s*,?`, "gm"), "", menuPath);
|
|
80
82
|
// 修复连续逗号
|
|
81
83
|
shelljs_1.default.sed("-i", /,,+/g, ",", menuPath);
|
|
82
84
|
// 修复对象前多余的逗号
|
|
@@ -91,6 +93,7 @@ const cleanupMenu = (controller, menuPath) => {
|
|
|
91
93
|
shelljs_1.default.sed("-i", /^[ ]{0,4}icon:/gm, " icon:", menuPath);
|
|
92
94
|
shelljs_1.default.sed("-i", /^[ ]{0,4}subMenus:/gm, " subMenus:", menuPath);
|
|
93
95
|
shelljs_1.default.sed("-i", /^[ ]{0,2}\}\*\//gm, " }*/", menuPath);
|
|
96
|
+
console.log(`✅ 已清理菜单配置: ${controller}`);
|
|
94
97
|
};
|
|
95
98
|
/**
|
|
96
99
|
* 清理 REST API 配置
|
|
@@ -100,6 +103,7 @@ const cleanupRestApi = (controller, restPath) => {
|
|
|
100
103
|
shelljs_1.default.sed("-i", new RegExp(`^const\\s+${controller}\\s*=\\s*require.*${controller}['"].*$`, "gm"), "", restPath);
|
|
101
104
|
// 删除 router.use 语句
|
|
102
105
|
shelljs_1.default.sed("-i", new RegExp(`^router\\.use\\(['"]\\/${controller}['"]\\s*,\\s*${controller}\\)\\s*$`, "gm"), "", restPath);
|
|
106
|
+
console.log(`✅ 已清理 REST API 配置: ${controller}`);
|
|
103
107
|
};
|
|
104
108
|
/**
|
|
105
109
|
* 删除数据库表
|
|
@@ -253,28 +257,30 @@ exports.deleteConfigCommand = {
|
|
|
253
257
|
for (const module of targetModules) {
|
|
254
258
|
utils_1.Console.separator();
|
|
255
259
|
utils_1.Console.highlight(`🗑️ 删除模块 ${successCount + failureCount + 1}/${targetModules.length}: ${module.controller}`);
|
|
260
|
+
utils_1.Console.newLine();
|
|
256
261
|
try {
|
|
257
|
-
const spinner = utils_1.Console.spinner("正在删除文件...", "red");
|
|
258
|
-
spinner.start();
|
|
259
262
|
// 生成删除路径
|
|
260
263
|
const paths = generateDeletePaths(module.controller, module.dictionary);
|
|
261
264
|
// 1. 删除文件和目录
|
|
265
|
+
utils_1.Console.info("📁 正在删除文件和目录...");
|
|
262
266
|
deleteModuleFiles(paths);
|
|
263
267
|
// 2. 清理配置文件
|
|
268
|
+
utils_1.Console.info("🔧 正在清理配置文件...");
|
|
264
269
|
cleanupReducers(module.controller, paths.destClientReduxReducersAllPath);
|
|
265
270
|
cleanupRestApi(module.controller, paths.destServerRestPath);
|
|
266
271
|
cleanupMenu(module.controller, paths.destClientUtilsMenuPath);
|
|
267
272
|
// 3. 删除数据库表(如果指定)
|
|
268
273
|
if (options.db) {
|
|
274
|
+
utils_1.Console.info("💾 正在删除数据库表...");
|
|
269
275
|
dropDatabaseTable(module.controller);
|
|
270
276
|
}
|
|
271
|
-
|
|
272
|
-
successCount++;
|
|
277
|
+
utils_1.Console.success(`✅ ${module.controller} 删除完成!`);
|
|
273
278
|
utils_1.Console.newLine();
|
|
279
|
+
successCount++;
|
|
274
280
|
}
|
|
275
281
|
catch (error) {
|
|
276
282
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
277
|
-
utils_1.Console.error(
|
|
283
|
+
utils_1.Console.error(`❌ 错误: ${errorMessage}`);
|
|
278
284
|
failures.push({ module: module.controller, error: errorMessage });
|
|
279
285
|
failureCount++;
|
|
280
286
|
utils_1.Console.newLine();
|