diff --git a/.eslintignore b/.eslintignore index cfd713ada..83099250c 100644 --- a/.eslintignore +++ b/.eslintignore @@ -26,6 +26,7 @@ apps/vscode/extension/editor/index.js apps/vscode/extension/editor/tldraw-assets.json **/sentry.server.config.js **/scripts/upload-sourcemaps.js +**/scripts/lib/auto-plugin.js **/coverage/**/* apps/dotcom/public/sw.js diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 35e7f5b96..5d42e9798 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -2,24 +2,14 @@ Describe what your pull request does. If appropriate, add GIFs or images showing ### Change Type - - -- [ ] `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 -- [ ] `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 +- [ ] `improvement` — Product improvement +- [ ] `api` — API change +- [ ] `bugfix` — Bug fix +- [ ] `other` — Changes that don't affect SDK users, e.g. internal or .com changes ### Test Plan diff --git a/apps/huppy/src/flows/enforcePrLabels.tsx b/apps/huppy/src/flows/enforcePrLabels.tsx index c73092abc..8d85c96a1 100644 --- a/apps/huppy/src/flows/enforcePrLabels.tsx +++ b/apps/huppy/src/flows/enforcePrLabels.tsx @@ -56,6 +56,10 @@ export const enforcePrLabels: Flow = { return fail('Please add a label to the PR.') } + if (pull.body?.includes('Add a brief release note for your PR here.')) { + return fail('Add a release note to the PR body.') + } + // add any labels that are checked console.log('adding labels') if (selectedReleaseLabels.length > 0) { diff --git a/scripts/lib/auto-plugin.js b/scripts/lib/auto-plugin.js new file mode 100644 index 000000000..09e743479 --- /dev/null +++ b/scripts/lib/auto-plugin.js @@ -0,0 +1,35 @@ +module.exports = class AutoPlugin { + constructor() { + this.name = 'tldraw' + } + + apply(auto) { + // Exclude bots. + auto.hooks.onCreateLogParse.tap(this.name, (changelog) => + changelog.hooks.omitCommit.tap(this.name, (commit) => + commit.authors.some((author) => author.type === 'Bot') + ) + ) + + // Render the release note line, not the commit line. + auto.hooks.onCreateChangelog.tap(this.name, (changelog) => + changelog.hooks.renderChangelogLine.tap(this.name, async (line, commit) => { + const releaseNote = /### Release Notes\n\n-(.*)/g.exec( + commit.pullRequest.body.replaceAll('\r\n', '\n') + ) + return releaseNote + ? `- ${releaseNote[1].trim()} [#${commit.pullRequest.number}](https://github.com/tldraw/tldraw/pull/${commit.pullRequest.number})` + : line + }) + ) + + // Only write out changelog, not release notes (they're not very good). + auto.hooks.onCreateChangelog.tap(this.name, (changelog) => + changelog.hooks.omitReleaseNotes.tap(this.name, (commit) => true) + ) + } +} + +function uniq(value, index, array) { + return array.indexOf(value) === index +} diff --git a/scripts/lib/labels.ts b/scripts/lib/labels.ts index 1e259be2f..32e429f77 100644 --- a/scripts/lib/labels.ts +++ b/scripts/lib/labels.ts @@ -10,63 +10,32 @@ interface Label { 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: `feature`, + description: `New feature`, + changelogTitle: '🎉 New Features', + }, { name: `improvement`, - description: `Improving existing features`, - changelogTitle: '💄 Improvements', + description: `Product improvement`, + changelogTitle: '💄 Product Improvements', }, { - name: `chore`, - description: `Updating dependencies, other boring stuff`, - changelogTitle: '🧹 Chores', + name: `api`, + description: `API change`, + changelogTitle: '🛠️ API Changes', }, + { name: `bugfix`, description: `Bug fix`, changelogTitle: '🐛 Bug Fixes' }, { - name: `galaxy brain`, - description: `Architectural changes`, - changelogTitle: '🤯 Architectural changes', + name: `other`, + description: `Changes that don't affect SDK users, e.g. internal or .com changes`, + changelogTitle: '🤷 Other', }, - { 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) + return [...TYPE_LABELS].map((label) => label.name) } function formatTemplateOption(label: Label) { @@ -74,11 +43,7 @@ function formatTemplateOption(label: Label) { } export function formatLabelOptionsForPRTemplate() { - let result = `\n\n` - for (const label of SCOPE_LABELS) { - result += formatTemplateOption(label) + '\n' - } - result += `\n\n\n` + let result = `\n\n\n` for (const label of TYPE_LABELS) { result += formatTemplateOption(label) + '\n' } @@ -88,8 +53,8 @@ export function formatLabelOptionsForPRTemplate() { export async function generateAutoRcFile() { const autoRcPath = join(REPO_ROOT, '.autorc') await writeJsonFile(autoRcPath, { - plugins: ['npm'], - labels: [...SCOPE_LABELS, ...TYPE_LABELS].map(({ name, changelogTitle }) => ({ + plugins: ['npm', '../scripts/lib/auto-plugin.js'], + labels: [...TYPE_LABELS.filter((l) => l.name !== 'other')].map(({ name, changelogTitle }) => ({ name, changelogTitle, releaseType: 'none',