tldraw/scripts/lib/labels.ts
Mime Čuvalo 65a6890584
dx: PR labels re-revamp (#4016)
This is a followup to https://github.com/tldraw/tldraw/pull/3112 after a
discussion with Alex about how our release notes writing is really
manual now.

This changes the labels to be a more limited set.

It also adds a plugin to help massage the release notes into what we
want it to be:
- ignores bot commits
- use the release notes, if found, not the commit msg
- skip writing the "release notes" in general, just create the changelog
which is what we want anyway.

### Change Type

<!--  Please select a 'Scope' label ️ -->

- [ ] `sdk` — Changes the tldraw SDK
- [ ] `dotcom` — Changes the tldraw.com web app
- [ ] `docs` — Changes to the documentation, examples, or templates.
- [ ] `vs code` — Changes to the vscode plugin
- [ ] `internal` — Does not affect user-facing stuff

<!--  Please select a 'Type' label ️ -->

- [ ] `bugfix` — Bug fix
- [ ] `feature` — New feature
- [ ] `improvement` — Improving existing features
- [ ] `chore` — Updating dependencies, other boring stuff
- [ ] `galaxy brain` — Architectural changes
- [ ] `tests` — Changes to any test code
- [ ] `tools` — Changes to infrastructure, CI, internal scripts,
debugging tools, etc.
- [ ] `dunno` — I don't know
2024-06-26 11:06:15 +00:00

63 lines
1.6 KiB
TypeScript

import { join } from 'path'
import { REPO_ROOT, writeJsonFile } from './file'
interface 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 TYPE_LABELS = [
{
name: `feature`,
description: `New feature`,
changelogTitle: '🎉 New Features',
},
{
name: `improvement`,
description: `Product improvement`,
changelogTitle: '💄 Product Improvements',
},
{
name: `api`,
description: `API change`,
changelogTitle: '🛠️ API Changes',
},
{ name: `bugfix`, description: `Bug fix`, changelogTitle: '🐛 Bug Fixes' },
{
name: `other`,
description: `Changes that don't affect SDK users, e.g. internal or .com changes`,
changelogTitle: '🤷 Other',
},
] as const satisfies Label[]
export function getLabelNames() {
return [...TYPE_LABELS].map((label) => label.name)
}
function formatTemplateOption(label: Label) {
return `- [ ] \`${label.name}\`${label.description}`
}
export function formatLabelOptionsForPRTemplate() {
let 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', '../scripts/lib/auto-plugin.js'],
labels: [...TYPE_LABELS.filter((l) => l.name !== 'other')].map(({ name, changelogTitle }) => ({
name,
changelogTitle,
releaseType: 'none',
})),
})
}