Skip to content

Commit

Permalink
chore: add prepare script (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
zshipko authored Oct 10, 2024
1 parent 48e0b84 commit adae7c1
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
1 change: 1 addition & 0 deletions config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
template-suffix: ejs
dependencies:
- extism-py
- uv

available-feature-flags:
- name: stub-with-code-samples
Expand Down
44 changes: 44 additions & 0 deletions template/prepare.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash

# Function to check if a command exists
command_exists () {
command -v "$1" >/dev/null 2>&1
}

missing_deps=0

# Check for uv
if ! (command_exists uv); then
missing_deps=1
echo "❌ uv is not installed."
echo ""
echo "To install uv, visit the official download page:"
echo "👉 https://docs.astral.sh/uv/getting-started/installation/"
echo ""
fi

# Exit with a bad exit code if any dependencies are missing
if [ "$missing_deps" -ne 0 ]; then
echo "Install the missing dependencies and ensure they are on your path. Then run this command again."
# TODO: remove sleep when cli bug is fixed
sleep 2
exit 1
fi

# Check for extism-js
if ! command_exists extism-py; then
echo "❌ extism-py is not installed."
echo ""
echo "extism-py is needed to compile the plug-in. You can find the instructions to install it here: https://github.com/extism/python-pdk"
echo ""
echo "Alternatively, you can use an install script."
echo ""
echo "🔹 Mac / Linux:"
echo "curl -L https://raw.githubusercontent.com/extism/python-pdk/main/install.sh | bash"
echo ""
# TODO: remove sleep when cli bug is fixed
sleep 2
exit 1
fi


2 changes: 1 addition & 1 deletion template/xtp.toml.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ build = "PYTHONPATH=./plugin extism-py -o plugin.wasm plugin/__init__.py"
format = "uv run ruff format plugin/*.py"

# xtp plugin init runs this script before running the format script
prepare = "uv sync"
prepare = "bash prepare.sh && uv sync"

0 comments on commit adae7c1

Please sign in to comment.