CLI to discover configured npm registries write authToken to user config
npm install @rb-mwindh/setup-npm-auth
A CLI and GitHub Action to discover configured npm registries and write authentication tokens to the npm user config. Supports default, publish, and scoped registries. Designed for use in CI/CD pipelines and local development.
Install globally or use via npx:
``sh`
npx @rb-mwindh/setup-npm-auth --include default --include publish=PUBLISH_TOKEN --include @myscope=SCOPE_TOKEN
#### Options
- --include default
Include a registry. Repeatable. Grammar: , publish, or @scope[=ENV_VAR]. Defaults to NODE_AUTH_TOKEN if ENV_VAR is omitted.-L, --location
- --dry-run
Specify npm config location. Defaults to user-level config.
- -v, --verbose
Show what would be configured, but do not write anything.
-
Show detailed output.
#### Examples
`shSet auth for the default registry using NODE_AUTH_TOKEN
NODE_AUTH_TOKEN=foo npx @rb-mwindh/setup-npm-auth
$3
You can use this tool as a declarative GitHub Action in your workflows:
`yaml
- uses: rb-mwindh/setup-npm-auth@main
with:
verbose: 'true'
includes: |
default
publish=PUBLISH_TOKEN
@myscope=SCOPE_TOKEN
`#### Action Inputs
-
includes: Registries to include (e.g. default, publish, @scope=ENV)
- location: npm config location (user, global, project)
- dry-run: Show what would be done, but do not execute
- verbose: Show more outputDevelopment
$3
This action uses @vercel/ncc to bundle all runtime dependencies into a single file. The bundled output is committed to the repository in the
dist/ directory because GitHub Actions require all code and dependencies to be present in the repository.To build the action after making changes:
`bash
npm ci
npm run build
`The
dist/ directory is intentionally committed to version control, as this is required for JavaScript GitHub Actions to work on self-hosted runners without requiring npm install`.MIT © Markus Windhager