2023-06-11 01:15:31 +03:00
|
|
|
#!/bin/bash
|
|
|
|
RUN="docker-compose run --rm"
|
2023-06-18 01:32:45 +03:00
|
|
|
# UP="docker-compose up"
|
|
|
|
|
|
|
|
name=$(basename $0)
|
2023-06-11 01:15:31 +03:00
|
|
|
command=$1
|
|
|
|
args=${@:2}
|
|
|
|
|
2023-06-18 01:32:45 +03:00
|
|
|
|
2023-06-11 01:15:31 +03:00
|
|
|
case $command in
|
|
|
|
|
|
|
|
sh)
|
2023-06-18 01:32:45 +03:00
|
|
|
$RUN --service-ports mermaid sh $args
|
2023-06-11 01:15:31 +03:00
|
|
|
;;
|
|
|
|
|
2023-06-18 01:32:45 +03:00
|
|
|
i | install)
|
2023-06-18 01:32:45 +03:00
|
|
|
$RUN mermaid sh -c "npx pnpm install $args"
|
2023-06-11 01:15:31 +03:00
|
|
|
;;
|
|
|
|
|
2023-06-18 01:32:45 +03:00
|
|
|
add)
|
|
|
|
$RUN mermaid sh -c "npx pnpm -w add $args"
|
2023-06-18 01:32:45 +03:00
|
|
|
;;
|
|
|
|
|
2023-06-18 01:32:45 +03:00
|
|
|
test | vitest | e2e )
|
|
|
|
$RUN mermaid sh -c "npx pnpm $command $args"
|
2023-06-18 01:32:45 +03:00
|
|
|
;;
|
|
|
|
|
2023-06-19 04:29:41 +03:00
|
|
|
prettier)
|
|
|
|
$RUN mermaid sh -c "npx pnpm prettier --write $args"
|
|
|
|
;;
|
|
|
|
|
2023-06-11 01:15:31 +03:00
|
|
|
lint)
|
2023-06-19 04:29:41 +03:00
|
|
|
$RUN mermaid sh -c "npx pnpm -w run lint:fix $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"
|
|
|
|
# $UP --rm mermaid sh -c "npx pnpm run dev"
|
|
|
|
;;
|
|
|
|
|
2023-06-11 01:15:31 +03:00
|
|
|
help)
|
2023-06-18 01:32:45 +03:00
|
|
|
usage=$(
|
2023-06-11 01:15:31 +03:00
|
|
|
cat <<EOF
|
|
|
|
Run commonly used commands within docker containers
|
|
|
|
|
2023-06-18 01:32:45 +03:00
|
|
|
\033[1m$name install\033[0m # Equvalent of pnpm install
|
2023-06-18 01:32:45 +03:00
|
|
|
\033[1m$name dev\033[0m # Run dev server with examples, open http://localhost:9000
|
2023-06-18 01:32:45 +03:00
|
|
|
|
2023-06-18 01:32:45 +03:00
|
|
|
$name add # Add package, 'run add d3-sankey'
|
2023-06-18 01:32:45 +03: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-11 01:15:31 +03:00
|
|
|
|
2023-06-18 01:32:45 +03:00
|
|
|
$name sh # Open sh inside docker container for development
|
|
|
|
|
|
|
|
$name help # Show this help
|
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
|
|
|
;;
|
|
|
|
|
|
|
|
esac
|