All Projects → npm → libnpmpublish

npm / libnpmpublish

Licence: ISC License
programmatically publish and unpublish npm packages

Programming Languages

javascript
184084 projects - #8 most used programming language

Labels

Projects that are alternatives of or similar to libnpmpublish

config
Configuration management for https://github.com/npm/cli
Stars: ✭ 22 (-50%)
Mutual labels:  npm-cli
cacache
npm's content-addressable cache
Stars: ✭ 181 (+311.36%)
Mutual labels:  npm-cli
cmd-shim
The cmd-shim used in npm
Stars: ✭ 65 (+47.73%)
Mutual labels:  npm-cli
libnpmsearch
programmatic API for the shiny new npm search endpoint
Stars: ✭ 25 (-43.18%)
Mutual labels:  npm-cli
cross-post
Cross Post a blog to multiple websites
Stars: ✭ 66 (+50%)
Mutual labels:  npm-cli
git
a util for spawning git from npm CLI contexts
Stars: ✭ 48 (+9.09%)
Mutual labels:  npm-cli
fs-minipass
fs read and write streams based on minipass
Stars: ✭ 15 (-65.91%)
Mutual labels:  npm-cli
npm-registry-mock
mock the npm registry
Stars: ✭ 26 (-40.91%)
Mutual labels:  npm-cli
node-cli-boilerplate
🪓 Create node cli with this user friendly boilerplate
Stars: ✭ 17 (-61.36%)
Mutual labels:  npm-cli
npm-profile
Make changes to your npmjs.com profile via cli or library
Stars: ✭ 29 (-34.09%)
Mutual labels:  npm-cli
inflight
Add callbacks to requests in flight to avoid async duplication
Stars: ✭ 63 (+43.18%)
Mutual labels:  npm-cli
Cli
the package manager for JavaScript
Stars: ✭ 5,277 (+11893.18%)
Mutual labels:  npm-cli
Node Semver
The semver parser for node (the one npm uses)
Stars: ✭ 3,944 (+8863.64%)
Mutual labels:  npm-cli
run-script
Run a lifecycle script for a package (descendant of npm-lifecycle)
Stars: ✭ 29 (-34.09%)
Mutual labels:  npm-cli
lint
lint the npmcli way
Stars: ✭ 27 (-38.64%)
Mutual labels:  npm-cli
proggy
Progress bar updates at a distance
Stars: ✭ 12 (-72.73%)
Mutual labels:  npm-cli
pacote
npm fetcher
Stars: ✭ 179 (+306.82%)
Mutual labels:  npm-cli
parse-conflict-json
Parse a JSON string that has git merge conflicts, resolving if possible
Stars: ✭ 24 (-45.45%)
Mutual labels:  npm-cli

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
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].