nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.48k stars 2.34k forks source link

[Feature Request] have NX cli try to infer full names of targets/projects from abbreviations (like Gradle) #17012

Closed gioragutt closed 8 months ago

gioragutt commented 1 year ago

Description

Docs: https://docs.gradle.org/current/userguide/command_line_interface.html#sec:name_abbreviation

From my past experience with Gradle, it was able to infer what command I'm trying to run based on initials (f.e: gradle buildWebApp could be written as gradle bWA).

This way, you could shorten cli invocations, so for example:

nx test web-app could be shortened to nx t wa. Of course, if you can't infer a single project:target combo (0 or >1 results), you'd throw an error.

Motivation

Basically this is nice for some power users who like these micro-optimizations when working int eh CLI.

For example, I had recent project called experiences-campaign, for which I had a playground target.

Having to write nx playground experiences-campaign or nx run experiences-campaign:playground is pretty verbose, and I'm sure people have even worse cases, especially when there are huge workspaces with nested projects.

If I could write nx p eC/e-c or nx run eC/e-c:p that would save me a lot of time.

Suggested Implementation

Basically there would have to be some transformation of full name -> short name.

From gradle's docs linked above, there's an explanation about what it accepts:

You can use camel case patterns for more complex abbreviations. These patterns are expanded to match camel case and kebab case names. For example the pattern foBa (or even fB) matches fooBar and foo-bar.

More concretely, you can run the compileTest task in the my-awesome-library subproject with the gradle mAL:cT command.

Once you have this transformation, you could backtrack it to project:target pairs, perhaps with some regex or something.

This could perhaps be handled parseTargetString (especially as it has a reference to the project graph and can perform this search)

Alternate Implementations

github-actions[bot] commented 9 months ago

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! 🙏

gioragutt commented 8 months ago

Not irrelevant yet, so would like to re-open

github-actions[bot] commented 7 months ago

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.