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
|
||||
67
scripts/env.sh
Executable file
67
scripts/env.sh
Executable file
@@ -0,0 +1,67 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Strata Framework - Environment Setup
|
||||
# Source this file to set up the Strata environment without installing
|
||||
# Usage: source ./scripts/env.sh
|
||||
# or: . ./scripts/env.sh
|
||||
|
||||
# Get the directory of this script
|
||||
if [ -n "$BASH_SOURCE" ]; then
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
elif [ -n "$ZSH_VERSION" ]; then
|
||||
SCRIPT_DIR="$(cd "$(dirname "${(%):-%x}")" && pwd)"
|
||||
else
|
||||
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
||||
fi
|
||||
|
||||
REPO_DIR="$(dirname "$SCRIPT_DIR")"
|
||||
|
||||
# Check if binary exists
|
||||
if [ ! -x "$REPO_DIR/bin/strata" ]; then
|
||||
echo "Strata binary not found. Building..."
|
||||
(cd "$REPO_DIR" && make build)
|
||||
fi
|
||||
|
||||
# Set environment variables
|
||||
export STRATA_DEV=1
|
||||
export STRATA_REPO="$REPO_DIR"
|
||||
export PATH="$REPO_DIR/bin:$PATH"
|
||||
|
||||
# Set aliases
|
||||
alias st='strata'
|
||||
alias stdev='strata dev'
|
||||
alias stbuild='strata build'
|
||||
alias stgen='strata generate'
|
||||
alias stnew='npx create-strata'
|
||||
|
||||
# Development aliases
|
||||
alias stmake='make -C "$STRATA_REPO"'
|
||||
alias stbuild-compiler='make -C "$STRATA_REPO" build'
|
||||
alias stclean='make -C "$STRATA_REPO" clean'
|
||||
alias sttest='make -C "$STRATA_REPO" test'
|
||||
|
||||
# Quick function to rebuild and run
|
||||
strebuild() {
|
||||
make -C "$STRATA_REPO" build && strata "$@"
|
||||
}
|
||||
|
||||
# Function to run example app
|
||||
stexample() {
|
||||
cd "$STRATA_REPO/examples/basic-app" && strata dev
|
||||
}
|
||||
|
||||
echo ""
|
||||
echo "Strata development environment activated!"
|
||||
echo ""
|
||||
echo " Binary: $REPO_DIR/bin/strata"
|
||||
echo " Version: $(strata version 2>/dev/null || echo 'unknown')"
|
||||
echo ""
|
||||
echo " Commands:"
|
||||
echo " strata - Run strata CLI"
|
||||
echo " strebuild - Rebuild compiler and run command"
|
||||
echo " stexample - Run example app"
|
||||
echo " stmake <cmd> - Run make command in repo"
|
||||
echo ""
|
||||
echo " Aliases:"
|
||||
echo " st, stdev, stbuild, stgen, stnew"
|
||||
echo ""
|
||||
260
scripts/get-strata.sh
Executable file
260
scripts/get-strata.sh
Executable file
@@ -0,0 +1,260 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Strata Framework - Remote Installer
|
||||
# Usage: curl -fsSL https://stratajs.dev/install | bash
|
||||
# or: wget -qO- https://stratajs.dev/install | bash
|
||||
#
|
||||
# Options (via environment variables):
|
||||
# STRATA_VERSION=latest Version to install (default: latest)
|
||||
# STRATA_HOME=~/.strata Installation directory
|
||||
# STRATA_GLOBAL=1 Install globally to /usr/local/bin
|
||||
|
||||
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'
|
||||
|
||||
# Configuration
|
||||
REPO="strata/strata"
|
||||
STRATA_VERSION="${STRATA_VERSION:-latest}"
|
||||
STRATA_HOME="${STRATA_HOME:-$HOME/.strata}"
|
||||
STRATA_BIN="$STRATA_HOME/bin"
|
||||
STRATA_GLOBAL="${STRATA_GLOBAL:-0}"
|
||||
|
||||
# Print banner
|
||||
echo ""
|
||||
echo -e "${CYAN}"
|
||||
echo " ╔═══════════════════════════════════════════════════════╗"
|
||||
echo " ║ Strata Framework - Quick Installer ║"
|
||||
echo " ╚═══════════════════════════════════════════════════════╝"
|
||||
echo -e "${NC}"
|
||||
|
||||
# Detect OS and architecture
|
||||
detect_platform() {
|
||||
local os arch
|
||||
|
||||
os="$(uname -s)"
|
||||
arch="$(uname -m)"
|
||||
|
||||
case "$os" in
|
||||
Darwin)
|
||||
os="darwin"
|
||||
;;
|
||||
Linux)
|
||||
os="linux"
|
||||
;;
|
||||
MINGW*|MSYS*|CYGWIN*)
|
||||
os="windows"
|
||||
;;
|
||||
*)
|
||||
echo -e "${RED}Unsupported operating system: $os${NC}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
case "$arch" in
|
||||
x86_64|amd64)
|
||||
arch="amd64"
|
||||
;;
|
||||
arm64|aarch64)
|
||||
arch="arm64"
|
||||
;;
|
||||
*)
|
||||
echo -e "${RED}Unsupported architecture: $arch${NC}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
echo "${os}-${arch}"
|
||||
}
|
||||
|
||||
# Check for required tools
|
||||
check_requirements() {
|
||||
local missing=0
|
||||
|
||||
# Check for curl or wget
|
||||
if ! command -v curl &> /dev/null && ! command -v wget &> /dev/null; then
|
||||
echo -e "${RED}Error: curl or wget is required${NC}"
|
||||
missing=1
|
||||
fi
|
||||
|
||||
# Check for tar
|
||||
if ! command -v tar &> /dev/null; then
|
||||
echo -e "${RED}Error: tar is required${NC}"
|
||||
missing=1
|
||||
fi
|
||||
|
||||
if [ $missing -eq 1 ]; then
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Download file
|
||||
download() {
|
||||
local url="$1"
|
||||
local dest="$2"
|
||||
|
||||
if command -v curl &> /dev/null; then
|
||||
curl -fsSL "$url" -o "$dest"
|
||||
else
|
||||
wget -qO "$dest" "$url"
|
||||
fi
|
||||
}
|
||||
|
||||
# Get latest version from GitHub
|
||||
get_latest_version() {
|
||||
local api_url="https://api.github.com/repos/$REPO/releases/latest"
|
||||
local version
|
||||
|
||||
if command -v curl &> /dev/null; then
|
||||
version=$(curl -fsSL "$api_url" | grep '"tag_name"' | cut -d'"' -f4)
|
||||
else
|
||||
version=$(wget -qO- "$api_url" | grep '"tag_name"' | cut -d'"' -f4)
|
||||
fi
|
||||
|
||||
echo "$version"
|
||||
}
|
||||
|
||||
# Main installation
|
||||
main() {
|
||||
check_requirements
|
||||
|
||||
local platform=$(detect_platform)
|
||||
echo -e "${BLUE}▶${NC} Detected platform: $platform"
|
||||
|
||||
# Get version
|
||||
if [ "$STRATA_VERSION" = "latest" ]; then
|
||||
echo -e "${BLUE}▶${NC} Fetching latest version..."
|
||||
STRATA_VERSION=$(get_latest_version)
|
||||
if [ -z "$STRATA_VERSION" ]; then
|
||||
echo -e "${YELLOW}⚠${NC} Could not determine latest version, using v0.1.0"
|
||||
STRATA_VERSION="v0.1.0"
|
||||
fi
|
||||
fi
|
||||
echo -e "${GREEN}✓${NC} Version: $STRATA_VERSION"
|
||||
|
||||
# Create directories
|
||||
echo -e "${BLUE}▶${NC} Creating directories..."
|
||||
mkdir -p "$STRATA_BIN"
|
||||
mkdir -p "$STRATA_HOME/completions"
|
||||
mkdir -p "$STRATA_HOME/config"
|
||||
|
||||
# Download binary
|
||||
local binary_name="strata-${platform}"
|
||||
if [ "$(echo $platform | cut -d'-' -f1)" = "windows" ]; then
|
||||
binary_name="${binary_name}.exe"
|
||||
fi
|
||||
|
||||
local download_url="https://github.com/$REPO/releases/download/$STRATA_VERSION/$binary_name"
|
||||
local temp_file=$(mktemp)
|
||||
|
||||
echo -e "${BLUE}▶${NC} Downloading Strata..."
|
||||
echo " URL: $download_url"
|
||||
|
||||
if ! download "$download_url" "$temp_file"; then
|
||||
echo -e "${RED}Error: Failed to download Strata${NC}"
|
||||
echo ""
|
||||
echo "This could mean:"
|
||||
echo " 1. The release doesn't exist yet"
|
||||
echo " 2. Network connectivity issues"
|
||||
echo ""
|
||||
echo "Try installing from source instead:"
|
||||
echo -e " ${CYAN}git clone https://github.com/$REPO.git${NC}"
|
||||
echo -e " ${CYAN}cd strata && make install${NC}"
|
||||
rm -f "$temp_file"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Install binary
|
||||
mv "$temp_file" "$STRATA_BIN/strata"
|
||||
chmod +x "$STRATA_BIN/strata"
|
||||
echo -e "${GREEN}✓${NC} Installed to $STRATA_BIN/strata"
|
||||
|
||||
# Install globally if requested
|
||||
if [ "$STRATA_GLOBAL" = "1" ]; then
|
||||
echo -e "${BLUE}▶${NC} Installing globally..."
|
||||
if [ -w /usr/local/bin ]; then
|
||||
ln -sf "$STRATA_BIN/strata" /usr/local/bin/strata
|
||||
else
|
||||
sudo ln -sf "$STRATA_BIN/strata" /usr/local/bin/strata
|
||||
fi
|
||||
echo -e "${GREEN}✓${NC} Linked to /usr/local/bin/strata"
|
||||
fi
|
||||
|
||||
# Configure shell
|
||||
echo -e "${BLUE}▶${NC} Configuring shell..."
|
||||
local shell_type=$(basename "$SHELL")
|
||||
local shell_config
|
||||
|
||||
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
|
||||
;;
|
||||
fish)
|
||||
shell_config="$HOME/.config/fish/config.fish"
|
||||
;;
|
||||
*)
|
||||
shell_config="$HOME/.profile"
|
||||
;;
|
||||
esac
|
||||
|
||||
if [ -f "$shell_config" ] && grep -q "# Strata Framework" "$shell_config"; then
|
||||
echo -e "${GREEN}✓${NC} Shell already configured"
|
||||
else
|
||||
cat >> "$shell_config" << 'SHELL_CONFIG'
|
||||
|
||||
# Strata Framework
|
||||
export STRATA_HOME="$HOME/.strata"
|
||||
export PATH="$STRATA_HOME/bin:$PATH"
|
||||
|
||||
# Strata aliases
|
||||
alias st='strata'
|
||||
alias stdev='strata dev'
|
||||
alias stbuild='strata build'
|
||||
alias stgen='strata generate'
|
||||
alias stnew='npx create-strata'
|
||||
SHELL_CONFIG
|
||||
echo -e "${GREEN}✓${NC} Added to $shell_config"
|
||||
fi
|
||||
|
||||
# Create config file
|
||||
cat > "$STRATA_HOME/config/strata.json" << CONFIG
|
||||
{
|
||||
"version": "$STRATA_VERSION",
|
||||
"installPath": "$STRATA_HOME",
|
||||
"installedAt": "$(date -u +"%Y-%m-%dT%H:%M:%SZ")",
|
||||
"installedVia": "quick-installer"
|
||||
}
|
||||
CONFIG
|
||||
|
||||
# Print success
|
||||
echo ""
|
||||
echo -e "${GREEN}════════════════════════════════════════════════════════${NC}"
|
||||
echo -e "${GREEN} Installation Complete! ${NC}"
|
||||
echo -e "${GREEN}════════════════════════════════════════════════════════${NC}"
|
||||
echo ""
|
||||
echo " Restart your terminal or run:"
|
||||
echo -e " ${CYAN}source $shell_config${NC}"
|
||||
echo ""
|
||||
echo " Then create your first project:"
|
||||
echo -e " ${CYAN}npx create-strata my-app${NC}"
|
||||
echo -e " ${CYAN}cd my-app${NC}"
|
||||
echo -e " ${CYAN}strata dev${NC}"
|
||||
echo ""
|
||||
echo " Documentation: https://stratajs.dev/docs"
|
||||
echo ""
|
||||
}
|
||||
|
||||
main
|
||||
624
scripts/install.sh
Executable file
624
scripts/install.sh
Executable file
@@ -0,0 +1,624 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Strata Framework - Local Installation Script
|
||||
# Usage: ./scripts/install.sh [options]
|
||||
# --global Install globally to /usr/local
|
||||
# --local Install locally only (default)
|
||||
# --skip-deps Skip dependency checks
|
||||
# --no-shell Skip shell configuration
|
||||
# --help Show this help message
|
||||
|
||||
set -e
|
||||
|
||||
# Colors for output
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
CYAN='\033[0;36m'
|
||||
NC='\033[0m' # No Color
|
||||
BOLD='\033[1m'
|
||||
|
||||
# Installation directories
|
||||
STRATA_HOME="${STRATA_HOME:-$HOME/.strata}"
|
||||
STRATA_BIN="$STRATA_HOME/bin"
|
||||
STRATA_COMPLETIONS="$STRATA_HOME/completions"
|
||||
STRATA_CONFIG="$STRATA_HOME/config"
|
||||
LOCAL_BIN="/usr/local/bin"
|
||||
|
||||
# Script directory (where strata repo is)
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_DIR="$(dirname "$SCRIPT_DIR")"
|
||||
|
||||
# Default options
|
||||
INSTALL_GLOBAL=false
|
||||
SKIP_DEPS=false
|
||||
SKIP_SHELL=false
|
||||
|
||||
# Parse arguments
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
--global)
|
||||
INSTALL_GLOBAL=true
|
||||
shift
|
||||
;;
|
||||
--local)
|
||||
INSTALL_GLOBAL=false
|
||||
shift
|
||||
;;
|
||||
--skip-deps)
|
||||
SKIP_DEPS=true
|
||||
shift
|
||||
;;
|
||||
--no-shell)
|
||||
SKIP_SHELL=true
|
||||
shift
|
||||
;;
|
||||
--help|-h)
|
||||
echo "Strata Framework - Installation Script"
|
||||
echo ""
|
||||
echo "Usage: ./scripts/install.sh [options]"
|
||||
echo ""
|
||||
echo "Options:"
|
||||
echo " --global Install globally to /usr/local/bin (requires sudo)"
|
||||
echo " --local Install locally to ~/.strata (default)"
|
||||
echo " --skip-deps Skip dependency version checks"
|
||||
echo " --no-shell Skip shell configuration (PATH, completions)"
|
||||
echo " --help Show this help message"
|
||||
echo ""
|
||||
echo "Environment Variables:"
|
||||
echo " STRATA_HOME Installation directory (default: ~/.strata)"
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo -e "${RED}Unknown option: $1${NC}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Print banner
|
||||
print_banner() {
|
||||
echo ""
|
||||
echo -e "${CYAN}"
|
||||
echo " ╔═══════════════════════════════════════════════════════╗"
|
||||
echo " ║ ║"
|
||||
echo " ║ ███████╗████████╗██████╗ █████╗ ████████╗ █████╗ ║"
|
||||
echo " ║ ██╔════╝╚══██╔══╝██╔══██╗██╔══██╗╚══██╔══╝██╔══██╗ ║"
|
||||
echo " ║ ███████╗ ██║ ██████╔╝███████║ ██║ ███████║ ║"
|
||||
echo " ║ ╚════██║ ██║ ██╔══██╗██╔══██║ ██║ ██╔══██║ ║"
|
||||
echo " ║ ███████║ ██║ ██║ ██║██║ ██║ ██║ ██║ ██║ ║"
|
||||
echo " ║ ╚══════╝ ╚═╝ ╚═╝ ╚═╝╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ║"
|
||||
echo " ║ ║"
|
||||
echo " ║ Static Template Rendering Architecture ║"
|
||||
echo " ╚═══════════════════════════════════════════════════════╝"
|
||||
echo -e "${NC}"
|
||||
echo ""
|
||||
}
|
||||
|
||||
# Print step
|
||||
print_step() {
|
||||
echo -e "${BLUE}▶${NC} $1"
|
||||
}
|
||||
|
||||
# Print success
|
||||
print_success() {
|
||||
echo -e "${GREEN}✓${NC} $1"
|
||||
}
|
||||
|
||||
# Print warning
|
||||
print_warning() {
|
||||
echo -e "${YELLOW}⚠${NC} $1"
|
||||
}
|
||||
|
||||
# Print error
|
||||
print_error() {
|
||||
echo -e "${RED}✗${NC} $1"
|
||||
}
|
||||
|
||||
# Check if command exists
|
||||
command_exists() {
|
||||
command -v "$1" &> /dev/null
|
||||
}
|
||||
|
||||
# Get version number from version string
|
||||
get_version() {
|
||||
echo "$1" | grep -oE '[0-9]+\.[0-9]+' | head -1
|
||||
}
|
||||
|
||||
# Compare versions (returns 0 if $1 >= $2)
|
||||
version_gte() {
|
||||
[ "$(printf '%s\n' "$2" "$1" | sort -V | head -n1)" = "$2" ]
|
||||
}
|
||||
|
||||
# Check system requirements
|
||||
check_requirements() {
|
||||
print_step "Checking system requirements..."
|
||||
echo ""
|
||||
|
||||
local requirements_met=true
|
||||
|
||||
# Check Go
|
||||
if command_exists go; then
|
||||
GO_VERSION=$(go version | grep -oE 'go[0-9]+\.[0-9]+' | sed 's/go//')
|
||||
if version_gte "$GO_VERSION" "1.21"; then
|
||||
print_success "Go $GO_VERSION (required: >= 1.21)"
|
||||
else
|
||||
print_warning "Go $GO_VERSION found, but >= 1.21 is recommended"
|
||||
fi
|
||||
else
|
||||
print_error "Go is not installed"
|
||||
echo " Install from: https://go.dev/dl/"
|
||||
echo " Or use: brew install go (macOS)"
|
||||
echo " sudo apt install golang-go (Ubuntu/Debian)"
|
||||
requirements_met=false
|
||||
fi
|
||||
|
||||
# Check Node.js
|
||||
if command_exists node; then
|
||||
NODE_VERSION=$(node -v | sed 's/v//')
|
||||
NODE_MAJOR=$(echo "$NODE_VERSION" | cut -d. -f1)
|
||||
if [ "$NODE_MAJOR" -ge 18 ]; then
|
||||
print_success "Node.js $NODE_VERSION (required: >= 18.0)"
|
||||
else
|
||||
print_warning "Node.js $NODE_VERSION found, but >= 18.0 is required"
|
||||
requirements_met=false
|
||||
fi
|
||||
else
|
||||
print_error "Node.js is not installed"
|
||||
echo " Install from: https://nodejs.org/"
|
||||
echo " Or use: brew install node (macOS)"
|
||||
echo " nvm install 20 (using nvm)"
|
||||
requirements_met=false
|
||||
fi
|
||||
|
||||
# Check npm
|
||||
if command_exists npm; then
|
||||
NPM_VERSION=$(npm -v)
|
||||
print_success "npm $NPM_VERSION"
|
||||
else
|
||||
print_error "npm is not installed"
|
||||
requirements_met=false
|
||||
fi
|
||||
|
||||
# Check git
|
||||
if command_exists git; then
|
||||
GIT_VERSION=$(git --version | grep -oE '[0-9]+\.[0-9]+\.[0-9]+')
|
||||
print_success "Git $GIT_VERSION"
|
||||
else
|
||||
print_warning "Git is not installed (optional, but recommended)"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
|
||||
if [ "$requirements_met" = false ] && [ "$SKIP_DEPS" = false ]; then
|
||||
print_error "Some requirements are not met. Install missing dependencies and try again."
|
||||
echo " Or run with --skip-deps to continue anyway (not recommended)."
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
# Create directory structure
|
||||
create_directories() {
|
||||
print_step "Creating Strata directories..."
|
||||
|
||||
mkdir -p "$STRATA_HOME"
|
||||
mkdir -p "$STRATA_BIN"
|
||||
mkdir -p "$STRATA_COMPLETIONS"
|
||||
mkdir -p "$STRATA_CONFIG"
|
||||
mkdir -p "$REPO_DIR/bin"
|
||||
|
||||
print_success "Created $STRATA_HOME"
|
||||
}
|
||||
|
||||
# Build Go compiler
|
||||
build_compiler() {
|
||||
print_step "Building Strata compiler..."
|
||||
|
||||
cd "$REPO_DIR/compiler"
|
||||
|
||||
# Download Go dependencies
|
||||
echo " Downloading Go dependencies..."
|
||||
go mod tidy
|
||||
go mod download
|
||||
|
||||
# Build the compiler
|
||||
echo " Compiling..."
|
||||
go build -ldflags="-s -w" -o "$REPO_DIR/bin/strata" ./cmd/strata
|
||||
|
||||
# Copy to strata home
|
||||
cp "$REPO_DIR/bin/strata" "$STRATA_BIN/strata"
|
||||
chmod +x "$STRATA_BIN/strata"
|
||||
|
||||
# Copy create-strata CLI
|
||||
if [ -f "$REPO_DIR/bin/create-strata" ]; then
|
||||
cp "$REPO_DIR/bin/create-strata" "$STRATA_BIN/create-strata"
|
||||
chmod +x "$STRATA_BIN/create-strata"
|
||||
fi
|
||||
|
||||
cd "$REPO_DIR"
|
||||
|
||||
print_success "Compiler built successfully"
|
||||
}
|
||||
|
||||
# Install npm dependencies
|
||||
install_npm_deps() {
|
||||
print_step "Installing npm dependencies..."
|
||||
|
||||
cd "$REPO_DIR"
|
||||
npm install --silent
|
||||
|
||||
print_success "npm dependencies installed"
|
||||
}
|
||||
|
||||
# Install globally
|
||||
install_global() {
|
||||
if [ "$INSTALL_GLOBAL" = true ]; then
|
||||
print_step "Installing globally to $LOCAL_BIN..."
|
||||
|
||||
if [ -w "$LOCAL_BIN" ]; then
|
||||
ln -sf "$STRATA_BIN/strata" "$LOCAL_BIN/strata"
|
||||
print_success "Linked strata to $LOCAL_BIN/strata"
|
||||
else
|
||||
echo " Requires sudo to write to $LOCAL_BIN"
|
||||
sudo ln -sf "$STRATA_BIN/strata" "$LOCAL_BIN/strata"
|
||||
print_success "Linked strata to $LOCAL_BIN/strata (with sudo)"
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# Detect shell (use $SHELL env var which reflects user's login shell)
|
||||
detect_shell() {
|
||||
basename "${SHELL:-/bin/bash}"
|
||||
}
|
||||
|
||||
# Get shell config file
|
||||
get_shell_config() {
|
||||
local shell_type="$1"
|
||||
case "$shell_type" in
|
||||
zsh)
|
||||
echo "$HOME/.zshrc"
|
||||
;;
|
||||
bash)
|
||||
if [ -f "$HOME/.bash_profile" ]; then
|
||||
echo "$HOME/.bash_profile"
|
||||
else
|
||||
echo "$HOME/.bashrc"
|
||||
fi
|
||||
;;
|
||||
fish)
|
||||
echo "$HOME/.config/fish/config.fish"
|
||||
;;
|
||||
*)
|
||||
echo "$HOME/.profile"
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
# Configure shell
|
||||
configure_shell() {
|
||||
if [ "$SKIP_SHELL" = true ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
print_step "Configuring shell..."
|
||||
|
||||
local shell_type=$(detect_shell)
|
||||
local shell_config=$(get_shell_config "$shell_type")
|
||||
local strata_marker="# Strata Framework"
|
||||
|
||||
# Check if already configured
|
||||
if [ -f "$shell_config" ] && grep -q "$strata_marker" "$shell_config"; then
|
||||
print_success "Shell already configured in $shell_config"
|
||||
return
|
||||
fi
|
||||
|
||||
# Create backup
|
||||
if [ -f "$shell_config" ]; then
|
||||
cp "$shell_config" "${shell_config}.backup.$(date +%Y%m%d%H%M%S)"
|
||||
fi
|
||||
|
||||
# Add Strata configuration
|
||||
cat >> "$shell_config" << 'SHELL_CONFIG'
|
||||
|
||||
# Strata Framework
|
||||
export STRATA_HOME="$HOME/.strata"
|
||||
export PATH="$STRATA_HOME/bin:$PATH"
|
||||
|
||||
# Strata aliases
|
||||
alias st='strata'
|
||||
alias stdev='strata dev'
|
||||
alias stbuild='strata build'
|
||||
alias stgen='strata generate'
|
||||
alias stnew='create-strata'
|
||||
|
||||
# Strata completions
|
||||
SHELL_CONFIG
|
||||
|
||||
# Add shell-specific completion loading
|
||||
case "$shell_type" in
|
||||
zsh)
|
||||
cat >> "$shell_config" << 'ZSH_COMPLETION'
|
||||
if [ -f "$STRATA_HOME/completions/_strata" ]; then
|
||||
fpath=($STRATA_HOME/completions $fpath)
|
||||
autoload -Uz compinit && compinit
|
||||
fi
|
||||
ZSH_COMPLETION
|
||||
;;
|
||||
bash)
|
||||
cat >> "$shell_config" << 'BASH_COMPLETION'
|
||||
if [ -f "$STRATA_HOME/completions/strata.bash" ]; then
|
||||
source "$STRATA_HOME/completions/strata.bash"
|
||||
fi
|
||||
BASH_COMPLETION
|
||||
;;
|
||||
fish)
|
||||
cat >> "$shell_config" << 'FISH_COMPLETION'
|
||||
if test -f "$STRATA_HOME/completions/strata.fish"
|
||||
source "$STRATA_HOME/completions/strata.fish"
|
||||
end
|
||||
FISH_COMPLETION
|
||||
;;
|
||||
esac
|
||||
|
||||
print_success "Added Strata configuration to $shell_config"
|
||||
}
|
||||
|
||||
# Generate and install completions
|
||||
install_completions() {
|
||||
if [ "$SKIP_SHELL" = true ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
print_step "Installing shell completions..."
|
||||
|
||||
# Generate bash completion
|
||||
cat > "$STRATA_COMPLETIONS/strata.bash" << 'BASH_COMP'
|
||||
# Strata bash completion
|
||||
|
||||
_strata_completions() {
|
||||
local cur prev opts
|
||||
COMPREPLY=()
|
||||
cur="${COMP_WORDS[COMP_CWORD]}"
|
||||
prev="${COMP_WORDS[COMP_CWORD-1]}"
|
||||
|
||||
# Main commands
|
||||
local commands="dev build preview generate init help version"
|
||||
|
||||
# Generate subcommands
|
||||
local generate_types="component page store layout middleware"
|
||||
|
||||
case "$prev" in
|
||||
strata|st)
|
||||
COMPREPLY=( $(compgen -W "$commands" -- "$cur") )
|
||||
return 0
|
||||
;;
|
||||
generate|g)
|
||||
COMPREPLY=( $(compgen -W "$generate_types" -- "$cur") )
|
||||
return 0
|
||||
;;
|
||||
dev)
|
||||
COMPREPLY=( $(compgen -W "--port --open --host" -- "$cur") )
|
||||
return 0
|
||||
;;
|
||||
build)
|
||||
COMPREPLY=( $(compgen -W "--analyze --watch --minify --sourcemap" -- "$cur") )
|
||||
return 0
|
||||
;;
|
||||
preview)
|
||||
COMPREPLY=( $(compgen -W "--port --host" -- "$cur") )
|
||||
return 0
|
||||
;;
|
||||
--port)
|
||||
COMPREPLY=( $(compgen -W "3000 3001 4000 5000 8080" -- "$cur") )
|
||||
return 0
|
||||
;;
|
||||
esac
|
||||
|
||||
# Default: show all commands
|
||||
if [[ "$cur" == -* ]]; then
|
||||
COMPREPLY=( $(compgen -W "--help --version" -- "$cur") )
|
||||
else
|
||||
COMPREPLY=( $(compgen -W "$commands" -- "$cur") )
|
||||
fi
|
||||
}
|
||||
|
||||
complete -F _strata_completions strata
|
||||
complete -F _strata_completions st
|
||||
BASH_COMP
|
||||
|
||||
# Generate zsh completion
|
||||
cat > "$STRATA_COMPLETIONS/_strata" << 'ZSH_COMP'
|
||||
#compdef strata st
|
||||
|
||||
# Strata zsh completion
|
||||
|
||||
_strata() {
|
||||
local -a commands
|
||||
local -a generate_types
|
||||
|
||||
commands=(
|
||||
'dev:Start development server with hot reload'
|
||||
'build:Build for production'
|
||||
'preview:Preview production build'
|
||||
'generate:Generate component, page, or store'
|
||||
'init:Initialize new Strata project'
|
||||
'help:Show help information'
|
||||
'version:Show version information'
|
||||
)
|
||||
|
||||
generate_types=(
|
||||
'component:Generate a new component'
|
||||
'page:Generate a new page'
|
||||
'store:Generate a new store'
|
||||
'layout:Generate a new layout'
|
||||
'middleware:Generate a new middleware'
|
||||
)
|
||||
|
||||
_arguments -C \
|
||||
'1: :->command' \
|
||||
'*: :->args'
|
||||
|
||||
case "$state" in
|
||||
command)
|
||||
_describe -t commands 'strata commands' commands
|
||||
;;
|
||||
args)
|
||||
case "$words[2]" in
|
||||
generate|g)
|
||||
if [[ $CURRENT -eq 3 ]]; then
|
||||
_describe -t generate_types 'generate types' generate_types
|
||||
else
|
||||
_files
|
||||
fi
|
||||
;;
|
||||
dev)
|
||||
_arguments \
|
||||
'--port[Port number]:port:(3000 3001 4000 5000 8080)' \
|
||||
'--open[Open browser automatically]' \
|
||||
'--host[Host to bind]:host:(localhost 0.0.0.0)'
|
||||
;;
|
||||
build)
|
||||
_arguments \
|
||||
'--analyze[Analyze bundle size]' \
|
||||
'--watch[Watch for changes]' \
|
||||
'--minify[Minify output]' \
|
||||
'--sourcemap[Generate sourcemaps]'
|
||||
;;
|
||||
preview)
|
||||
_arguments \
|
||||
'--port[Port number]:port:(4000 5000 8080)' \
|
||||
'--host[Host to bind]:host:(localhost 0.0.0.0)'
|
||||
;;
|
||||
*)
|
||||
_files
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
esac
|
||||
}
|
||||
|
||||
_strata "$@"
|
||||
ZSH_COMP
|
||||
|
||||
# Generate fish completion
|
||||
cat > "$STRATA_COMPLETIONS/strata.fish" << 'FISH_COMP'
|
||||
# Strata fish completion
|
||||
|
||||
# Main commands
|
||||
complete -c strata -f -n "__fish_use_subcommand" -a "dev" -d "Start development server"
|
||||
complete -c strata -f -n "__fish_use_subcommand" -a "build" -d "Build for production"
|
||||
complete -c strata -f -n "__fish_use_subcommand" -a "preview" -d "Preview production build"
|
||||
complete -c strata -f -n "__fish_use_subcommand" -a "generate" -d "Generate component/page/store"
|
||||
complete -c strata -f -n "__fish_use_subcommand" -a "init" -d "Initialize new project"
|
||||
complete -c strata -f -n "__fish_use_subcommand" -a "help" -d "Show help"
|
||||
complete -c strata -f -n "__fish_use_subcommand" -a "version" -d "Show version"
|
||||
|
||||
# Generate subcommands
|
||||
complete -c strata -f -n "__fish_seen_subcommand_from generate" -a "component" -d "Generate component"
|
||||
complete -c strata -f -n "__fish_seen_subcommand_from generate" -a "page" -d "Generate page"
|
||||
complete -c strata -f -n "__fish_seen_subcommand_from generate" -a "store" -d "Generate store"
|
||||
complete -c strata -f -n "__fish_seen_subcommand_from generate" -a "layout" -d "Generate layout"
|
||||
|
||||
# Dev options
|
||||
complete -c strata -f -n "__fish_seen_subcommand_from dev" -l port -d "Port number"
|
||||
complete -c strata -f -n "__fish_seen_subcommand_from dev" -l open -d "Open browser"
|
||||
complete -c strata -f -n "__fish_seen_subcommand_from dev" -l host -d "Host to bind"
|
||||
|
||||
# Build options
|
||||
complete -c strata -f -n "__fish_seen_subcommand_from build" -l analyze -d "Analyze bundle"
|
||||
complete -c strata -f -n "__fish_seen_subcommand_from build" -l watch -d "Watch mode"
|
||||
complete -c strata -f -n "__fish_seen_subcommand_from build" -l minify -d "Minify output"
|
||||
complete -c strata -f -n "__fish_seen_subcommand_from build" -l sourcemap -d "Generate sourcemaps"
|
||||
|
||||
# Alias
|
||||
complete -c st -w strata
|
||||
FISH_COMP
|
||||
|
||||
print_success "Shell completions installed"
|
||||
}
|
||||
|
||||
# Create config file
|
||||
create_config() {
|
||||
print_step "Creating configuration..."
|
||||
|
||||
# Create global strata config
|
||||
cat > "$STRATA_CONFIG/strata.json" << CONFIG
|
||||
{
|
||||
"version": "0.1.0",
|
||||
"installPath": "$STRATA_HOME",
|
||||
"repoPath": "$REPO_DIR",
|
||||
"installedAt": "$(date -u +"%Y-%m-%dT%H:%M:%SZ")",
|
||||
"shell": {
|
||||
"configured": $([ "$SKIP_SHELL" = true ] && echo "false" || echo "true"),
|
||||
"completions": $([ "$SKIP_SHELL" = true ] && echo "false" || echo "true")
|
||||
},
|
||||
"global": $INSTALL_GLOBAL
|
||||
}
|
||||
CONFIG
|
||||
|
||||
print_success "Configuration created at $STRATA_CONFIG/strata.json"
|
||||
}
|
||||
|
||||
# Print success message
|
||||
print_final() {
|
||||
echo ""
|
||||
echo -e "${GREEN}════════════════════════════════════════════════════════${NC}"
|
||||
echo -e "${GREEN} Installation Complete! ${NC}"
|
||||
echo -e "${GREEN}════════════════════════════════════════════════════════${NC}"
|
||||
echo ""
|
||||
echo -e " ${BOLD}Strata has been installed to:${NC} $STRATA_HOME"
|
||||
echo ""
|
||||
echo -e " ${BOLD}Quick Start:${NC}"
|
||||
echo ""
|
||||
echo " 1. Restart your terminal or run:"
|
||||
echo -e " ${CYAN}source $(get_shell_config $(detect_shell))${NC}"
|
||||
echo ""
|
||||
echo " 2. Create a new project:"
|
||||
echo -e " ${CYAN}npx create-strata my-app${NC}"
|
||||
echo -e " ${CYAN}cd my-app${NC}"
|
||||
echo -e " ${CYAN}npm install${NC}"
|
||||
echo -e " ${CYAN}strata dev${NC}"
|
||||
echo ""
|
||||
echo " Or try the example app:"
|
||||
echo -e " ${CYAN}cd $REPO_DIR/examples/basic-app${NC}"
|
||||
echo -e " ${CYAN}strata dev${NC}"
|
||||
echo ""
|
||||
echo -e " ${BOLD}Available Commands:${NC}"
|
||||
echo ""
|
||||
echo " strata dev Start dev server with hot reload"
|
||||
echo " strata build Build for production"
|
||||
echo " strata preview Preview production build"
|
||||
echo " strata generate Generate component/page/store"
|
||||
echo ""
|
||||
echo -e " ${BOLD}Aliases:${NC}"
|
||||
echo ""
|
||||
echo " st → strata"
|
||||
echo " stdev → strata dev"
|
||||
echo " stbuild → strata build"
|
||||
echo " stgen → strata generate"
|
||||
echo " stnew → npx create-strata"
|
||||
echo ""
|
||||
echo -e " ${BOLD}Documentation:${NC} https://stratajs.dev/docs"
|
||||
echo -e " ${BOLD}GitHub:${NC} https://github.com/strata/strata"
|
||||
echo ""
|
||||
}
|
||||
|
||||
# Main installation
|
||||
main() {
|
||||
print_banner
|
||||
|
||||
check_requirements
|
||||
create_directories
|
||||
build_compiler
|
||||
install_npm_deps
|
||||
install_global
|
||||
configure_shell
|
||||
install_completions
|
||||
create_config
|
||||
|
||||
print_final
|
||||
}
|
||||
|
||||
# Run main
|
||||
main
|
||||
64
scripts/setup.sh
Executable file
64
scripts/setup.sh
Executable file
@@ -0,0 +1,64 @@
|
||||
#!/bin/bash
|
||||
|
||||
set -e
|
||||
|
||||
echo ""
|
||||
echo " ╔═══════════════════════════════════════╗"
|
||||
echo " ║ Strata Framework Setup ║"
|
||||
echo " ╚═══════════════════════════════════════╝"
|
||||
echo ""
|
||||
|
||||
# Check for Go
|
||||
if ! command -v go &> /dev/null; then
|
||||
echo " ❌ Go is not installed."
|
||||
echo " Install from: https://go.dev/dl/"
|
||||
exit 1
|
||||
fi
|
||||
echo " ✓ Go $(go version | cut -d' ' -f3)"
|
||||
|
||||
# Check for Node
|
||||
if ! command -v node &> /dev/null; then
|
||||
echo " ❌ Node.js is not installed."
|
||||
echo " Install from: https://nodejs.org/"
|
||||
exit 1
|
||||
fi
|
||||
echo " ✓ Node $(node -v)"
|
||||
|
||||
# Check for npm
|
||||
if ! command -v npm &> /dev/null; then
|
||||
echo " ❌ npm is not installed."
|
||||
exit 1
|
||||
fi
|
||||
echo " ✓ npm $(npm -v)"
|
||||
|
||||
echo ""
|
||||
echo " Installing Go dependencies..."
|
||||
cd compiler
|
||||
go mod download
|
||||
cd ..
|
||||
|
||||
echo ""
|
||||
echo " Building compiler..."
|
||||
mkdir -p bin
|
||||
cd compiler
|
||||
go build -o ../bin/strata ./cmd/strata
|
||||
cd ..
|
||||
|
||||
echo ""
|
||||
echo " ✓ Compiler built: ./bin/strata"
|
||||
|
||||
echo ""
|
||||
echo " Installing npm dependencies..."
|
||||
npm install --silent
|
||||
|
||||
echo ""
|
||||
echo " ════════════════════════════════════════"
|
||||
echo " ✓ Setup complete!"
|
||||
echo ""
|
||||
echo " Quick start:"
|
||||
echo " cd examples/basic-app"
|
||||
echo " ../../bin/strata dev"
|
||||
echo ""
|
||||
echo " Or use make:"
|
||||
echo " make dev"
|
||||
echo ""
|
||||
177
scripts/uninstall.sh
Executable file
177
scripts/uninstall.sh
Executable file
@@ -0,0 +1,177 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Strata Framework - Uninstall Script
|
||||
# Usage: ./scripts/uninstall.sh [options]
|
||||
# --keep-config Keep configuration files
|
||||
# --force Skip confirmation prompt
|
||||
# --help Show this help message
|
||||
|
||||
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}"
|
||||
LOCAL_BIN="/usr/local/bin"
|
||||
|
||||
# Options
|
||||
KEEP_CONFIG=false
|
||||
FORCE=false
|
||||
|
||||
# Parse arguments
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
--keep-config)
|
||||
KEEP_CONFIG=true
|
||||
shift
|
||||
;;
|
||||
--force|-f)
|
||||
FORCE=true
|
||||
shift
|
||||
;;
|
||||
--help|-h)
|
||||
echo "Strata Framework - Uninstall Script"
|
||||
echo ""
|
||||
echo "Usage: ./scripts/uninstall.sh [options]"
|
||||
echo ""
|
||||
echo "Options:"
|
||||
echo " --keep-config Keep configuration files in ~/.strata/config"
|
||||
echo " --force, -f Skip confirmation prompt"
|
||||
echo " --help Show this help message"
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo -e "${RED}Unknown option: $1${NC}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
print_step() {
|
||||
echo -e "${BLUE}▶${NC} $1"
|
||||
}
|
||||
|
||||
print_success() {
|
||||
echo -e "${GREEN}✓${NC} $1"
|
||||
}
|
||||
|
||||
print_warning() {
|
||||
echo -e "${YELLOW}⚠${NC} $1"
|
||||
}
|
||||
|
||||
# Confirmation prompt
|
||||
if [ "$FORCE" = false ]; then
|
||||
echo ""
|
||||
echo -e "${YELLOW}╔═══════════════════════════════════════════════════════╗${NC}"
|
||||
echo -e "${YELLOW}║ Strata Framework - Uninstall ║${NC}"
|
||||
echo -e "${YELLOW}╚═══════════════════════════════════════════════════════╝${NC}"
|
||||
echo ""
|
||||
echo "This will remove:"
|
||||
echo " - Strata binary from $STRATA_HOME/bin"
|
||||
echo " - Shell completions from $STRATA_HOME/completions"
|
||||
if [ "$KEEP_CONFIG" = false ]; then
|
||||
echo " - Configuration from $STRATA_HOME/config"
|
||||
fi
|
||||
echo " - Global symlink from $LOCAL_BIN (if exists)"
|
||||
echo " - Shell configuration (Strata block) from your shell rc file"
|
||||
echo ""
|
||||
read -p "Are you sure you want to uninstall Strata? [y/N] " -n 1 -r
|
||||
echo ""
|
||||
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
|
||||
echo "Uninstall cancelled."
|
||||
exit 0
|
||||
fi
|
||||
echo ""
|
||||
fi
|
||||
|
||||
# Remove global symlink
|
||||
print_step "Removing global symlink..."
|
||||
if [ -L "$LOCAL_BIN/strata" ]; then
|
||||
if [ -w "$LOCAL_BIN" ]; then
|
||||
rm -f "$LOCAL_BIN/strata"
|
||||
else
|
||||
sudo rm -f "$LOCAL_BIN/strata"
|
||||
fi
|
||||
print_success "Removed $LOCAL_BIN/strata"
|
||||
else
|
||||
echo " No global symlink found"
|
||||
fi
|
||||
|
||||
# Remove Strata home directory
|
||||
print_step "Removing Strata installation..."
|
||||
if [ -d "$STRATA_HOME" ]; then
|
||||
if [ "$KEEP_CONFIG" = true ]; then
|
||||
# Keep config, remove everything else
|
||||
rm -rf "$STRATA_HOME/bin"
|
||||
rm -rf "$STRATA_HOME/completions"
|
||||
print_success "Removed $STRATA_HOME (kept config)"
|
||||
else
|
||||
rm -rf "$STRATA_HOME"
|
||||
print_success "Removed $STRATA_HOME"
|
||||
fi
|
||||
else
|
||||
echo " No installation found at $STRATA_HOME"
|
||||
fi
|
||||
|
||||
# Clean up shell configuration
|
||||
print_step "Cleaning shell configuration..."
|
||||
|
||||
clean_shell_config() {
|
||||
local config_file="$1"
|
||||
|
||||
if [ ! -f "$config_file" ]; then
|
||||
return
|
||||
fi
|
||||
|
||||
# Check if Strata config exists
|
||||
if ! grep -q "# Strata Framework" "$config_file"; then
|
||||
return
|
||||
fi
|
||||
|
||||
# Create backup
|
||||
cp "$config_file" "${config_file}.backup.$(date +%Y%m%d%H%M%S)"
|
||||
|
||||
# Remove Strata block (from "# Strata Framework" to the next blank line after completions)
|
||||
# This handles multi-line blocks
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
# macOS sed
|
||||
sed -i '' '/# Strata Framework/,/^$/d' "$config_file"
|
||||
else
|
||||
# GNU sed
|
||||
sed -i '/# Strata Framework/,/^$/d' "$config_file"
|
||||
fi
|
||||
|
||||
print_success "Cleaned $config_file"
|
||||
}
|
||||
|
||||
# Clean common shell config files
|
||||
for config_file in "$HOME/.bashrc" "$HOME/.bash_profile" "$HOME/.zshrc" "$HOME/.profile"; do
|
||||
clean_shell_config "$config_file"
|
||||
done
|
||||
|
||||
# Fish config
|
||||
if [ -f "$HOME/.config/fish/config.fish" ]; then
|
||||
clean_shell_config "$HOME/.config/fish/config.fish"
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo -e "${GREEN}════════════════════════════════════════════════════════${NC}"
|
||||
echo -e "${GREEN} Strata has been uninstalled ${NC}"
|
||||
echo -e "${GREEN}════════════════════════════════════════════════════════${NC}"
|
||||
echo ""
|
||||
echo " Restart your terminal for changes to take effect."
|
||||
echo ""
|
||||
if [ "$KEEP_CONFIG" = true ]; then
|
||||
echo " Your configuration was preserved at $STRATA_HOME/config"
|
||||
echo ""
|
||||
fi
|
||||
echo " To reinstall Strata:"
|
||||
echo -e " ${CYAN}./scripts/install.sh${NC}"
|
||||
echo ""
|
||||
189
scripts/upgrade.sh
Executable file
189
scripts/upgrade.sh
Executable file
@@ -0,0 +1,189 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Strata Framework - Upgrade Script
|
||||
# Usage: ./scripts/upgrade.sh [options]
|
||||
# --check Only check for updates, don't install
|
||||
# --force Force reinstall even if up-to-date
|
||||
# --help Show this help message
|
||||
|
||||
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_CONFIG="$STRATA_HOME/config"
|
||||
|
||||
# Script directory
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_DIR="$(dirname "$SCRIPT_DIR")"
|
||||
|
||||
# Options
|
||||
CHECK_ONLY=false
|
||||
FORCE=false
|
||||
|
||||
# Parse arguments
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
--check)
|
||||
CHECK_ONLY=true
|
||||
shift
|
||||
;;
|
||||
--force|-f)
|
||||
FORCE=true
|
||||
shift
|
||||
;;
|
||||
--help|-h)
|
||||
echo "Strata Framework - Upgrade Script"
|
||||
echo ""
|
||||
echo "Usage: ./scripts/upgrade.sh [options]"
|
||||
echo ""
|
||||
echo "Options:"
|
||||
echo " --check Only check for updates"
|
||||
echo " --force Force reinstall even if up-to-date"
|
||||
echo " --help Show this help message"
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo -e "${RED}Unknown option: $1${NC}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
print_step() {
|
||||
echo -e "${BLUE}▶${NC} $1"
|
||||
}
|
||||
|
||||
print_success() {
|
||||
echo -e "${GREEN}✓${NC} $1"
|
||||
}
|
||||
|
||||
print_warning() {
|
||||
echo -e "${YELLOW}⚠${NC} $1"
|
||||
}
|
||||
|
||||
print_error() {
|
||||
echo -e "${RED}✗${NC} $1"
|
||||
}
|
||||
|
||||
# Get current installed version
|
||||
get_installed_version() {
|
||||
if [ -f "$STRATA_CONFIG/strata.json" ]; then
|
||||
grep '"version"' "$STRATA_CONFIG/strata.json" | cut -d'"' -f4
|
||||
elif [ -x "$STRATA_HOME/bin/strata" ]; then
|
||||
"$STRATA_HOME/bin/strata" version 2>/dev/null | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1 || echo "unknown"
|
||||
else
|
||||
echo "not installed"
|
||||
fi
|
||||
}
|
||||
|
||||
# Get repo version from package.json
|
||||
get_repo_version() {
|
||||
if [ -f "$REPO_DIR/package.json" ]; then
|
||||
grep '"version"' "$REPO_DIR/package.json" | head -1 | cut -d'"' -f4
|
||||
else
|
||||
echo "unknown"
|
||||
fi
|
||||
}
|
||||
|
||||
# Compare versions (returns 0 if $1 < $2)
|
||||
version_lt() {
|
||||
[ "$(printf '%s\n' "$1" "$2" | sort -V | head -n1)" = "$1" ] && [ "$1" != "$2" ]
|
||||
}
|
||||
|
||||
echo ""
|
||||
echo -e "${CYAN}╔═══════════════════════════════════════════════════════╗${NC}"
|
||||
echo -e "${CYAN}║ Strata Framework - Upgrade Check ║${NC}"
|
||||
echo -e "${CYAN}╚═══════════════════════════════════════════════════════╝${NC}"
|
||||
echo ""
|
||||
|
||||
# Check versions
|
||||
print_step "Checking versions..."
|
||||
|
||||
INSTALLED_VERSION=$(get_installed_version)
|
||||
REPO_VERSION=$(get_repo_version)
|
||||
|
||||
echo " Installed: $INSTALLED_VERSION"
|
||||
echo " Available: $REPO_VERSION"
|
||||
echo ""
|
||||
|
||||
# Determine if upgrade is needed
|
||||
if [ "$INSTALLED_VERSION" = "not installed" ]; then
|
||||
print_warning "Strata is not installed"
|
||||
echo ""
|
||||
echo " Run the installer:"
|
||||
echo -e " ${CYAN}./scripts/install.sh${NC}"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
NEEDS_UPGRADE=false
|
||||
if [ "$INSTALLED_VERSION" = "unknown" ] || [ "$REPO_VERSION" = "unknown" ]; then
|
||||
print_warning "Unable to determine version comparison"
|
||||
NEEDS_UPGRADE=true
|
||||
elif version_lt "$INSTALLED_VERSION" "$REPO_VERSION"; then
|
||||
NEEDS_UPGRADE=true
|
||||
fi
|
||||
|
||||
if [ "$NEEDS_UPGRADE" = false ] && [ "$FORCE" = false ]; then
|
||||
print_success "Strata is up-to-date!"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ "$NEEDS_UPGRADE" = true ]; then
|
||||
echo -e "${YELLOW}Update available: $INSTALLED_VERSION → $REPO_VERSION${NC}"
|
||||
else
|
||||
echo "Forcing reinstall of version $REPO_VERSION"
|
||||
fi
|
||||
echo ""
|
||||
|
||||
if [ "$CHECK_ONLY" = true ]; then
|
||||
echo "Run without --check to install the update."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Perform upgrade
|
||||
print_step "Pulling latest changes..."
|
||||
cd "$REPO_DIR"
|
||||
|
||||
if [ -d ".git" ]; then
|
||||
git pull --rebase 2>/dev/null || print_warning "Could not pull (not a git repo or no remote)"
|
||||
fi
|
||||
|
||||
print_step "Rebuilding compiler..."
|
||||
cd "$REPO_DIR/compiler"
|
||||
go mod download
|
||||
go build -ldflags="-s -w" -o "$REPO_DIR/bin/strata" ./cmd/strata
|
||||
cp "$REPO_DIR/bin/strata" "$STRATA_HOME/bin/strata"
|
||||
chmod +x "$STRATA_HOME/bin/strata"
|
||||
|
||||
print_step "Updating npm dependencies..."
|
||||
cd "$REPO_DIR"
|
||||
npm install --silent
|
||||
|
||||
print_step "Updating configuration..."
|
||||
# Update version in config
|
||||
if [ -f "$STRATA_CONFIG/strata.json" ]; then
|
||||
if [[ "$OSTYPE" == "darwin"* ]]; then
|
||||
sed -i '' "s/\"version\": \".*\"/\"version\": \"$REPO_VERSION\"/" "$STRATA_CONFIG/strata.json"
|
||||
else
|
||||
sed -i "s/\"version\": \".*\"/\"version\": \"$REPO_VERSION\"/" "$STRATA_CONFIG/strata.json"
|
||||
fi
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo -e "${GREEN}════════════════════════════════════════════════════════${NC}"
|
||||
echo -e "${GREEN} Upgrade Complete! ${NC}"
|
||||
echo -e "${GREEN}════════════════════════════════════════════════════════${NC}"
|
||||
echo ""
|
||||
echo " Strata has been upgraded to version $REPO_VERSION"
|
||||
echo ""
|
||||
echo " Run 'strata version' to verify."
|
||||
echo ""
|
||||
Reference in New Issue
Block a user