Giter Club home page Giter Club logo

libnpmpublish's Introduction

We've Moved! ๐Ÿšš

The code for this repo is now a workspace in the npm CLI repo.

github.com/npm/cli

You can find the workspace in /workspaces/libnpmpublish

Please file bugs and feature requests as issues on the CLI and tag the issue with "ws:libnpmpublish".

github.com/npm/cli/issues

libnpmpublish

libnpmpublish is a Node.js library for programmatically publishing and unpublishing npm packages. Give it a manifest as an object and a tarball as a Buffer, and it'll put them on the registry for you.

Table of Contents

Example

const { publish, unpublish } = require('libnpmpublish')

Install

$ npm install libnpmpublish

API

opts for libnpmpublish commands

libnpmpublish uses npm-registry-fetch. Most options are passed through directly to that library, so please refer to its own opts documentation for options that can be passed in.

A couple of options of note:

  • opts.defaultTag - registers the published package with the given tag, defaults to latest.

  • opts.access - tells the registry whether this package should be published as public or restricted. Only applies to scoped packages, which default to restricted.

  • opts.token - can be passed in and will be used as the authentication token for the registry. For other ways to pass in auth details, see the n-r-f docs.

> libpub.publish(manifest, tarData, [opts]) -> Promise

Sends the package represented by the manifest and tarData to the configured registry.

manifest should be the parsed package.json for the package being published (which can also be the manifest pulled from a packument, a git repo, tarball, etc.)

tarData is a Buffer of the tarball being published.

If opts.npmVersion is passed in, it will be used as the _npmVersion field in the outgoing packument. You may put your own user-agent string in there to identify your publishes.

If opts.algorithms is passed in, it should be an array of hashing algorithms to generate integrity hashes for. The default is ['sha512'], which means you end up with dist.integrity = 'sha512-deadbeefbadc0ffee'. Any algorithm supported by your current node version is allowed -- npm clients that do not support those algorithms will simply ignore the unsupported hashes.

Example
// note that pacote.manifest() and pacote.tarball() can also take
// any spec that npm can install.  a folder shown here, since that's
// far and away the most common use case.
const path = '/a/path/to/your/source/code'
const pacote = require('pacote') // see: http://npm.im/pacote
const manifest = await pacote.manifest(path)
const tarData = await pacote.tarball(path)
await libpub.publish(manifest, tarData, {
  npmVersion: '[email protected]',
  token: 'my-auth-token-here'
}, opts)
// Package has been published to the npm registry.

> libpub.unpublish(spec, [opts]) -> Promise

Unpublishes spec from the appropriate registry. The registry in question may have its own limitations on unpublishing.

spec should be either a string, or a valid npm-package-arg parsed spec object. For legacy compatibility reasons, only tag and version specs will work as expected. range specs will fail silently in most cases.

Example
await libpub.unpublish('lodash', { token: 'i-am-the-worst'})
//
// `lodash` has now been unpublished, along with all its versions

libnpmpublish's People

Contributors

claudiahdz avatar fritzy avatar geopet avatar isaacs avatar nlf avatar pine avatar ruyadorno avatar sreeramjayan avatar thisismissem avatar wraithgar avatar zkat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

libnpmpublish's Issues

ChainAlert: npm package release (5.0.0) has no matching tag in this repo

Dear libnpmpublish maintainers,
Thank you for your contribution to the open-source community.

This issue was automatically created to inform you a new version (5.0.0) of libnpmpublish was published without a matching tag in this repo.

Our service monitors the open-source ecosystem and informs popular packages' owners in case of potentially harmful activity.
If you find this behavior legitimate, kindly close and ignore this issue. Read more

badge

ChainAlert: new npm maintainer has published version 5.0.0 of package libnpmpublish

Dear libnpmpublish maintainers,
Thank you for your contribution to the open-source community.

This issue was automatically created to inform you a new npm maintainer has published version 5.0.0 of libnpmpublish.

New Maintainers:

Our service monitors the open-source ecosystem and informs popular packages' owners in case of potentially harmful activity.
If you find this behavior legitimate, kindly close and ignore this issue. Read more

badge

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.