refactor: Use XDG compliant isolated directory structure
Some checks failed
Lint / lint (push) Failing after 21s
Lint / lint (pull_request) Failing after 16s

- Using $BOOTSTRAP_BIN, $BOOTSTRAP_OPT, etc
- Add defensive fallback for undefined vars in common.sh
This commit is contained in:
2026-06-26 23:52:03 +05:30
parent 4c1c7de0b7
commit d5c90d6e85
17 changed files with 84 additions and 50 deletions

View File

@@ -65,10 +65,27 @@ install_bootstrap() {
[ -f "$HOME/.bashrc" ] && target_files+=("$HOME/.bashrc")
local routes_dir="$HOME/.config/bootstrap"
mkdir -p "$routes_dir"
mkdir -p "$routes_dir/env.d"
mkdir -p "$routes_dir/aliases.d"
# Initialize XDG directories
mkdir -p "$HOME/.local/share/bootstrap/bin"
mkdir -p "$HOME/.local/share/bootstrap/opt"
mkdir -p "$HOME/.local/share/bootstrap/runtimes"
mkdir -p "$HOME/.local/state/bootstrap/logs"
mkdir -p "$HOME/.local/state/bootstrap/rollback"
mkdir -p "$HOME/.cache/bootstrap/downloads"
mkdir -p "$HOME/.cache/bootstrap/tmp"
# Create the universal binary PATH snippet
cat << 'EOF' > "$routes_dir/env.d/bootstrap-bin.sh"
export BOOTSTRAP_BIN="$BOOTSTRAP_BIN"
case ":$PATH:" in
*":$BOOTSTRAP_BIN:"*) ;;
*) export PATH="$BOOTSTRAP_BIN:$PATH" ;;
esac
EOF
# List of all files to download/copy
local files=(
"VERSION"
@@ -142,6 +159,13 @@ install_bootstrap() {
# >>> bootstrap-cli setup >>>
export BOOTSTRAP_DIR="$HOME/.config/bootstrap"
export BOOTSTRAP_DATA_DIR="$HOME/.local/share/bootstrap"
export BOOTSTRAP_STATE_DIR="$HOME/.local/state/bootstrap"
export BOOTSTRAP_CACHE_DIR="$HOME/.cache/bootstrap"
export BOOTSTRAP_BIN="$BOOTSTRAP_DATA_DIR/bin"
export BOOTSTRAP_OPT="$BOOTSTRAP_DATA_DIR/opt"
export BOOTSTRAP_RUNTIMES="$BOOTSTRAP_DATA_DIR/runtimes"
[ -f "$BOOTSTRAP_DIR/b.sh" ] && . "$BOOTSTRAP_DIR/b.sh"
for f in "$BOOTSTRAP_DIR/env.d/"*.sh; do [ -r "$f" ] && . "$f"; done
for f in "$BOOTSTRAP_DIR/aliases.d/"*.sh; do [ -r "$f" ] && . "$f"; done