fix(autolink): detect create extension npm bin symlinks#2623
Conversation
🦋 Changeset detectedLatest commit: b3eaa58 The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
📝 WalkthroughWalkthroughThe PR refactors CLI entrypoint detection: isCliEntrypoint now accepts optional entrypoint and moduleUrl, normalizes and realpath-resolves both paths, and compares them. Tests mock fs.realpathSync to verify npm .bin symlink detection; a changeset documents the fix. ChangesCLI Entrypoint Symlink Detection
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
❌ 1 Tests Failed:
View the top 1 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
c4d35c8 to
188b248
Compare
There was a problem hiding this comment.
Pull request overview
This PR fixes create-lynx-extension’s CLI executable guard so main() runs correctly when the CLI is invoked via npm-created node_modules/.bin/* symlinks (e.g. npm create lynx-extension-canary, npm exec create-lynx-extension), instead of silently exiting.
Changes:
- Normalize both the invoked entrypoint path and the module path using
fs.realpathSyncbefore comparing them in the CLI “am I the entrypoint?” guard. - Export the
isCliEntrypointhelper to enable direct regression testing. - Add a regression test that simulates npm bin symlink resolution via a
fs.realpathSyncmock.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| packages/lynx/create-lynx-extension/src/cli.ts | Realpath-normalize the entrypoint/module paths for correct CLI guard behavior when invoked through symlinks; export isCliEntrypoint. |
| packages/lynx/create-lynx-extension/test/cli.test.ts | Add regression coverage for npm .bin symlink execution by exercising isCliEntrypoint with mocked realpathSync. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
188b248 to
b3eaa58
Compare
Merging this PR will degrade performance by 15.39%
|
| Benchmark | BASE |
HEAD |
Efficiency | |
|---|---|---|---|---|
| ❌ | 008-many-use-state-destroyBackground |
8 ms | 9.5 ms | -16.16% |
| ❌ | transform 1000 view elements |
40 ms | 46.9 ms | -14.62% |
Tip
Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.
Comparing p/wangjianliang/fix-create-lynx-extension-bin-entrypoint (b3eaa58) with main (9437b0d)
Footnotes
-
26 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports. ↩
React External#1275 Bundle Size — 693.04KiB (0%).b3eaa58(current) vs 9437b0d main#1274(baseline) Bundle metrics
|
| Current #1275 |
Baseline #1274 |
|
|---|---|---|
0B |
0B |
|
0B |
0B |
|
0% |
0% |
|
0 |
0 |
|
3 |
3 |
|
17 |
17 |
|
5 |
5 |
|
8.59% |
8.59% |
|
0 |
0 |
|
0 |
0 |
Bundle analysis report Branch p/wangjianliang/fix-create-lynx-... Project dashboard
Generated by RelativeCI Documentation Report issue
React Example with Element Template#427 Bundle Size — 197.79KiB (0%).b3eaa58(current) vs 9437b0d main#426(baseline) Bundle metrics
Bundle size by type
|
| Current #427 |
Baseline #426 |
|
|---|---|---|
145.76KiB |
145.76KiB |
|
52.03KiB |
52.03KiB |
Bundle analysis report Branch p/wangjianliang/fix-create-lynx-... Project dashboard
Generated by RelativeCI Documentation Report issue
React MTF Example#1293 Bundle Size — 207.46KiB (0%).b3eaa58(current) vs 9437b0d main#1292(baseline) Bundle metrics
|
| Current #1293 |
Baseline #1292 |
|
|---|---|---|
0B |
0B |
|
0B |
0B |
|
0% |
0% |
|
0 |
0 |
|
3 |
3 |
|
192 |
192 |
|
77 |
77 |
|
44.38% |
44.38% |
|
2 |
2 |
|
0 |
0 |
Bundle size by type no changes
| Current #1293 |
Baseline #1292 |
|
|---|---|---|
111.23KiB |
111.23KiB |
|
96.23KiB |
96.23KiB |
Bundle analysis report Branch p/wangjianliang/fix-create-lynx-... Project dashboard
Generated by RelativeCI Documentation Report issue
Web Explorer#9735 Bundle Size — 901.38KiB (0%).b3eaa58(current) vs 9437b0d main#9734(baseline) Bundle metrics
|
| Current #9735 |
Baseline #9734 |
|
|---|---|---|
45.06KiB |
45.06KiB |
|
2.22KiB |
2.22KiB |
|
0% |
0% |
|
9 |
9 |
|
11 |
11 |
|
229 |
229 |
|
11 |
11 |
|
27.22% |
27.22% |
|
10 |
10 |
|
0 |
0 |
Bundle size by type no changes
| Current #9735 |
Baseline #9734 |
|
|---|---|---|
497.1KiB |
497.1KiB |
|
402.06KiB |
402.06KiB |
|
2.22KiB |
2.22KiB |
Bundle analysis report Branch p/wangjianliang/fix-create-lynx-... Project dashboard
Generated by RelativeCI Documentation Report issue
React Example#8160 Bundle Size — 236.51KiB (0%).b3eaa58(current) vs 9437b0d main#8159(baseline) Bundle metrics
|
| Current #8160 |
Baseline #8159 |
|
|---|---|---|
0B |
0B |
|
0B |
0B |
|
0% |
0% |
|
0 |
0 |
|
4 |
4 |
|
197 |
197 |
|
80 |
80 |
|
44.87% |
44.87% |
|
2 |
2 |
|
0 |
0 |
Bundle size by type no changes
| Current #8160 |
Baseline #8159 |
|
|---|---|---|
145.76KiB |
145.76KiB |
|
90.75KiB |
90.75KiB |
Bundle analysis report Branch p/wangjianliang/fix-create-lynx-... Project dashboard
Generated by RelativeCI Documentation Report issue
Summary
Fix
create-lynx-extensionso the published CLI runs when invoked through npm-created bin symlinks such asnpm create lynx-extension-canaryornpm exec create-lynx-extension.Root Cause
The executable guard compared
path.resolve(process.argv[1])directly withfileURLToPath(import.meta.url). npm invokes package bins throughnode_modules/.bin/*symlinks, so the comparison failed andmain()was never called. The process exited successfully without printing help, prompting, or creating files.Changes
fs.realpathSyncbefore comparing them.Validation
pnpm --filter create-lynx-extension testpnpm --filter create-lynx-extension buildpnpm biome check packages/lynx/create-lynx-extension/src/cli.ts packages/lynx/create-lynx-extension/test/cli.test.tspnpm dprint fmt packages/lynx/create-lynx-extension/src/cli.ts packages/lynx/create-lynx-extension/test/cli.test.tsnpm exec --package /Users/bytedance/Code/lynx-stack/packages/lynx/create-lynx-extension create-lynx-extension -- --helpSummary by CodeRabbit
Bug Fixes
.binsymlinks and consistently normalize paths for reliable executable detection.Tests
.binsymlink entrypoint detection for the CLI.