first commit
This commit is contained in:
1
whtml-cli/bin/.pydio
Normal file
1
whtml-cli/bin/.pydio
Normal file
@@ -0,0 +1 @@
|
||||
31a084b9-4616-4629-9b7e-1b1a17db3970
|
||||
8
whtml-cli/bin/whtml
Executable file
8
whtml-cli/bin/whtml
Executable file
@@ -0,0 +1,8 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
require('commander')
|
||||
.version(require('../package').version)
|
||||
.usage('<command> [options]')
|
||||
.command('init', 'generate a new project from a template')
|
||||
.command('list', 'list available official templates')
|
||||
.parse(process.argv)
|
||||
50
whtml-cli/bin/whtml-init
Executable file
50
whtml-cli/bin/whtml-init
Executable file
@@ -0,0 +1,50 @@
|
||||
#!/usr/bin/env node
|
||||
const program = require('commander')
|
||||
const exec = require('child_process').exec
|
||||
const chalk = require('chalk')
|
||||
const ora = require('ora')
|
||||
const { GetUserInfo } = require('./../lib')
|
||||
const config = require('../package')
|
||||
|
||||
program.on('--help', () => {
|
||||
console.log()
|
||||
console.log(' Examples:')
|
||||
console.log()
|
||||
console.log(chalk.gray(' # create a new project with an official template'))
|
||||
console.log(' $ whtml init my-project')
|
||||
console.log()
|
||||
})
|
||||
|
||||
|
||||
function help () {
|
||||
program.parse(process.argv)
|
||||
if (program.args.length < 1) return program.help()
|
||||
}
|
||||
help()
|
||||
|
||||
|
||||
|
||||
let projectName = program.args[0], gitUrl, branch, cmdStr
|
||||
gitUrl = config.git.url, branch = config.git.branch
|
||||
cmdStr = `git clone ${gitUrl} ${projectName} && cd ${projectName} && git checkout ${branch}`
|
||||
|
||||
run(cmdStr)
|
||||
GetUserInfo()
|
||||
const spinner = ora('downloading template...')
|
||||
spinner.start()
|
||||
|
||||
function run(url){
|
||||
exec(url, (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
console.log(error)
|
||||
process.exit()
|
||||
}
|
||||
spinner.stop()
|
||||
console.log(chalk.green('\n √ Download Success...'))
|
||||
console.log(chalk.green(`\n cd ${projectName} #Enter the folder\n npm install #Resolve dependence\n npm run all #Running project`))
|
||||
console.log()
|
||||
process.exit()
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
13
whtml-cli/bin/whtml-list
Executable file
13
whtml-cli/bin/whtml-list
Executable file
@@ -0,0 +1,13 @@
|
||||
#!/usr/bin/env node
|
||||
|
||||
const config = require('../package')
|
||||
const chalk = require('chalk')
|
||||
|
||||
console.log()
|
||||
console.log(
|
||||
chalk.green(
|
||||
`作者:${config.git.auto}\n项目地址:${config.git.url} \n分支:${config.git.branch}`
|
||||
)
|
||||
)
|
||||
console.log()
|
||||
process.exit()
|
||||
Reference in New Issue
Block a user