{"id":15290341,"url":"https://github.com/npm/libnpmpublish","last_synced_at":"2025-10-07T03:33:02.473Z","repository":{"id":44914791,"uuid":"146668808","full_name":"npm/libnpmpublish","owner":"npm","description":"programmatically publish and unpublish npm packages","archived":true,"fork":false,"pushed_at":"2022-01-18T22:19:13.000Z","size":1237,"stargazers_count":46,"open_issues_count":0,"forks_count":10,"subscribers_count":11,"default_branch":"main","last_synced_at":"2024-10-01T16:07:08.285Z","etag":null,"topics":["npm-cli"],"latest_commit_sha":null,"homepage":"https://npmjs.com/package/libnpmpublish","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"isc","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/npm.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-08-29T23:11:10.000Z","updated_at":"2023-11-15T23:33:47.000Z","dependencies_parsed_at":"2022-09-05T11:52:01.865Z","dependency_job_id":null,"html_url":"https://github.com/npm/libnpmpublish","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npm%2Flibnpmpublish","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npm%2Flibnpmpublish/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npm%2Flibnpmpublish/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/npm%2Flibnpmpublish/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/npm","download_url":"https://codeload.github.com/npm/libnpmpublish/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235586097,"owners_count":19014028,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["npm-cli"],"created_at":"2024-09-30T16:07:15.757Z","updated_at":"2025-10-07T03:32:57.149Z","avatar_url":"https://github.com/npm.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# We've Moved! 🚚\nThe code for this repo is now a workspace in the npm CLI repo.\n\n[github.com/npm/cli](https://github.com/npm/cli)\n\nYou can find the workspace in /workspaces/libnpmpublish\n\nPlease file bugs and feature requests as issues on the CLI and tag the issue with \"ws:libnpmpublish\".\n\n[github.com/npm/cli/issues](https://github.com/npm/cli)\n\n# libnpmpublish\n\n[`libnpmpublish`](https://github.com/npm/libnpmpublish) is a Node.js\nlibrary for programmatically publishing and unpublishing npm packages. Give\nit a manifest as an object and a tarball as a Buffer, and it'll put them on\nthe registry for you.\n\n## Table of Contents\n\n* [Example](#example)\n* [Install](#install)\n* [API](#api)\n  * [publish/unpublish opts](#opts)\n  * [`publish()`](#publish)\n  * [`unpublish()`](#unpublish)\n\n## Example\n\n```js\nconst { publish, unpublish } = require('libnpmpublish')\n```\n\n## Install\n\n`$ npm install libnpmpublish`\n\n### API\n\n#### \u003ca name=\"opts\"\u003e\u003c/a\u003e `opts` for `libnpmpublish` commands\n\n`libnpmpublish` uses\n[`npm-registry-fetch`](https://npm.im/npm-registry-fetch).  Most options\nare passed through directly to that library, so please refer to [its own\n`opts` documentation](http://npm.im/npm-registry-fetch#fetch-options) for\noptions that can be passed in.\n\nA couple of options of note:\n\n* `opts.defaultTag` - registers the published package with the given tag,\n  defaults to `latest`.\n\n* `opts.access` - tells the registry whether this package should be\n  published as public or restricted. Only applies to scoped packages, which\n  default to restricted.\n\n* `opts.token` - can be passed in and will be used as the authentication\n  token for the registry. For other ways to pass in auth details, see the\n  n-r-f docs.\n\n#### \u003ca name=\"publish\"\u003e\u003c/a\u003e `\u003e libpub.publish(manifest, tarData, [opts]) -\u003e Promise`\n\nSends the package represented by the `manifest` and `tarData` to the\nconfigured registry.\n\n`manifest` should be the parsed `package.json` for the package being\npublished (which can also be the manifest pulled from a packument, a git\nrepo, tarball, etc.)\n\n`tarData` is a `Buffer` of the tarball being published.\n\nIf `opts.npmVersion` is passed in, it will be used as the `_npmVersion`\nfield in the outgoing packument.  You may put your own user-agent string in\nthere to identify your publishes.\n\nIf `opts.algorithms` is passed in, it should be an array of hashing\nalgorithms to generate `integrity` hashes for. The default is `['sha512']`,\nwhich means you end up with `dist.integrity = 'sha512-deadbeefbadc0ffee'`.\nAny algorithm supported by your current node version is allowed -- npm\nclients that do not support those algorithms will simply ignore the\nunsupported hashes.\n\n##### Example\n\n```js\n// note that pacote.manifest() and pacote.tarball() can also take\n// any spec that npm can install.  a folder shown here, since that's\n// far and away the most common use case.\nconst path = '/a/path/to/your/source/code'\nconst pacote = require('pacote') // see: http://npm.im/pacote\nconst manifest = await pacote.manifest(path)\nconst tarData = await pacote.tarball(path)\nawait libpub.publish(manifest, tarData, {\n  npmVersion: 'my-pub-script@1.0.2',\n  token: 'my-auth-token-here'\n}, opts)\n// Package has been published to the npm registry.\n```\n\n#### \u003ca name=\"unpublish\"\u003e\u003c/a\u003e `\u003e libpub.unpublish(spec, [opts]) -\u003e Promise`\n\nUnpublishes `spec` from the appropriate registry. The registry in question may\nhave its own limitations on unpublishing.\n\n`spec` should be either a string, or a valid\n[`npm-package-arg`](https://npm.im/npm-package-arg) parsed spec object. For\nlegacy compatibility reasons, only `tag` and `version` specs will work as\nexpected. `range` specs will fail silently in most cases.\n\n##### Example\n\n```js\nawait libpub.unpublish('lodash', { token: 'i-am-the-worst'})\n//\n// `lodash` has now been unpublished, along with all its versions\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnpm%2Flibnpmpublish","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnpm%2Flibnpmpublish","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnpm%2Flibnpmpublish/lists"}