Skip to content

Commit 1c8cd51

Browse files
committed
Add --ref option to install.sh to install a specific commit
1 parent f730aeb commit 1c8cd51

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

install.sh

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,23 +3,30 @@
33
# Development Lifecycle Protocol (DLP) Installer
44
# https://github.com/edgarjs/dlp
55
#
6-
# Usage:
7-
# curl -sSL https://github.com/edgarjs/dlp/raw/main/install.sh | bash # global
8-
# curl -sSL https://github.com/edgarjs/dlp/raw/main/install.sh | bash -s -- -l # local
6+
# Options:
7+
# -l, --local Install to .dlp/ in current directory
8+
# -r, --ref <ref> Install specific commit SHA, branch, or tag
99
#
1010

1111
set -e
1212

1313
REPO="edgarjs/dlp"
1414
INSTALL_DIR="$HOME/.dlp"
1515
LOCAL=false
16+
REF=""
1617

1718
while [ $# -gt 0 ]; do
1819
case "$1" in
1920
-l|--local) LOCAL=true; INSTALL_DIR=".dlp" ;;
21+
-r|--ref)
22+
shift
23+
[ -z "$1" ] && { echo "Error: --ref requires a value"; exit 1; }
24+
REF="$1"
25+
;;
2026
-h|--help)
21-
echo "Usage: install.sh [-l|--local]"
22-
echo " -l, --local Install to .dlp/ in current directory"
27+
echo "Usage: install.sh [-l|--local] [-r|--ref <ref>]"
28+
echo " -l, --local Install to .dlp/ in current directory"
29+
echo " -r, --ref <ref> Install specific commit SHA, branch, or tag"
2330
exit 0
2431
;;
2532
*) echo "Unknown option: $1"; exit 1 ;;
@@ -29,13 +36,18 @@ done
2936

3037
command -v curl >/dev/null || { echo "Error: curl is required"; exit 1; }
3138

32-
RELEASE=$(curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest" | grep '"tag_name"' | cut -d'"' -f4)
33-
[ -z "$RELEASE" ] && { echo "Error: Could not fetch latest release"; exit 1; }
39+
# Use provided ref or fetch latest release
40+
if [ -n "$REF" ]; then
41+
VERSION="$REF"
42+
else
43+
VERSION=$(curl -fsSL "https://api.github.com/repos/${REPO}/releases/latest" | grep '"tag_name"' | cut -d'"' -f4)
44+
[ -z "$VERSION" ] && { echo "Error: Could not fetch latest release"; exit 1; }
45+
fi
3446

35-
echo "Installing DLP ${RELEASE} to ${INSTALL_DIR}..."
47+
echo "Installing DLP ${VERSION} to ${INSTALL_DIR}..."
3648
mkdir -p "$INSTALL_DIR"
37-
curl -fsSL "https://github.com/${REPO}/archive/${RELEASE}.tar.gz" | tar xz --strip-components=1 -C "$INSTALL_DIR"
38-
echo "$RELEASE" > "$INSTALL_DIR/.dlp-version"
49+
curl -fsSL "https://github.com/${REPO}/archive/${VERSION}.tar.gz" | tar xz --strip-components=1 -C "$INSTALL_DIR"
50+
echo "$VERSION" > "$INSTALL_DIR/.dlp-version"
3951

4052
INSTRUCTIONS="## Development Lifecycle Protocol (DLP)
4153

0 commit comments

Comments
 (0)