Files
strata-compile/Makefile
Carlos Gutierrez 9e451469f5 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
2026-01-16 09:01:29 -05:00

284 lines
8.8 KiB
Makefile

.PHONY: build install install-global install-local uninstall upgrade doctor \
dev clean test example-build \
gen-component gen-page gen-store \
setup link help
# ============================================================================
# BUILD
# ============================================================================
# Build the Go compiler
build:
@echo "Building Strata compiler..."
@mkdir -p bin
@cd compiler && go mod tidy && go build -ldflags="-s -w" -o ../bin/strata ./cmd/strata
@echo "Done! Binary at ./bin/strata"
# Build with race detector (for development)
build-debug:
@echo "Building Strata compiler (debug)..."
@mkdir -p bin
@cd compiler && go build -race -o ../bin/strata-debug ./cmd/strata
@echo "Done! Binary at ./bin/strata-debug"
# ============================================================================
# INSTALLATION
# ============================================================================
# Full installation (local by default)
install:
@chmod +x scripts/install.sh
@./scripts/install.sh
# Install globally to /usr/local/bin
install-global:
@chmod +x scripts/install.sh
@./scripts/install.sh --global
# Install locally to ~/.strata only
install-local:
@chmod +x scripts/install.sh
@./scripts/install.sh --local
# Quick setup (build + npm install, no shell config)
setup: build
@echo "Installing npm dependencies..."
@npm install --silent
@echo ""
@echo "Strata setup complete!"
@echo " Binary: ./bin/strata"
@echo ""
@echo "Run 'make install' for full installation with shell config."
# Link binary to /usr/local/bin (quick global access)
link: build
@echo "Linking strata to /usr/local/bin..."
@if [ -w /usr/local/bin ]; then \
ln -sf "$(PWD)/bin/strata" /usr/local/bin/strata; \
else \
sudo ln -sf "$(PWD)/bin/strata" /usr/local/bin/strata; \
fi
@echo "Done! 'strata' command is now available globally."
# Unlink from /usr/local/bin
unlink:
@echo "Unlinking strata from /usr/local/bin..."
@if [ -w /usr/local/bin ]; then \
rm -f /usr/local/bin/strata; \
else \
sudo rm -f /usr/local/bin/strata; \
fi
@echo "Done!"
# Uninstall Strata
uninstall:
@chmod +x scripts/uninstall.sh
@./scripts/uninstall.sh
# Uninstall without confirmation
uninstall-force:
@chmod +x scripts/uninstall.sh
@./scripts/uninstall.sh --force
# ============================================================================
# MAINTENANCE
# ============================================================================
# Upgrade to latest version
upgrade:
@chmod +x scripts/upgrade.sh
@./scripts/upgrade.sh
# Check for updates only
upgrade-check:
@chmod +x scripts/upgrade.sh
@./scripts/upgrade.sh --check
# Diagnose installation issues
doctor:
@chmod +x scripts/doctor.sh
@./scripts/doctor.sh
# Auto-fix installation issues
doctor-fix:
@chmod +x scripts/doctor.sh
@./scripts/doctor.sh --fix
# ============================================================================
# DEVELOPMENT
# ============================================================================
# Run dev server on example app
dev: build
@cd examples/basic-app && ../../bin/strata dev
# Run dev server with browser open
dev-open: build
@cd examples/basic-app && ../../bin/strata dev --open
# Build example app for production
example-build: build
@cd examples/basic-app && ../../bin/strata build
# Preview example app production build
example-preview: build
@cd examples/basic-app && ../../bin/strata preview
# Watch and rebuild compiler on changes
watch:
@echo "Watching for compiler changes..."
@while true; do \
find compiler -name '*.go' | entr -d make build; \
done
# ============================================================================
# TESTING
# ============================================================================
# Run all tests
test:
@echo "Running Go tests..."
@cd compiler && go test ./...
@echo ""
@echo "Running npm tests..."
@npm test
# Run Go tests only
test-go:
@cd compiler && go test ./...
# Run Go tests with verbose output
test-go-verbose:
@cd compiler && go test -v ./...
# Run npm tests only
test-npm:
@npm test
# Run tests with coverage
test-coverage:
@cd compiler && go test -coverprofile=coverage.out ./...
@cd compiler && go tool cover -html=coverage.out -o coverage.html
@echo "Coverage report: compiler/coverage.html"
# ============================================================================
# CODE GENERATION
# ============================================================================
# Generate component (usage: make gen-component NAME=MyComponent)
gen-component: build
@if [ -z "$(NAME)" ]; then \
echo "Usage: make gen-component NAME=MyComponent"; \
exit 1; \
fi
@cd examples/basic-app && ../../bin/strata generate component $(NAME)
# Generate page (usage: make gen-page NAME=about)
gen-page: build
@if [ -z "$(NAME)" ]; then \
echo "Usage: make gen-page NAME=about"; \
exit 1; \
fi
@cd examples/basic-app && ../../bin/strata generate page $(NAME)
# Generate store (usage: make gen-store NAME=cart)
gen-store: build
@if [ -z "$(NAME)" ]; then \
echo "Usage: make gen-store NAME=cart"; \
exit 1; \
fi
@cd examples/basic-app && ../../bin/strata generate store $(NAME)
# Shorthand aliases
c: gen-component
p: gen-page
s: gen-store
# ============================================================================
# CLEANUP
# ============================================================================
# Clean all build artifacts
clean:
@rm -rf bin/
@rm -rf dist/
@rm -rf .strata/
@rm -rf examples/basic-app/dist/
@rm -rf examples/basic-app/.strata/
@rm -rf compiler/coverage.out
@rm -rf compiler/coverage.html
@echo "Cleaned!"
# Deep clean (includes node_modules and go cache)
clean-all: clean
@rm -rf node_modules/
@cd compiler && go clean -cache
@echo "Deep cleaned!"
# ============================================================================
# RELEASE
# ============================================================================
# Build release binaries for all platforms
release:
@echo "Building release binaries..."
@mkdir -p dist/release
@cd compiler && GOOS=darwin GOARCH=amd64 go build -ldflags="-s -w" -o ../dist/release/strata-darwin-amd64 ./cmd/strata
@cd compiler && GOOS=darwin GOARCH=arm64 go build -ldflags="-s -w" -o ../dist/release/strata-darwin-arm64 ./cmd/strata
@cd compiler && GOOS=linux GOARCH=amd64 go build -ldflags="-s -w" -o ../dist/release/strata-linux-amd64 ./cmd/strata
@cd compiler && GOOS=linux GOARCH=arm64 go build -ldflags="-s -w" -o ../dist/release/strata-linux-arm64 ./cmd/strata
@cd compiler && GOOS=windows GOARCH=amd64 go build -ldflags="-s -w" -o ../dist/release/strata-windows-amd64.exe ./cmd/strata
@echo "Release binaries built in dist/release/"
# ============================================================================
# HELP
# ============================================================================
# Show help
help:
@echo ""
@echo "Strata Framework - Development Commands"
@echo "========================================"
@echo ""
@echo "Installation:"
@echo " make install Full installation with shell config"
@echo " make install-global Install globally to /usr/local/bin"
@echo " make install-local Install locally to ~/.strata"
@echo " make setup Quick setup (build + npm, no shell config)"
@echo " make link Link binary to /usr/local/bin"
@echo " make uninstall Uninstall Strata"
@echo ""
@echo "Maintenance:"
@echo " make upgrade Upgrade to latest version"
@echo " make upgrade-check Check for updates"
@echo " make doctor Diagnose installation issues"
@echo " make doctor-fix Auto-fix installation issues"
@echo ""
@echo "Building:"
@echo " make build Build the Go compiler"
@echo " make build-debug Build with race detector"
@echo " make release Build release binaries for all platforms"
@echo ""
@echo "Development:"
@echo " make dev Run dev server (examples/basic-app)"
@echo " make dev-open Run dev server and open browser"
@echo " make example-build Build example app for production"
@echo " make example-preview Preview production build"
@echo " make watch Watch and rebuild compiler"
@echo ""
@echo "Testing:"
@echo " make test Run all tests"
@echo " make test-go Run Go tests only"
@echo " make test-npm Run npm tests only"
@echo " make test-coverage Run tests with coverage report"
@echo ""
@echo "Code Generation:"
@echo " make gen-component NAME=Button Generate component"
@echo " make gen-page NAME=about Generate page"
@echo " make gen-store NAME=cart Generate store"
@echo ""
@echo "Cleanup:"
@echo " make clean Clean build artifacts"
@echo " make clean-all Deep clean (includes node_modules)"
@echo ""