Skip to content

Commit 3eec56e

Browse files
committed
1 parent 7a2ce3f commit 3eec56e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+11376
-91
lines changed

node_modules/.gitignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,14 @@
7777
!/buffer
7878
!/builtins
7979
!/cacache
80+
!/cacache/node_modules/
81+
/cacache/node_modules/*
82+
!/cacache/node_modules/foreground-child
83+
!/cacache/node_modules/glob
84+
!/cacache/node_modules/jackspeak
85+
!/cacache/node_modules/minimatch
86+
!/cacache/node_modules/minipass
87+
!/cacache/node_modules/signal-exit
8088
!/chalk
8189
!/chownr
8290
!/ci-info

node_modules/cacache/lib/content/write.js

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ const events = require('events')
44

55
const contentPath = require('./path')
66
const fs = require('fs/promises')
7-
const moveFile = require('../util/move-file')
8-
const Minipass = require('minipass')
7+
const { moveFile } = require('@npmcli/fs')
8+
const { Minipass } = require('minipass')
99
const Pipeline = require('minipass-pipeline')
1010
const Flush = require('minipass-flush')
1111
const path = require('path')
@@ -17,9 +17,6 @@ module.exports = write
1717

1818
async function write (cache, data, opts = {}) {
1919
const { algorithms, size, integrity } = opts
20-
if (algorithms && algorithms.length > 1) {
21-
throw new Error('opts.algorithms only supports a single algorithm for now')
22-
}
2320

2421
if (typeof size === 'number' && data.length !== size) {
2522
throw sizeError(size, data.length)
@@ -30,16 +27,19 @@ async function write (cache, data, opts = {}) {
3027
throw checksumError(integrity, sri)
3128
}
3229

33-
const tmp = await makeTmp(cache, opts)
34-
try {
35-
await fs.writeFile(tmp.target, data, { flag: 'wx' })
36-
await moveToDestination(tmp, cache, sri, opts)
37-
return { integrity: sri, size: data.length }
38-
} finally {
39-
if (!tmp.moved) {
40-
await fs.rm(tmp.target, { recursive: true, force: true })
30+
for (const algo in sri) {
31+
const tmp = await makeTmp(cache, opts)
32+
const hash = sri[algo].toString()
33+
try {
34+
await fs.writeFile(tmp.target, data, { flag: 'wx' })
35+
await moveToDestination(tmp, cache, hash, opts)
36+
} finally {
37+
if (!tmp.moved) {
38+
await fs.rm(tmp.target, { recursive: true, force: true })
39+
}
4140
}
4241
}
42+
return { integrity: sri, size: data.length }
4343
}
4444

4545
module.exports.stream = writeStream
@@ -161,8 +161,14 @@ async function moveToDestination (tmp, cache, sri, opts) {
161161
const destDir = path.dirname(destination)
162162

163163
await fs.mkdir(destDir, { recursive: true })
164-
await moveFile(tmp.target, destination)
165-
tmp.moved = true
164+
try {
165+
await moveFile(tmp.target, destination, { overwrite: false })
166+
tmp.moved = true
167+
} catch (err) {
168+
if (!err.message.startsWith('The destination file exists')) {
169+
throw Object.assign(err, { code: 'EEXIST' })
170+
}
171+
}
166172
}
167173

168174
function sizeError (expected, found) {

node_modules/cacache/lib/entry-index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const {
99
rm,
1010
writeFile,
1111
} = require('fs/promises')
12-
const Minipass = require('minipass')
12+
const { Minipass } = require('minipass')
1313
const path = require('path')
1414
const ssri = require('ssri')
1515
const uniqueFilename = require('unique-filename')
@@ -109,12 +109,12 @@ async function compact (cache, key, matchFn, opts = {}) {
109109
module.exports.insert = insert
110110

111111
async function insert (cache, key, integrity, opts = {}) {
112-
const { metadata, size } = opts
112+
const { metadata, size, time } = opts
113113
const bucket = bucketPath(cache, key)
114114
const entry = {
115115
key,
116116
integrity: integrity && ssri.stringify(integrity),
117-
time: Date.now(),
117+
time: time || Date.now(),
118118
size,
119119
metadata,
120120
}

node_modules/cacache/lib/get.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
'use strict'
22

33
const Collect = require('minipass-collect')
4-
const Minipass = require('minipass')
4+
const { Minipass } = require('minipass')
55
const Pipeline = require('minipass-pipeline')
66

77
const index = require('./entry-index')
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
'use strict'
22

3-
const glob = require('glob')
3+
const { glob } = require('glob')
44

55
const globify = (pattern) => pattern.split('//').join('/')
66
module.exports = (path, options) => glob(globify(path), options)

node_modules/cacache/lib/util/move-file.js

Lines changed: 0 additions & 56 deletions
This file was deleted.

node_modules/cacache/lib/verify.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,11 @@ async function garbageCollect (cache, opts) {
100100
return
101101
}
102102

103-
liveContent.add(entry.integrity.toString())
103+
// integrity is stringified, re-parse it so we can get each hash
104+
const integrity = ssri.parse(entry.integrity)
105+
for (const algo in integrity) {
106+
liveContent.add(integrity[algo].toString())
107+
}
104108
})
105109
await new Promise((resolve, reject) => {
106110
indexStream.on('end', resolve).on('error', reject)
@@ -220,6 +224,7 @@ async function rebuildBucket (cache, bucket, stats, opts) {
220224
await index.insert(cache, entry.key, entry.integrity, {
221225
metadata: entry.metadata,
222226
size: entry.size,
227+
time: entry.time,
223228
})
224229
stats.totalEntries++
225230
} catch (err) {
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
The ISC License
2+
3+
Copyright (c) 2015-2023 Isaac Z. Schlueter and Contributors
4+
5+
Permission to use, copy, modify, and/or distribute this software for any
6+
purpose with or without fee is hereby granted, provided that the above
7+
copyright notice and this permission notice appear in all copies.
8+
9+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10+
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11+
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12+
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13+
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14+
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
15+
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
"use strict";
2+
var __importDefault = (this && this.__importDefault) || function (mod) {
3+
return (mod && mod.__esModule) ? mod : { "default": mod };
4+
};
5+
Object.defineProperty(exports, "__esModule", { value: true });
6+
exports.allSignals = void 0;
7+
const node_constants_1 = __importDefault(require("node:constants"));
8+
exports.allSignals =
9+
// this is the full list of signals that Node will let us do anything with
10+
Object.keys(node_constants_1.default).filter(k => k.startsWith('SIG') &&
11+
// https://github.com/tapjs/signal-exit/issues/21
12+
k !== 'SIGPROF' &&
13+
// no sense trying to listen for SIGKILL, it's impossible
14+
k !== 'SIGKILL');
15+
// These are some obscure signals that are reported by kill -l
16+
// on macOS, Linux, or Windows, but which don't have any mapping
17+
// in Node.js. No sense trying if they're just going to throw
18+
// every time on every platform.
19+
//
20+
// 'SIGEMT',
21+
// 'SIGLOST',
22+
// 'SIGPOLL',
23+
// 'SIGRTMAX',
24+
// 'SIGRTMAX-1',
25+
// 'SIGRTMAX-10',
26+
// 'SIGRTMAX-11',
27+
// 'SIGRTMAX-12',
28+
// 'SIGRTMAX-13',
29+
// 'SIGRTMAX-14',
30+
// 'SIGRTMAX-15',
31+
// 'SIGRTMAX-2',
32+
// 'SIGRTMAX-3',
33+
// 'SIGRTMAX-4',
34+
// 'SIGRTMAX-5',
35+
// 'SIGRTMAX-6',
36+
// 'SIGRTMAX-7',
37+
// 'SIGRTMAX-8',
38+
// 'SIGRTMAX-9',
39+
// 'SIGRTMIN',
40+
// 'SIGRTMIN+1',
41+
// 'SIGRTMIN+10',
42+
// 'SIGRTMIN+11',
43+
// 'SIGRTMIN+12',
44+
// 'SIGRTMIN+13',
45+
// 'SIGRTMIN+14',
46+
// 'SIGRTMIN+15',
47+
// 'SIGRTMIN+16',
48+
// 'SIGRTMIN+2',
49+
// 'SIGRTMIN+3',
50+
// 'SIGRTMIN+4',
51+
// 'SIGRTMIN+5',
52+
// 'SIGRTMIN+6',
53+
// 'SIGRTMIN+7',
54+
// 'SIGRTMIN+8',
55+
// 'SIGRTMIN+9',
56+
// 'SIGSTKFLT',
57+
// 'SIGUNUSED',
58+
//# sourceMappingURL=all-signals.js.map

0 commit comments

Comments
 (0)