Skip to content

refactor: single source of truth for the app version (package.json) - #8

Merged
OliEder merged 1 commit into
claude/app-review-Oy0Tafrom
claude/version-single-source
Jun 29, 2026
Merged

OliEder merged 1 commit into
claude/app-review-Oy0Tafrom
claude/version-single-source

Conversation

@OliEder

@OliEder OliEder commented May 30, 2026

Copy link
Copy Markdown
Contributor

Follow-up to #7. The app version had to be bumped by hand in three places (package.json, the index.html badge, and the E2E test). This makes package.json the single source of truth.

What changed

  • 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 the current working directory). 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.
  • E2E test derives the expected version from package.json instead of hardcoding it.
  • build-pages.sh now builds every variant through build.js instead of a raw esbuild call + sed stamp. /preview is labelled via APP_VERSION; release builds derive v<version> from the tag's package.json. Older release refs (whose main.js predates injection) simply keep their static badge — which for a release tag already equals the tag version — so the fallback stays correct.
  • Docs (README + arc42) updated to describe the single-source mechanism.

Bumping the version is now a one-line change to package.json.

Verification

  • npm run build injects the badge; browser-rendered badge shows v0.2.1.
  • All 51 E2E tests pass (including the now-derived version assertion).
  • build-pages.sh verified for all three paths: new release tag (injected), APP_VERSION override (preview label), and old ref (static-badge fallback) — all produce correct badges.

Stacked on #7 (claude/app-review-Oy0Ta) to avoid file overlap; GitHub will retarget this to main automatically once #7 merges.

https://claude.ai/code/session_01H8rjA9L8mXvBm5FREpaPfD


Generated by Claude Code

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.
@OliEder
OliEder merged commit e25a74d into claude/app-review-Oy0Ta Jun 29, 2026
@OliEder
OliEder deleted the claude/version-single-source branch June 29, 2026 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants