Coder Social home page Coder Social logo

gitlab-standard-labels's Introduction

gitlab-standard-labels stability

Create a standard set of issue labels and board lists for a GitLab CE project via API.

Installation

Install the package globally:

npm install -g gitlab-standard-labels

Optionally set the private token:

npm config set gitlab-standard-labels.token your-private-token

Note: you can get the private token from your account settings. The token can also be set as a command argument.

Usage

  Usage:
    $ gitlab-standard-labels <repository-url>

  Commands:
    <default>   Create a set of labels for a project

  Arguments:
    <repository-url>   The complete URL to the repository (eg. https://gitlab.example.com/group/name)

  Options:
    -t, --token=    The authentication token, overwrites the token in the npm config, if defined
    -c, --config=   The path to a custom labels configuration file
    -d, --delete    Delete previous existing labels and board lists before the creation
    -b, --board     Create default board lists
    -h, --help      Print usage
    -v, --version   Print current version

Examples

Create the default labels:

gitlab-standard-labels https://gitlab.example.com/group/name

Create the default labels, delete any existing label:

gitlab-standard-labels -d https://gitlab.example.com/group/name

Create the default labels and board lists, delete any existing label or list:

gitlab-standard-labels -bd https://gitlab.example.com/group/name

Create the default labels using a custom token:

gitlab-standard-labels -b --token=some-other-token https://gitlab.example.com/group/name

Create the labels using a custom configuration file:

gitlab-standard-labels --config="/path/to/my/config.json" https://gitlab.example.com/group/name

License

MIT

gitlab-standard-labels's People

Contributors

fsavina avatar scaccogatto avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

gitlab-standard-labels's Issues

Seems to be broken with GitLab 12.10

Generated a few labels, but then errored with the following:

No default board found. Please visit the board page in order to trigger the default GitLab board creation. Hopefully one day this is gonna be fixed by the GitLab team...
Creating all labels in repository weblinx/vernon-hills-park-district
Error: Request failed with status code 409
    at setStandardLabels (/home/jacob/.nvm/versions/node/v12.16.3/lib/node_modules/gitlab-standard-labels/labels/index.js:66:11)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)

Could be because I already had a couple of labels set up manually, but in the past this has always worked fine (it would error, but still make the rest of the labels).

Add support for remapping existing labels to new ones

This may be too complicated for this script, but I'd love the ability to "translate" my existing labels in to this "sane" format. I only recently started trying to use labels to their fullest extent, so I have 200+ projects in my GitLab instance that have an older format.

Being able to set something in the config file like:

{
    ...,
    "translations": {
        "enhancement": "Type: Enhancement",
        "broken": "Type: Bug",
        "done" : "Status: Completed"
    }
}

I have two thoughts on how this could be achieved:

  1. After inserting labels for a project, index all issues. Delete existing labels, and assign translated labels
  2. Before inserting labels for a project, index existing labels, and adjust their settings to match the translated value. (i.e. update broken/#FF0000 to Type: Bug/EE0701).

Any thoughts on this? It'd be a great help in getting all my projects reconfigured.

Thank you and a config for Sane Labels

First of all, thank you very much for this. I was just about to write such tool myself, but luckily I gave a npm search beforehand and found yours. This is an excellent tool and again thank you very much from a fellow developer and gitlab user 💥.

I may send you a PR to create labels for groups instead of just project in future. Could be handy too.

Also here's a config I made to create sane labels, based on this.

[
  {
    "name": "Priority: Critical",
    "color": "#e11d21",
    "board": false,
    "priority": 10
  },
  {
    "name": "Priority: High",
    "color": "#eb6420",
    "board": false,
    "priority": 9
  },
  {
    "name": "Priority: Medium",
    "color": "#fbca04",
    "board": false,
    "priority": 8
  },
  {
    "name": "Priority: Low",
    "color": "#009800",
    "board": false,
    "priority": 7
  },
  {
    "name": "Status: Abandoned",
    "color": "#000000",
    "board": false,
    "priority": 1
  },
  {
    "name": "Status: Accepted",
    "color": "#009800",
    "board": true,
    "priority": 1
  },
  {
    "name": "Status: Proposal",
    "color": "#e11d21",
    "board": true,
    "priority": 1
  },
  {
    "name": "Status: In Progress",
    "color": "#cccccc",
    "board": true,
    "priority": 1
  },
  {
    "name": "Status: TBD",
    "color": "#e11d21",
    "board": false,
    "priority": 1
  },
  {
    "name": "Status: Review Needed",
    "color": "#fbca04",
    "board": true,
    "priority": 1,
    "description": "Needs review from a maintainer"
  },
  {
    "name": "Status: Revision Needed",
    "color": "#e11d21",
    "board": false,
    "priority": 1,
    "description": "Needs code input from a maintainer"
  },
  {
    "name": "Status: Doc Needed",
    "color": "#006b75",
    "board": true,
    "priority": 1
  },
  {
    "name": "Status: Available",
    "color": "#bfe5bf",
    "board": true,
    "priority": 1
  },
  {
    "name": "Status: Blocked",
    "color": "#e11d21",
    "board": false,
    "priority": 1,
    "description": "Blocked because of upstream dependencies"
  },
  {
    "name": "Status: Wontfix",
    "color": "#D2DAE1",
    "board": false,
    "priority": 1
  },

  { "name": "Type: Bug", "color": "#e11d21", "board": false, "priority": 11 },
  {
    "name": "Type: Maintenance",
    "color": "#fbca04",
    "board": false,
    "priority": 1
  },
  {
    "name": "Type: Enhancement",
    "color": "#84b6eb",
    "board": false,
    "priority": 1
  },
  {
    "name": "Type: Discussion",
    "color": "#cc317c",
    "board": false,
    "priority": 1
  },
  { "name": "¯\\_[ツ]_/¯", "color": "#FFC107", "board": false, "priority": 1 },
  {
    "name": "[ノಠ益ಠ]ノ彡┻━┻",
    "color": "#333333",
    "board": false,
    "priority": 1
  },
  {
    "name": "Type: Security",
    "color": "#EE3F46",
    "board": false,
    "priority": 11
  },

  {
    "name": "Type: Feature",
    "color": "#91ca55",
    "board": false,
    "priority": 1
  },
  {
    "name": "Type: Optimization",
    "color": "#5EBEFF",
    "board": false,
    "priority": 1
  },
  {
    "name": "Type: UI/UX",
    "color": "#FFC274",
    "board": false,
    "priority": 1
  },
  {
    "name": "Type: Compatibility",
    "color": "#000000",
    "board": false,
    "priority": 1
  }
]

Maybe someone will find it useful.

Once again thank you very much.

Add support for custom config file

The list is pretty standard, but not all labels are suitable for all users. Which is why I propse an option to pick a custom config file.

Maybe a --config= or -c option to point to a custom JSON file, that you validate using a JSON schema.

Based on the current labels/config.json, I made the following schema:

{
    "$schema": "http://json-schema.org/draft-04/schema#",
    "$id": "https://github.com/hcesrl/gitlab-standard-labels/schema/labels.json#",
    "$comment": "Defines a list of labels to use",
    "title": "Label definition file",
    "description": "Contains a list of an unrestricted number of labels",
    "type": "array",
    "minItems": 1,
    "items": {
        "type": "object",
        "additionalProperties": false,
        "required": [
            "name",
            "color"
        ],
        "properties": {
            "name": {
                "type": "string",
                "minLength": 1,
                "maxLength": 64
            },
            "color": {
                "type": "string",
                "regex": "^#[0-9a-f]{6}$"
            },
            "priority": {
                "type": "number",
                "enum": [
                    1
                ]
            },
            "board": {
                "type": "boolean",
                "enum": [
                    true
                ]
            }
        }
    }
}

The schema also points out some irregularities, such as the use of priority but only using a value of 1 and the board flag only allowing true, which seems like it should be either true or false.

Let me know what you think 😉

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.