From 56fae02e3a3a99d9e957965a0b1e396b092376fa Mon Sep 17 00:00:00 2001 From: DavHau Date: Fri, 29 Jul 2022 21:59:20 +0200 Subject: [PATCH] feat: verify dream-lock.json against jsonschema --- src/specifications/dream-lock-schema.json | 4 ++-- src/utils/default.nix | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/specifications/dream-lock-schema.json b/src/specifications/dream-lock-schema.json index 098bc638..bdb964cc 100644 --- a/src/specifications/dream-lock-schema.json +++ b/src/specifications/dream-lock-schema.json @@ -97,8 +97,8 @@ }, "then": { "properties": { - "rootName": { "type": "string" }, - "rootVersion": { "type": "string" }, + "rootName": { "type": ["string", "null"] }, + "rootVersion": { "type": ["string", "null"] }, "path": { "type": "string" }, "type": { "type": "string" }, "dir": { "type": "string" } diff --git a/src/utils/default.nix b/src/utils/default.nix index 42a6f89a..0c06cb08 100644 --- a/src/utils/default.nix +++ b/src/utils/default.nix @@ -232,6 +232,12 @@ in | python3 ${../apps/cli/format-dream-lock.py} \ | sponge $dreamLockPath + # validate dream-lock.json against jsonschema + ${python3.pkgs.jsonschema}/bin/jsonschema \ + --instance $dreamLockPath \ + --output pretty \ + ${../specifications/dream-lock-schema.json} + # add dream-lock.json to git if git rev-parse --show-toplevel &>/dev/null; then echo "adding file to git: $dreamLockPath"