Skip to content

[custom-devices] general improvements, add custom-devices subcommand, better error handling#82043

Merged
fluttergithubbot merged 42 commits intoflutter:masterfrom
ardera:feature/custom-device-improvements
Jul 7, 2021
Merged

[custom-devices] general improvements, add custom-devices subcommand, better error handling#82043
fluttergithubbot merged 42 commits intoflutter:masterfrom
ardera:feature/custom-device-improvements

Conversation

@ardera
Copy link
Contributor

@ardera ardera commented May 7, 2021

  • generally improves the custom devices feature
  • adds flutter subcommand for custom-devices management:
    • flutter custom-devices list lists the configured custom devices
      • can be used to check for errors
      • will also output the path of the config
    • flutter custom-devices reset
      • resets the configured custom devices config to default & creates a backup
    • flutter custom-devices add
      • either supply a json-formatted string as an argument to the --json parameter
      • or configure using an interactive, guided device setup
      • that guided setup will by default setup a ssh device, i.e. it won't ask for the values of every custom device config option, but rather for things like the ssh username & hostname and generally provide some good defaults for ssh devices
    • flutter custom-devices delete
      • deletes a custom-devices file based on the device id
  • better error checking when loading the config & better error messages
  • if anything goes wrong while loading a CustomDeviceConfig, a JsonRevivalException will be thrown with an error message describing the error (like Expected 'pingSuccessRegex' to be null or string-ified regex.)
  • that error will also be catched and expanded a bit by CustomDevicesConfig.devices so the outputted error message may look like this: Could not load custom device from config index 0: Expected 'pingSuccessRegex' to be null or string-ified regex.

fixes #79406

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide, including Features we expect every widget to implement.
  • I signed the CLA.
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt.
  • All existing and new tests are passing.

@flutter-dashboard flutter-dashboard bot added the tool Affects the "flutter" command-line tool. See also t: labels. label May 7, 2021
@google-cla google-cla bot added the cla: yes label May 7, 2021
@flutter-dashboard
Copy link

This pull request executed golden file tests, but it has not been updated in a while (20+ days). Test results from Gold expire after as many days, so this pull request will need to be updated with a fresh commit in order to get results from Gold.

For more guidance, visit Writing a golden file test for package:flutter.

Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing.

@ardera ardera force-pushed the feature/custom-device-improvements branch from fb909e1 to 8195220 Compare May 30, 2021 12:43
@HidenoriMatsubayashi
Copy link
Member

Great work! I have one feedback about custom-devices.schema.json. There may be some reason, but I thought enabled is more intuitive than disabled when I first saw it.

          "disabled": {
            "description": ~,
            "type": "boolean"
            "type": "boolean",
            "default": false
          },

@ardera
Copy link
Contributor Author

ardera commented May 30, 2021

Great work! I have one feedback about custom-devices.schema.json. There may be some reason, but I thought enabled is more intuitive than disabled when I first saw it.

Thanks! Yeah, the style guide also mentions this, I chose to ignore it because I thought it'd be weird for a field to default to "true" if omitted, but you're probably right I should've called it enabled instead. Also leads to some awkward double negatives in the code

I'll change it 👍

@ardera ardera changed the title [wip] [custom-devices] general improvements, add custom-devices subcommand, better error handling [custom-devices] general improvements, add custom-devices subcommand, better error handling Jun 3, 2021
@ardera ardera force-pushed the feature/custom-device-improvements branch from f6c028f to e30c32e Compare June 3, 2021 23:50
@ardera
Copy link
Contributor Author

ardera commented Jun 4, 2021

this should be ready to be reviewed now @jonahwilliams (just fyi)

@jonahwilliams jonahwilliams self-requested a review June 4, 2021 00:52
@jonahwilliams
Copy link
Contributor

Awesome, will take a look at this tomorrow!

Copy link
Contributor

@jonahwilliams jonahwilliams left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still looking through this one, just some initial feedback

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure what this means

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A config with a null runDebug command would be invalid, a config with ["dawdawaw"] as the runDebug command would be valid, but wouldn't work

So you can use the --check option to make sure it the config actually works, which will execute some of the commands of the config with dummy arguments and see if they succeed.

But if you have to ask to understand it, that's probably a good sign the help isn't helpful enough 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I updated the help, is it better?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahh I see. In this case, it is better to either leave off the value help or provide an actual example of the data you would pass : valueHelp: '{...};. That might be too much for the CLI help option

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay, I changed the valueHelp to {"id": "pi", ...} now

@jonahwilliams jonahwilliams self-requested a review June 15, 2021 16:42
Copy link
Contributor

@jonahwilliams jonahwilliams left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FallThroughError should be an Exception type if it is intended to be caught.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahh I see. In this case, it is better to either leave off the value help or provide an actual example of the data you would pass : valueHelp: '{...};. That might be too much for the CLI help option

@ardera ardera force-pushed the feature/custom-device-improvements branch 2 times, most recently from df79296 to 6fb0d02 Compare June 27, 2021 12:03
@ardera ardera requested review from Piinks and jmagman as code owners June 27, 2021 12:03
@google-cla
Copy link

google-cla bot commented Jun 27, 2021

All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter.

We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only @googlebot I consent. in this pull request.

Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the cla label to yes (if enabled on your project).

ℹ️ Googlers: Go here for more info.

@google-cla google-cla bot added cla: no and removed cla: yes labels Jun 27, 2021
@ardera ardera force-pushed the feature/custom-device-improvements branch from 6fb0d02 to 576c39d Compare June 27, 2021 15:15
@google-cla google-cla bot added cla: yes and removed cla: no labels Jun 27, 2021
@ardera
Copy link
Contributor Author

ardera commented Jun 27, 2021

FallThroughError should be an Exception type if it is intended to be caught.

I see, in the one instance where I throw it, it's not intended to be caught (I mean I don't know what to do when the command is run on something other than macOS, windows or linux)

Also I did something wrong while rebasing (somehow I rebased master on top of custom-device-improvements instead of the other way around), all the master commits showed up in this PR and somehow the bot requested two authors of the commits for review. Maybe you can remove the two from the reviewer list? @jonahwilliams

ardera added 5 commits June 27, 2021 17:23
- make CustomDeviceConfig throw `JsonRevivalException` when it couldn't load the config.
- make CustomDevicesConfig log those JsonRevivalExceptions
- make CustomDevicesConfig log other config loading errors
- add tests for CustomDevicesConfig for testing those errors
- implement more dataclass-like methods for CustomDeviceConfig
- make CustomDeviceConfig immutable
- improve default pingSuccessRegex
- move some common stuff from the custom device tests into a custom_devices_common.dart
- fix some formatting issues
- hookup track-widget-creation and tree-shake-icons options
- hookup runtime engine options
ardera and others added 14 commits June 27, 2021 17:23
- use ErrorHandlingFilesystem to delete file
- use OperatingSystemUtils to find a free port
- improve the custom-devices add help a bit
… doesn't exist, and return false when that's the case

- in test, match config file contents after executing custom-devices reset
- add test for correct custom-devices reset message
…m_devices_config_test.dart

Co-authored-by: Jonah Williams <[email protected]>
- make config backup function synchronous
@ardera ardera force-pushed the feature/custom-device-improvements branch from 576c39d to ec88744 Compare June 27, 2021 15:24
@zanderso
Copy link
Member

zanderso commented Jul 1, 2021

@ardera Is this ready for another review pass?

FYI @eseidel

@ardera
Copy link
Contributor Author

ardera commented Jul 1, 2021

@zanderso yep it's ready

@zanderso zanderso requested a review from jonahwilliams July 1, 2021 22:40
Copy link
Contributor

@jonahwilliams jonahwilliams left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zanderso
Copy link
Member

zanderso commented Jul 7, 2021

@ardera I would love to see an article in our Wiki (to start) with a tutorial on how to use this.

@ardera
Copy link
Contributor Author

ardera commented Jul 8, 2021

@ardera I would love to see an article in our Wiki (to start) with a tutorial on how to use this.

sure, good idea!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

tool Affects the "flutter" command-line tool. See also t: labels.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[custom devices] review & improve usability

5 participants