tldraw/scripts/lib/labels.ts
Steve Ruiz bc7f0c638e
Update pull_request_template.md (#4038)
This PR updates the PR template. Just simplifies stuff, fixes spacing
and casing.

### Change Type

- [ ] `feature` — New feature
- [ ] `improvement` — Product improvement
- [ ] `api` — API change
- [ ] `bugfix` — Bug fix
- [x] `other` — Changes that don't affect SDK users, e.g. internal or
.com changes
2024-06-28 15:57:38 +00:00

59 lines
1.5 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: `bugfix`, description: `Bug fix`, changelogTitle: '🐛 Bug Fixes' },
{
name: `improvement`,
description: `Product improvement`,
changelogTitle: '💄 Product Improvements',
},
{
name: `feature`,
description: `New feature`,
changelogTitle: '🎉 New Features',
},
{
name: `api`,
description: `API change`,
changelogTitle: '🛠️ API Changes',
},
{
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}\``
}
export function formatLabelOptionsForPRTemplate() {
return TYPE_LABELS.map(formatTemplateOption).join('\n')
}
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',
})),
})
}