Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKat Marchán <kzm@zkat.tech>2018-08-02 02:36:03 +0300
committerKat Marchán <kzm@zkat.tech>2018-08-02 02:36:03 +0300
commit0096f69978d2f40b170b28096f269b0b0008a692 (patch)
tree776b8c00e90d1133a71e66be11e0fad1b5bb0360 /node_modules/cacache
parent0a22be42eb0d40cd0bd87e68c9e28fc9d72c0e19 (diff)
cacache@11.1.0
Diffstat (limited to 'node_modules/cacache')
-rw-r--r--node_modules/cacache/CHANGELOG.md22
-rw-r--r--node_modules/cacache/lib/content/read.js110
-rw-r--r--node_modules/cacache/package.json41
-rw-r--r--node_modules/cacache/put.js6
4 files changed, 119 insertions, 60 deletions
diff --git a/node_modules/cacache/CHANGELOG.md b/node_modules/cacache/CHANGELOG.md
index f04bdea0c..a9aeb3bc1 100644
--- a/node_modules/cacache/CHANGELOG.md
+++ b/node_modules/cacache/CHANGELOG.md
@@ -2,6 +2,28 @@
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
+<a name="11.1.0"></a>
+# [11.1.0](https://github.com/zkat/cacache/compare/v11.0.3...v11.1.0) (2018-08-01)
+
+
+### Features
+
+* **read:** add sync support for low-level content read ([b43af83](https://github.com/zkat/cacache/commit/b43af83))
+
+
+
+<a name="11.0.3"></a>
+## [11.0.3](https://github.com/zkat/cacache/compare/v11.0.2...v11.0.3) (2018-08-01)
+
+
+### Bug Fixes
+
+* **config:** add ssri config options ([#136](https://github.com/zkat/cacache/issues/136)) ([10d5d9a](https://github.com/zkat/cacache/commit/10d5d9a))
+* **perf:** refactor content.read to avoid lstats ([c5ac10e](https://github.com/zkat/cacache/commit/c5ac10e))
+* **test:** oops when removing safe-buffer ([1950490](https://github.com/zkat/cacache/commit/1950490))
+
+
+
<a name="11.0.2"></a>
## [11.0.2](https://github.com/zkat/cacache/compare/v11.0.1...v11.0.2) (2018-05-07)
diff --git a/node_modules/cacache/lib/content/read.js b/node_modules/cacache/lib/content/read.js
index 5c1a6f2f2..e308ead92 100644
--- a/node_modules/cacache/lib/content/read.js
+++ b/node_modules/cacache/lib/content/read.js
@@ -10,7 +10,8 @@ const pipe = BB.promisify(require('mississippi').pipe)
const ssri = require('ssri')
const Y = require('../util/y.js')
-BB.promisifyAll(fs)
+const lstatAsync = BB.promisify(fs.lstat)
+const readFileAsync = BB.promisify(fs.readFile)
const ReadOpts = figgyPudding({
size: {}
@@ -19,10 +20,8 @@ const ReadOpts = figgyPudding({
module.exports = read
function read (cache, integrity, opts) {
opts = ReadOpts(opts)
- return pickContentSri(cache, integrity).then(content => {
- const sri = content.sri
- const cpath = contentPath(cache, sri)
- return fs.readFileAsync(cpath, null).then(data => {
+ return withContentSri(cache, integrity, (cpath, sri) => {
+ return readFileAsync(cpath, null).then(data => {
if (typeof opts.size === 'number' && opts.size !== data.length) {
throw sizeError(opts.size, data.length)
} else if (ssri.checkData(data, sri)) {
@@ -34,17 +33,31 @@ function read (cache, integrity, opts) {
})
}
+module.exports.sync = readSync
+function readSync (cache, integrity, opts) {
+ opts = ReadOpts(opts)
+ return withContentSriSync(cache, integrity, (cpath, sri) => {
+ const data = fs.readFileSync(cpath)
+ if (typeof opts.size === 'number' && opts.size !== data.length) {
+ throw sizeError(opts.size, data.length)
+ } else if (ssri.checkData(data, sri)) {
+ return data
+ } else {
+ throw integrityError(sri, cpath)
+ }
+ })
+}
+
module.exports.stream = readStream
module.exports.readStream = readStream
function readStream (cache, integrity, opts) {
opts = ReadOpts(opts)
const stream = new PassThrough()
- pickContentSri(
- cache, integrity
- ).then(content => {
- const sri = content.sri
+ withContentSri(cache, integrity, (cpath, sri) => {
+ return lstatAsync(cpath).then(stat => ({cpath, sri, stat}))
+ }).then(({cpath, sri, stat}) => {
return pipe(
- fs.createReadStream(contentPath(cache, sri)),
+ fs.createReadStream(cpath),
ssri.integrityStream({
integrity: sri,
size: opts.size
@@ -57,37 +70,64 @@ function readStream (cache, integrity, opts) {
return stream
}
+let copyFileAsync
if (fs.copyFile) {
module.exports.copy = copy
+ copyFileAsync = BB.promisify(fs.copyFile)
}
function copy (cache, integrity, dest, opts) {
opts = ReadOpts(opts)
- return pickContentSri(cache, integrity).then(content => {
- const sri = content.sri
- const cpath = contentPath(cache, sri)
- return fs.copyFileAsync(cpath, dest).then(() => content.size)
+ return withContentSri(cache, integrity, (cpath, sri) => {
+ return copyFileAsync(cpath, dest)
})
}
module.exports.hasContent = hasContent
function hasContent (cache, integrity) {
if (!integrity) { return BB.resolve(false) }
- return pickContentSri(cache, integrity)
- .catch({code: 'ENOENT'}, () => false)
- .catch({code: 'EPERM'}, err => {
+ return withContentSri(cache, integrity, (cpath, sri) => {
+ return lstatAsync(cpath).then(stat => ({size: stat.size, sri}))
+ }).catch(err => {
+ if (err.code === 'ENOENT') { return false }
+ if (err.code === 'EPERM') {
if (process.platform !== 'win32') {
throw err
} else {
return false
}
- }).then(content => {
- if (!content.sri) return false
- return ({ sri: content.sri, size: content.stat.size })
- })
+ }
+ })
}
-module.exports._pickContentSri = pickContentSri
-function pickContentSri (cache, integrity) {
+function withContentSri (cache, integrity, fn) {
+ return BB.try(() => {
+ const sri = ssri.parse(integrity)
+ // If `integrity` has multiple entries, pick the first digest
+ // with available local data.
+ const algo = sri.pickAlgorithm()
+ const digests = sri[algo]
+ if (digests.length <= 1) {
+ const cpath = contentPath(cache, digests[0])
+ return fn(cpath, digests[0])
+ } else {
+ return BB.any(sri[sri.pickAlgorithm()].map(meta => {
+ return withContentSri(cache, meta, fn)
+ }, {concurrency: 1}))
+ .catch(err => {
+ if ([].some.call(err, e => e.code === 'ENOENT')) {
+ throw Object.assign(
+ new Error('No matching content found for ' + sri.toString()),
+ {code: 'ENOENT'}
+ )
+ } else {
+ throw err[0]
+ }
+ })
+ }
+ })
+}
+
+function withContentSriSync (cache, integrity, fn) {
const sri = ssri.parse(integrity)
// If `integrity` has multiple entries, pick the first digest
// with available local data.
@@ -95,21 +135,17 @@ function pickContentSri (cache, integrity) {
const digests = sri[algo]
if (digests.length <= 1) {
const cpath = contentPath(cache, digests[0])
- return fs.lstatAsync(cpath).then(stat => ({ sri: digests[0], stat }))
+ return fn(cpath, digests[0])
} else {
- return BB.any(sri[sri.pickAlgorithm()].map(meta => {
- return pickContentSri(cache, meta)
- }))
- .catch(err => {
- if ([].some.call(err, e => e.code === 'ENOENT')) {
- throw Object.assign(
- new Error('No matching content found for ' + sri.toString()),
- {code: 'ENOENT'}
- )
- } else {
- throw err[0]
- }
- })
+ let lastErr = null
+ for (const meta of sri[sri.pickAlgorithm()]) {
+ try {
+ return withContentSriSync(cache, meta, fn)
+ } catch (err) {
+ lastErr = err
+ }
+ }
+ if (lastErr) { throw lastErr }
}
}
diff --git a/node_modules/cacache/package.json b/node_modules/cacache/package.json
index c9e61596f..01e20c134 100644
--- a/node_modules/cacache/package.json
+++ b/node_modules/cacache/package.json
@@ -1,34 +1,30 @@
{
- "_args": [
- [
- "cacache@11.0.2",
- "/Users/rebecca/code/npm"
- ]
- ],
- "_from": "cacache@11.0.2",
- "_id": "cacache@11.0.2",
+ "_from": "cacache@latest",
+ "_id": "cacache@11.1.0",
"_inBundle": false,
- "_integrity": "sha512-hMiz7LN4w8sdfmKsvNs80ao/vf2JCGWWdpu95JyY90AJZRbZJmgE71dCefRiNf8OCqiZQDcUBfYiLlUNu4/j5A==",
+ "_integrity": "sha512-wFLexxfPdlvoUlpHIaU4y4Vm+Im/otOPCg1ov5g9/HRfUhVA8GpDdQL66SWBgRpgNC+5ebMT1Vr1RyPaFrJVqw==",
"_location": "/cacache",
"_phantomChildren": {},
"_requested": {
- "type": "version",
+ "type": "tag",
"registry": true,
- "raw": "cacache@11.0.2",
+ "raw": "cacache@latest",
"name": "cacache",
"escapedName": "cacache",
- "rawSpec": "11.0.2",
+ "rawSpec": "latest",
"saveSpec": null,
- "fetchSpec": "11.0.2"
+ "fetchSpec": "latest"
},
"_requiredBy": [
+ "#USER",
"/",
"/make-fetch-happen",
"/pacote"
],
- "_resolved": "https://registry.npmjs.org/cacache/-/cacache-11.0.2.tgz",
- "_spec": "11.0.2",
- "_where": "/Users/rebecca/code/npm",
+ "_resolved": "https://registry.npmjs.org/cacache/-/cacache-11.1.0.tgz",
+ "_shasum": "3d76dbc2e9da413acaad2557051960a4dad3e1a4",
+ "_spec": "cacache@latest",
+ "_where": "/Users/zkat/Documents/code/work/npm",
"author": {
"name": "Kat Marchán",
"email": "kzm@sykosomatic.org"
@@ -36,6 +32,7 @@
"bugs": {
"url": "https://github.com/zkat/cacache/issues"
},
+ "bundleDependencies": false,
"cache-version": {
"content": "2",
"index": "5"
@@ -64,7 +61,7 @@
"figgy-pudding": "^3.1.0",
"glob": "^7.1.2",
"graceful-fs": "^4.1.11",
- "lru-cache": "^4.1.2",
+ "lru-cache": "^4.1.3",
"mississippi": "^3.0.0",
"mkdirp": "^0.5.1",
"move-concurrently": "^1.0.1",
@@ -74,17 +71,17 @@
"unique-filename": "^1.1.0",
"y18n": "^4.0.0"
},
+ "deprecated": false,
"description": "Fast, fault-tolerant, cross-platform, disk-based, data-agnostic, content-addressable cache.",
"devDependencies": {
"benchmark": "^2.1.4",
"chalk": "^2.3.2",
"cross-env": "^5.1.4",
"require-inject": "^1.4.2",
- "safe-buffer": "^5.1.1",
"standard": "^11.0.1",
- "standard-version": "^4.3.0",
- "tacks": "^1.2.2",
- "tap": "^11.1.3",
+ "standard-version": "^4.4.0",
+ "tacks": "^1.2.7",
+ "tap": "^12.0.1",
"weallbehave": "^1.2.0",
"weallcontribute": "^1.0.8"
},
@@ -127,5 +124,5 @@
"update-coc": "weallbehave -o . && git add CODE_OF_CONDUCT.md && git commit -m 'docs(coc): updated CODE_OF_CONDUCT.md'",
"update-contrib": "weallcontribute -o . && git add CONTRIBUTING.md && git commit -m 'docs(contributing): updated CONTRIBUTING.md'"
},
- "version": "11.0.2"
+ "version": "11.1.0"
}
diff --git a/node_modules/cacache/put.js b/node_modules/cacache/put.js
index 0b0ee1497..01b0dd84f 100644
--- a/node_modules/cacache/put.js
+++ b/node_modules/cacache/put.js
@@ -13,10 +13,14 @@ const PutOpts = figgyPudding({
integrity: {},
memoize: {},
metadata: {},
+ pickAlgorithm: {},
size: {},
tmpPrefix: {},
uid: {},
- gid: {}
+ gid: {},
+ single: {},
+ sep: {},
+ strict: {}
})
module.exports = putData