Skip to content

Commit 5a1eac9

Browse files
Merge branch 'main' into webview_flutter_android_set-Web-Authentication-Support
2 parents e13e9cc + 69cf959 commit 5a1eac9

18 files changed

Lines changed: 519 additions & 243 deletions

.repo_tool_config.yaml

Lines changed: 124 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,124 @@
1+
# Repo-specific configuration for the flutter_plugin_tools repository tooling.
2+
3+
repo_name: flutter/packages
4+
5+
# The minimum Flutter version that can be used as the minimum SDK constraint
6+
# by packages in this repository. For example, if this is set to 3.22.0, then a
7+
# package can have a minimum SDK version of 3.32.0, 3.35.0, 3.38.0, etc., but
8+
# not 3.29.0.
9+
#
10+
# The major and minor version here should match the lowest version analyzed
11+
# in legacy version analysis (.ci.yaml analyze_legacy).
12+
min_flutter: '3.38.0'
13+
14+
# The list of external packages that are allowed as dependencies.
15+
# All entries here must have an explanation for why they are here. See
16+
# https://github.com/flutter/flutter/blob/master/docs/ecosystem/contributing/README.md#Dependencies
17+
allowed_dependencies:
18+
# Dependencies that are only allowed if pinned. This should be used for the
19+
# rare case of a dependency on a package that we have no influence over.
20+
# A pin can be either an exact version, or a range with an explicit, inclusive
21+
# max version, which must a version that already exists, not a future version.
22+
pinned:
23+
# Test-only dependency, so does not impact package clients, and
24+
# has limited impact so could be easily removed if there are
25+
# ever maintenance issues in the future.
26+
- lcov_parser
27+
28+
# This should be removed; see
29+
# https://github.com/flutter/flutter/issues/130897
30+
- provider
31+
32+
# Used by vector_graphics_compiler, as a production, user-facing dependency.
33+
# This is allowed only with pinned dependencies, so that any changes can be
34+
# audited before passing them on to clients as transitive updates, to mitigate
35+
# the risk of the package being compromised.
36+
- xml
37+
38+
# Dependencies that can be unpinned. Package should only ever be added here if
39+
# we fully trust the package's development and publishing process.
40+
unpinned:
41+
## Explicit allowances
42+
43+
# Owned by individual Flutter Team members.
44+
# Ideally we would not do this at all, since there's no clear plan for what
45+
# would happen if the individuals left the Flutter Team, and the
46+
# repositories may or may not meet Flutter's security standards. Be
47+
# extremely cautious about adding to this list.
48+
- build_verify
49+
- google_maps
50+
51+
## Allowed by default:
52+
53+
# Dart-team-owned packages
54+
- analyzer
55+
- args
56+
- async
57+
- build
58+
- build_config
59+
- build_runner
60+
- build_test
61+
- code_builder
62+
- collection
63+
- convert
64+
- crypto
65+
- dart_style
66+
- devtools_app_shared
67+
- devtools_extensions
68+
- fake_async
69+
- ffi
70+
- ffigen
71+
- file
72+
- file_testing
73+
- gcloud
74+
- graphs
75+
- html
76+
- http
77+
- intl
78+
- io
79+
- js
80+
- jni
81+
- jni_flutter
82+
- jnigen
83+
- json_serializable
84+
- leak_tracker
85+
- leak_tracker_flutter_testing
86+
- lints
87+
- logging
88+
- markdown
89+
- meta
90+
- mime
91+
- mockito
92+
- objective_c
93+
- path
94+
- package_config
95+
- platform
96+
- process
97+
- pub_semver
98+
- shelf
99+
- shelf_static
100+
- source_gen
101+
- stream_transform
102+
- test
103+
- test_api
104+
- vm_service
105+
- wasm
106+
- web
107+
- yaml
108+
109+
# Google-owned packages
110+
- _discoveryapis_commons
111+
- adaptive_navigation
112+
- googleapis
113+
- googleapis_auth
114+
- json_annotation
115+
- protobuf
116+
- quiver
117+
- sanitize_html
118+
- source_helper
119+
- vector_math
120+
- webkit_inspection_protocol
121+
122+
package_labels:
123+
google_maps_flutter: maps
124+
webview_flutter: webview

script/tool/README.md

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,3 +228,25 @@ _everything_, including untracked or uncommitted files in version control.
228228
`publish` will first check the status of the local
229229
directory and refuse to publish if there are any mismatched files with version
230230
control present.
231+
232+
## Configuration
233+
234+
The `.repo_tool_config.yaml` file at the root of the repository contains
235+
configuration for this tool, to support using the same script in multiple
236+
repositories.
237+
238+
The following sections are supported:
239+
240+
- `repo_name` (**required**): The name of the repository
241+
(e.g., `flutter/packages`).
242+
- `min_flutter` or `min_dart`: The minimum SDK version
243+
that packages in the repository are allowed to support.
244+
- `allowed_dependencies`, containing one or both of:
245+
- `pinned`: A list of package names that are allowed as `pubspec.yaml`
246+
dependencies as long as they are pinned to an exact version.
247+
- `unpinned`: A list of package names that are allowed as `pubspec.yaml`
248+
dependencies without a specific version constraint (or with a broad
249+
constraint).
250+
- `package_labels`: A map from a package name to the label to use for that
251+
package's issue link query. This is only needed for packages that use a
252+
label other than `p: <package_name>`.

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

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,10 @@ const String kDoNotLandWarning = 'DO NOT MERGE';
4141
/// Key for enabling web WASM compilation
4242
const String kWebWasmFlag = 'wasm';
4343

44+
/// The URL to provide in printed messages to point users to tool documentation.
45+
const String toolDocsUrl =
46+
'https://github.com/flutter/packages/blob/main/script/tool/README.md';
47+
4448
/// Target platforms supported by Flutter.
4549
// ignore: public_member_api_docs
4650
enum FlutterPlatform { android, ios, linux, macos, web, windows }
@@ -126,7 +130,7 @@ bool isPackage(FileSystemEntity entity) {
126130
/// While there is no specific definition of the meaning of different non-zero
127131
/// exit codes for this tool, commands should follow the general convention:
128132
/// 1: The command ran correctly, but found errors.
129-
/// 2: The command failed to run because the arguments were invalid.
133+
/// 2: The command failed to run because the arguments or config were invalid.
130134
/// >2: The command failed to run correctly for some other reason. Ideally,
131135
/// each such failure should have a unique exit code within the context of
132136
/// that command.
@@ -136,12 +140,16 @@ class ToolExit extends Error {
136140

137141
/// The code that the process should exit with.
138142
final int exitCode;
143+
144+
@override
145+
String toString() => 'ToolExit(exitCode: $exitCode)';
139146
}
140147

141148
/// A exit code for [ToolExit] for a successful run that found errors.
142149
const int exitCommandFoundErrors = 1;
143150

144-
/// A exit code for [ToolExit] for a failure to run due to invalid arguments.
151+
/// A exit code for [ToolExit] for a failure to run due to invalid arguments
152+
/// or config.
145153
const int exitInvalidArguments = 2;
146154

147155
/// The directory for any cached files downloaded or created by the tool.
@@ -162,7 +170,3 @@ Directory? ciLogsDirectory(Platform platform, FileSystem fileSystem) {
162170
}
163171
return logsDirectory;
164172
}
165-
166-
/// The directory that contains repo-specific configuration for this tooling.
167-
Directory toolConfigDirectory(Directory repoRoot) =>
168-
repoRoot.childDirectory('tool_config');

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -393,8 +393,8 @@ abstract class PackageCommand extends Command<void> {
393393
/// platform interface package which declares the API for implementations,
394394
/// and one or more platform-specific implementation packages.
395395
/// 3./4. Either of the above, but in a third_party/packages/ directory that
396-
/// is a sibling of the packages directory. This is used for a small number
397-
/// of packages in the flutter/packages repository.
396+
/// is a sibling of the packages directory. This is used for packages that
397+
/// originate outside of the Flutter team.
398398
Stream<PackageEnumerationEntry> _getAllPackages() async* {
399399
final packageSelectionFlags = <String>{
400400
_packagesArg,
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
// Copyright 2013 The Flutter Authors
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
import 'package:file/file.dart';
6+
import 'package:meta/meta.dart';
7+
import 'package:yaml/yaml.dart';
8+
import 'core.dart';
9+
import 'output_utils.dart';
10+
11+
/// The name of the tool configuration file, at the root of the repository.
12+
const String configFilename = '.repo_tool_config.yaml';
13+
14+
YamlMap? _toolConfig;
15+
16+
/// Clears the cached tool configuration.
17+
///
18+
/// Visible for testing only.
19+
@visibleForTesting
20+
void clearToolConfigCache() {
21+
_toolConfig = null;
22+
}
23+
24+
YamlMap _getToolConfig(Directory repoRoot) {
25+
if (_toolConfig == null) {
26+
final File configFile = repoRoot.childFile(configFilename);
27+
if (!configFile.existsSync()) {
28+
printError(
29+
'Configuration file $configFilename not found at repository root.',
30+
);
31+
throw ToolExit(exitInvalidArguments);
32+
}
33+
final Object yaml = loadYamlNode(configFile.readAsStringSync());
34+
if (yaml is! YamlMap) {
35+
printError('Configuration file $configFilename is must be a map.');
36+
throw ToolExit(exitInvalidArguments);
37+
}
38+
_toolConfig = yaml;
39+
}
40+
return _toolConfig!;
41+
}
42+
43+
/// Returns the name of the repository.
44+
String getRepositoryName(Directory repoRoot) {
45+
final name = _getToolConfig(repoRoot)['repo_name'] as String?;
46+
if (name == null) {
47+
printError('repo_name is missing in $configFilename');
48+
throw ToolExit(exitInvalidArguments);
49+
}
50+
return name;
51+
}
52+
53+
/// Returns the minimum Flutter version allowed.
54+
String? getMinFlutterVersion(Directory repoRoot) {
55+
final Object? yaml = _getToolConfig(repoRoot)['min_flutter'];
56+
if (yaml == null) {
57+
return null;
58+
}
59+
if (yaml is! String) {
60+
printError('min_flutter must be a full version string (e.g., "3.44.0").');
61+
throw ToolExit(exitInvalidArguments);
62+
}
63+
return yaml;
64+
}
65+
66+
/// Returns the allowed dependencies, grouped by 'pinned' and 'unpinned'.
67+
({List<String> pinned, List<String> unpinned}) getAllowedDependencies(
68+
Directory repoRoot,
69+
) {
70+
final allowedDeps =
71+
_getToolConfig(repoRoot)['allowed_dependencies'] as YamlMap?;
72+
if (allowedDeps == null) {
73+
return (pinned: <String>[], unpinned: <String>[]);
74+
}
75+
76+
final List<String> pinned =
77+
(allowedDeps['pinned'] as YamlList?)?.map((e) => e as String).toList() ??
78+
<String>[];
79+
final List<String> unpinned =
80+
(allowedDeps['unpinned'] as YamlList?)
81+
?.map((e) => e as String)
82+
.toList() ??
83+
<String>[];
84+
85+
return (pinned: pinned, unpinned: unpinned);
86+
}
87+
88+
/// Returns a map from package names to non-standard issue labels used for those
89+
/// packages. Packages that use the default label `p: <package_name>` are not
90+
/// included in the returned map.
91+
Map<String, String> getNonStandardPackageLabels(Directory repoRoot) {
92+
final customLabels = _getToolConfig(repoRoot)['package_labels'] as YamlMap?;
93+
if (customLabels == null) {
94+
return <String, String>{};
95+
}
96+
97+
return customLabels.map(
98+
(key, value) => MapEntry(key as String, value as String),
99+
);
100+
}

script/tool/lib/src/format_command.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ class FormatCommand extends PackageLoopingCommand {
204204

205205
print(
206206
'\nTo fix run the repository tooling `format` command: '
207-
'https://github.com/flutter/packages/blob/main/script/tool/README.md#format-code\n'
207+
'$toolDocsUrl#format-code\n'
208208
'or copy-paste this command into your terminal:',
209209
);
210210

0 commit comments

Comments
 (0)