-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathno.sh
executable file
·144 lines (120 loc) · 2.78 KB
/
no.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#!/bin/bash
# ------------------------------------------------------------------
# [Author] Bryan McGrane
# [Title] Sensory Cloud Node SDK Helper Script
# ------------------------------------------------------------------
SUBJECT=no
USAGE="Usage: no [OPTIONS] [COMMAND]"
OPTIONS="
Options:\n
-h\t Helper Script Description
"
COMMANDS="
Commands:\n
build | b\t\t Build Tsc Package\n
publish | p\t\t Publish Tsc Package\n
genproto | gp\t\t Generate Proto Files\n
help | h\t\t Display a Help Message\n
"
# --- Initialization -----------------------------------------------
set -euo pipefail
# --- Functions ----------------------------------------------------
print_helper() {
echo
echo ${USAGE}
echo
echo -e ${OPTIONS}
echo
echo -e ${COMMANDS}
}
throw_not_implemented_error() {
echo "This feature is not yet implemented!"
exit 125;
}
generate_proto_files() {
echo "Generating proto files"
npm install -g grpc-tools
npm install grpc_tools_node_protoc_ts --save-dev
cd proto/
PROTOC_GEN_TS_PATH="../node_modules/.bin/protoc-gen-ts"
for x in $(find . -iname "*.proto");
do
grpc_tools_node_protoc \
--plugin=protoc-gen-ts=${PROTOC_GEN_TS_PATH} \
--ts_out=grpc_js:../src/generated \
--js_out=import_style=commonjs:../src/generated \
--grpc_out=grpc_js:../src/generated \
$x
echo "Generated grpc code for $x";
done
cd ..
}
build() {
echo "Building Sensory Cloud Web SDK"
generate_proto_files
mkdir -p ./dist/generated
cp -r ./src/generated ./dist
npx tsc
cp -r ./dist/generated ./build/main
}
# --- Environment --------------------------------------------------
IMAGE=ph
CONTAINER=ph_web
CURRENT_BRANCH=${CI_COMMIT_BRANCH:-$(git rev-parse --symbolic-full-name --abbrev-ref HEAD)}
# --- Options processing -------------------------------------------
if [ $# == 0 ] ; then
print_helper
exit 1;
fi
while getopts ":h" optname
do
case "$optname" in
"h")
print_helper
;;
"?")
echo "Unknown option $OPTARG"
exit 0;
;;
":")
echo "No argument value for option $OPTARG"
exit 0;
;;
*)
echo "Unknown error while processing options"
exit 0;
;;
esac
done
shift $(($OPTIND - 1))
# --- Body --------------------------------------------------------
case "$1" in
"lint"|"l")
ng lint --fix
;;
"build"|"b")
build
;;
"test"|"t")
npx nyc --silent ava
;;
"publish"|"p")
build
if [ "$1" == "-login" ]; then
npm login
fi
npm publish --access public
;;
"genproto"|"gp")
generate_proto_files
exit 0;
;;
"help"|"h")
print_helper
;;
*)
print_helper
exit 0;
;;
esac
# -----------------------------------------------------------------