Allow explicit exclusion of packages from pinned packages in flutter update-packages --force-update (#147679)

## Description

This introduces a list of packages that we will explicitly not pin.  It is to be used for things where the package isn't actually published, but is a transitive dependency of another package included in the SDK.  This happens with the `macros` package, for instance, which depends on the private, unpublished, `_macros` package where the SDK does some tricky things to depend on it (it depends on "any", but ships it as part of the SDK).

Also ran `flutter update-packages --force-update` to update all of the pubspec files.

## Related Issues
 - Fixes #147656

## Tests
 - Added a test that makes sure that explicitly unpinned packages don't show up in the pinned list.
This commit is contained in:
Greg Spencer
2024-05-01 18:16:54 -07:00
committed by GitHub
parent ab8ecd5e74
commit 2e78ed0ff9
41 changed files with 191 additions and 115 deletions

View File

@@ -24,6 +24,7 @@ dependencies:
# To update these, use "flutter update-packages --force-upgrade".
collection: 1.14.11
meta: 1.1.8
macros: 0.0.1
typed_data: 1.1.6
vector_math: 2.0.8
@@ -197,6 +198,7 @@ void main() {
equals(<String>{
'collection: 1.14.11',
'meta: 1.1.8',
'macros: 0.0.1',
'typed_data: 1.1.6',
'vector_math: 2.0.8',
'sky_engine: ',
@@ -212,6 +214,7 @@ void main() {
equals(<String>{
'collection: 1.14.11',
'meta: 1.1.8',
'macros: 0.0.1',
'typed_data: 1.1.6',
'vector_math: 2.0.8',
'sky_engine: ',
@@ -226,10 +229,32 @@ void main() {
equals(<String>{
'collection: 1.14.11',
'meta: 1.1.8',
'macros: 0.0.1',
'typed_data: 1.1.6',
'vector_math: 2.0.8',
'sky_engine: ',
'gallery: ',
}));
});
testWithoutContext('PubspecYaml apply skips explicitly excluded packages', () async {
final PubspecYaml flutterPubspec = PubspecYaml(flutter);
final PubDependencyTree flutterTree = PubDependencyTree();
final List<String> depsLines = <String>[
// Have to add these first so that flutterTree.fill ignores the one in
// the pubspec.
'- macros 0.0.1 [_macros]',
'- _macros 0.0.1',
for (final PubspecDependency dependency in flutterPubspec.allDependencies)
'- ${dependency.name} ${dependency.version}',
];
final Set<String> dependencies = flutterPubspec.allDependencies.map<String>(
(PubspecDependency dep) => dep.name).toSet();
depsLines.add('- flutter 1.0.0 [${dependencies.join(' ')}}]');
depsLines.forEach(flutterTree.fill);
flutterPubspec.apply(flutterTree, <String>{});
final String contents = flutter.childFile('pubspec.yaml').readAsStringSync();
expect(contents, isNot(contains('_macros: 0.0.1')));
});
}