-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.js
More file actions
29 lines (23 loc) · 905 Bytes
/
main.js
File metadata and controls
29 lines (23 loc) · 905 Bytes
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
import "dotenv/config";
import { Octokit } from "@octokit/core";
import {
getStaredRepositories, sortRepositoriesBy, starRepository, unstarRepository
} from "./src/api/api.js"
import { delay, log } from "./src/utils/utils.js";
const USER_TOKEN = process.env.USER_TOKEN;
const octokit = new Octokit({
auth: USER_TOKEN
})
const staredRepositories = await getStaredRepositories(octokit);
const sortedRepositories = await sortRepositoriesBy(staredRepositories, "name");
let count = 1;
staredRepositories.forEach(repository => {
log(`${count++} | ${repository.owner.login} / ${repository.name}\n`);
});
count = 1;
for (const repository of sortedRepositories) {
console.log(count++, repository.name, repository.owner.login)
await unstarRepository(octokit, repository.owner.login, repository.name);
await starRepository(octokit, repository.owner.login, repository.name);
await delay(3000);
}