-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·120 lines (102 loc) · 2.81 KB
/
install.sh
File metadata and controls
executable file
·120 lines (102 loc) · 2.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#!/bin/bash
set -euo pipefail
REPO="tomtev/loopwind"
INSTALL_DIR="$HOME/.loopwind"
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
CYAN='\033[0;36m'
BOLD='\033[1m'
NC='\033[0m'
info() { printf "${CYAN}%s${NC}\n" "$1"; }
success() { printf "${GREEN}%s${NC}\n" "$1"; }
warn() { printf "${YELLOW}%s${NC}\n" "$1"; }
error() { printf "${RED}%s${NC}\n" "$1" >&2; }
# Detect OS
OS="$(uname -s)"
case "$OS" in
Darwin) OS="darwin" ;;
Linux) OS="linux" ;;
*)
error "Unsupported OS: $OS"
exit 1
;;
esac
# Detect architecture
ARCH="$(uname -m)"
case "$ARCH" in
x86_64) ARCH="x64" ;;
aarch64) ARCH="arm64" ;;
arm64) ARCH="arm64" ;;
*)
error "Unsupported architecture: $ARCH"
exit 1
;;
esac
TARBALL="loopwind-${OS}-${ARCH}.tar.gz"
URL="https://github.com/${REPO}/releases/latest/download/${TARBALL}"
echo ""
printf "${BOLD}loopwind installer${NC}\n"
echo ""
# Check for Node.js
if ! command -v node &>/dev/null; then
error "Node.js is required but not installed."
echo " Install it from https://nodejs.org/ (v18+)"
exit 1
fi
NODE_VERSION="$(node -v)"
info "Found Node.js ${NODE_VERSION}"
# Download
info "Downloading ${TARBALL}..."
TMPDIR_PATH="$(mktemp -d)"
trap 'rm -rf "$TMPDIR_PATH"' EXIT
if ! curl -fsSL "$URL" -o "${TMPDIR_PATH}/${TARBALL}"; then
error "Download failed. Check that a release exists for ${OS}-${ARCH}."
echo " ${URL}"
exit 1
fi
# Extract
info "Installing to ${INSTALL_DIR}..."
rm -rf "$INSTALL_DIR"
mkdir -p "$INSTALL_DIR"
tar -xzf "${TMPDIR_PATH}/${TARBALL}" -C "$INSTALL_DIR" --strip-components=1
# Get version
VERSION="unknown"
if [ -f "$INSTALL_DIR/package.json" ]; then
VERSION="$(node -e "console.log(require('$INSTALL_DIR/package.json').version)" 2>/dev/null || echo "unknown")"
fi
# Create wrapper script
WRAPPER='#!/bin/bash
exec node "$HOME/.loopwind/dist/cli.js" "$@"'
BIN_DIR="$HOME/.loopwind/bin"
mkdir -p "$BIN_DIR"
echo "$WRAPPER" > "$BIN_DIR/loopwind"
chmod +x "$BIN_DIR/loopwind"
WRAPPER_PATH="$BIN_DIR/loopwind"
# Add to PATH if not already there
if [[ ":$PATH:" != *":$BIN_DIR:"* ]]; then
SHELL_NAME="$(basename "$SHELL")"
case "$SHELL_NAME" in
zsh) PROFILE="$HOME/.zshrc" ;;
bash) PROFILE="$HOME/.bashrc" ;;
*) PROFILE="$HOME/.profile" ;;
esac
if ! grep -q '.loopwind/bin' "$PROFILE" 2>/dev/null; then
echo 'export PATH="$HOME/.loopwind/bin:$PATH"' >> "$PROFILE"
info "Added ~/.loopwind/bin to PATH in ${PROFILE}"
info "Run: source ${PROFILE} (or open a new terminal)"
fi
fi
echo ""
success "loopwind v${VERSION} installed successfully!"
echo ""
echo " Location: ${INSTALL_DIR}"
echo " Command: ${WRAPPER_PATH}"
echo ""
echo " Get started:"
echo " cd your-project/"
echo " loopwind init"
echo " loopwind add image-template"
echo " loopwind render image-template '{\"title\":\"Hello World\"}'"
echo ""