-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerate.sh
executable file
·86 lines (74 loc) · 2.22 KB
/
generate.sh
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
die()
{
local _ret="${2:-1}"
test "${_PRINT_HELP:-no}" = yes && print_help >&2
echo "$1" >&2
exit "${_ret}"
}
begins_with_short_option()
{
local first_option all_short_options='sh'
first_option="${1:0:1}"
test "$all_short_options" = "${all_short_options/$first_option/}" && return 1 || return 0
}
# THE DEFAULTS INITIALIZATION - OPTIONALS
_arg_skip_fetch="off"
print_help()
{
printf '%s\n' "Eve ESI api client generator"
printf 'Usage: %s [-s|--(no-)skip-fetch] [-h|--help]\n' "$0"
printf '\t%s\n' "-s, --skip-fetch, --no-skip-fetch: do not fetch new spec if specified (off by default)"
printf '\t%s\n' "-h, --help: Prints help"
}
parse_commandline()
{
while test $# -gt 0
do
_key="$1"
case "$_key" in
-s|--no-skip-fetch|--skip-fetch)
_arg_skip_fetch="on"
test "${1:0:5}" = "--no-" && _arg_skip_fetch="off"
;;
-s*)
_arg_skip_fetch="on"
_next="${_key##-s}"
if test -n "$_next" -a "$_next" != "$_key"
then
{ begins_with_short_option "$_next" && shift && set -- "-s" "-${_next}" "$@"; } || die "The short option '$_key' can't be decomposed to ${_key:0:2} and -${_key:2}, because ${_key:0:2} doesn't accept value and '-${_key:2:1}' doesn't correspond to a short option."
fi
;;
-h|--help)
print_help
exit 0
;;
-h*)
print_help
exit 0
;;
*)
_PRINT_HELP=yes die "FATAL ERROR: Got an unexpected argument '$1'" 1
;;
esac
shift
done
}
parse_commandline "$@"
# OTHER STUFF GENERATED BY Argbash
### END OF CODE GENERATED BY Argbash (sortof) ### ])
# [ <-- needed because of Argbash
if [ $_arg_skip_fetch = "off" ]; then
curl 'https://esi.evetech.net/latest/swagger.json' \
-H 'accept: application/json,*/*' \
-H 'cache-control: no-cache' \
--compressed | jq > cfg/swagger.json
curl --data "@./cfg/swagger.json" \
'https://converter.swagger.io/api/convert' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
--compressed | yq -P > cfg/openapi3.yaml
cfg/replace.sh cfg/mappings.yaml cfg/openapi3.yaml
fi
openapi-generator-cli generate -i cfg/openapi3.yaml -c cfg/config.yaml -o . -g typescript-axios --git-user-id dariusbakunas --git-repo-id eve-esi-client
patch package.json < package.patch
yarn && yarn prettier