Skip to content

Commit 36adff3

Browse files
lukekarryswraithgar
authored andcommitted
deps: pacote@18.0.2
1 parent 486d46c commit 36adff3

20 files changed

Lines changed: 65 additions & 752 deletions

File tree

DEPENDENCIES.md

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -242,18 +242,14 @@ graph LR;
242242
pacote-->npm-registry-fetch;
243243
pacote-->npmcli-git["@npmcli/git"];
244244
pacote-->npmcli-installed-package-contents["@npmcli/installed-package-contents"];
245+
pacote-->npmcli-package-json["@npmcli/package-json"];
245246
pacote-->npmcli-promise-spawn["@npmcli/promise-spawn"];
246247
pacote-->npmcli-run-script["@npmcli/run-script"];
247248
pacote-->proc-log;
248-
pacote-->read-package-json-fast;
249-
pacote-->read-package-json;
250249
pacote-->ssri;
251250
parse-conflict-json-->json-parse-even-better-errors;
252251
promzard-->read;
253252
read-->mute-stream;
254-
read-package-json-->json-parse-even-better-errors;
255-
read-package-json-->normalize-package-data;
256-
read-package-json-->npm-normalize-package-bin;
257253
read-package-json-fast-->json-parse-even-better-errors;
258254
read-package-json-fast-->npm-normalize-package-bin;
259255
unique-filename-->unique-slug;
@@ -713,12 +709,11 @@ graph LR;
713709
pacote-->npm-registry-fetch;
714710
pacote-->npmcli-git["@npmcli/git"];
715711
pacote-->npmcli-installed-package-contents["@npmcli/installed-package-contents"];
712+
pacote-->npmcli-package-json["@npmcli/package-json"];
716713
pacote-->npmcli-promise-spawn["@npmcli/promise-spawn"];
717714
pacote-->npmcli-run-script["@npmcli/run-script"];
718715
pacote-->proc-log;
719716
pacote-->promise-retry;
720-
pacote-->read-package-json-fast;
721-
pacote-->read-package-json;
722717
pacote-->sigstore;
723718
pacote-->ssri;
724719
pacote-->tar;
@@ -733,10 +728,6 @@ graph LR;
733728
promise-retry-->retry;
734729
promzard-->read;
735730
read-->mute-stream;
736-
read-package-json-->glob;
737-
read-package-json-->json-parse-even-better-errors;
738-
read-package-json-->normalize-package-data;
739-
read-package-json-->npm-normalize-package-bin;
740731
read-package-json-fast-->json-parse-even-better-errors;
741732
read-package-json-fast-->npm-normalize-package-bin;
742733
semver-->lru-cache;
@@ -811,6 +802,6 @@ packages higher up the chain.
811802
- @npmcli/run-script, libnpmhook, libnpmorg, libnpmsearch, libnpmteam, init-package-json, npm-profile
812803
- @npmcli/package-json, npm-registry-fetch
813804
- @npmcli/git, make-fetch-happen, @npmcli/config
814-
- @npmcli/installed-package-contents, @npmcli/map-workspaces, cacache, npm-pick-manifest, read-package-json, promzard
805+
- @npmcli/installed-package-contents, @npmcli/map-workspaces, cacache, npm-pick-manifest, promzard
815806
- @npmcli/docs, @npmcli/fs, npm-bundled, read-package-json-fast, unique-filename, npm-install-checks, npm-package-arg, normalize-package-data, npm-packlist, bin-links, nopt, parse-conflict-json, @npmcli/mock-globals, read
816807
- @npmcli/eslint-config, @npmcli/template-oss, ignore-walk, semver, npm-normalize-package-bin, @npmcli/name-from-folder, json-parse-even-better-errors, fs-minipass, ssri, unique-slug, @npmcli/promise-spawn, hosted-git-info, proc-log, validate-npm-package-name, @npmcli/node-gyp, @npmcli/redact, @npmcli/agent, minipass-fetch, @npmcli/query, cmd-shim, read-cmd-shim, write-file-atomic, abbrev, proggy, minify-registry-metadata, ini, mute-stream, npm-audit-report, npm-user-validate

mock-registry/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
"json-stringify-safe": "^5.0.1",
5252
"nock": "^13.3.3",
5353
"npm-package-arg": "^11.0.2",
54-
"pacote": "^18.0.0",
54+
"pacote": "^18.0.1",
5555
"tap": "^16.3.8"
5656
}
5757
}

node_modules/.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,6 @@
178178
!/qrcode-terminal
179179
!/read-cmd-shim
180180
!/read-package-json-fast
181-
!/read-package-json
182181
!/read
183182
!/retry
184183
!/safer-buffer

node_modules/@npmcli/package-json/lib/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,12 @@ class PackageJson {
167167
return this
168168
}
169169

170+
fromContent (data) {
171+
this.#manifest = data
172+
this.#canSave = false
173+
return this
174+
}
175+
170176
// Load data from a comment
171177
// /**package { "name": "foo", "version": "1.2.3", ... } **/
172178
fromComment (data) {

node_modules/@npmcli/package-json/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@npmcli/package-json",
3-
"version": "5.0.3",
3+
"version": "5.1.0",
44
"description": "Programmatic API to update package.json",
55
"main": "lib/index.js",
66
"files": [
@@ -25,7 +25,7 @@
2525
"license": "ISC",
2626
"devDependencies": {
2727
"@npmcli/eslint-config": "^4.0.0",
28-
"@npmcli/template-oss": "4.21.3",
28+
"@npmcli/template-oss": "4.21.4",
2929
"read-package-json": "^7.0.0",
3030
"read-package-json-fast": "^3.0.2",
3131
"tap": "^16.0.1"
@@ -48,7 +48,7 @@
4848
},
4949
"templateOSS": {
5050
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
51-
"version": "4.21.3",
51+
"version": "4.21.4",
5252
"publish": "true"
5353
},
5454
"tap": {

node_modules/pacote/lib/dir.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ class DirFetcher extends Fetcher {
8787
return Promise.resolve(this.package)
8888
}
8989

90-
return this[_readPackageJson](this.resolved + '/package.json')
90+
return this[_readPackageJson](this.resolved)
9191
.then(mani => this.package = {
9292
...mani,
9393
_integrity: this.integrity && String(this.integrity),

node_modules/pacote/lib/fetcher.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55

66
const npa = require('npm-package-arg')
77
const ssri = require('ssri')
8-
const { promisify } = require('util')
98
const { basename, dirname } = require('path')
109
const tar = require('tar')
1110
const { log } = require('proc-log')
@@ -16,12 +15,14 @@ const cacache = require('cacache')
1615
const isPackageBin = require('./util/is-package-bin.js')
1716
const removeTrailingSlashes = require('./util/trailing-slashes.js')
1817
const getContents = require('@npmcli/installed-package-contents')
19-
const readPackageJsonFast = require('read-package-json-fast')
20-
const readPackageJson = promisify(require('read-package-json'))
18+
const PackageJson = require('@npmcli/package-json')
2119
const { Minipass } = require('minipass')
22-
2320
const cacheDir = require('./util/cache-dir.js')
2421

22+
// Pacote is only concerned with the package.json contents
23+
const packageJsonPrepare = (p) => PackageJson.prepare(p).then(pkg => pkg.content)
24+
const packageJsonNormalize = (p) => PackageJson.normalize(p).then(pkg => pkg.content)
25+
2526
// Private methods.
2627
// Child classes should not have to override these.
2728
// Users should never call them.
@@ -93,9 +94,9 @@ class FetcherBase {
9394
this.fullMetadata = this.before ? true : !!opts.fullMetadata
9495
this.fullReadJson = !!opts.fullReadJson
9596
if (this.fullReadJson) {
96-
this[_readPackageJson] = readPackageJson
97+
this[_readPackageJson] = packageJsonPrepare
9798
} else {
98-
this[_readPackageJson] = readPackageJsonFast
99+
this[_readPackageJson] = packageJsonNormalize
99100
}
100101

101102
// rrh is a registry hostname or 'never' or 'always'

node_modules/pacote/lib/file.js

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1-
const Fetcher = require('./fetcher.js')
21
const fsm = require('fs-minipass')
32
const cacache = require('cacache')
4-
const _tarballFromResolved = Symbol.for('pacote.Fetcher._tarballFromResolved')
5-
const _exeBins = Symbol('_exeBins')
63
const { resolve } = require('path')
7-
const fs = require('fs')
4+
const { stat, chmod } = require('fs/promises')
5+
const Fetcher = require('./fetcher.js')
6+
7+
const _exeBins = Symbol('_exeBins')
8+
const _tarballFromResolved = Symbol.for('pacote.Fetcher._tarballFromResolved')
89
const _readPackageJson = Symbol.for('package.Fetcher._readPackageJson')
910

1011
class FileFetcher extends Fetcher {
@@ -26,7 +27,7 @@ class FileFetcher extends Fetcher {
2627
// have to unpack the tarball for this.
2728
return cacache.tmp.withTmp(this.cache, this.opts, dir =>
2829
this.extract(dir)
29-
.then(() => this[_readPackageJson](dir + '/package.json'))
30+
.then(() => this[_readPackageJson](dir))
3031
.then(mani => this.package = {
3132
...mani,
3233
_integrity: this.integrity && String(this.integrity),
@@ -40,31 +41,31 @@ class FileFetcher extends Fetcher {
4041
return Promise.resolve()
4142
}
4243

43-
return Promise.all(Object.keys(pkg.bin).map(k => new Promise(res => {
44+
return Promise.all(Object.keys(pkg.bin).map(async k => {
4445
const script = resolve(dest, pkg.bin[k])
4546
// Best effort. Ignore errors here, the only result is that
4647
// a bin script is not executable. But if it's missing or
4748
// something, we just leave it for a later stage to trip over
4849
// when we can provide a more useful contextual error.
49-
fs.stat(script, (er, st) => {
50-
if (er) {
51-
return res()
52-
}
50+
try {
51+
const st = await stat(script)
5352
const mode = st.mode | 0o111
5453
if (mode === st.mode) {
55-
return res()
54+
return
5655
}
57-
fs.chmod(script, mode, res)
58-
})
59-
})))
56+
await chmod(script, mode)
57+
} catch {
58+
// Ignore errors here
59+
}
60+
}))
6061
}
6162

6263
extract (dest) {
6364
// if we've already loaded the manifest, then the super got it.
6465
// but if not, read the unpacked manifest and chmod properly.
6566
return super.extract(dest)
6667
.then(result => this.package ? result
67-
: this[_readPackageJson](dest + '/package.json').then(pkg =>
68+
: this[_readPackageJson](dest).then(pkg =>
6869
this[_exeBins](pkg, dest)).then(() => result))
6970
}
7071

node_modules/pacote/lib/git.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -156,11 +156,11 @@ class GitFetcher extends Fetcher {
156156
[_resolvedFromClone] () {
157157
// do a full or shallow clone, then look at the HEAD
158158
// kind of wasteful, but no other option, really
159-
return this[_clone](dir => this.resolved)
159+
return this[_clone](() => this.resolved)
160160
}
161161

162162
[_prepareDir] (dir) {
163-
return this[_readPackageJson](dir + '/package.json').then(mani => {
163+
return this[_readPackageJson](dir).then(mani => {
164164
// no need if we aren't going to do any preparation.
165165
const scripts = mani.scripts
166166
if (!mani.workspaces && (!scripts || !(
@@ -312,7 +312,7 @@ class GitFetcher extends Fetcher {
312312
return this.spec.hosted && this.resolved
313313
? FileFetcher.prototype.manifest.apply(this)
314314
: this[_clone](dir =>
315-
this[_readPackageJson](dir + '/package.json')
315+
this[_readPackageJson](dir)
316316
.then(mani => this.package = {
317317
...mani,
318318
_resolved: this.resolved,

node_modules/pacote/lib/registry.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const RemoteFetcher = require('./remote.js')
33
const _tarballFromResolved = Symbol.for('pacote.Fetcher._tarballFromResolved')
44
const pacoteVersion = require('../package.json').version
55
const removeTrailingSlashes = require('./util/trailing-slashes.js')
6-
const rpj = require('read-package-json-fast')
6+
const PackageJson = require('@npmcli/package-json')
77
const pickManifest = require('npm-pick-manifest')
88
const ssri = require('ssri')
99
const crypto = require('crypto')
@@ -127,12 +127,13 @@ class RegistryFetcher extends Fetcher {
127127
}
128128

129129
const packument = await this.packument()
130-
let mani = await pickManifest(packument, this.spec.fetchSpec, {
130+
const steps = PackageJson.normalizeSteps.filter(s => s !== '_attributes')
131+
const mani = await new PackageJson().fromContent(pickManifest(packument, this.spec.fetchSpec, {
131132
...this.opts,
132133
defaultTag: this.defaultTag,
133134
before: this.before,
134-
})
135-
mani = rpj.normalize(mani)
135+
})).normalize({ steps }).then(p => p.content)
136+
136137
/* XXX add ETARGET and E403 revalidation of cached packuments here */
137138

138139
// add _time from packument if fetched with fullMetadata

0 commit comments

Comments
 (0)