Skip to content

Commit 6273ed1

Browse files
committed
feat(bootstrap): support target repository hook in universal installer
1 parent a736fde commit 6273ed1

2 files changed

Lines changed: 90 additions & 79 deletions

File tree

README.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,34 +14,34 @@ Full documentation is available at [nathfavour.github.io/anyisland/](https://nat
1414

1515
## Quick Start
1616

17-
### 1. Install
17+
### 1. Install, Update & Uninstall
1818
```bash
19+
# Install Anyisland standalone
1920
curl -fsSL https://raw.githubusercontent.com/nathfavour/anyisland/master/install.sh | bash
20-
```
2121

22-
### 2. Update
23-
```bash
22+
# Or install Anyisland and a target tool in a single command
23+
curl -fsSL https://raw.githubusercontent.com/nathfavour/anyisland/master/install.sh | bash -s -- <owner/repo>
24+
25+
# Update (Anyisland updates automatically on every run, but you can force it)
2426
anyisland update anyisland
25-
```
2627

27-
### 3. Uninstall
28-
```bash
28+
# Uninstall Anyisland
2929
anyisland uninstall
3030
```
3131

32-
### 4. Setup
32+
### 2. Setup
3333
Initialize your local Island and configure your PATH.
3434
```bash
3535
anyisland setup
3636
```
3737

38-
### 5. Ingest a Tool
38+
### 3. Ingest a Tool
3939
Transform any GitHub repository into an installed tool via AI analysis.
4040
```bash
4141
anyisland ingest github.com/user/repo
4242
```
4343

44-
### 6. List Tools
44+
### 4. List Tools
4545
See what's installed and managed.
4646
```bash
4747
anyisland list
@@ -55,5 +55,6 @@ anyisland list
5555

5656
## Development
5757
```bash
58+
# Build CLI
5859
go build -o anyisland ./cmd/anyisland
5960
```

install.sh

Lines changed: 79 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
11
#!/bin/bash
22
set -e
33

4-
# Anyisland Universal Bootstrap
5-
# This script prepares the system and hands off to the Anyisland binary.
4+
# Anyisland Universal Bootstrap & Tool Installer Hook
5+
# Prepares the host, bootstraps Anyisland, and optionally installs a target repository.
66

77
ISLAND_DIR="$HOME/.anyisland"
88
LOCAL_BIN="$HOME/.local/bin"
99
VERSION="latest"
10+
TARGET_REPO="${1:-$ANYISLAND_TARGET}"
1011

11-
echo "🏝️ Anyisland Bootstrap"
12+
if [ -n "$TARGET_REPO" ]; then
13+
echo "🏝️ Anyisland Universal Bootstrap (Installing: $TARGET_REPO)"
14+
else
15+
echo "🏝️ Anyisland Bootstrap"
16+
fi
1217

1318
# 1. Detect Platform
1419
OS="$(uname -s | tr '[:upper:]' '[:lower:]')"
@@ -25,93 +30,98 @@ esac
2530
echo "📍 Platform: $OS-$ARCH"
2631

2732
# 2. Check if already installed and up-to-date
33+
ALREADY_INSTALLED=false
2834
if command -v anyisland &> /dev/null; then
29-
CURRENT_COMMIT=$(anyisland version | grep "Commit:" | awk '{print $2}' | cut -d'(' -f1 | xargs)
35+
CURRENT_COMMIT=$(anyisland version 2>/dev/null | grep "Commit:" | awk '{print $2}' | cut -d'(' -f1 | xargs || true)
3036
REPO_URL="https://github.com/nathfavour/anyisland"
3137

3238
if command -v git &> /dev/null; then
33-
REMOTE_COMMIT=$(git ls-remote "$REPO_URL" HEAD | awk '{print $1}')
34-
if [ "$CURRENT_COMMIT" = "$REMOTE_COMMIT" ]; then
39+
REMOTE_COMMIT=$(git ls-remote "$REPO_URL" HEAD 2>/dev/null | awk '{print $1}' || true)
40+
if [ -n "$CURRENT_COMMIT" ] && [ "$CURRENT_COMMIT" = "$REMOTE_COMMIT" ]; then
3541
echo "✅ Anyisland is already at the latest version ($CURRENT_COMMIT)."
36-
exit 0
42+
ALREADY_INSTALLED=true
3743
fi
44+
else
45+
ALREADY_INSTALLED=true
3846
fi
3947
fi
4048

41-
# 3. Build/Download Binary
42-
BUILD_SUCCESS=false
49+
# 3. Build/Download Binary if needed
50+
if [ "$ALREADY_INSTALLED" = false ]; then
51+
BUILD_SUCCESS=false
4352

44-
# Check if we can build from local source (meaning we are running `./install.sh` inside the repo)
45-
if [ -d "cmd/anyisland" ] && command -v go &> /dev/null; then
46-
echo "🔨 Building Anyisland from local source..."
47-
if go build -o anyisland ./cmd/anyisland; then
48-
BUILD_SUCCESS=true
53+
# Check if we can build from local source
54+
if [ -d "cmd/anyisland" ] && command -v go &> /dev/null; then
55+
echo "🔨 Building Anyisland from local source..."
56+
if go build -o anyisland ./cmd/anyisland 2>/dev/null; then
57+
BUILD_SUCCESS=true
58+
fi
4959
fi
50-
fi
5160

52-
if [ "$BUILD_SUCCESS" != "true" ]; then
53-
echo "📥 Attempting to download pre-built binary for $OS-$ARCH..."
54-
EXT="tar.gz"
55-
if [ "$OS" = "windows" ]; then
56-
EXT="zip"
57-
fi
58-
BINARY_NAME="anyisland_${OS}_${ARCH}.${EXT}"
59-
DOWNLOAD_URL="https://github.com/nathfavour/anyisland/releases/download/v0.0.0/${BINARY_NAME}"
60-
61-
if ! curl -fsSL "$DOWNLOAD_URL" -o anyisland_archive; then
62-
echo "⚠️ v0.0.0 release not found. Falling back to latest release..."
63-
DOWNLOAD_URL="https://github.com/nathfavour/anyisland/releases/latest/download/${BINARY_NAME}"
64-
curl -fsSL "$DOWNLOAD_URL" -o anyisland_archive
65-
fi
66-
67-
if [ -f anyisland_archive ]; then
68-
echo "✅ Downloaded pre-built binary archive."
61+
if [ "$BUILD_SUCCESS" != "true" ]; then
62+
echo "📥 Attempting to download pre-built binary for $OS-$ARCH..."
63+
EXT="tar.gz"
6964
if [ "$OS" = "windows" ]; then
70-
if command -v unzip &> /dev/null; then
71-
unzip -o anyisland_archive anyisland.exe
65+
EXT="zip"
66+
fi
67+
BINARY_NAME="anyisland_${OS}_${ARCH}.${EXT}"
68+
DOWNLOAD_URL="https://github.com/nathfavour/anyisland/releases/latest/download/${BINARY_NAME}"
69+
70+
if curl -fsSL "$DOWNLOAD_URL" -o anyisland_archive 2>/dev/null; then
71+
echo "✅ Downloaded pre-built binary archive."
72+
if [ "$OS" = "windows" ]; then
73+
if command -v unzip &> /dev/null; then
74+
unzip -o anyisland_archive anyisland.exe
75+
fi
76+
[ -f anyisland.exe ] && mv anyisland.exe anyisland
7277
else
73-
echo "⚠️ unzip command not found. Cannot extract archive."
74-
rm -f anyisland_archive
75-
exit 1
78+
tar -xzf anyisland_archive anyisland 2>/dev/null || true
7679
fi
77-
mv anyisland.exe anyisland
78-
else
79-
tar -xzf anyisland_archive anyisland
80+
rm -f anyisland_archive
81+
[ -f anyisland ] && BUILD_SUCCESS=true
8082
fi
81-
rm -f anyisland_archive
82-
BUILD_SUCCESS=true
83-
else
84-
echo "⚠️ Failed to download pre-built binary."
8583
fi
86-
fi
8784

88-
if [ "$BUILD_SUCCESS" != "true" ]; then
89-
if command -v go &> /dev/null; then
90-
echo "🔨 Go is installed. Attempting to compile from remote source..."
91-
if GOBIN="$(pwd)" go install github.com/nathfavour/anyisland/cmd/anyisland@master; then
92-
echo "✅ Built successfully from remote source."
93-
BUILD_SUCCESS=true
85+
if [ "$BUILD_SUCCESS" != "true" ]; then
86+
if command -v go &> /dev/null; then
87+
echo "🔨 Go is installed. Attempting to compile from remote source..."
88+
if GOBIN="$(pwd)" go install github.com/nathfavour/anyisland/cmd/anyisland@master 2>/dev/null; then
89+
echo "✅ Built successfully from remote source."
90+
BUILD_SUCCESS=true
91+
fi
9492
fi
9593
fi
96-
fi
9794

98-
if [ "$BUILD_SUCCESS" != "true" ]; then
99-
echo "❌ Failed to download or build Anyisland binary. Exiting."
100-
exit 1
101-
fi
95+
if [ "$BUILD_SUCCESS" != "true" ]; then
96+
echo "❌ Failed to download or build Anyisland binary. Exiting."
97+
exit 1
98+
fi
10299

103-
# 4. Hand-off to Anyisland for self-installation
104-
echo "🚚 Handing off to Anyisland for system integration..."
105-
if [ -f "anyisland.exe" ]; then
106-
mv anyisland.exe anyisland
107-
fi
108-
chmod +x anyisland
109-
mkdir -p "$LOCAL_BIN"
110-
mv anyisland "$LOCAL_BIN/"
100+
# 4. Hand-off to Anyisland for self-installation
101+
echo "🚚 Handing off to Anyisland for system integration..."
102+
if [ -f "anyisland.exe" ]; then
103+
mv anyisland.exe anyisland
104+
fi
105+
chmod +x anyisland 2>/dev/null || true
106+
mkdir -p "$LOCAL_BIN"
107+
mv anyisland "$LOCAL_BIN/"
111108

112-
"$LOCAL_BIN/anyisland" self-install
109+
"$LOCAL_BIN/anyisland" self-install
110+
fi
113111

114-
echo ""
115-
echo "✅ Anyisland installation complete!"
116-
echo "🚀 Run 'anyisland' to get started."
117-
echo "👉 You may need to restart your shell to update your PATH."
112+
# 5. Handle Target Repo Hook if provided
113+
if [ -n "$TARGET_REPO" ]; then
114+
echo "📦 Installing target package: $TARGET_REPO via Anyisland..."
115+
ANYISLAND_BIN="$LOCAL_BIN/anyisland"
116+
if ! command -v anyisland &> /dev/null; then
117+
export PATH="$LOCAL_BIN:$PATH"
118+
fi
119+
"$ANYISLAND_BIN" install "$TARGET_REPO"
120+
echo ""
121+
echo "🎉 Successfully installed $TARGET_REPO!"
122+
else
123+
echo ""
124+
echo "✅ Anyisland installation complete!"
125+
echo "🚀 Run 'anyisland' to get started."
126+
echo "👉 You may need to restart your shell to update your PATH."
127+
fi

0 commit comments

Comments
 (0)