-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
168 lines (146 loc) · 4.81 KB
/
Makefile
File metadata and controls
168 lines (146 loc) · 4.81 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
163
164
165
166
167
168
.PHONY: help format lint test api frontend clean install analyze docker-build docker-up docker-down docker-logs
# Default target - show help
help:
@echo "ExtensionScanner - Available Make Commands"
@echo "======================================="
@echo ""
@echo "Docker (Recommended):"
@echo " make docker-build - Build Docker container"
@echo " make docker-up - Start container (foreground)"
@echo " make docker-down - Stop container"
@echo " make docker-logs - View container logs"
@echo ""
@echo "Code Quality:"
@echo " make format - Format Python code with Black"
@echo " make lint - Run Pylint on source code"
@echo " make test - Run pytest test suite"
@echo " make precommit - Run pre-commit hooks on all files"
@echo ""
@echo "Run Applications (Local Development):"
@echo " make api - Start FastAPI server for frontend (port 8007)"
@echo " make frontend - Start React frontend dev server (port 5173)"
@echo " make analyze URL=... - Analyze extension from Chrome Web Store URL"
@echo " make analyze-file FILE=... - Analyze local CRX/ZIP file"
@echo ""
@echo "Development:"
@echo " make install - Install dependencies with uv"
@echo " make clean - Remove output files and caches"
@echo ""
# Format code with Black
format:
@echo "Formatting Python code with Black..."
uv run black .
@echo "✓ Formatting complete"
# Lint code with Pylint
lint:
@echo "Running Pylint on source code..."
uv run pylint src/
@echo "✓ Linting complete"
# Run tests
test:
@echo "Running pytest..."
uv run pytest
@echo "✓ Tests complete"
# Run pre-commit hooks
precommit:
@echo "Running pre-commit hooks..."
pre-commit run --all-files
@echo "✓ Pre-commit checks complete"
# Start FastAPI server
api:
@echo "Starting FastAPI server with auto-reload..."
@echo "Access at: http://localhost:8007"
@echo "API docs at: http://localhost:8007/docs"
uv run extension-scanner serve --reload
# Start React frontend
frontend:
@echo "Starting React frontend development server..."
@echo "Access at: http://localhost:5173"
cd frontend && npm run dev
# Analyze extension via CLI from URL
analyze:
ifndef URL
@echo "Error: URL parameter is required"
@echo "Usage: make analyze URL=https://chromewebstore.google.com/detail/example/abcdef"
@echo " make analyze URL=https://... OUTPUT=results.json"
@exit 1
endif
@echo "Analyzing Chrome extension from URL..."
ifdef OUTPUT
uv run extension-scanner analyze --url $(URL) --output $(OUTPUT)
else
uv run extension-scanner analyze --url $(URL)
endif
# Analyze local CRX/ZIP file via CLI
analyze-file:
ifndef FILE
@echo "Error: FILE parameter is required"
@echo "Usage: make analyze-file FILE=/path/to/extension.crx"
@echo " make analyze-file FILE=/path/to/extension.zip OUTPUT=results.json"
@exit 1
endif
@echo "Analyzing local extension file..."
ifdef OUTPUT
uv run extension-scanner analyze --file $(FILE) --output $(OUTPUT)
else
uv run extension-scanner analyze --file $(FILE)
endif
# Install dependencies
install:
@echo "Installing Python dependencies with uv..."
uv sync
# Clean output and cache files
clean:
@echo "Cleaning caches..."
rm -rf .pytest_cache/
rm -rf .ruff_cache/
rm -rf **/__pycache__/
rm -rf **/*.pyc
@echo "✓ Cleanup complete"
# =============================================================================
# Docker Commands
# =============================================================================
# Build Docker container
docker-build:
@echo "Building ExtensionScanner Docker container..."
docker compose build
@echo "✓ Docker build complete"
# Start container in foreground
docker-up:
@echo "Starting ExtensionScanner container..."
@echo "Access at: http://localhost:8007"
docker compose up
# Start container in background
docker-up-d:
@echo "Starting ExtensionScanner container in background..."
docker compose up -d
@echo "✓ Container started. Access at: http://localhost:8007"
# Stop container
docker-down:
@echo "Stopping ExtensionScanner container..."
docker compose down
@echo "✓ Container stopped"
# View container logs
docker-logs:
docker compose logs -f
# =============================================================================
# Deployment Commands
# =============================================================================
# Deploy to Railway (requires Railway CLI and RAILWAY_TOKEN)
deploy:
@echo "Deploying to Railway..."
@command -v railway >/dev/null 2>&1 || { echo "Installing Railway CLI..."; npm install -g @railway/cli; }
railway up
@echo "✓ Deployment complete"
# Link to existing Railway project
deploy-link:
@echo "Linking to Railway project..."
railway login
railway link
@echo "✓ Project linked"
# View production logs
deploy-logs:
railway logs -f
# Check production status
deploy-status:
railway status