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
|
#!/usr/bin/env bash
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
# registry.sh
|
# registry.sh - Knowledge Genome Registry
|
||||||
# Bash-only runtime config: dynamic paths and genome registry array.
|
# Dynamic paths and genome definitions.
|
||||||
# Source this in shell scripts — never included by Make or env parsers.
|
|
||||||
# =============================================================================
|
# =============================================================================
|
||||||
|
|
||||||
# Dynamic paths — resolved relative to this file at source time
|
# Guard against double sourcing
|
||||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
[[ -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"
|
WORK_DIR="${HOME}/knowledge-genome-setup"
|
||||||
KEYS_DIR="${WORK_DIR}/keys"
|
KEYS_DIR="${WORK_DIR}/keys"
|
||||||
TEMPLATES_DIR="${SCRIPT_DIR}/templates"
|
TEMPLATES_DIR="${PROJECT_ROOT}/templates"
|
||||||
LIB_DIR="${SCRIPT_DIR}/lib"
|
LIB_DIR="${PROJECT_ROOT}/lib"
|
||||||
PROVIDERS_DIR="${SCRIPT_DIR}/providers"
|
PROVIDERS_DIR="${PROJECT_ROOT}/providers"
|
||||||
|
|
||||||
# --- GENOME REGISTRY ---
|
# --- GENOME REGISTRY ---
|
||||||
# Format: "name|description"
|
# Format: "name|description"
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ set -euo pipefail
|
||||||
|
|
||||||
# Resolve script directory and source core components
|
# Resolve script directory and source core components
|
||||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
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}/lib/output.sh"
|
||||||
source "${SCRIPT_DIR}/globals.env"
|
source "${SCRIPT_DIR}/globals.env"
|
||||||
source "${SCRIPT_DIR}/registry.sh"
|
source "${SCRIPT_DIR}/registry.sh"
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue