Files
OmniRoute/tests/unit/cli-serve-version-banner.test.ts
Diego Rodrigues de Sa e Souza be96fb916b feat(cli): show version in startup banner (integrates #5752) (#5769)
* feat(cli): show version in startup banner

Print dim 'v<version>' line below ASCII art logo in omniroute serve.
Uses readFileSync (same pattern as program.mjs) to read package.json.
Closes #5749.

* test(cli): guard startup-banner version line (#5752)

Source-inspection test (same pattern as cli-serve-port.test.ts) asserting
serve.mjs parses the version from package.json and prints v${_pkg.version}
in the startup banner — satisfies Hard Rule #8 for the bin/ change.

Co-authored-by: diegosouzapw <diegosouza.pw@gmail.com>

* docs(changelog): credit #5752 startup-banner version line (thanks @chirag127)

---------

Co-authored-by: Chirag Singhal <76880977+chirag127@users.noreply.github.com>
2026-07-01 01:29:33 -03:00

39 lines
1.2 KiB
TypeScript

import test from "node:test";
import assert from "node:assert/strict";
import fs from "node:fs";
import path from "node:path";
/**
* Regression guard for the startup-banner version line (#5752).
*
* `runServe` prints `v<version>` under the ASCII banner. The version is parsed
* once at module load from the repo-root package.json. These source-inspection
* assertions (same technique as cli-serve-port.test.ts) ensure the banner never
* silently loses the version again — mirroring how the CLI is exercised without
* spawning a real server.
*/
const serveSource = fs.readFileSync(
path.resolve(import.meta.dirname, "../../bin/cli/commands/serve.mjs"),
"utf-8",
);
test("serve banner: version is parsed from package.json at module load", () => {
assert.match(
serveSource,
/_pkg\s*=\s*JSON\.parse\(\s*readFileSync\(/,
"serve.mjs should parse the version from package.json into _pkg",
);
assert.ok(
serveSource.includes("package.json"),
"serve.mjs should reference package.json for the version source",
);
});
test("serve banner: startup banner prints v<version>", () => {
assert.match(
serveSource,
/v\$\{_pkg\.version\}/,
"serve.mjs should print v${_pkg.version} in the startup banner",
);
});