
Most of our commands are generally of the form: ``` for (each plugin as defined by the tool flags) check some things for success or failure print a summary all of the failing things exit non-zero if anything failed ``` Currently all that logic not consistent, having been at various points copied and pasted around, modified, in some cases rewritten. There's unnecessary boilerplate in each new command, and there's unnecessary variation that makes it harder both to maintain the tool, and to consume the test output: - There's no standard format for separating each plugin's run to search within a log - There's no standard format for the summary at the end - In some cases commands have been written to ToolExit on failure, which means we don't actually get the rest of the runs This makes a new base class for commands that follow this structure to use, with shared code for all the common bits. This makes it harder to accidentally write new commands incorrectly, easier to maintain the code, and lets us standardize output so that searching within large logs will be easier. This ports two commands over as a proof of concept to demonstrate that it works; more will be converted in follow-ups. Related to https://github.com/flutter/flutter/issues/83413
Flutter Plugin Tools
This is a set of utilities used in the flutter/plugins and flutter/packages repositories. It is no longer explictily maintained as a general-purpose tool for multi-package repositories, so your mileage may vary if using it in other repositories.
Note: The commands in tools are designed to run at the root of the repository or <repository-root>/packages/
.
Getting Started
In flutter/plugins, the tool is run from source. In flutter/packages, the published version is used instead. (It is marked as Discontinued since it is no longer maintained as a general-purpose tool, but updates are still published for use in flutter/packages.)
From Source (flutter/plugins only)
Set up:
cd ./script/tool && dart pub get && cd ../../
Run:
dart run ./script/tool/bin/flutter_plugin_tools.dart <args>
Published Version
Set up:
dart pub global activate flutter_plugin_tools
Run:
dart pub global run flutter_plugin_tools <args>
Commands
Run with --help
for a full list of commands and arguments, but the
following shows a number of common commands being run for a specific plugin.
All examples assume running from source; see above for running the published version instead.
Note that the plugins
argument, despite the name, applies to any package.
(It will likely be renamed packages
in the future.)
Format Code
cd <repository root>
dart run ./script/tool/bin/flutter_plugin_tools.dart format --plugins plugin_name
Run the Dart Static Analyzer
cd <repository root>
dart run ./script/tool/bin/flutter_plugin_tools.dart analyze --plugins plugin_name
Run Dart Unit Tests
cd <repository root>
dart run ./script/tool/bin/flutter_plugin_tools.dart test --plugins plugin_name
Run XCTests
cd <repository root>
# For iOS:
dart run ./script/tool/bin/flutter_plugin_tools.dart xctest --ios --plugins plugin_name
# For macOS:
dart run ./script/tool/bin/flutter_plugin_tools.dart xctest --macos --plugins plugin_name
Publish a Release
sh cd <path_to_plugins> git checkout <commit_hash_to_publish> dart run ./script/tool/bin/flutter_plugin_tools.dart publish-plugin --package <package>
By default the tool tries to push tags to the upstream
remote, but some
additional settings can be configured. Run dart run ./script/tool/bin/flutter_plugin_tools.dart publish-plugin --help
for more usage information.
The tool wraps pub publish
for pushing the package to pub, and then will
automatically use git to try to create and push tags. It has some additional
safety checking around pub publish
too. By default pub publish
publishes
everything, including untracked or uncommitted files in version control.
publish-plugin
will first check the status of the local
directory and refuse to publish if there are any mismatched files with version
control present.
Automated publishing is under development. Follow flutter/flutter#27258 for updates.
Updating the Tool
For flutter/plugins, just changing the source here is all that's needed.
For changes that are relevant to flutter/packages, you will also need to:
- Update the tool's pubspec.yaml and CHANGELOG
- Publish the tool
- Update the pinned version in flutter/packages