forked from okta/okta-developer-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathupdate-error-codes.sh
More file actions
61 lines (50 loc) · 1.1 KB
/
Copy pathupdate-error-codes.sh
File metadata and controls
61 lines (50 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/usr/bin/env bash
# See https://bit.ly/2WRXVta for details
# Strict
set -o errexit -o pipefail
# Constants
readonly url=https://bit.ly/3i5eThn
readonly archive=/tmp/api-errors.zip
readonly file=error-codes.json
readonly dir=packages/@okta/vuepress-site/data
main() {
error-codes-download
echo
error-codes-update
echo
error-codes-diff
}
error-codes-download() {
banner "Downloading jar from $url..."
curl -k -L $url > $archive || die "Could not download file"
}
error-codes-update() {
banner "Updating $file..."
unzip -o $archive api-errors.json -d $dir || die "Could not unzip file"
mv $dir/api-errors.json $dir/$file
rm $archive
}
error-codes-diff() {
banner "Showing differences in $file..."
git --no-pager diff $dir/$file || die "Could not diff file"
}
banner() {
local -r line=$(printf -- '-%.0s' {1..100}); status $line; status "$1"; status $line;
}
status() {
green "$1";
}
die() {
red "${1:-Exiting}" >&2 && exit 1;
}
green() {
ansi 32 "$@";
}
red() {
ansi 91 "$@";
}
ansi() {
echo -e "\033[${1}m${*:2}\033[0m";
}
# Entry point
main