Content-Length: 499508 | pFad | http://github.com/npm/cli/pull/7945/commits/9a6a7f19a9709d56c7e9ffb2be99ccabc95dba2d

3C npm-packlist et al update by wraithgar · Pull Request #7945 · npm/cli · GitHub
Skip to content

npm-packlist et al update #7945

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Dec 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
deps: @npmcli/package-json@6.1.0
  • Loading branch information
wraithgar committed Nov 27, 2024
commit 9a6a7f19a9709d56c7e9ffb2be99ccabc95dba2d
9 changes: 7 additions & 2 deletions node_modules/@npmcli/package-json/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const updateScripts = require('./update-scripts.js')
const updateWorkspaces = require('./update-workspaces.js')
const normalize = require('./normalize.js')
const { read, parse } = require('./read-package.js')
const { packageSort } = require('./sort.js')

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

async save () {
async save ({ sort } = {}) {
if (!this.#canSave) {
throw new Error('No package.json to save to')
}
const {
[Symbol.for('indent')]: indent,
[Symbol.for('newline')]: newline,
...rest
} = this.content

const format = indent === undefined ? ' ' : indent
const eol = newline === undefined ? '\n' : newline

const content = sort ? packageSort(rest) : rest

const fileContent = `${
JSON.stringify(this.content, null, format)
JSON.stringify(content, null, format)
}\n`
.replace(/\n/g, eol)

Expand Down
101 changes: 101 additions & 0 deletions node_modules/@npmcli/package-json/lib/sort.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/**
* arbitrary sort order for package.json largely pulled from:
* https://github.com/keithamus/sort-package-json/blob/main/defaultRules.md
*
* cross checked with:
* https://github.com/npm/types/blob/main/types/index.d.ts#L104
* https://docs.npmjs.com/cli/configuring-npm/package-json
*/
function packageSort (json) {
const {
name,
version,
private: isPrivate,
description,
keywords,
homepage,
bugs,
repository,
funding,
license,
author,
maintainers,
contributors,
type,
imports,
exports,
main,
browser,
types,
bin,
man,
directories,
files,
workspaces,
scripts,
config,
dependencies,
devDependencies,
peerDependencies,
peerDependenciesMeta,
optionalDependencies,
bundledDependencies,
bundleDependencies,
engines,
os,
cpu,
publishConfig,
devEngines,
licenses,
overrides,
...rest
} = json

return {
...(typeof name !== 'undefined' ? { name } : {}),
...(typeof version !== 'undefined' ? { version } : {}),
...(typeof isPrivate !== 'undefined' ? { private: isPrivate } : {}),
...(typeof description !== 'undefined' ? { description } : {}),
...(typeof keywords !== 'undefined' ? { keywords } : {}),
...(typeof homepage !== 'undefined' ? { homepage } : {}),
...(typeof bugs !== 'undefined' ? { bugs } : {}),
...(typeof repository !== 'undefined' ? { repository } : {}),
...(typeof funding !== 'undefined' ? { funding } : {}),
...(typeof license !== 'undefined' ? { license } : {}),
...(typeof author !== 'undefined' ? { author } : {}),
...(typeof maintainers !== 'undefined' ? { maintainers } : {}),
...(typeof contributors !== 'undefined' ? { contributors } : {}),
...(typeof type !== 'undefined' ? { type } : {}),
...(typeof imports !== 'undefined' ? { imports } : {}),
...(typeof exports !== 'undefined' ? { exports } : {}),
...(typeof main !== 'undefined' ? { main } : {}),
...(typeof browser !== 'undefined' ? { browser } : {}),
...(typeof types !== 'undefined' ? { types } : {}),
...(typeof bin !== 'undefined' ? { bin } : {}),
...(typeof man !== 'undefined' ? { man } : {}),
...(typeof directories !== 'undefined' ? { directories } : {}),
...(typeof files !== 'undefined' ? { files } : {}),
...(typeof workspaces !== 'undefined' ? { workspaces } : {}),
...(typeof scripts !== 'undefined' ? { scripts } : {}),
...(typeof config !== 'undefined' ? { config } : {}),
...(typeof dependencies !== 'undefined' ? { dependencies } : {}),
...(typeof devDependencies !== 'undefined' ? { devDependencies } : {}),
...(typeof peerDependencies !== 'undefined' ? { peerDependencies } : {}),
...(typeof peerDependenciesMeta !== 'undefined' ? { peerDependenciesMeta } : {}),
...(typeof optionalDependencies !== 'undefined' ? { optionalDependencies } : {}),
...(typeof bundledDependencies !== 'undefined' ? { bundledDependencies } : {}),
...(typeof bundleDependencies !== 'undefined' ? { bundleDependencies } : {}),
...(typeof engines !== 'undefined' ? { engines } : {}),
...(typeof os !== 'undefined' ? { os } : {}),
...(typeof cpu !== 'undefined' ? { cpu } : {}),
...(typeof publishConfig !== 'undefined' ? { publishConfig } : {}),
...(typeof devEngines !== 'undefined' ? { devEngines } : {}),
...(typeof licenses !== 'undefined' ? { licenses } : {}),
...(typeof overrides !== 'undefined' ? { overrides } : {}),
...rest,
}
}

module.exports = {
packageSort,
}
36 changes: 18 additions & 18 deletions node_modules/@npmcli/package-json/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,17 @@
{
"name": "@npmcli/package-json",
"version": "6.0.1",
"version": "6.1.0",
"description": "Programmatic API to update package.json",
"keywords": [
"npm",
"oss"
],
"repository": {
"type": "git",
"url": "git+https://github.com/npm/package-json.git"
},
"license": "ISC",
"author": "GitHub Inc.",
"main": "lib/index.js",
"files": [
"bin/",
Expand All @@ -18,19 +28,6 @@
"template-oss-apply": "template-oss-apply --force",
"eslint": "eslint \"**/*.{js,cjs,ts,mjs,jsx,tsx}\""
},
"keywords": [
"npm",
"oss"
],
"author": "GitHub Inc.",
"license": "ISC",
"devDependencies": {
"@npmcli/eslint-config": "^5.0.0",
"@npmcli/template-oss": "4.23.3",
"read-package-json": "^7.0.0",
"read-package-json-fast": "^4.0.0",
"tap": "^16.0.1"
},
"dependencies": {
"@npmcli/git": "^6.0.0",
"glob": "^10.2.2",
Expand All @@ -40,16 +37,19 @@
"proc-log": "^5.0.0",
"semver": "^7.5.3"
},
"repository": {
"type": "git",
"url": "git+https://github.com/npm/package-json.git"
"devDependencies": {
"@npmcli/eslint-config": "^5.0.0",
"@npmcli/template-oss": "4.23.5",
"read-package-json": "^7.0.0",
"read-package-json-fast": "^4.0.0",
"tap": "^16.0.1"
},
"engines": {
"node": "^18.17.0 || >=20.5.0"
},
"templateOSS": {
"//@npmcli/template-oss": "This file is partially managed by @npmcli/template-oss. Edits may be overwritten.",
"version": "4.23.3",
"version": "4.23.5",
"publish": "true"
},
"tap": {
Expand Down
8 changes: 4 additions & 4 deletions package-lock.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@
"@npmcli/config": "^10.0.0-pre.0",
"@npmcli/fs": "^4.0.0",
"@npmcli/map-workspaces": "^4.0.2",
"@npmcli/package-json": "^6.0.1",
"@npmcli/package-json": "^6.1.0",
"@npmcli/promise-spawn": "^8.0.2",
"@npmcli/redact": "^3.0.0",
"@npmcli/run-script": "^9.0.1",
Expand Down Expand Up @@ -3537,9 +3537,9 @@
}
},
"node_modules/@npmcli/package-json": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/@npmcli/package-json/-/package-json-6.0.1.tgz",
"integrity": "sha512-YW6PZ99sc1Q4DINEY2td5z9Z3rwbbsx7CyCnOc7UXUUdePXh5gPi1UeaoQVmKQMVbIU7aOwX2l1OG5ZfjgGi5g==",
"version": "6.1.0",
"resolved": "https://registry.npmjs.org/@npmcli/package-json/-/package-json-6.1.0.tgz",
"integrity": "sha512-t6G+6ZInT4X+tqj2i+wlLIeCKnKOTuz9/VFYDtj+TGTur5q7sp/OYrQA19LdBbWfXDOi0Y4jtedV6xtB8zQ9ug==",
"inBundle": true,
"license": "ISC",
"dependencies": {
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": "^10.0.0-pre.0",
"@npmcli/fs": "^4.0.0",
"@npmcli/map-workspaces": "^4.0.2",
"@npmcli/package-json": "^6.0.1",
"@npmcli/package-json": "^6.1.0",
"@npmcli/promise-spawn": "^8.0.2",
"@npmcli/redact": "^3.0.0",
"@npmcli/run-script": "^9.0.1",
Expand Down








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/npm/cli/pull/7945/commits/9a6a7f19a9709d56c7e9ffb2be99ccabc95dba2d

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy