2023-06-11 01:15:31 +03:00
|
|
|
#!/bin/bash
|
|
|
|
RUN="docker-compose run --rm"
|
2023-06-18 01:32:45 +03:00
|
|
|
|
|
|
|
name=$(basename $0)
|
2023-06-11 01:15:31 +03:00
|
|
|
command=$1
|
|
|
|
args=${@:2}
|
|
|
|
|
|
|
|
case $command in
|
|
|
|
|
|
|
|
sh)
|
2023-06-25 01:18:38 +03:00
|
|
|
$RUN mermaid sh -c "npx $args"
|
2023-06-11 01:15:31 +03:00
|
|
|
;;
|
|
|
|
|
2023-06-27 14:11:06 +03:00
|
|
|
pnpm)
|
|
|
|
$RUN mermaid sh -c "npx $command $args"
|
2023-06-11 01:15:31 +03:00
|
|
|
;;
|
|
|
|
|
2023-06-18 01:32:45 +03:00
|
|
|
dev)
|
|
|
|
$RUN --service-ports mermaid sh -c "npx pnpm run dev"
|
2023-06-25 01:18:38 +03:00
|
|
|
;;
|
|
|
|
|
|
|
|
docs:dev)
|
2023-06-29 15:24:09 +03:00
|
|
|
$RUN --service-ports mermaid sh -c "cd packages/mermaid/src/docs && npx pnpm prefetch && npx vitepress --port 3333 --host"
|
2023-06-18 01:32:45 +03:00
|
|
|
;;
|
|
|
|
|
2023-06-11 01:15:31 +03:00
|
|
|
help)
|
2023-06-29 19:51:46 +03:00
|
|
|
|
|
|
|
# Alignment of help message must be as it is, it will be nice looking when printed
|
2023-06-18 01:32:45 +03:00
|
|
|
usage=$(
|
2023-06-11 01:15:31 +03:00
|
|
|
cat <<EOF
|
2023-06-27 14:11:06 +03:00
|
|
|
|
2023-06-29 20:16:25 +03:00
|
|
|
Welcome to Mermaid Local Docker Development
|
|
|
|
Script for runnign commands within docker containers.
|
|
|
|
__________________________________________________________________________________________
|
|
|
|
|
|
|
|
\033[1mDevelopment quick start guide\033[0m:
|
2023-06-11 01:15:31 +03:00
|
|
|
|
2023-06-27 14:43:35 +03:00
|
|
|
\033[1m$name pnpm install\033[0m # Install packages
|
|
|
|
\033[1m$name dev\033[0m # Run dev server with examples, open http://localhost:9000
|
2023-06-29 20:16:25 +03:00
|
|
|
\033[1m$name pnpm build\033[0m # Prepare it for production
|
|
|
|
\033[1m$name docs:dev\033[0m # Then add documentation, open http://localhost:3333
|
|
|
|
__________________________________________________________________________________________
|
2023-06-18 01:32:45 +03:00
|
|
|
|
2023-06-27 14:11:06 +03:00
|
|
|
Commands:
|
2023-06-11 01:15:31 +03:00
|
|
|
|
2023-06-27 14:43:35 +03:00
|
|
|
$name pnpm # Run any 'pnpm' command
|
|
|
|
$name dev # Run dev server with examples, open http://localhost:9000
|
|
|
|
$name docs:dev # For docs contributions, open http://localhost:3333
|
2023-06-27 14:11:06 +03:00
|
|
|
|
2023-06-27 14:43:35 +03:00
|
|
|
$name sh # Open 'sh' inside docker container for development
|
2023-06-18 01:32:45 +03:00
|
|
|
|
2023-06-27 14:43:35 +03:00
|
|
|
$name help # Show this help
|
2023-06-29 20:16:25 +03:00
|
|
|
__________________________________________________________________________________________
|
2023-06-27 14:11:06 +03:00
|
|
|
|
|
|
|
Examples of frequiently used commands:
|
|
|
|
|
2023-06-27 14:43:35 +03:00
|
|
|
$name pnpm add # Add package, 'run add d3-sankey'
|
2023-06-29 20:16:25 +03:00
|
|
|
$name pnpm prettier --write # Prettify a file 'run prettier <path-to-file>', e.g.:
|
|
|
|
# 'git diff --name-only develop | xargs run pnpm prettier --write'
|
2023-06-27 14:43:35 +03:00
|
|
|
$name pnpm test # Run unit tests
|
|
|
|
$name pnpm vitest # Run watcher for unit tests
|
|
|
|
$name pnpm e2e # Run integration tests
|
2023-06-11 01:15:31 +03:00
|
|
|
EOF
|
2023-06-18 01:32:45 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
echo -n -e "$usage"
|
2023-06-11 01:15:31 +03:00
|
|
|
;;
|
|
|
|
|
|
|
|
*)
|
2023-06-18 01:32:45 +03:00
|
|
|
$name help
|
2023-06-11 01:15:31 +03:00
|
|
|
;;
|
|
|
|
|
2023-06-19 04:34:41 +03:00
|
|
|
esac
|