-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
64 lines (56 loc) · 1.88 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
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env node
const chalk = require('chalk');
const figlet = require('figlet');
const clear = require('clear');
const CLI = require('clui');
const Spinner = CLI.Spinner;
const inquirer = require('./lib/inquirer');
const github = require('./lib/github');
const repo = require('./lib/repo');
const status = new Spinner('Loading repos, please wait..');
// Clear the screen and
// display banner text 'Git CleanUp'
clear();
console.log(
chalk.yellow(
figlet.textSync('Git Cleanup', { horizontalLayout: 'full', kerning: 'full' })
));
// Ask for user's Github credentials
const run = async () => {
let token = github.getStoredGithubToken()
let owner_name = github.getStoredUserName()
if (!token) {
await github.setGithubCredentials()
token = await github.regsiterNewToken()
owner_name = github.getStoredUserName()
}
status.start();
let repos = await repo.getPrivateRepos(token)
if (repos === null) {
console.log(chalk.red(`No private repos found!`))
}
else {
status.stop();
while (1) {
let action = await inquirer.askUserActions();
if (action.option === 'Clone and delete all the private repos') {
repo.cloneAndDelete(repos, token);
}
// Extremely dangerous, use with caution!
else if (action.option === 'Delete all the private repos without cloning') {
repo.delete(owner_name, repos, token);
}
else if (action.option === 'Make all private repos public') {
repo.public(owner_name, repos, token);
}
else if (action.option === 'Quit') {
process.exit();
}
}
/* else if(action.option === 'Make selected private repos public') {
console.log('making selected public')
} */
}
}
// Run the script
run();