npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

labelify

v2.0.0

Published

Automate and simplify the creation of labels for your repository.

Downloads

6

Readme

labelify

NPM version Travis Build Status dependencies Status devDependencies Status

Automate and simplify the creation of labels for your GitHub/GitLab/Send_a_PR_For_You_Platform repository.

Highlights

  • Support configuration file.
  • Support GitHub/GitLab platforms (include self hosted solutions).
  • CLI.
  • Promise interface.
  • Simple usage.

Installation

npm i -D labelify

Getting Started

  1. 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 use labelify property in package.json.

    Example labelify.config.js file (basic github 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"
        }
      ]
    };
  2. Add labelify command in package.json.

    {
      "scripts": {
        "labelify": "labelify"
      }
    }
  3. Creating a personal access token for the command line

  4. Run npm script.

    NPM:

    TOKEN=YOUR_SECRET_TOKEN npm run labelify

    Yarn:

    TOKEN=YOUR_SECRET_TOKEN yarn labelify

Configuration file

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"
    }
  ]
};

labels

List of labels. label fields.

config

List of config options. list config options.

extends

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"
    }
  ]
};

API

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));

options.labels

Type: Array

Default: []

Array of labels.

List of label fields

name

Required

Type: String

Name of label.

color

Required

Type: String

Color of label. Support short (#fff) and long (#ffffff) hex notation.

description

Optional

Type: String

Description of label.

If you want remove priority for label use null value.

priority

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.


options.config

Type: Object

Default: {}

Notes:

  • labelify automatically resolve platform and endpoint options based on information in package.json.
  • Use platform option only when you have self hosted solution.
  • Use endpoint option only when you have nonstandard API URL fro your platform.

overlap

Type: Boolean

Default: false

Removes all labels which are not in options/configuration from the repository.

platform

Type: string

Type of platform where your store repository.

Available configuration:

  • github
  • gitlab

endpoint

Type: string

Endpoint for your API. Example for github it is https://api.github.com/repos/itgalaxy/labelify/labels.

api

Allow to pass own API. Should contain 4 method. You can look on example API here.

token

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:

CLI

  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

Todo

PR welcome

  • medium More tests.
  • low Respect x-ratelimit-remaining and x-ratelimit-reset from github.
  • low Support bitbucket.
  • low Basic presets.
  • low Integrate ora for better logging.

Thanks

  • git-label - inspiration and ideas.
  • got - for great library without several megabytes.
  • the logo designed by @reallinfo

Contribution

Feel free to push your code if you agree with publishing under the MIT license.

Changelog

License