From 7f10a4f77097552c4fa5c0787f6e2e7b4c6f936a Mon Sep 17 00:00:00 2001 From: Matteo Cherubini Date: Sat, 9 May 2026 17:25:36 +0200 Subject: [PATCH] refactor: Split configuration into `globals.env` and `registry.sh` --- scripts/add-genome.sh | 5 ++--- scripts/lint-genomes.sh | 5 +++-- scripts/setup-genomes.sh | 8 ++++++-- scripts/setup-master.sh | 3 ++- scripts/setup.sh | 5 +++-- 5 files changed, 16 insertions(+), 10 deletions(-) diff --git a/scripts/add-genome.sh b/scripts/add-genome.sh index fc69296..37dab87 100644 --- a/scripts/add-genome.sh +++ b/scripts/add-genome.sh @@ -6,7 +6,8 @@ set -euo pipefail source "lib/output.sh" -source "config.env" +source "globals.env" +source "registry.sh" GENOME_NAME="${1:-}" GENOME_DESC="${2:-}" @@ -19,10 +20,8 @@ fi step "Adding New Genome: ${GENOME_NAME}" -# Sovrascrivo l'array per la sessione corrente GENOMES=("${GENOME_NAME}|${GENOME_DESC}") -# FIX BUG 2: Uso source invece di bash per mantenere il context dell'array source "scripts/setup-genomes.sh" success "Genome '${GENOME_NAME}' added and linked successfully!" diff --git a/scripts/lint-genomes.sh b/scripts/lint-genomes.sh index 392fac7..7c2a77e 100644 --- a/scripts/lint-genomes.sh +++ b/scripts/lint-genomes.sh @@ -2,13 +2,14 @@ # ============================================================================= # scripts/lint-genomes.sh # Executes quality control across all registered genomes. -# Iterates from the GENOMES registry in config.env — not from filesystem patterns — +# Iterates from the GENOMES registry in registry.sh — not from filesystem patterns — # so all genomes are covered regardless of their naming convention. # ============================================================================= set -euo pipefail source "lib/output.sh" -source "config.env" +source "globals.env" +source "registry.sh" source "lib/lint.sh" step "Starting Knowledge Genome Linting" diff --git a/scripts/setup-genomes.sh b/scripts/setup-genomes.sh index 1add46a..b8a7863 100644 --- a/scripts/setup-genomes.sh +++ b/scripts/setup-genomes.sh @@ -6,7 +6,12 @@ set -euo pipefail source "lib/output.sh" -source "config.env" +source "globals.env" + +if [[ -z "${WORK_DIR:-}" ]]; then + source "registry.sh" +fi + source "lib/scaffold.sh" source "lib/git-crypt.sh" source "providers/${PROVIDER}.sh" @@ -29,7 +34,6 @@ for entry in "${GENOMES[@]}"; do cd "${WORK_DIR}/${MASTER_REPO}" info "Linking ${GENOME_NAME} as a submodule..." - # FIX BUG 1: Adding the submodule clones the empty remote repository git submodule add "${SSH_URL}" "${GENOME_NAME}" cd "${GENOME_NAME}" diff --git a/scripts/setup-master.sh b/scripts/setup-master.sh index 4707f5b..42c3e1a 100644 --- a/scripts/setup-master.sh +++ b/scripts/setup-master.sh @@ -6,7 +6,8 @@ set -euo pipefail source "lib/output.sh" -source "config.env" +source "globals.env" +source "registry.sh" source "lib/scaffold.sh" source "providers/${PROVIDER}.sh" # Required for remote creation diff --git a/scripts/setup.sh b/scripts/setup.sh index eb2e5b7..0bc3107 100644 --- a/scripts/setup.sh +++ b/scripts/setup.sh @@ -10,7 +10,8 @@ set -euo pipefail # Resolve script directory and source core components SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" source "${SCRIPT_DIR}/lib/output.sh" -source "${SCRIPT_DIR}/config.env" +source "${SCRIPT_DIR}/globals.env" +source "${SCRIPT_DIR}/registry.sh" source "${SCRIPT_DIR}/lib/deps.sh" step "Starting Knowledge Genome Setup" @@ -24,7 +25,7 @@ check_git_identity info "Initializing Master Repository..." bash "${SCRIPT_DIR}/scripts/setup-master.sh" -# 3. Genomes Provisioning (as defined in config.env) +# 3. Genomes Provisioning (as defined in registry.sh) info "Provisioning registered Genomes..." bash "${SCRIPT_DIR}/scripts/setup-genomes.sh"