Skip to content

Commit 8953372

Browse files
committed
Add install script and installation docs
1 parent 993735e commit 8953372

File tree

3 files changed

+277
-7
lines changed

3 files changed

+277
-7
lines changed
+89-6
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,100 @@
11
# Installation
22

3-
## Install via cargo
3+
## Quick Install
4+
5+
You can quickly install AIScript using our installation script directly from GitHub:
6+
7+
```bash
8+
curl https://aiscript.dev/install.sh | sh
9+
```
10+
11+
Or if you prefer wget:
12+
13+
```bash
14+
wget -q -O- https://aiscript.dev/install.sh | sh
15+
```
16+
17+
This script will:
18+
1. Detect your OS and architecture
19+
2. Download the appropriate binary
20+
3. Verify the checksum
21+
4. Install AIScript to `~/.aiscript/bin/`
22+
5. Add this directory to your PATH (if needed)
23+
24+
## Install via Cargo
425

526
```
627
$ cargo install aiscript
728
829
$ aiscript --version
9-
aiscript 0.1.0
1030
```
1131

32+
## Manual Installation
33+
34+
If you prefer manual installation, you can download the appropriate binary for your platform from the [Releases page](https://github.com/aiscript-dev/aiscript/releases).
35+
36+
## Linux
37+
38+
```bash
39+
# Download the binary
40+
curl -L -o aiscript https://github.com/aiscript-dev/aiscript/releases/latest/download/aiscript-linux-x86_64
41+
42+
# Make it executable
43+
chmod +x aiscript
44+
45+
# Move to a directory in your PATH
46+
sudo mv aiscript /usr/local/bin/
47+
```
48+
49+
## macOS
50+
51+
```bash
52+
# Download the appropriate binary for your architecture (Intel or M1/M2)
53+
# For Intel Macs (x86_64):
54+
curl -L -o aiscript https://github.com/aiscript-dev/aiscript/releases/latest/download/aiscript-macos-x86_64
55+
# For Apple Silicon (M1/M2):
56+
curl -L -o aiscript https://github.com/aiscript-dev/aiscript/releases/latest/download/aiscript-macos-arm64
1257

13-
## Install via shell script
58+
# Make it executable
59+
chmod +x aiscript
60+
61+
# Move to a directory in your PATH
62+
sudo mv aiscript /usr/local/bin/
63+
```
64+
65+
## Windows
66+
67+
1. Download the [Windows executable](https://github.com/aiscript-dev/aiscript/releases/latest/download/aiscript-windows-x86_64.exe)
68+
2. Rename it to `aiscript.exe` if desired
69+
3. Move it to a directory in your PATH or create a directory for it and add that to your PATH
70+
71+
## Building from Source
72+
73+
If you prefer to build AIScript from source, you'll need Rust installed:
74+
75+
```bash
76+
# Clone the repository
77+
$ git clone https://github.com/aiscript-dev/aiscript.git
78+
$ cd aiscript
79+
# Build in release mode
80+
$ cargo build --release
81+
82+
# The binary will be in target/release/aiscript
83+
```
84+
85+
# Getting Started
86+
87+
After installation, you can run AIScript:
88+
89+
```bash
90+
# Check the version
91+
aiscript --version
92+
93+
# Run a script
94+
aiscript my_script.ai
95+
96+
# Enter interactive mode
97+
aiscript
98+
```
1499

15-
:::warning
16-
To be done
17-
:::
100+
Check out the documentation for more information on AIScript syntax and features.

docs/public/install.sh

+187
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,187 @@
1+
#!/bin/sh
2+
# AIScript Installer
3+
# This script detects the user's OS and architecture and downloads the appropriate AIScript binary
4+
5+
set -e
6+
7+
# Print error message and exit
8+
die() {
9+
echo "Error: $1" >&2
10+
exit 1
11+
}
12+
13+
# Get latest version from GitHub API
14+
get_latest_version() {
15+
if command -v curl >/dev/null 2>&1; then
16+
VERSION=$(curl -s https://api.github.com/repos/aiscript-dev/aiscript/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
17+
elif command -v wget >/dev/null 2>&1; then
18+
VERSION=$(wget -q -O- https://api.github.com/repos/aiscript-dev/aiscript/releases/latest | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
19+
else
20+
die "Neither curl nor wget found, please install one of them"
21+
fi
22+
23+
if [ -z "$VERSION" ]; then
24+
die "Could not determine the latest version"
25+
fi
26+
27+
echo "$VERSION"
28+
}
29+
30+
# Detect OS and architecture
31+
detect_platform() {
32+
OS=$(uname -s | tr '[:upper:]' '[:lower:]')
33+
ARCH=$(uname -m)
34+
35+
case "$OS" in
36+
linux*)
37+
OS="linux"
38+
;;
39+
darwin*)
40+
OS="macos"
41+
;;
42+
msys* | mingw* | cygwin* | win*)
43+
OS="windows"
44+
;;
45+
*)
46+
die "Unsupported operating system: $OS"
47+
;;
48+
esac
49+
50+
case "$ARCH" in
51+
x86_64 | amd64)
52+
ARCH="x86_64"
53+
;;
54+
arm64 | aarch64)
55+
if [ "$OS" = "macos" ]; then
56+
ARCH="arm64"
57+
else
58+
die "Unsupported architecture: $ARCH for $OS"
59+
fi
60+
;;
61+
*)
62+
die "Unsupported architecture: $ARCH"
63+
;;
64+
esac
65+
66+
# Return platform identifier
67+
if [ "$OS" = "windows" ]; then
68+
echo "aiscript-$OS-$ARCH.exe"
69+
else
70+
echo "aiscript-$OS-$ARCH"
71+
fi
72+
}
73+
74+
# Download a file
75+
download() {
76+
URL="$1"
77+
OUTPUT="$2"
78+
79+
if command -v curl >/dev/null 2>&1; then
80+
HTTP_CODE=$(curl -L -s -w "%{http_code}" "$URL" -o "$OUTPUT")
81+
if [ "$HTTP_CODE" != "200" ]; then
82+
die "Failed to download $URL (HTTP Status: $HTTP_CODE)"
83+
fi
84+
elif command -v wget >/dev/null 2>&1; then
85+
if ! wget --server-response -q "$URL" -O "$OUTPUT" 2>&1 | grep -q '200 OK'; then
86+
die "Failed to download $URL"
87+
fi
88+
else
89+
die "Neither curl nor wget found, please install one of them"
90+
fi
91+
}
92+
93+
# Verify the checksum of the downloaded file
94+
verify_checksum() {
95+
FILE="$1"
96+
EXPECTED_CHECKSUM="$2"
97+
98+
if command -v shasum >/dev/null 2>&1; then
99+
ACTUAL_CHECKSUM=$(shasum -a 256 "$FILE" | cut -d ' ' -f 1)
100+
elif command -v sha256sum >/dev/null 2>&1; then
101+
ACTUAL_CHECKSUM=$(sha256sum "$FILE" | cut -d ' ' -f 1)
102+
else
103+
echo "Warning: Neither shasum nor sha256sum found, skipping checksum verification"
104+
return 0
105+
fi
106+
107+
if [ "$ACTUAL_CHECKSUM" != "$EXPECTED_CHECKSUM" ]; then
108+
die "Checksum verification failed (expected: $EXPECTED_CHECKSUM, got: $ACTUAL_CHECKSUM)"
109+
fi
110+
111+
echo "Checksum verification successful"
112+
}
113+
114+
# Main function
115+
main() {
116+
echo "AIScript Installer"
117+
echo "----------------"
118+
119+
# Detect platform
120+
PLATFORM=$(detect_platform)
121+
echo "Detected platform: $PLATFORM"
122+
123+
# Get latest version
124+
VERSION=$(get_latest_version)
125+
echo "Latest version: $VERSION"
126+
127+
# Download binary
128+
BINARY_URL="https://github.com/aiscript-dev/aiscript/releases/download/${VERSION}/${PLATFORM}"
129+
CHECKSUM_URL="https://github.com/aiscript-dev/aiscript/releases/download/${VERSION}/checksums.txt"
130+
131+
echo "Downloading AIScript binary..."
132+
TMP_DIR=$(mktemp -d)
133+
BINARY_PATH="$TMP_DIR/aiscript"
134+
CHECKSUM_PATH="$TMP_DIR/checksums.txt"
135+
136+
download "$BINARY_URL" "$BINARY_PATH"
137+
download "$CHECKSUM_URL" "$CHECKSUM_PATH"
138+
139+
# Verify checksum
140+
echo "Verifying checksum..."
141+
EXPECTED_CHECKSUM=$(grep "$PLATFORM" "$CHECKSUM_PATH" | cut -d ' ' -f 1)
142+
verify_checksum "$BINARY_PATH" "$EXPECTED_CHECKSUM"
143+
144+
# Install binary
145+
INSTALL_DIR="$HOME/.aiscript/bin"
146+
INSTALL_PATH="$INSTALL_DIR/aiscript"
147+
148+
mkdir -p "$INSTALL_DIR"
149+
150+
echo "Installing AIScript to $INSTALL_PATH..."
151+
cp "$BINARY_PATH" "$INSTALL_PATH"
152+
chmod +x "$INSTALL_PATH"
153+
154+
# Clean up
155+
rm -rf "$TMP_DIR"
156+
157+
# Add to PATH if needed
158+
if [ -n "$SHELL" ]; then
159+
SHELL_NAME=$(basename "$SHELL")
160+
if [ "$SHELL_NAME" = "bash" ]; then
161+
PROFILE="$HOME/.bashrc"
162+
elif [ "$SHELL_NAME" = "zsh" ]; then
163+
PROFILE="$HOME/.zshrc"
164+
elif [ "$SHELL_NAME" = "fish" ]; then
165+
PROFILE="$HOME/.config/fish/config.fish"
166+
else
167+
PROFILE="$HOME/.profile"
168+
fi
169+
170+
if ! echo "$PATH" | grep -q "$INSTALL_DIR"; then
171+
echo "Adding AIScript to PATH in $PROFILE..."
172+
if [ "$SHELL_NAME" = "fish" ]; then
173+
echo 'set -gx PATH $PATH '"$INSTALL_DIR" >> "$PROFILE"
174+
else
175+
echo 'export PATH="$PATH:'"$INSTALL_DIR"'"' >> "$PROFILE"
176+
fi
177+
echo "Please restart your shell or run 'source $PROFILE' to update your PATH."
178+
fi
179+
else
180+
echo "To use AIScript, add $INSTALL_DIR to your PATH."
181+
fi
182+
183+
echo "AIScript $VERSION has been installed successfully!"
184+
echo "Run 'aiscript --help' to get started."
185+
}
186+
187+
main

theme/components/version-card/index.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const VersionCard: FC = () => {
1111
</div>
1212
<div className={styles.command}>
1313
<code className={styles.commandText}>
14-
cargo install aiscript
14+
curl https://aiscript.dev/install.sh | sh
1515
</code>
1616
</div>
1717
</div>

0 commit comments

Comments
 (0)