A version is packed once (dist keeps its first tarball, npm won't take it twice, and magpie updates by version), so a change shipped without a bump reaches no one. #1095 did that to astudio 0.2.2. scripts/bumped.mjs <base> diffs packages/ against base and names each package whose packed files (npm pack --dry-run) changed with its version the same. README.md is left out: magpie reads it from dist's index.json, rewritten every run. bumped.yml runs it on each pull request (base sha) and each push to main (event.before). Run: bun test scripts/bumped.test.mjs, 3 pass (mica). Broken by hand: with astudio set back to 0.2.2, `bun scripts/bumped.mjs a2af9d2d~1` fails naming packages/astudio@0.2.2: index.mjs; at 0.2.3 it passes. Not tried: the workflow itself, until this push runs it.
19 lines
1.0 KiB
JavaScript
19 lines
1.0 KiB
JavaScript
import { expect, test } from "bun:test"
|
|
import { unbumped } from "./bumped.mjs"
|
|
|
|
const versions = { "packages/a": ["0.1.0", "0.1.0"], "packages/b": ["0.1.0", "0.1.1"], "packages/new": [null, "0.1.0"], "packages/gone": ["0.1.0", null] }
|
|
const versionAt = (dir, at) => (versions[dir] ?? [null, null])[at === "base" ? 0 : 1]
|
|
const packed = () => ["index.mjs", "opencode2.mjs", "package.json", "README.md"]
|
|
|
|
test("a shipped file changed under the same version is named (plugins#1131)", () => {
|
|
expect(unbumped(["packages/a/index.mjs", "packages/a/opencode2.mjs"], versionAt, packed)).toEqual(["packages/a@0.1.0: index.mjs, opencode2.mjs"])
|
|
})
|
|
|
|
test("a bumped, new or removed package passes", () => {
|
|
expect(unbumped(["packages/b/index.mjs", "packages/new/index.mjs", "packages/gone/index.mjs"], versionAt, packed)).toEqual([])
|
|
})
|
|
|
|
test("README.md, tests and files outside packages need no bump", () => {
|
|
expect(unbumped(["packages/a/README.md", "packages/a/index.test.mjs", "scripts/check.mjs", "registry.json"], versionAt, packed)).toEqual([])
|
|
})
|