matrixSdkConstraints function

Future<({VersionConstraint dart, VersionConstraint flutter})> matrixSdkConstraints(
  1. List<SmfModule> modules
)

The versions of Flutter and of Dart that every app of the matrix of modules allows, as matrixOf finds its apps: the intersection of the SDK constraints of their pubspec.yamls, which the pipeline merges from the PubspecContribution.environments of the modules of each app, and which smf create checks the Flutter SDK against before it generates anything. A case of the contract harness with errors has no app in the matrix, and an app whose pubspec has no constraint allows every version.

Implementation

Future<({VersionConstraint flutter, VersionConstraint dart})>
    matrixSdkConstraints(List<SmfModule> modules) async {
  final harness = ContractHarness(ModuleRegistry(modules), render: false);
  final results = [
    ...await harness.checkAll(),
    for (final contractCase in harness.casesOfAll())
      await harness.check(contractCase),
  ];
  final pubspecs = [
    for (final result in results)
      if (result.validation case ValidationResult(:final pubspec)
          when result.errors.isEmpty)
        pubspec,
  ];
  return (
    flutter: VersionConstraint.intersection(
      pubspecs.map((pubspec) => pubspec.flutter).nonNulls,
    ),
    dart: VersionConstraint.intersection(
      pubspecs.map((pubspec) => pubspec.sdk).nonNulls,
    ),
  );
}