Closed joncfoo closed 3 years ago
Thanks @joncfoo! That looks excellent and will be a good addition for this. Could you add few lines to the README file about this as well and I'll merge this in and release new versions.
🎉 I've updated the readme with the usage and examples.
Thanks @joncfoo. This is now released as version 0.3.0
Problem
The tool does not support validating multiple files at once.
Solution
Introduce a CLI that makes it possible to validate several files at once.
Notes
We first tried to wrap the invocation of this tool in a shell script, calling it once per file we needed to validate. With ~400 files it took ~6m30s to complete which felt too long.
We speculated that the bulk of the time being spent during a single execution was in the
Ajv
schema-validation compile phase. We hacked up a script to validate our suspicion and indeed found it to be true. We were able to validate ~400 files in ~6s; with the schema-validation compile happening once (It looks likeAjv
caches compilation; calling it a second time is pretty fast).The choice to use
minimist
was based on introducing the least number of dependencies.There are two ways to provide files to validate:
We chose not to include a file-finder/globber as we felt that role was best left to other tools. e.g. via shell globbing
validate-entity catalog/**/*.yaml
, or piped inputfind ./catalog/ -name '*.yaml' -or -name '*.yml' | validate-entity -i
Validating several files at once produces a lot of output. To that end, a
quiet
option was introduced to control the verbosity of existing logging statements.Care was taken to not introduce changes to the existing CLI interface which expects a single file to validate.
CLI usage: