{"id":13527576,"url":"https://github.com/zkat/pacote","last_synced_at":"2025-04-01T09:31:49.710Z","repository":{"id":65990579,"uuid":"75573349","full_name":"zkat/pacote","owner":"zkat","description":"programmatic npm package and metadata downloader (moved!)","archived":true,"fork":false,"pushed_at":"2019-07-02T22:12:39.000Z","size":1732,"stargazers_count":280,"open_issues_count":30,"forks_count":62,"subscribers_count":9,"default_branch":"latest","last_synced_at":"2024-08-02T06:24:36.464Z","etag":null,"topics":["npm","package-management"],"latest_commit_sha":null,"homepage":"https://github.com/npm/pacote","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zkat.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null},"funding":{"github":["zkat"]}},"created_at":"2016-12-05T00:13:11.000Z","updated_at":"2024-06-01T17:32:18.000Z","dependencies_parsed_at":"2023-06-06T02:15:30.129Z","dependency_job_id":null,"html_url":"https://github.com/zkat/pacote","commit_stats":null,"previous_names":[],"tags_count":109,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zkat%2Fpacote","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zkat%2Fpacote/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zkat%2Fpacote/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zkat%2Fpacote/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zkat","download_url":"https://codeload.github.com/zkat/pacote/tar.gz/refs/heads/latest","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222715679,"owners_count":17027699,"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","package-management"],"created_at":"2024-08-01T06:01:52.517Z","updated_at":"2024-11-02T12:31:52.586Z","avatar_url":"https://github.com/zkat.png","language":"JavaScript","readme":"# pacote [![npm version](https://img.shields.io/npm/v/pacote.svg)](https://npm.im/pacote) [![license](https://img.shields.io/npm/l/pacote.svg)](https://npm.im/pacote) [![Travis](https://img.shields.io/travis/zkat/pacote.svg)](https://travis-ci.org/zkat/pacote) [![AppVeyor](https://ci.appveyor.com/api/projects/status/github/zkat/pacote?svg=true)](https://ci.appveyor.com/project/zkat/pacote) [![Coverage Status](https://coveralls.io/repos/github/zkat/pacote/badge.svg?branch=latest)](https://coveralls.io/github/zkat/pacote?branch=latest)\n\n## NOTE: This repo has moved to https://github.com/npm/pacote and only exists for archival purposes.\n\n[`pacote`](https://github.com/zkat/pacote) is a Node.js library for downloading\n[npm](https://npmjs.org)-compatible packages. It supports all package specifier\nsyntax that `npm install` and its ilk support. It transparently caches anything\nneeded to reduce excess operations, using [`cacache`](https://npm.im/cacache).\n\n## Install\n\n`$ npm install --save pacote`\n\n## Table of Contents\n\n* [Example](#example)\n* [Features](#features)\n* [Contributing](#contributing)\n* [API](#api)\n  * [`manifest`](#manifest)\n  * [`packument`](#packument)\n  * [`extract`](#extract)\n  * [`tarball`](#tarball)\n  * [`tarball.stream`](#tarball-stream)\n  * [`tarball.toFile`](#tarball-to-file)\n  * ~~[`prefetch`](#prefetch)~~ (deprecated)\n  * [`clearMemoized`](#clearMemoized)\n  * [`options`](#options)\n\n### Example\n\n```javascript\nconst pacote = require('pacote')\n\npacote.manifest('pacote@^1').then(pkg =\u003e {\n  console.log('package manifest for registry pkg:', pkg)\n  // { \"name\": \"pacote\", \"version\": \"1.0.0\", ... }\n})\n\npacote.extract('http://hi.com/pkg.tgz', './here').then(() =\u003e {\n  console.log('remote tarball contents extracted to ./here')\n})\n```\n\n### Features\n\n* Handles all package types [npm](https://npm.im/npm) does\n* [high-performance, reliable, verified local cache](https://npm.im/cacache)\n* offline mode\n* authentication support (private git, private npm registries, etc)\n* github, gitlab, and bitbucket-aware\n* semver range support for git dependencies\n\n### Contributing\n\nThe pacote team enthusiastically welcomes contributions and project participation! There's a bunch of things you can do if you want to contribute! The [Contributor Guide](CONTRIBUTING.md) has all the information you need for everything from reporting bugs to contributing entire new features. Please don't hesitate to jump in if you'd like to, or even ask us questions if something isn't clear.\n\n### API\n\n#### \u003ca name=\"manifest\"\u003e\u003c/a\u003e `\u003e pacote.manifest(spec, [opts])`\n\nFetches the *manifest* for a package. Manifest objects are similar and based\non the `package.json` for that package, but with pre-processed and limited\nfields. The object has the following shape:\n\n```javascript\n{\n  \"name\": PkgName,\n  \"version\": SemverString,\n  \"dependencies\": { PkgName: SemverString },\n  \"optionalDependencies\": { PkgName: SemverString },\n  \"devDependencies\": { PkgName: SemverString },\n  \"peerDependencies\": { PkgName: SemverString },\n  \"bundleDependencies\": false || [PkgName],\n  \"bin\": { BinName: Path },\n  \"_resolved\": TarballSource, // different for each package type\n  \"_integrity\": SubresourceIntegrityHash,\n  \"_shrinkwrap\": null || ShrinkwrapJsonObj\n}\n```\n\nNote that depending on the spec type, some additional fields might be present.\nFor example, packages from `registry.npmjs.org` have additional metadata\nappended by the registry.\n\n##### Example\n\n```javascript\npacote.manifest('pacote@1.0.0').then(pkgJson =\u003e {\n  // fetched `package.json` data from the registry\n})\n```\n\n#### \u003ca name=\"packument\"\u003e\u003c/a\u003e `\u003e pacote.packument(spec, [opts])`\n\nFetches the *packument* for a package. Packument objects are general metadata\nabout a project corresponding to registry metadata, and include version and\n`dist-tag` information about a package's available versions, rather than a\nspecific version. It may include additional metadata not usually available\nthrough the individual package metadata objects.\n\nIt generally looks something like this:\n\n```javascript\n{\n  \"name\": PkgName,\n  \"dist-tags\": {\n    'latest': VersionString,\n    [TagName]: VersionString,\n    ...\n  },\n  \"versions\": {\n    [VersionString]: Manifest,\n    ...\n  }\n}\n```\n\nNote that depending on the spec type, some additional fields might be present.\nFor example, packages from `registry.npmjs.org` have additional metadata\nappended by the registry.\n\n##### Example\n\n```javascript\npacote.packument('pacote').then(pkgJson =\u003e {\n  // fetched package versions metadata from the registry\n})\n```\n\n#### \u003ca name=\"extract\"\u003e\u003c/a\u003e `\u003e pacote.extract(spec, destination, [opts])`\n\nExtracts package data identified by `\u003cspec\u003e` into a directory named\n`\u003cdestination\u003e`, which will be created if it does not already exist.\n\nIf `opts.digest` is provided and the data it identifies is present in the cache,\n`extract` will bypass most of its operations and go straight to extracting the\ntarball.\n\n##### Example\n\n```javascript\npacote.extract('pacote@1.0.0', './woot', {\n  digest: 'deadbeef'\n}).then(() =\u003e {\n  // Succeeds as long as `pacote@1.0.0` still exists somewhere. Network and\n  // other operations are bypassed entirely if `digest` is present in the cache.\n})\n```\n\n#### \u003ca name=\"tarball\"\u003e\u003c/a\u003e `\u003e pacote.tarball(spec, [opts])`\n\nFetches package data identified by `\u003cspec\u003e` and returns the data as a buffer.\n\nThis API has two variants:\n\n* `pacote.tarball.stream(spec, [opts])` - Same as `pacote.tarball`, except it returns a stream instead of a Promise.\n* `pacote.tarball.toFile(spec, dest, [opts])` - Instead of returning data directly, data will be written directly to `dest`, and create any required directories along the way.\n\n##### Example\n\n```javascript\npacote.tarball('pacote@1.0.0', { cache: './my-cache' }).then(data =\u003e {\n  // data is the tarball data for pacote@1.0.0\n})\n```\n\n#### \u003ca name=\"tarball-stream\"\u003e\u003c/a\u003e `\u003e pacote.tarball.stream(spec, [opts])`\n\nSame as `pacote.tarball`, except it returns a stream instead of a Promise.\n\n##### Example\n\n```javascript\npacote.tarball.stream('pacote@1.0.0')\n.pipe(fs.createWriteStream('./pacote-1.0.0.tgz'))\n```\n\n#### \u003ca name=\"tarball-to-file\"\u003e\u003c/a\u003e `\u003e pacote.tarball.toFile(spec, dest, [opts])`\n\nLike `pacote.tarball`, but instead of returning data directly, data will be\nwritten directly to `dest`, and create any required directories along the way.\n\n##### Example\n\n```javascript\npacote.tarball.toFile('pacote@1.0.0', './pacote-1.0.0.tgz')\n.then(() =\u003e /* pacote tarball written directly to ./pacote-1.0.0.tgz */)\n```\n\n#### \u003ca name=\"prefetch\"\u003e\u003c/a\u003e `\u003e pacote.prefetch(spec, [opts])`\n\n##### THIS API IS DEPRECATED. USE `pacote.tarball()` INSTEAD\n\nFetches package data identified by `\u003cspec\u003e`, usually for the purpose of warming\nup the local package cache (with `opts.cache`). It does not return anything.\n\n##### Example\n\n```javascript\npacote.prefetch('pacote@1.0.0', { cache: './my-cache' }).then(() =\u003e {\n  // ./my-cache now has both the manifest and tarball for `pacote@1.0.0`.\n})\n```\n\n#### \u003ca name=\"clearMemoized\"\u003e\u003c/a\u003e `\u003e pacote.clearMemoized()`\n\nThis utility function can be used to force pacote to release its references\nto any memoized data in its various internal caches. It might help free\nsome memory.\n\n```javascript\npacote.manifest(...).then(() =\u003e pacote.clearMemoized)\n\n```\n\n#### \u003ca name=\"options\"\u003e\u003c/a\u003e `\u003e options`\n\n`pacote` accepts [the options for\n`npm-registry-fetch`](https://npm.im/npm-registry-fetch#fetch-options) as-is,\nwith a couple of additional `pacote-specific` ones:\n\n##### \u003ca name=\"dirPacker\"\u003e\u003c/a\u003e `opts.dirPacker`\n\n* Type: Function\n* Default: Uses [`npm-packlist`](https://npm.im/npm-packlist) and [`tar`](https://npm.im/tar) to make a tarball.\n\nExpects a function that takes a single argument, `dir`, and returns a\n`ReadableStream` that outputs packaged tarball data. Used when creating tarballs\nfor package specs that are not already packaged, such as git and directory\ndependencies. The default `opts.dirPacker` does not execute `prepare` scripts,\neven though npm itself does.\n\n##### \u003ca name=\"opts-enjoy-by\"\u003e\u003c/a\u003e `opts.enjoy-by`\n\n* Alias: `opts.enjoyBy`, `opts.before`\n* Type: Date-able\n* Default: undefined\n\nIf passed in, will be used while resolving to filter the versions for **registry\ndependencies** such that versions published **after** `opts.enjoy-by` are not\nconsidered -- as if they'd never been published.\n\n##### \u003ca name=\"opts-include-deprecated\"\u003e\u003c/a\u003e `opts.include-deprecated`\n\n* Alias: `opts.includeDeprecated`\n* Type: Boolean\n* Default: false\n\nIf false, deprecated versions will be skipped when selecting from registry range\nspecifiers. If true, deprecations do not affect version selection.\n\n##### \u003ca name=\"opts-full-metadata\"\u003e\u003c/a\u003e `opts.full-metadata`\n\n* Type: Boolean\n* Default: false\n\nIf `true`, the full packument will be fetched when doing metadata requests. By\ndefaul, `pacote` only fetches the summarized packuments, also called \"corgis\".\n\n##### \u003ca name=\"opts-tag\"\u003e\u003c/a\u003e `opts.tag`\n\n* Alias: `opts.defaultTag`\n* Type: String\n* Default: `'latest'`\n\nPackage version resolution tag. When processing registry spec ranges, this\noption is used to determine what dist-tag to treat as \"latest\". For more details\nabout how `pacote` selects versions and how `tag` is involved, see [the\ndocumentation for `npm-pick-manifest`](https://npm.im/npm-pick-manifest).\n\n##### \u003ca name=\"opts-resolved\"\u003e\u003c/a\u003e `opts.resolved`\n\n* Type: String\n* Default: null\n\nWhen fetching tarballs, this option can be passed in to skip registry metadata\nlookups when downloading tarballs. If the string is a `file:` URL, pacote will\ntry to read the referenced local file before attempting to do any further\nlookups. This option does not bypass integrity checks when `opts.integrity` is\npassed in.\n\n##### \u003ca name=\"opts-where\"\u003e\u003c/a\u003e `opts.where`\n\n* Type: String\n* Default: null\n\nPassed as an argument to [`npm-package-arg`](https://npm.im/npm-package-arg)\nwhen resolving `spec` arguments. Used to determine what path to resolve local\npath specs relatively from.\n","funding_links":["https://github.com/sponsors/zkat"],"categories":["JavaScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzkat%2Fpacote","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzkat%2Fpacote","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzkat%2Fpacote/lists"}