From aa7f2d40c656cac5d26a809b7e257d6cef905d80 Mon Sep 17 00:00:00 2001 From: Kenzie Davisson <43759233+kenzieschmoll@users.noreply.github.com> Date: Fri, 1 Sep 2023 13:27:26 -0700 Subject: [PATCH] Bump to `package:extension_discovery` 2.0.0 (#6280) --- packages/devtools_extensions/CHANGELOG.md | 2 ++ packages/devtools_extensions/README.md | 22 +++++++++---------- .../bin/_build_and_copy.dart | 8 +++---- packages/devtools_shared/CHANGELOG.md | 4 ++++ .../lib/src/extensions/extension_manager.dart | 15 ++----------- .../lib/src/extensions/extension_model.dart | 4 ++-- packages/devtools_shared/pubspec.yaml | 4 ++-- 7 files changed, 26 insertions(+), 33 deletions(-) diff --git a/packages/devtools_extensions/CHANGELOG.md b/packages/devtools_extensions/CHANGELOG.md index 4813c3fb87a..04461fac646 100644 --- a/packages/devtools_extensions/CHANGELOG.md +++ b/packages/devtools_extensions/CHANGELOG.md @@ -1,6 +1,8 @@ ## 0.0.3-wip * Add `showNotification` and `showBannerMessage` endpoints to the extensions API. * Add hot reload and hot restart actions to the simulated DevTools environment. +* Update `build_and_copy` command, as well as documentation, to reference `config.yaml` +instead of `config.json`, as required by `package:extension_discovery` v2.0.0. * Add exception handling to `devtools_extensions build_and_copy` command. ## 0.0.2 diff --git a/packages/devtools_extensions/README.md b/packages/devtools_extensions/README.md index ab28aa57bbf..3869b90311a 100644 --- a/packages/devtools_extensions/README.md +++ b/packages/devtools_extensions/README.md @@ -32,20 +32,18 @@ Under this directory, create the following structure: extension devtools/ build/ - config.json + config.yaml ``` -The `config.json` file contains metadata that DevTools needs in order to load the -extension. Copy the `config.json` file below and fill in the approproate value for each key. -The "materialIconCodePoint" field should correspond to the codepoint value of an icon from +The `config.yaml` file contains metadata that DevTools needs in order to load the +extension. Copy the `config.yaml` file below and fill in the approproate value for each key. +The `material_icon_code_point` field should correspond to the codepoint value of an icon from [material/icons.dart](https://github.com/flutter/flutter/blob/master/packages/flutter/lib/src/material/icons.dart). -```json -{ - "name": "foo_package", - "issueTracker": "", - "version": "0.0.1", - "materialIconCodePoint": "0xe0b1" -} +```yaml +name: foo_package +issue_tracker: +version: 0.0.1 +material_icon_code_point: '0xe0b1' ``` Now it is time to build your extension. @@ -66,7 +64,7 @@ foo_package/ # formerly the repository root of your pub package devtools/ build/ ... # pre-compiled output of foo_package_devtools_extension - config.json + config.yaml foo_package_devtools_extension/ # source code for your extension ``` diff --git a/packages/devtools_extensions/bin/_build_and_copy.dart b/packages/devtools_extensions/bin/_build_and_copy.dart index c3560e0f1a4..49830ee9079 100644 --- a/packages/devtools_extensions/bin/_build_and_copy.dart +++ b/packages/devtools_extensions/bin/_build_and_copy.dart @@ -94,10 +94,10 @@ class BuildExtensionCommand extends Command { required String source, required String dest, }) async { - _log('Copying the extension config.json file into a temp directory...'); + _log('Copying the extension config.yaml file into a temp directory...'); final tmp = Directory.current.createTempSync(); - final tmpConfigPath = path.join(tmp.path, 'config.json'); - final destinationConfigPath = path.join(dest, 'config.json'); + final tmpConfigPath = path.join(tmp.path, 'config.yaml'); + final destinationConfigPath = path.join(dest, 'config.yaml'); File(destinationConfigPath)..copySync(tmpConfigPath); _log('Replacing the existing extension build with the new one...'); @@ -111,7 +111,7 @@ class BuildExtensionCommand extends Command { ); _log( - 'Copying the extension config.json file back to the destination ' + 'Copying the extension config.yaml file back to the destination ' 'directory...', ); File(tmpConfigPath)..copySync(destinationConfigPath); diff --git a/packages/devtools_shared/CHANGELOG.md b/packages/devtools_shared/CHANGELOG.md index c8f537c5f30..6d6847fe955 100644 --- a/packages/devtools_shared/CHANGELOG.md +++ b/packages/devtools_shared/CHANGELOG.md @@ -1,3 +1,7 @@ +# 3.0.2 + +- Bump `package:extension_discovery` version to ^2.0.0 + # 3.0.1 - Bump `package:extension_discovery` version to ^1.0.1 diff --git a/packages/devtools_shared/lib/src/extensions/extension_manager.dart b/packages/devtools_shared/lib/src/extensions/extension_manager.dart index ada13b455e4..43226b53076 100644 --- a/packages/devtools_shared/lib/src/extensions/extension_manager.dart +++ b/packages/devtools_shared/lib/src/extensions/extension_manager.dart @@ -76,21 +76,10 @@ class ExtensionsManager { } for (final extension in extensions) { final config = extension.config; - // ignore: avoid-unnecessary-type-assertions; false positive, config is type Object. - if (config is! Map) { - // Fail gracefully. Invalid content in the extension's config.json. - print( - '[WARNING] invalid config.json content for ${extension.package}:\n' - '$config', - ); - continue; - } - final configAsMap = config as Map; - // This should be relative to the 'extension/devtools/' directory and // defaults to 'build'; final relativeExtensionLocation = - configAsMap['buildLocation'] as String? ?? 'build'; + config['buildLocation'] as String? ?? 'build'; final location = path.join( extension.rootUri.toFilePath(), @@ -100,7 +89,7 @@ class ExtensionsManager { try { final pluginConfig = DevToolsExtensionConfig.parse({ - ...configAsMap, + ...config, DevToolsExtensionConfig.pathKey: location, }); devtoolsExtensions.add(pluginConfig); diff --git a/packages/devtools_shared/lib/src/extensions/extension_model.dart b/packages/devtools_shared/lib/src/extensions/extension_model.dart index 55c03dc4844..71308cee568 100644 --- a/packages/devtools_shared/lib/src/extensions/extension_model.dart +++ b/packages/devtools_shared/lib/src/extensions/extension_model.dart @@ -53,14 +53,14 @@ class DevToolsExtensionConfig implements Comparable { ); } throw StateError( - 'Unexpected value types in the extension config.json. Expected all ' + 'Unexpected value types in the extension config.yaml. Expected all ' 'values to be of type String, but one or more had a different type:\n' '${sb.toString()}', ); } else { throw StateError( 'Missing required fields ${diff.toString()} in the extension ' - 'config.json.', + 'config.yaml.', ); } } diff --git a/packages/devtools_shared/pubspec.yaml b/packages/devtools_shared/pubspec.yaml index 666e22b13f7..2cdef6f825a 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: 3.0.1 +version: 3.0.2 repository: https://github.com/flutter/devtools/tree/master/packages/devtools_shared @@ -10,7 +10,7 @@ environment: dependencies: collection: ^1.15.0 - extension_discovery: ^1.0.1 + extension_discovery: ^2.0.0 path: ^1.8.0 shelf: ^1.1.0 sse: ^4.1.2