mermaid/run

70 lines
1.3 KiB
Plaintext
Raw Normal View History

#!/bin/bash
RUN="docker-compose run --rm"
2023-06-18 00:32:45 +02:00
# UP="docker-compose up"
name=$(basename $0)
command=$1
args=${@:2}
2023-06-18 00:32:45 +02:00
case $command in
sh)
2023-06-24 20:37:19 +02:00
$RUN mermaid sh $args
;;
2023-06-18 00:32:45 +02:00
i | install)
2023-06-18 00:32:45 +02:00
$RUN mermaid sh -c "npx pnpm install $args"
;;
2023-06-18 00:32:45 +02:00
add)
$RUN mermaid sh -c "npx pnpm -w add $args"
2023-06-18 00:32:45 +02:00
;;
2023-06-18 00:32:45 +02:00
test | vitest | e2e )
$RUN mermaid sh -c "npx pnpm $command $args"
2023-06-18 00:32:45 +02:00
;;
2023-06-19 03:29:41 +02:00
prettier)
$RUN mermaid sh -c "npx pnpm prettier --write $args"
;;
lint)
2023-06-19 03:29:41 +02:00
$RUN mermaid sh -c "npx pnpm -w run lint:fix $args"
;;
2023-06-18 00:32:45 +02:00
dev)
$RUN --service-ports mermaid sh -c "npx pnpm run dev"
# $UP --rm mermaid sh -c "npx pnpm run dev"
;;
help)
2023-06-18 00:32:45 +02:00
usage=$(
cat <<EOF
Run commonly used commands within docker containers
2023-06-18 00:32:45 +02:00
\033[1m$name install\033[0m # Equvalent of pnpm install
2023-06-18 00:32:45 +02:00
\033[1m$name dev\033[0m # Run dev server with examples, open http://localhost:9000
2023-06-18 00:32:45 +02:00
2023-06-18 00:32:45 +02:00
$name add # Add package, 'run add d3-sankey'
2023-06-19 03:34:41 +02:00
$name prettier # Prettify a file 'run prettier <path-to-file>'
2023-06-18 00:32:45 +02:00
$name lint # Equvalent of pnpm -w run lint:fix
$name test # Run unit tests
$name vitest # Run watcher for unit tests
$name e2e # Run integration tests
2023-06-18 00:32:45 +02:00
$name sh # Open sh inside docker container for development
$name help # Show this help
EOF
2023-06-18 00:32:45 +02:00
)
echo -n -e "$usage"
;;
*)
2023-06-18 00:32:45 +02:00
$name help
;;
2023-06-19 03:34:41 +02:00
esac