Skip to content

Commit a26b623

Browse files
[tool] Adopt platform 3.2.0 (#12789)
`platform` 3.2.0 added new APIs, and broke the ability to mock the old APIs. This updates all code to expect `NativePlatform` instead of `Platform`, and replaces `MockPlatform` with the upstream `TestNativePlatform`. Fixes flutter/flutter#192420
1 parent c0b28f6 commit a26b623

42 files changed

Lines changed: 1228 additions & 1097 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎script/tool/CHANGELOG.md‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1-
## NEXT
1+
## 0.14.4+1
22

33
* Adds support for batch release of pre-1.0 packages.
44
* Exempts `AGENTS.md` from requiring version and changelog changes.
5+
* Updates to support `platform` 3.2.0, to account for upstream breaking changes
6+
to mocking.
57

68
## 0.14.4
79

‎script/tool/lib/src/common/cmake.dart‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class CMakeProject {
1919
this.flutterProject, {
2020
required this.buildMode,
2121
this.processRunner = const ProcessRunner(),
22-
this.platform = const LocalPlatform(),
22+
required this.platform,
2323
required this.arch,
2424
});
2525

@@ -30,7 +30,7 @@ class CMakeProject {
3030
final ProcessRunner processRunner;
3131

3232
/// The platform that commands are being run on.
33-
final Platform platform;
33+
final NativePlatform platform;
3434

3535
/// The architecture subdirectory of the build.
3636
final String arch;

‎script/tool/lib/src/common/core.dart‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ Directory toolCacheDirectory(Directory repoRoot) {
160160
}
161161

162162
/// The directory to which to write logs and other artifacts, if set in CI.
163-
Directory? ciLogsDirectory(Platform platform, FileSystem fileSystem) {
163+
Directory? ciLogsDirectory(NativePlatform platform, FileSystem fileSystem) {
164164
final String? logsDirectoryPath = platform.environment['FLUTTER_LOGS_DIR'];
165165
Directory? logsDirectory;
166166
if (logsDirectoryPath != null) {

‎script/tool/lib/src/common/flutter_command_utils.dart‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import 'repository_package.dart';
1616
Future<bool> runConfigOnlyBuild(
1717
RepositoryPackage package,
1818
ProcessRunner processRunner,
19-
Platform platform,
19+
NativePlatform platform,
2020
FlutterPlatform targetPlatform, {
2121
bool buildDebug = false,
2222
List<String> extraArgs = const <String>[],

‎script/tool/lib/src/common/gradle.dart‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ class GradleProject {
1717
/// [processRunner].
1818
GradleProject(
1919
this.flutterProject, {
20+
required this.platform,
2021
this.processRunner = const ProcessRunner(),
21-
this.platform = const LocalPlatform(),
2222
});
2323

2424
/// The directory of a Flutter project to run Gradle commands in.
@@ -28,7 +28,7 @@ class GradleProject {
2828
final ProcessRunner processRunner;
2929

3030
/// The platform that commands are being run on.
31-
final Platform platform;
31+
final NativePlatform platform;
3232

3333
/// The project's 'android' directory.
3434
Directory get androidDirectory => flutterProject.platformDirectory(FlutterPlatform.android);

‎script/tool/lib/src/common/package_command.dart‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,10 @@ abstract class PackageCommand extends Command<void> {
4040
PackageCommand(
4141
this.packagesDir, {
4242
this.processRunner = const ProcessRunner(),
43-
this.platform = const LocalPlatform(),
43+
NativePlatform? platform,
4444
GitDir? gitDir,
4545
}) : _gitDir = gitDir {
46+
this.platform = platform ?? NativePlatform.current!;
4647
thirdPartyPackagesDir = rootDir.childDirectory('third_party').childDirectory('packages');
4748

4849
argParser.addMultiOption(
@@ -206,7 +207,7 @@ abstract class PackageCommand extends Command<void> {
206207
/// The current platform.
207208
///
208209
/// This can be overridden for testing.
209-
final Platform platform;
210+
late final NativePlatform platform;
210211

211212
/// The git directory to use. If unset, [gitDir] populates it from the
212213
/// packages directory's enclosing repository.

‎script/tool/lib/src/common/pub_utils.dart‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ import 'repository_package.dart';
1717
Future<bool> runPubGet(
1818
RepositoryPackage package,
1919
ProcessRunner processRunner,
20-
Platform platform, {
20+
NativePlatform platform, {
2121
bool streamOutput = true,
2222
}) async {
2323
return runPubCommand(
@@ -39,7 +39,7 @@ Future<bool> runPubCommand(
3939
List<String> commandArgs,
4040
RepositoryPackage package,
4141
ProcessRunner processRunner,
42-
Platform platform, {
42+
NativePlatform platform, {
4343
bool streamOutput = true,
4444
String? dartSdkPathOverride,
4545
bool recursiveFlutterCheck = false,
@@ -77,7 +77,7 @@ Future<io.Process> startPubCommand(
7777
List<String> commandArgs,
7878
RepositoryPackage package,
7979
ProcessRunner processRunner,
80-
Platform platform,
80+
NativePlatform platform,
8181
) async {
8282
return processRunner.start(_pubCommand(package, platform), <String>[
8383
'pub',
@@ -87,7 +87,7 @@ Future<io.Process> startPubCommand(
8787

8888
String _pubCommand(
8989
RepositoryPackage package,
90-
Platform platform, {
90+
NativePlatform platform, {
9191
String? dartSdkPathOverride,
9292
bool recursiveFlutterCheck = false,
9393
}) {

‎script/tool/lib/src/common/xcode.dart‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ class Xcode {
3838
required String scheme,
3939
String? configuration,
4040
List<String> extraFlags = const <String>[],
41-
required Platform hostPlatform,
41+
required NativePlatform hostPlatform,
4242
}) async {
4343
final FileSystem fileSystem = exampleDirectory.fileSystem;
4444
String? resultBundlePath;

‎script/tool/lib/src/publish_command.dart‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ If running this command on CI, you can set the pub credential content in the $_p
531531
}
532532

533533
/// The path in which pub expects to find its credentials file.
534-
String _getCredentialsPath({required Platform platform, required p.Context path}) {
534+
String _getCredentialsPath({required NativePlatform platform, required p.Context path}) {
535535
// See https://github.com/dart-lang/pub/blob/master/doc/cache_layout.md#layout
536536
String? configDir;
537537
if (platform.isLinux) {

‎script/tool/pubspec.yaml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: flutter_plugin_tools
22
description: Productivity and CI utils for Flutter team package repositories.
33
repository: https://github.com/flutter/packages/tree/main/script/tool
4-
version: 0.14.4
4+
version: 0.14.4+1
55

66
dependencies:
77
args: ^2.1.0
@@ -15,7 +15,7 @@ dependencies:
1515
http_multi_server: ^3.0.1
1616
meta: ^1.10.0
1717
path: ^1.8.3
18-
platform: ^3.0.2
18+
platform: ^3.2.0
1919
pub_semver: ^2.0.0
2020
pubspec_parse: ^1.4.0
2121
quiver: ^3.0.1

0 commit comments

Comments
 (0)