Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cli
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
lhfe
cli
Commits
22369114
Commit
22369114
authored
Mar 29, 2021
by
lipengcheng
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
0329
parent
666b0d6c
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
7 deletions
+15
-7
README.md
README.md
+5
-0
Creator.js
lib/Creator.js
+5
-6
utils.js
lib/utils.js
+5
-1
No files found.
README.md
View file @
22369114
...
...
@@ -6,6 +6,9 @@
-
[
x
]
未知的命令给出相关的建议命令
-
[
x
]
通过pkg.engines及semver指定项目的工作环境
-
[
]
this.run给仓库做git初始化操作 -- vuecli
-
[
]
vuecli中对ora(spinner)使用的封装
-
[
]
vuecli中对log的封装(logger)
-
[
]
command
<list>
显示模板列表
#### Q
metalsmith是什么?
handlerbar?
...
...
@@ -80,6 +83,8 @@ semver:版本号控制 -- vuelci
slash: 将window反斜杠路径转换为斜杠路径 foo
\\
bar ➔ foo/bar -- vuecli
minimist:解析参数选项 -- vuecli
validate-npm-package-name:判断作为pkgname的某个字符串是否已经存在
ncpjs:异步文件目录递归复制
模板引擎:consolidatejs、handlebars、ejs、jade、swig
#### 创建项目逻辑
...
...
lib/Creator.js
View file @
22369114
...
...
@@ -12,6 +12,7 @@ module.exports = class Creator {
constructor
(
projectname
,
targetDir
)
{
this
.
name
=
projectname
this
.
target
=
targetDir
this
.
tmpTarget
=
path
.
resolve
(
targetDir
,
'.tmp'
)
this
.
downlodRepo
=
util
.
promisify
(
downlodRepo
)
}
...
...
@@ -57,7 +58,8 @@ module.exports = class Creator {
}
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
);
// 优化:先下载到系统目录中(用作缓存),再使用ejs handlerbar渲染模板,然后再写入到目标目录
// await this.downlodRepo(requestUrl, path.resolve(process.cwd(), `${repo}@${tag}`))
...
...
@@ -103,10 +105,7 @@ module.exports = class Creator {
// function (err) {
// console.log(err || 'Success')
// })
await
this
.
downlodRepo
(
url
,
path
.
resolve
(
process
.
cwd
(),
`aaaa`
),
{
clone
:
true
})
.
then
(()
=>
{
})
.
catch
((
err
)
=>
console
.
log
(
`err:`
,
err
))
await
wrapLoading
(
this
.
downlodRepo
,
'Waitting for download。。。'
,
url
,
this
.
tmpTarget
,
{
clone
:
true
})
}
}
\ No newline at end of file
lib/utils.js
View file @
22369114
...
...
@@ -20,7 +20,11 @@ function execute(cmd) {
});
}
// 睡觉方法
/**
* sleep
* @param {Number} ms 毫秒
* @returns promise
*/
async
function
sleep
(
ms
)
{
return
new
Promise
((
resolve
,
rejecrt
)
=>
setTimeout
(
resolve
(),
ms
))
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment