-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
chore: Add Yarn plugin for using preview builds #25086
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
c9dc800 to
ad045c2
Compare
Some MetaMask repos (e.g. `core`) allow upcoming package changes to be
tested in Extension and/or Mobile prior to release by publishing
"preview builds".
However, using a preview build can be complicated, as care must be taken
to accurately simulate what the dependency tree of a project will look
like when a new production version is released.
To make this process easier, this commit adds a Yarn plugin. The plugin
works like this:
1. First, you must tell the plugin which preview builds you want to use
for which dependencies. You do this by adding an entry to a
`previewBuilds` section in `package.json`. For instance, to specify
that version `29.0.0-preview-3ec2a74` should be used to test
non-breaking changes to `@metamask/network-controller`, you would
add:
"previewBuilds": {
"@metamask/network-controller": {
"type": "non-breaking",
"previewVersion": "29.0.0-preview-3ec2a74"
}
}
Similarly, you could set `type` to "breaking" to test breaking
changes.
By default the plugin will assume the NPM scope of the preview build
to be `@metamask-previews`, but you can change this with
`previewScope`:
"previewBuilds": {
"@metamask/network-controller": {
"type": "non-breaking",
"previewScope": "my-custom-scope"
"previewVersion": "29.0.0-preview-3ec2a74",
}
}
2. Next, run `yarn install`. The plugin will read the `previewBuilds`
section to determine how the dependencies you've specified should be
resolved. If the `type` of an entry is "non-breaking", all version
ranges of that dependency in the dependency tree that are
major-compatible with the corresponding entry in `dependencies` will
resolve to the preview build. If the `type` is "breaking", then only
the version range of the corresponding entry in `dependencies` will
resolve to the preview build. Finally, if a dependency is patched,
the preview build will be patched in the same way.
ad045c2 to
d1c3830
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Co-authored-by: cryptodev-2s <[email protected]>
cryptodev-2s
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!
🔍 Smart E2E Test Selection
click to see 🤖 AI reasoning detailsThe changes in this PR are purely related to Yarn dependency management infrastructure:
Key observations:
Since these changes don't affect any runtime behavior of the application and the plugin won't be active without additional configuration, no E2E tests are needed to validate this PR. |
|
Gudahtt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Seems to work great, I just tested it out as well



Description
Some MetaMask repos (e.g.
core) allow upcoming package changes to be tested in Extension and/or Mobile prior to release by publishing "preview builds".However, using a preview build can be complicated, as care must be taken to accurately simulate what the dependency tree of a project will look like when a new production version is released.
To make this process easier, this commit adds a Yarn plugin. The plugin works like this:
First, you must tell the plugin which preview builds you want to use for which dependencies. You do this by adding an entry to a
previewBuildssection inpackage.json. For instance, to specify that version29.0.0-preview-3ec2a74should be used to test non-breaking changes to@metamask/network-controller, you would add:Similarly, you could set
typeto "breaking" to test breaking changes.By default the plugin will assume the NPM scope of the preview build to be
metamask-previews, but you can change this withpreviewScope:Next, run
yarn install. The plugin will read thepreviewBuildssection to determine how the dependencies you've specified should be resolved. If thetypeof an entry is "non-breaking", all version ranges of that dependency in the dependency tree that are major-compatible with the corresponding entry independencieswill resolve to the preview build. If thetypeis "breaking", then only the version range of the corresponding entry independencieswill resolve to the preview build. Finally, if a dependency is patched, the preview build will be patched in the same way.Changelog
CHANGELOG entry: null
Related issues
https://consensyssoftware.atlassian.net/browse/WPC-199
Manual testing steps
package.json:yarn install. You should see a message at the end of the installation steps:yarn why @metamask-previews/network-controller. You should see only one entry:@metamask/network-controllerwas updated to use the preview build.previewBuildsinpackage.jsonto read:yarn install. You should see a message at the end of the installation steps:yarn why @metamask-previews/network-controller. You should see a bunch of entries:@metamask/network-controllermatching^29.0.0were updated to use the preview build.previewBuildsand re-runyarn install.yarn patch @metamask/network-controller@npm:29.0.0. Open the resulting patch directory and make a modification to any file. Runyarn patch-commit -s <directory>to generate the patch and updatepackage.json, then runyarn installto apply the patch.package.json:yarn install. You should see a message at the end of the installation steps:yarn why @metamask/network-controller. You should see a bunch of entries:Screenshots/Recordings
(N/A)
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Introduces a Yarn v4 plugin to map
@metamask/*dependencies to preview packages (e.g.,@metamask-previews/*) based on apreviewBuildsconfig inpackage.json.@yarnpkg/plugin-preview-builds.cjsimplementsvalidateProject,reduceDependency, andafterAllInstalledhooks; supportstype(breakingvsnon-breaking), optionalpreviewScope, preservespatch:descriptors, and logs mapped resolutions.yarnrc.ymlto register the plugin and preapprove@metamask/*,@metamask-previews/*,@lavamoat/*, and@consensys/*for age-gate bypass@yarnpkg/coreto.depcheckrc.ymlignores for plugin usageWritten by Cursor Bugbot for commit c400892. This will update automatically on new commits. Configure here.