Skip to content

Commit

Permalink
Address some devtools extensions feedback related to Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
kenzieschmoll committed Nov 1, 2023
1 parent ec4387b commit 18b54b8
Show file tree
Hide file tree
Showing 6 changed files with 91 additions and 28 deletions.
3 changes: 3 additions & 0 deletions packages/devtools_extensions/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
## 0.0.10
* Fix some bugs with the `build_and_copy` command for Windows.
* Add an example `launch.json` file in the `example/foo` directory.
* Clean up the package readme to make instructions Windows-compatible.
* Update the README with instructions for joining the Flutter Discord server.
* Bump the `devtools_shared` dependency to ^5.0.0

Expand Down
22 changes: 12 additions & 10 deletions packages/devtools_extensions/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,16 +113,16 @@ In `lib/main.dart`, place a `DevToolsExtension` widget at the root of your app:
import 'package:devtools_extensions/devtools_extensions.dart';
void main() {
runApp(const FooPackageDevToolsExtension());
runApp(const FooDevToolsExtension());
}
class FooPackageDevToolsExtension extends StatelessWidget {
const FooPackageDevToolsExtension({super.key});
class FooDevToolsExtension extends StatelessWidget {
const FooDevToolsExtension({super.key});
@override
Widget build(BuildContext context) {
return const DevToolsExtension(
child: FooDevToolsExtension(),
child: Placeholder(),
);
}
}
Expand Down Expand Up @@ -159,7 +159,7 @@ file in VS code:
...
{
"name": "foo_devtools_extension + simulated environment",
"program": "foo/extension/foo_devtools_extension/lib/main.dart",
"cwd": "packages/foo_devtools_extension",
"request": "launch",
"type": "dart",
"args": [
Expand All @@ -185,11 +185,13 @@ real DevTools environment. Build your flutter web app and copy the built assets

Use the `build_extension` command from `package:devtools_extensions` to help with this step.
```sh
cd your_extension_web_app &&
flutter pub get &&
dart run devtools_extensions build_and_copy \
--source=. \
--dest=path/to/your_pub_package/extension/devtools
cd your_extension_web_app
```
```sh
flutter pub get
```
```sh
dart run devtools_extensions build_and_copy --source=. --dest=path/to/your_pub_package/extension/devtools
```

2. Prepare and run a test application that depends on your pub package. You'll need to change the
Expand Down
33 changes: 17 additions & 16 deletions packages/devtools_extensions/bin/_build_and_copy.dart
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class BuildExtensionCommand extends Command {
_log('Building the extension Flutter web app...');
await _runProcess(
processManager,
'flutter',
Platform.isWindows ? 'flutter.bat' : 'flutter',
[
'build',
'web',
Expand All @@ -69,24 +69,25 @@ class BuildExtensionCommand extends Command {
workingDirectory: source,
);

_log('Setting canvaskit permissions...');
await _runProcess(
processManager,
'chmod',
[
'0755',
// Note: using a wildcard `canvaskit.*` throws.
'build/web/canvaskit/canvaskit.js',
'build/web/canvaskit/canvaskit.wasm',
],
workingDirectory: source,
);
// TODO(kenz): investigate if we need to perform a windows equivalent of
// `chmod` or if we even need to perform `chmod` for linux / mac anymore.
if (!Platform.isWindows) {
_log('Setting canvaskit permissions...');
await _runProcess(
processManager,
'chmod',
[
'0755',
// Note: using a wildcard `canvaskit.*` throws.
'build/web/canvaskit/canvaskit.js',
'build/web/canvaskit/canvaskit.wasm',
],
workingDirectory: source,
);
}

_log('Copying built output to the extension destination...');
await _copyBuildToDestination(source: source, dest: destination);

// Closes stdin for the entire program.
await sharedStdIn.terminate();
}

Future<void> _copyBuildToDestination({
Expand Down
2 changes: 1 addition & 1 deletion packages/devtools_extensions/bin/devtools_extensions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ void main(List<String> arguments) async {
final command = BuildExtensionCommand();
final runner = CommandRunner('devtools_extensions', command.description)
..addCommand(BuildExtensionCommand());
await runner.run(arguments);
await runner.run(arguments).whenComplete(sharedStdIn.terminate);
}
57 changes: 57 additions & 0 deletions packages/devtools_extensions/example/foo/.vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "foo_devtools_extension",
"cwd": "packages/foo_devtools_extension",
"request": "launch",
"type": "dart"
},
{
"name": "foo_devtools_extension (profile mode)",
"cwd": "packages/foo_devtools_extension",
"request": "launch",
"type": "dart",
"flutterMode": "profile",
},
{
"name": "foo_devtools_extension (release mode)",
"cwd": "packages/foo_devtools_extension",
"request": "launch",
"type": "dart",
"flutterMode": "release",
},
{
"name": "foo_devtools_extension + simulated environment",
"cwd": "packages/foo_devtools_extension",
"request": "launch",
"type": "dart",
"args": [
"--dart-define=use_simulated_environment=true"
],
},
{
"name": "foo_devtools_extension + simulated environment (profile mode)",
"cwd": "packages/foo_devtools_extension",
"request": "launch",
"type": "dart",
"flutterMode": "profile",
"args": [
"--dart-define=use_simulated_environment=true"
],
},
{
"name": "foo_devtools_extension + simulated environment (release mode)",
"cwd": "packages/foo_devtools_extension",
"request": "launch",
"type": "dart",
"flutterMode": "release",
"args": [
"--dart-define=use_simulated_environment=true"
],
}
]
}
2 changes: 1 addition & 1 deletion packages/devtools_extensions/extension_config_spec.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ The `config.yaml` file for a DevTools extension must follow the format below.
## Required fields

- `name` : the package name that this DevTools extension belongs to. The value of this field
will be used in the extension page title bar.
will be used in the extension page title bar. This name should not contain spaces or special characters.
- `issueTracker`: the url for the extension's issue tracker. When a user clicks the “Report an
issue” link in the DevTools UI, they will be directed to this url.
- `version`: the version of the DevTools extension. This version number should evolve over time
Expand Down

0 comments on commit 18b54b8

Please sign in to comment.