Show the app version at the top of the page (Ver YYMMDDX)

Adds src/version.js, bump-version.js and a pre-commit hook that bumps the
version in commits that change the app.

Closes #15

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-09 19:01:33 -05:00
parent 1736548ef9
commit a2fcc65759
10 changed files with 193 additions and 3 deletions

View File

@@ -74,3 +74,28 @@ test('backupName and passphraseProblem', () => {
assert.ok(passphraseProblem('elevenchars'));
assert.equal(passphraseProblem('twelve chars!'), '');
});
// ---- version ----
import { APP_VERSION, isVersion, nextVersion, versionDate } from '../src/version.js';
test('APP_VERSION is a valid Ver YYMMDDX', () => {
assert.equal(isVersion(APP_VERSION), true);
assert.equal(isVersion('261109B'), true);
for (const bad of ['', '26110B', '2611091', '261109b', '261109AA', null, 5]) assert.equal(isVersion(bad), false, String(bad));
});
test('nextVersion: next letter same day, A on a new day, error past Z', () => {
const d = new Date(2026, 10, 9, 15, 0); // 9 Nov 2026 local
assert.equal(versionDate(d), '261109');
assert.equal(nextVersion('261109A', d), '261109B');
assert.equal(nextVersion('261109Y', d), '261109Z');
assert.throws(() => nextVersion('261109Z', d), /26 versions/);
assert.equal(nextVersion('261108D', d), '261109A');
assert.equal(nextVersion('261109C', new Date(2027, 0, 2)), '270102A');
assert.throws(() => nextVersion('nope', d), /Not a version/);
});
test('the built page carries the version', async () => {
const { bundleJs } = await import('../build.js'); // importing must not run a build
assert.ok(bundleJs().includes(`APP_VERSION = '${APP_VERSION}'`));
});