-
Notifications
You must be signed in to change notification settings - Fork 20
/
run_test.sh
executable file
·155 lines (129 loc) · 4.15 KB
/
run_test.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
145
146
147
148
149
150
151
152
153
154
155
#!/usr/bin/env bash
set -e
TEMPLATE_PATH="/tmp"
APP_NAME="forum"
TEMPLATE_NAME=
SCOPE=
# parse args
while getopts ":t:s:" opt; do
case $opt in
t) TEMPLATE_NAME="$OPTARG" ;;
s) SCOPE="$OPTARG" ;;
\?)
echo "Invalid option: -$OPTARG" >&2
exit 1
;;
:)
echo "Option -$OPTARG requires an argument." >&2
exit 1
;;
esac
done
cleanup_tmp() {
rm -rf "${TEMPLATE_PATH:?}/$1"
}
print_version() {
echo "$(hc-scaffold --version)"
}
setup_and_build_happ() {
print_version
cleanup_tmp "$1"
cd $TEMPLATE_PATH
hc-scaffold --template="$2" web-app "$1" --package-manager pnpm --setup-nix true -F
cd "$1"
hc-scaffold dna forum
hc-scaffold zome posts --integrity dnas/forum/zomes/integrity/ --coordinator dnas/forum/zomes/coordinator/
hc-scaffold entry-type post --reference-entry-hash false --crud crud --link-from-original-to-each-update true --fields title:String:TextField,content:String:TextArea
hc-scaffold entry-type comment --reference-entry-hash false --crud crud --link-from-original-to-each-update false --fields post_hash:ActionHash::Post
hc-scaffold entry-type like --reference-entry-hash false --crud crd --fields like_hash:Option\<ActionHash\>::Like,string_list:Vec\<String\>
hc-scaffold entry-type certificate --reference-entry-hash true --crud cr --fields post_hash:ActionHash::Post,agent:AgentPubKey::certified,certifications_hashes:Vec\<EntryHash\>::Certificate,certificate_type:Enum::CertificateType:TypeOne.TypeTwo,dna_hash:DnaHash
hc-scaffold collection global all_posts post
hc-scaffold collection by-author posts_by_author post
hc-scaffold collection global all_likes like
hc-scaffold collection global all_posts_entry_hash post:EntryHash
hc-scaffold collection by-author posts_by_author_entry_hash post:EntryHash
hc-scaffold link-type post like --delete true --bidirectional false
hc-scaffold link-type comment like:EntryHash --delete true --bidirectional true
hc-scaffold link-type certificate:EntryHash like --delete false --bidirectional false
hc-scaffold link-type agent:creator post:EntryHash --delete false --bidirectional true
nix develop --command bash -c "
set -e
pnpm install
pnpm --filter ui build
pnpm test
pnpm package
"
cd ..
}
setup_and_build_hello_world() {
print_version
cleanup_tmp hello-world
cd $TEMPLATE_PATH
hc-scaffold example --package-manager pnpm hello-world
cd hello-world
nix develop --command bash -c "
set -e
pnpm install
pnpm test
"
cd ..
}
if [[ -n "$SCOPE" ]]; then
case "$SCOPE" in
"hello_world")
setup_and_build_hello_world
;;
"holo_integration")
rm -rf /tmp/holo-flake
cd /tmp
hc-scaffold --template vue web-app --package-manager yarn holo-flake --setup-nix true -F
cd holo-flake
nix develop --command bash -c "
set -e
# Check if holo-dev-server is in the path
if command -v holo-dev-server >/dev/null 2>&1; then
echo 'holo-dev-server is available in the PATH while it should not'
exit 1
else
echo 'holo-dev-server is NOT available in the PATH'
fi
"
rm -rf /tmp/holo-flake
cd /tmp
hc-scaffold --template vue web-app --package-manager yarn holo-flake --setup-nix true --holo -F
cd holo-flake
nix develop --command bash -c "
set -e
# Check if holo-dev-server is in the path
if command -v holo-dev-server >/dev/null 2>&1; then
echo 'holo-dev-server is available in the PATH'
else
echo 'holo-dev-server is NOT available in the PATH'
exit 1
fi
"
rm -rf /tmp/holo-flake
cd /tmp
;;
*)
echo "Error: SCOPE must be one of 'hello_world', 'holo_integration', but got $SCOPE."
exit 1
;;
esac
exit 0 # Exit early
fi
if [[ -z "$APP_NAME" || -z "$TEMPLATE_NAME" ]]; then
echo "Error: APP_NAME and TEMPLATE_NAME environment variables must be set."
exit 1
fi
case "$TEMPLATE_NAME" in
"svelte" | "lit" | "vue" | "react" | "vanilla")
# Valid template name, proceed
;;
*)
echo "Error: TEMPLATE_NAME must be one of 'svelte', 'lit', 'vue', 'react' or 'vanilla'."
exit 1
;;
esac
cleanup_tmp "$APP_NAME"
setup_and_build_happ "$APP_NAME" "$TEMPLATE_NAME"