npm-diff.1 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  1. .TH "NPM\-DIFF" "1" "October 2021" "" ""
  2. .SH "NAME"
  3. \fBnpm-diff\fR \- The registry diff command
  4. .SS Synopsis
  5. .P
  6. .RS 2
  7. .nf
  8. npm diff [\.\.\.<paths>]
  9. npm diff \-\-diff=<pkg\-name> [\.\.\.<paths>]
  10. npm diff \-\-diff=<version\-a> [\-\-diff=<version\-b>] [\.\.\.<paths>]
  11. npm diff \-\-diff=<spec\-a> [\-\-diff=<spec\-b>] [\.\.\.<paths>]
  12. npm diff [\-\-diff\-ignore\-all\-space] [\-\-diff\-name\-only] [\.\.\.<paths>]
  13. .fi
  14. .RE
  15. .SS Description
  16. .P
  17. Similar to its \fBgit diff\fP counterpart, this command will print diff patches
  18. of files for packages published to the npm registry\.
  19. .RS 0
  20. .IP \(bu 2
  21. \fBnpm diff \-\-diff=<spec\-a> \-\-diff=<spec\-b>\fP
  22. Compares two package versions using their registry specifiers, e\.g:
  23. \fBnpm diff \-\-diff=pkg@1\.0\.0 \-\-diff=pkg@^2\.0\.0\fP\|\. It's also possible to
  24. compare across forks of any package,
  25. e\.g: \fBnpm diff \-\-diff=pkg@1\.0\.0 \-\-diff=pkg\-fork@1\.0\.0\fP\|\.
  26. Any valid spec can be used, so that it's also possible to compare
  27. directories or git repositories,
  28. e\.g: \fBnpm diff \-\-diff=pkg@latest \-\-diff=\./packages/pkg\fP
  29. Here's an example comparing two different versions of a package named
  30. \fBabbrev\fP from the registry:
  31. .P
  32. .RS 2
  33. .nf
  34. npm diff \-\-diff=abbrev@1\.1\.0 \-\-diff=abbrev@1\.1\.1
  35. .fi
  36. .RE
  37. On success, output looks like:
  38. .P
  39. .RS 2
  40. .nf
  41. diff \-\-git a/package\.json b/package\.json
  42. index v1\.1\.0\.\.v1\.1\.1 100644
  43. \-\-\- a/package\.json
  44. +++ b/package\.json
  45. @@ \-1,6 +1,6 @@
  46. {
  47. "name": "abbrev",
  48. \- "version": "1\.1\.0",
  49. + "version": "1\.1\.1",
  50. "description": "Like ruby's abbrev module, but in js",
  51. "author": "Isaac Z\. Schlueter <i@izs\.me>",
  52. "main": "abbrev\.js",
  53. .fi
  54. .RE
  55. Given the flexible nature of npm specs, you can also target local
  56. directories or git repos just like when using \fBnpm install\fP:
  57. .P
  58. .RS 2
  59. .nf
  60. npm diff \-\-diff=https://github\.com/npm/libnpmdiff \-\-diff=\./local\-path
  61. .fi
  62. .RE
  63. In the example above we can compare the contents from the package installed
  64. from the git repo at \fBgithub\.com/npm/libnpmdiff\fP with the contents of the
  65. \fB\|\./local\-path\fP that contains a valid package, such as a modified copy of
  66. the original\.
  67. .IP \(bu 2
  68. \fBnpm diff\fP (in a package directory, no arguments):
  69. If the package is published to the registry, \fBnpm diff\fP will fetch the
  70. tarball version tagged as \fBlatest\fP (this value can be configured using the
  71. \fBtag\fP option) and proceed to compare the contents of files present in that
  72. tarball, with the current files in your local file system\.
  73. This workflow provides a handy way for package authors to see what
  74. package\-tracked files have been changed in comparison with the latest
  75. published version of that package\.
  76. .IP \(bu 2
  77. \fBnpm diff \-\-diff=<pkg\-name>\fP (in a package directory):
  78. When using a single package name (with no version or tag specifier) as an
  79. argument, \fBnpm diff\fP will work in a similar way to
  80. \fBnpm\-outdated\fP \fInpm\-outdated\fR and reach for the registry to figure out
  81. what current published version of the package named \fB<pkg\-name>\fP
  82. will satisfy its dependent declared semver\-range\. Once that specific
  83. version is known \fBnpm diff\fP will print diff patches comparing the
  84. current version of \fB<pkg\-name>\fP found in the local file system with
  85. that specific version returned by the registry\.
  86. Given a package named \fBabbrev\fP that is currently installed:
  87. .P
  88. .RS 2
  89. .nf
  90. npm diff \-\-diff=abbrev
  91. .fi
  92. .RE
  93. That will request from the registry its most up to date version and
  94. will print a diff output comparing the currently installed version to this
  95. newer one if the version numbers are not the same\.
  96. .IP \(bu 2
  97. \fBnpm diff \-\-diff=<spec\-a>\fP (in a package directory):
  98. Similar to using only a single package name, it's also possible to declare
  99. a full registry specifier version if you wish to compare the local version
  100. of an installed package with the specific version/tag/semver\-range provided
  101. in \fB<spec\-a>\fP\|\.
  102. An example: assuming \fBpkg@1\.0\.0\fP is installed in the current \fBnode_modules\fP
  103. folder, running:
  104. .P
  105. .RS 2
  106. .nf
  107. npm diff \-\-diff=pkg@2\.0\.0
  108. .fi
  109. .RE
  110. It will effectively be an alias to
  111. \fBnpm diff \-\-diff=pkg@1\.0\.0 \-\-diff=pkg@2\.0\.0\fP\|\.
  112. .IP \(bu 2
  113. \fBnpm diff \-\-diff=<semver\-a> [\-\-diff=<semver\-b>]\fP (in a package directory):
  114. Using \fBnpm diff\fP along with semver\-valid version numbers is a shorthand
  115. to compare different versions of the current package\.
  116. It needs to be run from a package directory, such that for a package named
  117. \fBpkg\fP running \fBnpm diff \-\-diff=1\.0\.0 \-\-diff=1\.0\.1\fP is the same as running
  118. \fBnpm diff \-\-diff=pkg@1\.0\.0 \-\-diff=pkg@1\.0\.1\fP\|\.
  119. If only a single argument \fB<version\-a>\fP is provided, then the current local
  120. file system is going to be compared against that version\.
  121. Here's an example comparing two specific versions (published to the
  122. configured registry) of the current project directory:
  123. .P
  124. .RS 2
  125. .nf
  126. npm diff \-\-diff=1\.0\.0 \-\-diff=1\.1\.0
  127. .fi
  128. .RE
  129. .RE
  130. .P
  131. Note that tag names are not valid \fB\-\-diff\fP argument values, if you wish to
  132. compare to a published tag, you must use the \fBpkg@tagname\fP syntax\.
  133. .SS Filtering files
  134. .P
  135. It's possible to also specify positional arguments using file names or globs
  136. pattern matching in order to limit the result of diff patches to only a subset
  137. of files for a given package, e\.g:
  138. .P
  139. .RS 2
  140. .nf
  141. npm diff \-\-diff=pkg@2 \./lib/ CHANGELOG\.md
  142. .fi
  143. .RE
  144. .P
  145. In the example above the diff output is only going to print contents of files
  146. located within the folder \fB\|\./lib/\fP and changed lines of code within the
  147. \fBCHANGELOG\.md\fP file\.
  148. .SS Configuration
  149. <!\-\- AUTOGENERATED CONFIG DESCRIPTIONS START \-\->
  150. <!\-\- automatically generated, do not edit manually \-\->
  151. <!\-\- see lib/utils/config/definitions\.js \-\->
  152. .SS \fBdiff\fP
  153. .RS 0
  154. .IP \(bu 2
  155. Default:
  156. .IP \(bu 2
  157. Type: String (can be set multiple times)
  158. .RE
  159. .P
  160. Define arguments to compare in \fBnpm diff\fP\|\.
  161. <!\-\- automatically generated, do not edit manually \-\->
  162. <!\-\- see lib/utils/config/definitions\.js \-\->
  163. .SS \fBdiff\-name\-only\fP
  164. .RS 0
  165. .IP \(bu 2
  166. Default: false
  167. .IP \(bu 2
  168. Type: Boolean
  169. .RE
  170. .P
  171. Prints only filenames when using \fBnpm diff\fP\|\.
  172. <!\-\- automatically generated, do not edit manually \-\->
  173. <!\-\- see lib/utils/config/definitions\.js \-\->
  174. .SS \fBdiff\-unified\fP
  175. .RS 0
  176. .IP \(bu 2
  177. Default: 3
  178. .IP \(bu 2
  179. Type: Number
  180. .RE
  181. .P
  182. The number of lines of context to print in \fBnpm diff\fP\|\.
  183. <!\-\- automatically generated, do not edit manually \-\->
  184. <!\-\- see lib/utils/config/definitions\.js \-\->
  185. .SS \fBdiff\-ignore\-all\-space\fP
  186. .RS 0
  187. .IP \(bu 2
  188. Default: false
  189. .IP \(bu 2
  190. Type: Boolean
  191. .RE
  192. .P
  193. Ignore whitespace when comparing lines in \fBnpm diff\fP\|\.
  194. <!\-\- automatically generated, do not edit manually \-\->
  195. <!\-\- see lib/utils/config/definitions\.js \-\->
  196. .SS \fBdiff\-no\-prefix\fP
  197. .RS 0
  198. .IP \(bu 2
  199. Default: false
  200. .IP \(bu 2
  201. Type: Boolean
  202. .RE
  203. .P
  204. Do not show any source or destination prefix in \fBnpm diff\fP output\.
  205. .P
  206. Note: this causes \fBnpm diff\fP to ignore the \fB\-\-diff\-src\-prefix\fP and
  207. \fB\-\-diff\-dst\-prefix\fP configs\.
  208. <!\-\- automatically generated, do not edit manually \-\->
  209. <!\-\- see lib/utils/config/definitions\.js \-\->
  210. .SS \fBdiff\-src\-prefix\fP
  211. .RS 0
  212. .IP \(bu 2
  213. Default: "a/"
  214. .IP \(bu 2
  215. Type: String
  216. .RE
  217. .P
  218. Source prefix to be used in \fBnpm diff\fP output\.
  219. <!\-\- automatically generated, do not edit manually \-\->
  220. <!\-\- see lib/utils/config/definitions\.js \-\->
  221. .SS \fBdiff\-dst\-prefix\fP
  222. .RS 0
  223. .IP \(bu 2
  224. Default: "b/"
  225. .IP \(bu 2
  226. Type: String
  227. .RE
  228. .P
  229. Destination prefix to be used in \fBnpm diff\fP output\.
  230. <!\-\- automatically generated, do not edit manually \-\->
  231. <!\-\- see lib/utils/config/definitions\.js \-\->
  232. .SS \fBdiff\-text\fP
  233. .RS 0
  234. .IP \(bu 2
  235. Default: false
  236. .IP \(bu 2
  237. Type: Boolean
  238. .RE
  239. .P
  240. Treat all files as text in \fBnpm diff\fP\|\.
  241. <!\-\- automatically generated, do not edit manually \-\->
  242. <!\-\- see lib/utils/config/definitions\.js \-\->
  243. .SS \fBglobal\fP
  244. .RS 0
  245. .IP \(bu 2
  246. Default: false
  247. .IP \(bu 2
  248. Type: Boolean
  249. .RE
  250. .P
  251. Operates in "global" mode, so that packages are installed into the \fBprefix\fP
  252. folder instead of the current working directory\. See
  253. npm help folders for more on the differences in behavior\.
  254. .RS 0
  255. .IP \(bu 2
  256. packages are installed into the \fB{prefix}/lib/node_modules\fP folder, instead
  257. of the current working directory\.
  258. .IP \(bu 2
  259. bin files are linked to \fB{prefix}/bin\fP
  260. .IP \(bu 2
  261. man pages are linked to \fB{prefix}/share/man\fP
  262. .RE
  263. <!\-\- automatically generated, do not edit manually \-\->
  264. <!\-\- see lib/utils/config/definitions\.js \-\->
  265. .SS \fBtag\fP
  266. .RS 0
  267. .IP \(bu 2
  268. Default: "latest"
  269. .IP \(bu 2
  270. Type: String
  271. .RE
  272. .P
  273. If you ask npm to install a package and don't tell it a specific version,
  274. then it will install the specified tag\.
  275. .P
  276. Also the tag that is added to the package@version specified by the \fBnpm tag\fP
  277. command, if no explicit tag is given\.
  278. .P
  279. When used by the \fBnpm diff\fP command, this is the tag used to fetch the
  280. tarball that will be compared with the local files by default\.
  281. <!\-\- automatically generated, do not edit manually \-\->
  282. <!\-\- see lib/utils/config/definitions\.js \-\->
  283. .SS \fBworkspace\fP
  284. .RS 0
  285. .IP \(bu 2
  286. Default:
  287. .IP \(bu 2
  288. Type: String (can be set multiple times)
  289. .RE
  290. .P
  291. Enable running a command in the context of the configured workspaces of the
  292. current project while filtering by running only the workspaces defined by
  293. this configuration option\.
  294. .P
  295. Valid values for the \fBworkspace\fP config are either:
  296. .RS 0
  297. .IP \(bu 2
  298. Workspace names
  299. .IP \(bu 2
  300. Path to a workspace directory
  301. .IP \(bu 2
  302. Path to a parent workspace directory (will result in selecting all
  303. workspaces within that folder)
  304. .RE
  305. .P
  306. When set for the \fBnpm init\fP command, this may be set to the folder of a
  307. workspace which does not yet exist, to create the folder and set it up as a
  308. brand new workspace within the project\.
  309. .P
  310. This value is not exported to the environment for child processes\.
  311. <!\-\- automatically generated, do not edit manually \-\->
  312. <!\-\- see lib/utils/config/definitions\.js \-\->
  313. .SS \fBworkspaces\fP
  314. .RS 0
  315. .IP \(bu 2
  316. Default: null
  317. .IP \(bu 2
  318. Type: null or Boolean
  319. .RE
  320. .P
  321. Set to true to run the command in the context of \fBall\fR configured
  322. workspaces\.
  323. .P
  324. Explicitly setting this to false will cause commands like \fBinstall\fP to
  325. ignore workspaces altogether\. When not set explicitly:
  326. .RS 0
  327. .IP \(bu 2
  328. Commands that operate on the \fBnode_modules\fP tree (install, update, etc\.)
  329. will link workspaces into the \fBnode_modules\fP folder\. \- Commands that do
  330. other things (test, exec, publish, etc\.) will operate on the root project,
  331. \fIunless\fR one or more workspaces are specified in the \fBworkspace\fP config\.
  332. .RE
  333. .P
  334. This value is not exported to the environment for child processes\.
  335. <!\-\- automatically generated, do not edit manually \-\->
  336. <!\-\- see lib/utils/config/definitions\.js \-\->
  337. .SS \fBinclude\-workspace\-root\fP
  338. .RS 0
  339. .IP \(bu 2
  340. Default: false
  341. .IP \(bu 2
  342. Type: Boolean
  343. .RE
  344. .P
  345. Include the workspace root when workspaces are enabled for a command\.
  346. .P
  347. When false, specifying individual workspaces via the \fBworkspace\fP config, or
  348. all workspaces via the \fBworkspaces\fP flag, will cause npm to operate only on
  349. the specified workspaces, and not on the root project\.
  350. <!\-\- automatically generated, do not edit manually \-\->
  351. <!\-\- see lib/utils/config/definitions\.js \-\->
  352. <!\-\- AUTOGENERATED CONFIG DESCRIPTIONS END \-\->
  353. .SH See Also
  354. .RS 0
  355. .IP \(bu 2
  356. npm help outdated
  357. .IP \(bu 2
  358. npm help install
  359. .IP \(bu 2
  360. npm help config
  361. .IP \(bu 2
  362. npm help registry
  363. .RE