# Homebrew Tap Makefile # Provides convenient commands for building and managing the tap documentation .PHONY: help build serve parse clean test install dev setup check lint update # Default target .DEFAULT_GOAL := help # Variables RUBY := ruby PORT := 4000 HOST := localhost SCRIPTS_DIR := scripts THEME_DIR := theme DOCS_DIR := docs FORMULA_DIR := Formula help: ## Show this help message @echo "Homebrew Tap Documentation Builder" @echo "" @echo "Usage: make " @echo "" @echo "Targets:" @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " %-12s %s\n", $$1, $$2}' $(MAKEFILE_LIST) @echo "" @echo "Examples:" @echo " make build # Build the documentation site" @echo " make serve # Start development server on port 4000" @echo " make serve PORT=3000 # Start development server on port 3000" @echo " make dev # Full development setup (parse + build + serve)" build: ## Build the static documentation site @echo "๐Ÿ—๏ธ Building homebrew tap documentation..." @$(RUBY) $(SCRIPTS_DIR)/parse_formulas.rb @$(RUBY) $(SCRIPTS_DIR)/build_site.rb @echo "โœ… Build complete!" serve: ## Start development server (default: localhost:4000) @echo "๐Ÿš€ Starting development server on http://$(HOST):$(PORT)" @$(RUBY) $(SCRIPTS_DIR)/serve.rb $(PORT) $(HOST) parse: ## Parse formulae and generate JSON data only @echo "๐Ÿ“‹ Parsing formulae..." @$(RUBY) $(SCRIPTS_DIR)/parse_formulas.rb @echo "โœ… Formulae parsing complete!" clean: ## Clean all generated files @echo "๐Ÿงน Cleaning generated files..." @$(RUBY) $(SCRIPTS_DIR)/make.rb clean @echo "โœ… Clean complete!" dev: parse build serve ## Full development workflow: parse, build, and serve setup: ## Initial project setup and dependency check @echo "๐Ÿ”ง Setting up homebrew tap development environment..." @which $(RUBY) > /dev/null || (echo "โŒ Ruby not found. Please install Ruby first." && exit 1) @test -d $(FORMULA_DIR) || (echo "โŒ Formula directory not found" && exit 1) @test -d $(THEME_DIR) || (echo "โŒ Theme directory not found" && exit 1) @test -f $(THEME_DIR)/index.html.erb || (echo "โŒ Theme templates not found" && exit 1) @echo "โœ… Environment setup complete!" check: ## Check if all required files and directories exist @echo "๐Ÿ” Checking project structure..." @test -d $(SCRIPTS_DIR) && echo "โœ… Scripts directory exists" || echo "โŒ Scripts directory missing" @test -d $(THEME_DIR) && echo "โœ… Theme directory exists" || echo "โŒ Theme directory missing" @test -d $(FORMULA_DIR) && echo "โœ… Formula directory exists" || echo "โŒ Formula directory missing" @test -f $(THEME_DIR)/index.html.erb && echo "โœ… Index template exists" || echo "โŒ Index template missing" @test -f $(THEME_DIR)/formulae.html.erb && echo "โœ… Formulae template exists" || echo "โŒ Formulae template missing" @test -f $(THEME_DIR)/formula.html.erb && echo "โœ… Formula template exists" || echo "โŒ Formula template missing" @test -f $(THEME_DIR)/style.css && echo "โœ… CSS file exists" || echo "โŒ CSS file missing" @test -f $(THEME_DIR)/main.js && echo "โœ… JavaScript file exists" || echo "โŒ JavaScript file missing" test: check ## Run tests and validation @echo "๐Ÿงช Running validation tests..." @$(RUBY) -c $(SCRIPTS_DIR)/parse_formulas.rb && echo "โœ… parse_formulas.rb syntax OK" || echo "โŒ parse_formulas.rb syntax error" @$(RUBY) -c $(SCRIPTS_DIR)/build_site.rb && echo "โœ… build_site.rb syntax OK" || echo "โŒ build_site.rb syntax error" @$(RUBY) -c $(SCRIPTS_DIR)/serve.rb && echo "โœ… serve.rb syntax OK" || echo "โŒ serve.rb syntax error" @$(RUBY) -c $(SCRIPTS_DIR)/make.rb && echo "โœ… make.rb syntax OK" || echo "โŒ make.rb syntax error" @echo "โœ… All tests passed!" install: ## Install development dependencies (if Gemfile exists) @if [ -f Gemfile ]; then \ echo "๐Ÿ“ฆ Installing Ruby dependencies..."; \ bundle install; \ echo "โœ… Dependencies installed!"; \ else \ echo "โ„น๏ธ No Gemfile found, skipping dependency installation"; \ fi update: ## Update all gems to their latest versions (respecting Gemfile constraints) @if [ -f Gemfile ]; then \ echo "๐Ÿ”„ Updating Ruby dependencies..."; \ echo "๐Ÿ“ฆ Running bundle update..."; \ bundle update; \ echo "โœ… All gems updated to latest versions!"; \ echo ""; \ echo "๐Ÿ’ก Current gem versions:"; \ bundle list | grep -E "^\s*\*" | head -10; \ else \ echo "โŒ No Gemfile found"; \ exit 1; \ fi update-bundler: ## Update bundler itself to the latest version @echo "๐Ÿ”„ Updating Bundler..." @gem update bundler @echo "โœ… Bundler updated!" @echo "Current version: $$(bundle --version)" outdated: ## Show outdated gems @if [ -f Gemfile ]; then \ echo "๐Ÿ“‹ Checking for outdated gems..."; \ bundle outdated || true; \ else \ echo "โŒ No Gemfile found"; \ exit 1; \ fi watch: ## Watch for file changes and auto-rebuild (alias for serve) @$(MAKE) serve # Advanced targets serve-all: ## Start server accessible from all interfaces (0.0.0.0) @$(MAKE) serve HOST=0.0.0.0 serve-3000: ## Start server on port 3000 @$(MAKE) serve PORT=3000 serve-8080: ## Start server on port 8080 @$(MAKE) serve PORT=8080 build-production: ## Build for production deployment @echo "๐Ÿญ Building for production..." @$(MAKE) clean @$(MAKE) build @echo "โœ… Production build complete!" # Homebrew-specific targets tap-test: ## Test the tap installation locally @echo "๐Ÿบ Testing tap installation..." @brew tap-new ivuorinen/homebrew-tap --no-git 2>/dev/null || true @brew audit --strict $(FORMULA_DIR)/*.rb || echo "โš ๏ธ Some formulae may have audit issues" tap-install: ## Install this tap locally for testing @echo "๐Ÿบ Installing tap locally..." @brew tap $$(pwd) lint: ## Lint all Ruby scripts @echo "๐Ÿ” Linting Ruby scripts..." @brew style --fix --reset-cache . formula-new: ## Create a new formula template (usage: make formula-new NAME=myformula) @if [ -z "$(NAME)" ]; then \ echo "โŒ Please provide a formula name: make formula-new NAME=myformula"; \ exit 1; \ fi @echo "๐Ÿ“ Creating new formula: $(NAME)" @FIRST_CHAR=$$(echo $(NAME) | cut -c1); \ CLASS_NAME=$$($(RUBY) -e "puts '$(NAME)'.split('-').map(&:capitalize).join"); \ mkdir -p $(FORMULA_DIR)/$$FIRST_CHAR; \ echo "class $$CLASS_NAME < Formula" > $(FORMULA_DIR)/$$FIRST_CHAR/$(NAME).rb; \ echo ' desc "Description of $(NAME)"' >> $(FORMULA_DIR)/$$FIRST_CHAR/$(NAME).rb; \ echo ' homepage "https://github.com/ivuorinen/$(NAME)"' >> $(FORMULA_DIR)/$$FIRST_CHAR/$(NAME).rb; \ echo ' url "https://github.com/ivuorinen/$(NAME)/archive/v1.0.0.tar.gz"' >> $(FORMULA_DIR)/$$FIRST_CHAR/$(NAME).rb; \ echo ' sha256 "REPLACE_WITH_ACTUAL_SHA256"' >> $(FORMULA_DIR)/$$FIRST_CHAR/$(NAME).rb; \ echo ' license "MIT"' >> $(FORMULA_DIR)/$$FIRST_CHAR/$(NAME).rb; \ echo '' >> $(FORMULA_DIR)/$$FIRST_CHAR/$(NAME).rb; \ echo ' def install' >> $(FORMULA_DIR)/$$FIRST_CHAR/$(NAME).rb; \ echo ' # Installation steps here' >> $(FORMULA_DIR)/$$FIRST_CHAR/$(NAME).rb; \ echo ' end' >> $(FORMULA_DIR)/$$FIRST_CHAR/$(NAME).rb; \ echo '' >> $(FORMULA_DIR)/$$FIRST_CHAR/$(NAME).rb; \ echo ' test do' >> $(FORMULA_DIR)/$$FIRST_CHAR/$(NAME).rb; \ echo ' # Test steps here' >> $(FORMULA_DIR)/$$FIRST_CHAR/$(NAME).rb; \ echo ' end' >> $(FORMULA_DIR)/$$FIRST_CHAR/$(NAME).rb; \ echo 'end' >> $(FORMULA_DIR)/$$FIRST_CHAR/$(NAME).rb @echo "โœ… Formula template created at $(FORMULA_DIR)/$$(echo $(NAME) | cut -c1)/$(NAME).rb" @echo "๐Ÿ“ Remember to update the URL, SHA256, and implementation!" # Information targets info: ## Show project information @echo "๐Ÿ“‹ Homebrew Tap Information" @echo "==========================" @echo "Ruby version: $$($(RUBY) --version)" @echo "Project root: $$(pwd)" @echo "Scripts: $$(ls -1 $(SCRIPTS_DIR)/*.rb | wc -l | tr -d ' ') files" @echo "Formulae: $$(find $(FORMULA_DIR) -name '*.rb' | wc -l | tr -d ' ') files" @echo "Theme files: $$(ls -1 $(THEME_DIR)/* | wc -l | tr -d ' ') files" @if [ -f $(DOCS_DIR)/_data/formulae.json ]; then \ echo "Generated formulae: $$(cat $(DOCS_DIR)/_data/formulae.json | grep -o '"formulae_count":[0-9]*' | cut -d: -f2)"; \ fi version: ## Show version information @echo "Homebrew Tap Builder" @echo "Ruby: $$($(RUBY) --version)" @echo "Make: $$(make --version | head -1)" @echo "Git: $$(git --version 2>/dev/null || echo 'not available')" # Legacy support (for backward compatibility with scripts/make.rb) ruby-build: ## Legacy: use Ruby make script for build @$(RUBY) $(SCRIPTS_DIR)/make.rb build ruby-serve: ## Legacy: use Ruby make script for serve @$(RUBY) $(SCRIPTS_DIR)/make.rb serve ruby-clean: ## Legacy: use Ruby make script for clean @$(RUBY) $(SCRIPTS_DIR)/make.rb clean ruby-parse: ## Legacy: use Ruby make script for parse @$(RUBY) $(SCRIPTS_DIR)/make.rb parse