flutter/packages/flutter_tools/lib/executable.dart

126 lines
4.5 KiB
Dart
Raw Normal View History

// 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 'dart:async';
import 'runner.dart' as runner;
import 'src/base/context.dart';
import 'src/base/template.dart';
// The build_runner code generation is provided here to make it easier to
// avoid introducing the dependency into google3. Not all build* packages
// are synced internally.
import 'src/build_runner/build_runner.dart';
import 'src/build_runner/mustache_template.dart';
import 'src/build_runner/resident_web_runner.dart';
import 'src/build_runner/web_compilation_delegate.dart';
import 'src/codegen.dart';
flutter analyze command Other changes in this patch: - Make the 'flutter' tool say "Updating flutter tool..." when it calls pub get, to avoid confusion about what the pub get output is about. - Make the bash flutter tool call pub get when the revision has changed. (This was already happening on Windows.) - Fix a raft of bugs found by the analyzer. - Fix some style nits in various bits of code that happened to be near things the analyzer noticed. - Remove the logic in "flutter test" that would run "pub get", since upon further reflexion it was determined it didn't work anyway. We'll probably have to add better diagnostics here and say to run the updater script. - Remove the native velocity tracker script, since it was testing code that has since been removed. Notes on ignored warnings: - We ignore warnings in any packages that are not in the Flutter repo or in the author's current directory. - We ignore various irrelevant Strong Mode warnings. We still enable strong mode because even though it's not really relevant to our needs, it does (more or less accidentally) catch a few things that are helpful to us. - We allow CONSTANTS_LIKE_THIS, since we get some of those from other platforms that we are copying for sanity and consistency. - We allow one-member abstract classes since we have a number of them where it's perfectly reasonable. - We unfortunately still ignore warnings in mojom.dart autogenerated files. We should really fix those but that's a separate patch. - We verify the actual source file when we see the 'Name non-constant identifiers using lowerCamelCase.' lint, to allow one-letter variables that use capital letters (e.g. for physics expressions) and to allow multiple-underscore variable names. - We ignore all errors on lines that contain the following magic incantation and a "#" character: // analyzer doesn't like constructor tear-offs - For all remaining errors, if the line contains a comment of the form // analyzer says "..." ...then we ignore any errors that have that "..." string in them.
2015-11-11 18:29:05 +00:00
import 'src/commands/analyze.dart';
import 'src/commands/assemble.dart';
import 'src/commands/attach.dart';
import 'src/commands/build.dart';
import 'src/commands/channel.dart';
import 'src/commands/clean.dart';
import 'src/commands/config.dart';
2016-01-27 22:37:29 +00:00
import 'src/commands/create.dart';
import 'src/commands/daemon.dart';
2016-02-14 07:50:20 +00:00
import 'src/commands/devices.dart';
import 'src/commands/doctor.dart';
import 'src/commands/downgrade.dart';
import 'src/commands/drive.dart';
import 'src/commands/emulators.dart';
import 'src/commands/format.dart';
import 'src/commands/generate.dart';
import 'src/commands/ide_config.dart';
import 'src/commands/inject_plugins.dart';
import 'src/commands/install.dart';
import 'src/commands/logs.dart';
import 'src/commands/make_host_app_editable.dart';
import 'src/commands/packages.dart';
import 'src/commands/precache.dart';
2016-02-14 07:50:20 +00:00
import 'src/commands/run.dart';
2016-03-25 23:04:22 +00:00
import 'src/commands/screenshot.dart';
import 'src/commands/shell_completion.dart';
import 'src/commands/symbolize.dart';
2015-11-05 07:43:15 +00:00
import 'src/commands/test.dart';
import 'src/commands/train.dart';
import 'src/commands/update_packages.dart';
import 'src/commands/upgrade.dart';
import 'src/commands/version.dart';
import 'src/globals.dart' as globals;
import 'src/runner/flutter_command.dart';
import 'src/web/compile.dart';
import 'src/web/web_runner.dart';
2016-11-29 19:22:48 +00:00
/// Main entry point for commands.
///
/// This function is intended to be used from the `flutter` command line tool.
Future<void> main(List<String> args) async {
final bool verbose = args.contains('-v') || args.contains('--verbose');
final bool doctor = (args.isNotEmpty && args.first == 'doctor') ||
(args.length == 2 && verbose && args.last == 'doctor');
final bool help = args.contains('-h') || args.contains('--help') ||
(args.isNotEmpty && args.first == 'help') || (args.length == 1 && verbose);
2018-02-06 08:00:11 +00:00
final bool muteCommandLogging = help || doctor;
final bool verboseHelp = help && verbose;
2016-01-29 22:32:12 +00:00
await runner.run(args, <FlutterCommand>[
AnalyzeCommand(
verboseHelp: verboseHelp,
fileSystem: globals.fs,
platform: globals.platform,
processManager: globals.processManager,
logger: globals.logger,
terminal: globals.terminal,
),
AssembleCommand(),
AttachCommand(verboseHelp: verboseHelp),
BuildCommand(verboseHelp: verboseHelp),
ChannelCommand(verboseHelp: verboseHelp),
CleanCommand(verbose: verbose),
ConfigCommand(verboseHelp: verboseHelp),
CreateCommand(),
DaemonCommand(hidden: !verboseHelp),
DevicesCommand(),
DoctorCommand(verbose: verbose),
DowngradeCommand(),
DriveCommand(),
EmulatorsCommand(),
FormatCommand(),
GenerateCommand(),
IdeConfigCommand(hidden: !verboseHelp),
InjectPluginsCommand(hidden: !verboseHelp),
InstallCommand(),
LogsCommand(),
MakeHostAppEditableCommand(),
PackagesCommand(),
2019-09-17 15:19:33 +00:00
PrecacheCommand(verboseHelp: verboseHelp),
RunCommand(verboseHelp: verboseHelp),
ScreenshotCommand(),
ShellCompletionCommand(),
TestCommand(verboseHelp: verboseHelp),
TrainingCommand(),
UpdatePackagesCommand(hidden: !verboseHelp),
UpgradeCommand(),
VersionCommand(),
SymbolizeCommand(
stdio: globals.stdio,
fileSystem: globals.fs,
),
], verbose: verbose,
muteCommandLogging: muteCommandLogging,
verboseHelp: verboseHelp,
overrides: <Type, Generator>{
// The build runner instance is not supported in google3 because
// the build runner packages are not synced internally.
CodeGenerator: () => const BuildRunner(),
WebCompilationProxy: () => BuildRunnerWebCompilationProxy(),
// The web runner is not supported in google3 because it depends
// on dwds.
WebRunnerFactory: () => DwdsWebRunnerFactory(),
// The mustache dependency is different in google3
TemplateRenderer: () => const MustacheTemplateRenderer(),
});
}