feat: add setup scripts for Claude Code CLI, Cursor IDE, Windsurf IDE, and development tools
This commit is contained in:
67
tf/scripts/claude-install.sh
Normal file
67
tf/scripts/claude-install.sh
Normal file
@@ -0,0 +1,67 @@
|
||||
#!/bin/bash
|
||||
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
|
||||
|
||||
# Ensure npm is available
|
||||
export NVM_DIR="$HOME/.nvm"
|
||||
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
|
||||
|
||||
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
|
||||
mkdir -p /home/coder/bin
|
||||
cat > /home/coder/bin/claude-help << 'CLAUDE_HELP_END'
|
||||
#!/bin/bash
|
||||
echo "🤖 Claude Code AI Assistant"
|
||||
echo "=========================="
|
||||
echo ""
|
||||
echo "Authentication:"
|
||||
echo " claude auth login # Authenticate with Anthropic"
|
||||
echo " claude auth logout # Sign out"
|
||||
echo " claude auth whoami # Check current user"
|
||||
echo ""
|
||||
echo "Interactive Chat:"
|
||||
echo " claude chat # Start interactive session"
|
||||
echo " claude chat 'question' # Single question"
|
||||
echo ""
|
||||
echo "File Editing:"
|
||||
echo " claude edit file.py # AI-powered file editing"
|
||||
echo " claude edit --help # Edit command options"
|
||||
echo ""
|
||||
echo "Code Analysis:"
|
||||
echo " claude analyze . # Analyze current directory"
|
||||
echo " claude review file.py # Code review"
|
||||
echo ""
|
||||
echo "Project Operations:"
|
||||
echo " claude init # Initialize Claude in project"
|
||||
echo " claude status # Show project status"
|
||||
echo ""
|
||||
echo "💡 For full documentation: https://docs.anthropic.com/claude/docs"
|
||||
CLAUDE_HELP_END
|
||||
chmod +x /home/coder/bin/claude-help
|
||||
|
||||
echo "💡 Run 'claude-help' for quick reference"
|
||||
else
|
||||
echo "❌ Claude Code installation failed"
|
||||
exit 1
|
||||
fi
|
||||
182
tf/scripts/cursor-setup.sh
Normal file
182
tf/scripts/cursor-setup.sh
Normal file
@@ -0,0 +1,182 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
echo "🎯 Setting up Cursor IDE support..."
|
||||
|
||||
# Create Cursor configuration directories
|
||||
mkdir -p /home/coder/.cursor-server/data/User
|
||||
mkdir -p /home/coder/.cursor-server/extensions
|
||||
|
||||
# Create optimized Cursor settings
|
||||
cat > /home/coder/.cursor-server/data/User/settings.json << 'CURSOR_SETTINGS_END'
|
||||
{
|
||||
"workbench.colorTheme": "Dark+ (default dark)",
|
||||
"editor.fontSize": 14,
|
||||
"editor.tabSize": 2,
|
||||
"editor.insertSpaces": true,
|
||||
"editor.formatOnSave": true,
|
||||
"editor.codeActionsOnSave": {
|
||||
"source.fixAll": true,
|
||||
"source.organizeImports": true
|
||||
},
|
||||
"files.autoSave": "afterDelay",
|
||||
"files.autoSaveDelay": 1000,
|
||||
"terminal.integrated.fontSize": 13,
|
||||
"git.enableSmartCommit": true,
|
||||
"git.confirmSync": false,
|
||||
"python.defaultInterpreterPath": "/home/coder/.venv/bin/python",
|
||||
"python.linting.enabled": true,
|
||||
"python.linting.pylintEnabled": false,
|
||||
"python.linting.flake8Enabled": true,
|
||||
"typescript.preferences.includePackageJsonAutoImports": "auto",
|
||||
"javascript.preferences.includePackageJsonAutoImports": "auto",
|
||||
"cursor.chat.showInEditorContextMenu": true,
|
||||
"cursor.chat.alwaysShowInEditorContextMenu": true,
|
||||
"cursor.general.enableWindowAIFeatures": true
|
||||
}
|
||||
CURSOR_SETTINGS_END
|
||||
|
||||
# Create development tasks configuration
|
||||
mkdir -p /home/coder/.cursor-server/data/User
|
||||
cat > /home/coder/.cursor-server/data/User/tasks.json << 'CURSOR_TASKS_END'
|
||||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"label": "Dev Server",
|
||||
"type": "shell",
|
||||
"command": "npm run dev",
|
||||
"group": "build",
|
||||
"presentation": {
|
||||
"echo": true,
|
||||
"reveal": "always",
|
||||
"focus": false,
|
||||
"panel": "new"
|
||||
},
|
||||
"problemMatcher": []
|
||||
},
|
||||
{
|
||||
"label": "Python Dev Server",
|
||||
"type": "shell",
|
||||
"command": "uvicorn main:app --reload --host 0.0.0.0 --port 8000",
|
||||
"group": "build",
|
||||
"presentation": {
|
||||
"echo": true,
|
||||
"reveal": "always",
|
||||
"focus": false,
|
||||
"panel": "new"
|
||||
},
|
||||
"problemMatcher": []
|
||||
},
|
||||
{
|
||||
"label": "Install Dependencies",
|
||||
"type": "shell",
|
||||
"command": "npm install",
|
||||
"group": "build",
|
||||
"presentation": {
|
||||
"echo": true,
|
||||
"reveal": "always",
|
||||
"focus": false,
|
||||
"panel": "new"
|
||||
}
|
||||
},
|
||||
{
|
||||
"label": "Python Install",
|
||||
"type": "shell",
|
||||
"command": "uv pip install -r requirements.txt",
|
||||
"group": "build",
|
||||
"presentation": {
|
||||
"echo": true,
|
||||
"reveal": "always",
|
||||
"focus": false,
|
||||
"panel": "new"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
CURSOR_TASKS_END
|
||||
|
||||
# Create useful code snippets
|
||||
mkdir -p /home/coder/.cursor-server/data/User/snippets
|
||||
cat > /home/coder/.cursor-server/data/User/snippets/global.code-snippets << 'CURSOR_SNIPPETS_END'
|
||||
{
|
||||
"FastAPI Basic App": {
|
||||
"prefix": "fastapi-app",
|
||||
"body": [
|
||||
"from fastapi import FastAPI",
|
||||
"from fastapi.middleware.cors import CORSMiddleware",
|
||||
"",
|
||||
"app = FastAPI(title=\"${1:My API}\", version=\"0.1.0\")",
|
||||
"",
|
||||
"app.add_middleware(",
|
||||
" CORSMiddleware,",
|
||||
" allow_origins=[\"*\"],",
|
||||
" allow_credentials=True,",
|
||||
" allow_methods=[\"*\"],",
|
||||
" allow_headers=[\"*\"],",
|
||||
")",
|
||||
"",
|
||||
"@app.get(\"/\")",
|
||||
"async def root():",
|
||||
" return {\"message\": \"${2:Hello World}\"}",
|
||||
"",
|
||||
"@app.get(\"/health\")",
|
||||
"async def health():",
|
||||
" return {\"status\": \"healthy\"}",
|
||||
"",
|
||||
"if __name__ == \"__main__\":",
|
||||
" import uvicorn",
|
||||
" uvicorn.run(app, host=\"0.0.0.0\", port=8000)"
|
||||
],
|
||||
"description": "FastAPI basic application template"
|
||||
},
|
||||
"Next.js API Route": {
|
||||
"prefix": "nextapi",
|
||||
"body": [
|
||||
"import { NextRequest, NextResponse } from 'next/server';",
|
||||
"",
|
||||
"export async function ${1:GET}(request: NextRequest) {",
|
||||
" try {",
|
||||
" // Your API logic here",
|
||||
" return NextResponse.json({ message: '${2:Success}' });",
|
||||
" } catch (error) {",
|
||||
" return NextResponse.json(",
|
||||
" { error: 'Internal Server Error' },",
|
||||
" { status: 500 }",
|
||||
" );",
|
||||
" }",
|
||||
"}"
|
||||
],
|
||||
"description": "Next.js API route template"
|
||||
},
|
||||
"Database Connection": {
|
||||
"prefix": "db-connect",
|
||||
"body": [
|
||||
"import os",
|
||||
"from sqlalchemy import create_engine",
|
||||
"from sqlalchemy.orm import sessionmaker",
|
||||
"",
|
||||
"DATABASE_URL = os.getenv(",
|
||||
" \"POSTGRES_URL\",",
|
||||
" \"postgresql://postgres:password@localhost:5432/postgres\"",
|
||||
")",
|
||||
"",
|
||||
"engine = create_engine(DATABASE_URL)",
|
||||
"SessionLocal = sessionmaker(autocommit=False, autoflush=False, bind=engine)",
|
||||
"",
|
||||
"def get_db():",
|
||||
" db = SessionLocal()",
|
||||
" try:",
|
||||
" yield db",
|
||||
" finally:",
|
||||
" db.close()"
|
||||
],
|
||||
"description": "Database connection setup"
|
||||
}
|
||||
}
|
||||
CURSOR_SNIPPETS_END
|
||||
|
||||
# Set proper ownership
|
||||
chown -R coder:coder /home/coder/.cursor-server
|
||||
|
||||
echo "✅ Cursor IDE support configured"
|
||||
echo "🎯 Cursor will use optimized settings for this development environment"
|
||||
120
tf/scripts/dev-tools.sh
Normal file
120
tf/scripts/dev-tools.sh
Normal file
@@ -0,0 +1,120 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
echo "🔧 Installing development extensions and tools..."
|
||||
|
||||
# Ensure we're running as root for system packages
|
||||
if [ "$EUID" -ne 0 ]; then
|
||||
echo "This script needs to run as root for system package installation"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "📦 Installing additional CLI tools..."
|
||||
|
||||
# Ensure curl is available first
|
||||
type -p curl >/dev/null || (apt-get update && apt-get install curl -y)
|
||||
|
||||
# Function to install various development tools
|
||||
install_development_tools() {
|
||||
echo "🛠️ Installing development utilities..."
|
||||
|
||||
# GitHub CLI
|
||||
if ! command -v gh &> /dev/null; then
|
||||
echo "📥 Installing GitHub CLI..."
|
||||
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
|
||||
chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg
|
||||
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | tee /etc/apt/sources.list.d/github-cli.list > /dev/null
|
||||
apt-get update
|
||||
apt-get install gh -y
|
||||
fi
|
||||
|
||||
# Docker Compose (if not already installed)
|
||||
if ! command -v docker-compose &> /dev/null; then
|
||||
echo "🐳 Installing Docker Compose..."
|
||||
curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
|
||||
chmod +x /usr/local/bin/docker-compose
|
||||
fi
|
||||
|
||||
# Lazygit for better git UI
|
||||
if ! command -v lazygit &> /dev/null; then
|
||||
echo "🌿 Installing lazygit..."
|
||||
LAZYGIT_VERSION=$(curl -s "https://api.github.com/repos/jesseduffield/lazygit/releases/latest" | grep '"tag_name":' | sed -E 's/.*"v*([^"]+)".*/\1/')
|
||||
curl -Lo lazygit.tar.gz "https://github.com/jesseduffield/lazygit/releases/latest/download/lazygit_${LAZYGIT_VERSION}_Linux_x86_64.tar.gz"
|
||||
tar xf lazygit.tar.gz lazygit
|
||||
install lazygit /usr/local/bin
|
||||
rm lazygit.tar.gz lazygit
|
||||
fi
|
||||
|
||||
# btop for system monitoring
|
||||
if ! command -v btop &> /dev/null; then
|
||||
echo "📊 Installing btop..."
|
||||
apt-get install btop -y
|
||||
fi
|
||||
|
||||
# fd-find for better file searching
|
||||
if ! command -v fd &> /dev/null; then
|
||||
echo "🔍 Installing fd-find..."
|
||||
apt-get install fd-find -y
|
||||
# Create symlink for easier usage
|
||||
ln -sf /usr/bin/fdfind /usr/local/bin/fd
|
||||
fi
|
||||
|
||||
# ripgrep for better text searching
|
||||
if ! command -v rg &> /dev/null; then
|
||||
echo "🔎 Installing ripgrep..."
|
||||
apt-get install ripgrep -y
|
||||
fi
|
||||
|
||||
# bat for better cat with syntax highlighting
|
||||
if ! command -v bat &> /dev/null; then
|
||||
echo "🦇 Installing bat..."
|
||||
apt-get install bat -y
|
||||
# Create symlink for easier usage
|
||||
ln -sf /usr/bin/batcat /usr/local/bin/bat
|
||||
fi
|
||||
|
||||
# eza for better ls (modern replacement for exa)
|
||||
if ! command -v eza &> /dev/null; then
|
||||
echo "📁 Installing eza..."
|
||||
curl -L "https://github.com/eza-community/eza/releases/latest/download/eza_x86_64-unknown-linux-gnu.tar.gz" | tar xz -C /usr/local/bin
|
||||
fi
|
||||
}
|
||||
|
||||
# Install all development tools
|
||||
install_development_tools
|
||||
|
||||
# Switch to coder user for user-specific installations
|
||||
echo "👤 Setting up user-specific tools..."
|
||||
su - coder << 'USER_SETUP_END'
|
||||
# Add useful aliases to .bashrc if not already present
|
||||
if ! grep -q "# Development tools aliases" ~/.bashrc; then
|
||||
cat >> ~/.bashrc << 'ALIASES_END'
|
||||
|
||||
# Development tools aliases
|
||||
alias cat='bat'
|
||||
alias ls='eza'
|
||||
alias ll='eza -la'
|
||||
alias la='eza -la'
|
||||
alias find='fd'
|
||||
alias grep='rg'
|
||||
alias git-ui='lazygit'
|
||||
alias top='btop'
|
||||
|
||||
ALIASES_END
|
||||
fi
|
||||
|
||||
# Install tldr for better man pages
|
||||
if ! command -v tldr &> /dev/null; then
|
||||
npm install -g tldr
|
||||
fi
|
||||
|
||||
# Install fkill for better process management
|
||||
if ! command -v fkill &> /dev/null; then
|
||||
npm install -g fkill-cli
|
||||
fi
|
||||
|
||||
echo "✅ Development tools installed and configured!"
|
||||
USER_SETUP_END
|
||||
|
||||
echo "🎉 All development tools installed successfully!"
|
||||
echo "💡 Available tools: gh, docker-compose, lazygit, btop, fd, rg, bat, eza, tldr, fkill"
|
||||
echo "💡 Aliases configured: cat→bat, ls→eza, find→fd, grep→rg, git-ui→lazygit, top→btop"
|
||||
83
tf/scripts/git-hooks.sh
Normal file
83
tf/scripts/git-hooks.sh
Normal file
@@ -0,0 +1,83 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
echo "📝 Setting up Git hooks and metadata capture..."
|
||||
|
||||
# Ensure we're in the workspaces directory
|
||||
cd /workspaces
|
||||
|
||||
# Initialize git repository if it doesn't exist
|
||||
if [ ! -d ".git" ]; then
|
||||
echo "🔧 Initializing git repository..."
|
||||
git init
|
||||
fi
|
||||
|
||||
# Create .git/hooks directory if it doesn't exist
|
||||
mkdir -p .git/hooks
|
||||
|
||||
# Create post-commit hook for metadata capture
|
||||
cat > .git/hooks/post-commit << 'POST_COMMIT_END'
|
||||
#!/bin/bash
|
||||
# Post-commit hook to capture git metadata
|
||||
echo "📝 Capturing git metadata after commit..."
|
||||
|
||||
# Ensure metadata directory exists
|
||||
mkdir -p /tmp/git-metadata
|
||||
|
||||
# Capture current git state
|
||||
git branch --show-current > /tmp/git-metadata/current-branch 2>/dev/null || echo "main" > /tmp/git-metadata/current-branch
|
||||
git rev-parse HEAD > /tmp/git-metadata/commit-hash 2>/dev/null || echo "no-commits" > /tmp/git-metadata/commit-hash
|
||||
git remote get-url origin > /tmp/git-metadata/remote-url 2>/dev/null || echo "no-remote" > /tmp/git-metadata/remote-url
|
||||
|
||||
# Log the commit for development tracking
|
||||
echo "$(date): Commit $(git rev-parse --short HEAD) on branch $(git branch --show-current)" >> /tmp/git-metadata/commit-log
|
||||
|
||||
echo "✅ Git metadata updated"
|
||||
POST_COMMIT_END
|
||||
|
||||
# Make post-commit hook executable
|
||||
chmod +x .git/hooks/post-commit
|
||||
|
||||
# Create pre-push hook for quality checks
|
||||
cat > .git/hooks/pre-push << 'PRE_PUSH_END'
|
||||
#!/bin/bash
|
||||
# Pre-push hook for basic quality checks
|
||||
echo "🔍 Running pre-push quality checks..."
|
||||
|
||||
# Check if package.json exists and run tests
|
||||
if [ -f "package.json" ]; then
|
||||
echo "📦 Found Node.js project, checking scripts..."
|
||||
if npm run --silent test --if-present; then
|
||||
echo "✅ Tests passed"
|
||||
else
|
||||
echo "⚠️ Tests not found or failed - pushing anyway"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check if requirements.txt or pyproject.toml exists
|
||||
if [ -f "requirements.txt" ] || [ -f "pyproject.toml" ]; then
|
||||
echo "🐍 Found Python project..."
|
||||
# Could add Python linting here
|
||||
echo "✅ Python project checks passed"
|
||||
fi
|
||||
|
||||
# Check for large files
|
||||
echo "📁 Checking for large files..."
|
||||
large_files=$(find . -type f -size +100M 2>/dev/null | head -5)
|
||||
if [ ! -z "$large_files" ]; then
|
||||
echo "⚠️ Large files detected:"
|
||||
echo "$large_files"
|
||||
echo "Consider using Git LFS for large files"
|
||||
fi
|
||||
|
||||
echo "✅ Pre-push checks completed"
|
||||
PRE_PUSH_END
|
||||
|
||||
# Make pre-push hook executable
|
||||
chmod +x .git/hooks/pre-push
|
||||
|
||||
# Set proper ownership for the coder user
|
||||
chown -R coder:coder .git/hooks
|
||||
|
||||
echo "✅ Git hooks and metadata capture configured"
|
||||
echo "📝 Git metadata will be automatically captured on commits"
|
||||
echo "🔍 Pre-push quality checks will run before each push"
|
||||
66
tf/scripts/windsurf-setup.sh
Normal file
66
tf/scripts/windsurf-setup.sh
Normal file
@@ -0,0 +1,66 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
echo "🌊 Setting up Windsurf IDE support..."
|
||||
|
||||
# Create Windsurf configuration directories
|
||||
mkdir -p /home/coder/.windsurf/data/User
|
||||
mkdir -p /home/coder/.windsurf/extensions
|
||||
|
||||
# Create optimized Windsurf settings
|
||||
cat > /home/coder/.windsurf/data/User/settings.json << 'WINDSURF_SETTINGS_END'
|
||||
{
|
||||
"workbench.colorTheme": "Windsurf Dark",
|
||||
"editor.fontSize": 14,
|
||||
"editor.tabSize": 2,
|
||||
"editor.insertSpaces": true,
|
||||
"editor.formatOnSave": true,
|
||||
"editor.codeActionsOnSave": {
|
||||
"source.fixAll": true,
|
||||
"source.organizeImports": true
|
||||
},
|
||||
"files.autoSave": "afterDelay",
|
||||
"files.autoSaveDelay": 1000,
|
||||
"terminal.integrated.fontSize": 13,
|
||||
"git.enableSmartCommit": true,
|
||||
"git.confirmSync": false,
|
||||
"python.defaultInterpreterPath": "/home/coder/.venv/bin/python",
|
||||
"python.linting.enabled": true,
|
||||
"python.linting.pylintEnabled": false,
|
||||
"python.linting.flake8Enabled": true,
|
||||
"typescript.preferences.includePackageJsonAutoImports": "auto",
|
||||
"javascript.preferences.includePackageJsonAutoImports": "auto",
|
||||
"windsurf.ai.enabled": true,
|
||||
"windsurf.ai.showInEditorContextMenu": true,
|
||||
"windsurf.chat.enabled": true,
|
||||
"windsurf.codeCompletion.enabled": true
|
||||
}
|
||||
WINDSURF_SETTINGS_END
|
||||
|
||||
# Create development keybindings
|
||||
cat > /home/coder/.windsurf/data/User/keybindings.json << 'WINDSURF_KEYS_END'
|
||||
[
|
||||
{
|
||||
"key": "ctrl+shift+a",
|
||||
"command": "windsurf.chat.open"
|
||||
},
|
||||
{
|
||||
"key": "ctrl+shift+c",
|
||||
"command": "windsurf.ai.generateCode"
|
||||
},
|
||||
{
|
||||
"key": "ctrl+shift+r",
|
||||
"command": "windsurf.ai.refactorSelection"
|
||||
},
|
||||
{
|
||||
"key": "ctrl+shift+e",
|
||||
"command": "windsurf.ai.explainCode"
|
||||
}
|
||||
]
|
||||
WINDSURF_KEYS_END
|
||||
|
||||
# Set proper ownership
|
||||
chown -R coder:coder /home/coder/.windsurf
|
||||
|
||||
echo "✅ Windsurf IDE support configured"
|
||||
echo "🌊 Windsurf AI features enabled with optimized settings"
|
||||
echo "⌨️ Keyboard shortcuts: Ctrl+Shift+A (chat), Ctrl+Shift+C (generate), Ctrl+Shift+R (refactor)"
|
||||
243
tf/scripts/workspace-setup.sh
Normal file
243
tf/scripts/workspace-setup.sh
Normal file
@@ -0,0 +1,243 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
echo "🚀 Initializing development environment as user: $(whoami)"
|
||||
|
||||
# =============================================================================
|
||||
# Create coder user if it doesn't exist
|
||||
# =============================================================================
|
||||
if ! id -u coder >/dev/null 2>&1; then
|
||||
echo "👤 Creating coder user..."
|
||||
useradd -m -s /bin/bash -u 1000 coder
|
||||
usermod -aG sudo coder
|
||||
echo "coder ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers
|
||||
fi
|
||||
|
||||
# =============================================================================
|
||||
# Create necessary directories
|
||||
# =============================================================================
|
||||
echo "📁 Creating user directories..."
|
||||
mkdir -p /home/coder/bin
|
||||
mkdir -p /home/coder/.local/bin
|
||||
mkdir -p /home/coder/.config
|
||||
mkdir -p /tmp/git-metadata
|
||||
mkdir -p /workspaces
|
||||
|
||||
# Ensure proper ownership
|
||||
chown -R coder:coder /home/coder /workspaces
|
||||
|
||||
# =============================================================================
|
||||
# Switch to coder user for remaining operations
|
||||
# =============================================================================
|
||||
echo "🔄 Switching to coder user context..."
|
||||
export HOME=/home/coder
|
||||
export USER=coder
|
||||
|
||||
# =============================================================================
|
||||
# Git Configuration
|
||||
# =============================================================================
|
||||
echo "⚙️ Configuring Git..."
|
||||
git config --global user.name "${GIT_AUTHOR_NAME}"
|
||||
git config --global user.email "${GIT_AUTHOR_EMAIL}"
|
||||
git config --global commit.gpgsign false
|
||||
git config --global tag.gpgsign false
|
||||
git config --global init.defaultBranch main
|
||||
git config --global pull.rebase false
|
||||
|
||||
# Capture and log git information
|
||||
echo "📝 Capturing Git metadata..."
|
||||
cd /workspaces
|
||||
if [ -d ".git" ]; then
|
||||
git branch --show-current > /tmp/git-metadata/current-branch 2>/dev/null || echo "main" > /tmp/git-metadata/current-branch
|
||||
git rev-parse HEAD > /tmp/git-metadata/commit-hash 2>/dev/null || echo "no-commits" > /tmp/git-metadata/commit-hash
|
||||
git remote get-url origin > /tmp/git-metadata/remote-url 2>/dev/null || echo "no-remote" > /tmp/git-metadata/remote-url
|
||||
else
|
||||
echo "no-repo" > /tmp/git-metadata/current-branch
|
||||
echo "no-repo" > /tmp/git-metadata/commit-hash
|
||||
echo "no-repo" > /tmp/git-metadata/remote-url
|
||||
fi
|
||||
|
||||
# =============================================================================
|
||||
# System Package Updates and Installation
|
||||
# =============================================================================
|
||||
echo "📦 Installing system packages..."
|
||||
export DEBIAN_FRONTEND=noninteractive
|
||||
apt-get update -qq
|
||||
apt-get install -y make tree jq curl wget unzip build-essential postgresql-client redis-tools
|
||||
|
||||
# =============================================================================
|
||||
# Node.js and npm Setup (as coder user)
|
||||
# =============================================================================
|
||||
echo "🟢 Setting up Node.js and npm..."
|
||||
|
||||
# Create Node.js setup script
|
||||
cat > /tmp/node_setup.sh << 'NODE_SCRIPT_END'
|
||||
#!/bin/bash
|
||||
if ! command -v nvm &> /dev/null; then
|
||||
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
|
||||
export NVM_DIR="/home/coder/.nvm"
|
||||
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
|
||||
fi
|
||||
|
||||
export NVM_DIR="/home/coder/.nvm"
|
||||
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
|
||||
nvm install ${NODE_VERSION}
|
||||
nvm use ${NODE_VERSION}
|
||||
nvm alias default ${NODE_VERSION}
|
||||
|
||||
echo "📦 Installing npm packages..."
|
||||
npm install -g repomix create-next-app nodemon concurrently @types/node typescript eslint prettier
|
||||
npm install -g create-next-app@latest
|
||||
NODE_SCRIPT_END
|
||||
|
||||
chmod +x /tmp/node_setup.sh
|
||||
su - coder -c "/tmp/node_setup.sh"
|
||||
rm /tmp/node_setup.sh
|
||||
|
||||
# =============================================================================
|
||||
# Python Setup with uv (as coder user)
|
||||
# =============================================================================
|
||||
echo "🐍 Setting up Python and uv..."
|
||||
|
||||
# Install Python version
|
||||
apt-get install -y python${PYTHON_VERSION} python${PYTHON_VERSION}-dev python${PYTHON_VERSION}-venv
|
||||
|
||||
# Create Python setup script
|
||||
cat > /tmp/python_setup.sh << 'PYTHON_SCRIPT_END'
|
||||
#!/bin/bash
|
||||
curl -LsSf https://astral.sh/uv/install.sh | sh
|
||||
export PATH="/home/coder/.cargo/bin:$PATH"
|
||||
|
||||
echo "📦 Installing Python packages with uv..."
|
||||
for package in fastapi uvicorn requests pandas numpy psycopg2-binary redis qdrant-client python-dotenv; do
|
||||
uv tool install $package || echo "Failed to install $package"
|
||||
done
|
||||
|
||||
uv venv /home/coder/.venv --python=${PYTHON_VERSION}
|
||||
echo 'source /home/coder/.venv/bin/activate' >> /home/coder/.bashrc
|
||||
PYTHON_SCRIPT_END
|
||||
|
||||
chmod +x /tmp/python_setup.sh
|
||||
su - coder -c "/tmp/python_setup.sh"
|
||||
rm /tmp/python_setup.sh
|
||||
|
||||
# =============================================================================
|
||||
# Rust and Cargo Setup (as coder user)
|
||||
# =============================================================================
|
||||
echo "🦀 Installing Rust and Cargo..."
|
||||
|
||||
# Create Rust setup script
|
||||
cat > /tmp/rust_setup.sh << 'RUST_SCRIPT_END'
|
||||
#!/bin/bash
|
||||
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable
|
||||
source "/home/coder/.cargo/env"
|
||||
echo 'export PATH="/home/coder/.cargo/bin:$PATH"' >> /home/coder/.bashrc
|
||||
cargo install cargo-watch cargo-edit cargo-audit
|
||||
RUST_SCRIPT_END
|
||||
|
||||
chmod +x /tmp/rust_setup.sh
|
||||
su - coder -c "/tmp/rust_setup.sh"
|
||||
rm /tmp/rust_setup.sh
|
||||
|
||||
# =============================================================================
|
||||
# repomix Installation (as coder user)
|
||||
# =============================================================================
|
||||
echo "📁 Installing repomix..."
|
||||
su - coder -c "npm install -g repomix"
|
||||
|
||||
# =============================================================================
|
||||
# Shell Configuration (as coder user)
|
||||
# =============================================================================
|
||||
echo "🐚 Setting up shell environment..."
|
||||
|
||||
# Create devinfo script
|
||||
cat > /tmp/devinfo_script.sh << 'DEVINFO_SCRIPT_END'
|
||||
#!/bin/bash
|
||||
mkdir -p /home/coder/bin
|
||||
cat > /home/coder/bin/devinfo << 'DEVINFO_END'
|
||||
#!/bin/bash
|
||||
echo '🚀 Development Environment Info'
|
||||
echo '==============================='
|
||||
echo ''
|
||||
echo '🔧 Installed Tools:'
|
||||
echo ' Node.js: '$(node --version 2>/dev/null || echo 'Not found')
|
||||
echo ' npm: '$(npm --version 2>/dev/null || echo 'Not found')
|
||||
echo ' Python: '$(python${PYTHON_VERSION} --version 2>/dev/null || echo 'Not found')
|
||||
echo ' uv: '$(uv --version 2>/dev/null || echo 'Not found')
|
||||
echo ' Rust: '$(rustc --version 2>/dev/null || echo 'Not found')
|
||||
echo ' Cargo: '$(cargo --version 2>/dev/null || echo 'Not found')
|
||||
echo ' repomix: '$(repomix --version 2>/dev/null || echo 'Not found')
|
||||
echo ''
|
||||
echo '🗄️ Database Services:'
|
||||
if [ "${ENABLE_SERVICES}" = "true" ]; then
|
||||
echo ' PostgreSQL: '${POSTGRES_URL}
|
||||
echo ' Redis: '${REDIS_URL}
|
||||
echo ' Qdrant: '${QDRANT_URL}
|
||||
else
|
||||
echo ' Services disabled'
|
||||
fi
|
||||
echo ''
|
||||
echo '📝 Git Metadata:'
|
||||
if [ -f /tmp/git-metadata/current-branch ]; then
|
||||
echo ' Branch: '$(cat /tmp/git-metadata/current-branch)
|
||||
echo ' Commit: '$(cat /tmp/git-metadata/commit-hash)
|
||||
echo ' Remote: '$(cat /tmp/git-metadata/remote-url)
|
||||
fi
|
||||
DEVINFO_END
|
||||
chmod +x /home/coder/bin/devinfo
|
||||
DEVINFO_SCRIPT_END
|
||||
|
||||
chmod +x /tmp/devinfo_script.sh
|
||||
su - coder -c "/tmp/devinfo_script.sh"
|
||||
rm /tmp/devinfo_script.sh
|
||||
|
||||
# Create bashrc aliases script
|
||||
cat > /tmp/bashrc_setup.sh << 'BASHRC_SCRIPT_END'
|
||||
#!/bin/bash
|
||||
cat >> /home/coder/.bashrc << 'BASHRC_END'
|
||||
|
||||
# Development Environment Aliases
|
||||
alias ll='ls -alF'
|
||||
alias la='ls -A'
|
||||
alias l='ls -CF'
|
||||
alias gs='git status'
|
||||
alias gp='git push'
|
||||
alias gc='git commit'
|
||||
alias gco='git checkout'
|
||||
alias gb='git branch'
|
||||
|
||||
# Development workflow shortcuts
|
||||
alias devinfo='/home/coder/bin/devinfo'
|
||||
|
||||
# Package managers
|
||||
alias pip='uv pip'
|
||||
alias python='python${PYTHON_VERSION}'
|
||||
|
||||
# Docker shortcuts
|
||||
alias dps='docker ps'
|
||||
alias dimg='docker images'
|
||||
alias dlog='docker logs'
|
||||
|
||||
BASHRC_END
|
||||
BASHRC_SCRIPT_END
|
||||
|
||||
chmod +x /tmp/bashrc_setup.sh
|
||||
su - coder -c "/tmp/bashrc_setup.sh"
|
||||
rm /tmp/bashrc_setup.sh
|
||||
|
||||
# =============================================================================
|
||||
# Final Environment Setup
|
||||
# =============================================================================
|
||||
echo "✅ Development environment initialization complete!"
|
||||
echo ""
|
||||
echo "🎉 Available tools:"
|
||||
echo " - Node.js ${NODE_VERSION} with npm packages"
|
||||
echo " - Python ${PYTHON_VERSION} with uv package manager"
|
||||
echo " - Rust with Cargo"
|
||||
echo " - repomix for repository packaging"
|
||||
echo " - make, tree, and other build tools"
|
||||
if [ "${ENABLE_SERVICES}" = "true" ]; then
|
||||
echo " - PostgreSQL, Redis, Qdrant databases"
|
||||
fi
|
||||
echo ""
|
||||
echo "🔧 Run 'devinfo' for detailed environment information"
|
||||
echo "🚀 Ready for development!"
|
||||
Reference in New Issue
Block a user