b9547c2e6b
This PR switches up how PR labels are validated to allow for more freeform label tweaking in the future. Basically **huppy will now only check that your PR is labelled, it doesn't care how it's labelled**. I also updated the PR template with a new labelling scheme that we can tweak over time. So before Huppy bot had to know about the specific set of allowed labels, and now as long as the label exists you're allowed to add it. So to add a new label to the PR template, just create the label and then add an option for it in the .md file. ### Change Type - [ ] `patch` — Bug fix - [ ] `minor` — New feature - [ ] `major` — Breaking change - [ ] `dependencies` — Changes to package dependencies[^1] - [ ] `documentation` — Changes to the documentation only[^2] - [ ] `tests` — Changes to any test code only[^2] - [x] `internal` — Any other changes that don't affect the published package[^2] - [ ] I don't know
98 lines
2.7 KiB
TypeScript
98 lines
2.7 KiB
TypeScript
import { join } from 'path'
|
|
import { REPO_ROOT, writeJsonFile } from './file'
|
|
|
|
type Label = {
|
|
// this is what the label is 'called' on github
|
|
name: string
|
|
// this is how we describe the label in our pull request template
|
|
description: string
|
|
// this is the section title for the label in our changelogs
|
|
changelogTitle: string
|
|
}
|
|
|
|
const SCOPE_LABELS = [
|
|
{
|
|
name: `sdk`,
|
|
description: `Changes the tldraw SDK`,
|
|
changelogTitle: '📚 SDK Changes',
|
|
},
|
|
{
|
|
name: `dotcom`,
|
|
description: `Changes the tldraw.com web app`,
|
|
changelogTitle: '🖥️ tldraw.com Changes',
|
|
},
|
|
{
|
|
name: `docs`,
|
|
description: `Changes to the documentation, examples, or templates.`,
|
|
changelogTitle: '📖 Documentation changes',
|
|
},
|
|
{
|
|
name: `vs code`,
|
|
description: `Changes to the vscode plugin`,
|
|
changelogTitle: '👩💻 VS Code Plugin Changes',
|
|
},
|
|
{
|
|
name: `internal`,
|
|
description: `Does not affect user-facing stuff`,
|
|
changelogTitle: '🕵️♀️ Internal Changes',
|
|
},
|
|
] as const satisfies Label[]
|
|
|
|
const TYPE_LABELS = [
|
|
{ name: `bugfix`, description: `Bug fix`, changelogTitle: '🐛 Bug Fixes' },
|
|
{ name: `feature`, description: `New feature`, changelogTitle: '🚀 Features' },
|
|
{
|
|
name: `improvement`,
|
|
description: `Improving existing features`,
|
|
changelogTitle: '💄 Improvements',
|
|
},
|
|
{
|
|
name: `chore`,
|
|
description: `Updating dependencies, other boring stuff`,
|
|
changelogTitle: '🧹 Chores',
|
|
},
|
|
{
|
|
name: `galaxy brain`,
|
|
description: `Architectural changes`,
|
|
changelogTitle: '🤯 Architectural changes',
|
|
},
|
|
{ name: `tests`, description: `Changes to any test code`, changelogTitle: '🧪 Tests' },
|
|
{
|
|
name: `tools`,
|
|
description: `Changes to infrastructure, CI, internal scripts, debugging tools, etc.`,
|
|
changelogTitle: '🛠️ Tools',
|
|
},
|
|
{ name: `dunno`, description: `I don't know`, changelogTitle: '🤷 Dunno' },
|
|
] as const satisfies Label[]
|
|
|
|
export function getLabelNames() {
|
|
return [...SCOPE_LABELS, ...TYPE_LABELS].map((label) => label.name)
|
|
}
|
|
|
|
function formatTemplateOption(label: Label) {
|
|
return `- [ ] \`${label.name}\` — ${label.description}`
|
|
}
|
|
|
|
export function formatLabelOptionsForPRTemplate() {
|
|
let result = `<!-- ❗ Please select a 'Scope' label ❗️ -->\n\n`
|
|
for (const label of SCOPE_LABELS) {
|
|
result += formatTemplateOption(label) + '\n'
|
|
}
|
|
result += `\n<!-- ❗ Please select a 'Type' label ❗️ -->\n\n`
|
|
for (const label of TYPE_LABELS) {
|
|
result += formatTemplateOption(label) + '\n'
|
|
}
|
|
return result
|
|
}
|
|
|
|
export async function generateAutoRcFile() {
|
|
const autoRcPath = join(REPO_ROOT, '.autorc')
|
|
await writeJsonFile(autoRcPath, {
|
|
plugins: ['npm'],
|
|
labels: [...SCOPE_LABELS, ...TYPE_LABELS].map(({ name, changelogTitle }) => ({
|
|
name,
|
|
changelogTitle,
|
|
releaseType: 'none',
|
|
})),
|
|
})
|
|
}
|