Files
Chris Yang 87cfd6ab03 [tool] version-check publish-check commands can check against pub (#3840)
Add a PubVersionFinder class to easily fetch the version from pub.

Add an against-pub flag to check-version command, which allows it to check the version against pub server

Make the 'publish-check' command to check against pub to determine if the specific versions of packages need to be published.
Add a log-status flag, which allows the publish-check command to log the final status of the result. This helps other ci tools to easily grab the results and use it to determine what to do next. See option 3 in flutter/flutter#81444

This PR also fixes some tests.

partially flutter/flutter#81444
2021-05-11 12:48:30 -07:00
..

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/.

To run the tool (in flutter/plugins):

cd <path_to_plugins>/script/tool && dart pub get && cd ../../
dart run ./script/tool/lib/src/main.dart <args>

Format Code

cd <path_to_plugins>
dart run /script/tool/lib/src/main.dart format --plugins plugin_name

Run static analyzer

cd <path_to_plugins>
pub run ./script/tool/lib/src/main.dart analyze --plugins plugin_name

Run Dart unit tests

cd <path_to_plugins>
pub run ./script/tool/lib/src/main.dart test --plugins plugin_name

Run XCTests

cd <path_to_plugins>
dart run lib/src/main.dart xctest --target RunnerUITests --skip <plugins_to_skip>

Publish and tag release

sh cd <path_to_plugins> git checkout <commit_hash_to_publish> dart run ./script/tool/lib/src/main.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/lib/src/main.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.

There is a lot about this process that is still to be desired. Some top level items are being tracked in flutter/flutter#27258.