-
Notifications
You must be signed in to change notification settings - Fork 0
fix(release): regenerate version artifacts and stop reflowing deno.json #3706
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
kojiwakayama
merged 2 commits into
main
from
fix/release-regenerate-and-preserve-formatting
Aug 14, 2026
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| /** | ||
| * Version rewriting for the release task. | ||
| * | ||
| * Kept apart from release.ts so it can be tested without pulling in that | ||
| * module's runtime dependencies. | ||
| */ | ||
|
|
||
| /** | ||
| * Replace the version in deno.json source text, leaving everything else byte for | ||
| * byte as it was. | ||
| * | ||
| * Re-serialising the parsed object instead reflows the whole file -- it expands | ||
| * inline arrays such as `"dependencies": ["build:npm"]` across several lines -- | ||
| * burying the one meaningful line under churn a human then has to revert. | ||
| */ | ||
| export function bumpDenoJsonVersion(source: string, newVersion: string): string { | ||
| const versionField = /("version"\s*:\s*")[^"]*(")/; | ||
| if (!versionField.test(source)) { | ||
| throw new Error('Could not find a "version" field in deno.json'); | ||
| } | ||
| return source.replace(versionField, `$1${newVersion}$2`); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| import { assertEquals, assertStringIncludes, assertThrows } from "#std/assert"; | ||
| import { describe, it } from "#std/testing/bdd"; | ||
| import { bumpDenoJsonVersion } from "./release-version.ts"; | ||
|
|
||
| // A deno.json shaped like the real one: an inline array is what re-serialising | ||
| // used to reflow, so it has to survive a bump untouched. | ||
| const DENO_JSON = `{ | ||
| "name": "veryfront", | ||
| "version": "0.1.1236", | ||
| "tasks": { | ||
| "test:node": { | ||
| "command": "node ./tests/node/run-tests.mjs", | ||
| "dependencies": ["build:npm"] | ||
| }, | ||
| "test:bun": { | ||
| "command": "node ./tests/bun/run-tests.mjs", | ||
| "dependencies": ["build:npm"] | ||
| } | ||
| } | ||
| } | ||
| `; | ||
|
|
||
| describe("scripts/release", () => { | ||
| describe("bumpDenoJsonVersion", () => { | ||
| it("changes the version and nothing else", () => { | ||
| const bumped = bumpDenoJsonVersion(DENO_JSON, "0.1.1237"); | ||
|
|
||
| assertStringIncludes(bumped, '"version": "0.1.1237"'); | ||
| assertEquals( | ||
| bumped.split("\n").filter((line, index) => line !== DENO_JSON.split("\n")[index]), | ||
| [' "version": "0.1.1237",'], | ||
| ); | ||
| }); | ||
|
|
||
| it("leaves inline arrays inline", () => { | ||
| // The regression: JSON.stringify expanded these across three lines each, | ||
| // so a one-line release commit arrived carrying unrelated reformatting. | ||
| const bumped = bumpDenoJsonVersion(DENO_JSON, "0.1.1237"); | ||
|
|
||
| assertEquals( | ||
| bumped.match(/"dependencies": \["build:npm"\]/g)?.length, | ||
| 2, | ||
| ); | ||
| assertEquals(bumped.includes('"dependencies": [\n'), false); | ||
| }); | ||
|
|
||
| it("keeps the file otherwise byte for byte", () => { | ||
| const bumped = bumpDenoJsonVersion(DENO_JSON, "0.1.1237"); | ||
|
|
||
| assertEquals( | ||
| bumped.replace('"version": "0.1.1237"', '"version": "0.1.1236"'), | ||
| DENO_JSON, | ||
| ); | ||
| }); | ||
|
|
||
| it("refuses a file with no version field", () => { | ||
| assertThrows( | ||
| () => bumpDenoJsonVersion('{\n "name": "veryfront"\n}\n', "0.1.1237"), | ||
| Error, | ||
| 'Could not find a "version" field', | ||
| ); | ||
| }); | ||
| }); | ||
|
|
||
| describe("release ordering", () => { | ||
| it("regenerates version artifacts before committing", async () => { | ||
| // hydration-runtime.generated.ts embeds its own VERSION and cannot be | ||
| // reached by the regex pass, so the generate step has to run before the | ||
| // commit. Reordering these silently reintroduces a stale-artifact release | ||
| // that fails generate:manifests:check on the required typecheck shard. | ||
| const source = await Deno.readTextFile(new URL("./release.ts", import.meta.url)); | ||
| const generateAt = source.indexOf('"deno", "task", "generate"'); | ||
| const commitAt = source.indexOf('"git", "commit"'); | ||
|
|
||
| assertEquals(generateAt > -1, true, "release must run deno task generate"); | ||
| assertEquals(commitAt > -1, true, "release must create the commit"); | ||
| assertEquals( | ||
| generateAt < commitAt, | ||
| true, | ||
| "deno task generate must run before the release commit", | ||
| ); | ||
| }); | ||
| }); | ||
| }); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win
Use the repository test helpers.
Replace the
#stdBDD and assertion imports with#veryfront/testing/bdd.tsand#veryfront/testing/assert.ts. This keeps the test on the repository test API.As per coding guidelines:
**/*.test.tsmust usedescribe()andit()from#veryfront/testing/bdd.ts, and assertions from#veryfront/testing/assert.ts.🤖 Prompt for AI Agents
Source: Coding guidelines