Skip to content

Commit 26264da

Browse files
committed
feat(patch): add npm patch update to rebase a patch onto a new version
1 parent 53f2c95 commit 26264da

8 files changed

Lines changed: 800 additions & 24 deletions

File tree

lib/commands/patch.js

Lines changed: 373 additions & 20 deletions
Large diffs are not rendered by default.

package-lock.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"@npmcli/arborist",
1313
"@npmcli/config",
1414
"@npmcli/fs",
15+
"@npmcli/git",
1516
"@npmcli/map-workspaces",
1617
"@npmcli/metavuln-calculator",
1718
"@npmcli/package-json",
@@ -88,6 +89,7 @@
8889
"@npmcli/arborist": "^10.0.0-pre.0",
8990
"@npmcli/config": "^11.0.0-pre.0",
9091
"@npmcli/fs": "^5.0.0",
92+
"@npmcli/git": "^7.0.2",
9193
"@npmcli/map-workspaces": "^5.0.3",
9294
"@npmcli/metavuln-calculator": "^9.0.3",
9395
"@npmcli/package-json": "^7.0.5",
@@ -158,7 +160,6 @@
158160
"devDependencies": {
159161
"@npmcli/docs": "^1.0.0",
160162
"@npmcli/eslint-config": "^5.1.0",
161-
"@npmcli/git": "^7.0.2",
162163
"@npmcli/mock-globals": "^1.0.0",
163164
"@npmcli/mock-registry": "^1.0.0",
164165
"@npmcli/template-oss": "4.29.0",

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
"@npmcli/arborist": "^10.0.0-pre.0",
5252
"@npmcli/config": "^11.0.0-pre.0",
5353
"@npmcli/fs": "^5.0.0",
54+
"@npmcli/git": "^7.0.2",
5455
"@npmcli/map-workspaces": "^5.0.3",
5556
"@npmcli/metavuln-calculator": "^9.0.3",
5657
"@npmcli/package-json": "^7.0.5",
@@ -119,6 +120,7 @@
119120
"@npmcli/arborist",
120121
"@npmcli/config",
121122
"@npmcli/fs",
123+
"@npmcli/git",
122124
"@npmcli/map-workspaces",
123125
"@npmcli/metavuln-calculator",
124126
"@npmcli/package-json",
@@ -185,7 +187,6 @@
185187
"devDependencies": {
186188
"@npmcli/docs": "^1.0.0",
187189
"@npmcli/eslint-config": "^5.1.0",
188-
"@npmcli/git": "^7.0.2",
189190
"@npmcli/mock-globals": "^1.0.0",
190191
"@npmcli/mock-registry": "^1.0.0",
191192
"@npmcli/template-oss": "4.29.0",

tap-snapshots/test/lib/commands/config.js.test.cjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ exports[`test/lib/commands/config.js TAP config list --json > output matches sna
181181
"strict-ssl": true,
182182
"tag-version-prefix": "v",
183183
"timing": false,
184+
"to": null,
184185
"umask": 0,
185186
"unicode": false,
186187
"update-notifier": true,
@@ -374,6 +375,7 @@ strict-ssl = true
374375
; tag = "latest" ; overridden by project
375376
tag-version-prefix = "v"
376377
timing = false
378+
to = null
377379
token-description = null
378380
umask = 0
379381
unicode = false

tap-snapshots/test/lib/docs.js.test.cjs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2074,6 +2074,17 @@ while still writing the timing file, use \`--silent\`.
20742074
20752075
20762076
2077+
#### \`to\`
2078+
2079+
* Default: null
2080+
* Type: null or String
2081+
2082+
Used by \`npm patch update\` to set the version to rebase a patch onto when it
2083+
cannot be read from \`package-lock.json\` — for example an exact-version
2084+
selector, or a version that has not been installed yet.
2085+
2086+
2087+
20772088
#### \`token-description\`
20782089
20792090
* Default: null
@@ -2650,6 +2661,7 @@ Array [
26502661
"tag",
26512662
"tag-version-prefix",
26522663
"timing",
2664+
"to",
26532665
"umask",
26542666
"unicode",
26552667
"update-notifier",
@@ -2852,6 +2864,7 @@ Array [
28522864
"keep-edit-dir",
28532865
"prefix",
28542866
"timing",
2867+
"to",
28552868
"update-notifier",
28562869
"usage",
28572870
"userconfig",
@@ -5336,12 +5349,13 @@ Usage:
53365349
npm patch <pkg>[@<version>]
53375350
npm patch add <pkg>[@<version>] [--edit-dir <path>] [--ignore-existing]
53385351
npm patch commit <edit-dir> [--patches-dir <dir>] [--keep-edit-dir]
5352+
npm patch update <pkg>[@<old-version>] [--to <new-version>] [--patches-dir <dir>]
53395353
npm patch ls
53405354
npm patch rm <pkg>[@<version>]
53415355
53425356
Options:
53435357
[--patches-dir <patches-dir>] [--allow-unused-patches] [--ignore-patch-failures]
5344-
[--edit-dir <edit-dir>] [--ignore-existing] [--keep-edit-dir]
5358+
[--edit-dir <edit-dir>] [--ignore-existing] [--keep-edit-dir] [--to <version>]
53455359
[--registry <registry>]
53465360
53475361
--patches-dir
@@ -5362,6 +5376,9 @@ Options:
53625376
--keep-edit-dir
53635377
With \`npm patch commit\`, do not remove the edit directory after
53645378
5379+
--to
5380+
Used by \`npm patch update\` to set the version to rebase a patch onto
5381+
53655382
--registry
53665383
The base URL of the npm registry.
53675384
@@ -5372,6 +5389,7 @@ Run "npm help patch" for more info
53725389
npm patch <pkg>[@<version>]
53735390
npm patch add <pkg>[@<version>] [--edit-dir <path>] [--ignore-existing]
53745391
npm patch commit <edit-dir> [--patches-dir <dir>] [--keep-edit-dir]
5392+
npm patch update <pkg>[@<old-version>] [--to <new-version>] [--patches-dir <dir>]
53755393
npm patch ls
53765394
npm patch rm <pkg>[@<version>]
53775395
\`\`\`
@@ -5384,6 +5402,7 @@ Note: This command is unaware of workspaces.
53845402
#### \`edit-dir\`
53855403
#### \`ignore-existing\`
53865404
#### \`keep-edit-dir\`
5405+
#### \`to\`
53875406
#### \`registry\`
53885407
`
53895408

0 commit comments

Comments
 (0)