Skip to content

Commit ec05081

Browse files
committed
update install script
1 parent 274e23c commit ec05081

File tree

2 files changed

+39
-70
lines changed

2 files changed

+39
-70
lines changed

install.sh

Lines changed: 37 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,47 @@
1-
#!/bin/bash
1+
#!/usr/bin/env bash
2+
set -euo pipefail
23

3-
# Function to print error messages in red
4-
error() {
5-
echo -e "\033[0;31merror:\033[0m $1" >&2
6-
exit 1
7-
}
4+
# [Initialize color codes and helper functions as in bun.sh]
85

9-
# Function to print information in dim color
10-
info() {
11-
echo -e "\033[0;2m$1\033[0m"
12-
}
6+
# Check for bun
7+
command -v bun >/dev/null ||
8+
error 'bun is required to run aitdd. Please install bun first.'
139

14-
# Function to install bun
15-
install_bun() {
16-
info "Installing bun..."
17-
curl -fsSL https://bun.sh/install | bash
18-
}
10+
# Define the GitHub repository URL
11+
github_repo="https://github.com/di-sukharev/AI-TDD"
1912

20-
# Check for bun and install if not present
21-
if ! command -v bun &> /dev/null; then
22-
install_bun
23-
else
24-
info "bun is already installed. Good. Continue."
25-
fi
13+
# Construct the download URL for your CLI
14+
# Modify this URL to point to the specific release or directory containing cli.ts
15+
aitdd_uri="$github_repo/releases/latest/download/out.zip"
2616

27-
# Define installation directory
28-
BIN_DIR="$HOME/.local/bin"
29-
mkdir -p "$BIN_DIR"
17+
# Define the installation directory
18+
install_dir=${HOME}/.aitdd
19+
bin_dir=$install_dir/bin
20+
exe=$bin_dir/aitdd
3021

31-
# Create a symbolic link to the CLI tool
32-
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)
33-
CLI_FILE="$SCRIPT_DIR/cli.ts"
34-
ln -sf "$CLI_FILE" "$BIN_DIR/aitdd"
22+
# Create the installation directory if it doesn't exist
23+
mkdir -p "$bin_dir" ||
24+
error "Failed to create install directory \"$bin_dir\""
3525

36-
# Detect the shell and update the corresponding configuration file
37-
SHELL_NAME=$(basename "$SHELL")
38-
case "$SHELL_NAME" in
39-
bash)
40-
SHELL_CONFIG="$HOME/.bashrc"
41-
;;
42-
zsh)
43-
SHELL_CONFIG="$HOME/.zshrc"
44-
;;
45-
fish)
46-
SHELL_CONFIG="$HOME/.config/fish/config.fish"
47-
;;
48-
*)
49-
SHELL_CONFIG=""
50-
;;
51-
esac
26+
# Download and extract your CLI files
27+
curl --fail --location --output "$exe.zip" "$aitdd_uri" ||
28+
error "Failed to download aitdd from \"$aitdd_uri\""
5229

53-
# Update PATH in the user's shell configuration file
54-
if [[ -n $SHELL_CONFIG && -w $SHELL_CONFIG ]]; then
55-
if ! grep -q "$BIN_DIR" "$SHELL_CONFIG"; then
56-
if [[ "$SHELL_NAME" == "fish" ]]; then
57-
echo "set -gx PATH \"$BIN_DIR\" \$PATH" >> "$SHELL_CONFIG"
58-
else
59-
echo "export PATH=\"$BIN_DIR:\$PATH\"" >> "$SHELL_CONFIG"
60-
fi
61-
info "Added $BIN_DIR to PATH in $SHELL_CONFIG"
62-
fi
63-
else
64-
info "Could not update PATH automatically. Please add $BIN_DIR to your PATH manually."
65-
fi
30+
unzip -oqd "$install_dir" "$exe.zip" ||
31+
error 'Failed to extract aitdd'
6632

67-
# Refresh environment (this won't affect the parent shell)
68-
export PATH="$BIN_DIR:$PATH"
33+
# Create the aitdd wrapper command
34+
cat <<EOF >"$exe"
35+
#!/usr/bin/env bash
36+
set -euo pipefail
37+
bun $install_dir/src/cli.ts "\$@"
38+
EOF
6939

70-
# Check if the tool is available in the PATH
71-
if command -v aitdd &> /dev/null; then
72-
info "aitdd tool installed successfully and is available in your PATH."
73-
else
74-
info "Installation complete, but the aitdd tool is not in your PATH. Please restart your shell or source your shell configuration file."
75-
fi
40+
# Make the wrapper executable
41+
chmod +x "$exe" ||
42+
error 'Failed to set permissions on aitdd executable'
43+
44+
# [Optional: Provide instructions for adding $bin_dir to PATH]
45+
46+
# Success message
47+
success "aitdd was installed successfully"

package.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
{
2-
"version": "2.1.7",
2+
"version": "0.0.1",
33
"name": "ai-tdd",
44
"description": "You write a test -> GPT writes the code to pass it ✅",
55
"bin": {
6-
"aitdd": ".cli.ts"
6+
"aitdd": "./cli.ts"
77
},
88
"author": "https://github.com/di-sukharev",
99
"module": "cli.ts",
1010
"type": "module",
11-
"files": [
12-
"./out/cli.js"
13-
],
1411
"release": {
1512
"branches": [
1613
"master"

0 commit comments

Comments
 (0)