Skip to content

Commit 817d235

Browse files
committed
refactor(pins): move version pins from catalog files to user-local config
Version pins are personal preferences that don't belong in git-tracked catalog files. This moves them to ~/.config/cli-audit/pins.json, matching the pattern already used by auto_update preferences in config.yml. - Add scripts/lib/pins.sh shared library for all pin read/write operations - Update pin_version.sh, unpin_version.sh, reset_pins.sh to use pins.sh - Update catalog.sh pin-reading functions to delegate to pins.sh - Update guide.sh pin checks to read from pins.json - Remove pinned_version/pinned_versions fields from all catalog/*.json - Migrate existing pin values to ~/.config/cli-audit/pins.json
1 parent 86efef2 commit 817d235

15 files changed

Lines changed: 182 additions & 105 deletions

catalog/git-branchless.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,5 @@
1111
"x86_64": "x86_64-unknown-linux-musl"
1212
},
1313
"notes": "Only x86_64 Linux builds available. KNOWN ISSUE: v0.10.0 release binary incorrectly reports version 0.9.0 - this is an upstream packaging bug, not an installer issue.",
14-
"known_issues": "v0.10.0 release binary reports version 0.9.0 (upstream packaging bug). Upgrade will appear to fail. Wait for v0.10.1+ or build from source.",
15-
"pinned_version": "0.10.0"
14+
"known_issues": "v0.10.0 release binary reports version 0.9.0 (upstream packaging bug). Upgrade will appear to fail. Wait for v0.10.1+ or build from source."
1615
}

catalog/go.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,5 @@
2727
"go.mod"
2828
]
2929
},
30-
"notes": "Go supports 2 versions (current + previous). Uses goenv if available, otherwise single system install.",
31-
"pinned_versions": {
32-
"1.24": "never"
33-
}
30+
"notes": "Go supports 2 versions (current + previous). Uses goenv if available, otherwise single system install."
3431
}

catalog/node.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,5 @@
2828
"package.json"
2929
]
3030
},
31-
"notes": "Managed via nvm (Node Version Manager). Supports multiple concurrent LTS versions.",
32-
"pinned_versions": {
33-
"22": "never"
34-
}
31+
"notes": "Managed via nvm (Node Version Manager). Supports multiple concurrent LTS versions."
3532
}

catalog/php.json

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,5 @@
3434
"composer.json"
3535
]
3636
},
37-
"notes": "Uses ondrej/php PPA for latest PHP version on Ubuntu/Debian. Required for Composer. Supports multiple concurrent versions (8.5, 8.4, 8.3, 8.2).",
38-
"pinned_versions": {
39-
"8.2": "never"
40-
}
37+
"notes": "Uses ondrej/php PPA for latest PHP version on Ubuntu/Debian. Required for Composer. Supports multiple concurrent versions (8.5, 8.4, 8.3, 8.2)."
4138
}

catalog/pip.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,5 @@
1212
"dnf": "python3-pip",
1313
"pacman": "python-pip"
1414
},
15-
"notes": "pip typically comes with Python 3. Use python3 -m pip if pip command is not available.",
16-
"pinned_version": "never"
15+
"notes": "pip typically comes with Python 3. Use python3 -m pip if pip command is not available."
1716
}

catalog/pipx.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,5 @@
1111
"brew": "pipx",
1212
"dnf": "pipx",
1313
"pacman": "python-pipx"
14-
},
15-
"pinned_version": "never"
14+
}
1615
}

catalog/python.json

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,5 @@
2828
"pyproject.toml",
2929
".tool-versions"
3030
]
31-
},
32-
"pinned_versions": {
33-
"3.11": "never",
34-
"3.10": "never"
3531
}
3632
}

catalog/ruby.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,5 @@
2626
"Gemfile"
2727
]
2828
},
29-
"notes": "Managed via rbenv for version management. Supports multiple concurrent versions.",
30-
"pinned_versions": {
31-
"3.4": "never",
32-
"3.3": "never"
33-
}
29+
"notes": "Managed via rbenv for version management. Supports multiple concurrent versions."
3430
}

scripts/AGENTS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
**Shared utilities:** `scripts/lib/` directory (10 modules):
5050
- `lib/common.sh` — Logging and output formatting
5151
- `lib/config.sh` — Read user config from `~/.config/cli-audit/config.yml`
52+
- `lib/pins.sh` — Read/write version pins from `~/.config/cli-audit/pins.json`
5253
- `lib/catalog.sh` — Catalog access utilities
5354
- `lib/capability.sh`, `lib/dependency.sh` — Capability and dependency checks
5455
- `lib/install_strategy.sh`, `lib/reconcile.sh` — Installation strategies

scripts/guide.sh

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ done
2626
# Load catalog query functions
2727
. "$DIR/lib/catalog.sh"
2828

29+
# Load pin library (user-local version pins)
30+
. "$DIR/lib/pins.sh"
31+
2932
# Load config query functions (for user preferences like auto_update)
3033
. "$DIR/lib/config.sh"
3134

@@ -410,11 +413,9 @@ process_tool() {
410413
fi
411414
else
412415
# Upgrade succeeded - remove any existing pin to avoid stale pins
413-
if catalog_has_tool "$tool"; then
414-
local existing_pin="$(catalog_get_property "$tool" pinned_version)"
415-
if [ -n "$existing_pin" ] && [ "$existing_pin" != "never" ]; then
416-
"$ROOT"/scripts/unpin_version.sh "$tool" || true
417-
fi
416+
local existing_pin="$(pins_get "$tool")"
417+
if [ -n "$existing_pin" ] && [ "$existing_pin" != "never" ]; then
418+
"$ROOT"/scripts/unpin_version.sh "$tool" || true
418419
fi
419420
fi
420421
;;
@@ -459,11 +460,9 @@ process_tool() {
459460
else
460461
printf " ✓ Auto-update enabled. This tool will update automatically in future.\n"
461462
# Remove any existing pin
462-
if catalog_has_tool "$tool"; then
463-
local existing_pin_a="$(catalog_get_property "$tool" pinned_version)"
464-
if [ -n "$existing_pin_a" ]; then
465-
"$ROOT"/scripts/unpin_version.sh "$tool" || true
466-
fi
463+
local existing_pin_a="$(pins_get "$tool")"
464+
if [ -n "$existing_pin_a" ]; then
465+
"$ROOT"/scripts/unpin_version.sh "$tool" || true
467466
fi
468467
fi
469468
;;
@@ -741,20 +740,20 @@ while read -r line; do
741740
continue
742741
fi
743742

744-
# Check if tool is pinned (use catalog name for pin check)
743+
# Check if tool is pinned (read from user-local pins file)
745744
# Skip pin checks if IGNORE_PINS=1
746745
if [ "$IGNORE_PINS" != "1" ]; then
747-
pinned_version="$(catalog_get_property "$catalog_name" pinned_version)"
746+
pinned_version="$(pins_get "$catalog_name")"
748747

749-
# For multi-version tools, check pinned_versions object AND base tool pin
748+
# For multi-version tools, check cycle-specific pin AND base tool pin
750749
if [ -n "$is_multi_version" ]; then
751750
# First check if the BASE tool (e.g., php) is pinned to "never" - skip ALL versions
752751
if [ "$pinned_version" = "never" ]; then
753752
continue
754753
fi
755754
# Then check version-specific pin
756755
version_cycle="${tool_name##*@}"
757-
multi_pin="$(catalog_get_pinned_version "$catalog_name" "$version_cycle")"
756+
multi_pin="$(pins_get_cycle "$catalog_name" "$version_cycle")"
758757
if [ "$multi_pin" = "never" ]; then
759758
continue
760759
fi

0 commit comments

Comments
 (0)