Skip to content
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

Support listing out npm cache #194

Closed
wants to merge 3 commits into from
Closed

Conversation

jacobtolar
Copy link

The documentation for npm-cache says it can list the contents of the cache folder:

Used to add, list, or clean the npm cache folder.

The list functionality isn't actually present, but is supported by cacache.

This PR adds a list (or ls) subcommand to npm cache that outputs the contents of the cache in the following format:

$ npm cache list
...
make-fetch-happen:request-cache:https://registry.npmjs.org/babel-plugin-transform-es2015-arrow-functions/-/babel-plugin-transform-es2015-arrow-functions-6.22.0.tgz
  url = https://registry.npmjs.org/babel-plugin-transform-es2015-arrow-functions/-/babel-plugin-transform-es2015-arrow-functions-6.22.0.tgz
  path = /Users/jtolar/.npm/_cacache/content-v2/sha1/45/26/92cb711d5f79dc7f85e440ce41b9f244d221
  size = 1752
  time = 1556301242419
make-fetch-happen:request-cache:https://registry.npmjs.org/ultron
  url = https://registry.npmjs.org/ultron
  path = /Users/jtolar/.npm/_cacache/content-v2/sha512/bb/79/1e224496f3bcf5cc6d503ca512a9ff44625ee82e436a7fb24dfde1591a56068846ef7ed2c6fe3f7f233afd74c2d672a4c18e711595d1b2fe64c81f54e9d0
  size = 2101
  time = 1556301242411
...

If a different output format would be preferable, I'm happy to change this PR.

@isaacs
Copy link
Contributor

isaacs commented Jun 26, 2019

This is a good idea. But it should use the cache.ls.stream interface instead, or else it loads the entire cache into memory. Otherwise, a fantastic patch.

@isaacs
Copy link
Contributor

isaacs commented Jun 26, 2019

Also, it should have a --json version.

(If you don't get to this, I will eventually, no sweat, not a blocker.)

@isaacs isaacs self-assigned this Jun 26, 2019
@jacobtolar
Copy link
Author

jacobtolar commented Jul 2, 2019

thanks for looking; updated to use ls.stream and added a --json option.

I don't write much nodejs code, so happy to refactor a bit if you have suggestions for improvements.

@darcyclarke darcyclarke added the Release 6.x work is associated with a specific npm 6 release label Nov 19, 2019
@darcyclarke darcyclarke added the pr: needs tests requires tests before merging label Nov 19, 2019
@darcyclarke
Copy link
Contributor

@jacobtolar can you add some test coverage? We'd love to land this in our next minor 6.x release if you can get to it in the next week or so.

@mikemimik
Copy link
Contributor

Hey @jacobtolar just a heads up that we'll be releasing a 6.14.0 next week (Dec 3rd, 2019). If you'd like this change to land, could you add some test coverage for it? :D

@mikemimik mikemimik modified the milestone: Release 6.14.0 Nov 26, 2019
@darcyclarke darcyclarke added this to the OSS - Sprint 8 milestone Jun 11, 2020
@th0rgall
Copy link

th0rgall commented Aug 6, 2020

If you need this listing feature in the CLI now, a workaround can be found here: https://github.com/yilmazdurmaz/npm-cache-list

@darcyclarke
Copy link
Contributor

@jacobtolar apologize this wasn't able to get pulled into v6. We'd love to see list & remove added to cache for v7 if you're willing to rework this PR or update based on the major refactoring we've done. Unfortunately, we're trying not to land any feature work on v6, so I'm going to close this PR for now, but again, encourage this as a feature to be added to v7.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr: needs tests requires tests before merging Release 6.x work is associated with a specific npm 6 release semver:minor new backwards-compatible feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants