Skip to content
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

[Feature] Mirror the binaries from the Yarn website #2033

Closed
arcanis opened this issue Oct 23, 2020 · 9 comments
Closed

[Feature] Mirror the binaries from the Yarn website #2033

arcanis opened this issue Oct 23, 2020 · 9 comments
Labels
enhancement New feature or request

Comments

@arcanis
Copy link
Member

arcanis commented Oct 23, 2020

Describe the user story

Our binaries are built for every release and stored within the repository. As a result, the binary from any release can be accessed through the following url:

https://raw.githubusercontent.com/yarnpkg/berry/%40yarnpkg/cli/{}/packages/yarnpkg-cli/bin/yarn.js (replacing {} by the version number for the CLI one wish to obtain)

Then the yarn set version command downloads the files from this url. It works well enough, but it has a few downside:

Describe the solution you'd like

I'd like to mirror those URLs behind Cloudflare and expose them through yarnpkg.com (so that bin.yarnpkg.com/2.0.0/packages/yarnpkg-cli/bin/yarn.js would be a cached alias for the url aforementioned). @Daniel15 do you know if this is something we can do?

Describe the drawbacks of your solution

The old url will still exist, so there is no backward incompatibility.

@arcanis arcanis added the enhancement New feature or request label Oct 23, 2020
@arcanis
Copy link
Member Author

arcanis commented Oct 23, 2020

I've setup a Cloudflare worker that mirrors our repository with a 7-days TTL:
https://repo.yarnpkg.com/2.3.2/packages/yarnpkg-cli/bin/yarn.js

@Daniel15
Copy link
Member

Interesting, I didn't think of using Cloudflare workers, but glad to know that it works. Is that free to use?

@ylemkimon
Copy link
Contributor

Note to reliably serve in China, an ICP license from the Chinese government is required (Cloudflare, for instance). Another way would be to use CDN such as jsDelivr which has a multi-CDN network and the ICP license. jsDelivr seems to provide custom endpoints, too.

@arcanis
Copy link
Member Author

arcanis commented Oct 28, 2020

Is that free to use?

Yep, up to a threshold. What's interesting is that it seems to be composable with the caching layer, so it's unlikely we'd hit the threshold! Only thing missing is to implement /latest, which will require to handle the cache invalidation (and to figure out a way to retrieve the latest).

@v1nc3n4
Copy link

v1nc3n4 commented Jan 22, 2021

Hi all,
Apart from choosing the right CDN/gateway/proxy Yarn would rely on to download distributions, what if the end-user could tweak this setting and, for instance, use the distribution server of his choice? A problem with the way distributions are downloaded is that the process is not customizable (yarn set version <version> is a kind of black box). Am I mistaking?
Regards

@ZeroAurora
Copy link

ZeroAurora commented Feb 8, 2021

I'd recommend jsDelivr. (https://cdn.jsdelivr.net/gh/yarnpkg/berry@latest/packages/yarnpkg-cli/bin/yarn.js , "latest" can be any tag)
Besides, what should we do to replace the download URL?
(Please ignore my comment related to yarnUpgradePath (deleted).)

@luislezcair
Copy link

It will be great to have yarn2 on npm since as mentioned in #3001 many companies have their own internal indexes and also strict policies on what can be installed on production servers and installing from github (or other non-standard location) is nearly illegal

@arcanis
Copy link
Member Author

arcanis commented Jul 18, 2021

New versions will use the Yarn website as source for the binaries (specifically, repo.yarnpkg.com).

@arcanis arcanis closed this as completed Jul 18, 2021
@enyineer
Copy link

enyineer commented May 17, 2024

@arcanis I would second comments from @v1nc3n4 and @luislezcair

I have a need to mirror repo.yarnpkg.com to a corporate Mirror (in my case Nexus Repository) so that it can be installed. I haven't found any Config or Environment Variable to tell Yarn where to get it from. Is this hardcoded without any chance to configure? If so this would be a big reason to migrate away from Yarn.

For this to work

bundleRef = getRef(`https://repo.yarnpkg.com/{}/packages/yarnpkg-cli/bin/yarn.js`, await resolveTag(configuration, `stable`));
has to be configurable.

If it could be installed via npmjs would be even better as most Mirror-Repository Softwares have native support for such mirrors.

Proxies are not an option.

Thanks in advance.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

7 participants