-
Notifications
You must be signed in to change notification settings - Fork 2
/
cli.js
executable file
·70 lines (62 loc) · 2.43 KB
/
cli.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env node
const inquirer = require('inquirer');
const colors = require('colors')
const showBanner = require('node-banner')
const program = require('commander')
const ora = require('ora')
const { CloneRepo, RenameFolder,InstallDepencies,addRedux,updateRepoForRedux} = require('./index')
var questions = [
{type:'list',name:'initRedux',message:colors.green('Do you want to install redux as well'),choices:['yes','no']},
]
const Setup = async () => {
await showBanner('React-Redux-cli','Stupid Cli to automate your setup.')
program
.command('init')
.alias('start')
.description('Start')
.action(function(){
inquirer
.prompt(questions)
.then((answer) => {
var spinner = ora("Installing React").start()
CloneRepo()
.then(() => {
spinner.text="Installing dependencies"
spinner.spinner = "moon"
RenameFolder()
.then(()=> {
InstallDepencies()
.then(() => {
spinner.stop()
console.log(colors.blue("Succesfullly installed your React application \n"))
if(answer.initRedux === "yes"){
spinner = ora("Installing Redux").start()
spinner.spinner = "monkey"
addRedux()
.then(() => {
updateRepoForRedux()
.then(()=> {
spinner.stop()
console.log(colors.bgYellow("Installed Redux!"))
})
})
.catch((err) => {
spinner.stop()
console.err(err)
process.exit(1)
})
}
})
})
.catch((err) => {
console.error(err)
process.exit(1)
})
})
})
})
program.parse(process.argv);
}
module.exports = {
Setup
}