generated from ChainSafe/typescript-lib-template
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathblack_box_test_helpers.sh
executable file
·81 lines (67 loc) · 1.67 KB
/
black_box_test_helpers.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
#!/usr/bin/env bash
ORIGARGS=("$@")
helpFunction() {
echo "Usage: $0 [start|stop|startBackgroundAndPublish|runTests] [background]"
exit 1 # Exit script after printing help
}
start() {
. scripts/env.sh
if [[ ${ORIGARGS[1]} == "background" ]]; then
startBackground
else
echo "Starting verdaccio..."
docker run -it --rm --name verdaccio -p 4873:4873 verdaccio/verdaccio
fi
}
startBackground() {
echo "Starting verdaccio in background..."
docker run -d --rm --name verdaccio -p 4873:4873 verdaccio/verdaccio
}
stop() {
echo "Stopping verdaccio ..."
docker ps -q --filter ancestor="verdaccio/verdaccio" | xargs -r docker stop
}
createVerdaccioNPMUser() {
curl -XPUT \
-H "Content-type: application/json" \
-d '{ "name": "test", "password": "test" }' \
'http://localhost:4873/-/user/org.couchdb.user:test'
}
loginNPMUser() {
npx npm-auth-to-token \
-u test \
-p test \
-e test@test.com \
-r http://localhost:4873
}
yarnPublish() {
yarn publish \
--new-version 9.9.9 \
--no-git-tag-version \
--tag blackbox \
--registry http://localhost:4873
}
publish() {
echo "Publishing to verdaccio ..."
npx wait-port -t 60000 4873
createVerdaccioNPMUser
loginNPMUser
yarn build
yarnPublish
}
startBackgroundAndPublish() {
startBackground && publish
}
runTests() {
cd test/black_box
yarn --update-checksums
yarn install
yarn test
}
case $1 in
start) start ;;
stop) stop ;;
startBackgroundAndPublish) startBackgroundAndPublish ;;
runTests) runTests ;;
*) helpFunction ;; # Print helpFunction in case parameter is non-existent
esac