From b9e7ee88d879a6d436433d1c1822a74dc857fdc8 Mon Sep 17 00:00:00 2001 From: Devon Carew Date: Tue, 1 Nov 2016 11:46:30 -0700 Subject: [PATCH] Remove atom check (#6605) * remove the validator check for atom * remove the atom launch config * review comments --- .../flutter_tools/lib/src/commands/setup.dart | 91 ------------------- packages/flutter_tools/lib/src/doctor.dart | 75 +-------------- .../create/.atom/launches.tmpl/main.yaml.tmpl | 7 -- 3 files changed, 2 insertions(+), 171 deletions(-) delete mode 100644 packages/flutter_tools/templates/create/.atom/launches.tmpl/main.yaml.tmpl diff --git a/packages/flutter_tools/lib/src/commands/setup.dart b/packages/flutter_tools/lib/src/commands/setup.dart index 40cd3f6360..b2209bc94a 100644 --- a/packages/flutter_tools/lib/src/commands/setup.dart +++ b/packages/flutter_tools/lib/src/commands/setup.dart @@ -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([apmPath, 'install', 'dartlang']); - else - printStatus('dartlang plugin installed'); - - if (!atomValidator.hasPackage('flutter')) - await runCommandAndStreamOutput([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 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); - } - } } diff --git a/packages/flutter_tools/lib/src/doctor.dart b/packages/flutter_tools/lib/src/doctor.dart index 01b75d4602..09f1614010 100644 --- a/packages/flutter_tools/lib/src/doctor.dart +++ b/packages/flutter_tools/lib/src/doctor.dart @@ -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 ideValidators = []; - 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 get installed { - AtomValidator atom = new AtomValidator(); - return atom.isInstalled ? [atom] : []; - } - - static File getConfigFile() { - // ~/.atom/config.cson - return new File(path.join(_getAtomHomePath(), 'config.cson')); - } - - static String _getAtomHomePath() { - final Map 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 validate() async { - List messages = []; - - 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 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 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 get installed { + static Iterable get installedValidators { if (Platform.isLinux) return IntelliJValidatorOnLinux.installed; if (Platform.isMacOS) diff --git a/packages/flutter_tools/templates/create/.atom/launches.tmpl/main.yaml.tmpl b/packages/flutter_tools/templates/create/.atom/launches.tmpl/main.yaml.tmpl deleted file mode 100644 index fcea8be05b..0000000000 --- a/packages/flutter_tools/templates/create/.atom/launches.tmpl/main.yaml.tmpl +++ /dev/null @@ -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: