#!/usr/bin/env bash
# Runs Maestro for a single flow file or a directory of flows (any path Maestro accepts).
# Env and platform come from the yarn script name; you only pass the flow path (and optional maestro args).
# Usage (via yarn): yarn e2e:path:<platform>:<env> <path>
# Example: yarn e2e:path:ios:dev e2e/flows/goals
# Example: yarn e2e:path:android:dev e2e/flows/goals/my-flow.yml
set -euo pipefail

REPO_ROOT="$(cd "$(dirname "$0")/.." && pwd)"
cd "$REPO_ROOT"

ENV_FILE="${1:?missing env file}"
PLATFORM="${2:?missing platform (ios or android)}"
FLOW="${3:?missing flow path (file or directory, e.g. e2e/flows/goals)}"

shift 3

exec ./e2e/run-with-env.sh "$FLOW" "$ENV_FILE" "$PLATFORM" --config e2e/config.yml "$@"
