cacache 12.0.4 → 15.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 +108 -2
- package/README.md +66 -38
- package/get.js +173 -165
- package/index.js +39 -1
- package/lib/content/.write.js.swp +0 -0
- package/lib/content/path.js +7 -4
- package/lib/content/read.js +128 -73
- package/lib/content/rm.js +8 -9
- package/lib/content/write.js +126 -106
- package/lib/entry-index.js +144 -127
- package/lib/memoization.js +15 -10
- package/lib/util/disposer.js +30 -0
- package/lib/util/fix-owner.js +36 -19
- package/lib/util/hash-to-segments.js +1 -5
- package/lib/util/move-file.js +45 -28
- package/lib/util/tmp.js +11 -13
- package/lib/verify.js +168 -108
- package/ls.js +1 -1
- package/package.json +30 -31
- package/put.js +65 -67
- package/rm.js +5 -2
- package/README.es.md +0 -628
- package/en.js +0 -3
- package/es.js +0 -3
- package/lib/util/y.js +0 -25
- package/locales/en.js +0 -47
- package/locales/en.json +0 -7
- package/locales/es.js +0 -49
- package/locales/es.json +0 -6
package/CHANGELOG.md
CHANGED
|
@@ -2,9 +2,115 @@
|
|
|
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
|
-
|
|
5
|
+
## [15.0.0](https://github.com/npm/cacache/compare/v14.0.0...v15.0.0) (2020-02-18)
|
|
6
6
|
|
|
7
7
|
|
|
8
|
+
### ⚠ BREAKING CHANGES
|
|
9
|
+
|
|
10
|
+
* drop figgy-pudding and use canonical option names.
|
|
11
|
+
|
|
12
|
+
### Features
|
|
13
|
+
|
|
14
|
+
* remove figgy-pudding ([57d11bc](https://github.com/npm/cacache/commit/57d11bce34f979247d1057d258acc204c4944491))
|
|
15
|
+
|
|
16
|
+
## [14.0.0](https://github.com/npm/cacache/compare/v13.0.1...v14.0.0) (2020-01-28)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### ⚠ BREAKING CHANGES
|
|
20
|
+
|
|
21
|
+
* **deps:** bumps engines to >= 10
|
|
22
|
+
|
|
23
|
+
* **deps:** tar v6 and mkdirp v1 ([5a66e7a](https://github.com/npm/cacache/commit/5a66e7a))
|
|
24
|
+
|
|
25
|
+
### [13.0.1](https://github.com/npm/cacache/compare/v13.0.0...v13.0.1) (2019-09-30)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### Bug Fixes
|
|
29
|
+
|
|
30
|
+
* **fix-owner:** chownr.sync quits on non-root uid ([08801be](https://github.com/npm/cacache/commit/08801be))
|
|
31
|
+
|
|
32
|
+
## [13.0.0](https://github.com/npm/cacache/compare/v12.0.3...v13.0.0) (2019-09-25)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
### ⚠ BREAKING CHANGES
|
|
36
|
+
|
|
37
|
+
* This subtly changes the streaming interface of
|
|
38
|
+
everything in cacache that streams, which is, well, everything in
|
|
39
|
+
cacache. Most users will probably not notice, but any code that
|
|
40
|
+
depended on stream behavior always being deferred until next tick will
|
|
41
|
+
need to adjust.
|
|
42
|
+
|
|
43
|
+
The mississippi methods 'to', 'from', 'through', and so on, have been
|
|
44
|
+
replaced with their Minipass counterparts, and streaming interaction
|
|
45
|
+
with the file system is done via fs-minipass.
|
|
46
|
+
|
|
47
|
+
The following modules are of interest here:
|
|
48
|
+
|
|
49
|
+
- [minipass](http://npm.im/minipass) The core stream library.
|
|
50
|
+
|
|
51
|
+
- [fs-minipass](http://npm.im/fs-minipass) Note that the 'WriteStream'
|
|
52
|
+
class from fs-minipass is _not_ a Minipass stream, but rather a plain
|
|
53
|
+
old EventEmitter that duck types as a Writable.
|
|
54
|
+
|
|
55
|
+
- [minipass-collect](http://npm.im/minipass-collect) Gather up all the
|
|
56
|
+
data from a stream. Cacache only uses Collect.PassThrough, which is a
|
|
57
|
+
basic Minipass passthrough stream which emits a 'collect' event with
|
|
58
|
+
the completed data just before the 'end' event.
|
|
59
|
+
|
|
60
|
+
- [minipass-pipeline](http://npm.im/minipass-pipeline) Connect one or
|
|
61
|
+
more streams into a pipe chain. Errors anywhere in the pipeline are
|
|
62
|
+
proxied down the chain and then up to the Pipeline object itself.
|
|
63
|
+
Writes go into the head, reads go to the tail. Used in place of
|
|
64
|
+
pump() and pumpify().
|
|
65
|
+
|
|
66
|
+
- [minipass-flush](http://npm.im/minipass-flush) A Minipass passthrough
|
|
67
|
+
stream that defers its 'end' event until after a flush() method has
|
|
68
|
+
completed (either calling the supplied callback, or returning a
|
|
69
|
+
promise.) Use in place of flush-write-stream (aka mississippi.to).
|
|
70
|
+
|
|
71
|
+
Streams from through2, concat-stream, and the behavior provided by
|
|
72
|
+
end-of-stream are all implemented in Minipass itself.
|
|
73
|
+
|
|
74
|
+
Features of interest to cacache, which make Minipass a particularly good
|
|
75
|
+
fit:
|
|
76
|
+
|
|
77
|
+
- All of the 'endish' events are normalized, so we can just listen on
|
|
78
|
+
'end' and know that finish, prefinish, and close will be handled as
|
|
79
|
+
well.
|
|
80
|
+
- Minipass doesn't waste time [containing
|
|
81
|
+
zalgo](https://blog.izs.me/2013/08/designing-apis-for-asynchrony).
|
|
82
|
+
- Minipass has built-in support for promises that indicate the end or
|
|
83
|
+
error: stream.promise(), stream.collect(), and stream.concat().
|
|
84
|
+
- With reliable and consistent timing guarantees, much less
|
|
85
|
+
error-checking logic is required. We can be more confident that an
|
|
86
|
+
error is being thrown or emitted in the correct place, rather than in
|
|
87
|
+
a callback which is deferred, resulting in a hung promise or
|
|
88
|
+
uncaughtException.
|
|
89
|
+
|
|
90
|
+
The biggest downside of Minipass is that it lacks some of the internal
|
|
91
|
+
characteristics of node-core streams, which many community modules use
|
|
92
|
+
to identify streams. They have no _writableState or _readableState
|
|
93
|
+
objects, or _read or _write methods. As a result, the is-stream module
|
|
94
|
+
(at least, at the time of this commit) doesn't recognize Minipass
|
|
95
|
+
streams as readable or writable streams.
|
|
96
|
+
|
|
97
|
+
All in all, the changes required of downstream users should be minimal,
|
|
98
|
+
but are unlikely to be zero. Hence the semver major change.
|
|
99
|
+
|
|
100
|
+
### Features
|
|
101
|
+
|
|
102
|
+
* replace all streams with Minipass streams ([f4c0962](https://github.com/npm/cacache/commit/f4c0962))
|
|
103
|
+
* **deps:** Add minipass and minipass-pipeline ([a6545a9](https://github.com/npm/cacache/commit/a6545a9))
|
|
104
|
+
* **promise:** converted .resolve to native promise, converted .map and .reduce to native ([220c56d](https://github.com/npm/cacache/commit/220c56d))
|
|
105
|
+
* **promise:** individually promisifing functions as needed ([74b939e](https://github.com/npm/cacache/commit/74b939e))
|
|
106
|
+
* **promise:** moved .reject from bluebird to native promise ([1d56da1](https://github.com/npm/cacache/commit/1d56da1))
|
|
107
|
+
* **promise:** removed .fromNode, removed .join ([9c457a0](https://github.com/npm/cacache/commit/9c457a0))
|
|
108
|
+
* **promise:** removed .map, replaced with p-map. removed .try ([cc3ee05](https://github.com/npm/cacache/commit/cc3ee05))
|
|
109
|
+
* **promise:** removed .tap ([0260f12](https://github.com/npm/cacache/commit/0260f12))
|
|
110
|
+
* **promise:** removed .using/.disposer ([5d832f3](https://github.com/npm/cacache/commit/5d832f3))
|
|
111
|
+
* **promise:** removed bluebird ([c21298c](https://github.com/npm/cacache/commit/c21298c))
|
|
112
|
+
* **promise:** removed bluebird specific .catch calls ([28aeeac](https://github.com/npm/cacache/commit/28aeeac))
|
|
113
|
+
* **promise:** replaced .reduce and .mapSeries ([478f5cb](https://github.com/npm/cacache/commit/478f5cb))
|
|
8
114
|
|
|
9
115
|
### [12.0.3](https://github.com/npm/cacache/compare/v12.0.2...v12.0.3) (2019-08-19)
|
|
10
116
|
|
|
@@ -69,7 +175,7 @@ chown everything to root.
|
|
|
69
175
|
The solution is for the user to create a folder, make it user-owned, and
|
|
70
176
|
use that, rather than relying on cacache to create the root cache folder.
|
|
71
177
|
|
|
72
|
-
If we decide to restore the uid/gid opts, and use ownership
|
|
178
|
+
If we decide to restore the uid/gid opts, and use ownership inference
|
|
73
179
|
only when uid/gid are unset, then take care to also make rm take an
|
|
74
180
|
option object, and pass it through to entry-index.js.
|
|
75
181
|
|
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`
|
|
@@ -35,12 +33,10 @@ _Translations: [español](README.es.md)_
|
|
|
35
33
|
* Writing
|
|
36
34
|
* [`put`](#put-data)
|
|
37
35
|
* [`put.stream`](#put-stream)
|
|
38
|
-
* [`put*` opts](#put-options)
|
|
39
36
|
* [`rm.all`](#rm-all)
|
|
40
37
|
* [`rm.entry`](#rm-entry)
|
|
41
38
|
* [`rm.content`](#rm-content)
|
|
42
39
|
* Utilities
|
|
43
|
-
* [`setLocale`](#set-locale)
|
|
44
40
|
* [`clearMemoized`](#clear-memoized)
|
|
45
41
|
* [`tmp.mkdir`](#tmp-mkdir)
|
|
46
42
|
* [`tmp.withTmp`](#with-tmp)
|
|
@@ -52,7 +48,7 @@ _Translations: [español](README.es.md)_
|
|
|
52
48
|
### Example
|
|
53
49
|
|
|
54
50
|
```javascript
|
|
55
|
-
const cacache = require('cacache
|
|
51
|
+
const cacache = require('cacache')
|
|
56
52
|
const fs = require('fs')
|
|
57
53
|
|
|
58
54
|
const tarball = '/path/to/mytar.tgz'
|
|
@@ -95,7 +91,7 @@ cacache.get.byDigest(cachePath, integrityHash).then(data => {
|
|
|
95
91
|
* Lockless, high-concurrency cache access
|
|
96
92
|
* Streaming support
|
|
97
93
|
* Promise support
|
|
98
|
-
*
|
|
94
|
+
* Fast -- sub-millisecond reads and writes including verification
|
|
99
95
|
* Arbitrary metadata storage
|
|
100
96
|
* Garbage collection and additional offline verification
|
|
101
97
|
* Thorough test coverage
|
|
@@ -113,21 +109,6 @@ Happy hacking!
|
|
|
113
109
|
|
|
114
110
|
### API
|
|
115
111
|
|
|
116
|
-
#### <a name="localized-api"></a> Using localized APIs
|
|
117
|
-
|
|
118
|
-
cacache includes a complete API in English, with the same features as other
|
|
119
|
-
translations. To use the English API as documented in this README, use
|
|
120
|
-
`require('cacache/en')`. This is also currently the default if you do
|
|
121
|
-
`require('cacache')`, but may change in the future.
|
|
122
|
-
|
|
123
|
-
cacache also supports other languages! You can find the list of currently
|
|
124
|
-
supported ones by looking in `./locales` in the source directory. You can use
|
|
125
|
-
the API in that language with `require('cacache/<lang>')`.
|
|
126
|
-
|
|
127
|
-
Want to add support for a new language? Please go ahead! You should be able to
|
|
128
|
-
copy `./locales/en.js` and `./locales/en.json` and fill them in. Translating the
|
|
129
|
-
`README.md` is a bit more work, but also appreciated if you get around to it. 👍🏼
|
|
130
|
-
|
|
131
112
|
#### <a name="ls"></a> `> cacache.ls(cache) -> Promise<Object>`
|
|
132
113
|
|
|
133
114
|
Lists info for all entries currently in the cache as a single large object. Each
|
|
@@ -219,6 +200,8 @@ A sub-function, `get.byDigest` may be used for identical behavior, except lookup
|
|
|
219
200
|
will happen by integrity hash, bypassing the index entirely. This version of the
|
|
220
201
|
function *only* returns `data` itself, without any wrapper.
|
|
221
202
|
|
|
203
|
+
See: [options](#get-options)
|
|
204
|
+
|
|
222
205
|
##### Note
|
|
223
206
|
|
|
224
207
|
This function loads the entire cache entry into memory before returning it. If
|
|
@@ -260,6 +243,8 @@ A sub-function, `get.stream.byDigest` may be used for identical behavior,
|
|
|
260
243
|
except lookup will happen by integrity hash, bypassing the index entirely. This
|
|
261
244
|
version does not emit the `metadata` and `integrity` events at all.
|
|
262
245
|
|
|
246
|
+
See: [options](#get-options)
|
|
247
|
+
|
|
263
248
|
##### Example
|
|
264
249
|
|
|
265
250
|
```javascript
|
|
@@ -346,12 +331,33 @@ cacache.get.hasContent(cachePath, 'sha521-NOT+IN/CACHE==').then(console.log)
|
|
|
346
331
|
false
|
|
347
332
|
```
|
|
348
333
|
|
|
334
|
+
##### <a name="get-options"></a> Options
|
|
335
|
+
|
|
336
|
+
##### `opts.integrity`
|
|
337
|
+
If present, the pre-calculated digest for the inserted content. If this option
|
|
338
|
+
is provided and does not match the post-insertion digest, insertion will fail
|
|
339
|
+
with an `EINTEGRITY` error.
|
|
340
|
+
|
|
341
|
+
##### `opts.memoize`
|
|
342
|
+
|
|
343
|
+
Default: null
|
|
344
|
+
|
|
345
|
+
If explicitly truthy, cacache will read from memory and memoize data on bulk read. If `false`, cacache will read from disk data. Reader functions by default read from in-memory cache.
|
|
346
|
+
|
|
347
|
+
##### `opts.size`
|
|
348
|
+
If provided, the data stream will be verified to check that enough data was
|
|
349
|
+
passed through. If there's more or less data than expected, insertion will fail
|
|
350
|
+
with an `EBADSIZE` error.
|
|
351
|
+
|
|
352
|
+
|
|
349
353
|
#### <a name="put-data"></a> `> cacache.put(cache, key, data, [opts]) -> Promise`
|
|
350
354
|
|
|
351
355
|
Inserts data passed to it into the cache. The returned Promise resolves with a
|
|
352
356
|
digest (generated according to [`opts.algorithms`](#optsalgorithms)) after the
|
|
353
357
|
cache entry has been successfully written.
|
|
354
358
|
|
|
359
|
+
See: [options](#put-options)
|
|
360
|
+
|
|
355
361
|
##### Example
|
|
356
362
|
|
|
357
363
|
```javascript
|
|
@@ -371,6 +377,8 @@ Stream](https://nodejs.org/api/stream.html#stream_writable_streams) that inserts
|
|
|
371
377
|
data written to it into the cache. Emits an `integrity` event with the digest of
|
|
372
378
|
written contents when it succeeds.
|
|
373
379
|
|
|
380
|
+
See: [options](#put-options)
|
|
381
|
+
|
|
374
382
|
##### Example
|
|
375
383
|
|
|
376
384
|
```javascript
|
|
@@ -383,9 +391,7 @@ request.get(
|
|
|
383
391
|
)
|
|
384
392
|
```
|
|
385
393
|
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
`cacache.put` functions have a number of options in common.
|
|
394
|
+
##### <a name="put-options"></a> Options
|
|
389
395
|
|
|
390
396
|
##### `opts.metadata`
|
|
391
397
|
|
|
@@ -400,7 +406,7 @@ with an `EBADSIZE` error.
|
|
|
400
406
|
##### `opts.integrity`
|
|
401
407
|
|
|
402
408
|
If present, the pre-calculated digest for the inserted content. If this option
|
|
403
|
-
|
|
409
|
+
is provided and does not match the post-insertion digest, insertion will fail
|
|
404
410
|
with an `EINTEGRITY` error.
|
|
405
411
|
|
|
406
412
|
`algorithms` has no effect if this option is present.
|
|
@@ -433,6 +439,11 @@ cache.
|
|
|
433
439
|
Reading from disk data can be forced by explicitly passing `memoize: false` to
|
|
434
440
|
the reader functions, but their default will be to read from memory.
|
|
435
441
|
|
|
442
|
+
##### `opts.tmpPrefix`
|
|
443
|
+
Default: null
|
|
444
|
+
|
|
445
|
+
Prefix to append on the temporary directory name inside the cache's tmp dir.
|
|
446
|
+
|
|
436
447
|
#### <a name="rm-all"></a> `> cacache.rm.all(cache) -> Promise`
|
|
437
448
|
|
|
438
449
|
Clears the entire cache. Mainly by blowing away the cache directory itself.
|
|
@@ -478,14 +489,6 @@ cacache.rm.content(cachePath, 'sha512-SoMeDIGest/IN+BaSE64==').then(() => {
|
|
|
478
489
|
})
|
|
479
490
|
```
|
|
480
491
|
|
|
481
|
-
#### <a name="set-locale"></a> `> cacache.setLocale(locale)`
|
|
482
|
-
|
|
483
|
-
Configure the language/locale used for messages and errors coming from cacache.
|
|
484
|
-
The list of available locales is in the `./locales` directory in the project
|
|
485
|
-
root.
|
|
486
|
-
|
|
487
|
-
_Interested in contributing more languages! [Submit a PR](CONTRIBUTING.md)!_
|
|
488
|
-
|
|
489
492
|
#### <a name="clear-memoized"></a> `> cacache.clearMemoized()`
|
|
490
493
|
|
|
491
494
|
Completely resets the in-memory entry cache.
|
|
@@ -504,6 +507,8 @@ permissions.
|
|
|
504
507
|
If you want automatic cleanup of this directory, use
|
|
505
508
|
[`tmp.withTmp()`](#with-tpm)
|
|
506
509
|
|
|
510
|
+
See: [options](#tmp-options)
|
|
511
|
+
|
|
507
512
|
##### Example
|
|
508
513
|
|
|
509
514
|
```javascript
|
|
@@ -537,12 +542,14 @@ cacache.tmp.mkdir(cache).then(dir => {
|
|
|
537
542
|
|
|
538
543
|
Creates a temporary directory with [`tmp.mkdir()`](#tmp-mkdir) and calls `cb`
|
|
539
544
|
with it. The created temporary directory will be removed when the return value
|
|
540
|
-
of `cb()` resolves
|
|
541
|
-
|
|
545
|
+
of `cb()` resolves, the tmp directory will be automatically deleted once that
|
|
546
|
+
promise completes.
|
|
542
547
|
|
|
543
548
|
The same caveats apply when it comes to managing permissions for the tmp dir's
|
|
544
549
|
contents.
|
|
545
550
|
|
|
551
|
+
See: [options](#tmp-options)
|
|
552
|
+
|
|
546
553
|
##### Example
|
|
547
554
|
|
|
548
555
|
```javascript
|
|
@@ -553,6 +560,13 @@ cacache.tmp.withTmp(cache, dir => {
|
|
|
553
560
|
})
|
|
554
561
|
```
|
|
555
562
|
|
|
563
|
+
##### <a name="tmp-options"></a> Options
|
|
564
|
+
|
|
565
|
+
##### `opts.tmpPrefix`
|
|
566
|
+
Default: null
|
|
567
|
+
|
|
568
|
+
Prefix to append on the temporary directory name inside the cache's tmp dir.
|
|
569
|
+
|
|
556
570
|
#### <a name="integrity"></a> Subresource Integrity Digests
|
|
557
571
|
|
|
558
572
|
For content verification and addressing, cacache uses strings following the
|
|
@@ -608,10 +622,24 @@ When it's done, it'll return an object with various stats about the verification
|
|
|
608
622
|
process, including amount of storage reclaimed, number of valid entries, number
|
|
609
623
|
of entries removed, etc.
|
|
610
624
|
|
|
611
|
-
##### Options
|
|
625
|
+
##### <a name="verify-options"></a> Options
|
|
626
|
+
|
|
627
|
+
##### `opts.concurrency`
|
|
612
628
|
|
|
613
|
-
|
|
614
|
-
|
|
629
|
+
Default: 20
|
|
630
|
+
|
|
631
|
+
Number of concurrently read files in the filesystem while doing clean up.
|
|
632
|
+
|
|
633
|
+
##### `opts.filter`
|
|
634
|
+
Receives a formatted entry. Return false to remove it.
|
|
635
|
+
Note: might be called more than once on the same entry.
|
|
636
|
+
|
|
637
|
+
##### `opts.log`
|
|
638
|
+
Custom logger function:
|
|
639
|
+
```
|
|
640
|
+
log: { silly () {} }
|
|
641
|
+
log.silly('verify', 'verifying cache at', cache)
|
|
642
|
+
```
|
|
615
643
|
|
|
616
644
|
##### Example
|
|
617
645
|
|