Coder Social home page Coder Social logo

npm's Introduction

@semantic-release/npm

Set of semantic-release plugins for publishing to a npm registry.

Travis Codecov Greenkeeper badge

npm latest version npm next version

verifyConditions

Verify the presence of the NPM_TOKEN environment variable, create or update the .npmrc file with the token and verify the token is valid.

prepare

Update the package.json version and create the npm package tarball.

publish

Publish to the npm registry.

Configuration

Npm registry authentication

The npm authentication configuration is required and can be set via environment variables.

Both the token and the legacy (username, password and email) authentication are supported. It is recommended to use the token authentication. The legacy authentication is supported as the alternative npm registries Artifactory and npm-registry-couchapp only supports that form of authentication at this point.

Note: Only the auth-only level of npm two-factor authentication is supported, semantic-release will not work with the default auth-and-writes level.

Environment variables

Variable Description
NPM_TOKEN Npm token created via npm token create
NPM_USERNAME Npm username created via npm adduser or on npmjs.com
NPM_PASSWORD Password of the npm user.
NPM_EMAIL Email address associated with the npm user

Use either NPM_TOKEN for token authentication or NPM_USERNAME, NPM_PASSWORD and NPM_EMAIL for legacy authentication

Options

Options Description Default
npmPublish Whether to publish the npm package to the registry. If false the package.json version will still be updated. true
pkgRoot Directory path to publish. .
tarballDir Directory path in which to write the the package tarball. If false the tarball is not be kept on the file system. false

Note: The pkgRoot directory must contains a package.json. The version will be updated only in the package.json and npm-shrinkwrap.json within the pkgRoot directory.

Npm configuration

The plugins are based on npm and will use the configuration from .npmrc. See npm config for the option list.

The registry and dist-tag can be configured in the package.json and will take precedence over the configuration in .npmrc:

{
  "publishConfig": {
    "registry": "https://registry.npmjs.org/",
    "tag": "latest"
  }
}

Usage

The plugins are used by default by semantic-release so no specific configuration is requiered to use them.

Each individual plugin can be disabled, replaced or used with other plugins in the package.json:

{
  "release": {
    "verifyConditions": ["@semantic-release/npm", "verify-other-condition"],
    "publish": ["@semantic-release/npm", "custom-publish"]
  }
}

The npmPublish and tarballDir option can be used to skip the publishing to the npm registry and instead, release the package tarball with another plugin. For example with the github plugin:

{
  "release": {
    "verifyConditions": ["@semantic-release/npm", "@semantic-release/git", "@semantic-release/github"],
    "publish": [
      {
        "path": "@semantic-release/npm",
        "npmPublish": false,
        "tarballDir": "dist"
      },
      {
        "path": "@semantic-release/github",
        "assets": "dist/*.tgz"
      },
    ]
  }
}

When publishing from a sub-directory with the pkgRoot option, the package.json and npm-shrinkwrap.json updated with the new version can be moved to another directory with a postpublish npm script. For example with the git plugin:

{
  "release": {
    "verifyConditions": ["@semantic-release/npm", "@semantic-release/git"],
    "publish": [
      {
        "path": "@semantic-release/npm",
        "pkgRoot": "dist"
      },
      {
        "path": "@semantic-release/git",
        "assets": ["package.json", "npm-shrinkwrap.json"]
      },
    ]
  },
  "scripts": {
    "postpublish": "cp -r dist/package.json . && cp -r dist/npm-shrinkwrap.json ."
  }
}

npm's People

Contributors

drapegnik avatar greenkeeper[bot] avatar pvdlg avatar sapegin avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.