logo
0
0
Login

npm

This version is forked and modified from plugins/npm.

It implements npm publish, supporting both official repositories and private repositories.

Adjustments:

  • Removed registry check in package.json
  • Documentation adjusted to fit CNB usage scenarios

Input

  • username: string Username
  • password: string Password
  • token: string Authentication via token
  • email: string Email
  • registry: string Registry, default: https://registry.npmjs.org/
  • folder: string Directory to publish, default is current directory.
  • fail_on_version_conflict: boolean Exit with error when version exists
  • tag: string NPM publish tag --tag
  • access: string NPM scoped package access --access

Usage in Cloud Native Build

Publish to CNB's npm artifact repository

$: # Triggered on tag push tag_push: - docker: image: node:22-alpine stages: - name: update version # Modify version in package.json to current tag, but won't commit code script: npm version $CNB_BRANCH --no-git-tag-version - name: npm publish image: tencentcom/npm settings: username: $CNB_TOKEN_USER_NAME token: $CNB_TOKEN email: $CNB_COMMITTER_EMAIL registry: https://npm.cnb.cool/xxx/xxx/-/packages/ folder: ./ fail_on_version_conflict: true

Publish to official npm registry

When pushing to the official repository, you cannot use a password; you must authenticate with a token.

  1. Save the token in the secret repository in an npm-token.yml file, then import it using imports.
# npm-token.yml NPM_USER: your-username NPM_TOKEN: your-token NPM_EMAIL: your-email@email.com
main: push: - stages: - name: npm publish image: tencentcom/npm imports: https://cnb.cool/xxx/npm-token.yml settings: username: $NPM_USER token: $NPM_TOKEN email: $NPM_EMAIL folder: ./ fail_on_version_conflict: true

Usage with Docker

docker run --rm \ -e PLUGIN_USERNAME=xxx \ -e PLUGIN_TOKEN=xxx \ -e PLUGIN_EMAIL=xxx@xxx.com \ -v $(pwd):$(pwd) \ -w $(pwd) \ tencentcom/npm

About

npm

768.00 KiB
0 forks0 stars4 branches0 TagREADMEMIT license
Language
Go76.2%
Markdown20.3%
License2.3%
SVG1%
Others0.2%