-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
57 lines (51 loc) · 1.73 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env node
const clone = require('git-clone')
const program = require('commander')
const shell = require('shelljs')
const log = require('tracer').colorConsole()
const Listr = require('listr')
const package = require("./package.json")
program
.version(package.version)
program
.command('init <project>','初始化一个项目,project为自定义的项目名称')
.action(function (project) {
if (project) {
let pwd = shell.pwd()
let url = `https://github.com/starsion/react-star.git`
// console.log("")
log.info(`Template address:${url}`)
new Listr([
{
title: 'download.....',
task: () => {
return new Promise((resolve, reject) => {
clone(url, pwd + `/${project}`, null, function () {
resolve("ok")
})
})
}
},
{
title: 'setting.....',
task: () => shell.rm('-rf', pwd + `/${project}/.git`)
},
])
.run(
)
.then(
() => {
console.log(`\n\t1 - cd ${project}`)
console.log(`\t2 - npm install`)
console.log(`\t3 - npm run\n`)
}
)
.catch(
(err) => { log.error(err) }
)
} else {
log.error('请输入你的项目名称')
console.log('请输入你的项目名称')
}
})
program.parse(process.argv)