Files
ark-stronghold-protocol/test/version.test.js
T
sganggs 308444ef29 feedback1 integrate: version 0.1.1 and CHANGELOG.md
- package.json, package-lock.json and APP_VERSION (title screen, server banner, /healthz) at 0.1.1
- CHANGELOG.md (Simplified Chinese): the player-visible fixes of 0.1.1 by area, the reports checked and found not
  to be bugs, and 0.1.0; linked from the README's 文档 table; README / DEPLOY name the current version
- version.test.js checks the CHANGELOG heading and the README badge
2026-10-03 08:22:31 +08:00

62 lines
3.3 KiB
JavaScript

// Release metadata: one version everywhere (package.json, package-lock.json, shared/constants.js APP_VERSION shown on
// the title screen, the server banner and /healthz), the GPL-3.0-or-later licence (LICENSE, package.json, lockfile) and
// the notice files the README and the release bundle point at.
import { test } from 'node:test';
import assert from 'node:assert/strict';
import { readFileSync, existsSync } from 'node:fs';
import { join, dirname } from 'node:path';
import { fileURLToPath } from 'node:url';
import { APP_VERSION, PROTOCOL_VERSION } from '../shared/constants.js';
const ROOT = join(dirname(fileURLToPath(import.meta.url)), '..');
const read = (p) => readFileSync(join(ROOT, p), 'utf8');
const pkg = JSON.parse(read('package.json'));
const lock = JSON.parse(read('package-lock.json'));
test('one release version: package.json, package-lock.json and APP_VERSION', () => {
assert.match(APP_VERSION, /^\d+\.\d+\.\d+$/);
assert.equal(pkg.version, APP_VERSION);
assert.equal(lock.version, APP_VERSION);
assert.equal(lock.packages[''].version, APP_VERSION);
assert.equal(PROTOCOL_VERSION, 1, 'the wire protocol number is separate from the release version');
assert.equal(pkg.private, true, 'never published to npm');
});
test('CHANGELOG.md opens with the release version, and the README links it', () => {
const log = read('CHANGELOG.md');
const first = log.match(/^## (\d+\.\d+\.\d+) — (\d{4}-\d{2}-\d{2})/m);
assert.ok(first, 'a "## x.y.z — date" heading');
assert.equal(first[1], APP_VERSION, 'the newest entry is the current version');
assert.match(log, /^## 0\.1\.0 — 2026-10-02/m, 'the first public release stays listed');
const readme = read('README.md');
assert.match(readme, /\[CHANGELOG\.md\]\(CHANGELOG\.md\)/);
assert.match(readme, new RegExp(`badge/version-${APP_VERSION.replace(/\./g, '\\.')}-`), 'the README badge');
});
test('the release version is what players see', () => {
assert.match(read('public/js/screens/title.js'), /v\$\{APP_VERSION\}/, 'title screen footer');
assert.ok(!/PROTOCOL v1/.test(read('public/js/screens/title.js')), 'no protocol number posing as a version');
const server = read('server/index.js');
assert.match(server, /Stronghold Protocol: Covenant v\$\{APP_VERSION\}/, 'boot banner');
assert.match(server, /app: APP_VERSION/, '/healthz');
});
test('GPL-3.0-or-later: LICENSE, package metadata and notices', () => {
const license = read('LICENSE');
assert.match(license.slice(0, 200), /GNU GENERAL PUBLIC LICENSE\s+Version 3, 29 June 2007/);
assert.match(license, /END OF TERMS AND CONDITIONS/);
assert.equal(pkg.license, 'GPL-3.0-or-later');
assert.equal(lock.packages[''].license, 'GPL-3.0-or-later');
assert.match(pkg.repository.url, /github\.com\/sganggs\/Stronghold-Protocol/);
for (const f of ['NOTICE.md', 'THIRD-PARTY-NOTICES.md', 'tools/local-extract/LICENSE-Ark-Unpacker.txt']) {
assert.ok(existsSync(join(ROOT, f)), f);
}
const notice = read('NOTICE.md');
assert.match(notice, /GPL-3\.0-or-later/);
assert.match(notice, /非商业/);
assert.match(notice, /section 7/, 'the Spine Runtimes linking permission');
const aklz4 = read('tools/local-extract/aklz4.py');
assert.match(aklz4, /SPDX-License-Identifier: BSD-3-Clause/);
assert.match(aklz4, /Copyright \(c\) 2022, Harry Huang/);
});