Commit 22369114 authored by lipengcheng 's avatar lipengcheng

0329

parent 666b0d6c
...@@ -6,6 +6,9 @@ ...@@ -6,6 +6,9 @@
- [x] 未知的命令给出相关的建议命令 - [x] 未知的命令给出相关的建议命令
- [x] 通过pkg.engines及semver指定项目的工作环境 - [x] 通过pkg.engines及semver指定项目的工作环境
- [ ] this.run给仓库做git初始化操作 -- vuecli - [ ] this.run给仓库做git初始化操作 -- vuecli
- [ ] vuecli中对ora(spinner)使用的封装
- [ ] vuecli中对log的封装(logger)
- [ ] command <list> 显示模板列表
#### Q #### Q
metalsmith是什么? metalsmith是什么?
handlerbar? handlerbar?
...@@ -80,6 +83,8 @@ semver:版本号控制 -- vuelci ...@@ -80,6 +83,8 @@ semver:版本号控制 -- vuelci
slash: 将window反斜杠路径转换为斜杠路径 foo\\bar ➔ foo/bar -- vuecli slash: 将window反斜杠路径转换为斜杠路径 foo\\bar ➔ foo/bar -- vuecli
minimist:解析参数选项 -- vuecli minimist:解析参数选项 -- vuecli
validate-npm-package-name:判断作为pkgname的某个字符串是否已经存在 validate-npm-package-name:判断作为pkgname的某个字符串是否已经存在
ncpjs:异步文件目录递归复制
模板引擎:consolidatejs、handlebars、ejs、jade、swig
#### 创建项目逻辑 #### 创建项目逻辑
......
...@@ -12,6 +12,7 @@ module.exports = class Creator { ...@@ -12,6 +12,7 @@ module.exports = class Creator {
constructor(projectname, targetDir) { constructor(projectname, targetDir) {
this.name = projectname this.name = projectname
this.target = targetDir this.target = targetDir
this.tmpTarget = path.resolve(targetDir, '.tmp')
this.downlodRepo = util.promisify(downlodRepo) this.downlodRepo = util.promisify(downlodRepo)
} }
...@@ -57,7 +58,8 @@ module.exports = class Creator { ...@@ -57,7 +58,8 @@ module.exports = class Creator {
} }
async exeDownload(repo, tag) { async exeDownload(repo, tag) {
let requestUrl = `${ORG}/${repo}${tag ? `#${tag}` : ''}` // let requestUrl = `${ORG}/${repo}${tag ? `#${tag}` : ''}`
let requestUrl = ORG + '/' + repo + tag ? `#${tag}` : ''
console.log(`requestUrl:`,requestUrl); console.log(`requestUrl:`,requestUrl);
// 优化:先下载到系统目录中(用作缓存),再使用ejs handlerbar渲染模板,然后再写入到目标目录 // 优化:先下载到系统目录中(用作缓存),再使用ejs handlerbar渲染模板,然后再写入到目标目录
// await this.downlodRepo(requestUrl, path.resolve(process.cwd(), `${repo}@${tag}`)) // await this.downlodRepo(requestUrl, path.resolve(process.cwd(), `${repo}@${tag}`))
...@@ -103,10 +105,7 @@ module.exports = class Creator { ...@@ -103,10 +105,7 @@ module.exports = class Creator {
// function (err) { // function (err) {
// console.log(err || 'Success') // console.log(err || 'Success')
// }) // })
await wrapLoading(this.downlodRepo, 'Waitting for download。。。', url, this.tmpTarget, { clone: true })
await this.downlodRepo(url, path.resolve(process.cwd(), `aaaa`), { clone: true })
.then(() => { })
.catch((err) => console.log(`err:`, err))
} }
} }
\ No newline at end of file
...@@ -20,7 +20,11 @@ function execute(cmd) { ...@@ -20,7 +20,11 @@ function execute(cmd) {
}); });
} }
// 睡觉方法 /**
* sleep
* @param {Number} ms 毫秒
* @returns promise
*/
async function sleep(ms) { async function sleep(ms) {
return new Promise((resolve, rejecrt) => setTimeout(resolve(), ms)) return new Promise((resolve, rejecrt) => setTimeout(resolve(), ms))
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment