You've already forked tribes-plugin-aether
forked from tribes/tribes-plugin-template
fddd616772
Add the shared plugin helper, host-backed test config, and runtime validation entrypoint. Update the example plugin route/docs and replace the old standalone test suite with the host-backed contract and page tests.
53 lines
1.1 KiB
Bash
53 lines
1.1 KiB
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
usage() {
|
|
cat <<'EOF'
|
|
Usage:
|
|
plugin validate
|
|
plugin test [mix test args...]
|
|
plugin precommit [mix precommit args...]
|
|
plugin shell
|
|
EOF
|
|
}
|
|
|
|
fail() {
|
|
echo "plugin: $*" >&2
|
|
exit 1
|
|
}
|
|
|
|
script_dir="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd -P)"
|
|
plugin_root="$(cd "$script_dir/.." && pwd -P)"
|
|
host_root="${TRIBES_HOST_ROOT:-$plugin_root/../tribes}"
|
|
host_root="$(cd "$host_root" && pwd -P)"
|
|
host_script="$host_root/scripts/plugin"
|
|
|
|
command_name="${1:-}"
|
|
if [[ -z "$command_name" ]]; then
|
|
usage
|
|
exit 1
|
|
fi
|
|
shift
|
|
|
|
case "$command_name" in
|
|
validate | test | precommit | shell) ;;
|
|
-h | --help | help)
|
|
usage
|
|
exit 0
|
|
;;
|
|
*)
|
|
usage
|
|
fail "unknown command: $command_name"
|
|
;;
|
|
esac
|
|
|
|
[[ -x "$host_script" || -f "$host_script" ]] || fail "expected host plugin script at $host_script"
|
|
|
|
if [[ "${DEVENV_ROOT:-}" == "$plugin_root" ]]; then
|
|
command -v devenv >/dev/null 2>&1 || fail "devenv is required when running from the plugin devenv shell"
|
|
cd "$host_root"
|
|
exec devenv shell -- bash ./scripts/plugin "$command_name" "$plugin_root" "$@"
|
|
fi
|
|
|
|
exec bash "$host_script" "$command_name" "$plugin_root" "$@"
|