Skip to main content

query projects

Use the moon query projects sub-command to query information about all projects in the project graph. The project list can be filtered by passing a query statement as an argument, or by using options arguments.

# Find all projects
$ moon query projects

# Find all projects with an id that matches "react"
$ moon query projects --id react
$ moon query projects "project~react"

# Find all projects with a `lint` or `build` task
$ moon query projects --tasks "lint|build"
$ moon query projects "task=[lint,build]"

By default, this will output a list of projects in the format of <id> | <source> | <stack> | <type> | <language>, separated by new lines.

web | apps/web | frontend | application | typescript

The projects can also be output in JSON (which contains all data) by passing the --json flag. The output has the following structure:

{
projects: Project[],
options: QueryOptions,
}

Affected projects

This command can also be used to query for affected projects, based on the state of the VCS working tree. For advanced control, you can also pass the results of moon query touched-files to stdin.

# Find all affected projects
$ moon query projects --affected

# Find all affected projects using the results of another query
$ moon query touched-files | moon query projects --affected

Arguments

Options

  • --affected - Filter projects that have been affected by touched files. This will only filter based on files, and does not include upstream or downstream dependencies.
  • --json - Display the projects in JSON format.

Filters

All option values are case-insensitive regex patterns.

  • --alias <regex> - Filter projects that match this alias.
  • --id <regex> - Filter projects that match this ID/name.
  • --language <regex> - Filter projects of this programming language.
  • --source <regex> - Filter projects that match this source path.
  • --stack <regex> - Filter projects of the tech stack.
  • --tags <regex> - Filter projects that have the following tags.
  • --tasks <regex> - Filter projects that have the following tasks.
  • --type <regex> - Filter project of this type.