meteor/pacote

Name: pacote

Owner: Meteor

Description: programmatic npm package and metadata downloader

Forked from: zkat/pacote

Created: 2017-10-19 00:40:09.0

Updated: 2017-10-19 00:40:11.0

Pushed: 2017-12-20 15:27:08.0

Homepage:

Size: 1102

Language: JavaScript

GitHub Committers

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

pacote npm version license Travis AppVeyor Coverage Status

NOTE: this package is still under heavy development. Please don't use it yet

pacote is a Node.js library for downloading npm-compatible packages. It supports all package specifier syntax that npm install and its ilk support. It transparently caches anything needed to reduce excess operations, using cacache.

Install

$ npm install --save pacote

Table of Contents
Example
t pacote = require('pacote')

te.manifest('pacote@^1').then(pkg => {
nsole.log('package manifest for registry pkg:', pkg)
 { "name": "pacote", "version": "1.0.0", ... }


te.extract('http://hi.com/pkg.tgz', './here').then(() => {
nsole.log('remote tarball contents extracted to ./here')

Features
Contributing

The 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 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.

API
> pacote.manifest(spec, [opts])

Fetches the manifest for a package. Manifest objects are similar and based on the package.json for that package, but with pre-processed and limited fields. The object has the following shape:


ame": PkgName,
ersion": SemverString,
ependencies": { PkgName: SemverString },
ptionalDependencies": { PkgName: SemverString },
evDependencies": { PkgName: SemverString },
eerDependencies": { PkgName: SemverString },
undleDependencies": false || [PkgName],
in": { BinName: Path },
resolved": TarballSource, // different for each package type
integrity": SubresourceIntegrityHash,
shrinkwrap": null || ShrinkwrapJsonObj

Note that depending on the spec type, some additional fields might be present. For example, packages from registry.npmjs.org have additional metadata appended by the registry.

Example
te.manifest('pacote@1.0.0').then(pkgJson => {
 fetched `package.json` data from the registry

> pacote.extract(spec, destination, [opts])

Extracts package data identified by <spec> into a directory named <destination>, which will be created if it does not already exist.

If opts.digest is provided and the data it identifies is present in the cache, extract will bypass most of its operations and go straight to extracting the tarball.

Example
te.extract('pacote@1.0.0', './woot', {
gest: 'deadbeef'
hen(() => {
 Succeeds as long as `pacote@1.0.0` still exists somewhere. Network and
 other operations are bypassed entirely if `digest` is present in the cache.

> pacote.prefetch(spec, [opts])

Fetches package data identified by <spec>, usually for the purpose of warming up the local package cache (with opts.cache). It does not return anything.

Example
te.prefetch('pacote@1.0.0', { cache: './my-cache' }).then(() => {
 ./my-cache now has both the manifest and tarball for `pacote@1.0.0`.

> pacote.clearMemoized()

This utility function can be used to force pacote to release its references to any memoized data in its various internal caches. It might help free some memory.

te.manifest(...).then(() => pacote.clearMemoized)
> options opts.integrity

If provided, pacote will confirm that the relevant integrity hash for each operation's results matches the given digest. The call will return EINTEGRITY if the check fails.

Additionally, pacote.extract will use this integrity string check the cache directly for matching contents before performing any other operations.

opts.cache opts.cacheUid/opts.cacheGid opts.uid/opts.gid opts.scope opts.registry opts.@somescope:registry opts.auth opts.log opts.maxSockets

Default: silentNpmLog

An npmlog-compatible logger. Will be used to log various events at the levels specified by npmlog.


This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.