Remove atom check (#6605)
* remove the validator check for atom * remove the atom launch config * review comments
This commit is contained in:
@@ -3,14 +3,9 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
import '../base/os.dart';
|
||||
import '../base/process.dart';
|
||||
import '../cache.dart';
|
||||
import '../doctor.dart';
|
||||
import '../globals.dart';
|
||||
import '../runner/flutter_command.dart';
|
||||
|
||||
@@ -48,41 +43,6 @@ class SetupCommand extends FlutterCommand {
|
||||
}
|
||||
}
|
||||
|
||||
// setup atom
|
||||
printStatus('\nChecking Atom:');
|
||||
String apmPath = os.which('apm')?.path;
|
||||
if (apmPath == null && FileSystemEntity.isFileSync('/usr/local/bin/apm'))
|
||||
apmPath = '/usr/local/bin/apm';
|
||||
if (apmPath == null && FileSystemEntity.isFileSync('/usr/bin/apm'))
|
||||
apmPath = '/usr/bin/apm';
|
||||
if (apmPath == null) {
|
||||
final String expectedLocation = '/Applications/Atom.app/Contents/Resources/app/apm/bin/apm';
|
||||
if (FileSystemEntity.isFileSync(expectedLocation))
|
||||
apmPath = expectedLocation;
|
||||
}
|
||||
|
||||
if (apmPath == null) {
|
||||
printError('Unable to locate the Atom installation.');
|
||||
} else {
|
||||
printStatus('apm command available at $apmPath');
|
||||
|
||||
AtomValidator atomValidator = new AtomValidator();
|
||||
|
||||
if (!atomValidator.hasPackage('dartlang'))
|
||||
await runCommandAndStreamOutput(<String>[apmPath, 'install', 'dartlang']);
|
||||
else
|
||||
printStatus('dartlang plugin installed');
|
||||
|
||||
if (!atomValidator.hasPackage('flutter'))
|
||||
await runCommandAndStreamOutput(<String>[apmPath, 'install', 'flutter']);
|
||||
else
|
||||
printStatus('flutter plugin installed');
|
||||
|
||||
// Set up the ~/.atom/config.cson file - make sure the path the the
|
||||
// flutter and dart sdks are correct.
|
||||
_updateAtomConfigFile();
|
||||
}
|
||||
|
||||
// run doctor
|
||||
printStatus('\nFlutter doctor:');
|
||||
bool goodInstall = await doctor.diagnose();
|
||||
@@ -102,55 +62,4 @@ class SetupCommand extends FlutterCommand {
|
||||
|
||||
return goodInstall ? 0 : 1;
|
||||
}
|
||||
|
||||
// Quick-and-dirty manipulation of the cson file.
|
||||
void _updateAtomConfigFile() {
|
||||
// flutter:
|
||||
// flutterRoot: "..."
|
||||
// dartlang:
|
||||
// sdkLocation: "..."
|
||||
|
||||
String flutterRoot = path.normalize(path.absolute(Cache.flutterRoot));
|
||||
String sdkLocation = path.join(flutterRoot, 'bin/cache/dart-sdk');
|
||||
|
||||
File file = AtomValidator.getConfigFile();
|
||||
|
||||
if (file.existsSync()) {
|
||||
String cson = file.readAsStringSync();
|
||||
cson = cson.trimRight() + '\n';
|
||||
|
||||
List<String> lines = cson.split('\n').map((String line) => line.trim()).toList();
|
||||
|
||||
if (!lines.contains('flutter:')) {
|
||||
cson += '''
|
||||
flutter:
|
||||
flutterRoot: "$flutterRoot"
|
||||
''';
|
||||
}
|
||||
|
||||
if (!lines.contains('dartlang:')) {
|
||||
cson += '''
|
||||
dartlang:
|
||||
sdkLocation: "$sdkLocation"
|
||||
''';
|
||||
}
|
||||
|
||||
if (cson.trim() != file.readAsStringSync().trim()) {
|
||||
printStatus('Updating ${file.path}');
|
||||
file.writeAsStringSync(cson);
|
||||
}
|
||||
} else {
|
||||
// Create a new config file.
|
||||
printStatus('Creating ${file.path}');
|
||||
|
||||
String cson = '''
|
||||
"*":
|
||||
flutter:
|
||||
flutterRoot: "$flutterRoot"
|
||||
dartlang:
|
||||
sdkLocation: "$sdkLocation"
|
||||
''';
|
||||
file.writeAsStringSync(cson);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:convert' show JSON;
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:path/path.dart' as path;
|
||||
@@ -11,7 +10,6 @@ import 'package:path/path.dart' as path;
|
||||
import 'android/android_workflow.dart';
|
||||
import 'base/common.dart';
|
||||
import 'base/context.dart';
|
||||
import 'base/os.dart';
|
||||
import 'device.dart';
|
||||
import 'globals.dart';
|
||||
import 'ios/ios_workflow.dart';
|
||||
@@ -41,8 +39,7 @@ class Doctor {
|
||||
_validators.add(_iosWorkflow);
|
||||
|
||||
List<DoctorValidator> ideValidators = <DoctorValidator>[];
|
||||
ideValidators.addAll(AtomValidator.installed);
|
||||
ideValidators.addAll(IntelliJValidator.installed);
|
||||
ideValidators.addAll(IntelliJValidator.installedValidators);
|
||||
if (ideValidators.isNotEmpty)
|
||||
_validators.addAll(ideValidators);
|
||||
else
|
||||
@@ -244,74 +241,6 @@ class NoIdeValidator extends DoctorValidator {
|
||||
}
|
||||
}
|
||||
|
||||
class AtomValidator extends DoctorValidator {
|
||||
AtomValidator() : super('Atom - a lightweight development environment for Flutter');
|
||||
|
||||
static Iterable<DoctorValidator> get installed {
|
||||
AtomValidator atom = new AtomValidator();
|
||||
return atom.isInstalled ? <DoctorValidator>[atom] : <DoctorValidator>[];
|
||||
}
|
||||
|
||||
static File getConfigFile() {
|
||||
// ~/.atom/config.cson
|
||||
return new File(path.join(_getAtomHomePath(), 'config.cson'));
|
||||
}
|
||||
|
||||
static String _getAtomHomePath() {
|
||||
final Map<String, String> env = Platform.environment;
|
||||
if (env['ATOM_HOME'] != null)
|
||||
return env['ATOM_HOME'];
|
||||
return os.isWindows
|
||||
? path.join(env['USERPROFILE'], '.atom')
|
||||
: path.join(env['HOME'], '.atom');
|
||||
}
|
||||
|
||||
bool get isInstalled => FileSystemEntity.isDirectorySync(_getAtomHomePath());
|
||||
|
||||
@override
|
||||
Future<ValidationResult> validate() async {
|
||||
List<ValidationMessage> messages = <ValidationMessage>[];
|
||||
|
||||
int installCount = 0;
|
||||
|
||||
if (_validateHasPackage(messages, 'flutter', 'Flutter'))
|
||||
installCount++;
|
||||
|
||||
if (_validateHasPackage(messages, 'dartlang', 'Dart'))
|
||||
installCount++;
|
||||
|
||||
return new ValidationResult(
|
||||
installCount == 2 ? ValidationType.installed : ValidationType.partial,
|
||||
messages
|
||||
);
|
||||
}
|
||||
|
||||
bool _validateHasPackage(List<ValidationMessage> messages, String packageName, String description) {
|
||||
if (!hasPackage(packageName)) {
|
||||
messages.add(new ValidationMessage(
|
||||
'$packageName plugin not installed; this adds $description specific functionality to Atom.\n'
|
||||
'Install the plugin from Atom or run \'apm install $packageName\'.'
|
||||
));
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
String flutterPluginPath = path.join(_getAtomHomePath(), 'packages', packageName);
|
||||
File packageFile = new File(path.join(flutterPluginPath, 'package.json'));
|
||||
Map<String, dynamic> packageInfo = JSON.decode(packageFile.readAsStringSync());
|
||||
String version = packageInfo['version'];
|
||||
messages.add(new ValidationMessage('$packageName plugin version $version'));
|
||||
} catch (error) {
|
||||
printTrace('Unable to read $packageName plugin version: $error');
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool hasPackage(String packageName) {
|
||||
String packagePath = path.join(_getAtomHomePath(), 'packages', packageName);
|
||||
return FileSystemEntity.isDirectorySync(packagePath);
|
||||
}
|
||||
}
|
||||
|
||||
abstract class IntelliJValidator extends DoctorValidator {
|
||||
IntelliJValidator(String title) : super(title);
|
||||
|
||||
@@ -323,7 +252,7 @@ abstract class IntelliJValidator extends DoctorValidator {
|
||||
'IdeaIC' : 'IntelliJ IDEA Community Edition',
|
||||
};
|
||||
|
||||
static Iterable<DoctorValidator> get installed {
|
||||
static Iterable<DoctorValidator> get installedValidators {
|
||||
if (Platform.isLinux)
|
||||
return IntelliJValidatorOnLinux.installed;
|
||||
if (Platform.isMacOS)
|
||||
|
||||
@@ -1,7 +0,0 @@
|
||||
# Flutter launch configuration for lib/main.dart.
|
||||
type: flutter
|
||||
path: lib/main.dart
|
||||
|
||||
flutter:
|
||||
# The starting route for the app.
|
||||
route:
|
||||
Reference in New Issue
Block a user