diff --git a/node_modules/@npmcli/package-json/lib/index.js b/node_modules/@npmcli/package-json/lib/index.js index 87c3a63093688..e98308f3d3b84 100644 --- a/node_modules/@npmcli/package-json/lib/index.js +++ b/node_modules/@npmcli/package-json/lib/index.js @@ -73,13 +73,15 @@ class PackageJson { ) } - for (const step of knownSteps) + for (const step of knownSteps) { this[_manifest] = step({ content, originalContent: this[_manifest] }) + } // unknown properties will just be overwitten for (const [key, value] of Object.entries(content)) { - if (!knownKeys.has(key)) + if (!knownKeys.has(key)) { this[_manifest][key] = value + } } return this @@ -98,8 +100,9 @@ class PackageJson { }\n` .replace(/\n/g, eol) - if (fileContent.trim() !== this[_readFileContent].trim()) + if (fileContent.trim() !== this[_readFileContent].trim()) { return await writeFile(this[_filename], fileContent) + } } } diff --git a/node_modules/@npmcli/package-json/lib/update-dependencies.js b/node_modules/@npmcli/package-json/lib/update-dependencies.js index dac45a8bed7bf..7259949ab661d 100644 --- a/node_modules/@npmcli/package-json/lib/update-dependencies.js +++ b/node_modules/@npmcli/package-json/lib/update-dependencies.js @@ -28,8 +28,9 @@ const updateDependencies = ({ content, originalContent }) => { // optionalDependencies don't need to be repeated in two places if (pkg.dependencies) { if (pkg.optionalDependencies) { - for (const name of Object.keys(pkg.optionalDependencies)) + for (const name of Object.keys(pkg.optionalDependencies)) { delete pkg.dependencies[name] + } } } @@ -37,16 +38,18 @@ const updateDependencies = ({ content, originalContent }) => { // loop through all types of dependencies and update package json pkg for (const type of depTypes) { - if (pkg[type]) + if (pkg[type]) { result[type] = pkg[type] + } // prune empty type props from resulting object const emptyDepType = pkg[type] && typeof pkg === 'object' && Object.keys(pkg[type]).length === 0 - if (emptyDepType) + if (emptyDepType) { delete result[type] + } } // if original package.json had dep in peerDeps AND deps, preserve that. diff --git a/node_modules/@npmcli/package-json/lib/update-scripts.js b/node_modules/@npmcli/package-json/lib/update-scripts.js index 3a88d3e9a17a8..30495e54cc3c7 100644 --- a/node_modules/@npmcli/package-json/lib/update-scripts.js +++ b/node_modules/@npmcli/package-json/lib/update-scripts.js @@ -1,8 +1,9 @@ const updateScripts = ({ content, originalContent = {} }) => { const newScripts = content.scripts - if (!newScripts) + if (!newScripts) { return originalContent + } // validate scripts content being appended const hasInvalidScripts = () => diff --git a/node_modules/@npmcli/package-json/lib/update-workspaces.js b/node_modules/@npmcli/package-json/lib/update-workspaces.js index 207dd94a236d7..04bf63230636f 100644 --- a/node_modules/@npmcli/package-json/lib/update-workspaces.js +++ b/node_modules/@npmcli/package-json/lib/update-workspaces.js @@ -1,8 +1,9 @@ const updateWorkspaces = ({ content, originalContent = {} }) => { const newWorkspaces = content.workspaces - if (!newWorkspaces) + if (!newWorkspaces) { return originalContent + } // validate workspaces content being appended const hasInvalidWorkspaces = () => diff --git a/node_modules/@npmcli/package-json/package.json b/node_modules/@npmcli/package-json/package.json index 8708ec5eb6fb1..d2c4b9da9db62 100644 --- a/node_modules/@npmcli/package-json/package.json +++ b/node_modules/@npmcli/package-json/package.json @@ -1,10 +1,11 @@ { "name": "@npmcli/package-json", - "version": "1.0.1", + "version": "2.0.0", "description": "Programmatic API to update package.json", "main": "lib/index.js", "files": [ - "lib" + "bin/", + "lib/" ], "scripts": { "preversion": "npm test", @@ -12,11 +13,12 @@ "prepublishOnly": "git push origin --follow-tags", "snap": "tap", "test": "tap", - "npmclilint": "npmcli-lint", - "lint": "npm run npmclilint -- \"lib/*.*js\" \"test/*.*js\"", + "lint": "eslint \"**/*.js\"", "lintfix": "npm run lint -- --fix", - "posttest": "npm run lint --", - "postsnap": "npm run lintfix --" + "posttest": "npm run lint", + "postsnap": "npm run lintfix --", + "postlint": "template-oss-check", + "template-oss-apply": "template-oss-apply --force" }, "keywords": [ "npm", @@ -25,10 +27,22 @@ "author": "GitHub Inc.", "license": "ISC", "devDependencies": { - "@npmcli/lint": "^1.0.1", - "tap": "^15.0.9" + "@npmcli/eslint-config": "^3.0.1", + "@npmcli/template-oss": "3.2.2", + "tap": "^16.0.1" }, "dependencies": { "json-parse-even-better-errors": "^2.3.1" + }, + "repository": { + "type": "git", + "url": "https://github.com/npm/package-json.git" + }, + "engines": { + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" + }, + "templateOSS": { + "//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.", + "version": "3.2.2" } } diff --git a/package-lock.json b/package-lock.json index 977e8634fc73d..e8845ebbe54c3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -93,7 +93,7 @@ "@npmcli/config": "^4.0.1", "@npmcli/fs": "^2.1.0", "@npmcli/map-workspaces": "^2.0.2", - "@npmcli/package-json": "^1.0.1", + "@npmcli/package-json": "^2.0.0", "@npmcli/run-script": "^3.0.1", "abbrev": "~1.1.1", "ansicolors": "~0.3.2", @@ -973,11 +973,15 @@ "license": "ISC" }, "node_modules/@npmcli/package-json": { - "version": "1.0.1", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@npmcli/package-json/-/package-json-2.0.0.tgz", + "integrity": "sha512-42jnZ6yl16GzjWSH7vtrmWyJDGVa/LXPdpN2rcUWolFjc9ON2N3uz0qdBbQACfmhuJZ2lbKYtmK5qx68ZPLHMA==", "inBundle": true, - "license": "ISC", "dependencies": { "json-parse-even-better-errors": "^2.3.1" + }, + "engines": { + "node": "^12.13.0 || ^14.15.0 || >=16.0.0" } }, "node_modules/@npmcli/promise-spawn": { @@ -1033,6 +1037,15 @@ "node": "^12.13.0 || ^14.15.0 || >=16.0.0" } }, + "node_modules/@npmcli/template-oss/node_modules/@npmcli/package-json": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@npmcli/package-json/-/package-json-1.0.1.tgz", + "integrity": "sha512-y6jnu76E9C23osz8gEMBayZmaZ69vFOIk8vR1FJL/wbEJ54+9aVG9rLTjQKSXfgYZEr50nw1txBBFfBZZe+bYg==", + "dev": true, + "dependencies": { + "json-parse-even-better-errors": "^2.3.1" + } + }, "node_modules/@npmcli/template-oss/node_modules/yaml": { "version": "2.0.0-11", "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.0.0-11.tgz", @@ -9521,7 +9534,7 @@ "@npmcli/move-file": "^1.1.0", "@npmcli/name-from-folder": "^1.0.1", "@npmcli/node-gyp": "^1.0.3", - "@npmcli/package-json": "^1.0.1", + "@npmcli/package-json": "^2.0.0", "@npmcli/run-script": "^3.0.0", "bin-links": "^3.0.0", "cacache": "^16.0.0", @@ -10193,7 +10206,7 @@ "@npmcli/move-file": "^1.1.0", "@npmcli/name-from-folder": "^1.0.1", "@npmcli/node-gyp": "^1.0.3", - "@npmcli/package-json": "^1.0.1", + "@npmcli/package-json": "2.0.0", "@npmcli/run-script": "^3.0.0", "@npmcli/template-oss": "3.2.2", "benchmark": "^2.1.4", @@ -10338,7 +10351,9 @@ "version": "1.0.3" }, "@npmcli/package-json": { - "version": "1.0.1", + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/@npmcli/package-json/-/package-json-2.0.0.tgz", + "integrity": "sha512-42jnZ6yl16GzjWSH7vtrmWyJDGVa/LXPdpN2rcUWolFjc9ON2N3uz0qdBbQACfmhuJZ2lbKYtmK5qx68ZPLHMA==", "requires": { "json-parse-even-better-errors": "^2.3.1" } @@ -10382,6 +10397,15 @@ "yaml": "^2.0.0-11" }, "dependencies": { + "@npmcli/package-json": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/@npmcli/package-json/-/package-json-1.0.1.tgz", + "integrity": "sha512-y6jnu76E9C23osz8gEMBayZmaZ69vFOIk8vR1FJL/wbEJ54+9aVG9rLTjQKSXfgYZEr50nw1txBBFfBZZe+bYg==", + "dev": true, + "requires": { + "json-parse-even-better-errors": "^2.3.1" + } + }, "yaml": { "version": "2.0.0-11", "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.0.0-11.tgz", diff --git a/package.json b/package.json index 55ef611cde406..1410f3c6dfc80 100644 --- a/package.json +++ b/package.json @@ -60,7 +60,7 @@ "@npmcli/config": "^4.0.1", "@npmcli/fs": "^2.1.0", "@npmcli/map-workspaces": "^2.0.2", - "@npmcli/package-json": "^1.0.1", + "@npmcli/package-json": "^2.0.0", "@npmcli/run-script": "^3.0.1", "abbrev": "~1.1.1", "ansicolors": "~0.3.2", diff --git a/workspaces/arborist/package.json b/workspaces/arborist/package.json index 8913b4449e238..1f086c638e17d 100644 --- a/workspaces/arborist/package.json +++ b/workspaces/arborist/package.json @@ -10,7 +10,7 @@ "@npmcli/move-file": "^1.1.0", "@npmcli/name-from-folder": "^1.0.1", "@npmcli/node-gyp": "^1.0.3", - "@npmcli/package-json": "^1.0.1", + "@npmcli/package-json": "^2.0.0", "@npmcli/run-script": "^3.0.0", "bin-links": "^3.0.0", "cacache": "^16.0.0",