Skip to content

Commit

Permalink
deps: @npmcli/[email protected]
Browse files Browse the repository at this point in the history
  • Loading branch information
wraithgar committed Apr 6, 2022
1 parent e034a8e commit 4a9a705
Show file tree
Hide file tree
Showing 8 changed files with 70 additions and 24 deletions.
9 changes: 6 additions & 3 deletions node_modules/@npmcli/package-json/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
}
}
}

Expand Down
9 changes: 6 additions & 3 deletions node_modules/@npmcli/package-json/lib/update-dependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,25 +28,28 @@ 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]
}
}
}

const result = { ...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.
Expand Down
3 changes: 2 additions & 1 deletion node_modules/@npmcli/package-json/lib/update-scripts.js
Original file line number Diff line number Diff line change
@@ -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 = () =>
Expand Down
3 changes: 2 additions & 1 deletion node_modules/@npmcli/package-json/lib/update-workspaces.js
Original file line number Diff line number Diff line change
@@ -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 = () =>
Expand Down
30 changes: 22 additions & 8 deletions node_modules/@npmcli/package-json/package.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,24 @@
{
"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",
"postversion": "npm publish",
"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",
Expand All @@ -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"
}
}
36 changes: 30 additions & 6 deletions package-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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": {
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down Expand Up @@ -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"
}
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion workspaces/arborist/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 4a9a705

Please sign in to comment.