forked from mermaid-js/mermaid
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run
executable file
·105 lines (76 loc) · 2.8 KB
/
run
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
#!/bin/bash
RUN="docker compose run --rm"
ansi() { echo -e "\e[${1}m${*:2}\e[0m"; }
bold() { ansi 1 "$@"; }
# italic() { ansi 3 "$@"; }
underline() { ansi 4 "$@"; }
# strikethrough() { ansi 9 "$@"; }
# red() { ansi 31 "$@"; }
name=$(basename $0)
command=$1
args=${@:2}
case $command in
build)
docker compose build $args
;;
sh)
$RUN mermaid sh
;;
pnpm)
$RUN mermaid sh -c "pnpm $args"
;;
dev)
$RUN --service-ports mermaid sh -c "pnpm run dev"
;;
docs:dev)
$RUN --service-ports mermaid sh -c "pnpm run --filter mermaid docs:dev:docker"
;;
cypress)
$RUN cypress $args
;;
help)
# Alignment of help message must be as it is, it will be nice looking when printed
usage=$(
cat <<EOF
$(bold MERMAID LOCAL DOCKER DEVELOPMENT)
Welcome! Thank you for joining the development.
This is a script for running commands within docker containers at ease.
__________________________________________________________________________________________
Development Quick Start Guide:
$(bold ./$name pnpm install) # Install packages
$(bold ./$name dev) # Launch dev server with examples, open http://localhost:9000
$(bold ./$name docs:dev) # Launch official website, open http://localhost:3333
$(bold ./$name pnpm vitest) # Run watcher for unit tests
$(bold ./$name cypress) # Run integration tests (after starting dev server)
$(bold ./$name pnpm build) # Prepare it for production
__________________________________________________________________________________________
Commands:
$(bold ./$name build) # Build image
$(bold ./$name cypress) # Run integration tests
$(bold ./$name dev) # Run dev server with examples, open http://localhost:9000
$(bold ./$name docs:dev) # For docs contributions, open http://localhost:3333
$(bold ./$name help) # Show this help
$(bold ./$name pnpm) # Run any 'pnpm' command
$(bold ./$name sh) # Open 'sh' inside docker container for development
__________________________________________________________________________________________
Examples of frequiently used commands:
$(bold ./$name pnpm add --filter mermaid) $(underline package)
Add package to mermaid
$(bold ./$name pnpm -w run lint:fix)
Run prettier and ES lint
$(bold git diff --name-only develop \| xargs ./$name pnpm prettier --write)
Prettify everything you added so far
$(bold ./$name cypress open --project .)
Open cypress interactive GUI
$(bold ./$name cypress run --spec cypress/integration/rendering/)$(underline test.spec.ts)
Run specific test in cypress
$(bold xhost +local:)
Allow local connections for x11 server
EOF
)
echo -n -e "$usage"
;;
*)
$name help
;;
esac