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

Support private registries #96

Merged
merged 1 commit into from
Apr 13, 2023

Conversation

gabidobo
Copy link
Member

@gabidobo gabidobo commented Apr 7, 2023

This PR adds support for private registries:

  • configuration can be done via the NPM_CONFIG_REGISTRY env var or with config files
  • .npmrc config files are read from $HOME/.npmrc and from the project path
  • dependency on ini has been added to read the config files
  • env vars can be replaced in configuration values (like registry=${REGISTRY_VAR})
  • all registry-related code has been moved to the new registry.js file
  • the node-fetch http client has been added to handle all http requests more concisely

Closes #50

@gabidobo gabidobo linked an issue Apr 7, 2023 that may be closed by this pull request
@gabidobo gabidobo self-assigned this Apr 7, 2023
@gabidobo gabidobo marked this pull request as ready for review April 8, 2023 20:58
@andreimarinescu andreimarinescu merged commit b36cba0 into main Apr 13, 2023
@andreimarinescu andreimarinescu deleted the 50-support-customprivate-registries branch April 13, 2023 12:21
let fetch = () => {};

const replaceEnvVars = (str) =>
str.replace(/\${([^}]+)}/g, (match, variableName) => process.env[variableName] || '');

Choose a reason for hiding this comment

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

FYI, I am getting an error here when running sandworm audit:

❯ sandworm audit
Sandworm 🪱
Security and License Compliance Audit
⠋ Building dependency graph...
❌ Failed: str.replace is not a function
TypeError: str.replace is not a function
    at replaceEnvVars (/Users/david/.nvm/versions/node/v18.12.1/lib/node_modules/@sandworm/audit/src/registry.js:9:7)
    at /Users/david/.nvm/versions/node/v18.12.1/lib/node_modules/@sandworm/audit/src/registry.js:17:28
    at Array.forEach (<anonymous>)
    [...]

In my case, the error is happening because str is a boolean (true) rather than a string. (The key is "color").

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.

Support custom/private registries
3 participants