dn-middleware-pkginfo
Advanced tools
Comparing version 1.0.3 to 1.1.0
@@ -9,3 +9,3 @@ const fs = require('fs'); | ||
*/ | ||
module.exports = function () { | ||
module.exports = function (opts) { | ||
@@ -17,5 +17,27 @@ //外层函数的用于接收「参数对象」 | ||
if (!this.inquirer) { | ||
throw new Error('请升级 dbl-next 到最新版本'); | ||
throw new Error('请升级 dawn 到最新版本'); | ||
} | ||
opts.items = opts.items || [{ | ||
name: 'name', | ||
type: 'input', | ||
default: path.basename(this.cwd), | ||
message: '请输入项目名称', | ||
validate: function (name) { | ||
return !!name; | ||
} | ||
}, { | ||
name: 'version', | ||
type: 'input', | ||
message: '请输入初始版本', | ||
default: '1.0.0', | ||
validate: function (version) { | ||
return !!version; | ||
} | ||
}, { | ||
name: 'description', | ||
type: 'input', | ||
message: '请输入项目描述' | ||
}]; | ||
let pkgFile = `${this.cwd}/package.json`; | ||
@@ -25,26 +47,5 @@ if (fs.existsSync(pkgFile)) { | ||
let pkg = require(pkgFile); | ||
let result = await this.inquirer.prompt([{ | ||
name: 'name', | ||
type: 'input', | ||
default: path.basename(this.cwd), | ||
message: '请输入项目名称', | ||
validate: function (name) { | ||
return !!name; | ||
} | ||
}, { | ||
name: 'version', | ||
type: 'input', | ||
message: '请输入初始版本', | ||
default: '1.0.0', | ||
validate: function (version) { | ||
return !!version; | ||
} | ||
}, { | ||
name: 'description', | ||
type: 'input', | ||
message: '请输入项目描述' | ||
}]); | ||
pkg.name = result.name; | ||
pkg.version = result.version; | ||
pkg.description = result.description; | ||
let result = await this.inquirer.prompt(opts.items); | ||
Object.assign(pkg, result); | ||
this.project = pkg; | ||
await this.utils.writeFile(pkgFile, JSON.stringify(pkg, null, ' ')); | ||
@@ -51,0 +52,0 @@ this.console.info('完成'); |
{ | ||
"name": "dn-middleware-pkginfo", | ||
"version": "1.0.3", | ||
"description": "", | ||
"version": "1.1.0", | ||
"description": "用于根据用户输入配置 package 中的信息", | ||
"main": "./lib/index.js", | ||
@@ -6,0 +6,0 @@ "scripts": { |
@@ -1,1 +0,1 @@ | ||
# 中件间工程模板 | ||
# 中间件工程模板 |
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
2084
5