-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompile
executable file
·68 lines (54 loc) · 2.33 KB
/
compile
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
#!/usr/bin/env bash
self() {
DIR=$( cd "$( dirname "$0" )/" && pwd)
echo $DIR
}
eval $(./scripts/colors | sed 's/\(.*\)=\(.*\)/export \1="\2"/g')
clear
echo
./scripts/banner
echo
echo -e " ${BLUE}Linting...${END}"
npm run lint
if [[ "$?" -gt "0" ]]; then
# Linting error
exit 1
fi
echo -e " ${BLUE}Compiling TypeScript files to Javascript...${END}"
tsfiles=$(ls $(self)/contracts/*.ts|rev|cut -d '.' -f 2-100|rev|xargs -I___ echo " > ${PURPLE}___.ts${END}\n < ${GREEN}___.js${END}")
numtsfiles=$(echo "$tsfiles"|wc -l|xargs)
echo -e " - Found ${GREEN}${numtsfiles}${END} .ts file(s)"
grepwhat=".*$1.*"
if [[ "$numtsfiles" -gt 0 ]]; then
# --external:./contracts/GlobalJSHooksAPI.ts
ls $(self)/contracts/*.ts|grep -i -E "$grepwhat"|rev|cut -d '.' -f 2-100|rev|xargs -I___ echo "npm run compile -- ___.ts --outfile=___.js "|bash # ___.ts --outFile ___-tsc.js
echo -e "$tsfiles"|grep -i -E "$grepwhat"
fi
# exit 0
echo
# docker exec jshooks-build /quickjslite/qjsc /contracts/bla-tsc.js
echo -e " ${BLUE}Compiling JS files to binary Hook files ${GREEN}(.bc)${BLUE}...${END}"
jsfiles=$(ls $(self)/contracts/*.js|grep -i -E "$grepwhat"|rev|cut -d '.' -f 2-100|cut -d '/' -f 1|rev|xargs -I___ echo " > ${PURPLE}$(self)/contracts/___.js${END}")
numjsfiles=$(echo "$jsfiles"|wc -l|xargs)
echo -e " - Found ${GREEN}${numjsfiles}${END} .js file(s)"
if [[ "$numjsfiles" -gt 0 ]]; then
echo -e "$jsfiles"
rm -f $(self)/build/*.bc
rm -f $(self)/build/*.bc.raw
echo -e " - Compiled:${GREEN}"
ls $(self)/contracts/*.js|grep -i -E "$grepwhat"|rev|cut -d '.' -f 2-100|cut -d '/' -f 1|rev|xargs -I___ echo "docker exec jshooks-build sh /qjsc-compile.sh ___.js"|bash
echo -e "${END}"
fi
echo " You can now deploy by issuing:"
echo " ./deploy {contract} {account}"
echo
echo " For example:"
echo -e " ./deploy ${BLUE}somecontract${END} ${PURPLE}ryouhapPYV5KNHmFUKrjNqsjxhnxvQiVt${END}"
echo
echo -e " By default, a Hook will be deployed with namespace ${RED}0000..0000${END} (64x), flag ${RED}1${END}"
echo -e " and hookon ${RED}0000ffff..ffff7000000000000000000400000${END} (all transactions)."
echo -e " If you want to change these settings, deploy with environment variables:"
echo -e " ${CYAN}HOOKON=...${END}"
echo -e " ${CYAN}FLAGS=...${END}"
echo -e " ${CYAN}NAMESPACE=...${END}"
echo