Skip to content

chore(version): centralize plugin version + add drift guard - #16

Merged
Inch-high merged 2 commits into
mainfrom
chore/centralize-version-drift-guard
Jun 1, 2026
Merged

Inch-high merged 2 commits into
mainfrom
chore/centralize-version-drift-guard

Conversation

@Inch-high

Copy link
Copy Markdown
Owner

What & why

The plugin version was hardcoded in several disconnected places, so it drifted: the Settings → Theme "About" footer still read Modern UI v0.7.0 (Phase 7) and the shell user-menu read v0.4.2, while the plugin is at v0.8.x. This makes package.json the single source of truth and adds a guard so the remaining literals can't silently drift again.

Changes

Front-end (TS/Lit)

  • New src/ts/version.ts exports MODERNUI_VERSION, fed by a Vite define (__MODERNUI_VERSION__) from package.json in both tools/build.mjs and vitest.config.ts — one source for build and tests.
  • shell-user-menu.ts imports it instead of const VERSION = '0.4.2', and its About link's placeholder github.com/EXAMPLE/… URL is corrected to the real repo.

PHP pages

  • tools/build.mjs emits package/version (gitignored, ships in the txz) from package.json.
  • New modernui_plugin_version() in helpers.php reads it; Theme.page's About footer renders the real version (htmlspecialchars-escaped) instead of the hardcoded v0.7.0 (Phase 7).
  • The .plg <!ENTITY version> necessarily stays a literal (Unraid parses it before any code runs); the new guard keeps it honest.

Drift guard

  • tools/check-version-sync.mjs (npm run version:check) fails if package.json, package-lock.json (root + packages[""]), and the .plg <!ENTITY version> disagree. Wired into CI and release before the test steps.

Verification

  • npm run version:check → all four in sync at 0.8.3; forcing a mismatch exits 1 naming the culprit.
  • npm run build → bundle contains Modern UI v${…} → 0.8.3; no 0.4.2/EXAMPLE literals remain.
  • 462 TS tests pass; tsc --noEmit shows no new errors. PHP helpers.test.php passes (the one pre-existing save-docker-autostart failure is an unrelated Windows-only flake).

🤖 Generated with Claude Code

Inch-high and others added 2 commits June 1, 2026 21:31
Make package.json the single source of truth for the plugin version so it
can't go stale in multiple places again:

- Front-end: Vite `define` injects the version into a new src/ts/version.ts
  (MODERNUI_VERSION). shell-user-menu now imports it instead of a hardcoded
  `const VERSION = '0.4.2'`, and its About link's placeholder EXAMPLE URL is
  fixed to the real repo. vitest mirrors the same define so tests resolve it
  identically.
- PHP pages: build emits package/version (gitignored) from package.json, read
  at render time by modernui_plugin_version(). Theme.page's About footer shows
  the real version instead of the hardcoded "Modern UI v0.7.0 (Phase 7)".

Add tools/check-version-sync.mjs (`npm run version:check`): fails if
package.json, package-lock.json (root + packages[""]), and the .plg
<!ENTITY version> drift. Wired into CI and release before the test steps.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
`biome ci` in the lint job flagged the new single-line version read as
exceeding the line width. Apply Biome's formatting (multi-line call) so
the lint job passes; no behavior change.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@Inch-high
Inch-high merged commit b1a74a6 into main Jun 1, 2026
2 checks passed
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.

1 participant