Add markpost --version / -v to print the installed CLI version - #154
Add markpost --version / -v to print the installed CLI version#154grimicorn-agent wants to merge 4 commits into
Conversation
Wires a top-level version flag (--version, -v, and version for symmetry with the existing help path) so a globally-installed user can confirm which @markpost/cli version they're running. Reads the version the same way libs/config.ts already imports package.json. Extra arguments after the version token are rejected (fail loud), mirroring the sync command's own unexpected-argument guard. Closes #150
Independent code review trail (3 rounds, opus)Round 1
Round 2
Round 3
Unresolved / investigated and not applied: all three rounds flagged that
Given the reproducible, passing build/typecheck/runtime evidence against a theoretical claim repeated without new evidence across all 3 rounds, I did not apply the suggested |
grimicorn
left a comment
There was a problem hiding this comment.
Fix conflicts and pull in main for the CI fix
Merge + independent code review trailMerged After the merge: Round 1
Round 2
Round 3
3 rounds run per policy; stopping here. Re-requesting @grimicorn's review. |
What changed
Wires a top-level version flag into
src/index.ts's dispatch so a globally-installed user can confirm which@markpost/cliversion they're running:markpost --version,markpost -v, andmarkpost version(added for symmetry withhelp/--help/-h— seeHELP_COMMANDS) all print the installed version and exit 0.markpost push -v) still reaches its handler untouched.markpost --version sync) are rejected withUnexpected arguments: ...+ a usage line, exit 1 — a stray extra word is a usage mistake, not a request to version and run something else, mirroring thesynccommand's own unexpected-argument guard.packageJson.versionvia the sameimport ... from '../package.json' with { type: 'json' }patternsrc/libs/config.tsalready uses (this PR imports it directly insrc/index.tsrather than routing throughconfig.ts, sinceconfig.tsdoesn't currently export it).HELP_TEXTand the README's command table now mention--version/-vso the flag is discoverable.Implementation decisions
import ... from '../package.json'should fail TypeScript'srootDir/resolveJsonModulechecks undertsconfig.json's"module": "NodeNext"+"rootDir": "./src". I verified directly:npm run build(tsc && tsc-alias),npx tsc -p tsconfig.json --listFiles, and running the emitteddist/index.js(node dist/index.js --version→0.1.0) all succeed with zero errors. This matches the pre-existing, working precedent insrc/libs/config.ts. I did not apply the reviewer's suggestedcreateRequirerewrite since there is no actual reproducible failure — happy to revisit if CI proves otherwise.package.jsonenginesfloor for Node 20.10+ (import-attribute syntax) — that's a pre-existing condition of the codebase'swith { type: 'json' }usage inconfig.ts, not something this change introduces, and this PR was asked to avoid touchingpackage.json(another open PR is mid-flight on it).Testing
tests/index.test.ts: new cases for all three version tokens (happy path incl. semver-shape assertion, sub-argument pass-through, extra-argument rejection for each token).npm run typecheck,npm run build,npm run lintall clean.Where to see it
src/index.ts(dispatch,runVersionCommand,VERSION_COMMANDS/VERSION_USAGE)tests/index.test.tsREADME.mdcommand tableCloses #150