-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
162 lines (128 loc) · 4.64 KB
/
Copy pathMakefile
File metadata and controls
162 lines (128 loc) · 4.64 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
.PHONY: build build-cli build-release run clean install uninstall open lint format help build-mcp install-mcp uninstall-mcp
# Project configuration
PROJECT_NAME = PRDashboard
SCHEME = PRDashboard
CLI_SCHEME = ghpr
BUILD_DIR = build
DERIVED_DATA = $(BUILD_DIR)/DerivedData
APP_NAME = $(PROJECT_NAME).app
CLI_NAME = ghpr
INSTALL_DIR = /Applications
# MCP server (TypeScript)
MCP_DIR = mcp-ghpr
MCP_BIN_NAME = mcp-ghpr
LOCAL_BIN_DIR = $(HOME)/.local/bin
# Xcode build settings
XCODE_PROJECT = $(PROJECT_NAME).xcodeproj
XCODE_FLAGS = -project $(XCODE_PROJECT) -scheme $(SCHEME) -derivedDataPath $(DERIVED_DATA)
# Default target
all: build
## Build targets
build: ## Build debug version
xcodebuild $(XCODE_FLAGS) -configuration Debug build
build-cli: ## Build ghpr command-line tool
xcodebuild -project $(XCODE_PROJECT) -scheme $(CLI_SCHEME) -derivedDataPath $(DERIVED_DATA) -configuration Debug build
@CLI_PATH=$$(find $(DERIVED_DATA) -name "$(CLI_NAME)" -type f | head -1); \
if [ -n "$$CLI_PATH" ]; then \
echo "Built $$CLI_PATH"; \
fi
build-release: ## Build release version
xcodebuild $(XCODE_FLAGS) -configuration Release build
archive: ## Create release archive
xcodebuild $(XCODE_FLAGS) -configuration Release \
-archivePath $(BUILD_DIR)/$(PROJECT_NAME).xcarchive archive
## Run targets
run: build ## Build and run the app
@APP_PATH=$$(find $(DERIVED_DATA) -name "$(APP_NAME)" -type d | head -1); \
if [ -n "$$APP_PATH" ]; then \
open "$$APP_PATH"; \
else \
echo "Error: Could not find $(APP_NAME)"; \
exit 1; \
fi
run-release: build-release ## Build release and run
@APP_PATH=$$(find $(DERIVED_DATA) -name "$(APP_NAME)" -type d | head -1); \
if [ -n "$$APP_PATH" ]; then \
open "$$APP_PATH"; \
else \
echo "Error: Could not find $(APP_NAME)"; \
exit 1; \
fi
## Installation targets
install: build-release ## Install to /Applications
@APP_PATH=$$(find $(DERIVED_DATA) -name "$(APP_NAME)" -type d | head -1); \
if [ -n "$$APP_PATH" ]; then \
echo "Installing to $(INSTALL_DIR)/$(APP_NAME)..."; \
rm -rf "$(INSTALL_DIR)/$(APP_NAME)"; \
cp -R "$$APP_PATH" "$(INSTALL_DIR)/"; \
echo "Installed successfully!"; \
else \
echo "Error: Build the app first with 'make build-release'"; \
exit 1; \
fi
uninstall: ## Remove from /Applications
@if [ -d "$(INSTALL_DIR)/$(APP_NAME)" ]; then \
echo "Removing $(INSTALL_DIR)/$(APP_NAME)..."; \
rm -rf "$(INSTALL_DIR)/$(APP_NAME)"; \
echo "Uninstalled successfully!"; \
else \
echo "$(APP_NAME) is not installed"; \
fi
## MCP server targets
build-mcp: ## Build the mcp-ghpr TypeScript MCP server
cd $(MCP_DIR) && npm install && npm run build
install-mcp: build-mcp ## Install mcp-ghpr launcher into ~/.local/bin/
@mkdir -p "$(LOCAL_BIN_DIR)"
@MCP_ENTRY="$(CURDIR)/$(MCP_DIR)/dist/index.js"; \
LAUNCHER="$(LOCAL_BIN_DIR)/$(MCP_BIN_NAME)"; \
printf '#!/bin/sh\nexec node "%s" "$$@"\n' "$$MCP_ENTRY" > "$$LAUNCHER"; \
chmod +x "$$LAUNCHER"; \
echo "Installed $$LAUNCHER -> $$MCP_ENTRY"
uninstall-mcp: ## Remove mcp-ghpr launcher from ~/.local/bin/
@LAUNCHER="$(LOCAL_BIN_DIR)/$(MCP_BIN_NAME)"; \
if [ -e "$$LAUNCHER" ]; then \
rm -f "$$LAUNCHER" && echo "Removed $$LAUNCHER"; \
else \
echo "$$LAUNCHER not installed"; \
fi
## Clean targets
clean: ## Clean build artifacts
xcodebuild $(XCODE_FLAGS) clean
rm -rf $(BUILD_DIR)
clean-all: clean ## Clean everything including Xcode caches
rm -rf ~/Library/Developer/Xcode/DerivedData/$(PROJECT_NAME)-*
## Development targets
dev: ## Build with local signing (requires Apple ID in Xcode)
./dev.sh
dev-run: ## Build with local signing and run
./dev.sh --run
open: ## Open project in Xcode
open $(XCODE_PROJECT)
lint: ## Run SwiftLint (if installed)
@if command -v swiftlint &> /dev/null; then \
swiftlint lint --path $(PROJECT_NAME); \
else \
echo "SwiftLint not installed. Install with: brew install swiftlint"; \
fi
format: ## Format code with SwiftFormat (if installed)
@if command -v swiftformat &> /dev/null; then \
swiftformat $(PROJECT_NAME); \
else \
echo "SwiftFormat not installed. Install with: brew install swiftformat"; \
fi
## Utility targets
check: ## Check if project builds without errors
xcodebuild $(XCODE_FLAGS) -configuration Debug build -quiet
loc: ## Count lines of code
@echo "Lines of Swift code:"
@find $(PROJECT_NAME) -name "*.swift" -exec cat {} \; | wc -l
files: ## List all Swift files
@find $(PROJECT_NAME) -name "*.swift" | sort
## Help
help: ## Show this help
@echo "PRDashboard - GitHub PR Menu Bar App"
@echo ""
@echo "Usage: make [target]"
@echo ""
@echo "Targets:"
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}'