garden
garden copied to clipboard
Dev command interface changes
The dev
command currently builds, deploys and runs tests on every file change. This is a bit much for many common use-cases.
An alternative would be a dev
command with an interface where "build/deploy/test on every file change" (watching) can be toggled on or off (for all or any subset of these), and where builds, deploys and tests could also be manually triggered.
Each of these toggles/operations could be triggered with a keystroke, or a series of keystrokes. For example:
-
wa
to turn on watching for all task types -
wn
to turn off watching for all task types -
wd
to toggle deploys on file change -
d
to trigger deploys for changed modules -
t
to run tests
And so on. Or just stick to single-key operations for now (w
to toggle watching, b
, d
and t
for building, deploying and running tests, respectively). The available keystrokes could be displayed in a persistent bottom row in the terminal.
When watch is disabled, we should probably still hot reload on every file change (just skip every other task type).
Maybe later we could implement a simple, menu-like interface to display the keystrokes available in the current context (e.g. the choices once w
has been typed).
Implementation
CLI/front-end
We should be able to use the existing fancy logger to display the persistent keystroke guide-line, so hopefully we wouldn't have to get into any new, elaborate terminal rendering exercises here.
CLI/framework
We'd have to add a mechanism for running commands to receive CLI input, if we don't already have one.
The DevCommand
class would have to be rewritten to hold the watch toggle state (and to add the appropriate tasks depending on that state), and to respond to incoming keyboard events.
The "one-off requests" (build, deploy or test) should result in a processTasks
call with the needed tasks. These would be computed based on all the modules that have changed since the last one-off operation (or since the last watch change that occurred while watching was toggled on). None of these changes to the DevCommand
should be particularly complex.
Discussion
Is this general approach something that would be of value to users? How much work would it be to implement?
I absolutely would love to see this implemented. It will be very useful when setting up a new module or doing the initial configuration part. I would personally prefer to
just stick to single-key operations for now (w to toggle watching, b, d and t for building, deploying and running tests, respectively). The available keystrokes could be displayed in a persistent bottom row in the terminal.
and I personally like how jest handles the watch mode (see below).
Big +1
The dev command semantics were changed in #3671. The new dev command will be released in 0.13
. Closing this.