-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrepoRemover.js
51 lines (41 loc) · 1.23 KB
/
repoRemover.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
const { Octokit } = require("@octokit/core");
// https://github.com/octokit/core.js#readme
// Create a personal access token at https://github.com/settings/tokens/new?scopes=repo
const githubDeleteToken = process.env.githubDeleteToken;
const githubOwner = process.env.githubOwner;
const octokit = new Octokit({ auth: githubDeleteToken });
const remover = async (repo) => {
try {
const res = await octokit.request(`DELETE /repos/${githubOwner}/${repo}`, {
owner: githubOwner,
repo
})
console.log(`res, ${repo} has been removed`);
} catch (error) {
console.log(`Error deleting repo: ${repo}`, error)
}
}
const runDeletes = async (repos) => {
const repoDeletePromises = repos.map(repo => {
return remover(repo);
});
await Promise.all(repoDeletePromises);
}
const getRepos = async () => {
try {
return await octokit.request(`GET /repos/${githubOwner}/`, {
owner: githubOwner
});
} catch (error) {
console.log(error);
}
}
const getReposBySomeCriteria = () => {
const repos = require('./repos');
const repoNames = repos.map((repo)=>{
if (repo.git_url.includes('000')) return repo.name
})
console.log('Repo Names', repoNames);
return repoNames;
}
// runDeletes(repoNames);