git.iko.soy/rowtype-yoga/package-sets
on psc-0.14.5-20211116 help sign in
rowtype-yoga/package-sets/verify-registry.sh
42 lines 1.6 kB history raw
1#!/usr/bin/env nix-shell
2#!nix-shell -i bash
4set -euo pipefail
6# This script performs various sanity checks to ensure the packages here match the ones in the registry
8wget -q https://raw.githubusercontent.com/purescript/registry/master/new-packages.json
9wget -q https://raw.githubusercontent.com/purescript/registry/master/bower-packages.json
11REGISTRY=$(cat bower-packages.json new-packages.json | jq -s '.[0] * .[1] | to_entries | map({(.key | sub("purescript-";"")): .value }) | add')
12REGISTRY_PKGS=$(cat bower-packages.json new-packages.json | jq -s 'map(keys) | add | unique | map (sub("purescript-";""))')
14rm new-packages.json bower-packages.json
16# Check that all the packages in the set are present in the registry
18PKGSET=$(cat packages.json | jq -s 'map(keys) | add')
20RESULT=$(jq -n --argjson registry "${REGISTRY_PKGS}" --argjson pkgset "${PKGSET}" '$pkgset-$registry')
22if [ "${RESULT}" == "[]" ]; then
23 echo "[SUCCESS] All packages are in the registry"
24else
25 echo "[ERROR] Found some packages not in the registry:"
26 echo $RESULT
27 exit 1
28fi
30# Check that all the urls here match with the registry
32PKGSET_URLS=$(cat packages.json | jq 'to_entries | map({(.key) : .value.repo}) | add')
34RESULT=$(jq -n --argjson registry "${REGISTRY}" --argjson pkgset "${PKGSET_URLS}" '($pkgset | to_entries)-($registry | to_entries) | map({package: .key, package_sets_url: .value, registry_url: $registry[.key]})')
36if [ "${RESULT}" == "[]" ]; then
37 echo "[SUCCESS] All package URLs are matching the Registry"
38else
39 echo "[ERROR] Found some packages with URL differing from the registry:"
40 jq -n --argjson res "${RESULT}" '$res'
41 exit 1
42fi