
Fixes https://github.com/flutter/flutter/issues/112833 Most of the actual changes here are in [packages/flutter_tools/lib/src/version.dart](https://github.com/flutter/flutter/pull/124558/files#diff-092e00109d9e1589fbc7c6de750e29a6ae512b2dd44e85d60028953561201605), while the rest is largely just addressing changes to the constructor of `FlutterVersion` which now has different dependencies. This change makes `FlutterVersion` an interface with two concrete implementations: 1. `_FlutterVersionGit` which is mostly the previous implementation, and 2. `_FlutterVersionFromFile` which will read a new `.version.json` file from the root of the repo The [`FlutterVersion` constructor](https://github.com/flutter/flutter/pull/124558/files#diff-092e00109d9e1589fbc7c6de750e29a6ae512b2dd44e85d60028953561201605R70) is now a factory that first checks if `.version.json` exists, and if so returns an instance of `_FlutterVersionFromGit` else it returns the fallback `_FlutterVersionGit` which will end up writing `.version.json` so that we don't need to re-calculate the version on the next invocation. `.version.json` will be deleted in the bash/batch entrypoints any time we need to rebuild he tool (this will usually be because the user did `flutter upgrade` or `flutter channel`, or manually changed the commit with git).
57 lines
2.0 KiB
Dart
57 lines
2.0 KiB
Dart
// Copyright 2014 The Flutter Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
import '../android/android_workflow.dart';
|
|
import '../base/common.dart';
|
|
import '../globals.dart' as globals;
|
|
import '../runner/flutter_command.dart';
|
|
|
|
class DoctorCommand extends FlutterCommand {
|
|
DoctorCommand({this.verbose = false}) {
|
|
argParser.addFlag('android-licenses',
|
|
negatable: false,
|
|
help: "Run the Android SDK manager tool to accept the SDK's licenses.",
|
|
);
|
|
argParser.addOption('check-for-remote-artifacts',
|
|
hide: !verbose,
|
|
help: 'Used to determine if Flutter engine artifacts for all platforms '
|
|
'are available for download.',
|
|
valueHelp: 'engine revision git hash',);
|
|
}
|
|
|
|
final bool verbose;
|
|
|
|
@override
|
|
final String name = 'doctor';
|
|
|
|
@override
|
|
final String description = 'Show information about the installed tooling.';
|
|
|
|
@override
|
|
final String category = FlutterCommandCategory.sdk;
|
|
|
|
@override
|
|
Future<FlutterCommandResult> runCommand() async {
|
|
if (argResults?.wasParsed('check-for-remote-artifacts') ?? false) {
|
|
final String engineRevision = stringArg('check-for-remote-artifacts')!;
|
|
if (engineRevision.startsWith(RegExp(r'[a-f0-9]{1,40}'))) {
|
|
final bool success = await globals.doctor?.checkRemoteArtifacts(engineRevision) ?? false;
|
|
if (success) {
|
|
throwToolExit('Artifacts for engine $engineRevision are missing or are '
|
|
'not yet available.', exitCode: 1);
|
|
}
|
|
} else {
|
|
throwToolExit('Remote artifact revision $engineRevision is not a valid '
|
|
'git hash.');
|
|
}
|
|
}
|
|
final bool success = await globals.doctor?.diagnose(
|
|
androidLicenses: boolArg('android-licenses'),
|
|
verbose: verbose,
|
|
androidLicenseValidator: androidLicenseValidator,
|
|
) ?? false;
|
|
return FlutterCommandResult(success ? ExitStatus.success : ExitStatus.warning);
|
|
}
|
|
}
|