I think when you use the GitHub issues, probably many of you need to add/change labels. Actually, the default labels are well... not ideal. Generally, I add some new labels manually after I push the initial commit. That means I go to the issue board and add a label.
After reading the articles, I thought preparing labels that articles mentioned would be ↓
The usage of the Labels API is very simple. We just need to pass a couple of parameters and create an instance with GitHub personal token since there is a JS library “octokit” that allows us to use the API easily.
If you need a minimalistic library to utilize GitHub's REST API and GraphQL API which you can extend with plugins as needed, then @octokit/core is a great starting point.
I wrote a simple application with Nodejs and Typescript.
I used a typescript-starter to save time for setup. typescript-starter is useful, but it was a little bit too much for this since the ESlint configuration helped me to detect issues but at the same time prevent running the script quickly lol.
Quickly create and configure a new library or Node.js project
Start Now
Run one simple command to install and use the interactive project generator. You'll need Nodev10 or later.
npx typescript-starter
The interactive CLI will help you create and configure your project automatically.
Since this repo includes the CLI and it's tests, you'll only need to fork or clone this project if you want to contribute. If you find this project useful, please consider leaving a star so others can find it. Thanks!
Features
Write standard, future javascript – with stable ESNext features – today (stage 3 or finished features)
// label format
{
"id": 3218144327,
"node_id": "MDU6TGFiZWwzMjE4MTQ0MzI3",
"url": "https://api.github.com/repos/koji/frontend-tools/labels/wontfix",
"name": "wontfix",
"color": "ffffff",
"default": true,
"description": "This will not be worked on"
}
This Nodejs script will ask you 3 things initially. GitHub personal token(wont’ keep it anywhere), GitHub id, and a target repo name.
It will offer 4 simple functionalities to the repo you set.
Create a label
You will need to pass a new label name, label color(hex code without #), and label description as parameters. Then create a new label on your repo.
Create labels
This function will create 29 labels which are set as constant here
If you change the constant, you can update labels easily.
Delete a label
This function will remove a tag from your repo. It requires a label name as a parameter. (In the future, this should get labels list and allow to select a label/labels by multi-select)
Delete all labels
This will delete all labels from your repo. First, get all labels' names from the repo and pass them as a parameter. The process is the same as “Delete a label”