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

Commit 5afbfe9

Browse files
[flutter_plugin_tool] Migrate 'publish' to new base command (#4290)
Moves `publish` to PackageLoopingCommand, giving it the same standardized output and summary that is used by most other commands in the tool. Adds minor new functionality to the base command to allow it to handle the specific needs of publish: - Allows fully customizing the set of packages to loop over, to support --all-changed - Allows customization of a few more strings so the output better matches the functionality (e.g., using 'published' instead of 'ran' in the summary lines). Fixes flutter/flutter#83413
1 parent ffe53ec commit 5afbfe9

File tree

3 files changed

+163
-238
lines changed

3 files changed

+163
-238
lines changed

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

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,18 @@ abstract class PackageLoopingCommand extends PluginCommand {
9292
/// arguments are invalid), and to set up any run-level state.
9393
Future<void> initializeRun() async {}
9494

95+
/// Returns the packages to process. By default, this returns the packages
96+
/// defined by the standard tooling flags and the [inculdeSubpackages] option,
97+
/// but can be overridden for custom package enumeration.
98+
///
99+
/// Note: Consistent behavior across commands whenever possibel is a goal for
100+
/// this tool, so this should be overridden only in rare cases.
101+
Stream<PackageEnumerationEntry> getPackagesToProcess() async* {
102+
yield* includeSubpackages
103+
? getTargetPackagesAndSubpackages(filterExcluded: false)
104+
: getTargetPackages(filterExcluded: false);
105+
}
106+
95107
/// Runs the command for [package], returning a list of errors.
96108
///
97109
/// Errors may either be an empty string if there is no context that should
@@ -138,6 +150,9 @@ abstract class PackageLoopingCommand extends PluginCommand {
138150
/// context.
139151
String get failureListFooter => 'See above for full details.';
140152

153+
/// The summary string used for a successful run in the final overview output.
154+
String get successSummaryMessage => 'ran';
155+
141156
/// If true, all printing (including the summary) will be redirected to a
142157
/// buffer, and provided in a call to [handleCapturedOutput] at the end of
143158
/// the run.
@@ -206,9 +221,8 @@ abstract class PackageLoopingCommand extends PluginCommand {
206221

207222
await initializeRun();
208223

209-
final List<PackageEnumerationEntry> targetPackages = includeSubpackages
210-
? await getTargetPackagesAndSubpackages(filterExcluded: false).toList()
211-
: await getTargetPackages(filterExcluded: false).toList();
224+
final List<PackageEnumerationEntry> targetPackages =
225+
await getPackagesToProcess().toList();
212226

213227
final Map<PackageEnumerationEntry, PackageResult> results =
214228
<PackageEnumerationEntry, PackageResult>{};
@@ -346,7 +360,7 @@ abstract class PackageLoopingCommand extends PluginCommand {
346360
summary = 'skipped';
347361
style = hadWarning ? Styles.LIGHT_YELLOW : Styles.DARK_GRAY;
348362
} else {
349-
summary = 'ran';
363+
summary = successSummaryMessage;
350364
style = hadWarning ? Styles.YELLOW : Styles.GREEN;
351365
}
352366
if (hadWarning) {

0 commit comments

Comments
 (0)