Repository navigation
Preview build setup sometimes results in installation failures #1075
Description
Activity
I was unable to find any way to configure Yarn/npm or GitHub to support looking at this custom registry first, then falling back to npm.
We may want to investigate alternatives to GitHub Packages. Or perhaps we could write a script to sync all of our npm packages to the GitHub registry.
- added a commit that references this issue
on Jun 15, 2023 - added a commit that references this issue
on Jun 22, 2023 can we publish previews to npm instead?
solves:
- does not require a token to view previews
- doesnt require any yarnrc configuration to use them
tradeoffs:
- gh action will require an npm token that can publish releases. We can resolve security risk by pushing them to a different org (@metamask-previews for example)
- ??
As long as we can resolve to the new package name, that works. I'm not sure if that's possible with Yarn v3 for transitive dependencies.
e.g. if we have a new
@metamask/eth-sig-util@5.0.1release, how do we point all copies of@metamask/eth-sig-util@5.0.0in our dependency tree at@metamask-previews/eth-sig-util@something?Maybe Yarn resolutions can do this? Not sure.
I think that Yarn resolutions can accomplish this as well, but we would definitely need to test this out somehow. I can try experimenting with this.
Hey team! Please add your planning poker estimate with Zenhub @cryptodev-2s @Gudahtt @mcmire @mikesposito
I tried to test the above idea by using Verdaccio to publish a
@metamask-previewspackage locally. However, I could not get Verdaccio to work with Yarn v3. After pointing Yarn to usinghttp://localhost:4873instead of the Yarn registry, I kept getting anECONNREFUSEDerror. I'll have to try something else, perhaps using the GitHub registry instead.I've tested this using the GitHub registry instead and confirmed that the
resolutionsfield works to get Yarn to "see" one package under another name in the dependency tree.I first added the following to
.yarnrc.ymlin this repo:npmRegistries: "https://npm.pkg.github.com": npmAlwaysAuth: true npmAuthToken: "${GITHUB_NPM_TOKEN-}" npmScopes: mcmire: npmRegistryServer: "https://npm.pkg.github.com"I then opened the
package.jsonforcontroller-utilsand:- changed its name from
@metamask/controller-utilsto@mcmire/controller-utilsinpackage.json - changed the version by appending
-preview.aaato the end - updated
publishConfig.registryto "https://npm.pkg.github.com"
I then found every instance of
@metamask/controller-utilsinpackage.jsonacross the whole monorepo and replaced it with@mcmire/controller-utils, then ran:yarn installI then ran:
GITHUB_NPM_TOKEN="<token>" yarn workspace @mcmire/controller-utils npm publish --tag previewOver in the extension I then added the same section to
.yarnrc.ymlas above. When I added this to theresolutionsfield:"@metamask/controller-utils": "npm:@mcmire/controller-utils@preview"and ran:
GITHUB_NPM_TOKEN="<token>" yarn installand then
yarn why @metamask/controller-utilsI saw that every instance of
controller-utilsin the dependency tree was replaced:├─ @metamask/address-book-controller@npm:3.1.0 │ └─ @mcmire/controller-utils@npm:4.3.1-preview.aaa::__archiveUrl=https%3A%2F%2Fnpm.pkg.github.com%2Fdownload%2F%40mcmire%2Fcontroller-utils%2F4.3.1-preview.aaa%2F5d1425f907a37d76fc29c60e898e4e859fdc0f5c (via npm:@mcmire/controller-utils@latest) │ ├─ @metamask/assets-controllers@npm:9.2.0 │ └─ @mcmire/controller-utils@npm:4.3.1-preview.aaa::__archiveUrl=https%3A%2F%2Fnpm.pkg.github.com%2Fdownload%2F%40mcmire%2Fcontroller-utils%2F4.3.1-preview.aaa%2F5d1425f907a37d76fc29c60e898e4e859fdc0f5c (via npm:@mcmire/controller-utils@latest) │ ├─ @metamask/assets-controllers@npm:9.2.0 [15918] │ └─ @mcmire/controller-utils@npm:4.3.1-preview.aaa::__archiveUrl=https%3A%2F%2Fnpm.pkg.github.com%2Fdownload%2F%40mcmire%2Fcontroller-utils%2F4.3.1-preview.aaa%2F5d1425f907a37d76fc29c60e898e4e859fdc0f5c (via npm:@mcmire/controller-utils@latest) │ ├─ @metamask/base-controller@npm:2.0.0 │ └─ @mcmire/controller-utils@npm:4.3.1-preview.aaa::__archiveUrl=https%3A%2F%2Fnpm.pkg.github.com%2Fdownload%2F%40mcmire%2Fcontroller-utils%2F4.3.1-preview.aaa%2F5d1425f907a37d76fc29c60e898e4e859fdc0f5c (via npm:@mcmire/controller-utils@latest ...- changed its name from
It seems that the GitHub registry we have setup for the preview builds isn't mirroring packages from npm.
As a consequence, you may see installation failures non-preview
@metamaskpackages when using an.npmrcfile setup to point at the GitHub registry. I've found that I can get past the error by ensuring the non-preview packages are installed locally before putting the.npmrcfile in-place. This is a viable workaround but it requires frequently adding and removing this file, which is rather inconvenient.