Skip to content

Commit f69052e

Browse files
committed
deps: @npmcli/package-json@5.0.2
1 parent ef381b1 commit f69052e

File tree

4 files changed

+38
-14
lines changed

4 files changed

+38
-14
lines changed

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

+32-8
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,30 @@
11
const valid = require('semver/functions/valid')
22
const clean = require('semver/functions/clean')
33
const fs = require('fs/promises')
4-
const { glob } = require('glob')
54
const path = require('path')
65
const log = require('proc-log')
7-
const hostedGitInfo = require('hosted-git-info')
6+
7+
/**
8+
* @type {import('hosted-git-info')}
9+
*/
10+
let _hostedGitInfo
11+
function lazyHostedGitInfo () {
12+
if (!_hostedGitInfo) {
13+
_hostedGitInfo = require('hosted-git-info')
14+
}
15+
return _hostedGitInfo
16+
}
17+
18+
/**
19+
* @type {import('glob').glob}
20+
*/
21+
let _glob
22+
function lazyLoadGlob () {
23+
if (!_glob) {
24+
_glob = require('glob').glob
25+
}
26+
return _glob
27+
}
828

929
// used to be npm-normalize-package-bin
1030
function normalizePackageBin (pkg, changes) {
@@ -206,7 +226,7 @@ const normalize = async (pkg, { strict, steps, root, changes, allowLegacyCase })
206226
// add "install" attribute if any "*.gyp" files exist
207227
if (steps.includes('gypfile')) {
208228
if (!scripts.install && !scripts.preinstall && data.gypfile !== false) {
209-
const files = await glob('*.gyp', { cwd: pkg.path })
229+
const files = await lazyLoadGlob()('*.gyp', { cwd: pkg.path })
210230
if (files.length) {
211231
scripts.install = 'node-gyp rebuild'
212232
data.scripts = scripts
@@ -273,7 +293,11 @@ const normalize = async (pkg, { strict, steps, root, changes, allowLegacyCase })
273293
// populate "readme" attribute
274294
if (steps.includes('readme') && !data.readme) {
275295
const mdre = /\.m?a?r?k?d?o?w?n?$/i
276-
const files = await glob('{README,README.*}', { cwd: pkg.path, nocase: true, mark: true })
296+
const files = await lazyLoadGlob()('{README,README.*}', {
297+
cwd: pkg.path,
298+
nocase: true,
299+
mark: true,
300+
})
277301
let readmeFile
278302
for (const file of files) {
279303
// don't accept directories.
@@ -304,7 +328,7 @@ const normalize = async (pkg, { strict, steps, root, changes, allowLegacyCase })
304328
if (steps.includes('mans') && !data.man && data.directories?.man) {
305329
const manDir = data.directories.man
306330
const cwd = path.resolve(pkg.path, manDir)
307-
const files = await glob('**/*.[0-9]', { cwd })
331+
const files = await lazyLoadGlob()('**/*.[0-9]', { cwd })
308332
data.man = files.map(man =>
309333
path.relative(pkg.path, path.join(cwd, man)).split(path.sep).join('/')
310334
)
@@ -317,7 +341,7 @@ const normalize = async (pkg, { strict, steps, root, changes, allowLegacyCase })
317341
// expand "directories.bin"
318342
if (steps.includes('binDir') && data.directories?.bin && !data.bin) {
319343
const binsDir = path.resolve(pkg.path, path.join('.', path.join('/', data.directories.bin)))
320-
const bins = await glob('**', { cwd: binsDir })
344+
const bins = await lazyLoadGlob()('**', { cwd: binsDir })
321345
data.bin = bins.reduce((acc, binFile) => {
322346
if (binFile && !binFile.startsWith('.')) {
323347
const binName = path.basename(binFile)
@@ -445,7 +469,7 @@ const normalize = async (pkg, { strict, steps, root, changes, allowLegacyCase })
445469
}
446470
}
447471
if (data.repository.url) {
448-
const hosted = hostedGitInfo.fromUrl(data.repository.url)
472+
const hosted = lazyHostedGitInfo().fromUrl(data.repository.url)
449473
let r
450474
if (hosted) {
451475
if (hosted.getDefaultRepresentation() === 'shortcut') {
@@ -505,7 +529,7 @@ const normalize = async (pkg, { strict, steps, root, changes, allowLegacyCase })
505529
changes?.push(`Removed invalid "${deps}.${d}"`)
506530
delete data[deps][d]
507531
}
508-
const hosted = hostedGitInfo.fromUrl(data[deps][d])?.toString()
532+
const hosted = lazyHostedGitInfo().fromUrl(data[deps][d])?.toString()
509533
if (hosted && hosted !== data[deps][d]) {
510534
changes?.push(`Normalized git reference to "${deps}.${d}"`)
511535
data[deps][d] = hosted.toString()

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@npmcli/package-json",
3-
"version": "5.0.1",
3+
"version": "5.0.2",
44
"description": "Programmatic API to update package.json",
55
"main": "lib/index.js",
66
"files": [

package-lock.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@
9494
"@npmcli/config": "^8.0.2",
9595
"@npmcli/fs": "^3.1.0",
9696
"@npmcli/map-workspaces": "^3.0.4",
97-
"@npmcli/package-json": "^5.0.1",
97+
"@npmcli/package-json": "^5.0.2",
9898
"@npmcli/promise-spawn": "^7.0.1",
9999
"@npmcli/redact": "^1.1.0",
100100
"@npmcli/run-script": "^7.0.4",
@@ -1805,9 +1805,9 @@
18051805
}
18061806
},
18071807
"node_modules/@npmcli/package-json": {
1808-
"version": "5.0.1",
1809-
"resolved": "https://registry.npmjs.org/@npmcli/package-json/-/package-json-5.0.1.tgz",
1810-
"integrity": "sha512-WdwGsRP/do+94IXEgfD/oGGVn0VDS+wYM8MoXU5tJ+02Ke8ePSobMwnfcCHAfcvU/pFwZxyZYWaJdOBsqXRAbA==",
1808+
"version": "5.0.2",
1809+
"resolved": "https://registry.npmjs.org/@npmcli/package-json/-/package-json-5.0.2.tgz",
1810+
"integrity": "sha512-LmW+tueGSK+FCM3OpcKtwKKo3igpefh6HHiw23sGd8OdJ8l0GrfGfVdGOFVtJRMaXVnvI1RUdEPlB9VUln5Wbw==",
18111811
"inBundle": true,
18121812
"dependencies": {
18131813
"@npmcli/git": "^5.0.0",

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"@npmcli/config": "^8.0.2",
5757
"@npmcli/fs": "^3.1.0",
5858
"@npmcli/map-workspaces": "^3.0.4",
59-
"@npmcli/package-json": "^5.0.1",
59+
"@npmcli/package-json": "^5.0.2",
6060
"@npmcli/promise-spawn": "^7.0.1",
6161
"@npmcli/redact": "^1.1.0",
6262
"@npmcli/run-script": "^7.0.4",

0 commit comments

Comments
 (0)