Skip to content

Commit

Permalink
deps: @npmcli/package-json@5.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
wraithgar committed Apr 10, 2024
1 parent ef381b1 commit f69052e
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 14 deletions.
40 changes: 32 additions & 8 deletions node_modules/@npmcli/package-json/lib/normalize.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,30 @@
const valid = require('semver/functions/valid')
const clean = require('semver/functions/clean')
const fs = require('fs/promises')
const { glob } = require('glob')
const path = require('path')
const log = require('proc-log')
const hostedGitInfo = require('hosted-git-info')

/**
* @type {import('hosted-git-info')}
*/
let _hostedGitInfo
function lazyHostedGitInfo () {
if (!_hostedGitInfo) {
_hostedGitInfo = require('hosted-git-info')
}
return _hostedGitInfo
}

/**
* @type {import('glob').glob}
*/
let _glob
function lazyLoadGlob () {
if (!_glob) {
_glob = require('glob').glob
}
return _glob
}

// used to be npm-normalize-package-bin
function normalizePackageBin (pkg, changes) {
Expand Down Expand Up @@ -206,7 +226,7 @@ const normalize = async (pkg, { strict, steps, root, changes, allowLegacyCase })
// add "install" attribute if any "*.gyp" files exist
if (steps.includes('gypfile')) {
if (!scripts.install && !scripts.preinstall && data.gypfile !== false) {
const files = await glob('*.gyp', { cwd: pkg.path })
const files = await lazyLoadGlob()('*.gyp', { cwd: pkg.path })
if (files.length) {
scripts.install = 'node-gyp rebuild'
data.scripts = scripts
Expand Down Expand Up @@ -273,7 +293,11 @@ const normalize = async (pkg, { strict, steps, root, changes, allowLegacyCase })
// populate "readme" attribute
if (steps.includes('readme') && !data.readme) {
const mdre = /\.m?a?r?k?d?o?w?n?$/i
const files = await glob('{README,README.*}', { cwd: pkg.path, nocase: true, mark: true })
const files = await lazyLoadGlob()('{README,README.*}', {
cwd: pkg.path,
nocase: true,
mark: true,
})
let readmeFile
for (const file of files) {
// don't accept directories.
Expand Down Expand Up @@ -304,7 +328,7 @@ const normalize = async (pkg, { strict, steps, root, changes, allowLegacyCase })
if (steps.includes('mans') && !data.man && data.directories?.man) {
const manDir = data.directories.man
const cwd = path.resolve(pkg.path, manDir)
const files = await glob('**/*.[0-9]', { cwd })
const files = await lazyLoadGlob()('**/*.[0-9]', { cwd })
data.man = files.map(man =>
path.relative(pkg.path, path.join(cwd, man)).split(path.sep).join('/')
)
Expand All @@ -317,7 +341,7 @@ const normalize = async (pkg, { strict, steps, root, changes, allowLegacyCase })
// expand "directories.bin"
if (steps.includes('binDir') && data.directories?.bin && !data.bin) {
const binsDir = path.resolve(pkg.path, path.join('.', path.join('/', data.directories.bin)))
const bins = await glob('**', { cwd: binsDir })
const bins = await lazyLoadGlob()('**', { cwd: binsDir })
data.bin = bins.reduce((acc, binFile) => {
if (binFile && !binFile.startsWith('.')) {
const binName = path.basename(binFile)
Expand Down Expand Up @@ -445,7 +469,7 @@ const normalize = async (pkg, { strict, steps, root, changes, allowLegacyCase })
}
}
if (data.repository.url) {
const hosted = hostedGitInfo.fromUrl(data.repository.url)
const hosted = lazyHostedGitInfo().fromUrl(data.repository.url)
let r
if (hosted) {
if (hosted.getDefaultRepresentation() === 'shortcut') {
Expand Down Expand Up @@ -505,7 +529,7 @@ const normalize = async (pkg, { strict, steps, root, changes, allowLegacyCase })
changes?.push(`Removed invalid "${deps}.${d}"`)
delete data[deps][d]
}
const hosted = hostedGitInfo.fromUrl(data[deps][d])?.toString()
const hosted = lazyHostedGitInfo().fromUrl(data[deps][d])?.toString()
if (hosted && hosted !== data[deps][d]) {
changes?.push(`Normalized git reference to "${deps}.${d}"`)
data[deps][d] = hosted.toString()
Expand Down
2 changes: 1 addition & 1 deletion node_modules/@npmcli/package-json/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@npmcli/package-json",
"version": "5.0.1",
"version": "5.0.2",
"description": "Programmatic API to update package.json",
"main": "lib/index.js",
"files": [
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
"@npmcli/config": "^8.0.2",
"@npmcli/fs": "^3.1.0",
"@npmcli/map-workspaces": "^3.0.4",
"@npmcli/package-json": "^5.0.1",
"@npmcli/package-json": "^5.0.2",
"@npmcli/promise-spawn": "^7.0.1",
"@npmcli/redact": "^1.1.0",
"@npmcli/run-script": "^7.0.4",
Expand Down Expand Up @@ -1805,9 +1805,9 @@
}
},
"node_modules/@npmcli/package-json": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/@npmcli/package-json/-/package-json-5.0.1.tgz",
"integrity": "sha512-WdwGsRP/do+94IXEgfD/oGGVn0VDS+wYM8MoXU5tJ+02Ke8ePSobMwnfcCHAfcvU/pFwZxyZYWaJdOBsqXRAbA==",
"version": "5.0.2",
"resolved": "https://registry.npmjs.org/@npmcli/package-json/-/package-json-5.0.2.tgz",
"integrity": "sha512-LmW+tueGSK+FCM3OpcKtwKKo3igpefh6HHiw23sGd8OdJ8l0GrfGfVdGOFVtJRMaXVnvI1RUdEPlB9VUln5Wbw==",
"inBundle": true,
"dependencies": {
"@npmcli/git": "^5.0.0",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
"@npmcli/config": "^8.0.2",
"@npmcli/fs": "^3.1.0",
"@npmcli/map-workspaces": "^3.0.4",
"@npmcli/package-json": "^5.0.1",
"@npmcli/package-json": "^5.0.2",
"@npmcli/promise-spawn": "^7.0.1",
"@npmcli/redact": "^1.1.0",
"@npmcli/run-script": "^7.0.4",
Expand Down

0 comments on commit f69052e

Please sign in to comment.