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

Add npm private packages support #435

Merged
merged 3 commits into from
Oct 21, 2022
Merged

Add npm private packages support #435

merged 3 commits into from
Oct 21, 2022

Conversation

Justinidlerz
Copy link
Contributor

@Justinidlerz Justinidlerz commented Oct 20, 2022

Background

For the business case, I want to self-hosting this server and serve with some private packages hosted on the npm-registry

Changes

  • Add the npm-token flag to provide NPM private token
  • Add the .npmrc file in the temporary yarn installing directory to provide the _authToken
  • Remove the --no-default-rc flag of the yarn installing command to support reading .npmrc

if !fileExists(rcFilePath) {
err = ioutil.WriteFile(
rcFilePath,
[]byte("_authToken=${ESM_NPM_TOKEN}"),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

does the npmrc supports ${ESM_NPM_TOKEN} expression?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, the .npmrc is supported, Is designed for private packages in CI/CD.
But .yarnrc is not, and but .yarnrc.yml is supported 🤣 Yarn is so confused.

Actually, I tried to use other ways to implement it, such as:

  • Environment variables begin with npm_config_, but yarn will lower case all suffix, so the _authToken to be transformed to _authtoken, the _auth_token to be transformed to _auth-token
  • Use --use-yarnrc <path> for providing a specific .yarnrc file, but it was not supported to decode the environment variable expression

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for the explain! i didn't known this before

@ije
Copy link
Member

ije commented Oct 20, 2022

nice! 👍

Copy link
Member

@ije ije left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! thanks 👍

@ije ije merged commit 15f1bcf into esm-dev:main Oct 21, 2022
@ije
Copy link
Member

ije commented Oct 21, 2022

pls ignore the testing failed, it's caused by types checking, i will fix then. thanks

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

Successfully merging this pull request may close these issues.

2 participants