Skip to content

Instantly share code, notes, and snippets.

@nilesh93
Created September 2, 2022 05:21
Show Gist options
  • Save nilesh93/f985c8d1dc69e1680e8178a8ca5dca80 to your computer and use it in GitHub Desktop.
Save nilesh93/f985c8d1dc69e1680e8178a8ca5dca80 to your computer and use it in GitHub Desktop.
choreo-local-dev
#!/bin/sh
mkdir -p .choreo
mkdir -p .githook
cat > .githook/pre-commit <<EOF
#!/bin/bash
APP_NAME=$(cat Ballerina.toml | grep "name =" | cut -d"=" -f2- | sed 's/\"//g; s/\ //g')
rm -rf .choreo/build
mkdir -p .choreo/build
bal build --sticky --generate-config-schema --observability-included --target-dir .choreo/build || { echo 'Ballerina Build Failed' ; exit 1; }
mv .choreo/build/bin/config-schema.json .choreo/
unzip -p .choreo/build/bin/$(echo $APP_NAME).jar syntax-tree/syntax-tree.json > .choreo/syntax-tree.json
rm -rf .choreo/build
touch .choreo/committer.txt
echo "$VSCODE_CHOREO_USER_EMAIL" >> .choreo/committer.txt
echo "$VSCODE_CHOREO_USER_IDP_ID" >> .choreo/committer.txt
git add .choreo
EOF
cat > .githook/pre-commit <<EOF
#!/bin/sh
echo $CHOREO_USER_IDP_ID >> $1
EOF
git config core.hooksPath .githooks
chmod +x .githooks/pre-commit
chmod +x .githooks/commit-msg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment