-
Notifications
You must be signed in to change notification settings - Fork 3.2k
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
npm diff #1319
npm diff #1319
Conversation
Prior art: https://npmjs.com/lockfile-diff |
A more similar userland solution I found was this script: https://github.com/juliangruber/npm-diff |
Before landing this, it'd be great to discuss it on an RFC call to make sure everyone's use cases are considered. |
for sure! 😄 |
81f5a05
to
835c1aa
Compare
0720227
to
55dc1d2
Compare
55dc1d2
to
3d2547a
Compare
found 2 benchmarks with statistically significant performance improvements
timing results
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It’d be great if this supported all the arguments git diff did - eg, i use --name-only
constantly when i want filenames instead of contents, and i use the pager config and the diff tool config frequently. Additionally, the -w
option to suppress whitespace diffs (there’s a number of others)
i think it would be very confusing for one’s muscle memory if the command is called “diff” and doesn’t do what diff/git diff does. Thoughts?
@ljharb it does support all these options you mentioned! Thanks to feedback from you, @bnb and @coreyfarrell in the original RFC 😄 You can check the full list of options in the docs here: https://github.com/npm/cli/pull/1319/files#diff-81ea63c7baccd94f458fdc214180a305932547f44f5df499a6363d1cc29c8e5bR89 Now that said, have you actually poked at all git diff options to see what that implies? https://git-scm.com/docs/git-diff#_options 😰 I think using the old analogy saying that "git diff is the operational system of diffs" is very valid here. My proposal instead is that we start with these popular/essential set of options and we can work from there, continuing to incrementally add new configurations as we identify them as being essential over time. Hope that makes sense and thanks again with all the help! It has been very appreciated 😊 |
Beautiful, thanks :-) certainly i don’t know nor have used all the diff options, and until i discover one missing will likely be perfectly content in assuming they all work. |
One note specifically on I acknowledge that from a UX pov I would love to have it from day1 but it's a tradeoff I'm willing to make in order for this to be shipped (after so many months 🙃 ). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to change config values as theres some collisions/issues here.
Small update on this, after reviewing this thoroughly with @isaacs we decided to adjust options to be more npm-cli friendly. In practice that means we'll be prefixing the original git options (e.g: Will follow up with these updates soon 😊 |
@ruyadorno the prefix makes sense, but why would you need the |
@ljharb it was needed in order to enable filtering by filepaths, since both specs-to-compare and paths-to-filter are positional arguments. That was also a syntax choice that I was trying to inherit from git (since in git both commitish and paths are positional arguments they have to use a In $ git diff latest
fatal: ambiguous argument 'latest': both revision and filename
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]' Back to Then what about if I want to use Sorry about the lenght of it but this is the very long answer as to why we would need the |
Given that's already how |
Syncs APIs with changes proposed in the `npm diff` PR. ref: npm/cli#1319
3d2547a
to
b7f09ba
Compare
Heads up @ljharb and anyone else interested in this, after a few rounds of reviews with the team and specially feedback from @isaacs we landed on using translated config names to avoid colliding names (such as the We also changed the syntax to define specs using a named option |
b7f09ba
to
41cfc44
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Handful of relatively minor changes. Reviewed the docs and test much more carefully than the code, but since the tests pass, this is fine. Suggested changes can be made later (or maybe even pushed back on in some cases, idk).
- As proposed in RFC: npm/rfcs#144 PR-URL: #1319 Credit: @ruyadorno Close: #1319 Reviewed-by: @isaacs
dda1344
to
d011266
Compare
ℹ️ [Update]: I also wrote a blog post showcasing usage of the npm diff command in a more lightweight read format, in case someone lands here looking to learn more about it.
Introduce a new
npm diff
command for comparing published versions across the npm registry, complementing the experience fromnpm outdated
andnpm audit
for package consumers and providing a new workflow for package authors to quickly assess the delta between local changes and a specific published version of a package.What's in here
npm diff
with no params, useful for package authors, returns a diff between current files and the latest published version (or customizable tag).npm diff --diff=<spec>
compares a current installed package to aspec
defined by the user.npm diff --diff=<spec-a> --diff=<spec-b>
compares two diff published versions of a package.npm diff --diff=<version-a> --diff=<version-b>
version comparison shorthand for a current package.npm diff [<paths>...]
positional args filters what files to use, accepts globs and dir names.Supports some of the most popular
git diff
options: