diff options
author | Gar <gar+gh@danger.computer> | 2021-03-09 21:14:46 +0300 |
---|---|---|
committer | Gar <gar+gh@danger.computer> | 2021-03-09 22:10:06 +0300 |
commit | e9b7fc275a0bdf8f00dbcf5dd2283675776fc459 (patch) | |
tree | 3ec7349efc71154903deb4847fa81a8358c4fbb6 /node_modules/pacote | |
parent | 7f470b5c25d544e36d97b28e28ae20dfa1d4ab31 (diff) |
libnpmdiff@2.0.4
Diffstat (limited to 'node_modules/pacote')
-rw-r--r-- | node_modules/pacote/README.md | 12 | ||||
-rw-r--r-- | node_modules/pacote/lib/dir.js | 33 | ||||
-rw-r--r-- | node_modules/pacote/lib/index.js | 11 | ||||
-rw-r--r-- | node_modules/pacote/lib/util/tar-create-options.js | 24 | ||||
-rw-r--r-- | node_modules/pacote/package.json | 2 |
5 files changed, 55 insertions, 27 deletions
diff --git a/node_modules/pacote/README.md b/node_modules/pacote/README.md index 619e0ec44..2328c0a4a 100644 --- a/node_modules/pacote/README.md +++ b/node_modules/pacote/README.md @@ -168,6 +168,18 @@ resolved, and other properties, as they are determined. times (even just to validate the cache) for a given packument, since it is unlikely to change in the span of a single command. + +### Advanced API + +Each different type of fetcher is exposed for more advanced usage such as +using helper methods from this classes: + +* `DirFetcher` +* `FileFetcher` +* `GitFetcher` +* `RegistryFetcher` +* `RemoteFetcher` + ## Extracted File Modes Files are extracted with a mode matching the following formula: diff --git a/node_modules/pacote/lib/dir.js b/node_modules/pacote/lib/dir.js index 4a89348b9..0d3a00d95 100644 --- a/node_modules/pacote/lib/dir.js +++ b/node_modules/pacote/lib/dir.js @@ -4,11 +4,10 @@ const cacache = require('cacache') const Minipass = require('minipass') const { promisify } = require('util') const readPackageJson = require('read-package-json-fast') -const isPackageBin = require('./util/is-package-bin.js') +const tarCreateOptions = require('./util/tar-create-options.js') const packlist = require('npm-packlist') const tar = require('tar') const _prepareDir = Symbol('_prepareDir') -const _tarcOpts = Symbol('_tarcOpts') const { resolve } = require('path') const runScript = require('@npmcli/run-script') @@ -21,6 +20,11 @@ class DirFetcher extends Fetcher { this.resolved = this.spec.fetchSpec } + // exposes tarCreateOptions as public API + static tarCreateOptions (manifest) { + return tarCreateOptions(manifest) + } + get types () { return ['directory'] } @@ -65,35 +69,12 @@ class DirFetcher extends Fetcher { // pipe to the stream, and proxy errors the chain. this[_prepareDir]() .then(() => packlist({ path: this.resolved })) - .then(files => tar.c(this[_tarcOpts](), files) + .then(files => tar.c(tarCreateOptions(this.package), files) .on('error', er => stream.emit('error', er)).pipe(stream)) .catch(er => stream.emit('error', er)) return stream } - [_tarcOpts] () { - return { - cwd: this.resolved, - prefix: 'package/', - portable: true, - gzip: true, - - // ensure that package bins are always executable - // Note that npm-packlist is already filtering out - // anything that is not a regular file, ignored by - // .npmignore or package.json "files", etc. - filter: (path, stat) => { - if (isPackageBin(this.package, path)) - stat.mode |= 0o111 - return true - }, - - // Provide a specific date in the 1980s for the benefit of zip, - // which is confounded by files dated at the Unix epoch 0. - mtime: new Date('1985-10-26T08:15:00.000Z'), - } - } - manifest () { if (this.package) return Promise.resolve(this.package) diff --git a/node_modules/pacote/lib/index.js b/node_modules/pacote/lib/index.js index 546ba960b..cbcbd7c92 100644 --- a/node_modules/pacote/lib/index.js +++ b/node_modules/pacote/lib/index.js @@ -1,5 +1,16 @@ const { get } = require('./fetcher.js') +const GitFetcher = require('./git.js') +const RegistryFetcher = require('./registry.js') +const FileFetcher = require('./file.js') +const DirFetcher = require('./dir.js') +const RemoteFetcher = require('./remote.js') + module.exports = { + GitFetcher, + RegistryFetcher, + FileFetcher, + DirFetcher, + RemoteFetcher, resolve: (spec, opts) => get(spec, opts).resolve(), extract: (spec, dest, opts) => get(spec, opts).extract(dest), manifest: (spec, opts) => get(spec, opts).manifest(), diff --git a/node_modules/pacote/lib/util/tar-create-options.js b/node_modules/pacote/lib/util/tar-create-options.js new file mode 100644 index 000000000..e8abbe175 --- /dev/null +++ b/node_modules/pacote/lib/util/tar-create-options.js @@ -0,0 +1,24 @@ +const isPackageBin = require('./is-package-bin.js') + +const tarCreateOptions = manifest => ({ + cwd: manifest._resolved, + prefix: 'package/', + portable: true, + gzip: true, + + // ensure that package bins are always executable + // Note that npm-packlist is already filtering out + // anything that is not a regular file, ignored by + // .npmignore or package.json "files", etc. + filter: (path, stat) => { + if (isPackageBin(manifest, path)) + stat.mode |= 0o111 + return true + }, + + // Provide a specific date in the 1980s for the benefit of zip, + // which is confounded by files dated at the Unix epoch 0. + mtime: new Date('1985-10-26T08:15:00.000Z'), +}) + +module.exports = tarCreateOptions diff --git a/node_modules/pacote/package.json b/node_modules/pacote/package.json index a1668056f..dca67f3e8 100644 --- a/node_modules/pacote/package.json +++ b/node_modules/pacote/package.json @@ -1,6 +1,6 @@ { "name": "pacote", - "version": "11.2.7", + "version": "11.3.0", "description": "JavaScript package downloader", "author": "Isaac Z. Schlueter <i@izs.me> (https://izs.me)", "bin": { |