Skip to content

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

Merged
jianliang00 merged 1 commit into
mainfrom
p/wangjianliang/fix-create-lynx-extension-bin-entrypoint
May 13, 2026
Merged

fix(autolink): detect create extension npm bin symlinks#2623
jianliang00 merged 1 commit into
mainfrom
p/wangjianliang/fix-create-lynx-extension-bin-entrypoint

Conversation

@jianliang00
Copy link
Copy Markdown
Contributor

@jianliang00 jianliang00 commented May 13, 2026

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

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 Change Stack

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 13, 2026

🦋 Changeset detected

Latest commit: b3eaa58

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
create-lynx-extension Patch

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

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 13, 2026

📝 Walkthrough

Walkthrough

The 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.

Changes

CLI Entrypoint Symlink Detection

Layer / File(s) Summary
Entrypoint detection with real-path normalization
packages/lynx/create-lynx-extension/src/cli.ts
Added fs import and refactored isCliEntrypoint(entrypoint = process.argv[1], moduleUrl = import.meta.url) to normalize absolute paths, use fs.realpathSync with fallback, and compare resolved paths.
Symlink entrypoint test coverage
packages/lynx/create-lynx-extension/test/cli.test.ts
Extended imports to include pathToFileURL and isCliEntrypoint. Added a test that mocks fs.realpathSync so .bin/create-lynx-extension resolves to dist/cli.js and asserts detection returns true.
Release changeset
.changeset/fix-create-extension-bin-entrypoint.md
Adds a patch changeset noting a fix for npm bin symlink entrypoint detection for create-lynx-extension.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Suggested reviewers

  • PupilTong
  • f0rdream
  • colinaaa

Poem

🐰 I hopped along a symlink trail,
Real-path made the puzzle pale.
Entrypoint matched with tidy grace,
.bin and dist now share the place.
Cheers — a bunny's little celebratory dance! ✨

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ⚠️ Warning The title mentions fixing autolink but the PR actually fixes create-lynx-extension bin symlink detection, which is unrelated to autolink. Change the title to reflect the actual change, such as 'fix(create-lynx-extension): detect npm bin symlinks' or 'fix: detect create-lynx-extension npm bin symlinks'.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch p/wangjianliang/fix-create-lynx-extension-bin-entrypoint

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@jianliang00 jianliang00 changed the title [codex] Fix create-lynx-extension bin entrypoint symlink detection Fix create-lynx-extension bin entrypoint symlink detection May 13, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 13, 2026

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
4582 1 4581 63
View the top 1 failed test(s) by shortest run time
tests/web-elements.spec.ts::web-elements test suite › x-refresh-view › x-refresh-view/pull
Stack Traces | 3.51s run time
web-elements.spec.ts:3179:5 x-refresh-view/pull

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@jianliang00 jianliang00 force-pushed the p/wangjianliang/fix-create-lynx-extension-bin-entrypoint branch from c4d35c8 to 188b248 Compare May 13, 2026 12:10
@jianliang00 jianliang00 marked this pull request as ready for review May 13, 2026 12:12
Copilot AI review requested due to automatic review settings May 13, 2026 12:12
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.realpathSync before comparing them in the CLI “am I the entrypoint?” guard.
  • Export the isCliEntrypoint helper to enable direct regression testing.
  • Add a regression test that simulates npm bin symlink resolution via a fs.realpathSync mock.

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.

@jianliang00 jianliang00 force-pushed the p/wangjianliang/fix-create-lynx-extension-bin-entrypoint branch from 188b248 to b3eaa58 Compare May 13, 2026 12:17
@jianliang00 jianliang00 requested a review from colinaaa May 13, 2026 12:19
@jianliang00 jianliang00 changed the title Fix create-lynx-extension bin entrypoint symlink detection fix(autolink): detect create extension npm bin symlinks May 13, 2026
@jianliang00 jianliang00 enabled auto-merge (squash) May 13, 2026 12:30
@jianliang00 jianliang00 disabled auto-merge May 13, 2026 12:30
@jianliang00 jianliang00 merged commit bdbcf79 into main May 13, 2026
37 of 41 checks passed
@jianliang00 jianliang00 deleted the p/wangjianliang/fix-create-lynx-extension-bin-entrypoint branch May 13, 2026 12:30
@codspeed-hq
Copy link
Copy Markdown

codspeed-hq Bot commented May 13, 2026

Merging this PR will degrade performance by 15.39%

⚠️ Different runtime environments detected

Some benchmarks with significant performance changes were compared across different runtime environments,
which may affect the accuracy of the results.

Open the report in CodSpeed to investigate

❌ 2 regressed benchmarks
✅ 79 untouched benchmarks
⏩ 26 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

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)

Open in CodSpeed

Footnotes

  1. 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.

@relativeci
Copy link
Copy Markdown

relativeci Bot commented May 13, 2026

React External

#1275 Bundle Size — 693.04KiB (0%).

b3eaa58(current) vs 9437b0d main#1274(baseline)

Bundle metrics  no changes
                 Current
#1275
     Baseline
#1274
No change  Initial JS 0B 0B
No change  Initial CSS 0B 0B
No change  Cache Invalidation 0% 0%
No change  Chunks 0 0
No change  Assets 3 3
No change  Modules 17 17
No change  Duplicate Modules 5 5
No change  Duplicate Code 8.59% 8.59%
No change  Packages 0 0
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#1275
     Baseline
#1274
No change  Other 693.04KiB 693.04KiB

Bundle analysis reportBranch p/wangjianliang/fix-create-lynx-...Project dashboard


Generated by RelativeCIDocumentationReport issue

@relativeci
Copy link
Copy Markdown

relativeci Bot commented May 13, 2026

React Example with Element Template

#427 Bundle Size — 197.79KiB (0%).

b3eaa58(current) vs 9437b0d main#426(baseline)

Bundle metrics  Change 2 changes
                 Current
#427
     Baseline
#426
No change  Initial JS 0B 0B
No change  Initial CSS 0B 0B
No change  Cache Invalidation 0% 0%
No change  Chunks 0 0
No change  Assets 4 4
Change  Modules 79(-2.47%) 81
No change  Duplicate Modules 23 23
Change  Duplicate Code 40.32%(+0.07%) 40.29%
No change  Packages 2 2
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#427
     Baseline
#426
No change  IMG 145.76KiB 145.76KiB
No change  Other 52.03KiB 52.03KiB

Bundle analysis reportBranch p/wangjianliang/fix-create-lynx-...Project dashboard


Generated by RelativeCIDocumentationReport issue

@relativeci
Copy link
Copy Markdown

relativeci Bot commented May 13, 2026

React MTF Example

#1293 Bundle Size — 207.46KiB (0%).

b3eaa58(current) vs 9437b0d main#1292(baseline)

Bundle metrics  no changes
                 Current
#1293
     Baseline
#1292
No change  Initial JS 0B 0B
No change  Initial CSS 0B 0B
No change  Cache Invalidation 0% 0%
No change  Chunks 0 0
No change  Assets 3 3
No change  Modules 192 192
No change  Duplicate Modules 77 77
No change  Duplicate Code 44.38% 44.38%
No change  Packages 2 2
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#1293
     Baseline
#1292
No change  IMG 111.23KiB 111.23KiB
No change  Other 96.23KiB 96.23KiB

Bundle analysis reportBranch p/wangjianliang/fix-create-lynx-...Project dashboard


Generated by RelativeCIDocumentationReport issue

@relativeci
Copy link
Copy Markdown

relativeci Bot commented May 13, 2026

Web Explorer

#9735 Bundle Size — 901.38KiB (0%).

b3eaa58(current) vs 9437b0d main#9734(baseline)

Bundle metrics  no changes
                 Current
#9735
     Baseline
#9734
No change  Initial JS 45.06KiB 45.06KiB
No change  Initial CSS 2.22KiB 2.22KiB
No change  Cache Invalidation 0% 0%
No change  Chunks 9 9
No change  Assets 11 11
No change  Modules 229 229
No change  Duplicate Modules 11 11
No change  Duplicate Code 27.22% 27.22%
No change  Packages 10 10
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#9735
     Baseline
#9734
No change  JS 497.1KiB 497.1KiB
No change  Other 402.06KiB 402.06KiB
No change  CSS 2.22KiB 2.22KiB

Bundle analysis reportBranch p/wangjianliang/fix-create-lynx-...Project dashboard


Generated by RelativeCIDocumentationReport issue

@relativeci
Copy link
Copy Markdown

relativeci Bot commented May 13, 2026

React Example

#8160 Bundle Size — 236.51KiB (0%).

b3eaa58(current) vs 9437b0d main#8159(baseline)

Bundle metrics  no changes
                 Current
#8160
     Baseline
#8159
No change  Initial JS 0B 0B
No change  Initial CSS 0B 0B
No change  Cache Invalidation 0% 0%
No change  Chunks 0 0
No change  Assets 4 4
No change  Modules 197 197
No change  Duplicate Modules 80 80
No change  Duplicate Code 44.87% 44.87%
No change  Packages 2 2
No change  Duplicate Packages 0 0
Bundle size by type  no changes
                 Current
#8160
     Baseline
#8159
No change  IMG 145.76KiB 145.76KiB
No change  Other 90.75KiB 90.75KiB

Bundle analysis reportBranch p/wangjianliang/fix-create-lynx-...Project dashboard


Generated by RelativeCIDocumentationReport issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants