SIGN IN SIGN UP

fix(autolink): detect create extension npm bin symlinks (#2623)

## Summary

Fix `create-lynx-extension` so the published CLI runs when invoked
through npm-created bin symlinks such as `npm create
lynx-extension-canary` or `npm exec create-lynx-extension`.

## Root Cause

The executable guard compared `path.resolve(process.argv[1])` directly
with `fileURLToPath(import.meta.url)`. npm invokes package bins through
`node_modules/.bin/*` symlinks, so the comparison failed and `main()`
was never called. The process exited successfully without printing help,
prompting, or creating files.

## Changes

- Normalize the CLI entrypoint and module path through `fs.realpathSync`
before comparing them.
- Export the entrypoint helper for focused test coverage.
- Add a regression test for npm bin symlink execution.

## Validation

- `pnpm --filter create-lynx-extension test`
- `pnpm --filter create-lynx-extension build`
- `pnpm biome check packages/lynx/create-lynx-extension/src/cli.ts
packages/lynx/create-lynx-extension/test/cli.test.ts`
- `pnpm dprint fmt packages/lynx/create-lynx-extension/src/cli.ts
packages/lynx/create-lynx-extension/test/cli.test.ts`
- Local `npm exec --package
/Users/bytedance/Code/lynx-stack/packages/lynx/create-lynx-extension
create-lynx-extension -- --help`


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

* **Bug Fixes**
* Improved CLI entrypoint detection to correctly handle npm `.bin`
symlinks and consistently normalize paths for reliable executable
detection.

* **Tests**
* Added test coverage to verify npm `.bin` symlink entrypoint detection
for the CLI.

<!-- review_stack_entry_start -->

[![Review Change
Stack](https://storage.googleapis.com/coderabbit_public_assets/review-stack-in-coderabbit-ui.svg)](https://app.coderabbit.ai/change-stack/lynx-family/lynx-stack/pull/2623)

<!-- review_stack_entry_end -->
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
J
Jianliang Wang committed
bdbcf7996ebc5c09ec28273bf03527697b50cef7
Parent: 9437b0d
Committed by GitHub <noreply@github.com> on 5/13/2026, 12:30:47 PM