cacache 15.0.6 → 15.1.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/README.md CHANGED
@@ -36,6 +36,8 @@ just as easily be used on its own.
36
36
  * [`rm.all`](#rm-all)
37
37
  * [`rm.entry`](#rm-entry)
38
38
  * [`rm.content`](#rm-content)
39
+ * [`index.compact`](#index-compact)
40
+ * [`index.insert`](#index-insert)
39
41
  * Utilities
40
42
  * [`clearMemoized`](#clear-memoized)
41
43
  * [`tmp.mkdir`](#tmp-mkdir)
@@ -489,6 +491,25 @@ cacache.rm.content(cachePath, 'sha512-SoMeDIGest/IN+BaSE64==').then(() => {
489
491
  })
490
492
  ```
491
493
 
494
+ #### <a name="index-compact"></a> `> cacache.index.compact(cache, key, matchFn) -> Promise`
495
+
496
+ Uses `matchFn`, which must be a synchronous function that accepts two entries
497
+ and returns a boolean indicating whether or not the two entries match, to
498
+ deduplicate all entries in the cache for the given `key`.
499
+
500
+ The deduplicated list of entries is both written to the index, replacing the
501
+ existing content, and returned in the Promise.
502
+
503
+ #### <a name="index-insert"></a> `> cacache.index.insert(cache, key, integrity, opts) -> Promise`
504
+
505
+ Writes an index entry to the cache for the given `key` without writing content.
506
+
507
+ It is assumed if you are using this method, you have already stored the content
508
+ some other way and you only wish to add a new index to that content. The `metadata`
509
+ and `size` properties are read from `opts` and used as part of the index entry.
510
+
511
+ Returns a Promise resolving to the newly added entry.
512
+
492
513
  #### <a name="clear-memoized"></a> `> cacache.clearMemoized()`
493
514
 
494
515
  Completely resets the in-memory entry cache.
package/index.js CHANGED
@@ -7,6 +7,11 @@ const rm = require('./rm.js')
7
7
  const verify = require('./verify.js')
8
8
  const { clearMemoized } = require('./lib/memoization.js')
9
9
  const tmp = require('./lib/util/tmp.js')
10
+ const index = require('./lib/entry-index.js')
11
+
12
+ module.exports.index = {}
13
+ module.exports.index.compact = index.compact
14
+ module.exports.index.insert = index.insert
10
15
 
11
16
  module.exports.ls = ls
12
17
  module.exports.ls.stream = ls.stream
@@ -1,20 +1,25 @@
1
1
  'use strict'
2
2
 
3
3
  const util = require('util')
4
-
5
4
  const crypto = require('crypto')
6
5
  const fs = require('fs')
7
6
  const Minipass = require('minipass')
8
7
  const path = require('path')
9
8
  const ssri = require('ssri')
9
+ const uniqueFilename = require('unique-filename')
10
+
11
+ const { disposer } = require('./util/disposer')
10
12
  const contentPath = require('./content/path')
11
13
  const fixOwner = require('./util/fix-owner')
12
14
  const hashToSegments = require('./util/hash-to-segments')
13
15
  const indexV = require('../package.json')['cache-version'].index
16
+ const moveFile = require('@npmcli/move-file')
17
+ const rimraf = util.promisify(require('rimraf'))
14
18
 
15
19
  const appendFile = util.promisify(fs.appendFile)
16
20
  const readFile = util.promisify(fs.readFile)
17
21
  const readdir = util.promisify(fs.readdir)
22
+ const writeFile = util.promisify(fs.writeFile)
18
23
 
19
24
  module.exports.NotFoundError = class NotFoundError extends Error {
20
25
  constructor (cache, key) {
@@ -25,6 +30,64 @@ module.exports.NotFoundError = class NotFoundError extends Error {
25
30
  }
26
31
  }
27
32
 
33
+ module.exports.compact = compact
34
+
35
+ async function compact (cache, key, matchFn, opts = {}) {
36
+ const bucket = bucketPath(cache, key)
37
+ const entries = await bucketEntries(bucket)
38
+ // reduceRight because the bottom-most result is the newest
39
+ // since we add new entries with appendFile
40
+ const newEntries = entries.reduceRight((acc, newEntry) => {
41
+ if (!acc.find((oldEntry) => matchFn(oldEntry, newEntry))) {
42
+ acc.push(newEntry)
43
+ }
44
+
45
+ return acc
46
+ }, [])
47
+
48
+ const newIndex = '\n' + newEntries.map((entry) => {
49
+ const stringified = JSON.stringify(entry)
50
+ const hash = hashEntry(stringified)
51
+ return `${hash}\t${stringified}`
52
+ }).join('\n')
53
+
54
+ const setup = async () => {
55
+ const target = uniqueFilename(path.join(cache, 'tmp'), opts.tmpPrefix)
56
+ await fixOwner.mkdirfix(cache, path.dirname(target))
57
+ return {
58
+ target,
59
+ moved: false
60
+ }
61
+ }
62
+
63
+ const teardown = async (tmp) => {
64
+ if (!tmp.moved) {
65
+ return rimraf(tmp.target)
66
+ }
67
+ }
68
+
69
+ const write = async (tmp) => {
70
+ await writeFile(tmp.target, newIndex, { flag: 'wx' })
71
+ await fixOwner.mkdirfix(cache, path.dirname(bucket))
72
+ // we use @npmcli/move-file directly here because we
73
+ // want to overwrite the existing file
74
+ await moveFile(tmp.target, bucket)
75
+ tmp.moved = true
76
+ try {
77
+ await fixOwner.chownr(cache, bucket)
78
+ } catch (err) {
79
+ if (err.code !== 'ENOENT') {
80
+ throw err
81
+ }
82
+ }
83
+ }
84
+
85
+ // write the file atomically
86
+ await disposer(setup(), teardown, write)
87
+
88
+ return newEntries.map((entry) => formatEntry(cache, entry, true))
89
+ }
90
+
28
91
  module.exports.insert = insert
29
92
 
30
93
  function insert (cache, key, integrity, opts = {}) {
@@ -209,10 +272,14 @@ function ls (cache) {
209
272
  )
210
273
  }
211
274
 
275
+ module.exports.bucketEntries = bucketEntries
276
+
212
277
  function bucketEntries (bucket, filter) {
213
278
  return readFile(bucket, 'utf8').then((data) => _bucketEntries(data, filter))
214
279
  }
215
280
 
281
+ module.exports.bucketEntries.sync = bucketEntriesSync
282
+
216
283
  function bucketEntriesSync (bucket, filter) {
217
284
  const data = fs.readFileSync(bucket, 'utf8')
218
285
  return _bucketEntries(data, filter)
@@ -279,15 +346,15 @@ function hash (str, digest) {
279
346
  .digest('hex')
280
347
  }
281
348
 
282
- function formatEntry (cache, entry) {
349
+ function formatEntry (cache, entry, keepAll) {
283
350
  // Treat null digests as deletions. They'll shadow any previous entries.
284
- if (!entry.integrity) {
351
+ if (!entry.integrity && !keepAll) {
285
352
  return null
286
353
  }
287
354
  return {
288
355
  key: entry.key,
289
356
  integrity: entry.integrity,
290
- path: contentPath(cache, entry.integrity),
357
+ path: entry.integrity ? contentPath(cache, entry.integrity) : undefined,
291
358
  size: entry.size,
292
359
  time: entry.time,
293
360
  metadata: entry.metadata
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cacache",
3
- "version": "15.0.6",
3
+ "version": "15.1.0",
4
4
  "cache-version": {
5
5
  "content": "2",
6
6
  "index": "5"
@@ -83,7 +83,7 @@
83
83
  "standard": "^14.3.1",
84
84
  "standard-version": "^7.1.0",
85
85
  "tacks": "^1.3.0",
86
- "tap": "^14.10.6"
86
+ "tap": "^15.0.9"
87
87
  },
88
88
  "tap": {
89
89
  "100": true,
package/CHANGELOG.md DELETED
@@ -1,796 +0,0 @@
1
- # Changelog
2
-
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
-
5
- ### [15.0.6](https://github.com/npm/cacache/compare/v15.0.5...v15.0.6) (2021-03-22)
6
-
7
- ### [15.0.5](https://github.com/npm/cacache/compare/v15.0.4...v15.0.5) (2020-07-11)
8
-
9
- ### [15.0.4](https://github.com/npm/cacache/compare/v15.0.3...v15.0.4) (2020-06-03)
10
-
11
-
12
- ### Bug Fixes
13
-
14
- * replace move-file dep with @npmcli/move-file ([bf88af0](https://github.com/npm/cacache/commit/bf88af04e50cca9b54041151139ffc1fd415e2dc)), closes [#37](https://github.com/npm/cacache/issues/37)
15
-
16
- ### [15.0.3](https://github.com/npm/cacache/compare/v15.0.2...v15.0.3) (2020-04-28)
17
-
18
-
19
- ### Bug Fixes
20
-
21
- * actually remove move-concurrently dep ([29e6eec](https://github.com/npm/cacache/commit/29e6eec9fee73444ee09daf1c1be06ddd5fe57f6))
22
-
23
- ### [15.0.2](https://github.com/npm/cacache/compare/v15.0.1...v15.0.2) (2020-04-28)
24
-
25
-
26
- ### Bug Fixes
27
-
28
- * tacks should be a dev dependency ([93ec158](https://github.com/npm/cacache/commit/93ec15852f0fdf1753ea7f75b4b8926daf8a7565))
29
-
30
- ## [15.0.1](https://github.com/npm/cacache/compare/v15.0.0...v15.0.1) (2020-04-27)
31
-
32
- * **deps:** Use move-file instead of move-file-concurrently. ([92b125](https://github.com/npm/cacache/commit/92b1251a11b9848878b6c0d101b18bd8845acaa6))
33
-
34
- ## [15.0.0](https://github.com/npm/cacache/compare/v14.0.0...v15.0.0) (2020-02-18)
35
-
36
-
37
- ### ⚠ BREAKING CHANGES
38
-
39
- * drop figgy-pudding and use canonical option names.
40
-
41
- ### Features
42
-
43
- * remove figgy-pudding ([57d11bc](https://github.com/npm/cacache/commit/57d11bce34f979247d1057d258acc204c4944491))
44
-
45
- ## [14.0.0](https://github.com/npm/cacache/compare/v13.0.1...v14.0.0) (2020-01-28)
46
-
47
-
48
- ### ⚠ BREAKING CHANGES
49
-
50
- * **deps:** bumps engines to >= 10
51
-
52
- * **deps:** tar v6 and mkdirp v1 ([5a66e7a](https://github.com/npm/cacache/commit/5a66e7a))
53
-
54
- ### [13.0.1](https://github.com/npm/cacache/compare/v13.0.0...v13.0.1) (2019-09-30)
55
-
56
-
57
- ### Bug Fixes
58
-
59
- * **fix-owner:** chownr.sync quits on non-root uid ([08801be](https://github.com/npm/cacache/commit/08801be))
60
-
61
- ## [13.0.0](https://github.com/npm/cacache/compare/v12.0.3...v13.0.0) (2019-09-25)
62
-
63
-
64
- ### ⚠ BREAKING CHANGES
65
-
66
- * This subtly changes the streaming interface of
67
- everything in cacache that streams, which is, well, everything in
68
- cacache. Most users will probably not notice, but any code that
69
- depended on stream behavior always being deferred until next tick will
70
- need to adjust.
71
-
72
- The mississippi methods 'to', 'from', 'through', and so on, have been
73
- replaced with their Minipass counterparts, and streaming interaction
74
- with the file system is done via fs-minipass.
75
-
76
- The following modules are of interest here:
77
-
78
- - [minipass](http://npm.im/minipass) The core stream library.
79
-
80
- - [fs-minipass](http://npm.im/fs-minipass) Note that the 'WriteStream'
81
- class from fs-minipass is _not_ a Minipass stream, but rather a plain
82
- old EventEmitter that duck types as a Writable.
83
-
84
- - [minipass-collect](http://npm.im/minipass-collect) Gather up all the
85
- data from a stream. Cacache only uses Collect.PassThrough, which is a
86
- basic Minipass passthrough stream which emits a 'collect' event with
87
- the completed data just before the 'end' event.
88
-
89
- - [minipass-pipeline](http://npm.im/minipass-pipeline) Connect one or
90
- more streams into a pipe chain. Errors anywhere in the pipeline are
91
- proxied down the chain and then up to the Pipeline object itself.
92
- Writes go into the head, reads go to the tail. Used in place of
93
- pump() and pumpify().
94
-
95
- - [minipass-flush](http://npm.im/minipass-flush) A Minipass passthrough
96
- stream that defers its 'end' event until after a flush() method has
97
- completed (either calling the supplied callback, or returning a
98
- promise.) Use in place of flush-write-stream (aka mississippi.to).
99
-
100
- Streams from through2, concat-stream, and the behavior provided by
101
- end-of-stream are all implemented in Minipass itself.
102
-
103
- Features of interest to cacache, which make Minipass a particularly good
104
- fit:
105
-
106
- - All of the 'endish' events are normalized, so we can just listen on
107
- 'end' and know that finish, prefinish, and close will be handled as
108
- well.
109
- - Minipass doesn't waste time [containing
110
- zalgo](https://blog.izs.me/2013/08/designing-apis-for-asynchrony).
111
- - Minipass has built-in support for promises that indicate the end or
112
- error: stream.promise(), stream.collect(), and stream.concat().
113
- - With reliable and consistent timing guarantees, much less
114
- error-checking logic is required. We can be more confident that an
115
- error is being thrown or emitted in the correct place, rather than in
116
- a callback which is deferred, resulting in a hung promise or
117
- uncaughtException.
118
-
119
- The biggest downside of Minipass is that it lacks some of the internal
120
- characteristics of node-core streams, which many community modules use
121
- to identify streams. They have no _writableState or _readableState
122
- objects, or _read or _write methods. As a result, the is-stream module
123
- (at least, at the time of this commit) doesn't recognize Minipass
124
- streams as readable or writable streams.
125
-
126
- All in all, the changes required of downstream users should be minimal,
127
- but are unlikely to be zero. Hence the semver major change.
128
-
129
- ### Features
130
-
131
- * replace all streams with Minipass streams ([f4c0962](https://github.com/npm/cacache/commit/f4c0962))
132
- * **deps:** Add minipass and minipass-pipeline ([a6545a9](https://github.com/npm/cacache/commit/a6545a9))
133
- * **promise:** converted .resolve to native promise, converted .map and .reduce to native ([220c56d](https://github.com/npm/cacache/commit/220c56d))
134
- * **promise:** individually promisifing functions as needed ([74b939e](https://github.com/npm/cacache/commit/74b939e))
135
- * **promise:** moved .reject from bluebird to native promise ([1d56da1](https://github.com/npm/cacache/commit/1d56da1))
136
- * **promise:** removed .fromNode, removed .join ([9c457a0](https://github.com/npm/cacache/commit/9c457a0))
137
- * **promise:** removed .map, replaced with p-map. removed .try ([cc3ee05](https://github.com/npm/cacache/commit/cc3ee05))
138
- * **promise:** removed .tap ([0260f12](https://github.com/npm/cacache/commit/0260f12))
139
- * **promise:** removed .using/.disposer ([5d832f3](https://github.com/npm/cacache/commit/5d832f3))
140
- * **promise:** removed bluebird ([c21298c](https://github.com/npm/cacache/commit/c21298c))
141
- * **promise:** removed bluebird specific .catch calls ([28aeeac](https://github.com/npm/cacache/commit/28aeeac))
142
- * **promise:** replaced .reduce and .mapSeries ([478f5cb](https://github.com/npm/cacache/commit/478f5cb))
143
-
144
- ### [12.0.3](https://github.com/npm/cacache/compare/v12.0.2...v12.0.3) (2019-08-19)
145
-
146
-
147
- ### Bug Fixes
148
-
149
- * do not chown if not running as root ([2d80af9](https://github.com/npm/cacache/commit/2d80af9))
150
-
151
-
152
-
153
- ### [12.0.2](https://github.com/npm/cacache/compare/v12.0.1...v12.0.2) (2019-07-19)
154
-
155
-
156
-
157
- ### [12.0.1](https://github.com/npm/cacache/compare/v12.0.0...v12.0.1) (2019-07-19)
158
-
159
- * **deps** Abstracted out `lib/util/infer-owner.js` to
160
- [@npmcli/infer-owner](https://www.npmjs.com/package/@npmcli/infer-owner)
161
- so that it could be more easily used in other parts of the npm CLI.
162
-
163
-
164
- ## [12.0.0](https://github.com/npm/cacache/compare/v11.3.3...v12.0.0) (2019-07-15)
165
-
166
-
167
- ### Features
168
-
169
- * infer uid/gid instead of accepting as options ([ac84d14](https://github.com/npm/cacache/commit/ac84d14))
170
- * **i18n:** add another error message ([676cb32](https://github.com/npm/cacache/commit/676cb32))
171
-
172
-
173
- ### BREAKING CHANGES
174
-
175
- * the uid gid options are no longer respected or
176
- necessary. As of this change, cacache will always match the cache
177
- contents to the ownership of the cache directory (or its parent
178
- directory), regardless of what the caller passes in.
179
-
180
- Reasoning:
181
-
182
- The number one reason to use a uid or gid option was to keep root-owned
183
- files from causing problems in the cache. In npm's case, this meant
184
- that CLI's ./lib/command.js had to work out the appropriate uid and gid,
185
- then pass it to the libnpmcommand module, which had to in turn pass the
186
- uid and gid to npm-registry-fetch, which then passed it to
187
- make-fetch-happen, which passed it to cacache. (For package fetching,
188
- pacote would be in that mix as well.)
189
-
190
- Added to that, `cacache.rm()` will actually _write_ a file into the
191
- cache index, but has no way to accept an option so that its call to
192
- entry-index.js will write the index with the appropriate uid/gid.
193
- Little ownership bugs were all over the place, and tricky to trace
194
- through. (Why should make-fetch-happen even care about accepting or
195
- passing uids and gids? It's an http library.)
196
-
197
- This change allows us to keep the cache from having mixed ownership in
198
- any situation.
199
-
200
- Of course, this _does_ mean that if you have a root-owned but
201
- user-writable folder (for example, `/tmp`), then the cache will try to
202
- chown everything to root.
203
-
204
- The solution is for the user to create a folder, make it user-owned, and
205
- use that, rather than relying on cacache to create the root cache folder.
206
-
207
- If we decide to restore the uid/gid opts, and use ownership inference
208
- only when uid/gid are unset, then take care to also make rm take an
209
- option object, and pass it through to entry-index.js.
210
-
211
-
212
-
213
- ### [11.3.3](https://github.com/npm/cacache/compare/v11.3.2...v11.3.3) (2019-06-17)
214
-
215
-
216
- ### Bug Fixes
217
-
218
- * **audit:** npm audit fix ([200a6d5](https://github.com/npm/cacache/commit/200a6d5))
219
- * **config:** Add ssri config 'error' option ([#146](https://github.com/npm/cacache/issues/146)) ([47de8f5](https://github.com/npm/cacache/commit/47de8f5))
220
- * **deps:** npm audit fix ([481a7dc](https://github.com/npm/cacache/commit/481a7dc))
221
- * **standard:** standard --fix ([7799149](https://github.com/npm/cacache/commit/7799149))
222
- * **write:** avoid another cb never called situation ([5156561](https://github.com/npm/cacache/commit/5156561))
223
-
224
-
225
-
226
- <a name="11.3.2"></a>
227
- ## [11.3.2](https://github.com/npm/cacache/compare/v11.3.1...v11.3.2) (2018-12-21)
228
-
229
-
230
- ### Bug Fixes
231
-
232
- * **get:** make sure to handle errors in the .then ([b10bcd0](https://github.com/npm/cacache/commit/b10bcd0))
233
-
234
-
235
-
236
- <a name="11.3.1"></a>
237
- ## [11.3.1](https://github.com/npm/cacache/compare/v11.3.0...v11.3.1) (2018-11-05)
238
-
239
-
240
- ### Bug Fixes
241
-
242
- * **get:** export hasContent.sync properly ([d76c920](https://github.com/npm/cacache/commit/d76c920))
243
-
244
-
245
-
246
- <a name="11.3.0"></a>
247
- # [11.3.0](https://github.com/npm/cacache/compare/v11.2.0...v11.3.0) (2018-11-05)
248
-
249
-
250
- ### Features
251
-
252
- * **get:** add sync API for reading ([db1e094](https://github.com/npm/cacache/commit/db1e094))
253
-
254
-
255
-
256
- <a name="11.2.0"></a>
257
- # [11.2.0](https://github.com/npm/cacache/compare/v11.1.0...v11.2.0) (2018-08-08)
258
-
259
-
260
- ### Features
261
-
262
- * **read:** add sync support to other internal read.js fns ([fe638b6](https://github.com/npm/cacache/commit/fe638b6))
263
-
264
-
265
-
266
- <a name="11.1.0"></a>
267
- # [11.1.0](https://github.com/npm/cacache/compare/v11.0.3...v11.1.0) (2018-08-01)
268
-
269
-
270
- ### Features
271
-
272
- * **read:** add sync support for low-level content read ([b43af83](https://github.com/npm/cacache/commit/b43af83))
273
-
274
-
275
-
276
- <a name="11.0.3"></a>
277
- ## [11.0.3](https://github.com/npm/cacache/compare/v11.0.2...v11.0.3) (2018-08-01)
278
-
279
-
280
- ### Bug Fixes
281
-
282
- * **config:** add ssri config options ([#136](https://github.com/npm/cacache/issues/136)) ([10d5d9a](https://github.com/npm/cacache/commit/10d5d9a))
283
- * **perf:** refactor content.read to avoid lstats ([c5ac10e](https://github.com/npm/cacache/commit/c5ac10e))
284
- * **test:** oops when removing safe-buffer ([1950490](https://github.com/npm/cacache/commit/1950490))
285
-
286
-
287
-
288
- <a name="11.0.2"></a>
289
- ## [11.0.2](https://github.com/npm/cacache/compare/v11.0.1...v11.0.2) (2018-05-07)
290
-
291
-
292
- ### Bug Fixes
293
-
294
- * **verify:** size param no longer lost in a verify ([#131](https://github.com/npm/cacache/issues/131)) ([c614a19](https://github.com/npm/cacache/commit/c614a19)), closes [#130](https://github.com/npm/cacache/issues/130)
295
-
296
-
297
-
298
- <a name="11.0.1"></a>
299
- ## [11.0.1](https://github.com/npm/cacache/compare/v11.0.0...v11.0.1) (2018-04-10)
300
-
301
-
302
-
303
- <a name="11.0.0"></a>
304
- # [11.0.0](https://github.com/npm/cacache/compare/v10.0.4...v11.0.0) (2018-04-09)
305
-
306
-
307
- ### Features
308
-
309
- * **opts:** use figgy-pudding for opts ([#128](https://github.com/npm/cacache/issues/128)) ([33d4eed](https://github.com/npm/cacache/commit/33d4eed))
310
-
311
-
312
- ### meta
313
-
314
- * drop support for node@4 ([529f347](https://github.com/npm/cacache/commit/529f347))
315
-
316
-
317
- ### BREAKING CHANGES
318
-
319
- * node@4 is no longer supported
320
-
321
-
322
-
323
- <a name="10.0.4"></a>
324
- ## [10.0.4](https://github.com/npm/cacache/compare/v10.0.3...v10.0.4) (2018-02-16)
325
-
326
-
327
-
328
- <a name="10.0.3"></a>
329
- ## [10.0.3](https://github.com/npm/cacache/compare/v10.0.2...v10.0.3) (2018-02-16)
330
-
331
-
332
- ### Bug Fixes
333
-
334
- * **content:** rethrow aggregate errors as ENOENT ([fa918f5](https://github.com/npm/cacache/commit/fa918f5))
335
-
336
-
337
-
338
- <a name="10.0.2"></a>
339
- ## [10.0.2](https://github.com/npm/cacache/compare/v10.0.1...v10.0.2) (2018-01-07)
340
-
341
-
342
- ### Bug Fixes
343
-
344
- * **ls:** deleted entries could cause a premature stream EOF ([347dc36](https://github.com/npm/cacache/commit/347dc36))
345
-
346
-
347
-
348
- <a name="10.0.1"></a>
349
- ## [10.0.1](https://github.com/npm/cacache/compare/v10.0.0...v10.0.1) (2017-11-15)
350
-
351
-
352
- ### Bug Fixes
353
-
354
- * **move-file:** actually use the fallback to `move-concurrently` (#110) ([073fbe1](https://github.com/npm/cacache/commit/073fbe1))
355
-
356
-
357
-
358
- <a name="10.0.0"></a>
359
- # [10.0.0](https://github.com/npm/cacache/compare/v9.3.0...v10.0.0) (2017-10-23)
360
-
361
-
362
- ### Features
363
-
364
- * **license:** relicense to ISC (#111) ([fdbb4e5](https://github.com/npm/cacache/commit/fdbb4e5))
365
-
366
-
367
- ### Performance Improvements
368
-
369
- * more copyFile benchmarks ([63787bb](https://github.com/npm/cacache/commit/63787bb))
370
-
371
-
372
- ### BREAKING CHANGES
373
-
374
- * **license:** the license has been changed from CC0-1.0 to ISC.
375
-
376
-
377
-
378
- <a name="9.3.0"></a>
379
- # [9.3.0](https://github.com/npm/cacache/compare/v9.2.9...v9.3.0) (2017-10-07)
380
-
381
-
382
- ### Features
383
-
384
- * **copy:** added cacache.get.copy api for fast copies (#107) ([067b5f6](https://github.com/npm/cacache/commit/067b5f6))
385
-
386
-
387
-
388
- <a name="9.2.9"></a>
389
- ## [9.2.9](https://github.com/npm/cacache/compare/v9.2.8...v9.2.9) (2017-06-17)
390
-
391
-
392
-
393
- <a name="9.2.8"></a>
394
- ## [9.2.8](https://github.com/npm/cacache/compare/v9.2.7...v9.2.8) (2017-06-05)
395
-
396
-
397
- ### Bug Fixes
398
-
399
- * **ssri:** bump ssri for bugfix ([c3232ea](https://github.com/npm/cacache/commit/c3232ea))
400
-
401
-
402
-
403
- <a name="9.2.7"></a>
404
- ## [9.2.7](https://github.com/npm/cacache/compare/v9.2.6...v9.2.7) (2017-06-05)
405
-
406
-
407
- ### Bug Fixes
408
-
409
- * **content:** make verified content completely read-only (#96) ([4131196](https://github.com/npm/cacache/commit/4131196))
410
-
411
-
412
-
413
- <a name="9.2.6"></a>
414
- ## [9.2.6](https://github.com/npm/cacache/compare/v9.2.5...v9.2.6) (2017-05-31)
415
-
416
-
417
- ### Bug Fixes
418
-
419
- * **node:** update ssri to prevent old node 4 crash ([5209ffe](https://github.com/npm/cacache/commit/5209ffe))
420
-
421
-
422
-
423
- <a name="9.2.5"></a>
424
- ## [9.2.5](https://github.com/npm/cacache/compare/v9.2.4...v9.2.5) (2017-05-25)
425
-
426
-
427
- ### Bug Fixes
428
-
429
- * **deps:** fix lockfile issues and bump ssri ([84e1d7e](https://github.com/npm/cacache/commit/84e1d7e))
430
-
431
-
432
-
433
- <a name="9.2.4"></a>
434
- ## [9.2.4](https://github.com/npm/cacache/compare/v9.2.3...v9.2.4) (2017-05-24)
435
-
436
-
437
- ### Bug Fixes
438
-
439
- * **deps:** bumping deps ([bbccb12](https://github.com/npm/cacache/commit/bbccb12))
440
-
441
-
442
-
443
- <a name="9.2.3"></a>
444
- ## [9.2.3](https://github.com/npm/cacache/compare/v9.2.2...v9.2.3) (2017-05-24)
445
-
446
-
447
- ### Bug Fixes
448
-
449
- * **rm:** stop crashing if content is missing on rm ([ac90bc0](https://github.com/npm/cacache/commit/ac90bc0))
450
-
451
-
452
-
453
- <a name="9.2.2"></a>
454
- ## [9.2.2](https://github.com/npm/cacache/compare/v9.2.1...v9.2.2) (2017-05-14)
455
-
456
-
457
- ### Bug Fixes
458
-
459
- * **i18n:** lets pretend this didn't happen ([519b4ee](https://github.com/npm/cacache/commit/519b4ee))
460
-
461
-
462
-
463
- <a name="9.2.1"></a>
464
- ## [9.2.1](https://github.com/npm/cacache/compare/v9.2.0...v9.2.1) (2017-05-14)
465
-
466
-
467
- ### Bug Fixes
468
-
469
- * **docs:** fixing translation messup ([bb9e4f9](https://github.com/npm/cacache/commit/bb9e4f9))
470
-
471
-
472
-
473
- <a name="9.2.0"></a>
474
- # [9.2.0](https://github.com/npm/cacache/compare/v9.1.0...v9.2.0) (2017-05-14)
475
-
476
-
477
- ### Features
478
-
479
- * **i18n:** add Spanish translation for API ([531f9a4](https://github.com/npm/cacache/commit/531f9a4))
480
-
481
-
482
-
483
- <a name="9.1.0"></a>
484
- # [9.1.0](https://github.com/npm/cacache/compare/v9.0.0...v9.1.0) (2017-05-14)
485
-
486
-
487
- ### Features
488
-
489
- * **i18n:** Add Spanish translation and i18n setup (#91) ([323b90c](https://github.com/npm/cacache/commit/323b90c))
490
-
491
-
492
-
493
- <a name="9.0.0"></a>
494
- # [9.0.0](https://github.com/npm/cacache/compare/v8.0.0...v9.0.0) (2017-04-28)
495
-
496
-
497
- ### Bug Fixes
498
-
499
- * **memoization:** actually use the LRU ([0e55dc9](https://github.com/npm/cacache/commit/0e55dc9))
500
-
501
-
502
- ### Features
503
-
504
- * **memoization:** memoizers can be injected through opts.memoize (#90) ([e5614c7](https://github.com/npm/cacache/commit/e5614c7))
505
-
506
-
507
- ### BREAKING CHANGES
508
-
509
- * **memoization:** If you were passing an object to opts.memoize, it will now be used as an injected memoization object. If you were only passing booleans and other non-objects through that option, no changes are needed.
510
-
511
-
512
-
513
- <a name="8.0.0"></a>
514
- # [8.0.0](https://github.com/npm/cacache/compare/v7.1.0...v8.0.0) (2017-04-22)
515
-
516
-
517
- ### Features
518
-
519
- * **read:** change hasContent to return {sri, size} (#88) ([bad6c49](https://github.com/npm/cacache/commit/bad6c49)), closes [#87](https://github.com/npm/cacache/issues/87)
520
-
521
-
522
- ### BREAKING CHANGES
523
-
524
- * **read:** hasContent now returns an object with `{sri, size}` instead of `sri`. Use `result.sri` anywhere that needed the old return value.
525
-
526
-
527
-
528
- <a name="7.1.0"></a>
529
- # [7.1.0](https://github.com/npm/cacache/compare/v7.0.5...v7.1.0) (2017-04-20)
530
-
531
-
532
- ### Features
533
-
534
- * **size:** handle content size info (#49) ([91230af](https://github.com/npm/cacache/commit/91230af))
535
-
536
-
537
-
538
- <a name="7.0.5"></a>
539
- ## [7.0.5](https://github.com/npm/cacache/compare/v7.0.4...v7.0.5) (2017-04-18)
540
-
541
-
542
- ### Bug Fixes
543
-
544
- * **integrity:** new ssri with fixed integrity stream ([6d13e8e](https://github.com/npm/cacache/commit/6d13e8e))
545
- * **write:** wrap stuff in promises to improve errors ([3624fc5](https://github.com/npm/cacache/commit/3624fc5))
546
-
547
-
548
-
549
- <a name="7.0.4"></a>
550
- ## [7.0.4](https://github.com/npm/cacache/compare/v7.0.3...v7.0.4) (2017-04-15)
551
-
552
-
553
- ### Bug Fixes
554
-
555
- * **fix-owner:** throw away ENOENTs on chownr ([d49bbcd](https://github.com/npm/cacache/commit/d49bbcd))
556
-
557
-
558
-
559
- <a name="7.0.3"></a>
560
- ## [7.0.3](https://github.com/npm/cacache/compare/v7.0.2...v7.0.3) (2017-04-05)
561
-
562
-
563
- ### Bug Fixes
564
-
565
- * **read:** fixing error message for integrity verification failures ([9d4f0a5](https://github.com/npm/cacache/commit/9d4f0a5))
566
-
567
-
568
-
569
- <a name="7.0.2"></a>
570
- ## [7.0.2](https://github.com/npm/cacache/compare/v7.0.1...v7.0.2) (2017-04-03)
571
-
572
-
573
- ### Bug Fixes
574
-
575
- * **integrity:** use EINTEGRITY error code and update ssri ([8dc2e62](https://github.com/npm/cacache/commit/8dc2e62))
576
-
577
-
578
-
579
- <a name="7.0.1"></a>
580
- ## [7.0.1](https://github.com/npm/cacache/compare/v7.0.0...v7.0.1) (2017-04-03)
581
-
582
-
583
- ### Bug Fixes
584
-
585
- * **docs:** fix header name conflict in readme ([afcd456](https://github.com/npm/cacache/commit/afcd456))
586
-
587
-
588
-
589
- <a name="7.0.0"></a>
590
- # [7.0.0](https://github.com/npm/cacache/compare/v6.3.0...v7.0.0) (2017-04-03)
591
-
592
-
593
- ### Bug Fixes
594
-
595
- * **test:** fix content.write tests when running in docker ([d2e9b6a](https://github.com/npm/cacache/commit/d2e9b6a))
596
-
597
-
598
- ### Features
599
-
600
- * **integrity:** subresource integrity support (#78) ([b1e731f](https://github.com/npm/cacache/commit/b1e731f))
601
-
602
-
603
- ### BREAKING CHANGES
604
-
605
- * **integrity:** The entire API has been overhauled to use SRI hashes instead of digest/hashAlgorithm pairs. SRI hashes follow the Subresource Integrity standard and support strings and objects compatible with [`ssri`](https://npm.im/ssri).
606
-
607
- * This change bumps the index version, which will invalidate all previous index entries. Content entries will remain intact, and existing caches will automatically reuse any content from before this breaking change.
608
-
609
- * `cacache.get.info()`, `cacache.ls()`, and `cacache.ls.stream()` will now return objects that looks like this:
610
-
611
- ```
612
- {
613
- key: String,
614
- integrity: '<algorithm>-<base64hash>',
615
- path: ContentPath,
616
- time: Date<ms>,
617
- metadata: Any
618
- }
619
- ```
620
-
621
- * `opts.digest` and `opts.hashAlgorithm` are obsolete for any API calls that used them.
622
-
623
- * Anywhere `opts.digest` was accepted, `opts.integrity` is now an option. Any valid SRI hash is accepted here -- multiple hash entries will be resolved according to the standard: first, the "strongest" hash algorithm will be picked, and then each of the entries for that algorithm will be matched against the content. Content will be validated if *any* of the entries match (so, a single integrity string can be used for multiple "versions" of the same document/data).
624
-
625
- * `put.byDigest()`, `put.stream.byDigest`, `get.byDigest()` and `get.stream.byDigest()` now expect an SRI instead of a `digest` + `opts.hashAlgorithm` pairing.
626
-
627
- * `get.hasContent()` now expects an integrity hash instead of a digest. If content exists, it will return the specific single integrity hash that was found in the cache.
628
-
629
- * `verify()` has learned to handle integrity-based caches, and forgotten how to handle old-style cache indices due to the format change.
630
-
631
- * `cacache.rm.content()` now expects an integrity hash instead of a hex digest.
632
-
633
-
634
-
635
- <a name="6.3.0"></a>
636
- # [6.3.0](https://github.com/npm/cacache/compare/v6.2.0...v6.3.0) (2017-04-01)
637
-
638
-
639
- ### Bug Fixes
640
-
641
- * **fixOwner:** ignore EEXIST race condition from mkdirp ([4670e9b](https://github.com/npm/cacache/commit/4670e9b))
642
- * **index:** ignore index removal races when inserting ([b9d2fa2](https://github.com/npm/cacache/commit/b9d2fa2))
643
- * **memo:** use lru-cache for better mem management (#75) ([d8ac5aa](https://github.com/npm/cacache/commit/d8ac5aa))
644
-
645
-
646
- ### Features
647
-
648
- * **dependencies:** Switch to move-concurrently (#77) ([dc6482d](https://github.com/npm/cacache/commit/dc6482d))
649
-
650
-
651
-
652
- <a name="6.2.0"></a>
653
- # [6.2.0](https://github.com/npm/cacache/compare/v6.1.2...v6.2.0) (2017-03-15)
654
-
655
-
656
- ### Bug Fixes
657
-
658
- * **index:** additional bucket entry verification with checksum (#72) ([f8e0f25](https://github.com/npm/cacache/commit/f8e0f25))
659
- * **verify:** return fixOwner.chownr promise ([6818521](https://github.com/npm/cacache/commit/6818521))
660
-
661
-
662
- ### Features
663
-
664
- * **tmp:** safe tmp dir creation/management util (#73) ([c42da71](https://github.com/npm/cacache/commit/c42da71))
665
-
666
-
667
-
668
- <a name="6.1.2"></a>
669
- ## [6.1.2](https://github.com/npm/cacache/compare/v6.1.1...v6.1.2) (2017-03-13)
670
-
671
-
672
- ### Bug Fixes
673
-
674
- * **index:** set default hashAlgorithm ([d6eb2f0](https://github.com/npm/cacache/commit/d6eb2f0))
675
-
676
-
677
-
678
- <a name="6.1.1"></a>
679
- ## [6.1.1](https://github.com/npm/cacache/compare/v6.1.0...v6.1.1) (2017-03-13)
680
-
681
-
682
- ### Bug Fixes
683
-
684
- * **coverage:** bumping coverage for verify (#71) ([0b7faf6](https://github.com/npm/cacache/commit/0b7faf6))
685
- * **deps:** glob should have been a regular dep :< ([0640bc4](https://github.com/npm/cacache/commit/0640bc4))
686
-
687
-
688
-
689
- <a name="6.1.0"></a>
690
- # [6.1.0](https://github.com/npm/cacache/compare/v6.0.2...v6.1.0) (2017-03-12)
691
-
692
-
693
- ### Bug Fixes
694
-
695
- * **coverage:** more coverage for content reads (#70) ([ef4f70a](https://github.com/npm/cacache/commit/ef4f70a))
696
- * **tests:** use safe-buffer because omfg (#69) ([6ab8132](https://github.com/npm/cacache/commit/6ab8132))
697
-
698
-
699
- ### Features
700
-
701
- * **rm:** limited rm.all and fixed bugs (#66) ([d5d25ba](https://github.com/npm/cacache/commit/d5d25ba)), closes [#66](https://github.com/npm/cacache/issues/66)
702
- * **verify:** tested, working cache verifier/gc (#68) ([45ad77a](https://github.com/npm/cacache/commit/45ad77a))
703
-
704
-
705
-
706
- <a name="6.0.2"></a>
707
- ## [6.0.2](https://github.com/npm/cacache/compare/v6.0.1...v6.0.2) (2017-03-11)
708
-
709
-
710
- ### Bug Fixes
711
-
712
- * **index:** segment cache items with another subbucket (#64) ([c3644e5](https://github.com/npm/cacache/commit/c3644e5))
713
-
714
-
715
-
716
- <a name="6.0.1"></a>
717
- ## [6.0.1](https://github.com/npm/cacache/compare/v6.0.0...v6.0.1) (2017-03-05)
718
-
719
-
720
- ### Bug Fixes
721
-
722
- * **docs:** Missed spots in README ([8ffb7fa](https://github.com/npm/cacache/commit/8ffb7fa))
723
-
724
-
725
-
726
- <a name="6.0.0"></a>
727
- # [6.0.0](https://github.com/npm/cacache/compare/v5.0.3...v6.0.0) (2017-03-05)
728
-
729
-
730
- ### Bug Fixes
731
-
732
- * **api:** keep memo cache mostly-internal ([2f72d0a](https://github.com/npm/cacache/commit/2f72d0a))
733
- * **content:** use the rest of the string, not the whole string ([fa8f3c3](https://github.com/npm/cacache/commit/fa8f3c3))
734
- * **deps:** removed `format-number@2.0.2` ([1187791](https://github.com/npm/cacache/commit/1187791))
735
- * **deps:** removed inflight@1.0.6 ([0d1819c](https://github.com/npm/cacache/commit/0d1819c))
736
- * **deps:** rimraf@2.6.1 ([9efab6b](https://github.com/npm/cacache/commit/9efab6b))
737
- * **deps:** standard@9.0.0 ([4202cba](https://github.com/npm/cacache/commit/4202cba))
738
- * **deps:** tap@10.3.0 ([aa03088](https://github.com/npm/cacache/commit/aa03088))
739
- * **deps:** weallcontribute@1.0.8 ([ad4f4dc](https://github.com/npm/cacache/commit/ad4f4dc))
740
- * **docs:** add security note to hashKey ([03f81ba](https://github.com/npm/cacache/commit/03f81ba))
741
- * **hashes:** change default hashAlgorithm to sha512 ([ea00ba6](https://github.com/npm/cacache/commit/ea00ba6))
742
- * **hashes:** missed a spot for hashAlgorithm defaults ([45997d8](https://github.com/npm/cacache/commit/45997d8))
743
- * **index:** add length header before JSON for verification ([fb8cb4d](https://github.com/npm/cacache/commit/fb8cb4d))
744
- * **index:** change index filenames to sha1s of keys ([bbc5fca](https://github.com/npm/cacache/commit/bbc5fca))
745
- * **index:** who cares about race conditions anyway ([b1d3888](https://github.com/npm/cacache/commit/b1d3888))
746
- * **perf:** bulk-read get+read for massive speed ([d26cdf9](https://github.com/npm/cacache/commit/d26cdf9))
747
- * **perf:** use bulk file reads for index reads ([79a8891](https://github.com/npm/cacache/commit/79a8891))
748
- * **put-stream:** remove tmp file on stream insert error ([65f6632](https://github.com/npm/cacache/commit/65f6632))
749
- * **put-stream:** robustified and predictibilized ([daf9e08](https://github.com/npm/cacache/commit/daf9e08))
750
- * **put-stream:** use new promise API for moves ([1d36013](https://github.com/npm/cacache/commit/1d36013))
751
- * **readme:** updated to reflect new default hashAlgo ([c60a2fa](https://github.com/npm/cacache/commit/c60a2fa))
752
- * **verify:** tiny typo fix ([db22d05](https://github.com/npm/cacache/commit/db22d05))
753
-
754
-
755
- ### Features
756
-
757
- * **api:** converted external api ([7bf032f](https://github.com/npm/cacache/commit/7bf032f))
758
- * **cacache:** exported clearMemoized() utility ([8d2c5b6](https://github.com/npm/cacache/commit/8d2c5b6))
759
- * **cache:** add versioning to content and index ([31bc549](https://github.com/npm/cacache/commit/31bc549))
760
- * **content:** collate content files into subdirs ([c094d9f](https://github.com/npm/cacache/commit/c094d9f))
761
- * **deps:** `@npmcorp/move@1.0.0` ([bdd00bf](https://github.com/npm/cacache/commit/bdd00bf))
762
- * **deps:** `bluebird@3.4.7` ([3a17aff](https://github.com/npm/cacache/commit/3a17aff))
763
- * **deps:** `promise-inflight@1.0.1` ([a004fe6](https://github.com/npm/cacache/commit/a004fe6))
764
- * **get:** added memoization support for get ([c77d794](https://github.com/npm/cacache/commit/c77d794))
765
- * **get:** export hasContent ([2956ec3](https://github.com/npm/cacache/commit/2956ec3))
766
- * **index:** add hashAlgorithm and format insert ret val ([b639746](https://github.com/npm/cacache/commit/b639746))
767
- * **index:** collate index files into subdirs ([e8402a5](https://github.com/npm/cacache/commit/e8402a5))
768
- * **index:** promisify entry index ([cda3335](https://github.com/npm/cacache/commit/cda3335))
769
- * **memo:** added memoization lib ([da07b92](https://github.com/npm/cacache/commit/da07b92))
770
- * **memo:** export memoization api ([954b1b3](https://github.com/npm/cacache/commit/954b1b3))
771
- * **move-file:** add move fallback for weird errors ([5cf4616](https://github.com/npm/cacache/commit/5cf4616))
772
- * **perf:** bulk content write api ([51b536e](https://github.com/npm/cacache/commit/51b536e))
773
- * **put:** added memoization support to put ([b613a70](https://github.com/npm/cacache/commit/b613a70))
774
- * **read:** switched to promises ([a869362](https://github.com/npm/cacache/commit/a869362))
775
- * **rm:** added memoization support to rm ([4205cf0](https://github.com/npm/cacache/commit/4205cf0))
776
- * **rm:** switched to promises ([a000d24](https://github.com/npm/cacache/commit/a000d24))
777
- * **util:** promise-inflight ownership fix requests ([9517cd7](https://github.com/npm/cacache/commit/9517cd7))
778
- * **util:** use promises for api ([ae204bb](https://github.com/npm/cacache/commit/ae204bb))
779
- * **verify:** converted to Promises ([f0b3974](https://github.com/npm/cacache/commit/f0b3974))
780
-
781
-
782
- ### BREAKING CHANGES
783
-
784
- * cache: index/content directories are now versioned. Previous caches are no longer compatible and cannot be migrated.
785
- * util: fix-owner now uses Promises instead of callbacks
786
- * index: Previously-generated index entries are no longer compatible and the index must be regenerated.
787
- * index: The index format has changed and previous caches are no longer compatible. Existing caches will need to be regenerated.
788
- * hashes: Default hashAlgorithm changed from sha1 to sha512. If you
789
- rely on the prior setting, pass `opts.hashAlgorithm` in explicitly.
790
- * content: Previously-generated content directories are no longer compatible
791
- and must be regenerated.
792
- * verify: API is now promise-based
793
- * read: Switches to a Promise-based API and removes callback stuff
794
- * rm: Switches to a Promise-based API and removes callback stuff
795
- * index: this changes the API to work off promises instead of callbacks
796
- * api: this means we are going all in on promises now