0
0
Fork 0
Codesys-MCP-SP21-plus/tests/unit
Karstein Phobic Nyvold Kvistad 33363fbfd0 fix(release_project_version): stop README corruption and silent Changelog no-op
BUG 1: the README.md version replace was content.replace(/v\d+\.\d+\.\d+\.\d+/g,
newVersion) -- a blanket sweep that rewrote every version-looking string in
the file, corrupting historical fix landmarks, build-archive snapshots, and
even a different project's synced-library version (observed live on
SeaLeopard's README v1.3.0.0 -> v1.3.1.0). Replaced with updateReadmeVersion:
only touches the version token on the first "# " title heading, or a single
"**Version:**" line (Lib001 convention). If no anchor is found (or the
Version-line anchor is ambiguous), nothing is changed and the reason is
reported -- no global-replace fallback.

BUG 2: appendChangelogEntry's "ownership guard" checked for the literal text
'Auto-generated by `bump_project_version`', but the intro this same tool
seeds into new files says 'Auto-appended by `bump_project_version` on
release.' -- the strings never matched, so every one of this tool's own
previously-created Changelog.md files (SeaLeopard, since its v1.0.0.0 seed)
was treated as foreign and silently skipped. The skip only logged to
stderr while release_project_version's caller printed a fixed "Changelog.md:
appended vX" success line regardless. Separately, a genuinely hand-maintained
Keep-a-Changelog file (Lib001's CHANGELOG.md, "## [Unreleased]" / "## [x.y.z.w]
- date") was never understood at all. Confirmed via SeaLeopard commits
3c87d18 / c98c264, which hand-repaired both the missing changelog entries and
the corrupted README.

Replaced with buildChangelogUpdate (pure) + appendChangelogEntry (I/O
wrapper): detects the existing file's heading style from its own headings
(not intro wording) and emits a matching entry -- "ours" style
(## vX.Y.Z.W -- date) inserted before the first existing entry, or
Keep-a-Changelog style (## [X.Y.Z.W] - date) inserted after any
"## [Unreleased]" section (or before the first version heading if none).
An unrecognized format is left untouched with a clear skip reason. The write
is verified by re-reading the file before release_project_version reports
success; a write that didn't happen is now reported as NOT appended.

Rebuilt dist/ (tsc + scripts copy) since the MCP server runs from there.

Tests: 16 new (update-readme-version, build-changelog-update,
append-changelog-entry), full suite: npx vitest --run -- 229 passed, 1
pre-existing unrelated failure (script-manager.test.ts trips on a local
__pycache__ dir under src/scripts, present before this change too).
2026-07-23 17:20:02 +02:00
..
append-changelog-entry.test.ts fix(release_project_version): stop README corruption and silent Changelog no-op 2026-07-23 17:20:02 +02:00
build-changelog-update.test.ts fix(release_project_version): stop README corruption and silent Changelog no-op 2026-07-23 17:20:02 +02:00
clamp-interval.test.ts test(e2e): regression coverage for the four 2026-04-29 fixes (#14) 2026-04-29 13:44:02 +02:00
detect.test.ts feat(cli): --print-config --for-project <path> picks the install that opens the project 2026-04-27 22:27:31 +02:00
get-user-selection.test.ts feat(mcp): register get_user_selection tool 2026-04-28 22:28:09 +02:00
inspect.test.ts feat(cli): --inspect <project> reads CODESYS profile + mandatory libs offline (no CODESYS needed) 2026-04-27 21:47:31 +02:00
ipc.test.ts Initial release: MCP server for CODESYS with persistent UI instance 2026-02-08 18:59:16 +10:00
launcher.test.ts fix(launcher): revalidate stale "Refusing to launch" cache on get_codesys_status 2026-05-15 14:37:02 +02:00
live-values-pump.test.ts feat(live-values): depth-1 sub-property descent 2026-04-29 13:52:35 +02:00
live-values-write.test.ts feat(live-values): atomic writer for tui-live-values.json 2026-04-29 09:51:17 +02:00
mirror-paths.test.ts fix(mirror): per-project mirror dir name when multiple .project files share a parent 2026-04-27 22:22:09 +02:00
open-project-preflight.test.ts feat(open_project): pre-flight profile-mismatch check using offline .project inspection 2026-04-27 22:32:53 +02:00
path-guard.test.ts feat(project-tools): reject UNC paths with a clear, actionable error 2026-06-04 11:02:48 +02:00
reserved-iec-identifiers.test.ts create_pou/create_method: accept declarationCode/implementationCode; full IEC keyword guard (0.13.0) 2026-07-17 09:35:44 +02:00
script-manager.test.ts fix: ASCII-fy add_library.py comment, clean dist/scripts on build, global ASCII test 2026-06-12 13:43:27 +02:00
ssh-version.test.ts feat(ssh): read_running_version_ssh -- read PLC project version over SSH, no CODESYS needed 2026-04-27 22:13:29 +02:00
state-read.test.ts feat(state): add CJS reader for phobiCS-tui state file 2026-04-28 22:26:15 +02:00
update-readme-version.test.ts fix(release_project_version): stop README corruption and silent Changelog no-op 2026-07-23 17:20:02 +02:00
var-block-parse.test.ts feat(live-values): depth-1 sub-property descent 2026-04-29 13:52:35 +02:00