microsoft / devicescript

TypeScript for Tiny IoT Devices (ESP32, RP2040, ...)
https://microsoft.github.io/devicescript/
MIT License
3.23k stars 111 forks source link

Add prompts to ask user about installing additional but required packages #653

Closed dawiidio closed 7 months ago

dawiidio commented 8 months ago

It's just a small change but can improve flow while using cli.

When using devs devtools src/main.ts with "native" OS transports (eg: usb or serial - not via dashboard and WebUSB) user must specify transport by passing one of the following options

-u, --usb             listen to Jacdac over USB (requires usb)
-s, --serial          listen to Jacdac over SERIAL (requires serialport)
-i, --spi             listen to Jacdac over SPI (requires rpio, experimental)

all the above options require additional packages, that's why now you can install required package without leaving current process. Cli will detect if any of native transports is enabled and if required package is not installed will prompt question like the below one:

...
Install package "serialport" (Y/n)?
Installing package "serialport" ...
Package "serialport" installed!
...

after installation normal process flow will be restored with installed dependencies ready to use.

dawiidio commented 8 months ago

@microsoft-github-policy-service agree

pelikhan commented 8 months ago

This is a great start! My advice is to keep you PRs very focused on a single feature. If you find a bug along the way, move it out to a different PR so that it can be merged separately.

The formatting issue is annoying (the added ,) maybe we can fix this before this PR so that it is "just a formatting PR".

A few more comments:

👍 keep going!

dawiidio commented 8 months ago

@pelikhan

when the native package is missing and the cli is in vscode mode, we should send a side channel message to vscode so that the install flow is gone through vscode UI (future PR)

sure, I can add this communication in next pr. Maybe you know, when cli is in vscode mode it opens some additional socket channel to communicate with plugin?

pelikhan commented 8 months ago

@pelikhan

when the native package is missing and the cli is in vscode mode, we should send a side channel message to vscode so that the install flow is gone through vscode UI (future PR)

sure, I can add this communication in next pr. Maybe you know, when cli is in vscode mode it opens some additional socket channel to communicate with plugin?

Search for export function sendEvent<T extends SideEvent>( to see how to send an event from the CLI, and subSideEvent<SideOutputEvent> to receive that even on the vscode side

pelikhan commented 8 months ago

I've added a common linting task in package.json and also a dep on prettier so that we run the same version. You should be able to merge origin/main and it'll fix the whitespace/comma changes.

pelikhan commented 8 months ago

Merge origin/main, run yarn install and run yarn lint to run prettier

pelikhan commented 8 months ago

@dawiidio i've added a commit (https://github.com/microsoft/devicescript/commit/4372a1464ed26dc3e8c9f0e7a7bafc6b2987948c) to prep for this change. You can squeeze in the interactive piece of your changes in the TODO I left. Might be easier to start a new PR though.

pelikhan commented 7 months ago

Thank you @dawiidio , your PR has made it into https://github.com/microsoft/devicescript/pull/656