maruko-cli
Advanced tools
Comparing version 1.0.2 to 1.0.3
@@ -103,2 +103,21 @@ const fs = require('fs') | ||
async checkExist(path,pathAlias = `${this.fileNameCap}.${this.result.command}`){ | ||
if(fs.existsSync(path)){ | ||
const input = await inquirer.prompt({ | ||
name:'cover', | ||
type:'confirm', | ||
message:`${pathAlias} 已存在,是否覆盖原始文件`, | ||
default: false, | ||
}) | ||
return { | ||
cover:input.cover | ||
} | ||
} | ||
return { | ||
cover:true | ||
} | ||
} | ||
async componentGen(destPath){ | ||
@@ -109,2 +128,6 @@ // 生成组件 | ||
const destDir = destPath + '/' + destDirName; | ||
const { cover } = await this.checkExist(destDir); | ||
if(!cover) return; | ||
shell.cd(destPath); | ||
@@ -125,5 +148,9 @@ shell.mkdir(destDirName); | ||
async dtoGen(destPath){ | ||
async dtoGen(destPath,optional = false){ | ||
// 生成 DTO | ||
const sourceDir = this.templatePath + '/@dto/*'; | ||
const { cover } = await this.checkExist(destPath + `/${this.fileName}.${this.result.command}.ts`); | ||
if(!cover) return; | ||
shell.cd(destPath); | ||
@@ -140,3 +167,9 @@ shell.cp('-R',sourceDir,destPath); | ||
await this.genOptionalFile(); | ||
if(optional){ | ||
this.fileQueue.push( | ||
this.fileNameCap + '.dto' | ||
) | ||
}else{ | ||
await this.genOptionalFile(); | ||
} | ||
} | ||
@@ -149,3 +182,3 @@ | ||
optionalCommand = ''; | ||
const { alias,command } = this.result; | ||
const { alias } = this.result; | ||
if(alias === 'd'){ | ||
@@ -155,2 +188,6 @@ optionalMsg = '是否同步生成对应的 Service 文件' | ||
optionalCommand = 'service'; | ||
}else if(alias === 's'){ | ||
optionalMsg = '是否同步生成对应的 Dto 文件' | ||
optionalPath = config.pathSuffix.dto.validPaths[0]; | ||
optionalCommand = 'dto'; | ||
} | ||
@@ -173,2 +210,6 @@ | ||
const sourceDir = this.templatePath + '/@enum/*'; | ||
const { cover } = await this.checkExist(destPath + `/${this.fileName}.${this.result.command}.ts`); | ||
if(!cover) return; | ||
shell.cd(destPath); | ||
@@ -190,2 +231,6 @@ shell.cp('-R',sourceDir,destPath); | ||
const sourceDir = this.templatePath + '/@service/*'; | ||
const { cover } = await this.checkExist(destPath + `/${this.fileName}.${this.result.command}.ts`); | ||
if(!cover) return; | ||
shell.cd(destPath); | ||
@@ -208,2 +253,4 @@ shell.cp('-R',sourceDir,destPath); | ||
) | ||
}else{ | ||
await this.genOptionalFile(); | ||
} | ||
@@ -210,0 +257,0 @@ } |
{ | ||
"name": "maruko-cli", | ||
"version": "1.0.2", | ||
"version": "1.0.3", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12271
320