🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

hlj-cli

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hlj-cli - npm Package Compare versions

Comparing version
1.3.3
to
1.3.6
+44
-44
command/init.js

@@ -5,49 +5,49 @@ const co = require('co')

const chalk = require('chalk')
const fs = require("fs")
const path = require("path")
const fs = require('fs')
const path = require('path')
const exec = require('child_process').exec
const deleteFolder = function (path) {
let files = []
if (fs.existsSync(path)) {
files = fs.readdirSync(path)
files.forEach(function (file, index) {
let curPath = path + "/" + file
if (fs.statSync(curPath).isDirectory()) {
deleteFolder(curPath)
} else {
fs.unlinkSync(curPath)
}
})
fs.rmdirSync(path)
}
const deleteFolder = function(path) {
let files = []
if (fs.existsSync(path)) {
files = fs.readdirSync(path)
files.forEach(function(file, index) {
let curPath = path + '/' + file
if (fs.statSync(curPath).isDirectory()) {
deleteFolder(curPath)
} else {
fs.unlinkSync(curPath)
}
})
fs.rmdirSync(path)
}
}
module.exports = () => {
co(function *() {
let tplName = yield prompt('Template name: ')
let projectName = yield prompt('Project name: ')
let gitUrl
let branch
tplName=tplName.toLocaleLowerCase().trim()
if (!config.tpl[tplName]) {
console.log(chalk.red('\n × Template does not exit!'))
process.exit()
}
gitUrl = config.tpl[tplName].url
branch = config.tpl[tplName].branch || 'master'
const cmdStr = `git clone ${gitUrl} ${projectName} && cd ${projectName} && git checkout ${branch}`
console.log(chalk.white('\n Start generating...'))
exec(cmdStr, (error, stdout, stderr) => {
if (error) {
console.log(error)
process.exit()
}
const gitPath = path.join(process.cwd(), projectName, '.git')
deleteFolder(gitPath)
console.log(chalk.green('\n √ Generation completed!'))
console.log(chalk.green(`\n cd ${projectName}`))
console.log(chalk.green('\n npm install or yarn'))
console.log(chalk.green('\n npm start or yarn start'))
process.exit()
})
co(function*() {
let tplName = yield prompt('Template name: ')
let projectName = yield prompt('Project name: ')
let gitUrl
let branch
tplName = tplName.toLocaleLowerCase().trim()
if (!config.tpl[tplName]) {
console.log(chalk.red('\n × Template does not exit!'))
process.exit()
}
gitUrl = config.tpl[tplName].url
branch = config.tpl[tplName].branch || 'master'
const cmdStr = `git clone ${gitUrl} ${projectName} && cd ${projectName} && git checkout ${branch}`
console.log(chalk.white('\n Start generating...'))
exec(cmdStr, (error, stdout, stderr) => {
if (error) {
console.log(error)
process.exit()
}
const gitPath = path.join(process.cwd(), projectName, '.git')
deleteFolder(gitPath)
console.log(chalk.green('\n √ Generation completed!'))
console.log(chalk.green(`\n cd ${projectName}`))
console.log(chalk.green('\n npm install or yarn'))
console.log(chalk.green('\n npm start or yarn start'))
process.exit()
})
}
})
}
{
"name": "hlj-cli",
"version": "1.3.3",
"version": "1.3.6",
"description": "A simple CLI for creating your projects",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -14,19 +14,8 @@ ![hlj Logo](./logo1.png)

# template Looks like :
```
{
"tpl": {
"react": {
"url": "https://github.com/hunliji/hlj-react-template.git",
"branch": "master"
},
"vue":{
"url": "https://github.com/hunliji/hlj-vue-template.git",
"branch": "master"
}
}
}
```
# template name :
-- react
-- vue
-- antd