why icon indicating copy to clipboard operation
why copied to clipboard

Document package dependencies

Open Clindbergh opened this issue 1 year ago • 7 comments

It seems a good idea to document why certain packages were added.

Thanks for this innovative solution!

Clindbergh avatar Jul 05 '23 13:07 Clindbergh

Isn't it clear from the usage of the package why it's added?🤔

strdr4605 avatar Jul 05 '23 13:07 strdr4605

It depends. A couple of reasons why it might be helpful:

  • A package might be used only for direct usage with the cli (without npm scripts)
  • A package might be used in the code but usage search is not easy, for reasons which might be more or less common:
    • Packages might be added before they are actually used
    • The usage might be deleted but somebody forgot to remove it from the packages
    • The package might be used in a git submodule
    • The package might be used in generated or otherwise external / dynamic code

The main problem this feature would solve is the inability to add comments to the package.json.

This feature would allow the implementation of a CI rule that forbids the addition of undocumented packages, in a similar fashion that npm check allows.

Clindbergh avatar Jul 05 '23 17:07 Clindbergh

Ok, let's suppose that some teams need this, what should be the API? npx why --dep express? npx why --dep express "our nodejs server".

Or maybe using the same convention as when installing packages. npx why --S express "our nodejs server"

strdr4605 avatar Jul 05 '23 18:07 strdr4605

I think devDependencies should be supported as well. They might even be more important.

How about

npx why script <script name> (alias for npx why <script-name>) npx why dependency <dependency> npx why dependency --dev <dependency> (or alternatively, but less preferred npx why devDependency <dependency>)

The API to add documentation would be just like with scripts (adding the additional string).

I prefer using full names as this is more intuitive for newcomers. ~~Once #6 is implemented verbosity should not be a problem.~~

Clindbergh avatar Jul 05 '23 20:07 Clindbergh

Ideally any abbreviation of the words would work, similarly to some other cli tools like nmcli.

So npx why script == npx why scri == npx why s and npx why dependency == npx why dep == npx why d.

Clindbergh avatar Jul 05 '23 20:07 Clindbergh

+1 to this feature request. When an app is large enough, with a lot of packages, it's not always easy to know why a package was added (or what edge cases to test when evaluating if we should update said package).

tylercraft avatar Jun 04 '24 16:06 tylercraft

Ok, we can add this feature. Of course, it would be nice to implement also #6.

And I think as an API we can use:

npx why dependency react, npx why devDependency typescript, npx why peerDependency react-dom.

Also, if someone wants to work on this, we can discuss it here, and I will be happy to help develop and release this feature. Or I will check it myself when I have time.

strdr4605 avatar Jun 04 '24 19:06 strdr4605