Debian Codegraph @

cli/scripts/vendor

raw symbols SCIP
1 #!/usr/bin/env bash
2
3 set -eu
4
5 TYP=$1
6
7 usage() {
8 echo "usage: ./scripts/vendor <init|update|validate|outdated>"
9 exit 1
10 }
11
12 if [ -z "$TYP" ]; then
13 usage
14 fi
15
16 update() {
17 (set -x ; go mod tidy -modfile=vendor.mod; go mod vendor -modfile=vendor.mod)
18 }
19
20 validate() {
21 diff=$(git status --porcelain -- vendor.mod vendor.sum vendor)
22 if [ -n "$diff" ]; then
23 echo >&2 'ERROR: Vendor result differs. Vendor your package with "make -f docker.Makefile vendor"'
24 echo "$diff"
25 exit 1
26 fi
27 }
28
29 outdated() {
30 if [ ! -x "$(command -v go-mod-outdated)" ]; then
31 echo "go-mod-outdated not found. Install with 'go install github.com/psampaz/[email protected]'"
32 exit 1
33 fi
34 (set -x ; go list -mod=vendor -mod=readonly -modfile=vendor.mod -u -m -json all | go-mod-outdated -update -direct)
35 }
36
37 case $TYP in
38 "update")
39 update
40 ;;
41 "validate")
42 update
43 validate
44 ;;
45 "outdated")
46 outdated
47 ;;
48 *)
49 echo >&2 "Unknown type $TYP"
50 exit 1
51 ;;
52 esac