Skip to content

Commit

Permalink
feat: option to provide dependencies related filters from yaml (#698)
Browse files Browse the repository at this point in the history
  • Loading branch information
Pavel-Sulimau authored Apr 16, 2024
1 parent 2b16e36 commit 92be985
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 0 deletions.
17 changes: 17 additions & 0 deletions docs/filters.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,20 @@ melos exec --depends-on="flutter" --depends-on="firebase_core" -- flutter test

Use `--no-depends-on` to filter packages that do not depend on the given
dependencies.

## --include-dependencies

Takes the filtered list of packages, and expands them to include those packages'
transitive dependencies (ignoring filters).

```bash
melos list --scope=some_package --include-dependencies
```

## --include-dependents
Takes the filtered list of packages, and expands them to include those packages'
transitive dependents (ignoring filters).

```bash
melos list --scope=some_package --include-dependents
```
6 changes: 6 additions & 0 deletions packages/melos/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,12 @@ configuration file if the default is unsuitable.
- Include only packages that depend on a specific package.
- `--no-depends-on=<noDependantPackageName>`
- Include only packages that _don't_ depend on a specific package.
- `--include-dependencies`
- Expands the filtered list of packages to include those packages'
transitive dependencies (ignoring filters).
- `--include-dependents`
Expands the filtered list of packages to include those packages'
transitive dependents (ignoring filters).
- ♨️ Advanced support for IntelliJ IDEs with automatic creation of
[run configurations for workspace defined scripts and more](https://melos.invertase.dev/~melos-latest/ide-support)
on workspace bootstrap.
Expand Down
16 changes: 16 additions & 0 deletions packages/melos/lib/src/package.dart
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,20 @@ class PackageFilters {
path: path,
);

final includeDependents = assertKeyIsA<bool?>(
key: filterOptionIncludeDependents.camelCased,
map: yaml,
path: path,
) ??
false;

final includeDependencies = assertKeyIsA<bool?>(
key: filterOptionIncludeDependencies.camelCased,
map: yaml,
path: path,
) ??
false;

final noPrivateOptionKey = filterOptionNoPrivate.camelCased;
final excludePrivatePackagesTmp = assertKeyIsA<bool?>(
key: noPrivateOptionKey,
Expand Down Expand Up @@ -227,6 +241,8 @@ class PackageFilters {
dependsOn: dependsOn,
noDependsOn: noDependsOn,
diff: diff,
includeDependents: includeDependents,
includeDependencies: includeDependencies,
includePrivatePackages: includePrivatePackages,
published: published,
nullSafe: nullSafe,
Expand Down
33 changes: 33 additions & 0 deletions packages/melos/test/workspace_config_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,39 @@ void main() {
),
);
});

test('can decode packageFilters values', () {
expect(
VersionCommandConfigs.fromYaml(
const {
'changelogs': [
{
'path': 'FOO_CHANGELOG.md',
'packageFilters': {
'flutter': true,
'includeDependencies': true,
'includeDependents': true,
},
}
],
},
workspacePath: '.',
),
VersionCommandConfigs(
aggregateChangelogs: [
AggregateChangelogConfig.workspace(),
AggregateChangelogConfig(
path: 'FOO_CHANGELOG.md',
packageFilters: PackageFilters(
flutter: true,
includeDependencies: true,
includeDependents: true,
),
),
],
),
);
});
});
});

Expand Down

0 comments on commit 92be985

Please sign in to comment.