Automate and simplify the creation of labels for your GitHub/GitLab/Send_a_PR_For_You_Platform repository.
- Support configuration file.
- Support GitHub/GitLab platforms (include self hosted solutions).
- CLI.
- Promise interface.
- Simple usage.
npm i -D labelify
-
Create configuration file with your labels (add options if you need them) in root of your project. Recommended to create
labelify.config.js
file in root project directory or uselabelify
property inpackage.json
.Example
labelify.config.js
file (basicgithub
labels):module.exports = { // You can use any config options here. // config: { overlap: true }, labels: [ { color: "#ee0701", name: "bug" }, { color: "#cccccc", name: "duplicate" }, { color: "#84b6eb", name: "enhancement" }, { color: "#128A0C", name: "help wanted" }, { color: "#e6e6e6", name: "invalid" }, { color: "#cc317c", name: "question" }, { color: "#ffffff", name: "wontfix" } ] };
-
Add
labelify
command inpackage.json
.{ "scripts": { "labelify": "labelify" } }
-
Creating a personal access token for the command line
-
Run npm script.
NPM:
TOKEN=YOUR_SECRET_TOKEN npm run labelify
Yarn:
TOKEN=YOUR_SECRET_TOKEN yarn labelify
Configuration file contains:
- List of labels (Required).
- Config (Optional)
Find and load a configuration object algorithm.
Example configuration file:
labelify.config.js
module.exports = {
// You can use any config options here.
config: {
// overlap: true,
},
labels: [
{
color: "#111111",
name: "1"
},
{
color: "#222222",
name: "2"
},
{
color: "#333333",
name: "3"
}
]
};
List of labels. label fields.
List of config options. list config options.
Your configuration can extend an existing configuration (whether your own or a third-party config). When one configuration extends another, it starts with the other's properties then adds to and overrides what's there.
Example:
module.exports = {
extends: "labelify-config-standard",
labels: [
{
color: "#ffffff",
name: "extended-label"
}
]
};
const labelify = require("labelify");
const options = {
// Looks on config options below
config: {},
// Looks on label fields below
labels: [
{ color: "#aaa", name: "a" },
{ color: "#bbb", name: "b" },
{ color: "#ccc", name: "c" }
]
};
labelify(options)
.then(result => console.log(result))
.catch(error => console.log(error.stack));
Type: Array
Default: []
Array of labels.
Required
Type: String
Name of label.
Required
Type: String
Color of label. Support short (#fff
) and long (#ffffff
) hex notation.
Optional
Type: String
Description of label.
If you want remove priority for label use null
value.
Optional
Type: Number
Priority of label. Must be equal 0 or greater.
If you want remove priority for label use null
value.
Note: works only for Gitlab platform.
Type: Object
Default: {}
Notes:
labelify
automatically resolveplatform
andendpoint
options based on information inpackage.json
.- Use
platform
option only when you have self hosted solution. - Use
endpoint
option only when you have nonstandard API URL fro your platform.
Type: Boolean
Default: false
Removes all labels which are not in options/configuration from the repository.
Type: string
Type of platform where your store repository.
Available configuration:
- github
- gitlab
Type: string
Endpoint for your API.
Example for github it is https://api.github.com/repos/itgalaxy/labelify/labels
.
Allow to pass own API. Should contain 4 method. You can look on example API here.
Type: string
Default: process.env.TOKEN || process.env.GITHUB_TOKEN || process.env.GITLAB_TOKEN
Access token for your repository.
Note: store token
in code or configuration file is insecurity.
How to create token:
Automate and simplify the creation of labels for your repository.
Usage: labelify [options]
Options:
--config
Path to a specific configuration file (JSON, YAML, or CommonJS), or the
name of a module in node_modules that points to one. If no --config
argument is provided, "labelify" will search for configuration files in
the following places, in this order:
- a labelify property in package.json
- a .labelify file (with or without filename extension:
.json, .yaml, .yml, and .js are available)
- a labelify.config.js file exporting a JS object
The search will begin in the working directory and move up the directory
tree until a configuration file is found.
--config-basedir
An absolute path to the directory that relative paths defining "extends"
are *relative to*. Only necessary if these values are relative paths.
--overlap, -o
Removes all labels which are not in configuration from the repository.
--platform, -p
Type of platform where your store repository.
Use platform option only when you have self hosted solution.
--endpoint, -e
Endpoint for your API.
Use endpoint option only when you have nonstandard API URL fro your platform.
--version, -v
Show the currently installed version of labelify.
Example usage:
TOKEN=YOUR_SECRET_TOKEN labelify
PR welcome
- medium More tests.
- low Respect
x-ratelimit-remaining
andx-ratelimit-reset
fromgithub
. - low Support
bitbucket
. - low Basic presets.
- low Integrate
ora
for better logging.
- git-label - inspiration and ideas.
- got - for great library without
several megabytes
. - the logo designed by @reallinfo
Feel free to push your code if you agree with publishing under the MIT license.