diff --git a/validate.sh b/validate.sh index abe431c..651b17f 100755 --- a/validate.sh +++ b/validate.sh @@ -25,6 +25,24 @@ test_dependencies() { test_dep "sha256sum" test_dep "jq" test_dep "xargs" + test_dep "find" +} + +test_repository_structure() { + cd "${ROOTDIR}" + if [ ! -d "Repository" ]; then + print_clr ${ERROR} " Repository is missing expected 'Repository' folder" + exit 104 + fi + while read LINE; do + if ! [[ "$LINE" =~ ^Repository/[0-9]([.][0-9]){3}(/[^/]+){2}/[^/]+json$ ]]; then + error=$? + print_clr ${ERROR} " FAIL: Invalid path ${LINE}" + fi + done < <(find Repository/ -iname '*.json' -type f) + + [ ! -z "$error" ] && exit $error + print_clr ${SUCCESS} " SUCCESS: Repository directory structure" } check_sha256() { @@ -53,6 +71,7 @@ validate() { } test_dependencies +test_repository_structure for file in ${ROOTDIR}/**; do [ "${file: -5}" == ".json" ] && validate "${file}"