[flutter_tools] migrate .packages to package_config, partial (#70200)
This commit is contained in:
@@ -6,6 +6,7 @@ import 'package:args/command_runner.dart';
|
||||
import 'package:flutter_tools/src/base/file_system.dart';
|
||||
import 'package:flutter_tools/src/cache.dart';
|
||||
import 'package:flutter_tools/src/commands/create.dart';
|
||||
import 'package:flutter_tools/src/convert.dart';
|
||||
import 'package:flutter_tools/src/doctor.dart';
|
||||
import 'package:flutter_tools/src/reporting/reporting.dart';
|
||||
import 'package:flutter_tools/src/globals.dart' as globals;
|
||||
@@ -39,14 +40,24 @@ void main() {
|
||||
}
|
||||
// Set up enough of the packages to satisfy the templating code.
|
||||
final File packagesFile = globals.fs.file(
|
||||
globals.fs.path.join('flutter', 'packages', 'flutter_tools', '.packages'));
|
||||
globals.fs.path.join('flutter', 'packages', 'flutter_tools', '.dart_tool', 'package_config.json'));
|
||||
final File flutterManifest = globals.fs.file(
|
||||
globals.fs.path.join('flutter', 'packages', 'flutter_tools', 'templates', 'template_manifest.json'))
|
||||
..createSync(recursive: true);
|
||||
final Directory templateImagesDirectory = globals.fs.directory('flutter_template_images');
|
||||
templateImagesDirectory.createSync(recursive: true);
|
||||
packagesFile.createSync(recursive: true);
|
||||
packagesFile.writeAsStringSync('flutter_template_images:file:///${templateImagesDirectory.uri}');
|
||||
packagesFile.writeAsStringSync(json.encode(<String, Object>{
|
||||
'configVersion': 2,
|
||||
'packages': <Object>[
|
||||
<String, Object>{
|
||||
'name': 'flutter_template_images',
|
||||
'languageVersion': '2.8',
|
||||
'rootUri': templateImagesDirectory.uri.toString(),
|
||||
'packageUri': 'lib/',
|
||||
},
|
||||
],
|
||||
}));
|
||||
flutterManifest.writeAsStringSync('{"files":[]}');
|
||||
}, overrides: <Type, Generator>{
|
||||
DoctorValidatorsProvider: () => FakeDoctorValidatorsProvider(),
|
||||
|
||||
@@ -38,9 +38,7 @@ void main() {
|
||||
manifestPath: anyNamed('manifestPath'),
|
||||
applicationKernelFilePath: anyNamed('applicationKernelFilePath'),
|
||||
depfilePath: anyNamed('depfilePath'),
|
||||
privateKeyPath: anyNamed('privateKeyPath'),
|
||||
assetDirPath: anyNamed('assetDirPath'),
|
||||
packagesPath: anyNamed('packagesPath'),
|
||||
precompiledSnapshot: anyNamed('precompiledSnapshot'),
|
||||
reportLicensedPackages: anyNamed('reportLicensedPackages'),
|
||||
trackWidgetCreation: anyNamed('trackWidgetCreation'),
|
||||
|
||||
@@ -2701,7 +2701,7 @@ plugin1=${plugin1.path}
|
||||
legacySettingsDotGradleFiles.readAsStringSync().split(';EOF').map<String>((String body) => body.trim()),
|
||||
contains(templateSettingsDotGradle.readAsStringSync().trim()),
|
||||
);
|
||||
});
|
||||
}, skip: true); // TODO(jonahwilliams): This is an integration test and should be moved to the integration shard.
|
||||
}
|
||||
|
||||
/// Generates a fake app bundle at the location [directoryName]/[fileName].
|
||||
|
||||
@@ -23,7 +23,10 @@ void main() {
|
||||
|
||||
setUp(() {
|
||||
fileSystem = MemoryFileSystem.test();
|
||||
fileSystem.file('.packages').writeAsStringSync('\n');
|
||||
fileSystem
|
||||
.file('.dart_tool/package_config.json')
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync('{"configVersion":2,"packages":[]}');
|
||||
});
|
||||
|
||||
group('FlutterPlatform', () {
|
||||
@@ -82,7 +85,7 @@ void main() {
|
||||
'--enable-dart-profiling',
|
||||
'--non-interactive',
|
||||
'--use-test-fonts',
|
||||
'--packages=.packages',
|
||||
'--packages=.dart_tool/package_config.json',
|
||||
'example.dill'
|
||||
],
|
||||
stdout: 'success',
|
||||
@@ -237,7 +240,7 @@ class MockHttpServer extends Mock implements HttpServer {}
|
||||
// Uses a mock HttpServer. We don't want to bind random ports in our CI hosts.
|
||||
class TestFlutterPlatform extends FlutterPlatform {
|
||||
TestFlutterPlatform() : super(
|
||||
buildInfo: BuildInfo.debug,
|
||||
buildInfo: const BuildInfo(BuildMode.debug, '', treeShakeIcons: false, packagesPath: '.dart_tool/package_config.json'),
|
||||
shellPath: '/',
|
||||
precompiledDillPath: 'example.dill',
|
||||
host: InternetAddress.loopbackIPv6,
|
||||
@@ -259,7 +262,7 @@ class TestFlutterPlatform extends FlutterPlatform {
|
||||
// Uses a mock HttpServer. We don't want to bind random ports in our CI hosts.
|
||||
class TestObservatoryFlutterPlatform extends FlutterPlatform {
|
||||
TestObservatoryFlutterPlatform() : super(
|
||||
buildInfo: BuildInfo.debug,
|
||||
buildInfo: const BuildInfo(BuildMode.debug, '', treeShakeIcons: false, packagesPath: '.dart_tool/package_config.json'),
|
||||
shellPath: '/',
|
||||
precompiledDillPath: 'example.dill',
|
||||
host: InternetAddress.loopbackIPv6,
|
||||
|
||||
@@ -699,7 +699,10 @@ apply plugin: 'kotlin-android'
|
||||
|
||||
Future<FlutterProject> someProject() async {
|
||||
final Directory directory = globals.fs.directory('some_project');
|
||||
directory.childFile('.packages').createSync(recursive: true);
|
||||
directory.childDirectory('.dart_tool')
|
||||
.childFile('package_config.json')
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync('{"configVersion":2,"packages":[]}');
|
||||
directory.childDirectory('ios').createSync(recursive: true);
|
||||
final Directory androidDirectory = directory
|
||||
.childDirectory('android')
|
||||
@@ -750,7 +753,11 @@ flutter:
|
||||
|
||||
Future<FlutterProject> aModuleProject() async {
|
||||
final Directory directory = globals.fs.directory('module_project');
|
||||
directory.childFile('.packages').createSync(recursive: true);
|
||||
directory
|
||||
.childDirectory('.dart_tool')
|
||||
.childFile('package_config.json')
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync('{"configVersion":2,"packages":[]}');
|
||||
directory.childFile('pubspec.yaml').writeAsStringSync('''
|
||||
name: my_module
|
||||
flutter:
|
||||
@@ -768,7 +775,11 @@ void _testInMemory(String description, Future<void> testMethod()) {
|
||||
final FileSystem testFileSystem = MemoryFileSystem(
|
||||
style: globals.platform.isWindows ? FileSystemStyle.windows : FileSystemStyle.posix,
|
||||
);
|
||||
testFileSystem.file('.packages').writeAsStringSync('\n');
|
||||
testFileSystem
|
||||
.directory('.dart_tool')
|
||||
.childFile('package_config.json')
|
||||
..createSync(recursive: true)
|
||||
..writeAsStringSync('{"configVersion":2,"packages":[]}');
|
||||
// Transfer needed parts of the Flutter installation folder
|
||||
// to the in-memory file system used during testing.
|
||||
transfer(Cache(
|
||||
@@ -789,11 +800,22 @@ void _testInMemory(String description, Future<void> testMethod()) {
|
||||
final File packagesFile = testFileSystem.directory(Cache.flutterRoot)
|
||||
.childDirectory('packages')
|
||||
.childDirectory('flutter_tools')
|
||||
.childFile('.packages');
|
||||
.childDirectory('.dart_tool')
|
||||
.childFile('package_config.json');
|
||||
final Directory dummyTemplateImagesDirectory = testFileSystem.directory(Cache.flutterRoot).parent;
|
||||
dummyTemplateImagesDirectory.createSync(recursive: true);
|
||||
packagesFile.createSync(recursive: true);
|
||||
packagesFile.writeAsStringSync('flutter_template_images:${dummyTemplateImagesDirectory.uri}');
|
||||
packagesFile.writeAsStringSync(json.encode(<String, Object>{
|
||||
'configVersion': 2,
|
||||
'packages': <Object>[
|
||||
<String, Object>{
|
||||
'name': 'flutter_template_images',
|
||||
'rootUri': dummyTemplateImagesDirectory.uri.toString(),
|
||||
'packageUri': 'lib/',
|
||||
'languageVersion': '2.6'
|
||||
},
|
||||
],
|
||||
}));
|
||||
|
||||
final FlutterProjectFactory flutterProjectFactory = FlutterProjectFactory(
|
||||
fileSystem: testFileSystem,
|
||||
|
||||
@@ -194,7 +194,7 @@ void main() {
|
||||
compileExpression: anyNamed('compileExpression'),
|
||||
getSkSLMethod: anyNamed('getSkSLMethod'),
|
||||
)).thenAnswer((Invocation invocation) async { });
|
||||
when(mockFlutterDevice.setupDevFS(any, any, packagesFilePath: anyNamed('packagesFilePath')))
|
||||
when(mockFlutterDevice.setupDevFS(any, any))
|
||||
.thenAnswer((Invocation invocation) async {
|
||||
return testUri;
|
||||
});
|
||||
|
||||
@@ -43,7 +43,7 @@ void main() {
|
||||
);
|
||||
|
||||
expect(
|
||||
await localEngineLocator.findEnginePath(null, 'ios_debug'),
|
||||
await localEngineLocator.findEnginePath(null, 'ios_debug', null),
|
||||
matchesEngineBuildPaths(
|
||||
hostEngine: '/arbitrary/engine/src/out/host_debug',
|
||||
targetEngine: '/arbitrary/engine/src/out/ios_debug',
|
||||
@@ -57,7 +57,7 @@ void main() {
|
||||
.writeAsStringSync('sky_engine:file:///symlink/src/out/ios_debug/gen/dart-pkg/sky_engine/lib/');
|
||||
|
||||
expect(
|
||||
await localEngineLocator.findEnginePath(null, 'ios_debug'),
|
||||
await localEngineLocator.findEnginePath(null, 'ios_debug', null),
|
||||
matchesEngineBuildPaths(
|
||||
hostEngine: '/symlink/src/out/host_debug',
|
||||
targetEngine: '/symlink/src/out/ios_debug',
|
||||
@@ -81,7 +81,7 @@ void main() {
|
||||
);
|
||||
|
||||
expect(
|
||||
await localEngineLocator.findEnginePath('$kArbitraryEngineRoot/src', 'ios_debug'),
|
||||
await localEngineLocator.findEnginePath('$kArbitraryEngineRoot/src', 'ios_debug', null),
|
||||
matchesEngineBuildPaths(
|
||||
hostEngine: '/arbitrary/engine/src/out/host_debug',
|
||||
targetEngine: '/arbitrary/engine/src/out/ios_debug',
|
||||
@@ -112,7 +112,7 @@ void main() {
|
||||
);
|
||||
|
||||
expect(
|
||||
await localEngineLocator.findEnginePath(null, 'ios_debug'),
|
||||
await localEngineLocator.findEnginePath(null, 'ios_debug', null),
|
||||
matchesEngineBuildPaths(
|
||||
hostEngine: 'flutter/engine/src/out/host_debug',
|
||||
targetEngine: 'flutter/engine/src/out/ios_debug',
|
||||
|
||||
Reference in New Issue
Block a user