Created
February 23, 2021 18:18
-
-
Save reymon359/a2860531f29772e2296f26ae3f9e45d9 to your computer and use it in GitHub Desktop.
Export import GitHub labels. Custom ones as default.
This file contains 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
/** | |
* EXPORT LABELS | |
* 1. Copy and paste the following code into the repository browser console that you want to get the labels | |
* 2. Copy the result | |
*/ | |
const labels = []; | |
[].slice.call(document.querySelectorAll('.js-label-link')) | |
.forEach(function (element) { | |
labels.push({ | |
name: element.textContent.trim(), | |
description: element.getAttribute('title'), | |
color: element.getAttribute('style') | |
.replace('background-color:', '') | |
.replace(/color:.*/, '') | |
.trim() | |
.replace(/^#/, '') | |
.replace(/;$/, '') | |
.trim() | |
}) | |
}) | |
console.log(JSON.stringify(labels, null, 2)) | |
/** | |
* IMPORT LABELS | |
* 1. Change the JSON result to the one returned in the previous function | |
* 2. Copy and paste the following code into the repository console that you want to save the labels | |
*/ | |
[{ | |
name: 'Type Research 🔎', | |
description: 'The issue is related to researching information', | |
color: '1d44b0' | |
}, | |
{ | |
name: 'Type Style 🎨', | |
description: 'The issue is related to styling', | |
color: '1d44b0' | |
}, | |
{ | |
name: 'Type Test ✅', | |
description: 'The issue is related to tests', | |
color: '1d44b0' | |
}, | |
{ | |
name: 'Type Chore 🧬', | |
description: 'The issue is related to the chore of the project', | |
color: '1d44b0' | |
}, | |
{ | |
name: 'Estimation ? ♾', | |
description: 'Estimation Points: ? (? no idea)', | |
color: '155a48' | |
}, | |
{ | |
name: 'Estimation 1 ☕', | |
description: 'Estimation Points: 1 (15 min. aprox.)', | |
color: '155a48' | |
}, | |
{ | |
name: 'Estimation 2 ☕☕', | |
description: 'Estimation Points: 2 (30 min. aprox.)', | |
color: '155a48' | |
}, | |
{ | |
name: 'Estimation 3 ⏳', | |
description: 'Estimation Points: 3 (1 hour aprox.)', | |
color: '155a48' | |
}, | |
{ | |
name: 'Estimation 5 ⏳⏳', | |
description: 'Estimation points: 5 (3 hours aprox.)', | |
color: '155a48' | |
}, | |
{ | |
name: 'Estimation 8 ☀', | |
description: 'Estimation Points: 8 (1 day aprox.)', | |
color: '155a48' | |
}, | |
{ | |
name: 'Estimation 13 ☀☀', | |
description: 'Estimation Points: 13 (2 days aprox.)', | |
color: '155a48' | |
}, | |
{ | |
name: 'Estimation 20 📅', | |
description: 'Estimation Points: 20 (4 days aprox.)', | |
color: '155a48' | |
}, | |
{ | |
name: 'Estimation 40 📅📅', | |
description: 'Estimation Points: 40 (1 week aprox.)', | |
color: '155a48' | |
}, | |
{ | |
name: 'Priority High ☄☄☄', | |
description: 'The issue has a high priority', | |
color: '8338ec' | |
}, | |
{ | |
name: 'Priority Low ☄', | |
description: 'The issue has a low priority', | |
color: '8338ec' | |
}, | |
{ | |
name: 'Priority Medium ☄☄', | |
description: 'The issue has a medium priority', | |
color: '8338ec' | |
}, | |
{ | |
name: 'Time 1 ☕', | |
description: 'Spent 15 min. aprox. on the issue', | |
color: '132735' | |
}, | |
{ | |
name: 'Time 2 ☕☕', | |
description: 'Spent 30 min. aprox. on the issue', | |
color: '132735' | |
}, | |
{ | |
name: 'Time 3 ⏳', | |
description: 'Spent 1 hour aprox. on the issue', | |
color: '132735' | |
}, | |
{ | |
name: 'Time 4 ⏳⏳', | |
description: 'Spent 3 hours aprox. on the issue', | |
color: '132735' | |
}, | |
{ | |
name: 'Time 5 ☀', | |
description: 'Spent 1 day aprox. on the issue', | |
color: '132735' | |
}, | |
{ | |
name: 'Time 6 ☀☀', | |
description: 'Spent 2 days aprox. on the issue', | |
color: '132735' | |
}, | |
{ | |
name: 'Time 7 📅', | |
description: 'Spent 4 days aprox. on the issue', | |
color: '132735' | |
}, | |
{ | |
name: 'Time 8 📅📅', | |
description: 'Spent 1 week aprox. on the issue', | |
color: '132735' | |
}, | |
{ | |
name: 'Type Bug 🐛', | |
description: 'The issue is a bug', | |
color: '1d44b0' | |
}, | |
{ | |
name: 'Type Docs 📚', | |
description: 'The issue is related to documentation', | |
color: '1d44b0' | |
}, | |
{ | |
name: 'Type Feature ✨', | |
description: 'The issue is a new feature or enhancement', | |
color: '1d44b0' | |
}, | |
{ | |
name: 'Type Fix ✏', | |
description: 'The issue is a fix for something that is wrong', | |
color: '1d44b0' | |
}, | |
{ | |
name: 'Type Performance ⚡', | |
description: 'The issue is related to improving performance', | |
color: '1d44b0' | |
}, | |
{ | |
name: 'Type Planning 📐', | |
description: 'The issue is related to planning', | |
color: '1d44b0' | |
}, | |
{ | |
name: 'Type Refactor ♻', | |
description: 'The issue is related to refactoring the code', | |
color: '1d44b0' | |
} | |
].forEach(function (label) { | |
addLabel(label) | |
}) | |
function updateLabel (label) { | |
let flag = false; | |
[].slice.call(document.querySelectorAll('.js-labels-list-item')) | |
.forEach(function (element) { | |
if (element.querySelector('.js-label-link').textContent.trim() === label.name) { | |
flag = true | |
element.querySelector('.js-edit-label').click() | |
element.querySelector('.js-new-label-name-input').value = label.name | |
element.querySelector('.js-new-label-color-input').value = '#' + label.color | |
element.querySelector('.js-update-label .btn-primary').click() | |
} | |
}) | |
return flag | |
} | |
function addNewLabel (label) { | |
document.querySelector('.js-details-target-new-label').click() | |
document.querySelector('#new_label input#label-name-').value = label.name | |
document.querySelector('#new_label input#label-description-').value = label.description | |
document.querySelector('#new_label input#label-color-').value = '#' + label.color | |
document.querySelector('#new_label .btn-primary').disabled = false | |
document.querySelector('#new_label .btn-primary').click() | |
} | |
function addLabel (label) { | |
if (!updateLabel(label)) addNewLabel(label) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment