dojo / cli

:rocket: Dojo - command line tooling.
http://dojo.io
Other
26 stars 34 forks source link

.dojorc validation #241

Closed JamesLMilner closed 6 years ago

JamesLMilner commented 6 years ago

Enhancement

Some CLI tools that rely on configs will do validation on those configs to ensure they are correct. For example Webpack does this:

screenshot_20180710_141137

I'm not entirely sure how this would be achieved, so I thought I'd open that up for discussion. Happy to look into implementing once there is consensus on the best approach.

Code

I would imagine the interface would be something like this:

dojo validate

or for example

dojo build

Throws an error if .dojorc doesn't match a specified schema

mwistrand commented 6 years ago

One option would be a dedicated validate command alongside a validate method on the Command interface (which is how eject is handled). Each cli package would specify an optional validate method on the Command object it exports, and at the very least that would be executed with $ dojo validate. Additionally, the command-level validate could also be executed each time the command itself is invoked (e.g., $ dojo build would also validate the "build-app" config).