From b8cd6d54d7ce55077300b6d229b7357575ae9fd7 Mon Sep 17 00:00:00 2001 From: Danny Tuppeny Date: Mon, 20 Nov 2023 19:56:07 +0000 Subject: [PATCH 1/2] Fix some minor Windows issues `Uri.parse()` shouldn't be used with file paths for Windows (should use `Uri.file()`) + tweak some tests to always use posix paths in strings that are checked so that they're consistent across platforms. --- .../lib/src/extensions/extension_manager.dart | 2 +- .../extensions/extension_enablement_test.dart | 2 +- .../extensions/extension_manager_test.dart | 18 +++++++++++++++--- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/packages/devtools_shared/lib/src/extensions/extension_manager.dart b/packages/devtools_shared/lib/src/extensions/extension_manager.dart index ba3c45eea65..0d097f0ebba 100644 --- a/packages/devtools_shared/lib/src/extensions/extension_manager.dart +++ b/packages/devtools_shared/lib/src/extensions/extension_manager.dart @@ -61,7 +61,7 @@ class ExtensionsManager { try { extensions = await findExtensions( 'devtools', - packageConfig: Uri.parse( + packageConfig: Uri.file( path.join( rootPath, '.dart_tool', diff --git a/packages/devtools_shared/test/extensions/extension_enablement_test.dart b/packages/devtools_shared/test/extensions/extension_enablement_test.dart index adeabda69da..9adb3cc7b7a 100644 --- a/packages/devtools_shared/test/extensions/extension_enablement_test.dart +++ b/packages/devtools_shared/test/extensions/extension_enablement_test.dart @@ -17,7 +17,7 @@ void main() { setUp(() { options = DevToolsOptions(); tmpDir = Directory.current.createTempSync(); - tmpUri = Uri.parse(tmpDir.path); + tmpUri = Uri.file(tmpDir.path); }); tearDown(() { diff --git a/packages/devtools_shared/test/extensions/extension_manager_test.dart b/packages/devtools_shared/test/extensions/extension_manager_test.dart index 64c7438807c..342fee77a1b 100644 --- a/packages/devtools_shared/test/extensions/extension_manager_test.dart +++ b/packages/devtools_shared/test/extensions/extension_manager_test.dart @@ -44,9 +44,9 @@ void main() { Directory _createFromDir() { final from = Directory('tmp')..createSync(); - File.fromUri(Uri.parse(p.join(from.path, 'foo.txt')))..createSync(); + File(p.join(from.path, 'foo.txt'))..createSync(); final dir = Directory(p.join(from.path, 'bar'))..createSync(); - File.fromUri(Uri.parse(p.join(dir.path, 'baz.txt')))..createSync(); + File(p.join(dir.path, 'baz.txt'))..createSync(); final contents = _contentAsOrderedString(from); expect( contents, @@ -65,5 +65,17 @@ Directory _createToDir() { String _contentAsOrderedString(Directory dir) { final contents = dir.listSync(recursive: true) ..sort((a, b) => a.path.compareTo(b.path)); - return contents.toString(); + return contents + // Always use posix paths so that expectations can be consistent between + // Mac/Windows. + .map( + (e) => + "${e is Directory ? 'Directory' : 'File'}: '${posixPath(e.path)}'", + ) + .toList() + .toString(); } + +/// Returns a relative path [input] with posix/forward slashes regardless of +/// the current platform. +String posixPath(String input) => p.posix.joinAll(p.split(input)); From fc821a7fbd759c2c94d3fe4f8eab100b1deabe2f Mon Sep 17 00:00:00 2001 From: Danny Tuppeny Date: Tue, 21 Nov 2023 16:42:28 +0000 Subject: [PATCH 2/2] Update version / changelog --- packages/devtools_shared/CHANGELOG.md | 3 +++ packages/devtools_shared/pubspec.yaml | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/packages/devtools_shared/CHANGELOG.md b/packages/devtools_shared/CHANGELOG.md index cdaa12e1c9f..538f740e448 100644 --- a/packages/devtools_shared/CHANGELOG.md +++ b/packages/devtools_shared/CHANGELOG.md @@ -1,3 +1,6 @@ +# 6.0.2 +* Fix an issue parsing file paths on Windows that could prevent extensions from being detected. + # 6.0.1 * Bump minimum Dart SDK version to `3.3.0-91.0.dev` and minimum Flutter SDK version to `3.17.0-0.0.pre`. * Add field `isPublic` to `DevToolsExtensionConfig`. diff --git a/packages/devtools_shared/pubspec.yaml b/packages/devtools_shared/pubspec.yaml index 76a3161e9cc..faf53aceb18 100644 --- a/packages/devtools_shared/pubspec.yaml +++ b/packages/devtools_shared/pubspec.yaml @@ -1,7 +1,7 @@ name: devtools_shared description: Package of shared Dart structures between devtools_app, dds, and other tools. -version: 6.0.1 +version: 6.0.2-wip repository: https://github.com/flutter/devtools/tree/master/packages/devtools_shared