CLI Tool
Recently I read articles about GitHub labels for issues. I recommend you to check them out. (Sorry one of them is Japanese only)
How we organize GitHub issues: A simple styleguide for tagging
https://robinpowered.com/blog/best-practice-system-for-organizing-and-tagging-github-issues
Sane GitHub Labels
https://medium.com/@dave_lunny/sane-github-labels-c5d2e6004b63
GitHub Labels that are logical, colorful and sensible
https://seantrane.com/posts/logical-colorful-github-labels-18230/
GitHub Issuesのラベルを作り直す+Projectのかんばんを自動化
https://qiita.com/willow-micro/items/51eeb3efe5b4192a4abd
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 ↓
I checked GitHub API to create labels. Fortunately, there is a Labels API.
https://docs.github.com/en/rest/reference/issues#labels
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.
core.js
Extendable client for GitHub's REST & GraphQL APIs
- Usage
- Options
- Defaults
- Authentication
- Logging
- Hooks
- Plugins
- Build your own Octokit with Plugins and Defaults
- LICENSE
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.
If you don't need the Plugin API then using @octokit/request
or @octokit/graphql
directly is a good alternative.
Usage
Browsers |
Load @octokit/core directly from cdn.skypack.dev
<script type="module">
import { Octokit } from "https://cdn.skypack.dev/@octokit/core";
</script>
|
---|---|
Node |
Install with const { Octokit } = require("@octokit/core");
// or: import { Octokit } from "@octokit/core";
|
REST API example
// Create a personal access token at https://github.com/settings/tokens/new?scopes=repo
const octokit = new Octokit({ auth: `personal-access-token123` });
const response
…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.
bitjson
/
typescript-starter
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 Node v10
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)
- Optionally use typescript to improve tooling, linting, and documentation generation
- Export as a javascript module, making your work fully tree-shakable for consumers capable of using es6 imports (like Rollup, Webpack, or Parcel)
- Export type declarations to improve your downstream development experience
- Backwards compatibility for Node.js-style (CommonJS) imports
- Both strict and flexible typescript configurations…
The script’s repo is here.
koji
/
github-label-manager
Simple CLI tool to create/delete labels with GitHub Labels API
github label manager
Simple CLI tool to create/delete labels with GitHub Labels API.
label-manager.mov
Labels API
https://docs.github.com/en/rest/reference/issues#labels
label data format
// 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"
}
What this script can do is the below.
- Create a single label on a specific repo
- Create multiple labels on a specific repo
- Delete a single label from a specific repo
- Delete all labels from a specific repo
Requirement: Personal Token about repo
You can generate a token here.
What you will need to input
- Operation 0: Cancel (terminate the process) 1: Create a single label on a specific repo 2: Create multiple labels on a specific repo 3: Delete a single…
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”
Top comments (0)