Repository navigation
refactor: single source of truth for the app version (package.json) - #8
Merged
Merged
Conversation
The version previously had to be bumped by hand in package.json, the index.html badge, and the E2E test. Now it lives only in package.json: - scripts/build.js (new) replaces the inline esbuild command and injects the version at build time via esbuild `define` (__APP_VERSION__), read from $npm_package_version (falling back to the package.json in cwd). An optional APP_VERSION env var overrides the display string. - index.html ships an empty .app-version badge; main.js fills it from the injected constant on init. - The version E2E assertion derives the expected value from package.json. - build-pages.sh builds every variant through build.js instead of a raw esbuild call + sed stamp. The /preview build is labelled via APP_VERSION; release builds derive "v<version>" from the tag's package.json. Older release refs (whose main.js predates injection) keep their static badge, which for a tag already equals the tag version — so the fallback stays correct. Bumping the version is now a one-line change to package.json. Verified: build injects the badge, all 51 E2E tests pass, and build-pages produces correct badges for new (injected) and old (static fallback) refs.
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.
Follow-up to #7. The app version had to be bumped by hand in three places (
package.json, theindex.htmlbadge, and the E2E test). This makespackage.jsonthe single source of truth.What changed
scripts/build.js(new) replaces the inline esbuild command and injects the version at build time via esbuilddefine→__APP_VERSION__, read from$npm_package_version(falling back to thepackage.jsonin the current working directory). An optionalAPP_VERSIONenv var overrides the display string.index.htmlships an empty.app-versionbadge;main.jsfills it from the injected constant on init.package.jsoninstead of hardcoding it.build-pages.shnow builds every variant throughbuild.jsinstead of a raw esbuild call +sedstamp./previewis labelled viaAPP_VERSION; release builds derivev<version>from the tag'spackage.json. Older release refs (whosemain.jspredates injection) simply keep their static badge — which for a release tag already equals the tag version — so the fallback stays correct.Bumping the version is now a one-line change to
package.json.Verification
npm run buildinjects the badge; browser-rendered badge showsv0.2.1.build-pages.shverified for all three paths: new release tag (injected),APP_VERSIONoverride (preview label), and old ref (static-badge fallback) — all produce correct badges.https://claude.ai/code/session_01H8rjA9L8mXvBm5FREpaPfD
Generated by Claude Code