-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Add custom headers to tarball fetcher #6756
Add custom headers to tarball fetcher #6756
Conversation
@@ -329,3 +350,16 @@ export class LocalTarballFetcher extends TarballFetcher { | |||
return this.fetchFromLocal(this.reference); | |||
} | |||
} | |||
|
|||
type UrlParts = { |
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.
This is copied from
yarn/src/registries/npm-registry.js
Lines 77 to 88 in b8a565e
type UrlParts = { | |
host: string, | |
path: string, | |
}; | |
function urlParts(requestUrl: string): UrlParts { | |
const normalizedUrl = normalizeUrl(requestUrl); | |
const parsed = url.parse(normalizedUrl); | |
const host = parsed.host || ''; | |
const path = parsed.path || ''; | |
return {host, path}; | |
} |
I would like to put it in a more central location. I ask the Yarn team where would be the most appropriate destination? 😄
Given that this affect the syntax of the |
@arcanis : Good point and I agree. This feature is not available on npm - I reviewed https://docs.npmjs.com/misc/config#config-settings and hopefully did not miss a similar supported feature. I'm currently retrieving the config values with yarn/src/fetchers/tarball-fetcher.js Lines 279 to 281 in ed76774
.npmrc . I'm not yet sure how to load from .yarnrc config file.
Any advice on how I could load config from |
I think you should be able to access the |
Thank you for the assistance, @arcanis ! I pushed a commit switching from npm to yarn config. Now
after running yarn config set "//custom.gitlab.host/:_header:PRIVATE-TOKEN" "REDACTED" and Once the above is all approved, I will add tests, push the changes, and update the Pull Request description to reflect these changes. Thanks again for reviewing! |
It looks like the Jest tests need a higher timeout:
They fail intermittently and without related code changes. |
Thanks! It'll be part of the next release 😃 |
Summary
My team would like to download tarballs attached to GitLab Releases.
The projects are authenticated, therefore we need to add
PRIVATE-TOKEN
header to the request for the tarball. See https://docs.gitlab.com/ee/api/README.html#personal-access-tokensI propose the following configuration addition:
~/.npmrc
:where:
//custom.gitlab.host/
is the host which matches the tarball request.:_header:<HEADER-NAME>
indicates a custom header should be added, withPRIVATE-TOKEN
being theHEADER-NAME
in this instance. Multiple custom headers could be added in this way.Then we can run:
And the request will be authenticated.
Once I have approval on the above format then I will update the
CHANGELOG.md
😃 .Test plan
Once I have approval on the above format then I will add tests 😃 .
Update 1:
Now
~/.yarnrc
looks like:after running
and
~/.npmrc
is not used. Working great! 🎉Update 2:
See #6756 (comment)
I created a release and uploaded a tarball generated from
yarn pack
to https://github.com/Glavin001/yarn/releases/tag/1.13.0-config-tarball-fetcher-headers-1You can install this custom Yarn with: