|
3 | 3 | # Development Lifecycle Protocol (DLP) Installer |
4 | 4 | # https://github.com/edgarjs/dlp |
5 | 5 | # |
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 |
9 | 9 | # |
10 | 10 |
|
11 | 11 | set -e |
12 | 12 |
|
13 | 13 | REPO="edgarjs/dlp" |
14 | 14 | INSTALL_DIR="$HOME/.dlp" |
15 | 15 | LOCAL=false |
| 16 | +REF="" |
16 | 17 |
|
17 | 18 | while [ $# -gt 0 ]; do |
18 | 19 | case "$1" in |
19 | 20 | -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 | + ;; |
20 | 26 | -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" |
23 | 30 | exit 0 |
24 | 31 | ;; |
25 | 32 | *) echo "Unknown option: $1"; exit 1 ;; |
|
29 | 36 |
|
30 | 37 | command -v curl >/dev/null || { echo "Error: curl is required"; exit 1; } |
31 | 38 |
|
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 |
34 | 46 |
|
35 | | -echo "Installing DLP ${RELEASE} to ${INSTALL_DIR}..." |
| 47 | +echo "Installing DLP ${VERSION} to ${INSTALL_DIR}..." |
36 | 48 | 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" |
39 | 51 |
|
40 | 52 | INSTRUCTIONS="## Development Lifecycle Protocol (DLP) |
41 | 53 |
|
|
0 commit comments