[tool] Clean up "plugin" references (#6503)
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0615408..5ff1556 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml
@@ -50,5 +50,5 @@ run: | git config --global user.name ${{ secrets.USER_NAME }} git config --global user.email ${{ secrets.USER_EMAIL }} - dart ./script/tool/lib/src/main.dart publish-plugin --all-changed --base-sha=HEAD~ --skip-confirmation --remote=origin + dart ./script/tool/lib/src/main.dart publish --all-changed --base-sha=HEAD~ --skip-confirmation --remote=origin env: {PUB_CREDENTIALS: "${{ secrets.PUB_CREDENTIALS }}"}
diff --git a/script/tool/CHANGELOG.md b/script/tool/CHANGELOG.md index 2417d0f..830d3ca 100644 --- a/script/tool/CHANGELOG.md +++ b/script/tool/CHANGELOG.md
@@ -1,3 +1,11 @@ +## 0.11 + +* Renames `publish-plugin` to `publish`. +* Renames arguments to `list`: + * `--package` now lists top-level packages (previously `--plugin`). + * `--package-or-subpackage` now lists top-level packages (previously + `--package`). + ## 0.10.0+1 * Recognizes `run_test.sh` as a developer-only file in `version-check`.
diff --git a/script/tool/README.md b/script/tool/README.md index 0e44bf1..9f0ac84 100644 --- a/script/tool/README.md +++ b/script/tool/README.md
@@ -54,7 +54,7 @@ ## 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. +following shows a number of common commands being run for a specific package. All examples assume running from source; see above for running the published version instead. @@ -71,29 +71,29 @@ ```sh cd <repository root> -dart run ./script/tool/bin/flutter_plugin_tools.dart format --packages plugin_name +dart run ./script/tool/bin/flutter_plugin_tools.dart format --packages package_name ``` ### Run the Dart Static Analyzer ```sh cd <repository root> -dart run ./script/tool/bin/flutter_plugin_tools.dart analyze --packages plugin_name +dart run ./script/tool/bin/flutter_plugin_tools.dart analyze --packages package_name ``` ### Run Dart Unit Tests ```sh cd <repository root> -dart run ./script/tool/bin/flutter_plugin_tools.dart test --packages plugin_name +dart run ./script/tool/bin/flutter_plugin_tools.dart test --packages package_name ``` ### Run Dart Integration Tests ```sh cd <repository root> -dart run ./script/tool/bin/flutter_plugin_tools.dart build-examples --apk --packages plugin_name -dart run ./script/tool/bin/flutter_plugin_tools.dart drive-examples --android --packages plugin_name +dart run ./script/tool/bin/flutter_plugin_tools.dart build-examples --apk --packages package_name +dart run ./script/tool/bin/flutter_plugin_tools.dart drive-examples --android --packages package_name ``` Replace `--apk`/`--android` with the platform you want to test against @@ -110,11 +110,11 @@ ```sh cd <repository root> # Run just unit tests for iOS and Android: -dart run ./script/tool/bin/flutter_plugin_tools.dart native-test --ios --android --no-integration --packages plugin_name +dart run ./script/tool/bin/flutter_plugin_tools.dart native-test --ios --android --no-integration --packages package_name # Run all tests for macOS: -dart run ./script/tool/bin/flutter_plugin_tools.dart native-test --macos --packages plugin_name +dart run ./script/tool/bin/flutter_plugin_tools.dart native-test --macos --packages package_name # Run all tests for Windows: -dart run ./script/tool/bin/flutter_plugin_tools.dart native-test --windows --packages plugin_name +dart run ./script/tool/bin/flutter_plugin_tools.dart native-test --windows --packages package_name ``` ### Update README.md from Example Sources @@ -125,7 +125,7 @@ ```sh cd <repository root> -dart run ./script/tool/bin/flutter_plugin_tools.dart update-excerpts --packages plugin_name +dart run ./script/tool/bin/flutter_plugin_tools.dart update-excerpts --packages package_name ``` ### Update CHANGELOG and Version @@ -165,18 +165,18 @@ ```sh cd <path_to_plugins> git checkout <commit_hash_to_publish> -dart run ./script/tool/bin/flutter_plugin_tools.dart publish-plugin --packages <package> +dart run ./script/tool/bin/flutter_plugin_tools.dart publish --packages <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. +publish --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 +`publish` will first check the status of the local directory and refuse to publish if there are any mismatched files with version control present.
diff --git a/script/tool/lib/src/common/plugin_command.dart b/script/tool/lib/src/common/package_command.dart similarity index 92% rename from script/tool/lib/src/common/plugin_command.dart rename to script/tool/lib/src/common/package_command.dart index 843768f..60d7ecc 100644 --- a/script/tool/lib/src/common/plugin_command.dart +++ b/script/tool/lib/src/common/package_command.dart
@@ -34,9 +34,9 @@ /// Interface definition for all commands in this tool. // TODO(stuartmorgan): Move most of this logic to PackageLoopingCommand. -abstract class PluginCommand extends Command<void> { +abstract class PackageCommand extends Command<void> { /// Creates a command to operate on [packagesDir] with the given environment. - PluginCommand( + PackageCommand( this.packagesDir, { this.processRunner = const ProcessRunner(), this.platform = const LocalPlatform(), @@ -47,7 +47,7 @@ help: 'Specifies which packages the command should run on (before sharding).\n', valueHelp: 'package1,package2,...', - aliases: <String>[_pluginsArg], + aliases: <String>[_pluginsLegacyAliasArg], ); argParser.addOption( _shardIndexArg, @@ -58,7 +58,7 @@ ); argParser.addOption( _shardCountArg, - help: 'Specifies the number of shards into which plugins are divided.', + help: 'Specifies the number of shards into which packages are divided.', valueHelp: 'n', defaultsTo: '1', ); @@ -71,7 +71,7 @@ defaultsTo: <String>[], ); argParser.addFlag(_runOnChangedPackagesArg, - help: 'Run the command on changed packages/plugins.\n' + help: 'Run the command on changed packages.\n' 'If no packages have changed, or if there have been changes that may\n' 'affect all packages, the command runs on all packages.\n' 'Packages excluded with $_excludeArg are excluded even if changed.\n' @@ -106,13 +106,13 @@ static const String _logTimingArg = 'log-timing'; static const String _packagesArg = 'packages'; static const String _packagesForBranchArg = 'packages-for-branch'; - static const String _pluginsArg = 'plugins'; + static const String _pluginsLegacyAliasArg = 'plugins'; static const String _runOnChangedPackagesArg = 'run-on-changed-packages'; static const String _runOnDirtyPackagesArg = 'run-on-dirty-packages'; static const String _shardCountArg = 'shardCount'; static const String _shardIndexArg = 'shardIndex'; - /// The directory containing the plugin packages. + /// The directory containing the packages. final Directory packagesDir; /// The process runner. @@ -221,7 +221,7 @@ _shardCount = shardCount; } - /// Returns the set of plugins to exclude based on the `--exclude` argument. + /// Returns the set of packages to exclude based on the `--exclude` argument. Set<String> getExcludedPackageNames() { final Set<String> excludedPackages = _excludedPackages ?? getStringListArg(_excludeArg).expand<String>((String item) { @@ -250,22 +250,22 @@ Stream<PackageEnumerationEntry> getTargetPackages( {bool filterExcluded = true}) async* { // To avoid assuming consistency of `Directory.list` across command - // invocations, we collect and sort the plugin folders before sharding. + // invocations, we collect and sort the package folders before sharding. // This is considered an implementation detail which is why the API still // uses streams. - final List<PackageEnumerationEntry> allPlugins = + final List<PackageEnumerationEntry> allPackages = await _getAllPackages().toList(); - allPlugins.sort((PackageEnumerationEntry p1, PackageEnumerationEntry p2) => + allPackages.sort((PackageEnumerationEntry p1, PackageEnumerationEntry p2) => p1.package.path.compareTo(p2.package.path)); - final int shardSize = allPlugins.length ~/ shardCount + - (allPlugins.length % shardCount == 0 ? 0 : 1); - final int start = min(shardIndex * shardSize, allPlugins.length); - final int end = min(start + shardSize, allPlugins.length); + final int shardSize = allPackages.length ~/ shardCount + + (allPackages.length % shardCount == 0 ? 0 : 1); + final int start = min(shardIndex * shardSize, allPackages.length); + final int end = min(start + shardSize, allPackages.length); - for (final PackageEnumerationEntry plugin - in allPlugins.sublist(start, end)) { - if (!(filterExcluded && plugin.excluded)) { - yield plugin; + for (final PackageEnumerationEntry package + in allPackages.sublist(start, end)) { + if (!(filterExcluded && package.excluded)) { + yield package; } } } @@ -330,7 +330,7 @@ runOnChangedPackages = false; } - final Set<String> excludedPluginNames = getExcludedPackageNames(); + final Set<String> excludedPackageNames = getExcludedPackageNames(); if (runOnChangedPackages) { final GitVersionFinder gitVersionFinder = await retrieveVersionFinder(); @@ -368,15 +368,16 @@ ]) { await for (final FileSystemEntity entity in dir.list(followLinks: false)) { - // A top-level Dart package is a plugin package. + // A top-level Dart package is a standard package. if (isPackage(entity)) { if (packages.isEmpty || packages.contains(p.basename(entity.path))) { yield PackageEnumerationEntry( RepositoryPackage(entity as Directory), - excluded: excludedPluginNames.contains(entity.basename)); + excluded: excludedPackageNames.contains(entity.basename)); } } else if (entity is Directory) { - // Look for Dart packages under this top-level directory. + // Look for Dart packages under this top-level directory; this is the + // standard structure for federated plugins. await for (final FileSystemEntity subdir in entity.list(followLinks: false)) { if (isPackage(subdir)) { @@ -394,7 +395,7 @@ packages.intersection(possibleMatches).isNotEmpty) { yield PackageEnumerationEntry( RepositoryPackage(subdir as Directory), - excluded: excludedPluginNames + excluded: excludedPackageNames .intersection(possibleMatches) .isNotEmpty); } @@ -415,11 +416,12 @@ /// stream. Stream<PackageEnumerationEntry> getTargetPackagesAndSubpackages( {bool filterExcluded = true}) async* { - await for (final PackageEnumerationEntry plugin + await for (final PackageEnumerationEntry package in getTargetPackages(filterExcluded: filterExcluded)) { - yield plugin; - yield* getSubpackages(plugin.package).map((RepositoryPackage package) => - PackageEnumerationEntry(package, excluded: plugin.excluded)); + yield package; + yield* getSubpackages(package.package).map( + (RepositoryPackage subPackage) => + PackageEnumerationEntry(subPackage, excluded: package.excluded)); } } @@ -524,7 +526,7 @@ } // Returns true if one or more files changed that have the potential to affect - // any plugin (e.g., CI script changes). + // any packages (e.g., CI script changes). bool _changesRequireFullTest(List<String> changedFiles) { const List<String> specialFiles = <String>[ '.ci.yaml', // LUCI config.
diff --git a/script/tool/lib/src/common/package_looping_command.dart b/script/tool/lib/src/common/package_looping_command.dart index 9e696e9..a32ada2 100644 --- a/script/tool/lib/src/common/package_looping_command.dart +++ b/script/tool/lib/src/common/package_looping_command.dart
@@ -12,7 +12,7 @@ import 'package:pub_semver/pub_semver.dart'; import 'core.dart'; -import 'plugin_command.dart'; +import 'package_command.dart'; import 'process_runner.dart'; import 'repository_package.dart'; @@ -82,7 +82,7 @@ /// An abstract base class for a command that iterates over a set of packages /// controlled by a standard set of flags, running some actions on each package, /// and collecting and reporting the success/failure of those actions. -abstract class PackageLoopingCommand extends PluginCommand { +abstract class PackageLoopingCommand extends PackageCommand { /// Creates a command to operate on [packagesDir] with the given environment. PackageLoopingCommand( Directory packagesDir, {
diff --git a/script/tool/lib/src/common/package_state_utils.dart b/script/tool/lib/src/common/package_state_utils.dart index c946587..870956a 100644 --- a/script/tool/lib/src/common/package_state_utils.dart +++ b/script/tool/lib/src/common/package_state_utils.dart
@@ -161,7 +161,7 @@ return exampleComponents.first.toLowerCase() != 'readme.md'; } -// True if the change is only relevant to people working on the plugin. +// True if the change is only relevant to people working on the package. Future<bool> _isDevChange(List<String> pathComponents, {GitVersionFinder? git, String? repoPath}) async { return _isTestChange(pathComponents) ||
diff --git a/script/tool/lib/src/create_all_plugins_app_command.dart b/script/tool/lib/src/create_all_plugins_app_command.dart index 7bf007a..a23dc83 100644 --- a/script/tool/lib/src/create_all_plugins_app_command.dart +++ b/script/tool/lib/src/create_all_plugins_app_command.dart
@@ -10,13 +10,13 @@ import 'package:pubspec_parse/pubspec_parse.dart'; import 'common/core.dart'; -import 'common/plugin_command.dart'; +import 'common/package_command.dart'; import 'common/repository_package.dart'; const String _outputDirectoryFlag = 'output-dir'; /// A command to create an application that builds all in a single application. -class CreateAllPluginsAppCommand extends PluginCommand { +class CreateAllPluginsAppCommand extends PackageCommand { /// Creates an instance of the builder command. CreateAllPluginsAppCommand( Directory packagesDir, {
diff --git a/script/tool/lib/src/drive_examples_command.dart b/script/tool/lib/src/drive_examples_command.dart index 45e20c0..e8fb11b 100644 --- a/script/tool/lib/src/drive_examples_command.dart +++ b/script/tool/lib/src/drive_examples_command.dart
@@ -49,7 +49,7 @@ final String name = 'drive-examples'; @override - final String description = 'Runs driver tests for plugin example apps.\n\n' + final String description = 'Runs driver tests for package example apps.\n\n' 'For each *_test.dart in test_driver/ it drives an application with ' 'either the corresponding test in test_driver (for example, ' 'test_driver/app_test.dart would match test_driver/app.dart), or the '
diff --git a/script/tool/lib/src/format_command.dart b/script/tool/lib/src/format_command.dart index f640cba..cc6936c 100644 --- a/script/tool/lib/src/format_command.dart +++ b/script/tool/lib/src/format_command.dart
@@ -11,7 +11,7 @@ import 'package:platform/platform.dart'; import 'common/core.dart'; -import 'common/plugin_command.dart'; +import 'common/package_command.dart'; import 'common/process_runner.dart'; /// In theory this should be 8191, but in practice that was still resulting in @@ -37,7 +37,7 @@ '/google/google-java-format/releases/download/google-java-format-1.3/google-java-format-1.3-all-deps.jar'); /// A command to format all package code. -class FormatCommand extends PluginCommand { +class FormatCommand extends PackageCommand { /// Creates an instance of the format command. FormatCommand( Directory packagesDir, {
diff --git a/script/tool/lib/src/license_check_command.dart b/script/tool/lib/src/license_check_command.dart index 5e74d84..0517bcf 100644 --- a/script/tool/lib/src/license_check_command.dart +++ b/script/tool/lib/src/license_check_command.dart
@@ -8,7 +8,7 @@ import 'package:platform/platform.dart'; import 'common/core.dart'; -import 'common/plugin_command.dart'; +import 'common/package_command.dart'; const Set<String> _codeFileExtensions = <String>{ '.c', @@ -105,7 +105,7 @@ '''; /// Validates that code files have copyright and license blocks. -class LicenseCheckCommand extends PluginCommand { +class LicenseCheckCommand extends PackageCommand { /// Creates a new license check command for [packagesDir]. LicenseCheckCommand(Directory packagesDir, {Platform platform = const LocalPlatform(), GitDir? gitDir})
diff --git a/script/tool/lib/src/list_command.dart b/script/tool/lib/src/list_command.dart index e45c09b..b47657e 100644 --- a/script/tool/lib/src/list_command.dart +++ b/script/tool/lib/src/list_command.dart
@@ -5,11 +5,11 @@ import 'package:file/file.dart'; import 'package:platform/platform.dart'; -import 'common/plugin_command.dart'; +import 'common/package_command.dart'; import 'common/repository_package.dart'; /// A command to list different types of repository content. -class ListCommand extends PluginCommand { +class ListCommand extends PackageCommand { /// Creates an instance of the list command, whose behavior depends on the /// 'type' argument it provides. ListCommand( @@ -18,14 +18,14 @@ }) : super(packagesDir, platform: platform) { argParser.addOption( _type, - defaultsTo: _plugin, - allowed: <String>[_plugin, _example, _package, _file], + defaultsTo: _package, + allowed: <String>[_package, _example, _allPackage, _file], help: 'What type of file system content to list.', ); } static const String _type = 'type'; - static const String _plugin = 'plugin'; + static const String _allPackage = 'package-or-subpackage'; static const String _example = 'example'; static const String _package = 'package'; static const String _file = 'file'; @@ -39,7 +39,7 @@ @override Future<void> run() async { switch (getStringArg(_type)) { - case _plugin: + case _package: await for (final PackageEnumerationEntry entry in getTargetPackages()) { print(entry.package.path); } @@ -52,7 +52,7 @@ print(package.path); } break; - case _package: + case _allPackage: await for (final PackageEnumerationEntry entry in getTargetPackagesAndSubpackages()) { print(entry.package.path);
diff --git a/script/tool/lib/src/main.dart b/script/tool/lib/src/main.dart index ea1ec06..0f73c71 100644 --- a/script/tool/lib/src/main.dart +++ b/script/tool/lib/src/main.dart
@@ -25,7 +25,7 @@ import 'make_deps_path_based_command.dart'; import 'native_test_command.dart'; import 'publish_check_command.dart'; -import 'publish_plugin_command.dart'; +import 'publish_command.dart'; import 'pubspec_check_command.dart'; import 'readme_check_command.dart'; import 'remove_dev_dependencies.dart'; @@ -69,7 +69,7 @@ ..addCommand(NativeTestCommand(packagesDir)) ..addCommand(MakeDepsPathBasedCommand(packagesDir)) ..addCommand(PublishCheckCommand(packagesDir)) - ..addCommand(PublishPluginCommand(packagesDir)) + ..addCommand(PublishCommand(packagesDir)) ..addCommand(PubspecCheckCommand(packagesDir)) ..addCommand(ReadmeCheckCommand(packagesDir)) ..addCommand(RemoveDevDependenciesCommand(packagesDir))
diff --git a/script/tool/lib/src/make_deps_path_based_command.dart b/script/tool/lib/src/make_deps_path_based_command.dart index 805dd68..a09511a 100644 --- a/script/tool/lib/src/make_deps_path_based_command.dart +++ b/script/tool/lib/src/make_deps_path_based_command.dart
@@ -9,7 +9,7 @@ import 'common/core.dart'; import 'common/git_version_finder.dart'; -import 'common/plugin_command.dart'; +import 'common/package_command.dart'; import 'common/repository_package.dart'; const int _exitPackageNotFound = 3; @@ -24,7 +24,7 @@ /// where a non-breaking change to a platform interface package of a federated /// plugin would cause post-publish analyzer failures in another package of that /// plugin. -class MakeDepsPathBasedCommand extends PluginCommand { +class MakeDepsPathBasedCommand extends PackageCommand { /// Creates an instance of the command to convert selected dependencies to /// path-based. MakeDepsPathBasedCommand( @@ -150,7 +150,7 @@ return _RewriteOutcome.alreadyChanged; } printError( - 'Plugins with dependency overrides are not currently supported.'); + 'Packages with dependency overrides are not currently supported.'); throw ToolExit(_exitCannotUpdatePubspec); }
diff --git a/script/tool/lib/src/publish_check_command.dart b/script/tool/lib/src/publish_check_command.dart index d98a286..38e1b7b 100644 --- a/script/tool/lib/src/publish_check_command.dart +++ b/script/tool/lib/src/publish_check_command.dart
@@ -55,7 +55,7 @@ @override final String description = - 'Checks to make sure that a plugin *could* be published.'; + 'Checks to make sure that a package *could* be published.'; final PubVersionFinder _pubVersionFinder;
diff --git a/script/tool/lib/src/publish_plugin_command.dart b/script/tool/lib/src/publish_command.dart similarity index 98% rename from script/tool/lib/src/publish_plugin_command.dart rename to script/tool/lib/src/publish_command.dart index cae8eda..e7b3d11 100644 --- a/script/tool/lib/src/publish_plugin_command.dart +++ b/script/tool/lib/src/publish_command.dart
@@ -18,8 +18,8 @@ import 'common/core.dart'; import 'common/file_utils.dart'; import 'common/git_version_finder.dart'; +import 'common/package_command.dart'; import 'common/package_looping_command.dart'; -import 'common/plugin_command.dart'; import 'common/process_runner.dart'; import 'common/pub_version_finder.dart'; import 'common/repository_package.dart'; @@ -42,13 +42,13 @@ /// 2. Tags the release with the format <package-name>-v<package-version>. /// 3. Pushes the release to a remote. /// -/// Both 2 and 3 are optional, see `plugin_tools help publish-plugin` for full +/// Both 2 and 3 are optional, see `plugin_tools help publish` for full /// usage information. /// /// [processRunner], [print], and [stdin] can be overriden for easier testing. -class PublishPluginCommand extends PackageLoopingCommand { +class PublishCommand extends PackageLoopingCommand { /// Creates an instance of the publish command. - PublishPluginCommand( + PublishCommand( Directory packagesDir, { ProcessRunner processRunner = const ProcessRunner(), Platform platform = const LocalPlatform(), @@ -100,7 +100,7 @@ static const String _tagFormat = '%PACKAGE%-v%VERSION%'; @override - final String name = 'publish-plugin'; + final String name = 'publish'; @override final String description =
diff --git a/script/tool/lib/src/version_check_command.dart b/script/tool/lib/src/version_check_command.dart index 2356114..b3be672 100644 --- a/script/tool/lib/src/version_check_command.dart +++ b/script/tool/lib/src/version_check_command.dart
@@ -170,7 +170,7 @@ @override final String description = - 'Checks if the versions of the plugins have been incremented per pub specification.\n' + 'Checks if the versions of packages have been incremented per pub specification.\n' 'Also checks if the latest version in CHANGELOG matches the version in pubspec.\n\n' 'This command requires "pub" and "flutter" to be in your path.'; @@ -318,7 +318,7 @@ print('${indentation}Unable to find previous version ' '${getBoolArg(_againstPubFlag) ? 'on pub server' : 'at git base'}.'); logWarning( - '${indentation}If this plugin is not new, something has gone wrong.'); + '${indentation}If this package is not new, something has gone wrong.'); return _CurrentVersionState.validIncrease; // Assume new, thus valid. }
diff --git a/script/tool/pubspec.yaml b/script/tool/pubspec.yaml index 9b9d732..246c2ad 100644 --- a/script/tool/pubspec.yaml +++ b/script/tool/pubspec.yaml
@@ -1,7 +1,7 @@ name: flutter_plugin_tools description: Productivity utils for flutter/plugins and flutter/packages repository: https://github.com/flutter/plugins/tree/main/script/tool -version: 0.10.0+1 +version: 0.11.0 dependencies: args: ^2.1.0
diff --git a/script/tool/test/analyze_command_test.dart b/script/tool/test/analyze_command_test.dart index e10780f..e6b9109 100644 --- a/script/tool/test/analyze_command_test.dart +++ b/script/tool/test/analyze_command_test.dart
@@ -37,7 +37,7 @@ }); test('analyzes all packages', () async { - final RepositoryPackage plugin1 = createFakePlugin('a', packagesDir); + final RepositoryPackage package1 = createFakePackage('a', packagesDir); final RepositoryPackage plugin2 = createFakePlugin('b', packagesDir); await runCapturingPrint(runner, <String>['analyze']); @@ -45,9 +45,9 @@ expect( processRunner.recordedCalls, orderedEquals(<ProcessCall>[ - ProcessCall('flutter', const <String>['pub', 'get'], plugin1.path), - ProcessCall( - 'dart', const <String>['analyze', '--fatal-infos'], plugin1.path), + ProcessCall('flutter', const <String>['pub', 'get'], package1.path), + ProcessCall('dart', const <String>['analyze', '--fatal-infos'], + package1.path), ProcessCall('flutter', const <String>['pub', 'get'], plugin2.path), ProcessCall( 'dart', const <String>['analyze', '--fatal-infos'], plugin2.path),
diff --git a/script/tool/test/common/git_version_finder_test.dart b/script/tool/test/common/git_version_finder_test.dart index ad1a26f..d5a5dd4 100644 --- a/script/tool/test/common/git_version_finder_test.dart +++ b/script/tool/test/common/git_version_finder_test.dart
@@ -8,7 +8,7 @@ import 'package:mockito/mockito.dart'; import 'package:test/test.dart'; -import 'plugin_command_test.mocks.dart'; +import 'package_command_test.mocks.dart'; void main() { late List<List<String>?> gitDirCommands;
diff --git a/script/tool/test/common/plugin_command_test.dart b/script/tool/test/common/package_command_test.dart similarity index 98% rename from script/tool/test/common/plugin_command_test.dart rename to script/tool/test/common/package_command_test.dart index 8c6b386..c3d1ee3 100644 --- a/script/tool/test/common/plugin_command_test.dart +++ b/script/tool/test/common/package_command_test.dart
@@ -8,7 +8,7 @@ import 'package:file/file.dart'; import 'package:file/memory.dart'; import 'package:flutter_plugin_tools/src/common/core.dart'; -import 'package:flutter_plugin_tools/src/common/plugin_command.dart'; +import 'package:flutter_plugin_tools/src/common/package_command.dart'; import 'package:flutter_plugin_tools/src/common/process_runner.dart'; import 'package:git/git.dart'; import 'package:mockito/annotations.dart'; @@ -18,12 +18,12 @@ import '../mocks.dart'; import '../util.dart'; -import 'plugin_command_test.mocks.dart'; +import 'package_command_test.mocks.dart'; @GenerateMocks(<Type>[GitDir]) void main() { late RecordingProcessRunner processRunner; - late SamplePluginCommand command; + late SamplePackageCommand command; late CommandRunner<void> runner; late FileSystem fileSystem; late MockPlatform mockPlatform; @@ -49,7 +49,7 @@ return processRunner.run('git-$gitCommand', arguments); }); processRunner = RecordingProcessRunner(); - command = SamplePluginCommand( + command = SamplePackageCommand( packagesDir, processRunner: processRunner, platform: mockPlatform, @@ -282,7 +282,7 @@ }); test('returns subpackages after the enclosing package', () async { - final SamplePluginCommand localCommand = SamplePluginCommand( + final SamplePackageCommand localCommand = SamplePackageCommand( packagesDir, processRunner: processRunner, platform: mockPlatform, @@ -848,7 +848,7 @@ ]; for (int i = 0; i < expectedShards.length; ++i) { - final SamplePluginCommand localCommand = SamplePluginCommand( + final SamplePackageCommand localCommand = SamplePackageCommand( packagesDir, processRunner: processRunner, platform: mockPlatform, @@ -892,7 +892,7 @@ ]; for (int i = 0; i < expectedShards.length; ++i) { - final SamplePluginCommand localCommand = SamplePluginCommand( + final SamplePackageCommand localCommand = SamplePackageCommand( packagesDir, processRunner: processRunner, platform: mockPlatform, @@ -945,7 +945,7 @@ createFakePackage('package9', packagesDir); for (int i = 0; i < expectedShards.length; ++i) { - final SamplePluginCommand localCommand = SamplePluginCommand( + final SamplePackageCommand localCommand = SamplePackageCommand( packagesDir, processRunner: processRunner, platform: mockPlatform, @@ -971,8 +971,8 @@ }); } -class SamplePluginCommand extends PluginCommand { - SamplePluginCommand( +class SamplePackageCommand extends PackageCommand { + SamplePackageCommand( Directory packagesDir, { ProcessRunner processRunner = const ProcessRunner(), Platform platform = const LocalPlatform(),
diff --git a/script/tool/test/common/plugin_command_test.mocks.dart b/script/tool/test/common/package_command_test.mocks.dart similarity index 100% rename from script/tool/test/common/plugin_command_test.mocks.dart rename to script/tool/test/common/package_command_test.mocks.dart
diff --git a/script/tool/test/common/package_looping_command_test.dart b/script/tool/test/common/package_looping_command_test.dart index 7e9f63c..c858df0 100644 --- a/script/tool/test/common/package_looping_command_test.dart +++ b/script/tool/test/common/package_looping_command_test.dart
@@ -18,7 +18,7 @@ import '../mocks.dart'; import '../util.dart'; -import 'plugin_command_test.mocks.dart'; +import 'package_command_test.mocks.dart'; // Constants for colorized output start and end. const String _startElapsedTimeColor = '\x1B[90m'; @@ -373,9 +373,10 @@ test('skips unsupported Dart versions when requested', () async { final RepositoryPackage excluded = createFakePackage( - 'excluded_package', packagesDir, dartConstraint: '>=2.17.0 <3.0.0'); - final RepositoryPackage included = createFakePackage( - 'a_package', packagesDir); + 'excluded_package', packagesDir, + dartConstraint: '>=2.17.0 <3.0.0'); + final RepositoryPackage included = + createFakePackage('a_package', packagesDir); final TestPackageLoopingCommand command = createTestCommand( packageLoopingType: PackageLoopingType.includeAllSubpackages, @@ -406,8 +407,7 @@ createFakePlugin('package_a', packagesDir); createFakePackage('package_b', packagesDir); - final TestPackageLoopingCommand command = - createTestCommand(); + final TestPackageLoopingCommand command = createTestCommand(); final List<String> output = await runCommand(command); const String separator = @@ -440,8 +440,7 @@ createFakePlugin('package_a', packagesDir); createFakePackage('package_b', packagesDir); - final TestPackageLoopingCommand command = - createTestCommand(); + final TestPackageLoopingCommand command = createTestCommand(); final List<String> output = await runCommand(command, arguments: <String>['--log-timing']); @@ -783,8 +782,7 @@ createFakePackage('package_f', packagesDir); - final TestPackageLoopingCommand command = - createTestCommand(); + final TestPackageLoopingCommand command = createTestCommand(); final List<String> output = await runCommand(command); expect( @@ -809,8 +807,7 @@ test('prints exclusions as skips in long-form run summary', () async { createFakePackage('package_a', packagesDir); - final TestPackageLoopingCommand command = - createTestCommand(); + final TestPackageLoopingCommand command = createTestCommand(); final List<String> output = await runCommand(command, arguments: <String>['--exclude=package_a']);
diff --git a/script/tool/test/custom_test_command_test.dart b/script/tool/test/custom_test_command_test.dart index a28b475..8b0c021 100644 --- a/script/tool/test/custom_test_command_test.dart +++ b/script/tool/test/custom_test_command_test.dart
@@ -40,7 +40,7 @@ test('runs both new and legacy when both are present', () async { final RepositoryPackage package = - createFakePlugin('a_package', packagesDir, extraFiles: <String>[ + createFakePackage('a_package', packagesDir, extraFiles: <String>[ 'tool/run_tests.dart', 'run_tests.sh', ]); @@ -65,7 +65,7 @@ }); test('runs when only new is present', () async { - final RepositoryPackage package = createFakePlugin( + final RepositoryPackage package = createFakePackage( 'a_package', packagesDir, extraFiles: <String>['tool/run_tests.dart']); @@ -87,7 +87,7 @@ }); test('runs pub get before running Dart test script', () async { - final RepositoryPackage package = createFakePlugin( + final RepositoryPackage package = createFakePackage( 'a_package', packagesDir, extraFiles: <String>['tool/run_tests.dart']); @@ -103,7 +103,7 @@ }); test('runs when only legacy is present', () async { - final RepositoryPackage package = createFakePlugin( + final RepositoryPackage package = createFakePackage( 'a_package', packagesDir, extraFiles: <String>['run_tests.sh']); @@ -125,7 +125,7 @@ }); test('skips when neither is present', () async { - createFakePlugin('a_package', packagesDir); + createFakePackage('a_package', packagesDir); final List<String> output = await runCapturingPrint(runner, <String>['custom-test']); @@ -140,7 +140,7 @@ }); test('fails if new fails', () async { - createFakePlugin('a_package', packagesDir, extraFiles: <String>[ + createFakePackage('a_package', packagesDir, extraFiles: <String>[ 'tool/run_tests.dart', 'run_tests.sh', ]); @@ -166,7 +166,7 @@ }); test('fails if pub get fails', () async { - createFakePlugin('a_package', packagesDir, extraFiles: <String>[ + createFakePackage('a_package', packagesDir, extraFiles: <String>[ 'tool/run_tests.dart', 'run_tests.sh', ]); @@ -193,7 +193,7 @@ test('fails if legacy fails', () async { final RepositoryPackage package = - createFakePlugin('a_package', packagesDir, extraFiles: <String>[ + createFakePackage('a_package', packagesDir, extraFiles: <String>[ 'tool/run_tests.dart', 'run_tests.sh', ]); @@ -238,7 +238,7 @@ test('runs new and skips old when both are present', () async { final RepositoryPackage package = - createFakePlugin('a_package', packagesDir, extraFiles: <String>[ + createFakePackage('a_package', packagesDir, extraFiles: <String>[ 'tool/run_tests.dart', 'run_tests.sh', ]); @@ -261,7 +261,7 @@ }); test('runs when only new is present', () async { - final RepositoryPackage package = createFakePlugin( + final RepositoryPackage package = createFakePackage( 'a_package', packagesDir, extraFiles: <String>['tool/run_tests.dart']); @@ -283,7 +283,7 @@ }); test('skips package when only legacy is present', () async { - createFakePlugin('a_package', packagesDir, + createFakePackage('a_package', packagesDir, extraFiles: <String>['run_tests.sh']); final List<String> output = @@ -300,7 +300,7 @@ }); test('fails if new fails', () async { - createFakePlugin('a_package', packagesDir, extraFiles: <String>[ + createFakePackage('a_package', packagesDir, extraFiles: <String>[ 'tool/run_tests.dart', 'run_tests.sh', ]);
diff --git a/script/tool/test/dependabot_check_command_test.dart b/script/tool/test/dependabot_check_command_test.dart index a4c8693..b0558c3 100644 --- a/script/tool/test/dependabot_check_command_test.dart +++ b/script/tool/test/dependabot_check_command_test.dart
@@ -10,7 +10,7 @@ import 'package:mockito/mockito.dart'; import 'package:test/test.dart'; -import 'common/plugin_command_test.mocks.dart'; +import 'common/package_command_test.mocks.dart'; import 'util.dart'; void main() {
diff --git a/script/tool/test/federation_safety_check_command_test.dart b/script/tool/test/federation_safety_check_command_test.dart index 015a0eb..6b6b1a5 100644 --- a/script/tool/test/federation_safety_check_command_test.dart +++ b/script/tool/test/federation_safety_check_command_test.dart
@@ -12,7 +12,7 @@ import 'package:mockito/mockito.dart'; import 'package:test/test.dart'; -import 'common/plugin_command_test.mocks.dart'; +import 'common/package_command_test.mocks.dart'; import 'mocks.dart'; import 'util.dart';
diff --git a/script/tool/test/format_command_test.dart b/script/tool/test/format_command_test.dart index 5bd6f97..c1c4a21 100644 --- a/script/tool/test/format_command_test.dart +++ b/script/tool/test/format_command_test.dart
@@ -60,15 +60,15 @@ } /// Returns a list of [count] relative paths to pass to [createFakePlugin] - /// with name [pluginName] such that each path will be 99 characters long - /// relative to [packagesDir]. + /// or [createFakePackage] with name [packageName] such that each path will + /// be 99 characters long relative to [packagesDir]. /// /// This is for each of testing batching, since it means each file will /// consume 100 characters of the batch length. - List<String> _get99CharacterPathExtraFiles(String pluginName, int count) { + List<String> _get99CharacterPathExtraFiles(String packageName, int count) { final int padding = 99 - - pluginName.length - - 1 - // the path separator after the plugin name + packageName.length - + 1 - // the path separator after the package name 1 - // the path separator after the padding 10; // the file name const int filenameBase = 10000;
diff --git a/script/tool/test/license_check_command_test.dart b/script/tool/test/license_check_command_test.dart index 43fbd6b..005b77d 100644 --- a/script/tool/test/license_check_command_test.dart +++ b/script/tool/test/license_check_command_test.dart
@@ -11,7 +11,7 @@ import 'package:platform/platform.dart'; import 'package:test/test.dart'; -import 'common/plugin_command_test.mocks.dart'; +import 'common/package_command_test.mocks.dart'; import 'mocks.dart'; import 'util.dart';
diff --git a/script/tool/test/list_command_test.dart b/script/tool/test/list_command_test.dart index f74431c..f19215c 100644 --- a/script/tool/test/list_command_test.dart +++ b/script/tool/test/list_command_test.dart
@@ -29,17 +29,17 @@ runner.addCommand(command); }); - test('lists plugins', () async { - createFakePlugin('plugin1', packagesDir); + test('lists top-level packages', () async { + createFakePackage('package1', packagesDir); createFakePlugin('plugin2', packagesDir); final List<String> plugins = - await runCapturingPrint(runner, <String>['list', '--type=plugin']); + await runCapturingPrint(runner, <String>['list', '--type=package']); expect( plugins, orderedEquals(<String>[ - '/packages/plugin1', + '/packages/package1', '/packages/plugin2', ]), ); @@ -64,20 +64,20 @@ ); }); - test('lists packages', () async { - createFakePlugin('plugin1', packagesDir); + test('lists packages and subpackages', () async { + createFakePackage('package1', packagesDir); createFakePlugin('plugin2', packagesDir, examples: <String>['example1', 'example2']); createFakePlugin('plugin3', packagesDir, examples: <String>[]); - final List<String> packages = - await runCapturingPrint(runner, <String>['list', '--type=package']); + final List<String> packages = await runCapturingPrint( + runner, <String>['list', '--type=package-or-subpackage']); expect( packages, unorderedEquals(<String>[ - '/packages/plugin1', - '/packages/plugin1/example', + '/packages/package1', + '/packages/package1/example', '/packages/plugin2', '/packages/plugin2/example/example1', '/packages/plugin2/example/example2',
diff --git a/script/tool/test/make_deps_path_based_command_test.dart b/script/tool/test/make_deps_path_based_command_test.dart index 33d6be2..7e52dd6 100644 --- a/script/tool/test/make_deps_path_based_command_test.dart +++ b/script/tool/test/make_deps_path_based_command_test.dart
@@ -11,7 +11,7 @@ import 'package:mockito/mockito.dart'; import 'package:test/test.dart'; -import 'common/plugin_command_test.mocks.dart'; +import 'common/package_command_test.mocks.dart'; import 'mocks.dart'; import 'util.dart';
diff --git a/script/tool/test/publish_plugin_command_test.dart b/script/tool/test/publish_command_test.dart similarity index 94% rename from script/tool/test/publish_plugin_command_test.dart rename to script/tool/test/publish_command_test.dart index f3be3b4..19e8bdd 100644 --- a/script/tool/test/publish_plugin_command_test.dart +++ b/script/tool/test/publish_command_test.dart
@@ -10,14 +10,14 @@ import 'package:file/file.dart'; import 'package:file/memory.dart'; import 'package:flutter_plugin_tools/src/common/core.dart'; -import 'package:flutter_plugin_tools/src/publish_plugin_command.dart'; +import 'package:flutter_plugin_tools/src/publish_command.dart'; import 'package:http/http.dart' as http; import 'package:http/testing.dart'; import 'package:mockito/mockito.dart'; import 'package:platform/platform.dart'; import 'package:test/test.dart'; -import 'common/plugin_command_test.mocks.dart'; +import 'common/package_command_test.mocks.dart'; import 'mocks.dart'; import 'util.dart'; @@ -34,7 +34,7 @@ late Map<String, Map<String, dynamic>> mockHttpResponses; void _createMockCredentialFile() { - final String credentialPath = PublishPluginCommand.getCredentialPath(); + final String credentialPath = PublishCommand.getCredentialPath(); fileSystem.file(credentialPath) ..createSync(recursive: true) ..writeAsStringSync('some credential'); @@ -72,7 +72,7 @@ mockStdin = MockStdin(); commandRunner = CommandRunner<void>('tester', '') - ..addCommand(PublishPluginCommand( + ..addCommand(PublishCommand( packagesDir, processRunner: processRunner, stdinput: mockStdin, @@ -93,7 +93,7 @@ Error? commandError; final List<String> output = await runCapturingPrint(commandRunner, <String>[ - 'publish-plugin', + 'publish', '--packages=foo', ], errorHandler: (Error e) { commandError = e; @@ -122,7 +122,7 @@ Error? commandError; final List<String> output = await runCapturingPrint( - commandRunner, <String>['publish-plugin', '--packages=foo'], + commandRunner, <String>['publish', '--packages=foo'], errorHandler: (Error e) { commandError = e; }); @@ -154,8 +154,8 @@ stderrEncoding: utf8), // pub publish for plugin1 ]; - final List<String> output = await runCapturingPrint(commandRunner, - <String>['publish-plugin', '--packages=plugin1,plugin2']); + final List<String> output = await runCapturingPrint( + commandRunner, <String>['publish', '--packages=plugin1,plugin2']); expect( output, @@ -176,7 +176,7 @@ mockStdin.mockUserInputs.add(utf8.encode('user input')); await runCapturingPrint( - commandRunner, <String>['publish-plugin', '--packages=foo']); + commandRunner, <String>['publish', '--packages=foo']); expect(processRunner.mockPublishProcess.stdinMock.lines, contains('user input')); @@ -187,7 +187,7 @@ createFakePlugin('foo', packagesDir, examples: <String>[]); await runCapturingPrint(commandRunner, <String>[ - 'publish-plugin', + 'publish', '--packages=foo', '--pub-publish-flags', '--dry-run,--server=bar' @@ -209,7 +209,7 @@ createFakePlugin('foo', packagesDir, examples: <String>[]); await runCapturingPrint(commandRunner, <String>[ - 'publish-plugin', + 'publish', '--packages=foo', '--skip-confirmation', '--pub-publish-flags', @@ -232,7 +232,7 @@ createFakePlugin('plugin_b', packagesDir, examples: <String>[]); await runCapturingPrint(commandRunner, <String>[ - 'publish-plugin', + 'publish', '--packages=plugin_a,plugin_b', '--skip-confirmation', '--pub-publish-flags', @@ -263,7 +263,7 @@ Error? commandError; final List<String> output = await runCapturingPrint(commandRunner, <String>[ - 'publish-plugin', + 'publish', '--packages=foo', ], errorHandler: (Error e) { commandError = e; @@ -283,7 +283,7 @@ final List<String> output = await runCapturingPrint(commandRunner, <String>[ - 'publish-plugin', + 'publish', '--packages=foo', '--dry-run', ]); @@ -310,7 +310,7 @@ final List<String> output = await runCapturingPrint(commandRunner, <String>[ - 'publish-plugin', + 'publish', '--packages=$packageName', ]); @@ -330,7 +330,7 @@ test('with the version and name from the pubspec.yaml', () async { createFakePlugin('foo', packagesDir, examples: <String>[]); await runCapturingPrint(commandRunner, <String>[ - 'publish-plugin', + 'publish', '--packages=foo', ]); @@ -348,7 +348,7 @@ Error? commandError; final List<String> output = await runCapturingPrint(commandRunner, <String>[ - 'publish-plugin', + 'publish', '--packages=foo', ], errorHandler: (Error e) { commandError = e; @@ -375,7 +375,7 @@ final List<String> output = await runCapturingPrint(commandRunner, <String>[ - 'publish-plugin', + 'publish', '--packages=foo', ]); @@ -398,7 +398,7 @@ final List<String> output = await runCapturingPrint(commandRunner, <String>[ - 'publish-plugin', + 'publish', '--skip-confirmation', '--packages=foo', ]); @@ -420,8 +420,8 @@ mockStdin.readLineOutput = 'y'; - final List<String> output = await runCapturingPrint(commandRunner, - <String>['publish-plugin', '--packages=foo', '--dry-run']); + final List<String> output = await runCapturingPrint( + commandRunner, <String>['publish', '--packages=foo', '--dry-run']); expect( processRunner.recordedCalls @@ -445,7 +445,7 @@ final List<String> output = await runCapturingPrint(commandRunner, <String>[ - 'publish-plugin', + 'publish', '--packages=foo', '--remote', 'origin', @@ -491,7 +491,7 @@ mockStdin.readLineOutput = 'y'; final List<String> output = await runCapturingPrint(commandRunner, - <String>['publish-plugin', '--all-changed', '--base-sha=HEAD~']); + <String>['publish', '--all-changed', '--base-sha=HEAD~']); expect( output, @@ -553,7 +553,7 @@ mockStdin.readLineOutput = 'y'; final List<String> output = await runCapturingPrint(commandRunner, - <String>['publish-plugin', '--all-changed', '--base-sha=HEAD~']); + <String>['publish', '--all-changed', '--base-sha=HEAD~']); expect( output, @@ -598,7 +598,7 @@ final List<String> output = await runCapturingPrint( commandRunner, <String>[ - 'publish-plugin', + 'publish', '--all-changed', '--base-sha=HEAD~', '--dry-run' @@ -651,7 +651,7 @@ mockStdin.readLineOutput = 'y'; final List<String> output2 = await runCapturingPrint(commandRunner, - <String>['publish-plugin', '--all-changed', '--base-sha=HEAD~']); + <String>['publish', '--all-changed', '--base-sha=HEAD~']); expect( output2, containsAllInOrder(<Matcher>[ @@ -700,7 +700,7 @@ mockStdin.readLineOutput = 'y'; final List<String> output2 = await runCapturingPrint(commandRunner, - <String>['publish-plugin', '--all-changed', '--base-sha=HEAD~']); + <String>['publish', '--all-changed', '--base-sha=HEAD~']); expect( output2, containsAllInOrder(<Matcher>[ @@ -749,7 +749,7 @@ ]; final List<String> output = await runCapturingPrint(commandRunner, - <String>['publish-plugin', '--all-changed', '--base-sha=HEAD~']); + <String>['publish', '--all-changed', '--base-sha=HEAD~']); expect( output, @@ -795,7 +795,7 @@ Error? commandError; final List<String> output = await runCapturingPrint(commandRunner, - <String>['publish-plugin', '--all-changed', '--base-sha=HEAD~'], + <String>['publish', '--all-changed', '--base-sha=HEAD~'], errorHandler: (Error e) { commandError = e; }); @@ -830,7 +830,7 @@ ]; final List<String> output = await runCapturingPrint(commandRunner, - <String>['publish-plugin', '--all-changed', '--base-sha=HEAD~']); + <String>['publish', '--all-changed', '--base-sha=HEAD~']); expect(output, containsAllInOrder(<String>['Ran for 0 package(s)'])); expect( @@ -852,7 +852,7 @@ ]; final List<String> output = await runCapturingPrint(commandRunner, - <String>['publish-plugin', '--all-changed', '--base-sha=HEAD~']); + <String>['publish', '--all-changed', '--base-sha=HEAD~']); expect( output,
diff --git a/script/tool/test/update_excerpts_command_test.dart b/script/tool/test/update_excerpts_command_test.dart index 34c85cc..79f53d8 100644 --- a/script/tool/test/update_excerpts_command_test.dart +++ b/script/tool/test/update_excerpts_command_test.dart
@@ -12,7 +12,7 @@ import 'package:mockito/mockito.dart'; import 'package:test/test.dart'; -import 'common/plugin_command_test.mocks.dart'; +import 'common/package_command_test.mocks.dart'; import 'mocks.dart'; import 'util.dart';
diff --git a/script/tool/test/update_release_info_command_test.dart b/script/tool/test/update_release_info_command_test.dart index 7e7ff54..8cd2e95 100644 --- a/script/tool/test/update_release_info_command_test.dart +++ b/script/tool/test/update_release_info_command_test.dart
@@ -12,7 +12,7 @@ import 'package:mockito/mockito.dart'; import 'package:test/test.dart'; -import 'common/plugin_command_test.mocks.dart'; +import 'common/package_command_test.mocks.dart'; import 'mocks.dart'; import 'util.dart';
diff --git a/script/tool/test/version_check_command_test.dart b/script/tool/test/version_check_command_test.dart index 0e94712..598176b 100644 --- a/script/tool/test/version_check_command_test.dart +++ b/script/tool/test/version_check_command_test.dart
@@ -16,7 +16,7 @@ import 'package:pub_semver/pub_semver.dart'; import 'package:test/test.dart'; -import 'common/plugin_command_test.mocks.dart'; +import 'common/package_command_test.mocks.dart'; import 'mocks.dart'; import 'util.dart';