nsgm-cli 2.1.34 → 2.1.35

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.
@@ -79,14 +79,14 @@ const cleanupReducers = (controller, reducersPath) => {
79
79
  const cleanupMenu = (controller, menuPath) => {
80
80
  // 读取文件内容
81
81
  let content = fs_1.default.readFileSync(menuPath, "utf8");
82
- // 删除所有匹配的菜单项(使用与 generate_delete.ts 相同的正则)
83
- content = content.replace(new RegExp(`,?\\s*\\{\\s*//\\s*${controller}_.*_start[\\s\\S]*?//\\s*${controller}_.*_end\\s*\\}\\s*,?`, "gm"), "");
84
- // 修复连续逗号
82
+ // 删除所有匹配的菜单项(使用与 generate_delete.ts 相同的正则,替换为逗号)
83
+ content = content.replace(new RegExp(`,?\\s*\\{\\s*//\\s*${controller}_.*_start[\\s\\S]*?//\\s*${controller}_.*_end\\s*\\}\\s*,?`, "gm"), ",");
84
+ // 修复连续逗号(删除可能留下 ,,)
85
85
  content = content.replace(/,,+/g, ",");
86
- // 修复对象前多余的逗号
86
+ // 修复数组开头多余的逗号 ([, { -> [ {)
87
+ content = content.replace(/\[\s*,\s*\{/gm, "[\n {");
88
+ // 修复对象前多余的逗号(, { -> {)
87
89
  content = content.replace(/\n\s*,\s*\{/gm, "\n {");
88
- // 修复数组中缺失的逗号
89
- content = content.replace(/(\})\s*(\{)/gm, "$1,\n $2");
90
90
  // 清理缩进问题
91
91
  content = content.replace(/^[ ]{0,2}\/\*\{/gm, " /*{");
92
92
  content = content.replace(/^[ ]{0,4}key:/gm, " key:");