mirror of
https://github.com/spacebarchat/spacebarchat.git
synced 2024-11-25 11:52:56 +01:00
✨ rename issues script
This commit is contained in:
parent
2a198aabbf
commit
215f5d5196
3
scripts/github/config.example.json
Normal file
3
scripts/github/config.example.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"token": ""
|
||||
}
|
30
scripts/github/package-lock.json
generated
Normal file
30
scripts/github/package-lock.json
generated
Normal file
@ -0,0 +1,30 @@
|
||||
{
|
||||
"name": "github",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"version": "1.0.0",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"node-fetch": "^2.6.1"
|
||||
}
|
||||
},
|
||||
"node_modules/node-fetch": {
|
||||
"version": "2.6.1",
|
||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz",
|
||||
"integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==",
|
||||
"engines": {
|
||||
"node": "4.x || >=6.0.0"
|
||||
}
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"node-fetch": {
|
||||
"version": "2.6.1",
|
||||
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz",
|
||||
"integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw=="
|
||||
}
|
||||
}
|
||||
}
|
15
scripts/github/package.json
Normal file
15
scripts/github/package.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "github",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "rename_issues.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"node-fetch": "^2.6.1"
|
||||
}
|
||||
}
|
57
scripts/github/rename_issues.js
Normal file
57
scripts/github/rename_issues.js
Normal file
@ -0,0 +1,57 @@
|
||||
const { token } = require("./config.json");
|
||||
const fetch = require("node-fetch");
|
||||
const base = "https://api.github.com";
|
||||
const organization = "fosscord";
|
||||
|
||||
const request = async (path, opts = {}) =>
|
||||
await fetch(`${base}${path}`, {
|
||||
...opts,
|
||||
headers: {
|
||||
...opts.headers,
|
||||
Authorization: `token ${token}`,
|
||||
},
|
||||
}).then((response) => response.json());
|
||||
|
||||
async function getRepos() {
|
||||
return (await request(`/orgs/${organization}/repos`)).map((repo) => repo.name);
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const repos = await getRepos();
|
||||
for (const repo of repos) {
|
||||
var page = 1;
|
||||
do {
|
||||
var issues = await request(`/repos/${organization}/${repo}/issues?state=all&per_page=100&page=${page}`);
|
||||
for (const issue of issues) {
|
||||
const replacer = [
|
||||
"[Feature]",
|
||||
"[BUG]",
|
||||
"[Bug]",
|
||||
"[Security]",
|
||||
"[Route]",
|
||||
"[Voice]",
|
||||
"[Page]",
|
||||
"[Media]",
|
||||
"[Gateway]",
|
||||
"[Fix]",
|
||||
"[Plugin]",
|
||||
];
|
||||
const newTitle = replacer.reduce((acc, curr) => acc.replace(curr, ""), issue.title).trim();
|
||||
|
||||
if (newTitle !== issue.title) {
|
||||
console.log(`old: ${issue.title}, new: ${newTitle}`, issue.number);
|
||||
// continue;
|
||||
await request(`/repos/${organization}/${repo}/issues/${issue.number}`, {
|
||||
method: "PATCH",
|
||||
body: JSON.stringify({ title: newTitle }),
|
||||
});
|
||||
}
|
||||
}
|
||||
page++;
|
||||
} while (issues.length);
|
||||
}
|
||||
}
|
||||
|
||||
main()
|
||||
.then(() => console.log("done"))
|
||||
.catch(console.error);
|
Loading…
Reference in New Issue
Block a user