Merge branch 'master' into pre-commit

This commit is contained in:
Thomas Hobson 2021-10-13 23:17:44 +13:00 committed by GitHub
commit ddb3703a0d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 51 additions and 33 deletions

39
piston
View file

@ -1,7 +1,10 @@
#!/usr/bin/env bash
cd "$(dirname "$0")"
PISTON_ENV=$(cat .piston_env || echo dev)
EXECUTION_PATH="$PWD"
PISTON_PATH="$(dirname "$(realpath "$0")")"
cd "$PISTON_PATH"
PISTON_ENV=$(cat .piston_env 2> /dev/null || echo dev)
docker_compose(){
if [ -f "docker-compose.$PISTON_ENV.yaml" ]; then
@ -39,13 +42,14 @@ case $1 in
echo
echo "Development Commands:"
if [ $PISTON_ENV == dev ]; then
if [ "$PISTON_ENV" == dev ]; then
echo " clean-pkgs Clean any package build artifacts on disk"
echo " clean-repo Remove all packages from local repo"
echo " build-pkg <package> <version> Build a package"
echo " rebuild Build and restart the docker container"
echo " lint Lint the codebase using prettier"
echo " clean-pkgs Clean any package build artifacts on disk"
echo " clean-repo Remove all packages from local repo"
echo " list-pkgs Lists all packages that can be built"
echo " build-pkg <package> <version> [builder] Build a package [with desired builder image]"
echo " rebuild Build and restart the docker container"
echo " lint Lint the codebase using prettier"
else
@ -63,6 +67,8 @@ case $1 in
restart) docker_compose restart ;;
start)
init_precommit
rm -f .git/hooks/pre-commit
ln -s "$PISTON_PATH/pre-commit" "$PISTON_PATH/.git/hooks/pre-commit"
docker_compose up -d
;;
stop) docker_compose down ;;
@ -75,6 +81,7 @@ case $1 in
update)
git pull
cd cli && npm i > /dev/null && cd -
docker_compose pull
docker_compose up -d
;;
@ -82,12 +89,15 @@ case $1 in
clean-pkgs) git clean -fqXd packages ;;
clean-repo) git clean -fqXd repo ;;
list-pkgs) find packages -depth 2 | awk -F/ '$2 && $3{ print $2 "-" $3 }' | column ;;
build-pkg)
PKGSLUG="$2-$3"
BUILDER="${4:-piston-repo-builder}"
echo "Building $PKGSLUG"
echo "Ensuring latest builder image"
docker build repo -t piston-repo-builder
docker run --rm -v "$(realpath $(dirname "$0")):/piston" piston-repo-builder --no-server $PKGSLUG
docker build repo -t "$BUILDER"
docker run --rm -v "$PWD:/piston" "$BUILDER" --no-server "$PKGSLUG"
;;
lint)
@ -95,9 +105,8 @@ case $1 in
npx prettier --ignore-unknown --write .
;;
*)
cd cli
npm i > /dev/null
cd ../
node cli/index.js "$@"
;;
[ -d ./cli/node_modules ] || npm i > /dev/null
cd "$EXECUTION_PATH"
node "${PISTON_PATH}/cli/index.js" "$@"
;;
esac