rushstack icon indicating copy to clipboard operation
rushstack copied to clipboard

[rush] `rush add` should not require the -p flag to specify packages

Open chrispaterson opened this issue 3 years ago • 1 comments

Summary

  1. Every package manager that exists (except for rush) adds a package without a special flag for the package name. What else would you be adding if not a package? Why is this necessary?
  2. Can we sort the dependencies once they are added, instead of just dropping them to the bottom of the list?

chrispaterson avatar Aug 12 '22 22:08 chrispaterson

For 1, the main reason for this would be that the command-line parser we use (@rushstack/ts-command-line) doesn't support for more than one non-flag parameter, where add is the non-flag parameter here. In theory, the remainder property of the parsed command-line could be used for this, we'd just need to parse it properly. If you want to create a PR for such a feature, we'd happily take a look!

For 2, we had similar requests regarding this in the past. Here's the discussion regarding it: #2115 which was closed in favor #2496 ... TL;DR: it's something we've considered adding in the past, it just hasn't been done yet. However, there are also other solutions that already exist such as using Prettier with Prettier plugins. On that note:

  • Here's a guide for getting Prettier running: https://rushjs.io/pages/maintainer/enabling_prettier/
  • Here's a guide for using plugins with Prettier: https://github.com/microsoft/rushstack-websites/pull/79/files#diff-a37573dadadcbd27a6ab884951cb479d2cff91522d34b0fadef1a3e13c43360fR239

Given that there's an existing issue tracking the package.json sorting, I'm going to rename this issue to focus on the rush add bit.

D4N14L avatar Aug 15 '22 18:08 D4N14L