Generate src/version.js from codemeta.json instead of tracking it - #48
Merged
Conversation
The CDN bundle reports version 0.0.12, released 2025-07-17, while codemeta.json says 0.0.16, released 2026-01-28. That string is in production JavaScript today, four releases and seven months out of date. The cause is a gap in the tooling rather than anyone forgetting. cmt can only write to the repository root, so the Makefile generates version.js there and moves it into src/. Nothing runs that except a person typing `make`, and `deno task build` used to write its own bundle over the top of it. tools/version.js writes the file from inputs already in the repository: version codemeta.json "version" releaseDate codemeta.json "datePublished" releaseHash git rev-parse --short HEAD licenseText LICENSE.txt, or LICENSE Output is byte-identical to cmt's, verified against the committed file. This is not a replacement for cmt -- it covers the one file cmt cannot write to the right place, and cmt keeps README.md and CITATION.cff. `deno task build` runs it first, so a fresh clone needs Deno and nothing else, and the file cannot drift because it no longer exists between builds. It is gitignored for the same reason: it is build output, and it was tracked before, so without the ignore the next `git add -A` would restore the stale copy. `deno task release` becomes an alias for `deno task build` rather than a second copy of the same commands. The two had already drifted -- release omitted the version step, so on a clean checkout it would bundle against a file that does not exist. Two definitions of one build is what allowed that, and it is the same drift that let release zips and local builds disagree. The task CI exercises is the one that stays correct; nothing ever ran release. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
ADR-0004. The generator has to live somewhere, and the options that would share it across projects are all blocked or out of scope: cmt cannot write to src/, metadatatools is the wrong domain and its only version is yanked, raw GitHub URLs are served as text/plain and Deno refuses them, and publishing a package to JSR is not something we are taking on now. Vendoring is a placeholder. The script is deliberately project-agnostic so that replacing it costs one line in deno.json.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The version reported by the shipped bundles has been wrong for over a year.
src/version.jssaid0.0.12whilecodemeta.jsonsaid0.0.16, and sincethe CDN serves unversioned paths, that export is the only way a consumer can
tell what they are running.
Why it went stale
Nothing wrote it.
cmtis the generator and the Makefile invokes it:version.js: .FORCE cmt codemeta.json version.jsThat writes the repository root. The bundler reads
src/version.js. They havebeen different files since the
src/reorganization in dac929b (2025-07-17),and the target cannot be pointed at the new location, because
cmtuses theoutput filename as the format key (
cmt.ts:211,const format = outputName).So
cmt codemeta.json src/version.jsexits withunsupported format.src/version.jsstill carries that commit’\s own date and hash. It was correctthe day it was written and never again.
What this does
tools/generate-version.jsreadscodemeta.jsonand writessrc/version.js.Byte-identical to what
cmt0.0.46 produces; verified by diff.deno task buildnow depends ondeno task generate-version, so the versioncannot drift from
codemeta.jsonagain.src/version.jsis untracked, per ADR-0003 — it is build output.deno task releasehad also drifted and would have built from a missing fileon a clean checkout. It is now an alias for
deno task build.Verified on a clean checkout: produces
0.0.16, matchingcodemeta.json.What this does not change
cmt codemeta.json version.jsstill works and still refreshes the rootversion.js, which is published. The Makefile is untouched.A copy, deliberately
The script is vendored rather than shared, because every option that would
share it is blocked or out of scope right now. ADR-0004 records the four
rejected alternatives so the next person does not have to rediscover them.
The script is project-agnostic, so replacing it later costs one line in
deno.json.