-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
106 lines (87 loc) · 3.84 KB
/
Makefile
File metadata and controls
106 lines (87 loc) · 3.84 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# Makefile for ElevenLabs
# Auto-generated by swift-openapi-bootstrapper
# ------------------------------------------------------------------------------
# Configuration
# ------------------------------------------------------------------------------
# Shell settings: fail on error, pipefail
SHELL := /bin/bash
.SHELLFLAGS := -eu -o pipefail -c
# Swift Format Settings
SWIFT_FORMAT_OPTIONS := -i -p --ignore-unparsable-files --configuration .swift-format
SWIFT_FORMAT_TARGETS := ./Sources ./Tests
# Docker Settings
DOCKER_IMAGE := swift:latest
# Visuals
RED := \033[31m
GREEN := \033[32m
YELLOW := \033[33m
RESET := \033[0m
# ------------------------------------------------------------------------------
# Meta Targets
# ------------------------------------------------------------------------------
.PHONY: all help check-clean merge-main format test-on-linux generate build test
# Default target runs help
all: help
# auto-doc: Parses comments starting with '##' to generate a help menu
help:
@echo "$(YELLOW)Available commands:$(RESET)"
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " $(GREEN)%-20s$(RESET) %s\n", $$1, $$2}'
# ------------------------------------------------------------------------------
# Git Operations
# ------------------------------------------------------------------------------
check-clean: ## Check if there are uncommitted changes
@echo "$(YELLOW)Checking for uncommitted changes...$(RESET)"
@git diff-index --quiet HEAD -- || (echo "$(RED)Error: Uncommitted changes detected. Commit or stash them first.$(RESET)" && exit 1)
@echo "$(GREEN)Clean.$(RESET)"
merge-main: check-clean ## Merge current branch into main and push
$(eval BRANCH := $(shell git branch --show-current))
@if [ "$(BRANCH)" == "main" ]; then \
echo "$(RED)Error: You are already on main.$(RESET)"; \
exit 1; \
fi
@echo "$(YELLOW)Merging $(BRANCH) into main...$(RESET)"
git checkout main
git pull origin main
git merge "$(BRANCH)"
git push origin main
@echo "$(GREEN)Successfully merged $(BRANCH) into main and pushed.$(RESET)"
@# Optional: switch back to the original branch
@# git checkout "$(BRANCH)"
# ------------------------------------------------------------------------------
# Code Quality
# ------------------------------------------------------------------------------
format: check-clean ## Run swift-format on Sources and Tests
@echo "$(YELLOW)Formatting Swift files...$(RESET)"
@which swift-format > /dev/null || (echo "$(RED)swift-format not found.$(RESET)" && exit 1)
@find $(SWIFT_FORMAT_TARGETS) -name "*.swift" -not -path "*/GeneratedSources/*" \
| xargs swift-format $(SWIFT_FORMAT_OPTIONS)
@git add .
@echo "$(GREEN)Formatting complete. Changes staged.$(RESET)"
test-on-linux: ## Run swift tests inside a Docker container
@echo "$(YELLOW)Running tests in Docker ($(DOCKER_IMAGE))...$(RESET)"
docker run --rm \
-v "$(CURDIR):/code" \
-w /code \
$(DOCKER_IMAGE) \
swift test
regenerate:
uvx --from git+https://github.com/atacan/swift-package-generator-based-on-openapi.git swift-bootstrapper .
generate: ## Generate Swift code from OpenAPI spec
@echo "$(YELLOW)Generating Swift code from OpenAPI specification...$(RESET)"
swift run swift-openapi-generator generate \
--config openapi-generator-config-types.yaml \
openapi.json \
--output-directory Sources/ElevenLabsTypes/GeneratedSources
swift run swift-openapi-generator generate \
--config openapi-generator-config-client.yaml \
openapi.json \
--output-directory Sources/ElevenLabs/GeneratedSources
@echo "$(GREEN)Code generation complete!$(RESET)"
build: ## Build the Swift package
@echo "$(YELLOW)Building ElevenLabs...$(RESET)"
swift build
@echo "$(GREEN)Build complete!$(RESET)"
test: ## Run tests for the package
@echo "$(YELLOW)Running tests for ElevenLabs...$(RESET)"
swift test
@echo "$(GREEN)Tests complete!$(RESET)"