cacache 13.0.1 → 14.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  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.
4
4
 
5
+ ## [14.0.0](https://github.com/npm/cacache/compare/v13.0.1...v14.0.0) (2020-01-28)
6
+
7
+
8
+ ### ⚠ BREAKING CHANGES
9
+
10
+ * **deps:** bumps engines to >= 10
11
+
12
+ * **deps:** tar v6 and mkdirp v1 ([5a66e7a](https://github.com/npm/cacache/commit/5a66e7a))
13
+
5
14
  ### [13.0.1](https://github.com/npm/cacache/compare/v13.0.0...v13.0.1) (2019-09-30)
6
15
 
7
16
 
package/README.md CHANGED
@@ -12,8 +12,6 @@ when running as `root`.
12
12
  It was written to be used as [npm](https://npm.im)'s local cache, but can
13
13
  just as easily be used on its own.
14
14
 
15
- _Translations: [español](README.es.md)_
16
-
17
15
  ## Install
18
16
 
19
17
  `$ npm install --save cacache`
@@ -15,9 +15,10 @@ module.exports = contentPath
15
15
  function contentPath (cache, integrity) {
16
16
  const sri = ssri.parse(integrity, { single: true })
17
17
  // contentPath is the *strongest* algo given
18
- return path.join.apply(
19
- path,
20
- [contentDir(cache), sri.algorithm].concat(hashToSegments(sri.hexDigest()))
18
+ return path.join(
19
+ contentDir(cache),
20
+ sri.algorithm,
21
+ ...hashToSegments(sri.hexDigest())
21
22
  )
22
23
  }
23
24
 
@@ -127,6 +127,7 @@ function hasContent (cache, integrity) {
127
127
  return false
128
128
  }
129
129
  if (err.code === 'EPERM') {
130
+ /* istanbul ignore else */
130
131
  if (process.platform !== 'win32') {
131
132
  throw err
132
133
  } else {
@@ -151,6 +152,7 @@ function hasContentSync (cache, integrity) {
151
152
  return false
152
153
  }
153
154
  if (err.code === 'EPERM') {
155
+ /* istanbul ignore else */
154
156
  if (process.platform !== 'win32') {
155
157
  throw err
156
158
  } else {
@@ -175,7 +177,7 @@ function withContentSri (cache, integrity, fn) {
175
177
  } else {
176
178
  // Can't use race here because a generic error can happen before a ENOENT error, and can happen before a valid result
177
179
  return Promise
178
- .all(sri[sri.pickAlgorithm()].map((meta) => {
180
+ .all(digests.map((meta) => {
179
181
  return withContentSri(cache, meta, fn)
180
182
  .catch((err) => {
181
183
  if (err.code === 'ENOENT') {
@@ -201,10 +203,7 @@ function withContentSri (cache, integrity, fn) {
201
203
  }
202
204
 
203
205
  // Throw generic error
204
- const genericError = results.find((r) => r instanceof Error)
205
- if (genericError) {
206
- throw genericError
207
- }
206
+ throw results.find((r) => r instanceof Error)
208
207
  })
209
208
  }
210
209
  }
@@ -231,16 +230,14 @@ function withContentSriSync (cache, integrity, fn) {
231
230
  return fn(cpath, digests[0])
232
231
  } else {
233
232
  let lastErr = null
234
- for (const meta of sri[sri.pickAlgorithm()]) {
233
+ for (const meta of digests) {
235
234
  try {
236
235
  return withContentSriSync(cache, meta, fn)
237
236
  } catch (err) {
238
237
  lastErr = err
239
238
  }
240
239
  }
241
- if (lastErr) {
242
- throw lastErr
243
- }
240
+ throw lastErr
244
241
  }
245
242
  }
246
243
 
package/lib/content/rm.js CHANGED
@@ -10,11 +10,9 @@ module.exports = rm
10
10
 
11
11
  function rm (cache, integrity) {
12
12
  return hasContent(cache, integrity).then((content) => {
13
- if (content) {
14
- const sri = content.sri
15
- if (sri) {
16
- return rimraf(contentPath(cache, sri)).then(() => true)
17
- }
13
+ // ~pretty~ sure we can't end up with a content lacking sri, but be safe
14
+ if (content && content.sri) {
15
+ return rimraf(contentPath(cache, content.sri)).then(() => true)
18
16
  } else {
19
17
  return false
20
18
  }
@@ -3,7 +3,7 @@
3
3
  const util = require('util')
4
4
 
5
5
  const chownr = util.promisify(require('chownr'))
6
- const mkdirp = util.promisify(require('mkdirp'))
6
+ const mkdirp = require('mkdirp')
7
7
  const inflight = require('promise-inflight')
8
8
  const inferOwner = require('infer-owner')
9
9
 
@@ -11,6 +11,9 @@ const pinflight = require('promise-inflight')
11
11
  module.exports = moveFile
12
12
 
13
13
  function moveFile (src, dest) {
14
+ const isWindows = global.__CACACHE_TEST_FAKE_WINDOWS__ ||
15
+ process.platform === 'win32'
16
+
14
17
  // This isn't quite an fs.rename -- the assumption is that
15
18
  // if `dest` already exists, and we get certain errors while
16
19
  // trying to move it, we should just not bother.
@@ -23,22 +26,31 @@ function moveFile (src, dest) {
23
26
  return new Promise((resolve, reject) => {
24
27
  fs.link(src, dest, (err) => {
25
28
  if (err) {
26
- if (err.code === 'EEXIST' || err.code === 'EBUSY') {
29
+ if (isWindows && err.code === 'EPERM') {
30
+ // XXX This is a really weird way to handle this situation, as it
31
+ // results in the src file being deleted even though the dest
32
+ // might not exist. Since we pretty much always write files to
33
+ // deterministic locations based on content hash, this is likely
34
+ // ok (or at worst, just ends in a future cache miss). But it would
35
+ // be worth investigating at some time in the future if this is
36
+ // really what we want to do here.
37
+ return resolve()
38
+ } else if (err.code === 'EEXIST' || err.code === 'EBUSY') {
27
39
  // file already exists, so whatever
28
- } else if (err.code === 'EPERM' && process.platform === 'win32') {
29
- // file handle stayed open even past graceful-fs limits
40
+ return resolve()
30
41
  } else {
31
42
  return reject(err)
32
43
  }
44
+ } else {
45
+ return resolve()
33
46
  }
34
- return resolve()
35
47
  })
36
48
  })
37
49
  .then(() => {
38
50
  // content should never change for any reason, so make it read-only
39
51
  return Promise.all([
40
52
  unlink(src),
41
- process.platform !== 'win32' && chmod(dest, '0444')
53
+ !isWindows && chmod(dest, '0444')
42
54
  ])
43
55
  })
44
56
  .catch(() => {
package/lib/verify.js CHANGED
@@ -50,7 +50,7 @@ function verify (cache, opts) {
50
50
 
51
51
  return steps
52
52
  .reduce((promise, step, i) => {
53
- const label = step.name || `step #${i}`
53
+ const label = step.name
54
54
  const start = new Date()
55
55
  return promise.then((stats) => {
56
56
  return step(cache, opts).then((s) => {
@@ -208,6 +208,7 @@ function rebuildIndex (cache, opts) {
208
208
  }
209
209
  const buckets = {}
210
210
  for (const k in entries) {
211
+ /* istanbul ignore else */
211
212
  if (hasOwnProperty(entries, k)) {
212
213
  const hashed = index.hashKey(k)
213
214
  const entry = entries[k]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cacache",
3
- "version": "13.0.1",
3
+ "version": "14.0.0",
4
4
  "cache-version": {
5
5
  "content": "2",
6
6
  "index": "5"
@@ -69,12 +69,13 @@
69
69
  "minipass-collect": "^1.0.2",
70
70
  "minipass-flush": "^1.0.5",
71
71
  "minipass-pipeline": "^1.2.2",
72
- "mkdirp": "^0.5.1",
72
+ "mkdirp": "^1.0.3",
73
73
  "move-concurrently": "^1.0.1",
74
74
  "p-map": "^3.0.0",
75
75
  "promise-inflight": "^1.0.1",
76
76
  "rimraf": "^2.7.1",
77
77
  "ssri": "^7.0.0",
78
+ "tar": "^6.0.0",
78
79
  "unique-filename": "^1.1.1"
79
80
  },
80
81
  "devDependencies": {
@@ -89,7 +90,10 @@
89
90
  "weallbehave": "^1.2.0",
90
91
  "weallcontribute": "^1.0.9"
91
92
  },
93
+ "tap": {
94
+ "100": true
95
+ },
92
96
  "engines": {
93
- "node": ">= 8"
97
+ "node": ">= 10"
94
98
  }
95
99
  }