cacache 20.0.4 → 21.0.1
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/lib/content/write.js +2 -0
- package/lib/entry-index.js +3 -0
- package/lib/rm.js +1 -0
- package/lib/util/cache-dir.js +29 -0
- package/lib/util/tmp.js +5 -1
- package/lib/verify.js +2 -2
- package/package.json +7 -7
package/lib/content/write.js
CHANGED
|
@@ -10,6 +10,7 @@ const Pipeline = require('minipass-pipeline')
|
|
|
10
10
|
const Flush = require('minipass-flush')
|
|
11
11
|
const path = require('path')
|
|
12
12
|
const ssri = require('ssri')
|
|
13
|
+
const cacheDir = require('../util/cache-dir')
|
|
13
14
|
const { tmpName } = require('../util/tmp')
|
|
14
15
|
const fsm = require('fs-minipass')
|
|
15
16
|
|
|
@@ -153,6 +154,7 @@ async function pipeToTmp (inputStream, cache, tmpTarget, opts) {
|
|
|
153
154
|
|
|
154
155
|
async function makeTmp (cache, opts) {
|
|
155
156
|
const tmpTarget = tmpName(cache, opts.tmpPrefix)
|
|
157
|
+
await cacheDir.mkdir(cache)
|
|
156
158
|
await fs.mkdir(path.dirname(tmpTarget), { recursive: true })
|
|
157
159
|
return {
|
|
158
160
|
target: tmpTarget,
|
package/lib/entry-index.js
CHANGED
|
@@ -13,6 +13,7 @@ const { Minipass } = require('minipass')
|
|
|
13
13
|
const path = require('path')
|
|
14
14
|
const ssri = require('ssri')
|
|
15
15
|
const { tmpName } = require('./util/tmp')
|
|
16
|
+
const cacheDir = require('./util/cache-dir')
|
|
16
17
|
|
|
17
18
|
const contentPath = require('./content/path')
|
|
18
19
|
const hashToSegments = require('./util/hash-to-segments')
|
|
@@ -70,6 +71,7 @@ async function compact (cache, key, matchFn, opts = {}) {
|
|
|
70
71
|
|
|
71
72
|
const setup = async () => {
|
|
72
73
|
const target = tmpName(cache, opts.tmpPrefix)
|
|
74
|
+
await cacheDir.mkdir(cache)
|
|
73
75
|
await mkdir(path.dirname(target), { recursive: true })
|
|
74
76
|
return {
|
|
75
77
|
target,
|
|
@@ -121,6 +123,7 @@ async function insert (cache, key, integrity, opts = {}) {
|
|
|
121
123
|
metadata,
|
|
122
124
|
}
|
|
123
125
|
try {
|
|
126
|
+
await cacheDir.mkdir(cache)
|
|
124
127
|
await mkdir(path.dirname(bucket), { recursive: true })
|
|
125
128
|
const stringified = JSON.stringify(entry)
|
|
126
129
|
// NOTE - Cleverness ahoy!
|
package/lib/rm.js
CHANGED
|
@@ -27,5 +27,6 @@ module.exports.all = all
|
|
|
27
27
|
async function all (cache) {
|
|
28
28
|
memo.clearMemoized()
|
|
29
29
|
const paths = await glob(path.join(cache, '*(content-*|index-*)'), { silent: true, nosort: true })
|
|
30
|
+
paths.push(path.join(cache, 'CACHEDIR.TAG'))
|
|
30
31
|
return Promise.all(paths.map((p) => rm(p, { recursive: true, force: true })))
|
|
31
32
|
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
'use strict'
|
|
2
|
+
|
|
3
|
+
const fs = require('fs/promises')
|
|
4
|
+
const path = require('path')
|
|
5
|
+
|
|
6
|
+
const tagContent = `Signature: 8a477f597d28d172789f06886806bc55
|
|
7
|
+
# This file is a cache directory tag created by cacache.
|
|
8
|
+
# For information about cache directory tags, see https://bford.info/cachedir/
|
|
9
|
+
`
|
|
10
|
+
|
|
11
|
+
async function mkdir (cache) {
|
|
12
|
+
await fs.mkdir(cache, { recursive: true, owner: 'inherit' })
|
|
13
|
+
await writeTag(cache)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
async function writeTag (cache) {
|
|
17
|
+
try {
|
|
18
|
+
await fs.writeFile(path.join(cache, 'CACHEDIR.TAG'), tagContent, { flag: 'wx' })
|
|
19
|
+
} catch (err) {
|
|
20
|
+
if (err.code !== 'EEXIST') {
|
|
21
|
+
throw err
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
module.exports = {
|
|
27
|
+
mkdir,
|
|
28
|
+
tagContent,
|
|
29
|
+
}
|
package/lib/util/tmp.js
CHANGED
|
@@ -4,6 +4,7 @@ const crypto = require('crypto')
|
|
|
4
4
|
const { withTempDir } = require('@npmcli/fs')
|
|
5
5
|
const fs = require('fs/promises')
|
|
6
6
|
const path = require('path')
|
|
7
|
+
const cacheDir = require('./cache-dir')
|
|
7
8
|
|
|
8
9
|
module.exports.mkdir = mktmpdir
|
|
9
10
|
|
|
@@ -15,6 +16,7 @@ module.exports.tmpName = function tmpName (cache, tmpPrefix) {
|
|
|
15
16
|
async function mktmpdir (cache, opts = {}) {
|
|
16
17
|
const { tmpPrefix } = opts
|
|
17
18
|
const tmpDir = path.join(cache, 'tmp')
|
|
19
|
+
await cacheDir.mkdir(cache)
|
|
18
20
|
await fs.mkdir(tmpDir, { recursive: true, owner: 'inherit' })
|
|
19
21
|
// do not use path.join(), it drops the trailing / if tmpPrefix is unset
|
|
20
22
|
const target = `${tmpDir}${path.sep}${tmpPrefix || ''}`
|
|
@@ -28,5 +30,7 @@ function withTmp (cache, opts, cb) {
|
|
|
28
30
|
cb = opts
|
|
29
31
|
opts = {}
|
|
30
32
|
}
|
|
31
|
-
return
|
|
33
|
+
return cacheDir.mkdir(cache).then(() =>
|
|
34
|
+
withTempDir(path.join(cache, 'tmp'), cb, opts)
|
|
35
|
+
)
|
|
32
36
|
}
|
package/lib/verify.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
3
|
const {
|
|
4
|
-
mkdir,
|
|
5
4
|
readFile,
|
|
6
5
|
rm,
|
|
7
6
|
stat,
|
|
@@ -12,6 +11,7 @@ const contentPath = require('./content/path')
|
|
|
12
11
|
const fsm = require('fs-minipass')
|
|
13
12
|
const glob = require('./util/glob.js')
|
|
14
13
|
const index = require('./entry-index')
|
|
14
|
+
const cacheDir = require('./util/cache-dir')
|
|
15
15
|
const path = require('path')
|
|
16
16
|
const ssri = require('ssri')
|
|
17
17
|
|
|
@@ -77,7 +77,7 @@ async function markEndTime () {
|
|
|
77
77
|
|
|
78
78
|
async function fixPerms (cache, opts) {
|
|
79
79
|
opts.log.silly('verify', 'fixing cache permissions')
|
|
80
|
-
await mkdir(cache
|
|
80
|
+
await cacheDir.mkdir(cache)
|
|
81
81
|
return null
|
|
82
82
|
}
|
|
83
83
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "cacache",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "21.0.1",
|
|
4
4
|
"cache-version": {
|
|
5
5
|
"content": "2",
|
|
6
6
|
"index": "5"
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
],
|
|
47
47
|
"license": "ISC",
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@npmcli/fs": "^
|
|
49
|
+
"@npmcli/fs": "^6.0.0",
|
|
50
50
|
"fs-minipass": "^3.0.0",
|
|
51
51
|
"glob": "^13.0.0",
|
|
52
52
|
"lru-cache": "^11.1.0",
|
|
@@ -55,20 +55,20 @@
|
|
|
55
55
|
"minipass-flush": "^1.0.5",
|
|
56
56
|
"minipass-pipeline": "^1.2.4",
|
|
57
57
|
"p-map": "^7.0.2",
|
|
58
|
-
"ssri": "^
|
|
58
|
+
"ssri": "^14.0.0"
|
|
59
59
|
},
|
|
60
60
|
"devDependencies": {
|
|
61
|
-
"@npmcli/eslint-config": "^
|
|
62
|
-
"@npmcli/template-oss": "
|
|
61
|
+
"@npmcli/eslint-config": "^7.0.0",
|
|
62
|
+
"@npmcli/template-oss": "5.1.0",
|
|
63
63
|
"tap": "^16.0.0"
|
|
64
64
|
},
|
|
65
65
|
"engines": {
|
|
66
|
-
"node": "^
|
|
66
|
+
"node": "^22.22.2 || ^24.15.0 || >=26.0.0"
|
|
67
67
|
},
|
|
68
68
|
"templateOSS": {
|
|
69
69
|
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
|
|
70
70
|
"windowsCI": false,
|
|
71
|
-
"version": "
|
|
71
|
+
"version": "5.1.0",
|
|
72
72
|
"publish": "true"
|
|
73
73
|
},
|
|
74
74
|
"author": "GitHub Inc.",
|