Skip to content

Commit

Permalink
Bump to package:extension_discovery 2.0.0 (#6280)
Browse files Browse the repository at this point in the history
  • Loading branch information
kenzieschmoll authored Sep 1, 2023
1 parent 7a80948 commit aa7f2d4
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 33 deletions.
2 changes: 2 additions & 0 deletions packages/devtools_extensions/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
22 changes: 10 additions & 12 deletions packages/devtools_extensions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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": "<link_to_your_issue_tracker.com>",
"version": "0.0.1",
"materialIconCodePoint": "0xe0b1"
}
```yaml
name: foo_package
issue_tracker: <link_to_your_issue_tracker.com>
version: 0.0.1
material_icon_code_point: '0xe0b1'
```
Now it is time to build your extension.
Expand All @@ -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
```

Expand Down
8 changes: 4 additions & 4 deletions packages/devtools_extensions/bin/_build_and_copy.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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...');
Expand All @@ -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);
Expand Down
4 changes: 4 additions & 0 deletions packages/devtools_shared/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
15 changes: 2 additions & 13 deletions packages/devtools_shared/lib/src/extensions/extension_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<String, Object?>;

// 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(),
Expand All @@ -100,7 +89,7 @@ class ExtensionsManager {

try {
final pluginConfig = DevToolsExtensionConfig.parse({
...configAsMap,
...config,
DevToolsExtensionConfig.pathKey: location,
});
devtoolsExtensions.add(pluginConfig);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.',
);
}
}
Expand Down
4 changes: 2 additions & 2 deletions packages/devtools_shared/pubspec.yaml
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
Expand Down

0 comments on commit aa7f2d4

Please sign in to comment.