Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit 2592df9

Browse files
[tool] Clean up "plugin" references (#6503)
1 parent b3018c8 commit 2592df9

33 files changed

+174
-167
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,5 +50,5 @@ jobs:
5050
run: |
5151
git config --global user.name ${{ secrets.USER_NAME }}
5252
git config --global user.email ${{ secrets.USER_EMAIL }}
53-
dart ./script/tool/lib/src/main.dart publish-plugin --all-changed --base-sha=HEAD~ --skip-confirmation --remote=origin
53+
dart ./script/tool/lib/src/main.dart publish --all-changed --base-sha=HEAD~ --skip-confirmation --remote=origin
5454
env: {PUB_CREDENTIALS: "${{ secrets.PUB_CREDENTIALS }}"}

script/tool/CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
## 0.11
2+
3+
* Renames `publish-plugin` to `publish`.
4+
* Renames arguments to `list`:
5+
* `--package` now lists top-level packages (previously `--plugin`).
6+
* `--package-or-subpackage` now lists top-level packages (previously
7+
`--package`).
8+
19
## 0.10.0+1
210

311
* Recognizes `run_test.sh` as a developer-only file in `version-check`.

script/tool/README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ dart pub global run flutter_plugin_tools <args>
5454
## Commands
5555

5656
Run with `--help` for a full list of commands and arguments, but the
57-
following shows a number of common commands being run for a specific plugin.
57+
following shows a number of common commands being run for a specific package.
5858

5959
All examples assume running from source; see above for running the
6060
published version instead.
@@ -71,29 +71,29 @@ command is targetting. An package name can be any of:
7171

7272
```sh
7373
cd <repository root>
74-
dart run ./script/tool/bin/flutter_plugin_tools.dart format --packages plugin_name
74+
dart run ./script/tool/bin/flutter_plugin_tools.dart format --packages package_name
7575
```
7676

7777
### Run the Dart Static Analyzer
7878

7979
```sh
8080
cd <repository root>
81-
dart run ./script/tool/bin/flutter_plugin_tools.dart analyze --packages plugin_name
81+
dart run ./script/tool/bin/flutter_plugin_tools.dart analyze --packages package_name
8282
```
8383

8484
### Run Dart Unit Tests
8585

8686
```sh
8787
cd <repository root>
88-
dart run ./script/tool/bin/flutter_plugin_tools.dart test --packages plugin_name
88+
dart run ./script/tool/bin/flutter_plugin_tools.dart test --packages package_name
8989
```
9090

9191
### Run Dart Integration Tests
9292

9393
```sh
9494
cd <repository root>
95-
dart run ./script/tool/bin/flutter_plugin_tools.dart build-examples --apk --packages plugin_name
96-
dart run ./script/tool/bin/flutter_plugin_tools.dart drive-examples --android --packages plugin_name
95+
dart run ./script/tool/bin/flutter_plugin_tools.dart build-examples --apk --packages package_name
96+
dart run ./script/tool/bin/flutter_plugin_tools.dart drive-examples --android --packages package_name
9797
```
9898

9999
Replace `--apk`/`--android` with the platform you want to test against
@@ -110,11 +110,11 @@ Examples:
110110
```sh
111111
cd <repository root>
112112
# Run just unit tests for iOS and Android:
113-
dart run ./script/tool/bin/flutter_plugin_tools.dart native-test --ios --android --no-integration --packages plugin_name
113+
dart run ./script/tool/bin/flutter_plugin_tools.dart native-test --ios --android --no-integration --packages package_name
114114
# Run all tests for macOS:
115-
dart run ./script/tool/bin/flutter_plugin_tools.dart native-test --macos --packages plugin_name
115+
dart run ./script/tool/bin/flutter_plugin_tools.dart native-test --macos --packages package_name
116116
# Run all tests for Windows:
117-
dart run ./script/tool/bin/flutter_plugin_tools.dart native-test --windows --packages plugin_name
117+
dart run ./script/tool/bin/flutter_plugin_tools.dart native-test --windows --packages package_name
118118
```
119119

120120
### Update README.md from Example Sources
@@ -125,7 +125,7 @@ before running this command.
125125

126126
```sh
127127
cd <repository root>
128-
dart run ./script/tool/bin/flutter_plugin_tools.dart update-excerpts --packages plugin_name
128+
dart run ./script/tool/bin/flutter_plugin_tools.dart update-excerpts --packages package_name
129129
```
130130

131131
### Update CHANGELOG and Version
@@ -165,18 +165,18 @@ on the Flutter Wiki first.
165165
```sh
166166
cd <path_to_plugins>
167167
git checkout <commit_hash_to_publish>
168-
dart run ./script/tool/bin/flutter_plugin_tools.dart publish-plugin --packages <package>
168+
dart run ./script/tool/bin/flutter_plugin_tools.dart publish --packages <package>
169169
```
170170

171171
By default the tool tries to push tags to the `upstream` remote, but some
172172
additional settings can be configured. Run `dart run ./script/tool/bin/flutter_plugin_tools.dart
173-
publish-plugin --help` for more usage information.
173+
publish --help` for more usage information.
174174

175175
The tool wraps `pub publish` for pushing the package to pub, and then will
176176
automatically use git to try to create and push tags. It has some additional
177177
safety checking around `pub publish` too. By default `pub publish` publishes
178178
_everything_, including untracked or uncommitted files in version control.
179-
`publish-plugin` will first check the status of the local
179+
`publish` will first check the status of the local
180180
directory and refuse to publish if there are any mismatched files with version
181181
control present.
182182

script/tool/lib/src/common/plugin_command.dart renamed to script/tool/lib/src/common/package_command.dart

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ class PackageEnumerationEntry {
3434

3535
/// Interface definition for all commands in this tool.
3636
// TODO(stuartmorgan): Move most of this logic to PackageLoopingCommand.
37-
abstract class PluginCommand extends Command<void> {
37+
abstract class PackageCommand extends Command<void> {
3838
/// Creates a command to operate on [packagesDir] with the given environment.
39-
PluginCommand(
39+
PackageCommand(
4040
this.packagesDir, {
4141
this.processRunner = const ProcessRunner(),
4242
this.platform = const LocalPlatform(),
@@ -47,7 +47,7 @@ abstract class PluginCommand extends Command<void> {
4747
help:
4848
'Specifies which packages the command should run on (before sharding).\n',
4949
valueHelp: 'package1,package2,...',
50-
aliases: <String>[_pluginsArg],
50+
aliases: <String>[_pluginsLegacyAliasArg],
5151
);
5252
argParser.addOption(
5353
_shardIndexArg,
@@ -58,7 +58,7 @@ abstract class PluginCommand extends Command<void> {
5858
);
5959
argParser.addOption(
6060
_shardCountArg,
61-
help: 'Specifies the number of shards into which plugins are divided.',
61+
help: 'Specifies the number of shards into which packages are divided.',
6262
valueHelp: 'n',
6363
defaultsTo: '1',
6464
);
@@ -71,7 +71,7 @@ abstract class PluginCommand extends Command<void> {
7171
defaultsTo: <String>[],
7272
);
7373
argParser.addFlag(_runOnChangedPackagesArg,
74-
help: 'Run the command on changed packages/plugins.\n'
74+
help: 'Run the command on changed packages.\n'
7575
'If no packages have changed, or if there have been changes that may\n'
7676
'affect all packages, the command runs on all packages.\n'
7777
'Packages excluded with $_excludeArg are excluded even if changed.\n'
@@ -106,13 +106,13 @@ abstract class PluginCommand extends Command<void> {
106106
static const String _logTimingArg = 'log-timing';
107107
static const String _packagesArg = 'packages';
108108
static const String _packagesForBranchArg = 'packages-for-branch';
109-
static const String _pluginsArg = 'plugins';
109+
static const String _pluginsLegacyAliasArg = 'plugins';
110110
static const String _runOnChangedPackagesArg = 'run-on-changed-packages';
111111
static const String _runOnDirtyPackagesArg = 'run-on-dirty-packages';
112112
static const String _shardCountArg = 'shardCount';
113113
static const String _shardIndexArg = 'shardIndex';
114114

115-
/// The directory containing the plugin packages.
115+
/// The directory containing the packages.
116116
final Directory packagesDir;
117117

118118
/// The process runner.
@@ -221,7 +221,7 @@ abstract class PluginCommand extends Command<void> {
221221
_shardCount = shardCount;
222222
}
223223

224-
/// Returns the set of plugins to exclude based on the `--exclude` argument.
224+
/// Returns the set of packages to exclude based on the `--exclude` argument.
225225
Set<String> getExcludedPackageNames() {
226226
final Set<String> excludedPackages = _excludedPackages ??
227227
getStringListArg(_excludeArg).expand<String>((String item) {
@@ -250,22 +250,22 @@ abstract class PluginCommand extends Command<void> {
250250
Stream<PackageEnumerationEntry> getTargetPackages(
251251
{bool filterExcluded = true}) async* {
252252
// To avoid assuming consistency of `Directory.list` across command
253-
// invocations, we collect and sort the plugin folders before sharding.
253+
// invocations, we collect and sort the package folders before sharding.
254254
// This is considered an implementation detail which is why the API still
255255
// uses streams.
256-
final List<PackageEnumerationEntry> allPlugins =
256+
final List<PackageEnumerationEntry> allPackages =
257257
await _getAllPackages().toList();
258-
allPlugins.sort((PackageEnumerationEntry p1, PackageEnumerationEntry p2) =>
258+
allPackages.sort((PackageEnumerationEntry p1, PackageEnumerationEntry p2) =>
259259
p1.package.path.compareTo(p2.package.path));
260-
final int shardSize = allPlugins.length ~/ shardCount +
261-
(allPlugins.length % shardCount == 0 ? 0 : 1);
262-
final int start = min(shardIndex * shardSize, allPlugins.length);
263-
final int end = min(start + shardSize, allPlugins.length);
264-
265-
for (final PackageEnumerationEntry plugin
266-
in allPlugins.sublist(start, end)) {
267-
if (!(filterExcluded && plugin.excluded)) {
268-
yield plugin;
260+
final int shardSize = allPackages.length ~/ shardCount +
261+
(allPackages.length % shardCount == 0 ? 0 : 1);
262+
final int start = min(shardIndex * shardSize, allPackages.length);
263+
final int end = min(start + shardSize, allPackages.length);
264+
265+
for (final PackageEnumerationEntry package
266+
in allPackages.sublist(start, end)) {
267+
if (!(filterExcluded && package.excluded)) {
268+
yield package;
269269
}
270270
}
271271
}
@@ -330,7 +330,7 @@ abstract class PluginCommand extends Command<void> {
330330
runOnChangedPackages = false;
331331
}
332332

333-
final Set<String> excludedPluginNames = getExcludedPackageNames();
333+
final Set<String> excludedPackageNames = getExcludedPackageNames();
334334

335335
if (runOnChangedPackages) {
336336
final GitVersionFinder gitVersionFinder = await retrieveVersionFinder();
@@ -368,15 +368,16 @@ abstract class PluginCommand extends Command<void> {
368368
]) {
369369
await for (final FileSystemEntity entity
370370
in dir.list(followLinks: false)) {
371-
// A top-level Dart package is a plugin package.
371+
// A top-level Dart package is a standard package.
372372
if (isPackage(entity)) {
373373
if (packages.isEmpty || packages.contains(p.basename(entity.path))) {
374374
yield PackageEnumerationEntry(
375375
RepositoryPackage(entity as Directory),
376-
excluded: excludedPluginNames.contains(entity.basename));
376+
excluded: excludedPackageNames.contains(entity.basename));
377377
}
378378
} else if (entity is Directory) {
379-
// Look for Dart packages under this top-level directory.
379+
// Look for Dart packages under this top-level directory; this is the
380+
// standard structure for federated plugins.
380381
await for (final FileSystemEntity subdir
381382
in entity.list(followLinks: false)) {
382383
if (isPackage(subdir)) {
@@ -394,7 +395,7 @@ abstract class PluginCommand extends Command<void> {
394395
packages.intersection(possibleMatches).isNotEmpty) {
395396
yield PackageEnumerationEntry(
396397
RepositoryPackage(subdir as Directory),
397-
excluded: excludedPluginNames
398+
excluded: excludedPackageNames
398399
.intersection(possibleMatches)
399400
.isNotEmpty);
400401
}
@@ -415,11 +416,12 @@ abstract class PluginCommand extends Command<void> {
415416
/// stream.
416417
Stream<PackageEnumerationEntry> getTargetPackagesAndSubpackages(
417418
{bool filterExcluded = true}) async* {
418-
await for (final PackageEnumerationEntry plugin
419+
await for (final PackageEnumerationEntry package
419420
in getTargetPackages(filterExcluded: filterExcluded)) {
420-
yield plugin;
421-
yield* getSubpackages(plugin.package).map((RepositoryPackage package) =>
422-
PackageEnumerationEntry(package, excluded: plugin.excluded));
421+
yield package;
422+
yield* getSubpackages(package.package).map(
423+
(RepositoryPackage subPackage) =>
424+
PackageEnumerationEntry(subPackage, excluded: package.excluded));
423425
}
424426
}
425427

@@ -524,7 +526,7 @@ abstract class PluginCommand extends Command<void> {
524526
}
525527

526528
// Returns true if one or more files changed that have the potential to affect
527-
// any plugin (e.g., CI script changes).
529+
// any packages (e.g., CI script changes).
528530
bool _changesRequireFullTest(List<String> changedFiles) {
529531
const List<String> specialFiles = <String>[
530532
'.ci.yaml', // LUCI config.

script/tool/lib/src/common/package_looping_command.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import 'package:platform/platform.dart';
1212
import 'package:pub_semver/pub_semver.dart';
1313

1414
import 'core.dart';
15-
import 'plugin_command.dart';
15+
import 'package_command.dart';
1616
import 'process_runner.dart';
1717
import 'repository_package.dart';
1818

@@ -82,7 +82,7 @@ class PackageResult {
8282
/// An abstract base class for a command that iterates over a set of packages
8383
/// controlled by a standard set of flags, running some actions on each package,
8484
/// and collecting and reporting the success/failure of those actions.
85-
abstract class PackageLoopingCommand extends PluginCommand {
85+
abstract class PackageLoopingCommand extends PackageCommand {
8686
/// Creates a command to operate on [packagesDir] with the given environment.
8787
PackageLoopingCommand(
8888
Directory packagesDir, {

script/tool/lib/src/common/package_state_utils.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ bool _isUnpublishedExampleChange(
161161
return exampleComponents.first.toLowerCase() != 'readme.md';
162162
}
163163

164-
// True if the change is only relevant to people working on the plugin.
164+
// True if the change is only relevant to people working on the package.
165165
Future<bool> _isDevChange(List<String> pathComponents,
166166
{GitVersionFinder? git, String? repoPath}) async {
167167
return _isTestChange(pathComponents) ||

script/tool/lib/src/create_all_plugins_app_command.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ import 'package:pub_semver/pub_semver.dart';
1010
import 'package:pubspec_parse/pubspec_parse.dart';
1111

1212
import 'common/core.dart';
13-
import 'common/plugin_command.dart';
13+
import 'common/package_command.dart';
1414
import 'common/repository_package.dart';
1515

1616
const String _outputDirectoryFlag = 'output-dir';
1717

1818
/// A command to create an application that builds all in a single application.
19-
class CreateAllPluginsAppCommand extends PluginCommand {
19+
class CreateAllPluginsAppCommand extends PackageCommand {
2020
/// Creates an instance of the builder command.
2121
CreateAllPluginsAppCommand(
2222
Directory packagesDir, {

script/tool/lib/src/drive_examples_command.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class DriveExamplesCommand extends PackageLoopingCommand {
4949
final String name = 'drive-examples';
5050

5151
@override
52-
final String description = 'Runs driver tests for plugin example apps.\n\n'
52+
final String description = 'Runs driver tests for package example apps.\n\n'
5353
'For each *_test.dart in test_driver/ it drives an application with '
5454
'either the corresponding test in test_driver (for example, '
5555
'test_driver/app_test.dart would match test_driver/app.dart), or the '

script/tool/lib/src/format_command.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import 'package:meta/meta.dart';
1111
import 'package:platform/platform.dart';
1212

1313
import 'common/core.dart';
14-
import 'common/plugin_command.dart';
14+
import 'common/package_command.dart';
1515
import 'common/process_runner.dart';
1616

1717
/// In theory this should be 8191, but in practice that was still resulting in
@@ -37,7 +37,7 @@ final Uri _googleFormatterUrl = Uri.https('github.com',
3737
'/google/google-java-format/releases/download/google-java-format-1.3/google-java-format-1.3-all-deps.jar');
3838

3939
/// A command to format all package code.
40-
class FormatCommand extends PluginCommand {
40+
class FormatCommand extends PackageCommand {
4141
/// Creates an instance of the format command.
4242
FormatCommand(
4343
Directory packagesDir, {

script/tool/lib/src/license_check_command.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import 'package:path/path.dart' as p;
88
import 'package:platform/platform.dart';
99

1010
import 'common/core.dart';
11-
import 'common/plugin_command.dart';
11+
import 'common/package_command.dart';
1212

1313
const Set<String> _codeFileExtensions = <String>{
1414
'.c',
@@ -105,7 +105,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
105105
''';
106106

107107
/// Validates that code files have copyright and license blocks.
108-
class LicenseCheckCommand extends PluginCommand {
108+
class LicenseCheckCommand extends PackageCommand {
109109
/// Creates a new license check command for [packagesDir].
110110
LicenseCheckCommand(Directory packagesDir,
111111
{Platform platform = const LocalPlatform(), GitDir? gitDir})

0 commit comments

Comments
 (0)