Commit c3eec6ec authored by Devon Carew's avatar Devon Carew

several fixes to the doctor command

parent 7711b1f6
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import 'dart:io';
import '../base/os.dart';
import '../doctor.dart'; import '../doctor.dart';
import '../globals.dart'; import '../globals.dart';
import 'android_sdk.dart'; import 'android_sdk.dart';
...@@ -37,14 +40,47 @@ class AndroidWorkflow extends DoctorValidator implements Workflow { ...@@ -37,14 +40,47 @@ class AndroidWorkflow extends DoctorValidator implements Workflow {
if (androidSdk.latestVersion != null) { if (androidSdk.latestVersion != null) {
sdkVersionText = 'Android SDK ${androidSdk.latestVersion.buildToolsVersionName}'; sdkVersionText = 'Android SDK ${androidSdk.latestVersion.buildToolsVersionName}';
messages.add(new ValidationMessage('Platform ${androidSdk.latestVersion.platformVersionName}')); messages.add(new ValidationMessage(
messages.add(new ValidationMessage('Build-tools ${androidSdk.latestVersion.buildToolsVersionName}')); 'Platform ${androidSdk.latestVersion.platformVersionName}, '
'build-tools ${androidSdk.latestVersion.buildToolsVersionName}'
));
} }
List<String> validationResult = androidSdk.validateSdkWellFormed(); List<String> validationResult = androidSdk.validateSdkWellFormed();
if (validationResult.isEmpty) { if (validationResult.isEmpty) {
type = ValidationType.installed; const String _kJdkDownload = 'https://www.oracle.com/technetwork/java/javase/downloads/';
String javaVersion;
try {
printTrace('java -version');
ProcessResult result = Process.runSync('java', <String>['-version']);
if (result.exitCode == 0) {
javaVersion = result.stderr;
List<String> versionLines = javaVersion.split('\n');
javaVersion = versionLines.length >= 2 ? versionLines[1] : versionLines[0];
}
} catch (error) {
}
if (javaVersion != null) {
type = ValidationType.installed;
messages.add(new ValidationMessage(javaVersion));
if (os.which('jarsigner') == null) {
messages.add(new ValidationMessage.error(
'The jarsigner utility was not found; this is used to build Android APKs. You may need to install\n'
'or re-install the Java JDK: $_kJdkDownload.'
));
}
} else {
messages.add(new ValidationMessage.error(
'No Java SDK found; you can download Java from $_kJdkDownload.'
));
}
} else { } else {
messages.addAll(validationResult.map((String message) { messages.addAll(validationResult.map((String message) {
return new ValidationMessage.error(message); return new ValidationMessage.error(message);
......
...@@ -189,12 +189,15 @@ class _FlutterValidator extends DoctorValidator { ...@@ -189,12 +189,15 @@ class _FlutterValidator extends DoctorValidator {
FlutterVersion version = FlutterVersion.getVersion(); FlutterVersion version = FlutterVersion.getVersion();
messages.add(new ValidationMessage('Flutter root at ${version.flutterRoot}')); messages.add(new ValidationMessage('Flutter at ${version.flutterRoot}'));
messages.add(new ValidationMessage('Framework revision ${version.frameworkRevisionShort} ' messages.add(new ValidationMessage(
'(${version.frameworkAge}, channel ${version.channel})')); 'Framework revision ${version.frameworkRevisionShort} '
messages.add(new ValidationMessage('Engine revision ${version.engineRevisionShort}')); '(${version.frameworkAge}), '
'engine revision ${version.engineRevisionShort}'
return new ValidationResult(ValidationType.installed, messages, statusInfo: osName()); ));
return new ValidationResult(ValidationType.installed, messages,
statusInfo: 'on ${osName()}, channel ${version.channel}');
} }
} }
...@@ -238,7 +241,7 @@ class _AtomValidator extends DoctorValidator { ...@@ -238,7 +241,7 @@ class _AtomValidator extends DoctorValidator {
File packageFile = new File(path.join(flutterPluginPath, 'package.json')); File packageFile = new File(path.join(flutterPluginPath, 'package.json'));
dynamic packageInfo = JSON.decode(packageFile.readAsStringSync()); dynamic packageInfo = JSON.decode(packageFile.readAsStringSync());
String version = packageInfo['version']; String version = packageInfo['version'];
messages.add(new ValidationMessage('Atom installed; flutter plugin version $version')); messages.add(new ValidationMessage('Atom installed; Flutter plugin version $version'));
} catch (error) { } catch (error) {
printTrace('Unable to read flutter plugin version: $error'); printTrace('Unable to read flutter plugin version: $error');
} }
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
import 'dart:io'; import 'dart:io';
import '../base/os.dart';
import '../base/process.dart'; import '../base/process.dart';
import '../doctor.dart'; import '../doctor.dart';
import 'mac.dart'; import 'mac.dart';
...@@ -36,10 +37,11 @@ class IOSWorkflow extends DoctorValidator implements Workflow { ...@@ -36,10 +37,11 @@ class IOSWorkflow extends DoctorValidator implements Workflow {
if (xcode.isInstalled) { if (xcode.isInstalled) {
installCount++; installCount++;
messages.add(new ValidationMessage('XCode at ${xcode.xcodeSelectPath}'));
xcodeVersionInfo = xcode.xcodeVersionText; xcodeVersionInfo = xcode.xcodeVersionText;
if (xcodeVersionInfo.contains(',')) if (xcodeVersionInfo.contains(','))
xcodeVersionInfo = xcodeVersionInfo.substring(0, xcodeVersionInfo.indexOf(',')); xcodeVersionInfo = xcodeVersionInfo.substring(0, xcodeVersionInfo.indexOf(','));
messages.add(new ValidationMessage(xcode.xcodeVersionText)); messages.add(new ValidationMessage(xcode.xcodeVersionText));
if (!xcode.isInstalledAndMeetsVersionCheck) { if (!xcode.isInstalledAndMeetsVersionCheck) {
...@@ -62,18 +64,14 @@ class IOSWorkflow extends DoctorValidator implements Workflow { ...@@ -62,18 +64,14 @@ class IOSWorkflow extends DoctorValidator implements Workflow {
} }
// brew installed // brew installed
if (exitsHappy(<String>['brew', '-v'])) { if (os.which('brew') != null) {
installCount++; installCount++;
List<String> installed = <String>[];
if (!exitsHappy(<String>['ideviceinstaller', '-h'])) { if (!exitsHappy(<String>['ideviceinstaller', '-h'])) {
messages.add(new ValidationMessage.error( messages.add(new ValidationMessage.error(
'ideviceinstaller not available; this is used to discover connected iOS devices.\n' 'ideviceinstaller not available; this is used to discover connected iOS devices.\n'
'Install via \'brew install ideviceinstaller\'.' 'Install via \'brew install ideviceinstaller\'.'
)); ));
} else {
installed.add('ideviceinstaller');
} }
if (!hasIDeviceId) { if (!hasIDeviceId) {
...@@ -81,12 +79,7 @@ class IOSWorkflow extends DoctorValidator implements Workflow { ...@@ -81,12 +79,7 @@ class IOSWorkflow extends DoctorValidator implements Workflow {
'ios-deploy not available; this is used to deploy to connected iOS devices.\n' 'ios-deploy not available; this is used to deploy to connected iOS devices.\n'
'Install via \'brew install ios-deploy\'.' 'Install via \'brew install ios-deploy\'.'
)); ));
} else {
installed.add('ios-deploy');
} }
if (installed.isNotEmpty)
messages.add(new ValidationMessage(installed.join(', ') + ' installed'));
} else { } else {
messages.add(new ValidationMessage.error( messages.add(new ValidationMessage.error(
'Brew not installed; use this to install tools for iOS device development.\n' 'Brew not installed; use this to install tools for iOS device development.\n'
......
...@@ -22,45 +22,49 @@ const int kXcodeRequiredVersionMajor = 7; ...@@ -22,45 +22,49 @@ const int kXcodeRequiredVersionMajor = 7;
const int kXcodeRequiredVersionMinor = 0; const int kXcodeRequiredVersionMinor = 0;
class XCode { class XCode {
XCode() {
_eulaSigned = false;
try {
_xcodeSelectPath = runSync(<String>['xcode-select', '--print-path']);
_isInstalled = true;
_xcodeVersionText = runSync(<String>['xcodebuild', '-version']).replaceAll('\n', ', ');
try {
printTrace('xcrun clang');
ProcessResult result = Process.runSync('/usr/bin/xcrun', <String>['clang']);
if (result.stdout != null && result.stdout.contains('license'))
_eulaSigned = false;
else if (result.stderr != null && result.stderr.contains('license'))
_eulaSigned = false;
else
_eulaSigned = true;
} catch (error) {
}
} catch (error) {
_isInstalled = false;
}
}
/// Returns [XCode] active in the current app context. /// Returns [XCode] active in the current app context.
static XCode get instance => context[XCode] ?? (context[XCode] = new XCode()); static XCode get instance => context[XCode] ?? (context[XCode] = new XCode());
bool get isInstalledAndMeetsVersionCheck => isInstalled && xcodeVersionSatisfactory; bool get isInstalledAndMeetsVersionCheck => isInstalled && xcodeVersionSatisfactory;
bool _isInstalled; String _xcodeSelectPath;
bool get isInstalled { String get xcodeSelectPath => _xcodeSelectPath;
if (_isInstalled != null) {
return _isInstalled;
}
_isInstalled = exitsHappy(<String>['xcode-select', '--print-path']); bool _isInstalled;
return _isInstalled; bool get isInstalled => _isInstalled;
}
bool _eulaSigned;
/// Has the EULA been signed? /// Has the EULA been signed?
bool get eulaSigned { bool get eulaSigned => _eulaSigned;
if (!isInstalled)
return false;
try {
ProcessResult result = Process.runSync('/usr/bin/xcrun', <String>['clang']);
if (result.stdout != null && result.stdout.contains('license'))
return false;
if (result.stderr != null && result.stderr.contains('license'))
return false;
return true;
} catch (error) {
return false;
}
}
String _xcodeVersionText; String _xcodeVersionText;
String get xcodeVersionText => _xcodeVersionText;
String get xcodeVersionText {
if (_xcodeVersionText == null)
_xcodeVersionText = runSync(<String>['xcodebuild', '-version']).replaceAll('\n', ', ');
return _xcodeVersionText;
}
bool get xcodeVersionSatisfactory { bool get xcodeVersionSatisfactory {
RegExp regex = new RegExp(r'Xcode ([0-9.]+)'); RegExp regex = new RegExp(r'Xcode ([0-9.]+)');
......
...@@ -45,11 +45,10 @@ class FlutterVersion { ...@@ -45,11 +45,10 @@ class FlutterVersion {
@override @override
String toString() { String toString() {
String from = repositoryUrl == null ? 'Flutter from unknown source' : 'Flutter from $repositoryUrl (on channel $channel)'; String from = 'Flutter on channel $channel (from ${repositoryUrl == null ? 'unknown source' : repositoryUrl})';
String flutterText = 'Framework: $frameworkRevisionShort ($frameworkAge)'; String flutterText = 'Framework revision $frameworkRevisionShort ($frameworkAge); engine revision $engineRevisionShort';
String engineText = 'Engine: $engineRevisionShort';
return '$from\n\n$flutterText\n$engineText'; return '$from\n$flutterText';
} }
static FlutterVersion getVersion([String flutterRoot]) { static FlutterVersion getVersion([String flutterRoot]) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment