Skip to content

Commit b87ba24

Browse files
committed
deps: @npmcli/[email protected]
1 parent 1be8e95 commit b87ba24

File tree

5 files changed

+131
-25
lines changed

5 files changed

+131
-25
lines changed

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

+7-2
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ const updateScripts = require('./update-scripts.js')
77
const updateWorkspaces = require('./update-workspaces.js')
88
const normalize = require('./normalize.js')
99
const { read, parse } = require('./read-package.js')
10+
const { packageSort } = require('./sort.js')
1011

1112
// a list of handy specialized helper functions that take
1213
// care of special cases that are handled by the npm cli
@@ -230,19 +231,23 @@ class PackageJson {
230231
return this
231232
}
232233

233-
async save () {
234+
async save ({ sort } = {}) {
234235
if (!this.#canSave) {
235236
throw new Error('No package.json to save to')
236237
}
237238
const {
238239
[Symbol.for('indent')]: indent,
239240
[Symbol.for('newline')]: newline,
241+
...rest
240242
} = this.content
241243

242244
const format = indent === undefined ? ' ' : indent
243245
const eol = newline === undefined ? '\n' : newline
246+
247+
const content = sort ? packageSort(rest) : rest
248+
244249
const fileContent = `${
245-
JSON.stringify(this.content, null, format)
250+
JSON.stringify(content, null, format)
246251
}\n`
247252
.replace(/\n/g, eol)
248253

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
/**
2+
* arbitrary sort order for package.json largely pulled from:
3+
* https://github.com/keithamus/sort-package-json/blob/main/defaultRules.md
4+
*
5+
* cross checked with:
6+
* https://github.com/npm/types/blob/main/types/index.d.ts#L104
7+
* https://docs.npmjs.com/cli/configuring-npm/package-json
8+
*/
9+
function packageSort (json) {
10+
const {
11+
name,
12+
version,
13+
private: isPrivate,
14+
description,
15+
keywords,
16+
homepage,
17+
bugs,
18+
repository,
19+
funding,
20+
license,
21+
author,
22+
maintainers,
23+
contributors,
24+
type,
25+
imports,
26+
exports,
27+
main,
28+
browser,
29+
types,
30+
bin,
31+
man,
32+
directories,
33+
files,
34+
workspaces,
35+
scripts,
36+
config,
37+
dependencies,
38+
devDependencies,
39+
peerDependencies,
40+
peerDependenciesMeta,
41+
optionalDependencies,
42+
bundledDependencies,
43+
bundleDependencies,
44+
engines,
45+
os,
46+
cpu,
47+
publishConfig,
48+
devEngines,
49+
licenses,
50+
overrides,
51+
...rest
52+
} = json
53+
54+
return {
55+
...(typeof name !== 'undefined' ? { name } : {}),
56+
...(typeof version !== 'undefined' ? { version } : {}),
57+
...(typeof isPrivate !== 'undefined' ? { private: isPrivate } : {}),
58+
...(typeof description !== 'undefined' ? { description } : {}),
59+
...(typeof keywords !== 'undefined' ? { keywords } : {}),
60+
...(typeof homepage !== 'undefined' ? { homepage } : {}),
61+
...(typeof bugs !== 'undefined' ? { bugs } : {}),
62+
...(typeof repository !== 'undefined' ? { repository } : {}),
63+
...(typeof funding !== 'undefined' ? { funding } : {}),
64+
...(typeof license !== 'undefined' ? { license } : {}),
65+
...(typeof author !== 'undefined' ? { author } : {}),
66+
...(typeof maintainers !== 'undefined' ? { maintainers } : {}),
67+
...(typeof contributors !== 'undefined' ? { contributors } : {}),
68+
...(typeof type !== 'undefined' ? { type } : {}),
69+
...(typeof imports !== 'undefined' ? { imports } : {}),
70+
...(typeof exports !== 'undefined' ? { exports } : {}),
71+
...(typeof main !== 'undefined' ? { main } : {}),
72+
...(typeof browser !== 'undefined' ? { browser } : {}),
73+
...(typeof types !== 'undefined' ? { types } : {}),
74+
...(typeof bin !== 'undefined' ? { bin } : {}),
75+
...(typeof man !== 'undefined' ? { man } : {}),
76+
...(typeof directories !== 'undefined' ? { directories } : {}),
77+
...(typeof files !== 'undefined' ? { files } : {}),
78+
...(typeof workspaces !== 'undefined' ? { workspaces } : {}),
79+
...(typeof scripts !== 'undefined' ? { scripts } : {}),
80+
...(typeof config !== 'undefined' ? { config } : {}),
81+
...(typeof dependencies !== 'undefined' ? { dependencies } : {}),
82+
...(typeof devDependencies !== 'undefined' ? { devDependencies } : {}),
83+
...(typeof peerDependencies !== 'undefined' ? { peerDependencies } : {}),
84+
...(typeof peerDependenciesMeta !== 'undefined' ? { peerDependenciesMeta } : {}),
85+
...(typeof optionalDependencies !== 'undefined' ? { optionalDependencies } : {}),
86+
...(typeof bundledDependencies !== 'undefined' ? { bundledDependencies } : {}),
87+
...(typeof bundleDependencies !== 'undefined' ? { bundleDependencies } : {}),
88+
...(typeof engines !== 'undefined' ? { engines } : {}),
89+
...(typeof os !== 'undefined' ? { os } : {}),
90+
...(typeof cpu !== 'undefined' ? { cpu } : {}),
91+
...(typeof publishConfig !== 'undefined' ? { publishConfig } : {}),
92+
...(typeof devEngines !== 'undefined' ? { devEngines } : {}),
93+
...(typeof licenses !== 'undefined' ? { licenses } : {}),
94+
...(typeof overrides !== 'undefined' ? { overrides } : {}),
95+
...rest,
96+
}
97+
}
98+
99+
module.exports = {
100+
packageSort,
101+
}

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

+18-18
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,17 @@
11
{
22
"name": "@npmcli/package-json",
3-
"version": "6.0.1",
3+
"version": "6.1.0",
44
"description": "Programmatic API to update package.json",
5+
"keywords": [
6+
"npm",
7+
"oss"
8+
],
9+
"repository": {
10+
"type": "git",
11+
"url": "git+https://github.com/npm/package-json.git"
12+
},
13+
"license": "ISC",
14+
"author": "GitHub Inc.",
515
"main": "lib/index.js",
616
"files": [
717
"bin/",
@@ -18,19 +28,6 @@
1828
"template-oss-apply": "template-oss-apply --force",
1929
"eslint": "eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\""
2030
},
21-
"keywords": [
22-
"npm",
23-
"oss"
24-
],
25-
"author": "GitHub Inc.",
26-
"license": "ISC",
27-
"devDependencies": {
28-
"@npmcli/eslint-config": "^5.0.0",
29-
"@npmcli/template-oss": "4.23.3",
30-
"read-package-json": "^7.0.0",
31-
"read-package-json-fast": "^4.0.0",
32-
"tap": "^16.0.1"
33-
},
3431
"dependencies": {
3532
"@npmcli/git": "^6.0.0",
3633
"glob": "^10.2.2",
@@ -40,16 +37,19 @@
4037
"proc-log": "^5.0.0",
4138
"semver": "^7.5.3"
4239
},
43-
"repository": {
44-
"type": "git",
45-
"url": "git+https://github.com/npm/package-json.git"
40+
"devDependencies": {
41+
"@npmcli/eslint-config": "^5.0.0",
42+
"@npmcli/template-oss": "4.23.5",
43+
"read-package-json": "^7.0.0",
44+
"read-package-json-fast": "^4.0.0",
45+
"tap": "^16.0.1"
4646
},
4747
"engines": {
4848
"node": "^18.17.0 || >=20.5.0"
4949
},
5050
"templateOSS": {
5151
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
52-
"version": "4.23.3",
52+
"version": "4.23.5",
5353
"publish": "true"
5454
},
5555
"tap": {

package-lock.json

+4-4
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@
8989
"@npmcli/config": "^10.0.0-pre.0",
9090
"@npmcli/fs": "^4.0.0",
9191
"@npmcli/map-workspaces": "^4.0.2",
92-
"@npmcli/package-json": "^6.0.1",
92+
"@npmcli/package-json": "^6.1.0",
9393
"@npmcli/promise-spawn": "^8.0.2",
9494
"@npmcli/redact": "^3.0.0",
9595
"@npmcli/run-script": "^9.0.1",
@@ -3537,9 +3537,9 @@
35373537
}
35383538
},
35393539
"node_modules/@npmcli/package-json": {
3540-
"version": "6.0.1",
3541-
"resolved": "https://registry.npmjs.org/@npmcli/package-json/-/package-json-6.0.1.tgz",
3542-
"integrity": "sha512-YW6PZ99sc1Q4DINEY2td5z9Z3rwbbsx7CyCnOc7UXUUdePXh5gPi1UeaoQVmKQMVbIU7aOwX2l1OG5ZfjgGi5g==",
3540+
"version": "6.1.0",
3541+
"resolved": "https://registry.npmjs.org/@npmcli/package-json/-/package-json-6.1.0.tgz",
3542+
"integrity": "sha512-t6G+6ZInT4X+tqj2i+wlLIeCKnKOTuz9/VFYDtj+TGTur5q7sp/OYrQA19LdBbWfXDOi0Y4jtedV6xtB8zQ9ug==",
35433543
"inBundle": true,
35443544
"license": "ISC",
35453545
"dependencies": {

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
"@npmcli/config": "^10.0.0-pre.0",
5757
"@npmcli/fs": "^4.0.0",
5858
"@npmcli/map-workspaces": "^4.0.2",
59-
"@npmcli/package-json": "^6.0.1",
59+
"@npmcli/package-json": "^6.1.0",
6060
"@npmcli/promise-spawn": "^8.0.2",
6161
"@npmcli/redact": "^3.0.0",
6262
"@npmcli/run-script": "^9.0.1",

0 commit comments

Comments
 (0)