refactor: Improve script loading and project root resolution
This commit is contained in:
parent
188feabecc
commit
a311768475
2 changed files with 14 additions and 8 deletions
21
registry.sh
21
registry.sh
|
|
@ -1,17 +1,22 @@
|
|||
#!/usr/bin/env bash
|
||||
# =============================================================================
|
||||
# registry.sh
|
||||
# Bash-only runtime config: dynamic paths and genome registry array.
|
||||
# Source this in shell scripts — never included by Make or env parsers.
|
||||
# registry.sh - Knowledge Genome Registry
|
||||
# Dynamic paths and genome definitions.
|
||||
# =============================================================================
|
||||
|
||||
# Dynamic paths — resolved relative to this file at source time
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
# Guard against double sourcing
|
||||
[[ -n "${_REGISTRY_LOADED:-}" ]] && return
|
||||
_REGISTRY_LOADED=1
|
||||
|
||||
# Resolve project root relative to this file
|
||||
PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
|
||||
# Dynamic paths
|
||||
WORK_DIR="${HOME}/knowledge-genome-setup"
|
||||
KEYS_DIR="${WORK_DIR}/keys"
|
||||
TEMPLATES_DIR="${SCRIPT_DIR}/templates"
|
||||
LIB_DIR="${SCRIPT_DIR}/lib"
|
||||
PROVIDERS_DIR="${SCRIPT_DIR}/providers"
|
||||
TEMPLATES_DIR="${PROJECT_ROOT}/templates"
|
||||
LIB_DIR="${PROJECT_ROOT}/lib"
|
||||
PROVIDERS_DIR="${PROJECT_ROOT}/providers"
|
||||
|
||||
# --- GENOME REGISTRY ---
|
||||
# Format: "name|description"
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ set -euo pipefail
|
|||
|
||||
# Resolve script directory and source core components
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
||||
cd "${SCRIPT_DIR}" # All child scripts use relative paths from project root
|
||||
source "${SCRIPT_DIR}/lib/output.sh"
|
||||
source "${SCRIPT_DIR}/globals.env"
|
||||
source "${SCRIPT_DIR}/registry.sh"
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue