Melos commands support the following global filters:
Excludes private packages (publish_to: none). They are included by default.
melos bootstrap --no-privateFilters packages where the current local package version exists on pub.dev.
melos bootstrap --publishedUse --no-published to filter packages that have not had their current version
published yet.
Includes only packages with names matching the given glob. This option can be repeated.
# Run `flutter build ios` on all packages with "example" in the package name
melos exec --scope="*example*" -- flutter build iosExcludes packages with names matching the given glob. This option can be repeated.
# Run `flutter build ios` on all packages but ignore those whose packages names contain "internal"
melos exec --ignore="*internal*" -- flutter build iosFilters packages based on categories declared in the root pubspec.yaml file.
# Run `flutter build ios` on all packages in the "examples" category.
melos exec --category="examples" -- flutter build iosFilters packages based on whether there were changes between a commit and the
current HEAD or within a range of commits.
Specify a range of commits using the git shorthand syntax
START_COMMIT..END_COMMIT and START_COMMIT...END_COMMIT.
# Run `flutter build ios` on all packages that are different between current
# branch and the specified commit hash.
melos exec --diff=COMMIT_HASH -- flutter build ios
# Run `flutter build ios` on all packages that are different between remote
# `main` branch and `HEAD`.
melos exec --diff=origin/main...HEAD -- flutter build iosTo list the packages that changed since their latest release tag, use the
changed command.
Includes only packages where a specific directory exists inside the package.
# Only bootstrap packages with an example directory
melos bootstrap --dir-exists="example"Includes only packages where a specific file exists in the package.
# Only bootstrap packages with an README.md file
melos bootstrap --file-exists="README.md"Filters packages that need the Flutter SDK. A package needs the Flutter SDK when
its pubspec.yaml file meets any of these conditions:
- depends on a package that is shipped with the Flutter SDK (
sdk: flutter), for exampleflutterorflutter_test, in any dependency section, - declares a Flutter SDK constraint under
environment, or - depends, directly or transitively, on another package in the workspace that
declares a Flutter SDK constraint or that has Flutter in its
dependencies. Melos ignores thedev_dependenciesanddependency_overridesof that package, because they do not apply to the packages that depend on it.
melos exec --flutter -- flutter testUse --no-flutter to filter packages that do not need the Flutter SDK.
If a package needs the Flutter SDK only because of a dependency outside the workspace (for example a hosted package), declare a Flutter SDK constraint:
environment:
sdk: ^3.9.0
flutter: ">=3.35.0"The same rules decide whether Melos uses the flutter or the dart tool for a
package in commands such as melos analyze and melos test.
Includes only packages that depend on specific dependencies.
melos exec --depends-on="flutter" --depends-on="firebase_core" -- flutter testUse --no-depends-on to filter packages that do not depend on the given
dependencies.
Takes the filtered list of packages, and expands them to include those packages' transitive dependencies (ignoring filters).
melos list --scope=some_package --include-dependenciesTakes the filtered list of packages, and expands them to include those packages' transitive dependents (ignoring filters).
melos list --scope=some_package --include-dependentsThe packages that are included through --include-dependencies and
--include-dependents skip all the other filters. Use --post-filter to apply
a filter after Melos includes the dependencies and dependents. The value is
any of the other filters, written without the leading dashes. The option can be
repeated.
# Run `build_runner` in `some_package` and all of its transitive dependencies,
# but only in the packages that depend on `build_runner`.
melos exec --scope=some_package --include-dependencies \
--post-filter=depends-on=build_runner -- dart run build_runner build
# Run the tests of all changed packages and their transitive dependents, but
# only in the packages that have a `test` directory.
melos exec --diff=origin/main...HEAD --include-dependents \
--post-filter=dir-exists=test -- dart testFlags are written in the same way, for example --post-filter=no-private.
Post filters apply to all packages, including those that matched the other
filters. include-dependencies and include-dependents cannot be used as post
filters.
In packageFilters, the postFilters
option defines the post filters:
melos:
scripts:
generate:
exec: dart run build_runner build
packageFilters:
scope: some_package
includeDependencies: true
postFilters:
dependsOn: build_runner
