Last active
April 11, 2019 21:45
-
-
Save vict0rsch/188a60f1e87a68844e41082583df64c4 to your computer and use it in GitHub Desktop.
Get all labels + colors + description on your repository's `labels` section into a Project-Bot compatible settings.yml file
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Just run this whole script in your browser's console on the appropriate webpage | |
// For instance on https://github.com/facebook/create-react-app/labels | |
// 1 | |
var labels = []; | |
[].slice.call(document.querySelectorAll(".label-link")) | |
.forEach(function (element) { | |
labels.push({ | |
name: `"${element.textContent.trim()}"`, | |
// using style.backgroundColor might returns "rgb(...)" | |
color: element.getAttribute("style") | |
.replace("background-color:", "") | |
.replace(/color:.*/, "") | |
.trim() | |
// github wants hex code only without # or ; | |
.replace(/^#/, "") | |
.replace(/;$/, "") | |
.trim(), | |
description: `"${element.parentElement.nextElementSibling.textContent.trim()}"` | |
}) | |
}) | |
// 2 | |
const out = "labels:\n" + labels.map( | |
(l, i) => ` - name: ${l.name}\n color: ${l.color}\n description: ${l.description || '""'}\n` | |
).join("\n") | |
// 3 | |
function saveYML(text, filename) { | |
const blob = new Blob([text], { type: 'text/plain' }); | |
const e = document.createEvent('MouseEvents'); | |
const a = document.createElement('a'); | |
a.download = filename; | |
a.href = window.URL.createObjectURL(blob); | |
a.dataset.downloadurl = ['text/json', a.download, a.href].join(':'); | |
e.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null); | |
a.dispatchEvent(e); | |
} | |
saveYML(out, "settings.yml") |
Output from https://github.com/facebook/create-react-app/labels
labels:
- name: "CLA Signed"
color: 009900
description: ""
- name: "contributions: claimed"
color: d93f0b
description: ""
- name: "contributions: up for grabs!"
color: 128A0C
description: ""
- name: "difficulty: complex"
color: f9d0c4
description: ""
- name: "difficulty: impossible"
color: e99695
description: ""
- name: "difficulty: medium"
color: fef2c0
description: ""
- name: "difficulty: starter"
color: c5def5
description: ""
- name: "good first issue"
color: 128A0C
description: ""
- name: "hacktoberfest"
color: ff625f
description: ""
- name: "issue: announcement"
color: 5319e7
description: ""
- name: "issue: bug"
color: ee0701
description: ""
- name: "issue: install problem"
color: e5aa4b
description: ""
- name: "issue: needs investigation"
color: d106e8
description: ""
- name: "issue: proposal"
color: fbca04
description: ""
- name: "issue: question > PWA"
color: c5def5
description: ""
- name: "issue: question"
color: 006b75
description: ""
- name: "issue: typescript"
color: 007acc
description: ""
- name: "priority: low (ignored issue template)"
color: d4c5f9
description: ""
- name: "priority: low (needs more information)"
color: d4c5f9
description: ""
- name: "stale"
color: f4d37f
description: ""
- name: "tag: breaking change"
color: e11d21
description: ""
- name: "tag: bug fix"
color: fbca04
description: ""
- name: "tag: documentation"
color: 006b75
description: ""
- name: "tag: enhancement"
color: 1d76db
description: ""
- name: "tag: internal"
color: bfdadc
description: ""
- name: "tag: new feature"
color: 0e8a16
description: ""
- name: "tag: underlying tools"
color: d93f0b
description: ""
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
labels
as a list of objects with fieldsname
color
anddescription
yml
-compatible stringout
out
as asettings.yml
fileMost work from https://gist.github.com/MoOx/93c2853fee760f42d97f