Skip to content

Commit db141ec

Browse files
Copy the flutter version JSON file into the simulated Flutter SDK used by update_packages (#143035)
Dart pub now expects that file to be present in a Flutter SDK (see https://dart.googlesource.com/pub/+/dce232ec195df802a730eb3a66163e28d2ec6444)
1 parent bf9aa55 commit db141ec

File tree

3 files changed

+41
-0
lines changed

3 files changed

+41
-0
lines changed

packages/flutter_tools/lib/src/commands/update_packages.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import '../globals.dart' as globals;
1919
import '../project.dart';
2020
import '../runner/flutter_command.dart';
2121
import '../update_packages_pins.dart';
22+
import '../version.dart';
2223

2324
class UpdatePackagesCommand extends FlutterCommand {
2425
UpdatePackagesCommand() {
@@ -1713,6 +1714,10 @@ Directory createTemporaryFlutterSdk(
17131714
// Fill in version info.
17141715
realFlutter.childFile('version')
17151716
.copySync(directory.childFile('version').path);
1717+
final File versionJson = FlutterVersion.getVersionFile(realFlutter.fileSystem, realFlutter.path);
1718+
final Directory binCacheDirectory = directory.childDirectory('bin').childDirectory('cache');
1719+
binCacheDirectory.createSync(recursive: true);
1720+
versionJson.copySync(binCacheDirectory.childFile('flutter.version.json').path);
17161721

17171722
// Directory structure should mirror the current Flutter SDK
17181723
final Directory packages = directory.childDirectory('packages');

packages/flutter_tools/test/commands.shard/hermetic/update_packages_test.dart

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,20 @@ dependencies:
7373
# PUBSPEC CHECKSUM: 6543
7474
''';
7575

76+
const String kVersionJson = '''
77+
{
78+
"frameworkVersion": "1.2.3",
79+
"channel": "[user-branch]",
80+
"repositoryUrl": "git@github.com:flutter/flutter.git",
81+
"frameworkRevision": "1234567812345678123456781234567812345678",
82+
"frameworkCommitDate": "2024-02-06 22:26:52 +0100",
83+
"engineRevision": "abcdef01abcdef01abcdef01abcdef01abcdef01",
84+
"dartSdkVersion": "1.2.3",
85+
"devToolsVersion": "1.2.3",
86+
"flutterVersion": "1.2.3"
87+
}
88+
''';
89+
7690
void main() {
7791
group('update-packages', () {
7892
late FileSystem fileSystem;
@@ -91,6 +105,9 @@ void main() {
91105
fileSystem = MemoryFileSystem.test();
92106
flutterSdk = fileSystem.directory('flutter')..createSync();
93107
flutterSdk.childFile('version').writeAsStringSync('1.2.3');
108+
flutterSdk.childDirectory('bin').childDirectory('cache').childFile('flutter.version.json')
109+
..createSync(recursive: true)
110+
..writeAsStringSync(kVersionJson);
94111
flutter = flutterSdk.childDirectory('packages').childDirectory('flutter')
95112
..createSync(recursive: true);
96113
flutterSdk.childDirectory('dev').createSync(recursive: true);

packages/flutter_tools/test/general.shard/update_packages_test.dart

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,20 @@ dependencies:
7777
git:
7878
''';
7979

80+
const String kVersionJson = '''
81+
{
82+
"frameworkVersion": "1.2.3",
83+
"channel": "[user-branch]",
84+
"repositoryUrl": "git@github.com:flutter/flutter.git",
85+
"frameworkRevision": "1234567812345678123456781234567812345678",
86+
"frameworkCommitDate": "2024-02-06 22:26:52 +0100",
87+
"engineRevision": "abcdef01abcdef01abcdef01abcdef01abcdef01",
88+
"dartSdkVersion": "1.2.3",
89+
"devToolsVersion": "1.2.3",
90+
"flutterVersion": "1.2.3"
91+
}
92+
''';
93+
8094
void main() {
8195
late FileSystem fileSystem;
8296
late Directory flutterSdk;
@@ -88,6 +102,10 @@ void main() {
88102
flutterSdk = fileSystem.directory('flutter')..createSync();
89103
// Create version file
90104
flutterSdk.childFile('version').writeAsStringSync('1.2.3');
105+
// Create version JSON file
106+
flutterSdk.childDirectory('bin').childDirectory('cache').childFile('flutter.version.json')
107+
..createSync(recursive: true)
108+
..writeAsStringSync(kVersionJson);
91109
// Create a pubspec file
92110
flutter = flutterSdk.childDirectory('packages').childDirectory('flutter')
93111
..createSync(recursive: true);
@@ -144,6 +162,7 @@ void main() {
144162
// The version file exists.
145163
expect(result.childFile('version'), exists);
146164
expect(result.childFile('version').readAsStringSync(), '1.2.3');
165+
expect(fileSystem.file(fileSystem.path.join(result.path, 'bin', 'cache', 'flutter.version.json')), exists);
147166

148167
// The sky_engine package exists
149168
expect(fileSystem.directory('${result.path}/bin/cache/pkg/sky_engine'), exists);

0 commit comments

Comments
 (0)