feat: support yarn v1 detection from lockfile#1885
Conversation
✅ Deploy Preview for viteplus-preview canceled.
|
|
@codex review |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 189c176d58
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let yarn_lock_path = workspace_root.path.join("yarn.lock"); | ||
| if is_exists_file(&yarn_lock_path)? { | ||
| let version = if is_yarn_lockfile_v1(&yarn_lock_path) { | ||
| Str::from(">=1.0.0 <2.0.0") |
There was a problem hiding this comment.
Resolve Yarn v1 lockfiles to the latest 1.x release
When a project has only a Yarn v1 yarn.lock and the user's VP cache already contains an older Yarn 1.x install, returning this range flows into download_package_manager, whose range resolver checks find_cached_package_manager_version before the registry and returns that cached version. Because this detection source is LockfileOrConfig, build() then auto-pins the stale cached version into devEngines.packageManager, so a lockfile-only project can be stuck on an arbitrary old Yarn 1.x instead of the latest compatible Yarn v1 release.
Useful? React with 👍 / 👎.
| if is_exists_file(&yarn_lock_path)? { | ||
| let version = if is_yarn_lockfile_v1(&yarn_lock_path) { | ||
| Str::from(">=1.0.0 <2.0.0") |
There was a problem hiding this comment.
Honor Berry config before v1 lockfile detection
When a workspace has both .yarnrc.yml and an existing v1-format yarn.lock (for example right after configuring Yarn Berry before regenerating the lockfile), this branch classifies the project as Yarn v1 before the .yarnrc.yml check runs. The repo's detection docs identify .yarnrc.yml as a Yarn Berry (v2+) configuration signal, so this would install/pin Yarn 1 and ignore the project's Berry config instead of using the intended Yarn 2+ CLI.
Useful? React with 👍 / 👎.
I found
vp iis not working in my projects that use yarn v1 as its pkg manager.After digging into yarn v1 source code, I think we can distinguish from v1 or berry from lock file shape.
https://github.com/yarnpkg/yarn/blob/c2dda503f3759b5be5f0e24ecd9cf5c97a540147/src/lockfile/parse.js#L28
https://github.com/yarnpkg/yarn/blob/c2dda503f3759b5be5f0e24ecd9cf5c97a540147/src/lockfile/parse.js#L185-L194