Skip to content

Conversation

Eynorey
Copy link

@Eynorey Eynorey commented Sep 22, 2025

Related to #177.

This PR adds support for custom NPM registry configurations, allowing the action to install PNPM from there.

With this, the action reads a potential custom registry configuration from .npmrc if it exists, and uses the result by running the install script with a corresponding --registry <custom> flag.

# My custom registry
registry = https://my-registry.my-company.com/

Here are some scenarios I tested using this script:

Test Results
🧪 Testing readNpmrcRegistry function

📋 1. No .npmrc file
──────────────────────────────────────────────────
✅ PASS: Expected 'undefined', got 'undefined'

📋 2. Empty .npmrc file
──────────────────────────────────────────────────
[INFO] Reading .npmrc file from: /tmp/npmrc-test-gZgnMl/.npmrc
[DEBUG] No valid registry configuration found in .npmrc
✅ PASS: Expected 'undefined', got 'undefined'

📋 3. .npmrc without registry entry
──────────────────────────────────────────────────
[INFO] Reading .npmrc file from: /tmp/npmrc-test-gZgnMl/.npmrc
[DEBUG] No valid registry configuration found in .npmrc
✅ PASS: Expected 'undefined', got 'undefined'

📋 4. .npmrc with invalid registry entry
──────────────────────────────────────────────────
[INFO] Reading .npmrc file from: /tmp/npmrc-test-gZgnMl/.npmrc
[WARNING] Invalid registry URL format in .npmrc (must be http/https): invalid-url-without-protocol
[DEBUG] No valid registry configuration found in .npmrc
✅ PASS: Expected 'undefined', got 'undefined'

📋 5. .npmrc with one invalid and one valid registry entry
──────────────────────────────────────────────────
[INFO] Reading .npmrc file from: /tmp/npmrc-test-gZgnMl/.npmrc
[WARNING] Invalid registry URL format in .npmrc (must be http/https): invalid-url
[INFO] Using custom registry from .npmrc: https://npm.company.com/
✅ PASS: Expected 'https://npm.company.com/', got 'https://npm.company.com/'

📋 6. .npmrc with one valid and one scoped entry (scoped ignored)
──────────────────────────────────────────────────
[INFO] Reading .npmrc file from: /tmp/npmrc-test-gZgnMl/.npmrc
[INFO] Using custom registry from .npmrc: https://registry.npmjs.org/
✅ PASS: Expected 'https://registry.npmjs.org/', got 'https://registry.npmjs.org/'

📋 7. .npmrc with spaces around equals sign
──────────────────────────────────────────────────
[INFO] Reading .npmrc file from: /tmp/npmrc-test-gZgnMl/.npmrc
[INFO] Using custom registry from .npmrc: https://npm.example.com/
✅ PASS: Expected 'https://npm.example.com/', got 'https://npm.example.com/'

📋 8. .npmrc with trailing slash (should be preserved)
──────────────────────────────────────────────────
[INFO] Reading .npmrc file from: /tmp/npmrc-test-gZgnMl/.npmrc
[INFO] Using custom registry from .npmrc: https://npm.example.com/path/
✅ PASS: Expected 'https://npm.example.com/path/', got 'https://npm.example.com/path/'

📋 9. .npmrc with http (not just https)
──────────────────────────────────────────────────
[INFO] Reading .npmrc file from: /tmp/npmrc-test-gZgnMl/.npmrc
[INFO] Using custom registry from .npmrc: http://internal.npm.company.com/
✅ PASS: Expected 'http://internal.npm.company.com/', got 'http://internal.npm.company.com/'

📋 10. .npmrc with comments using semicolon
──────────────────────────────────────────────────
[INFO] Reading .npmrc file from: /tmp/npmrc-test-gZgnMl/.npmrc
[INFO] Using custom registry from .npmrc: https://npm.example.com/
✅ PASS: Expected 'https://npm.example.com/', got 'https://npm.example.com/'

Note

I was also considering an action parameter, but this feels more natural - if you are already using a custom registry via .npmrc, then you'll likely want your package manager to be fetched form there as well.

But I could also see a parameter being helpful for some setups, perhaps even acting as an override to the .npmrc registry configuration. Maybe as a follow-up?

Any feedback is greatly appreciated!

Copy link

@benquarmby benquarmby left a comment

Choose a reason for hiding this comment

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

❤️ Love this.

My opinion doesn't matter a great deal, but I'm going to give it anyway 😜

@Eynorey Eynorey force-pushed the support-custom-registry branch from e56432f to 3ea717c Compare September 22, 2025 21:16
read and respect registry configuration from .npmrc if it exists
@Eynorey
Copy link
Author

Eynorey commented Oct 6, 2025

@zkochan/@KSXGitHub would you mind taking a look when you get a chance, 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