-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
executable file
·101 lines (69 loc) · 2.38 KB
/
index.js
File metadata and controls
executable file
·101 lines (69 loc) · 2.38 KB
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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
#!/usr/bin/env node
const gitflow = require('commander');
const chalk = require('chalk')
const figlet = require('figlet')
const clear = require('clear');
const files = require('./lib/files');
const github = require('./lib/github_credentials');
const create_a_repo = require('./lib/create_a_repo');
const { setGithubCredentials } = require('./lib/github_credentials');
const { create } = require('lodash');
gitflow
.command('init')
.description('Draw the app banner')
.action(() => {
clear();
console.log(chalk.magenta(figlet.textSync('gitflow-cli', {horizontalLayout: 'full'})));
})
gitflow
.command('octocheck')
.description('Check github credentials')
.action( async () => {
let token = github.getStoredGithubToken();
if (!token) {
token = await github.setGithubCredentials();
}
console.log(token);
})
gitflow
.command('create_repo')
.description('Create a new repo on github')
.action(async() => {
const getGithubToken = async () => {
let token = github.getStoredGithubToken();
if (token) {
return token;
}
token = await setGithubCredentials();
return token
}
try {
const token = await getGithubToken();
github.githubAuth(token);
const url = await create_a_repo.createRemoteRepo();
await create_a_repo.createGitignore();
const complete = await create_a_repo.setupRepository(url);
if (complete) {
console.log(chalk.green('All done!'));
}
}
catch (err) {
if (err) {
switch(err.status) {
case 401:
console.log(chalk.red('Could not login you in'));
break;
case 422:
console.log(chalk.red('Rep already exists'));
break;
default:
console.log(err);
break;
}
}
}
})
gitflow.parse(process.argv);
if (!gitflow.args.length) {
gitflow.help()
}