git commit -m "feat: initial release of Strata framework v0.1.0
- Static compiler with STRC pattern (Static Template Resolution with
Compartmentalized Layers)
- Template syntax: { } interpolation, { s-for }, { s-if/s-elif/s-else
}
- File types: .strata, .compiler.sts, .service.sts, .api.sts, .sts,
.scss
- CLI tools: strata dev, strata build, strata g (generators)
- create-strata scaffolding CLI with Pokemon API example
- Dev server with WebSocket HMR (Hot Module Replacement)
- Documentation: README, ARCHITECTURE, CHANGELOG, CONTRIBUTING,
LICENSE
This commit is contained in:
294
scripts/doctor.sh
Executable file
294
scripts/doctor.sh
Executable file
@@ -0,0 +1,294 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Strata Framework - Doctor Script
|
||||
# Diagnoses installation issues and provides fixes
|
||||
# Usage: ./scripts/doctor.sh [--fix]
|
||||
|
||||
set -e
|
||||
|
||||
# Colors
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
CYAN='\033[0;36m'
|
||||
NC='\033[0m'
|
||||
BOLD='\033[1m'
|
||||
|
||||
# Directories
|
||||
STRATA_HOME="${STRATA_HOME:-$HOME/.strata}"
|
||||
STRATA_BIN="$STRATA_HOME/bin"
|
||||
STRATA_CONFIG="$STRATA_HOME/config"
|
||||
LOCAL_BIN="/usr/local/bin"
|
||||
|
||||
# Script directory
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_DIR="$(dirname "$SCRIPT_DIR")"
|
||||
|
||||
# Options
|
||||
AUTO_FIX=false
|
||||
|
||||
if [ "$1" = "--fix" ] || [ "$1" = "-f" ]; then
|
||||
AUTO_FIX=true
|
||||
fi
|
||||
|
||||
if [ "$1" = "--help" ] || [ "$1" = "-h" ]; then
|
||||
echo "Strata Framework - Doctor"
|
||||
echo ""
|
||||
echo "Usage: ./scripts/doctor.sh [options]"
|
||||
echo ""
|
||||
echo "Options:"
|
||||
echo " --fix, -f Automatically fix issues where possible"
|
||||
echo " --help Show this help message"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Counters
|
||||
ISSUES=0
|
||||
WARNINGS=0
|
||||
FIXES=0
|
||||
|
||||
print_check() {
|
||||
echo -e "${BLUE}[CHECK]${NC} $1"
|
||||
}
|
||||
|
||||
print_ok() {
|
||||
echo -e "${GREEN} [OK]${NC} $1"
|
||||
}
|
||||
|
||||
print_warn() {
|
||||
echo -e "${YELLOW} [WARN]${NC} $1"
|
||||
((WARNINGS++))
|
||||
}
|
||||
|
||||
print_fail() {
|
||||
echo -e "${RED} [FAIL]${NC} $1"
|
||||
((ISSUES++))
|
||||
}
|
||||
|
||||
print_fix() {
|
||||
echo -e "${CYAN} [FIX]${NC} $1"
|
||||
((FIXES++))
|
||||
}
|
||||
|
||||
print_info() {
|
||||
echo -e " $1"
|
||||
}
|
||||
|
||||
echo ""
|
||||
echo -e "${CYAN}╔═══════════════════════════════════════════════════════╗${NC}"
|
||||
echo -e "${CYAN}║ Strata Framework - Doctor ║${NC}"
|
||||
echo -e "${CYAN}╚═══════════════════════════════════════════════════════╝${NC}"
|
||||
echo ""
|
||||
|
||||
# Check Go installation
|
||||
print_check "Go installation"
|
||||
if command -v go &> /dev/null; then
|
||||
GO_VERSION=$(go version | grep -oE 'go[0-9]+\.[0-9]+' | sed 's/go//')
|
||||
GO_MAJOR=$(echo "$GO_VERSION" | cut -d. -f1)
|
||||
GO_MINOR=$(echo "$GO_VERSION" | cut -d. -f2)
|
||||
if [ "$GO_MAJOR" -ge 1 ] && [ "$GO_MINOR" -ge 21 ]; then
|
||||
print_ok "Go $GO_VERSION installed"
|
||||
else
|
||||
print_warn "Go $GO_VERSION installed (>= 1.21 recommended)"
|
||||
fi
|
||||
else
|
||||
print_fail "Go is not installed"
|
||||
print_info "Install from: https://go.dev/dl/"
|
||||
fi
|
||||
|
||||
# Check Node.js installation
|
||||
print_check "Node.js installation"
|
||||
if command -v node &> /dev/null; then
|
||||
NODE_VERSION=$(node -v | sed 's/v//')
|
||||
NODE_MAJOR=$(echo "$NODE_VERSION" | cut -d. -f1)
|
||||
if [ "$NODE_MAJOR" -ge 18 ]; then
|
||||
print_ok "Node.js $NODE_VERSION installed"
|
||||
else
|
||||
print_fail "Node.js $NODE_VERSION installed (>= 18.0 required)"
|
||||
print_info "Install from: https://nodejs.org/"
|
||||
fi
|
||||
else
|
||||
print_fail "Node.js is not installed"
|
||||
print_info "Install from: https://nodejs.org/"
|
||||
fi
|
||||
|
||||
# Check npm installation
|
||||
print_check "npm installation"
|
||||
if command -v npm &> /dev/null; then
|
||||
NPM_VERSION=$(npm -v)
|
||||
print_ok "npm $NPM_VERSION installed"
|
||||
else
|
||||
print_fail "npm is not installed"
|
||||
fi
|
||||
|
||||
# Check STRATA_HOME directory
|
||||
print_check "Strata home directory ($STRATA_HOME)"
|
||||
if [ -d "$STRATA_HOME" ]; then
|
||||
print_ok "Directory exists"
|
||||
else
|
||||
print_fail "Directory does not exist"
|
||||
if [ "$AUTO_FIX" = true ]; then
|
||||
mkdir -p "$STRATA_HOME" "$STRATA_BIN" "$STRATA_CONFIG"
|
||||
print_fix "Created $STRATA_HOME"
|
||||
else
|
||||
print_info "Run with --fix or: mkdir -p $STRATA_HOME"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check strata binary
|
||||
print_check "Strata binary"
|
||||
if [ -x "$STRATA_BIN/strata" ]; then
|
||||
print_ok "Binary exists at $STRATA_BIN/strata"
|
||||
# Try to get version
|
||||
if STRATA_VERSION=$("$STRATA_BIN/strata" version 2>/dev/null); then
|
||||
print_ok "Binary works: $STRATA_VERSION"
|
||||
else
|
||||
print_warn "Binary exists but may not be functional"
|
||||
fi
|
||||
elif [ -x "$REPO_DIR/bin/strata" ]; then
|
||||
print_warn "Binary only in repo ($REPO_DIR/bin/strata)"
|
||||
if [ "$AUTO_FIX" = true ]; then
|
||||
mkdir -p "$STRATA_BIN"
|
||||
cp "$REPO_DIR/bin/strata" "$STRATA_BIN/strata"
|
||||
chmod +x "$STRATA_BIN/strata"
|
||||
print_fix "Copied binary to $STRATA_BIN"
|
||||
else
|
||||
print_info "Run with --fix or: cp $REPO_DIR/bin/strata $STRATA_BIN/"
|
||||
fi
|
||||
else
|
||||
print_fail "Strata binary not found"
|
||||
if [ "$AUTO_FIX" = true ]; then
|
||||
print_info "Rebuilding compiler..."
|
||||
cd "$REPO_DIR/compiler"
|
||||
go build -ldflags="-s -w" -o "$REPO_DIR/bin/strata" ./cmd/strata
|
||||
mkdir -p "$STRATA_BIN"
|
||||
cp "$REPO_DIR/bin/strata" "$STRATA_BIN/strata"
|
||||
chmod +x "$STRATA_BIN/strata"
|
||||
print_fix "Built and installed binary"
|
||||
cd "$REPO_DIR"
|
||||
else
|
||||
print_info "Run with --fix or: make build"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check PATH
|
||||
print_check "PATH configuration"
|
||||
if echo "$PATH" | grep -q "$STRATA_BIN"; then
|
||||
print_ok "$STRATA_BIN is in PATH"
|
||||
elif echo "$PATH" | grep -q "$LOCAL_BIN" && [ -L "$LOCAL_BIN/strata" ]; then
|
||||
print_ok "Using global symlink at $LOCAL_BIN/strata"
|
||||
else
|
||||
print_warn "$STRATA_BIN is not in PATH"
|
||||
print_info "Add to your shell config: export PATH=\"\$STRATA_HOME/bin:\$PATH\""
|
||||
fi
|
||||
|
||||
# Check shell configuration
|
||||
print_check "Shell configuration"
|
||||
SHELL_TYPE=$(basename "$SHELL")
|
||||
case "$SHELL_TYPE" in
|
||||
zsh)
|
||||
SHELL_CONFIG="$HOME/.zshrc"
|
||||
;;
|
||||
bash)
|
||||
if [ -f "$HOME/.bash_profile" ]; then
|
||||
SHELL_CONFIG="$HOME/.bash_profile"
|
||||
else
|
||||
SHELL_CONFIG="$HOME/.bashrc"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
SHELL_CONFIG="$HOME/.profile"
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -f "$SHELL_CONFIG" ] && grep -q "# Strata Framework" "$SHELL_CONFIG"; then
|
||||
print_ok "Shell configured in $SHELL_CONFIG"
|
||||
else
|
||||
print_warn "Shell not configured"
|
||||
print_info "Run: ./scripts/install.sh (will configure shell)"
|
||||
fi
|
||||
|
||||
# Check completions
|
||||
print_check "Shell completions"
|
||||
if [ -f "$STRATA_HOME/completions/strata.bash" ] || [ -f "$STRATA_HOME/completions/_strata" ]; then
|
||||
print_ok "Completions installed"
|
||||
else
|
||||
print_warn "Shell completions not installed"
|
||||
print_info "Run: ./scripts/install.sh (will install completions)"
|
||||
fi
|
||||
|
||||
# Check npm dependencies
|
||||
print_check "npm dependencies"
|
||||
if [ -d "$REPO_DIR/node_modules" ]; then
|
||||
print_ok "node_modules exists"
|
||||
else
|
||||
print_fail "node_modules not found"
|
||||
if [ "$AUTO_FIX" = true ]; then
|
||||
cd "$REPO_DIR"
|
||||
npm install --silent
|
||||
print_fix "Installed npm dependencies"
|
||||
else
|
||||
print_info "Run: npm install"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Check Go modules
|
||||
print_check "Go modules"
|
||||
if [ -f "$REPO_DIR/compiler/go.sum" ]; then
|
||||
print_ok "go.sum exists"
|
||||
else
|
||||
print_warn "go.sum not found (may need go mod download)"
|
||||
fi
|
||||
|
||||
# Check compiler source
|
||||
print_check "Compiler source"
|
||||
if [ -f "$REPO_DIR/compiler/cmd/strata/main.go" ]; then
|
||||
print_ok "Compiler source found"
|
||||
else
|
||||
print_fail "Compiler source missing"
|
||||
print_info "Repository may be incomplete"
|
||||
fi
|
||||
|
||||
# Check runtime source
|
||||
print_check "Runtime source"
|
||||
if [ -f "$REPO_DIR/runtime/core/strata.sts" ]; then
|
||||
print_ok "Runtime source found"
|
||||
else
|
||||
print_fail "Runtime source missing"
|
||||
print_info "Repository may be incomplete"
|
||||
fi
|
||||
|
||||
# Check example app
|
||||
print_check "Example application"
|
||||
if [ -f "$REPO_DIR/examples/basic-app/strataconfig.ts" ]; then
|
||||
print_ok "Example app found"
|
||||
else
|
||||
print_warn "Example app not found"
|
||||
fi
|
||||
|
||||
# Summary
|
||||
echo ""
|
||||
echo "════════════════════════════════════════════════════════"
|
||||
echo ""
|
||||
|
||||
if [ $ISSUES -eq 0 ] && [ $WARNINGS -eq 0 ]; then
|
||||
echo -e "${GREEN}All checks passed! Strata is healthy.${NC}"
|
||||
elif [ $ISSUES -eq 0 ]; then
|
||||
echo -e "${YELLOW}Found $WARNINGS warning(s), but no critical issues.${NC}"
|
||||
else
|
||||
echo -e "${RED}Found $ISSUES issue(s) and $WARNINGS warning(s).${NC}"
|
||||
fi
|
||||
|
||||
if [ $FIXES -gt 0 ]; then
|
||||
echo -e "${CYAN}Applied $FIXES automatic fix(es).${NC}"
|
||||
fi
|
||||
|
||||
if [ $ISSUES -gt 0 ] && [ "$AUTO_FIX" = false ]; then
|
||||
echo ""
|
||||
echo "Run with --fix to attempt automatic repairs:"
|
||||
echo -e " ${CYAN}./scripts/doctor.sh --fix${NC}"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
exit $ISSUES
|
||||
Reference in New Issue
Block a user