ensurePubspecResolved function

Future<void> ensurePubspecResolved(
  1. String dir, {
  2. bool isOffline = false,
  3. SolveReportMode reportMode = SolveReportMode.none,
  4. bool onlyOutputWhenTerminal = true,
  5. ProgressGracePeriod? progressGracePeriod,
  6. FileSystem? fileSystem,
  7. Map<String, String>? environment,
  8. String? platformVersion,
  9. Stream<List<int>>? stdin,
  10. StreamSink<List<int>>? stdout,
  11. StreamSink<List<int>>? stderr,
  12. Client? httpClient,
})

Makes sure that dir/pubspec.yaml is resolved such that pubspec.lock and .dart_tool/package_config.json are up-to-date and all packages are downloaded to the cache.

Will compare file timestamps to see if full resolution can be skipped.

reportMode specifies the level of reporting output on success. Defaults to SolveReportMode.none (no output).

If onlyOutputWhenTerminal is true (the default) there will be no output if no terminal is attached.

progressGracePeriod specifies the shared grace period before initial spinners are displayed.

Throws a ResolutionFailedException if resolution fails.

Implementation

Future<void> ensurePubspecResolved(
  String dir, {
  bool isOffline = false,
  SolveReportMode reportMode = SolveReportMode.none,
  bool onlyOutputWhenTerminal = true,
  ProgressGracePeriod? progressGracePeriod,
  f.FileSystem? fileSystem,
  Map<String, String>? environment,
  String? platformVersion,
  Stream<List<int>>? stdin,
  StreamSink<List<int>>? stdout,
  StreamSink<List<int>>? stderr,
  http.Client? httpClient,
}) => withOverrides(
  () async {
    try {
      await Entrypoint.ensureUpToDate(
        dir,
        cache: SystemCache(isOffline: isOffline),
        reportMode: reportMode,
        onlyOutputWhenTerminal: onlyOutputWhenTerminal,
      );
    } on ApplicationException catch (e) {
      throw ResolutionFailedException._(e.toString());
    } finally {
      // TODO(https://github.com/dart-lang/pub/issues/4200)
      // This is a bit of a hack.
      // We should most likely take a client here.
      globalHttpClient.close();
    }
  },
  progressGracePeriod: progressGracePeriod,
  fileSystem: fileSystem,
  environment: environment,
  platformVersion: platformVersion,
  stdin: stdin,
  stdout: stdout,
  stderr: stderr,
  httpClient: httpClient,
);