From f80f258eef2208b09bf35abd3491b7ce0d94ea6e Mon Sep 17 00:00:00 2001 From: Rhys Sullivan <39114868+RhysSullivan@users.noreply.github.com> Date: Mon, 4 May 2026 00:47:26 -0700 Subject: [PATCH] Add CHANGELOG.md stubs for vite-plugin + plugin-example, lint going forward MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit release.yml failed again on the latest main with the same ENOENT — this time on `packages/core/vite-plugin/CHANGELOG.md`. That package and `packages/plugins/example` were added in #476 (Spec-driven plugin loading) without stubs, after my restore PR (#496) only put back the files #491 had deleted. Drift was inevitable as soon as the next package landed. This PR: - Adds the two missing stubs. - Adds `scripts/check-changelog-stubs.ts` and wires it into `bun run lint`. Fails CI when any workspace package directory lacks a CHANGELOG.md, with a clear message explaining why the stubs exist (changesets/action@v1 reads them) and pointing at the `--fix` flag. - `--fix` mode auto-creates stubs with a templated body. So the next time someone adds a package, lint flags it in PR rather than release.yml crashing later. --- package.json | 3 +- packages/core/vite-plugin/CHANGELOG.md | 6 ++ packages/plugins/example/CHANGELOG.md | 6 ++ scripts/check-changelog-stubs.ts | 76 ++++++++++++++++++++++++++ 4 files changed, 90 insertions(+), 1 deletion(-) create mode 100644 packages/core/vite-plugin/CHANGELOG.md create mode 100644 packages/plugins/example/CHANGELOG.md create mode 100644 scripts/check-changelog-stubs.ts diff --git a/package.json b/package.json index 422c2c05..c2cb86cb 100644 --- a/package.json +++ b/package.json @@ -37,8 +37,9 @@ "typecheck": "turbo run typecheck", "typecheck:slow": "turbo run typecheck:slow", "ci": "bun run lint && bun run typecheck && bun run test", - "lint": "oxlint -c .oxlintrc.jsonc . --deny-warnings", + "lint": "oxlint -c .oxlintrc.jsonc . --deny-warnings && bun run lint:changelog-stubs", "lint:release-notes": "bun run scripts/check-release-notes.ts", + "lint:changelog-stubs": "bun run scripts/check-changelog-stubs.ts", "lint:fix": "oxlint -c .oxlintrc.jsonc --fix .", "format": "oxfmt .", "format:check": "oxfmt --check .", diff --git a/packages/core/vite-plugin/CHANGELOG.md b/packages/core/vite-plugin/CHANGELOG.md new file mode 100644 index 00000000..1d1c52b9 --- /dev/null +++ b/packages/core/vite-plugin/CHANGELOG.md @@ -0,0 +1,6 @@ +# @executor-js/vite-plugin changelog + +This file exists for `changesets/action@v1` compatibility (it reads every +workspace package's `CHANGELOG.md` to build the Version Packages PR). +Canonical user-facing release notes are at `apps/cli/release-notes/next.md` +and on the GitHub Releases page. diff --git a/packages/plugins/example/CHANGELOG.md b/packages/plugins/example/CHANGELOG.md new file mode 100644 index 00000000..99cf0faf --- /dev/null +++ b/packages/plugins/example/CHANGELOG.md @@ -0,0 +1,6 @@ +# @executor-js/plugin-example changelog + +This file exists for `changesets/action@v1` compatibility (it reads every +workspace package's `CHANGELOG.md` to build the Version Packages PR). +Canonical user-facing release notes are at `apps/cli/release-notes/next.md` +and on the GitHub Releases page. diff --git a/scripts/check-changelog-stubs.ts b/scripts/check-changelog-stubs.ts new file mode 100644 index 00000000..eb6d3a41 --- /dev/null +++ b/scripts/check-changelog-stubs.ts @@ -0,0 +1,76 @@ +#!/usr/bin/env bun +/** + * Verifies every workspace package directory has a `CHANGELOG.md` file. + * + * `changesets/action@v1` (the GitHub Action wrapping the Changesets CLI in + * `release.yml`) reads every workspace package's `CHANGELOG.md` to build + * the Version Packages PR description. If any is missing, the action + * crashes with `ENOENT` at release time and blocks the release. + * + * The CLI alone (with `changelog: false` in `.changeset/config.json`) + * doesn't need them — but we run via the Action, which does. + * + * The stubs themselves are not user-facing. Canonical release notes are + * at `apps/cli/release-notes/next.md` and on the GitHub Releases page. + * + * Usage: + * bun run scripts/check-changelog-stubs.ts # fail on missing + * bun run scripts/check-changelog-stubs.ts --fix # create missing stubs + */ +import { existsSync, readFileSync, writeFileSync } from "node:fs"; +import { dirname, relative, resolve } from "node:path"; + +const repoRoot = resolve(import.meta.dir, ".."); + +type Pkg = { name?: string; private?: boolean }; + +const findWorkspacePackages = (): string[] => { + const root = JSON.parse(readFileSync(resolve(repoRoot, "package.json"), "utf8")) as { + workspaces?: string[]; + }; + const patterns = root.workspaces ?? []; + const dirs = new Set(); + for (const pattern of patterns) { + // Bun.Glob — handles workspace patterns like "packages/*/*", "apps/*" + for (const match of new Bun.Glob(`${pattern}/package.json`).scanSync({ cwd: repoRoot })) { + dirs.add(dirname(resolve(repoRoot, match))); + } + } + return [...dirs].sort(); +}; + +const STUB_TEMPLATE = (name: string) => + `# ${name} changelog\n\n` + + "This file exists for `changesets/action@v1` compatibility (it reads every\n" + + "workspace package's `CHANGELOG.md` to build the Version Packages PR).\n" + + "Canonical user-facing release notes are at `apps/cli/release-notes/next.md`\n" + + "and on the GitHub Releases page.\n"; + +const fix = process.argv.includes("--fix"); +const missing: string[] = []; + +for (const pkgDir of findWorkspacePackages()) { + const changelogPath = resolve(pkgDir, "CHANGELOG.md"); + if (existsSync(changelogPath)) continue; + + const pkg = JSON.parse(readFileSync(resolve(pkgDir, "package.json"), "utf8")) as Pkg; + const name = pkg.name ?? relative(repoRoot, pkgDir); + + if (fix) { + writeFileSync(changelogPath, STUB_TEMPLATE(name)); + console.log(`Created stub: ${relative(repoRoot, changelogPath)}`); + } else { + missing.push(`${relative(repoRoot, pkgDir)} (${name})`); + } +} + +if (!fix && missing.length > 0) { + console.error( + `\nMissing CHANGELOG.md in ${missing.length} workspace package(s):\n - ${missing.join("\n - ")}\n\n` + + "These are required by `changesets/action@v1` (the GitHub Action wrapping\n" + + "Changesets in release.yml). Without them, release.yml crashes with ENOENT\n" + + "and the Version Packages PR can't open.\n\n" + + "Run `bun run scripts/check-changelog-stubs.ts --fix` to create stubs.\n", + ); + process.exit(1); +}