fix(0.6.2): entrypoint guard rejected the npm-installed ralphctl shim#102
Merged
Conversation
shouldAutoInvoke gated on basename(process.argv[1]) matching cli.mjs / entrypoint.ts. Under npm's global install, the bin entry symlinks <prefix>/bin/ralphctl β dist/cli.mjs β basename ralphctl, gate fails, main() never runs. 0.6.0 / 0.6.1 silently no-op'd on a fresh npm i -g ralphctl && ralphctl --version (exit 0, empty stdout). Replace the basename allowlist with the canonical entry-module check: realpathSync(argv[1]) β pathToFileURL β compare to import.meta.url. Dev (tsx entrypoint.ts) and direct invocation (node dist/cli.mjs) both pass; symlinked bins resolve through and pass. Add a regression e2e that creates a renamed symlink to dist/cli.mjs and spawns it β asserts a semver lands on stdout. Prevents the silent-skip shape from regressing. Bump to 0.6.2.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Hotfix on top of 0.6.1.
npm i -g ralphctl && ralphctl --versionwas silently exiting 0 with no output β the basename gate inshouldAutoInvoke()rejected the npm-bin symlink (<prefix>/bin/ralphctlβdist/cli.mjs) because basename wasralphctl, notcli.mjs.Root cause
src/application/cli/entrypoint.ts#shouldAutoInvokecheckedbasename(process.argv[1])against the regex^(entrypoint|cli)\.(ts|mjs|js)$. When invoked via the npm-bin symlink,argv[1]is the shim path. Basenameralphctlfailed the regex βmain()never ran.Fix
Replace the basename allowlist with the canonical "am I the entry module?" pattern: resolve
argv[1]throughrealpathSyncand comparepathToFileURL(...).hreftoimport.meta.url. Dev (tsx src/.../entrypoint.ts) and direct (node dist/cli.mjs) both still pass; symlinked bins resolve through and pass too.Regression test
New e2e in
cli.e2e.test.tscreates a renamed symlink todist/cli.mjs(tmpRoot/ralphctl-bin-shim) and spawns it vianode. Asserts the version lands on stdout. Prevents the silent-skip shape from regressing.Test plan
pnpm typecheckΒ·pnpm lintΒ·pnpm testβ green locally (231 files / 2218 tests)dist/cli.mjs, symlinked/tmp/ralphctl-shim β dist/cli.mjs, rannode /tmp/ralphctl-shim --versionβ printed0.6.1(the version of the local working tree at build time)