Add a command to list all valid targets for a given project #22100
github-tma8118
started this conversation in
Feature Requests
Replies: 1 comment 1 reply
-
You can currently get project data with the For example, for a project called npx nx show project demo --json | jq -r '.targets | to_entries[] | .key' Which would show all targets, such as:
And you can use that to script your post-commit hook. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Description
I'd like to have an option to list all the valid targets for a given project.
For example, similar to how
nx print-affected --select=projects
prints a comma-separated list of affected projects, I'd like to do something likenx print-targets --project=some-affected-project
to print a comma-separated list of valid targets defined in that project.Motivation
I recently tried to implement a post-commit hook to print some helpful information for users after they made a commit.
The hook prints some commands to the terminal to encourage users to run things like unit tests locally before pushing them and consuming billable pipeline minutes just for the unit tests to fail, meaning that the user has to fix the tests and push again and consume more minutes.
I was able to get a list of affected projects and, for each one, suggest
nx run some-affected-project:test
, but not all of my projects have atest
target, so for some projects that suggestion doesn't make sense.It would be nice to be able to print the valid targets of each project.
Other tools such as Gradle have a similar concept, for example
gradle tasks
lists valid tasks for the current project:Although a comma-separated list would be easier to consume and iterate over in something like a post-commit hook.
Suggested Implementation
Alternate Implementations
Beta Was this translation helpful? Give feedback.
All reactions