https://levelup.gitconnected.com/create-github-labels-from-terminal-158d4868fab
https://github.com/koji/Hyouji/blob/main/blog/article.md
A simple CLI tool to create/delete labels with GitHub Labels API. Now available as a global npm package with persistent configuration storage.
https://levelup.gitconnected.com/create-github-labels-from-terminal-158d4868fab
hyouji.mov
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"
}
Install globally via npm:
npm install -g hyouji
Or use with npx (no installation required):
npx hyouji
This tool provides the following functionality:
- 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
- Import labels from JSON or YAML file
- Display your saved settings - View your stored GitHub configuration
- Persistent configuration - Save your GitHub token and username for future use
After installation, run the tool from anywhere:
hyouji
On your first run, you'll be prompted to enter:
- GitHub Personal Token - Generate one here with
repo
scope - GitHub Username - Your GitHub account name
These credentials will be securely saved and reused for future sessions.
- 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
- Import labels from JSON or YAML file
- Generate sample JSON - Create a sample JSON file with predefined labels
- Generate sample YAML - Create a sample YAML file with predefined labels
- Display your settings - View your saved configuration
- Exit
The tool now includes persistent configuration storage with enhanced security:
- Automatic saving: Your GitHub token and username are saved after first use
- Settings display: Use option 6 to view your current configuration
- Secure storage: Configuration is stored in
~/.config/github-label-manager/config.json
- Token encryption: Your personal token is automatically encrypted using machine-specific keys
- Automatic migration: Existing plain text configurations are automatically upgraded to encrypted format
- Token security: Your personal token is never displayed in plain text, only an obfuscated preview is shown
Token Encryption:
- All GitHub personal tokens are automatically encrypted before being saved to disk
- Encryption uses machine-specific keys derived from your system information
- Existing plain text configurations are automatically migrated to encrypted format on first run
- Even if someone gains access to your configuration file, the token remains protected
Privacy Protection:
- Tokens are never displayed in plain text in the interface
- Only an obfuscated preview (e.g.,
ghp_****...****3456
) is shown in settings - The settings display shows whether your token is encrypted or in plain text format
If you want to create/delete a single label, you need to type the followings.
- label name
- label color (technically optional)
- label description (technically optional)
- label name
In terms of multiple labels, this script is using label.js
to define name, color and description. The format is very simple.
If you want to put your own labels, you will need to modify label.js
file.
module.exports = Object.freeze([
{
name: "Type: Bug Fix",
color: "FF8A65",
description: "Fix features that are not working",
},
{
name: "Type: Enhancement",
color: "64B5F7",
description: "Add new features",
},
-
Install the package globally:
# npm npm install -g hyouji # pnpm pnpm install -g hyouji # yarn yarn global add hyouji # bun bun install -g hyouji
-
Run the tool:
hyouji
-
On first run, enter your GitHub credentials when prompted
-
Select your desired operation from the menu
-
Follow the prompts to manage your repository labels
# Run the tool
hyouji
# Or run without installing
npx hyouji
If you want to contribute or run from source:
git clone https://github.com/koji/hyouji.git
cd hyouji
npm install
npm run build
npm start
You can use pnpm
, yarn
or bun
.
The "Import labels from JSON or YAML file" option allows you to import multiple labels from external files. Both JSON and YAML formats are supported.
- JSON files (
.json
extension) - YAML files (
.yaml
or.yml
extension)
Both formats support the same label structure:
name
(required): The label namecolor
(optional): Hex color code without the#
symboldescription
(optional): Label description
[
{
"name": "bug",
"color": "d73a4a",
"description": "Something isn't working"
},
{
"name": "enhancement",
"color": "a2eeef",
"description": "New feature or request"
},
{
"name": "documentation",
"color": "0075ca",
"description": "Improvements or additions to documentation"
}
]
# Sample YAML file for importing GitHub labels
- name: 'bug'
color: 'd73a4a'
description: "Something isn't working"
- name: 'enhancement'
color: 'a2eeef'
description: 'New feature or request'
- name: 'documentation'
color: '0075ca'
description: 'Improvements or additions to documentation'
# Labels with minimal configuration (name only)
- name: 'good first issue'
color: '7057ff'
description: 'Good for newcomers'
# Labels without description (optional field)
- name: 'wontfix'
color: 'ffffff'
# Labels without color (will use GitHub default)
- name: 'question'
description: 'Further information is requested'
You can find complete example files in the examples/
directory:
examples/labels.json
- Basic label examples in JSON formatexamples/labels.yaml
- Basic label examples in YAML formatexamples/project-labels.json
- Project management labels in JSON formatexamples/project-labels.yaml
- Project management labels in YAML format
The tool can generate sample files for you:
- Generate sample JSON - Creates
hyouji.json
with predefined labels - Generate sample YAML - Creates
hyouji.yaml
with predefined labels
Both generated files contain the same predefined labels and can be used as starting points for your own label configurations.
The "Create multiple labels" option uses predefined labels from src/constant.ts
. These include common labels for project management:
{
name: 'Type: Bug Fix',
color: 'FF8A65',
description: 'Fix features that are not working',
},
{
name: 'Type: Enhancement',
color: '64B5F7',
description: 'Add new features',
},
// ... and many more
Your settings are stored in:
- Primary:
~/.config/github-label-manager/config.json
- Fallback:
~/.github-label-manager-config.json
Use the "Display your settings" menu option to:
- See your configuration file path
- View your stored GitHub username
- Check if a token is saved (without revealing the actual token)
- See when your configuration was last updated
If you need to reset your configuration, you can:
- Delete the configuration file manually
- The tool will prompt for new credentials on the next run
If you see authentication errors:
- Check that your token has the correct
repo
scope - Verify the token hasn't expired
- The tool will automatically prompt for a new token if validation fails
If you encounter file permission errors:
- Ensure you have write access to your home directory
- The tool will attempt to use fallback locations if needed
- Node.js 20 or higher
- GitHub Personal Access Token with
repo
scope