- Added system detection logic to handle different OS types (Linux, macOS, Windows). - Enhanced user creation logic to support non-root execution and proper ownership. - Updated directory creation to use dynamic home paths based on detected OS. - Improved Git configuration and metadata capture with error handling. - Modularized system package installation based on OS type. - Streamlined Node.js, Python, and Rust setup scripts with error handling. - Updated shell configuration to include dynamic aliases and environment info script. - Deprecated `devcontainer_image` variable in favor of `devcontainer_repo_url` for better repository management. - Adjusted Terraform workspace configuration to support new repository URL and caching options.
89 lines
3.1 KiB
Bash
89 lines
3.1 KiB
Bash
#!/bin/bash
|
|
# Convert CRLF to LF if present (handles Windows line endings)
|
|
if command -v dos2unix >/dev/null 2>&1; then
|
|
dos2unix "$0" 2>/dev/null || true
|
|
fi
|
|
|
|
set -e
|
|
echo "🤖 Installing Claude Code CLI..."
|
|
|
|
# Check if already installed
|
|
if command -v claude >/dev/null 2>&1; then
|
|
echo "✅ Claude Code already installed"
|
|
claude --version || echo "Claude Code version check failed"
|
|
exit 0
|
|
fi
|
|
|
|
# Cross-platform home directory detection
|
|
if [[ "$OSTYPE" == "msys" || "$OSTYPE" == "cygwin" || "$OSTYPE" == "win32" ]]; then
|
|
HOME_DIR="${USERPROFILE:-$HOME}"
|
|
BIN_DIR="$HOME_DIR/bin"
|
|
# Windows/WSL/Git Bash compatibility
|
|
export NVM_DIR="$HOME_DIR/.nvm"
|
|
else
|
|
HOME_DIR="$HOME"
|
|
BIN_DIR="/home/coder/bin"
|
|
export NVM_DIR="$HOME/.nvm"
|
|
fi
|
|
|
|
# Ensure npm is available
|
|
if [[ -s "$NVM_DIR/nvm.sh" ]]; then
|
|
# Use POSIX-compatible sourcing
|
|
. "$NVM_DIR/nvm.sh"
|
|
fi
|
|
|
|
if ! command -v npm >/dev/null 2>&1; then
|
|
echo "❌ npm not found - Node.js installation required"
|
|
exit 1
|
|
fi
|
|
|
|
echo "📥 Installing Claude Code globally via npm..."
|
|
npm install -g @anthropic-ai/claude
|
|
|
|
# Verify installation
|
|
if command -v claude >/dev/null 2>&1; then
|
|
echo "✅ Claude Code installed successfully!"
|
|
echo "🔧 Run 'claude auth login' to authenticate"
|
|
echo "💡 Use 'claude chat' for interactive assistance"
|
|
echo "💡 Use 'claude edit <file>' to edit files with AI"
|
|
|
|
# Create helper script with proper line endings
|
|
mkdir -p "$BIN_DIR"
|
|
|
|
# Use printf instead of cat with heredoc to ensure consistent line endings
|
|
{
|
|
printf '#!/bin/bash\n'
|
|
printf 'echo "🤖 Claude Code AI Assistant"\n'
|
|
printf 'echo "=========================="\n'
|
|
printf 'echo ""\n'
|
|
printf 'echo "Authentication:"\n'
|
|
printf 'echo " claude auth login # Authenticate with Anthropic"\n'
|
|
printf 'echo " claude auth logout # Sign out"\n'
|
|
printf 'echo " claude auth whoami # Check current user"\n'
|
|
printf 'echo ""\n'
|
|
printf 'echo "Interactive Chat:"\n'
|
|
printf 'echo " claude chat # Start interactive session"\n'
|
|
printf 'echo " claude chat '\''question'\'' # Single question"\n'
|
|
printf 'echo ""\n'
|
|
printf 'echo "File Editing:"\n'
|
|
printf 'echo " claude edit file.py # AI-powered file editing"\n'
|
|
printf 'echo " claude edit --help # Edit command options"\n'
|
|
printf 'echo ""\n'
|
|
printf 'echo "Code Analysis:"\n'
|
|
printf 'echo " claude analyze . # Analyze current directory"\n'
|
|
printf 'echo " claude review file.py # Code review"\n'
|
|
printf 'echo ""\n'
|
|
printf 'echo "Project Operations:"\n'
|
|
printf 'echo " claude init # Initialize Claude in project"\n'
|
|
printf 'echo " claude status # Show project status"\n'
|
|
printf 'echo ""\n'
|
|
printf 'echo "💡 For full documentation: https://docs.anthropic.com/claude/docs"\n'
|
|
} > "$BIN_DIR/claude-help"
|
|
|
|
chmod +x "$BIN_DIR/claude-help"
|
|
|
|
echo "💡 Run 'claude-help' for quick reference"
|
|
else
|
|
echo "❌ Claude Code installation failed"
|
|
exit 1
|
|
fi |