Skip to content

Commit e242ef1

Browse files
committed
deps: @npmcli/[email protected], @npmcli/[email protected]
These dependency updates fix the issue found in `9.7.0` that was the reason for its deprecation. Specifically `npm` will now use `bin` before `directories.bin` when looking for bin scripts. This matches the behavior of `[email protected]`.
1 parent 974e7d8 commit e242ef1

File tree

10 files changed

+58
-40
lines changed

10 files changed

+58
-40
lines changed

DEPENDENCIES.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,8 @@ graph LR;
218218
npmcli-package-json-->json-parse-even-better-errors;
219219
npmcli-package-json-->normalize-package-data;
220220
npmcli-package-json-->npm-normalize-package-bin;
221+
npmcli-package-json-->npmcli-git["@npmcli/git"];
222+
npmcli-package-json-->proc-log;
221223
npmcli-run-script-->npmcli-node-gyp["@npmcli/node-gyp"];
222224
npmcli-run-script-->npmcli-promise-spawn["@npmcli/promise-spawn"];
223225
npmcli-run-script-->read-package-json-fast;
@@ -704,6 +706,8 @@ graph LR;
704706
npmcli-package-json-->json-parse-even-better-errors;
705707
npmcli-package-json-->normalize-package-data;
706708
npmcli-package-json-->npm-normalize-package-bin;
709+
npmcli-package-json-->npmcli-git["@npmcli/git"];
710+
npmcli-package-json-->proc-log;
707711
npmcli-promise-spawn-->which;
708712
npmcli-query-->postcss-selector-parser;
709713
npmcli-run-script-->node-gyp;
@@ -822,8 +826,8 @@ packages higher up the chain.
822826
- @npmcli/arborist
823827
- @npmcli/metavuln-calculator
824828
- pacote, libnpmhook, libnpmorg, libnpmsearch, libnpmteam, npm-profile
825-
- npm-registry-fetch, libnpmversion
829+
- npm-registry-fetch, @npmcli/package-json, libnpmversion
826830
- @npmcli/git, make-fetch-happen, @npmcli/config, init-package-json
827-
- @npmcli/installed-package-contents, @npmcli/map-workspaces, cacache, npm-pick-manifest, @npmcli/run-script, read-package-json, @npmcli/package-json, promzard
831+
- @npmcli/installed-package-contents, @npmcli/map-workspaces, cacache, npm-pick-manifest, @npmcli/run-script, read-package-json, promzard
828832
- @npmcli/docs, @npmcli/fs, npm-bundled, read-package-json-fast, unique-filename, npm-install-checks, npm-package-arg, npm-packlist, normalize-package-data, bin-links, nopt, npmlog, parse-conflict-json, @npmcli/mock-globals, read
829833
- @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, minipass-fetch, @npmcli/query, cmd-shim, read-cmd-shim, write-file-atomic, abbrev, are-we-there-yet, gauge, minify-registry-metadata, ini, @npmcli/disparity-colors, mute-stream, npm-audit-report, npm-user-validate

node_modules/@npmcli/git/lib/find.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
const is = require('./is.js')
22
const { dirname } = require('path')
33

4-
module.exports = async ({ cwd = process.cwd() } = {}) => {
5-
if (await is({ cwd })) {
6-
return cwd
7-
}
8-
while (cwd !== dirname(cwd)) {
9-
cwd = dirname(cwd)
4+
module.exports = async ({ cwd = process.cwd(), root } = {}) => {
5+
while (true) {
106
if (await is({ cwd })) {
117
return cwd
128
}
9+
const next = dirname(cwd)
10+
if (cwd === root || cwd === next) {
11+
return null
12+
}
13+
cwd = next
1314
}
14-
return null
1515
}

node_modules/@npmcli/git/package.json

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@npmcli/git",
3-
"version": "4.0.4",
3+
"version": "4.1.0",
44
"main": "lib/index.js",
55
"files": [
66
"bin/",
@@ -23,16 +23,15 @@
2323
"template-oss-apply": "template-oss-apply --force"
2424
},
2525
"tap": {
26-
"check-coverage": true,
27-
"coverage-map": "map.js",
26+
"timeout": 600,
2827
"nyc-arg": [
2928
"--exclude",
3029
"tap-snapshots/**"
3130
]
3231
},
3332
"devDependencies": {
3433
"@npmcli/eslint-config": "^4.0.0",
35-
"@npmcli/template-oss": "4.12.0",
34+
"@npmcli/template-oss": "4.15.1",
3635
"npm-package-arg": "^10.0.0",
3736
"slash": "^3.0.0",
3837
"tap": "^16.0.1"
@@ -52,7 +51,7 @@
5251
},
5352
"templateOSS": {
5453
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
55-
"windowsCI": false,
56-
"version": "4.12.0"
54+
"version": "4.15.1",
55+
"publish": true
5756
}
5857
}

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ class PackageJson {
3838
'_attributes',
3939
'bundledDependencies',
4040
'bundleDependencies',
41+
'bundleDependenciesDeleteFalse',
4142
'gypfile',
4243
'serverjs',
4344
'scriptpath',

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

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@ const { glob } = require('glob')
33
const normalizePackageBin = require('npm-normalize-package-bin')
44
const normalizePackageData = require('normalize-package-data')
55
const path = require('path')
6+
const log = require('proc-log')
7+
const git = require('@npmcli/git')
68

7-
const normalize = async (pkg, { strict, steps }) => {
9+
const normalize = async (pkg, { strict, steps, root }) => {
810
const data = pkg.content
911
const scripts = data.scripts || {}
12+
const pkgId = `${data.name ?? ''}@${data.version ?? ''}`
1013

1114
// remove attributes that start with "_"
1215
if (steps.includes('_attributes')) {
@@ -20,7 +23,7 @@ const normalize = async (pkg, { strict, steps }) => {
2023
// build the "_id" attribute
2124
if (steps.includes('_id')) {
2225
if (data.name && data.version) {
23-
data._id = `${data.name}@${data.version}`
26+
data._id = pkgId
2427
}
2528
}
2629

@@ -34,7 +37,9 @@ const normalize = async (pkg, { strict, steps }) => {
3437
// expand "bundleDependencies: true or translate from object"
3538
if (steps.includes('bundleDependencies')) {
3639
const bd = data.bundleDependencies
37-
if (bd === true) {
40+
if (bd === false && !steps.includes('bundleDependenciesDeleteFalse')) {
41+
data.bundleDependencies = []
42+
} else if (bd === true) {
3843
data.bundleDependencies = Object.keys(data.dependencies || {})
3944
} else if (bd && typeof bd === 'object') {
4045
if (!Array.isArray(bd)) {
@@ -158,7 +163,7 @@ const normalize = async (pkg, { strict, steps }) => {
158163
}
159164

160165
// expand "directories.bin"
161-
if (steps.includes('binDir') && data.directories?.bin) {
166+
if (steps.includes('binDir') && data.directories?.bin && !data.bin) {
162167
const binsDir = path.resolve(pkg.path, path.join('.', path.join('/', data.directories.bin)))
163168
const bins = await glob('**', { cwd: binsDir })
164169
data.bin = bins.reduce((acc, binFile) => {
@@ -174,25 +179,28 @@ const normalize = async (pkg, { strict, steps }) => {
174179

175180
// populate "gitHead" attribute
176181
if (steps.includes('gitHead') && !data.gitHead) {
182+
const gitRoot = await git.find({ cwd: pkg.path, root })
177183
let head
178-
try {
179-
head = await fs.readFile(path.resolve(pkg.path, '.git/HEAD'), 'utf8')
180-
} catch (err) {
184+
if (gitRoot) {
185+
try {
186+
head = await fs.readFile(path.resolve(gitRoot, '.git/HEAD'), 'utf8')
187+
} catch (err) {
181188
// do nothing
189+
}
182190
}
183191
let headData
184192
if (head) {
185193
if (head.startsWith('ref: ')) {
186194
const headRef = head.replace(/^ref: /, '').trim()
187-
const headFile = path.resolve(pkg.path, '.git', headRef)
195+
const headFile = path.resolve(gitRoot, '.git', headRef)
188196
try {
189197
headData = await fs.readFile(headFile, 'utf8')
190198
headData = headData.replace(/^ref: /, '').trim()
191199
} catch (err) {
192200
// do nothing
193201
}
194202
if (!headData) {
195-
const packFile = path.resolve(pkg.path, '.git/packed-refs')
203+
const packFile = path.resolve(gitRoot, '.git/packed-refs')
196204
try {
197205
let refs = await fs.readFile(packFile, 'utf8')
198206
if (refs) {
@@ -271,11 +279,11 @@ const normalize = async (pkg, { strict, steps }) => {
271279
// in normalize-package-data if it had access to the file path.
272280
if (steps.includes('binRefs') && data.bin instanceof Object) {
273281
for (const key in data.bin) {
274-
const binPath = path.resolve(pkg.path, data.bin[key])
275282
try {
276-
await fs.access(binPath)
283+
await fs.access(path.resolve(pkg.path, data.bin[key]))
277284
} catch {
278-
delete data.bin[key]
285+
log.warn('package-json', pkgId, `No bin file found at ${data.bin[key]}`)
286+
// XXX: should a future breaking change delete bin entries that cannot be accessed?
279287
}
280288
}
281289
}

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@npmcli/package-json",
3-
"version": "3.1.0",
3+
"version": "3.1.1",
44
"description": "Programmatic API to update package.json",
55
"main": "lib/index.js",
66
"files": [
@@ -26,13 +26,17 @@
2626
"devDependencies": {
2727
"@npmcli/eslint-config": "^4.0.0",
2828
"@npmcli/template-oss": "4.15.1",
29+
"read-package-json": "^6.0.4",
30+
"read-package-json-fast": "^3.0.2",
2931
"tap": "^16.0.1"
3032
},
3133
"dependencies": {
34+
"@npmcli/git": "^4.1.0",
3235
"glob": "^10.2.2",
3336
"json-parse-even-better-errors": "^3.0.0",
3437
"normalize-package-data": "^5.0.0",
35-
"npm-normalize-package-bin": "^3.0.1"
38+
"npm-normalize-package-bin": "^3.0.1",
39+
"proc-log": "^3.0.0"
3640
},
3741
"repository": {
3842
"type": "git",

package-lock.json

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
"@npmcli/arborist": "^6.2.9",
8888
"@npmcli/config": "^6.2.0",
8989
"@npmcli/map-workspaces": "^3.0.4",
90-
"@npmcli/package-json": "^3.1.0",
90+
"@npmcli/package-json": "^3.1.1",
9191
"@npmcli/run-script": "^6.0.2",
9292
"abbrev": "^2.0.0",
9393
"archy": "~1.0.0",
@@ -157,7 +157,7 @@
157157
"@npmcli/docs": "^1.0.0",
158158
"@npmcli/eslint-config": "^4.0.0",
159159
"@npmcli/fs": "^3.1.0",
160-
"@npmcli/git": "^4.0.4",
160+
"@npmcli/git": "^4.1.0",
161161
"@npmcli/mock-globals": "^1.0.0",
162162
"@npmcli/mock-registry": "^1.0.0",
163163
"@npmcli/promise-spawn": "^6.0.2",
@@ -2290,9 +2290,9 @@
22902290
}
22912291
},
22922292
"node_modules/@npmcli/git": {
2293-
"version": "4.0.4",
2294-
"resolved": "https://registry.npmjs.org/@npmcli/git/-/git-4.0.4.tgz",
2295-
"integrity": "sha512-5yZghx+u5M47LghaybLCkdSyFzV/w4OuH12d96HO389Ik9CDsLaDZJVynSGGVJOLn6gy/k7Dz5XYcplM3uxXRg==",
2293+
"version": "4.1.0",
2294+
"resolved": "https://registry.npmjs.org/@npmcli/git/-/git-4.1.0.tgz",
2295+
"integrity": "sha512-9hwoB3gStVfa0N31ymBmrX+GuDGdVA/QWShZVqE0HK2Af+7QGGrCTbZia/SW0ImUTjTne7SP91qxDmtXvDHRPQ==",
22962296
"inBundle": true,
22972297
"dependencies": {
22982298
"@npmcli/promise-spawn": "^6.0.0",
@@ -2394,15 +2394,17 @@
23942394
}
23952395
},
23962396
"node_modules/@npmcli/package-json": {
2397-
"version": "3.1.0",
2398-
"resolved": "https://registry.npmjs.org/@npmcli/package-json/-/package-json-3.1.0.tgz",
2399-
"integrity": "sha512-qNPy6Yf9ruFST99xcrl5EWAvrb7qFrwgVbwdzcTJlIgxbArKOq5e/bgZ6rTL1X9hDgAdPbvL8RWx/OTLSB0ToA==",
2397+
"version": "3.1.1",
2398+
"resolved": "https://registry.npmjs.org/@npmcli/package-json/-/package-json-3.1.1.tgz",
2399+
"integrity": "sha512-+UW0UWOYFKCkvszLoTwrYGrjNrT8tI5Ckeb/h+Z1y1fsNJEctl7HmerA5j2FgmoqFaLI2gsA1X9KgMFqx/bRmA==",
24002400
"inBundle": true,
24012401
"dependencies": {
2402+
"@npmcli/git": "^4.1.0",
24022403
"glob": "^10.2.2",
24032404
"json-parse-even-better-errors": "^3.0.0",
24042405
"normalize-package-data": "^5.0.0",
2405-
"npm-normalize-package-bin": "^3.0.1"
2406+
"npm-normalize-package-bin": "^3.0.1",
2407+
"proc-log": "^3.0.0"
24062408
},
24072409
"engines": {
24082410
"node": "^14.17.0 || ^16.13.0 || >=18.0.0"

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
"@npmcli/arborist": "^6.2.9",
5858
"@npmcli/config": "^6.2.0",
5959
"@npmcli/map-workspaces": "^3.0.4",
60-
"@npmcli/package-json": "^3.1.0",
60+
"@npmcli/package-json": "^3.1.1",
6161
"@npmcli/run-script": "^6.0.2",
6262
"abbrev": "^2.0.0",
6363
"archy": "~1.0.0",
@@ -190,7 +190,7 @@
190190
"@npmcli/docs": "^1.0.0",
191191
"@npmcli/eslint-config": "^4.0.0",
192192
"@npmcli/fs": "^3.1.0",
193-
"@npmcli/git": "^4.0.4",
193+
"@npmcli/git": "^4.1.0",
194194
"@npmcli/mock-globals": "^1.0.0",
195195
"@npmcli/mock-registry": "^1.0.0",
196196
"@npmcli/promise-spawn": "^6.0.2",

scripts/npmcli-git-4.1.0.tgz

8.37 KB
Binary file not shown.

scripts/npmcli-package-json-3.1.1.tgz

7.48 KB
Binary file not shown.

0 commit comments

Comments
 (0)