feat: automate project bootstrap and registry

This commit is contained in:
MaksTinyWorkshop
2026-03-08 17:48:48 +01:00
parent e98575aedf
commit c1f96fae96
6 changed files with 233 additions and 61 deletions

View File

@@ -9,39 +9,16 @@ set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
SOURCE="$REPO_ROOT/_AI_INSTRUCTIONS.md"
PROJECTS_CONF="$REPO_ROOT/_projects.conf"
# --- Détection machine ---
OS="$(uname -s)"
CHANGED=0
# --- Construire la table markdown des projets ---
build_projects_table() {
local os="$1"
echo "| Projet | Stack | Localisation | État |"
echo "|---|---|---|---|"
while IFS='|' read -r nom stack path_nuc path_mac etat; do
# Ignorer lignes vides et commentaires
[[ -z "$nom" || "$nom" == \#* ]] && continue
if [ "$os" = "Darwin" ]; then
path="$path_mac"
else
path="$path_nuc"
fi
if [ -z "$path" ]; then
echo "| $nom | $stack | *non disponible sur cette machine* | $etat |"
else
echo "| $nom | $stack | \`$path\` | $etat |"
fi
done < "$PROJECTS_CONF"
}
generate_repo_claude() {
local header="$1"
local dest="$2"
local projects_table
local tmp
projects_table="$(build_projects_table "$OS")"
tmp="$(mktemp)"
mkdir -p "$(dirname "$dest")"
@@ -49,14 +26,7 @@ generate_repo_claude() {
{
echo "$header"
echo ""
# Remplacer {{PROJECTS_TABLE}} par la table générée
while IFS= read -r line; do
if [ "$line" = "{{PROJECTS_TABLE}}" ]; then
echo "$projects_table"
else
echo "$line"
fi
done < "$SOURCE"
cat "$SOURCE"
} > "$tmp"
if [ ! -f "$dest" ] || ! cmp -s "$tmp" "$dest"; then