fix: 完善后处理清理逻辑

 postProcessCleanup 增强:
- 修复 !xxx === 'yyy' → xxx !== 'yyy' (通用)
- 修复 this.config.get('xxx' + yyy).exists() → fs.existsSync(...)

🎯 效果:
- 解决更多逻辑运算符优先级问题
- 正确处理复杂表达式的exists()调用
This commit is contained in:
wanwu
2025-10-29 13:56:23 +08:00
parent bad1b60aa4
commit 9626ae5ecd
3 changed files with 10 additions and 3 deletions

View File

@@ -80,6 +80,13 @@ class ServiceMethodConverter {
return `if (${configCall} !== ${value})`;
});
// 3. 修复 !xxx === "yyy" → xxx !== "yyy" (通用)
tsBody = tsBody.replace(/!\s*([a-zA-Z_$.()[\]]+)\s*===\s*([^;)\n]+)/g, '$1 !== $2');
// 4. 修复复杂表达式的 .exists()
// this.config.get('xxx' + yyy).exists() → fs.existsSync(this.config.get('xxx' + yyy))
tsBody = tsBody.replace(/(this\.config\.get\([^)]+\))\.exists\(\)/g, 'fs.existsSync($1)');
return tsBody;
}

View File

@@ -16,7 +16,7 @@ export class AddonDevelopBuildServiceImplService {
* build
*/
async build(...args: any[]): Promise<any> {
if (!this.config.get('runActive') === "dev") throw new BadRequestException("只有在开发环境下才可以进行打包操作");
if (this.config.get('runActive') !== "dev") throw new BadRequestException("只有在开发环境下才可以进行打包操作");
if (!this.config.get('projectNiucloudAddon' + addon).exists()) throw new BadRequestException("插件不存在");
const infoFile: string = this.config.get('projectNiucloudAddon' + addon + "/src/main/resources/info.json");
@@ -26,7 +26,7 @@ export class AddonDevelopBuildServiceImplService {
this.addonPath = this.config.get('webRootDownAddon') + addon + "/";
try {
for (const child of this.fs.readdirSync(addonPath)) {
for (const child of fs.readdirSync(addonPath)) {
if (fs.lstatSync(child).isDirectory() && !path.basename(child) === "sql") fs.rmSync(child, { recursive: true, force: true });
}
fs.copyFileSync(infoFile, this.addonPath + "info.json");

View File

@@ -327,7 +327,7 @@ export class GenerateServiceImplService {
const zipFile: string = ZipUtil.zip(packageDir, tempDir + "package.zip");
} else {
// 同步
if (!this.config.get('envType') === "dev") throw new BadRequestException("只有在开发模式下才能进行同步代码");
if (this.config.get('envType') !== "dev") throw new BadRequestException("只有在开发模式下才能进行同步代码");
for (const coreGenerateTemplateVo of list) {
if (coreGenerateTemplateVo.getType() === "sql") {