Closed RobjS closed 3 years ago
@brent-dxw If you'd e.g. added a new plugin to whippet.json
, but not yet run whippet deps update
, I'd expect the validate command to fail at that point because the two files aren't aligned (i.e. whippet.lock
isn't reflecting the intention of whippet.json
, which is to install the new plugin). Is that what you meant? There may be another scenario I'm missing.
@brent-dxw If you'd e.g. added a new plugin to
whippet.json
, but not yet runwhippet deps update
, I'd expect the validate command to fail at that point because the two files aren't aligned (i.e.whippet.lock
isn't reflecting the intention ofwhippet.json
, which is to install the new plugin). Is that what you meant? There may be another scenario I'm missing.
Yes, that scenario. Ok, so that makes sense as expected behaviour, as in its validating the further steps.
This PR adds a new
whippet dependencies validate
command. It checks the contents ofwhippet.json
andwhippet.lock
against one another, and throws an error if:whippet.lock
is not what would be expected based on the contents ofwhippet.json
(the hash is based on a sha ofwhippet.json
's contents)This should allow us to run
whippet deps validate
in a CI environment and pick up any problems with thewhippet.json
orwhippet.lock
files much sooner than we currently do (i.e. when a PR is opened) - currently, those things are only picked up when an attemptedwhippet app deploy
fails (i.e. after everything is merged and the project is attempting to deploy).I've introduced Kahlan to write the tests for the new
Validator
class. Previously, we were only using PHPUnit, but that is painful to use and results in much less readable tests. We should probably migrate the PHPUnit tests into Kahlan at some point, but that's beyond the scope of this PR.