- 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-compile dev, strata-compile build, strata-compile
g (generators)
- create-strata-compile scaffolding CLI with Pokemon API example
- Dev server with WebSocket HMR (Hot Module Replacement)
- Documentation: README, ARCHITECTURE, CHANGELOG, CONTRIBUTING,
LICENSE
261 lines
7.3 KiB
Bash
Executable File
261 lines
7.3 KiB
Bash
Executable File
#!/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-compile'
|
|
alias stdev='strata-compile dev'
|
|
alias stbuild='strata-compile build'
|
|
alias stgen='strata-compile generate'
|
|
alias stnew='npx create-strata-compile'
|
|
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-compile my-app${NC}"
|
|
echo -e " ${CYAN}cd my-app${NC}"
|
|
echo -e " ${CYAN}strata-compile dev${NC}"
|
|
echo ""
|
|
echo " Documentation: https://stratajs.dev/docs"
|
|
echo ""
|
|
}
|
|
|
|
main
|