diff --git a/dwds/CHANGELOG.md b/dwds/CHANGELOG.md index 80ce3d895..1f34136f7 100644 --- a/dwds/CHANGELOG.md +++ b/dwds/CHANGELOG.md @@ -12,7 +12,7 @@ restart. - Remove verbose printing on receiving DevTools events. - Update `vm_service` version to `^8.2.0`. - +- Migrate .packages to package_config.json. **Breaking changes:** - `Dwds.start` and `ExpressionCompilerService` now take diff --git a/dwds/lib/src/readers/frontend_server_asset_reader.dart b/dwds/lib/src/readers/frontend_server_asset_reader.dart index c44cedb0b..f11616208 100644 --- a/dwds/lib/src/readers/frontend_server_asset_reader.dart +++ b/dwds/lib/src/readers/frontend_server_asset_reader.dart @@ -37,8 +37,8 @@ class FrontendServerAssetReader implements AssetReader { /// Corresponding `.json` and `.map` files will be read relative to /// [outputPath]. /// - /// [_packageRoot] is the path to the directory that contains a `.packages` - /// file for the application. + /// [_packageRoot] is the path to the directory that contains a + /// `.dart_tool/package_config.json` file for the application. FrontendServerAssetReader( String outputPath, this._packageRoot, @@ -46,8 +46,8 @@ class FrontendServerAssetReader implements AssetReader { _mapIncremental = File('$outputPath.incremental.map'), _jsonOriginal = File('$outputPath.json'), _jsonIncremental = File('$outputPath.incremental.json'), - _packageConfig = loadPackageConfig( - File(p.absolute(p.join(_packageRoot, '.packages')))); + _packageConfig = loadPackageConfig(File(p + .absolute(p.join(_packageRoot, '.dart_tool/package_config.json')))); @override Future dartSourceContents(String serverPath) async { diff --git a/dwds/lib/src/utilities/dart_uri.dart b/dwds/lib/src/utilities/dart_uri.dart index 4d3fb35cf..9903950af 100644 --- a/dwds/lib/src/utilities/dart_uri.dart +++ b/dwds/lib/src/utilities/dart_uri.dart @@ -157,7 +157,8 @@ class DartUri { /// Record library and script uris to enable resolving library and script paths. static Future initialize(SdkConfiguration sdkConfiguration) async { _sdkConfiguration = sdkConfiguration; - var packagesUri = p.toUri(p.join(currentDirectory, '.packages')); + var packagesUri = + p.toUri(p.join(currentDirectory, '.dart_tool/package_config.json')); clear(); @@ -190,8 +191,8 @@ class DartUri { /// Returns the dirname for the server URI. static String _dirForServerUri(String uri) => p.dirname(Uri.parse(uri).path); - /// Load the .packages file associated with the running application so we can - /// resolve file URLs into package: URLs appropriately. + /// Load the .dart_tool/package_config.json file associated with the running + /// application so we can resolve file URLs into package: URLs appropriately. static Future _loadPackageConfig(Uri uri) async { _packageConfig = await loadPackageConfigUri(uri, onError: (e) { _logger.warning('Cannot read packages spec: $uri', e); diff --git a/dwds/test/fixtures/context.dart b/dwds/test/fixtures/context.dart index e0b483713..5e74a0071 100644 --- a/dwds/test/fixtures/context.dart +++ b/dwds/test/fixtures/context.dart @@ -98,7 +98,8 @@ class TestContext { .absolute(directory ?? p.relative(relativeDirectory, from: p.current))); DartUri.currentDirectory = workingDirectory; - _packagesFilePath = p.join(workingDirectory, '.packages'); + _packagesFilePath = + p.join(workingDirectory, '.dart_tool/package_config.json'); _entryFile = File(p.normalize( p.absolute(entry ?? p.relative(relativeEntry, from: p.current)))); diff --git a/frontend_server_common/lib/src/asset_server.dart b/frontend_server_common/lib/src/asset_server.dart index 756d489f7..bb090bb46 100644 --- a/frontend_server_common/lib/src/asset_server.dart +++ b/frontend_server_common/lib/src/asset_server.dart @@ -12,7 +12,7 @@ import 'dart:io'; import 'dart:typed_data'; import 'package:dwds/dwds.dart'; -import 'package:file/file.dart'; +import 'package:file/file.dart' hide Directory; import 'package:logging/logging.dart'; import 'package:mime/mime.dart' as mime; import 'package:package_config/package_config.dart'; // ignore: deprecated_member_use @@ -50,8 +50,13 @@ class TestAssetServer implements AssetReader { ) async { var address = (await InternetAddress.lookup(hostname)).first; var httpServer = await HttpServer.bind(address, port); - var packages = await loadPackageConfigUri(Uri.base.resolve('.packages'), + print('ROOT IS $root'); + print('URI IS ${Uri.base}'); + // var packages = await findPackageConfig(Directory.fromUri(Uri.base)); + var packages = await loadPackageConfigUri( + Uri.base.resolve('package_config.json'), loader: (Uri uri) => fileSystem.file(uri).readAsBytes()); + print('======== PACKAGE VERSION IS ${packages.version}'); var server = TestAssetServer(root, httpServer, packages, address, fileSystem); diff --git a/frontend_server_common/lib/src/devfs.dart b/frontend_server_common/lib/src/devfs.dart index 568d1fad1..75097fab9 100644 --- a/frontend_server_common/lib/src/devfs.dart +++ b/frontend_server_common/lib/src/devfs.dart @@ -57,7 +57,7 @@ class WebDevFS { Future dispose() { fileSystem.currentDirectory = _savedCurrentDirectory; - return assetServer.close(); + // return assetServer.close(); } Future update({ diff --git a/webdev/test/e2e_test.dart b/webdev/test/e2e_test.dart index e5779b2b9..b5a47980b 100644 --- a/webdev/test/e2e_test.dart +++ b/webdev/test/e2e_test.dart @@ -53,7 +53,9 @@ void main() { await process.shouldExit(0); - await d.file('.packages', isNotEmpty).validate(exampleDirectory); + await d + .file('.dart_tool/package_config.json', isNotEmpty) + .validate(exampleDirectory); await d.file('pubspec.lock', isNotEmpty).validate(exampleDirectory); }); diff --git a/webdev/test/integration_test.dart b/webdev/test/integration_test.dart index 259ed60f8..25cabb501 100644 --- a/webdev/test/integration_test.dart +++ b/webdev/test/integration_test.dart @@ -53,7 +53,7 @@ name: sample )) .create(); - await d.file('.packages', ''' + await d.file('.dart_tool/package_config.json', ''' ''').create(); await d.dir('.dart_tool', [d.file('package_config.json', '')]).create(); @@ -84,7 +84,7 @@ name: sample .file('pubspec.lock', _pubspecLock(runnerVersion: null)) .create(); - await d.file('.packages', ''' + await d.file('.dart_tool/package_config.json', ''' ''').create(); await d .dir('.dart_tool', [d.file('package_config.json', '')]).create(); @@ -107,7 +107,7 @@ name: sample .file('pubspec.lock', _pubspecLock(webCompilersVersion: null)) .create(); - await d.file('.packages', ''' + await d.file('.dart_tool/package_config.json', ''' ''').create(); await d .dir('.dart_tool', [d.file('package_config.json', '')]).create(); @@ -132,7 +132,7 @@ name: sample .file('pubspec.lock', _pubspecLock(webCompilersVersion: null)) .create(); - await d.file('.packages', ''' + await d.file('.dart_tool/package_config.json', ''' ''').create(); await d .dir('.dart_tool', [d.file('package_config.json', '')]).create(); @@ -184,7 +184,7 @@ name: sample daemonVersion: buildDaemonVersion)) .create(); - await d.file('.packages', ''' + await d.file('.dart_tool/package_config.json', ''' ''').create(); await d.dir( '.dart_tool', [d.file('package_config.json', '')]).create(); @@ -240,7 +240,7 @@ name: sample test('should fail if there has been a dependency change', () async { await d.file('pubspec.lock', _pubspecLock()).create(); - await d.file('.packages', '').create(); + await d.file('.dart_tool/package_config.json', '').create(); await d.dir('.dart_tool', [d.file('package_config.json', '')]).create(); // Ensure there is a noticeable delta in the creation times