mirror of
https://github.com/flutter/flutter
synced 2024-08-24 18:36:03 +00:00
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)
This commit is contained in:
parent
bf9aa556d2
commit
db141ecd28
|
@ -19,6 +19,7 @@ import '../globals.dart' as globals;
|
|||
import '../project.dart';
|
||||
import '../runner/flutter_command.dart';
|
||||
import '../update_packages_pins.dart';
|
||||
import '../version.dart';
|
||||
|
||||
class UpdatePackagesCommand extends FlutterCommand {
|
||||
UpdatePackagesCommand() {
|
||||
|
@ -1713,6 +1714,10 @@ Directory createTemporaryFlutterSdk(
|
|||
// Fill in version info.
|
||||
realFlutter.childFile('version')
|
||||
.copySync(directory.childFile('version').path);
|
||||
final File versionJson = FlutterVersion.getVersionFile(realFlutter.fileSystem, realFlutter.path);
|
||||
final Directory binCacheDirectory = directory.childDirectory('bin').childDirectory('cache');
|
||||
binCacheDirectory.createSync(recursive: true);
|
||||
versionJson.copySync(binCacheDirectory.childFile('flutter.version.json').path);
|
||||
|
||||
// Directory structure should mirror the current Flutter SDK
|
||||
final Directory packages = directory.childDirectory('packages');
|
||||
|
|
|
@ -73,6 +73,20 @@ dependencies:
|
|||
# PUBSPEC CHECKSUM: 6543
|
||||
''';
|
||||
|
||||
const String kVersionJson = '''
|
||||
{
|
||||
"frameworkVersion": "1.2.3",
|
||||
"channel": "[user-branch]",
|
||||
"repositoryUrl": "git@github.com:flutter/flutter.git",
|
||||
"frameworkRevision": "1234567812345678123456781234567812345678",
|
||||
"frameworkCommitDate": "2024-02-06 22:26:52 +0100",
|
||||
"engineRevision": "abcdef01abcdef01abcdef01abcdef01abcdef01",
|
||||
"dartSdkVersion": "1.2.3",
|
||||
"devToolsVersion": "1.2.3",
|
||||
"flutterVersion": "1.2.3"
|
||||
}
|
||||
''';
|
||||
|
||||
void main() {
|
||||
group('update-packages', () {
|
||||
late FileSystem fileSystem;
|
||||
|
@ -91,6 +105,9 @@ void main() {
|
|||
fileSystem = MemoryFileSystem.test();
|
||||
flutterSdk = fileSystem.directory('flutter')..createSync();
|
||||
flutterSdk.childFile('version').writeAsStringSync('1.2.3');
|
||||
flutterSdk.childDirectory('bin').childDirectory('cache').childFile('flutter.version.json')
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync(kVersionJson);
|
||||
flutter = flutterSdk.childDirectory('packages').childDirectory('flutter')
|
||||
..createSync(recursive: true);
|
||||
flutterSdk.childDirectory('dev').createSync(recursive: true);
|
||||
|
|
|
@ -77,6 +77,20 @@ dependencies:
|
|||
git:
|
||||
''';
|
||||
|
||||
const String kVersionJson = '''
|
||||
{
|
||||
"frameworkVersion": "1.2.3",
|
||||
"channel": "[user-branch]",
|
||||
"repositoryUrl": "git@github.com:flutter/flutter.git",
|
||||
"frameworkRevision": "1234567812345678123456781234567812345678",
|
||||
"frameworkCommitDate": "2024-02-06 22:26:52 +0100",
|
||||
"engineRevision": "abcdef01abcdef01abcdef01abcdef01abcdef01",
|
||||
"dartSdkVersion": "1.2.3",
|
||||
"devToolsVersion": "1.2.3",
|
||||
"flutterVersion": "1.2.3"
|
||||
}
|
||||
''';
|
||||
|
||||
void main() {
|
||||
late FileSystem fileSystem;
|
||||
late Directory flutterSdk;
|
||||
|
@ -88,6 +102,10 @@ void main() {
|
|||
flutterSdk = fileSystem.directory('flutter')..createSync();
|
||||
// Create version file
|
||||
flutterSdk.childFile('version').writeAsStringSync('1.2.3');
|
||||
// Create version JSON file
|
||||
flutterSdk.childDirectory('bin').childDirectory('cache').childFile('flutter.version.json')
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync(kVersionJson);
|
||||
// Create a pubspec file
|
||||
flutter = flutterSdk.childDirectory('packages').childDirectory('flutter')
|
||||
..createSync(recursive: true);
|
||||
|
@ -144,6 +162,7 @@ void main() {
|
|||
// The version file exists.
|
||||
expect(result.childFile('version'), exists);
|
||||
expect(result.childFile('version').readAsStringSync(), '1.2.3');
|
||||
expect(fileSystem.file(fileSystem.path.join(result.path, 'bin', 'cache', 'flutter.version.json')), exists);
|
||||
|
||||
// The sky_engine package exists
|
||||
expect(fileSystem.directory('${result.path}/bin/cache/pkg/sky_engine'), exists);
|
||||
|
|
Loading…
Reference in a new issue