# # Project config resolution for ia_dev scripts. # Source this after setting PROJECT_ROOT and IA_DEV_ROOT. # Resolves PROJECT_SLUG (id) and PROJECT_CONFIG_PATH (projects//conf.json). # # Project id resolution order: # 1. IA_PROJECT (env) # 2. .ia_project at PROJECT_ROOT (one line, slug) # 3. ai_project_id at PROJECT_ROOT (one line, id = directory name in projects/) # # Config file: projects//conf.json (e.g. projects/lecoffreio/conf.json). # set -euo pipefail PROJECT_SLUG="" if [[ -n "${IA_PROJECT:-}" ]]; then PROJECT_SLUG="$(echo "${IA_PROJECT}" | sed 's/[[:space:]]//g')" fi if [[ -z "$PROJECT_SLUG" && -n "${PROJECT_ROOT:-}" && -f "$PROJECT_ROOT/.ia_project" ]]; then PROJECT_SLUG="$(cat "$PROJECT_ROOT/.ia_project" | sed 's/[[:space:]]//g')" fi if [[ -z "$PROJECT_SLUG" && -n "${PROJECT_ROOT:-}" && -f "$PROJECT_ROOT/ai_project_id" ]]; then PROJECT_SLUG="$(cat "$PROJECT_ROOT/ai_project_id" | sed 's/[[:space:]]//g')" fi PROJECT_CONFIG_PATH="" if [[ -n "$PROJECT_SLUG" && -n "${IA_DEV_ROOT:-}" ]]; then PROJECT_CONFIG_PATH="${IA_DEV_ROOT}/projects/${PROJECT_SLUG}/conf.json" if [[ ! -f "$PROJECT_CONFIG_PATH" ]]; then PROJECT_CONFIG_PATH="" fi fi export PROJECT_SLUG export PROJECT_CONFIG_PATH