Template
1
0
Fork 0

Fixed binaries

This commit is contained in:
Atridad Lahiji 2025-01-04 21:24:45 -07:00
parent 6032b9ab17
commit 9a2eb9b1a6
7 changed files with 66 additions and 60 deletions

3
.gitignore vendored
View file

@ -5,4 +5,5 @@ airbin
tmp/ tmp/
*.rdb *.rdb
.DS_Store .DS_Store
tailwind.config.js tailwind.config.js
lib/stylegen/tw

View file

@ -1,10 +1,3 @@
# Colors
CYAN := \033[36m
YELLOW := \033[33m
GREEN := \033[32m
RED := \033[31m
RESET := \033[0m
# Emoji # Emoji
CHECK := CHECK :=
BUILD := 🔨 BUILD := 🔨
@ -17,8 +10,8 @@ WARN := ⚠️
DOCS := 📚 DOCS := 📚
# Variables # Variables
BINARY_NAME := goth.stack BINARY_NAME := atri.dad
DOCKER_IMAGE := goth-stack DOCKER_IMAGE := atri-dot-dad
GO_FILES := $(wildcard *.go) GO_FILES := $(wildcard *.go)
CSS_INPUT := lib/stylegen/base.css CSS_INPUT := lib/stylegen/base.css
CSS_OUTPUT := public/css/styles.css CSS_OUTPUT := public/css/styles.css
@ -34,109 +27,108 @@ endif
.PHONY: all build clean run dev stylegen docker-dev docker-build docker-run test help reset ensure-swag .PHONY: all build clean run dev stylegen docker-dev docker-build docker-run test help reset ensure-swag
help: help:
@echo "$(CYAN)Available commands:$(RESET)" @echo "Available commands:"
@echo "$(YELLOW)make clean$(RESET) - Remove build artifacts" @echo "make clean - Remove build artifacts"
@echo "$(YELLOW)make reset$(RESET) - Clean and reset the project to initial state" @echo "make reset - Clean and reset the project to initial state"
@echo "$(YELLOW)make build$(RESET) - Generate CSS, docs, and build Go binary" @echo "make build - Generate CSS, docs, and build Go binary"
@echo "$(YELLOW)make run$(RESET) - Build and run the binary" @echo "make run - Build and run the binary"
@echo "$(YELLOW)make dev$(RESET) - Run in development mode" @echo "make dev - Run in development mode"
@echo "$(YELLOW)make docker-dev$(RESET)- Run development environment in Docker" @echo "make docker-dev - Run development environment in Docker"
@echo "$(YELLOW)make docker-run$(RESET)- Run production container" @echo "make docker-run - Run production container"
@echo "$(YELLOW)make test$(RESET) - Run tests" @echo "make test - Run tests"
@echo "$(YELLOW)make prod$(RESET) - Full production build" @echo "make prod - Full production build"
# Check if swag is installed # Check if swag is installed
ensure-swag: ensure-swag:
@command -v swag >/dev/null 2>&1 || { \ @command -v swag >/dev/null 2>&1 || { \
echo "$(WARN) $(RED)Swagger CLI (swag) is not installed. Installing...$(RESET)"; \ echo "$(WARN) Swagger CLI (swag) is not installed. Installing..."; \
go install github.com/swaggo/swag/cmd/swag@latest; \ go install github.com/swaggo/swag/cmd/swag@latest; \
} }
reset: reset:
@echo "$(CLEAN) $(CYAN)Performing complete project reset...$(RESET)" @echo "$(CLEAN) Performing complete project reset..."
@rm -f $(BINARY_NAME) @rm -f $(BINARY_NAME)
@rm -f $(CSS_OUTPUT) @rm -f $(CSS_OUTPUT)
@rm -rf public/css/* @rm -rf public/css/*
@rm -f tailwind.config.js @rm -f tailwind.config.js
@rm -rf docs/docs.go docs/swagger.json docs/swagger.yaml @rm -rf docs/docs.go docs/swagger.json docs/swagger.yaml
@go clean -cache -testcache -modcache @go clean -cache -testcache -modcache
@echo "$(CHECK) $(GREEN)Project reset complete$(RESET)" @rm -rf $(BASE_PATH)/tw # Remove the 'tw' directory
@echo "$(CHECK) Project reset complete"
clean: clean:
@echo "$(CLEAN) $(CYAN)Cleaning build artifacts...$(RESET)" @echo "$(CLEAN) Cleaning build artifacts..."
@rm -f $(BINARY_NAME) @rm -f $(BINARY_NAME)
@rm -f $(CSS_OUTPUT) @rm -f $(CSS_OUTPUT)
@echo "$(CHECK) $(GREEN)Cleanup complete$(RESET)" @rm -rf $(BASE_PATH)/lib/stylegen/tw # Remove the 'tw' directory
@echo "$(CHECK) Cleanup complete"
stylegen: stylegen:
@echo "$(CSS) $(CYAN)Generating CSS styles...$(RESET)" @echo "$(CSS) Generating CSS styles..."
@echo "Current working directory: $$(pwd)" @echo "Current working directory: $$(pwd)"
@echo "Contents of current directory:" @echo "Contents of current directory:"
@ls -la @ls -la
@echo "\nContents of lib/stylegen:" @echo "\nContents of lib/stylegen:"
@ls -la lib/stylegen @ls -la lib/stylegen
@echo "\nContents of lib/stylegen/tw:"
@ls -la lib/stylegen/tw
@chmod +x $(BASE_PATH)/lib/stylegen/gen.sh @chmod +x $(BASE_PATH)/lib/stylegen/gen.sh
@chmod +x $(BASE_PATH)/lib/stylegen/tw/*
@$(BASE_PATH)/lib/stylegen/gen.sh \ @$(BASE_PATH)/lib/stylegen/gen.sh \
-e "html" \ -e "html" \
-d "$(BASE_PATH)/pages/templates" \ -d "$(BASE_PATH)/pages/templates" \
-o "$(BASE_PATH)/public/css" -o "$(BASE_PATH)/public/css"
@echo "$(CHECK) $(GREEN)CSS generation complete$(RESET)" @echo "$(CHECK) CSS generation complete"
swaggergen: ensure-swag swaggergen: ensure-swag
@echo "$(DOCS) $(CYAN)Generating Swagger documentation...$(RESET)" @echo "$(DOCS) Generating Swagger documentation..."
@swag init @swag init
@echo "$(CHECK) $(GREEN)Swagger docs generated$(RESET)" @echo "$(CHECK) Swagger docs generated"
# Combined generation target # Combined generation target
generate: stylegen swaggergen generate: stylegen swaggergen
build: generate build: generate
@echo "$(BUILD) $(CYAN)Building binary...$(RESET)" @echo "$(BUILD) Building binary..."
@go build -o $(BINARY_NAME) @go build -o $(BINARY_NAME)
@echo "$(CHECK) $(GREEN)Build complete: $(BINARY_NAME)$(RESET)" @echo "$(CHECK) Build complete: $(BINARY_NAME)"
test: test:
@echo "$(TEST) $(CYAN)Running tests...$(RESET)" @echo "$(TEST) Running tests..."
@go test ./... @go test ./...
@echo "$(CHECK) $(GREEN)Tests complete$(RESET)" @echo "$(CHECK) Tests complete"
dev: generate dev: generate
@echo "$(RUN) $(CYAN)Starting development server...$(RESET)" @echo "$(RUN) Starting development server..."
@go run main.go @go run main.go
run: build run: build
@echo "$(RUN) $(CYAN)Running server...$(RESET)" @echo "$(RUN) Running server..."
@./$(BINARY_NAME) @./$(BINARY_NAME)
docker-dev: docker-dev:
@echo "$(DOCKER) $(CYAN)Starting development container...$(RESET)" @echo "$(DOCKER) Starting development container..."
@docker-compose -f docker-compose.dev.yml up --build @docker-compose -f docker-compose.dev.yml up --build
docker-build: generate docker-build: generate
@echo "$(DOCKER) $(CYAN)Building production Docker image...$(RESET)" @echo "$(DOCKER) Building production Docker image..."
@docker build -t $(DOCKER_IMAGE) . @docker build -t $(DOCKER_IMAGE) .
@echo "$(CHECK) $(GREEN)Docker image build complete$(RESET)" @echo "$(CHECK) Docker image build complete"
docker-run: docker-build docker-run: docker-build
@echo "$(DOCKER) $(CYAN)Running production container...$(RESET)" @echo "$(DOCKER) Running production container..."
@docker-compose up @docker-compose up
deps: deps:
@echo "$(BUILD) $(CYAN)Installing dependencies...$(RESET)" @echo "$(BUILD) Installing dependencies..."
@go mod download @go mod download
@go install github.com/swaggo/swag/cmd/swag@latest @go install github.com/swaggo/swag/cmd/swag@latest
@echo "$(CHECK) $(GREEN)Dependencies installed$(RESET)" @echo "$(CHECK) Dependencies installed"
fmt: fmt:
@echo "$(BUILD) $(CYAN)Formatting code...$(RESET)" @echo "$(BUILD) Formatting code..."
@go fmt ./... @go fmt ./...
@echo "$(CHECK) $(GREEN)Code formatting complete$(RESET)" @echo "$(CHECK) Code formatting complete"
# Full production build # Full production build
prod: clean generate build prod: clean generate build
@echo "$(CHECK) $(GREEN)Production build complete$(RESET)" @echo "$(CHECK) Production build complete"
.DEFAULT_GOAL := help .DEFAULT_GOAL := help

View file

@ -1,4 +1,5 @@
#!/bin/bash # Define the version of the binary to download
VERSION="v1.7.27"
# Parse command-line arguments # Parse command-line arguments
while [[ $# -gt 0 ]]; do while [[ $# -gt 0 ]]; do
@ -62,23 +63,35 @@ esac
echo "Detected OS: $OS" echo "Detected OS: $OS"
echo "Detected Architecture: $ARCH" echo "Detected Architecture: $ARCH"
# Use tw directory in script location # Function to construct the binary download URL based on version, OS, and architecture
BINARY="${SCRIPT_DIR}/tw/${OS}-${ARCH}" get_binary_url() {
if [ "$OS" = "windows" ]; then echo "https://github.com/dobicinaitis/tailwind-cli-extra/releases/download/$VERSION/tailwindcss-extra-$OS-$ARCH"
BINARY="${BINARY}.exe" }
fi
echo "Looking for binary at: $BINARY" # Create the 'tw' directory for storing the downloaded binary
TW_DIR="${SCRIPT_DIR}/tw"
mkdir -p "$TW_DIR"
# Check if binary exists # Set the binary path
BINARY="${TW_DIR}/tailwindcss-extra-${OS}-${ARCH}"
# Check if the binary is already downloaded, otherwise download it
if [ ! -f "$BINARY" ]; then if [ ! -f "$BINARY" ]; then
echo "Binary not found: $BINARY" echo "Binary not found, downloading version $VERSION..."
echo "Contents of ${SCRIPT_DIR}/tw/:"
ls -la "${SCRIPT_DIR}/tw/" DOWNLOAD_URL=$(get_binary_url)
if [ -z "$DOWNLOAD_URL" ]; then
echo "No suitable release found for this OS and architecture."
exit 1 exit 1
fi
# Download the binary
curl -L "$DOWNLOAD_URL" -o "$BINARY"
echo "Downloaded binary to: $BINARY"
fi fi
# Make binary executable # Make the binary executable
chmod +x "$BINARY" chmod +x "$BINARY"
echo "Using binary: $BINARY" echo "Using binary: $BINARY"

Binary file not shown.

Binary file not shown.

Binary file not shown.

File diff suppressed because one or more lines are too long