-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
executable file
·751 lines (585 loc) · 23 KB
/
Makefile
File metadata and controls
executable file
·751 lines (585 loc) · 23 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
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
# DoMD Project Makefile
# Development, build, and Docker automation
# ==============================================================================
# Configuration
# ==============================================================================
# Project information
PROJECT_NAME := domd
VERSION := $(shell cat VERSION 2>/dev/null || echo "0.1.0")
# Directories
SCRIPT_DIR := scripts
FRONTEND_DIR := frontend
# Docker settings
IMAGE_NAME ?= $(PROJECT_NAME)
IMAGE_TAG ?= latest
DOCKER_COMPOSE_FILE ?= docker-compose.yml
DOCKER_RUN_OPTS ?= --rm -it
DOCKER_WORKDIR ?= /app
DOCKER_USER ?= $(shell id -u):$(shell id -g)
DOCKER_NETWORK ?= $(PROJECT_NAME)-network
COMPOSE_PROJECT_NAME ?= $(PROJECT_NAME)
# Frontend settings
NODE_ENV ?= development
NPM = npm --prefix $(FRONTEND_DIR)
NPM_RUN = $(NPM) run
NPM_CI = $(NPM) ci
NPM_INSTALL = $(NPM) install
NPM_BUILD = $(NPM_RUN) build
NPM_START = $(NPM_RUN) start
NPM_TEST = $(NPM_RUN) test
NPM_LINT = $(NPM_RUN) lint
NPM_FORMAT = $(NPM_RUN) format
# Backend settings
PYTHON = python
PIP = pip
POETRY = poetry
PYTEST = $(POETRY) run pytest
UVICORN = $(POETRY) run uvicorn
PORT ?= 5000
# ==============================================================================
# Help
# ==============================================================================
.PHONY: help
help: ## Show this help message
@echo "$(PROJECT_NAME) - Project Command Detector"
@echo "=========================================="
@echo "Available commands:"
@echo ""
@echo "Installation:"
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## .*$$/ && $$0 ~ /install/ {printf " \033[36m%-25s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
@echo ""
@echo "Development:"
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## .*$$/ && $$0 ~ /(start|stop|test|lint|format|run)/ {printf " \033[36m%-25s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
@echo ""
@echo "Frontend:"
@awk 'BEGIN {FS = ":.*?## "} /^frontend-[-a-z]+:.*?## .*$$/ {printf " \033[36m%-25s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
@echo ""
@echo "Docker:"
@awk 'BEGIN {FS = ":.*?## "} /^docker-[-a-z]+:.*?## .*$$/ {printf " \033[36m%-25s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
@echo ""
@echo "Documentation:"
@awk 'BEGIN {FS = ":.*?## "} /^docs-[-a-z]+:.*?## .*$$/ {printf " \033[36m%-25s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
# ==============================================================================
# Installation
# ==============================================================================
.PHONY: install install-backend install-frontend update-deps
install: install-backend install-frontend ## Install all dependencies
install-backend: ## Install Python dependencies
@echo "Installing Python dependencies..."
$(POETRY) install
install-frontend: ## Install Node.js dependencies
@echo "Installing frontend dependencies..."
$(NPM_CI)
update-deps: update-backend-deps update-frontend-deps ## Update all dependencies
update-backend-deps: ## Update Python dependencies
@echo "Updating Python dependencies..."
$(POETRY) update
update-frontend-deps: ## Update frontend dependencies
@echo "Updating frontend dependencies..."
$(NPM_UPDATE)
$(NPM_DEDUPE)
# ==============================================================================
# Development
# ==============================================================================
.PHONY: start start-backend start-frontend stop test lint format clean
start: start-backend start-frontend ## Start all services
start-backend: ## Start the backend server
@echo "Starting backend server..."
@$(SCRIPT_DIR)/start.sh
start-frontend: ## Start the frontend development server
@echo "Starting frontend development server..."
@$(SCRIPT_DIR)/start_frontend.sh
stop: ## Stop all services
@echo "Stopping all services..."
@$(SCRIPT_DIR)/stop.sh
test: ## Run all tests
@echo "Running tests..."
@$(SCRIPT_DIR)/test_api.sh
lint: lint-backend lint-frontend ## Lint all code
lint-backend: ## Lint backend code
@echo "Linting backend code..."
$(POETRY) run black --check .
$(POETRY) run isort --check-only .
$(POETRY) run flake8 .
lint-frontend: ## Lint frontend code
@$(SCRIPT_DIR)/lint_frontend.sh
format: format-backend format-frontend ## Format all code
format-backend: ## Format backend code
@echo "Formatting backend code..."
$(POETRY) run black .
$(POETRY) run isort .
format-frontend: ## Format frontend code
@$(SCRIPT_DIR)/format_frontend.sh
clean: clean-backend clean-frontend ## Clean all build artifacts
clean-backend: ## Clean backend artifacts
@$(SCRIPT_DIR)/clean_backend.sh
clean-frontend: ## Clean frontend build artifacts
@$(SCRIPT_DIR)/clean_frontend.sh
# ==============================================================================
# Docker
# ==============================================================================
.PHONY: docker-build docker-run docker-stop docker-clean docker-logs
docker-build: ## Build Docker image
docker build -t $(IMAGE_NAME):$(IMAGE_TAG) .
docker-run: ## Run Docker container
docker run -d \
--name $(PROJECT_NAME) \
-p 5000:5000 \
-v $(PWD):/app \
$(IMAGE_NAME):$(IMAGE_TAG)
docker-stop: ## Stop Docker container
@docker stop $(PROJECT_NAME) 2>/dev/null || echo "No running container found"
@docker rm $(PROJECT_NAME) 2>/dev/null || echo "No container to remove"
docker-clean: docker-stop ## Clean Docker artifacts
@docker rmi $(IMAGE_NAME):$(IMAGE_TAG) 2>/dev/null || echo "No image to remove"
docker-logs: ## View Docker container logs
@docker logs -f $(PROJECT_NAME) 2>/dev/null || echo "No container logs found"
# ==============================================================================
# Documentation
# ==============================================================================
.PHONY: docs-build docs-serve
docs-build: ## Build documentation
@echo "Building documentation..."
@# Add documentation build commands here
docs-serve: ## Serve documentation locally
@echo "Serving documentation..."
@# Add documentation serve commands here
# ==============================================================================
# Utility
# ==============================================================================
.PHONY: check-env check-docker check-docker-compose
check-env:
@if [ ! -f ".env" ]; then \
echo "Warning: .env file not found. Creating from .env.example..."; \
cp -n .env.example .env || true; \
fi
check-docker: ## Check if Docker is installed and running
@$(SCRIPT_DIR)/check_docker.sh
check-docker-compose: check-docker ## Check if Docker Compose is installed
# Default target
help: ## Show this help message
@echo "DoMD - Project Command Detector"
@echo "================================="
@echo "Available commands:"
@echo "\nInstallation:"
@awk 'BEGIN {FS = \":.*?## \"} /^[a-zA-Z_-]+:.*?## .*$$/ && $$0 ~ /install/ {printf " \033[36m%-25s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
@echo "\nDevelopment:"
@awk 'BEGIN {FS = \":.*?## \"} /^[a-zA-Z_-]+:.*?## .*$$/ && $$0 ~ /(test|lint|format|mypy|run)/ {printf " \033[36m%-25s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
@echo "\nFrontend:"
@awk 'BEGIN {FS = \":.*?## \"} /^frontend-[-a-z]+:.*?## .*$$/ {printf " \033[36m%-25s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
@echo "\nDocker:"
@awk 'BEGIN {FS = \":.*?## \"} /^[a-zA-Z_-]+:.*?## .*$$/ && $$0 ~ /docker/ {printf " \033[36m%-25s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
@echo "\nDocumentation:"
@awk 'BEGIN {FS = \":.*?## \"} /^[a-zA-Z_-]+:.*?## .*$$/ && $$0 ~ /(docs|serve)/ {printf " \033[36m%-25s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
@echo "\nBuild & Publish:"
@awk 'BEGIN {FS = \":.*?## \"} /^[a-zA-Z_-]+:.*?## .*$$/ && ($$0 ~ /(build|publish|clean)/) && !($$0 ~ /(docker|frontend)/) {printf " \033[36m%-25s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
# Installation targets
# Development Commands
install: install-backend install-frontend ## Install all dependencies
install-backend: ## Install Python dependencies
@echo "Installing Python dependencies..."
$(POETRY) install
install-frontend: ## Install Node.js dependencies
@echo "Installing frontend dependencies..."
$(NPM_CI)
update-deps: update-backend-deps update-frontend-deps ## Update all dependencies
update-backend-deps: ## Update Python dependencies
@echo "Updating Python dependencies..."
$(POETRY) update
update-frontend-deps: ## Update frontend dependencies
@echo "Updating frontend dependencies..."
$(NPM_UPDATE)
$(NPM_DEDUPE)
# Backend targets
run-backend: ## Start the backend development server
@echo "Starting backend development server..."
$(UVICORN) domd.main:app --reload --port $(PORT)
run-backend-prod: ## Start the backend production server
@echo "Starting backend production server..."
$(UVICORN) domd.main:app --host 0.0.0.0 --port $(PORT)
run-backend-worker: ## Start the background worker
@echo "Starting background worker..."
$(POETRY) run python -m domd.worker
test-backend: ## Run backend tests
@echo "Running backend tests..."
$(PYTEST)
lint-backend: ## Lint backend code
@echo "Linting backend code..."
$(POETRY) run black --check .
$(POETRY) run isort --check-only .
$(POETRY) run flake8 .
format-backend: ## Format backend code
@echo "Formatting backend code..."
$(POETRY) run black .
$(POETRY) run isort .
# Frontend targets
frontend-install: ## Install frontend dependencies
@echo "Installing frontend dependencies..."
$(NPM_CI)
frontend-update: ## Update frontend dependencies
@echo "Updating frontend dependencies..."
$(NPM_UPDATE)
$(NPM_DEDUPE)
frontend-start: ## Start frontend development server
@echo "Starting frontend development server..."
NODE_ENV=$(NODE_ENV) $(NPM_START)
frontend-build: ## Build frontend for production
@echo "Building frontend for production..."
NODE_ENV=production $(NPM_BUILD)
frontend-test: ## Run frontend tests
@echo "Running frontend tests..."
$(NPM_TEST)
frontend-lint: ## Lint frontend code
@echo "Linting frontend code..."
$(NPM_LINT)
frontend-format: ## Format frontend code
@echo "Formatting frontend code..."
$(NPM_FORMAT)
frontend-audit: ## Check for vulnerable frontend dependencies
@echo "Auditing frontend dependencies..."
$(NPM_AUDIT)
frontend-outdated: ## Check for outdated frontend dependencies
@echo "Checking for outdated frontend dependencies..."
$(NPM_OUTDATED)
frontend-clean: ## Clean frontend build artifacts
@echo "Cleaning frontend build artifacts..."
rm -rf $(FRONTEND_DIR)/build
# Combined development commands
dev: ## Start both frontend and backend in development mode
@echo "Starting development environment..."
@echo "Backend: http://localhost:$(PORT)"
@echo "Frontend: http://localhost:3000"
@echo ""
@echo "Press Ctrl+C to stop all processes"
@echo ""
@echo "Starting backend and frontend..."
@$(MAKE) -j 2 run-backend frontend-start
# Database commands
db-shell: ## Open a database shell
@echo "Opening database shell..."
$(POETRY) run python -m domd.db shell
db-migrate: ## Run database migrations
@echo "Running database migrations..."
$(POETRY) run alembic upgrade head
db-reset: ## Reset the database (WARNING: This will delete all data!)
@$(SCRIPT_DIR)/reset_db.sh
# Installation targets
install: frontend-install ## Install the package and frontend dependencies
poetry install
dev-install: ## Install with development dependencies
poetry install --with dev,docs,testing,lint
poetry run pre-commit install
install-all: ## Install with all optional dependencies
poetry install --with dev,docs,testing,lint --extras "all"
install-api: ## Install with REST API dependencies
poetry install --extras "api"
# Testing targets
test: ## Run all tests
@echo "Running all tests..."
poetry run pytest
# Unit and integration tests
test-unit: ## Run unit tests only
@echo "Running unit tests..."
poetry run pytest -m "unit"
test-integration: ## Run integration tests only
@echo "Running integration tests..."
poetry run pytest -m "integration"
test-api: ## Run API tests only
@echo "Running API tests..."
poetry run pytest tests/test_api_*.py -v
# Ansible test targets
test-ansible: ## Run all Ansible-related tests
@echo "Running all Ansible tests..."
poetry run pytest tests/test_ansible_*.py -v
ansible-lint: ## Run ansible-lint on playbooks and roles
@echo "Running ansible-lint..."
if ! command -v ansible-lint >/dev/null; then \
echo "Installing ansible-lint..."; \
pip install --user ansible-lint; \
fi
ansible-lint -x role-name ansible/
ansible-check: ## Check Ansible playbook syntax
@echo "Checking Ansible playbook syntax..."
ansible-playbook ansible/site.yml --syntax-check -i ansible/inventory/production
ansible-dry-run: ## Run Ansible playbook in check mode (dry run)
@echo "Running Ansible in check mode..."
ansible-playbook ansible/site.yml --check --diff -i ansible/inventory/production
ansible-install: ## Install Ansible Galaxy requirements
@echo "Installing Ansible Galaxy requirements..."
ansible-galaxy install -r ansible/requirements.yml
test-ansible-unit: ## Run Ansible unit tests only
@echo "Running Ansible unit tests..."
poetry run pytest tests/test_ansible_*.py -m "unit" -v
test-ansible-integration: ## Run Ansible integration tests
@echo "Running Ansible integration tests..."
ANSIBLE_CONFIG=ansible/ansible.cfg poetry run pytest tests/test_ansible_*.py -m "integration" -v
# Specific Ansible component tests
test-playbooks: ## Test Ansible playbook functionality
@echo "Testing Ansible playbooks..."
ANSIBLE_CONFIG=ansible/ansible.cfg poetry run pytest tests/test_ansible_playbook.py -v
test-roles: ## Test Ansible role functionality
@echo "Testing Ansible roles..."
ANSIBLE_CONFIG=ansible/ansible.cfg poetry run pytest tests/test_ansible_roles.py -v
test-galaxy: ## Test Ansible Galaxy integration
@echo "Testing Ansible Galaxy..."
ANSIBLE_CONFIG=ansible/ansible.cfg poetry run pytest tests/test_ansible_galaxy.py -v
test-vault: ## Test Ansible Vault operations
@echo "Testing Ansible Vault..."
ANSIBLE_CONFIG=ansible/ansible.cfg poetry run pytest tests/test_ansible_vault.py -v
test-inventory: ## Test Ansible inventory handling
@echo "Testing Ansible inventory..."
ANSIBLE_CONFIG=ansible/ansible.cfg poetry run pytest tests/test_ansible_inventory.py -v
# Test coverage
coverage: ## Generate test coverage report
@echo "Generating test coverage report..."
poetry run pytest --cov=domd --cov-report=term-missing --cov-report=html
# Linting and code quality
lint: ## Run all linting and code quality checks
@echo "Running linting and code quality checks..."
poetry run black --check src/ tests/
poetry run isort --check-only src/ tests/
poetry run flake8 src/ tests/
poetry run mypy src/
format: ## Format code with black and isort
@echo "Formatting code..."
poetry run black src/ tests/
poetry run isort src/ tests/
format-check: ## Check if code is properly formatted
@echo "Checking code formatting..."
poetry run black --check src/ tests/
poetry run isort --check-only src/ tests/
test-cov: ## Run tests with coverage report
@echo "Running tests with coverage..."
poetry run pytest --cov=domd --cov-report=html --cov-report=term
test-verbose: ## Run tests with verbose output
@echo "Running tests with verbose output..."
poetry run pytest -v
mypy: ## Run type checking
@echo "Running type checking with mypy..."
poetry run mypy src/
flake8: ## Run flake8 linter
@echo "Running flake8 linting..."
poetry run flake8 src/ tests/
pylint: ## Run pylint
@echo "Running pylint..."
poetry run pylint src/domd/
# Documentation targets
docs: ## Build documentation
poetry run mkdocs build
serve-docs: ## Serve documentation locally
poetry run mkdocs serve
# API targets
run-api: ## Run the REST API server
poetry run domd-api
run-api-debug: ## Run the REST API server in debug mode
poetry run domd-api --debug
run-api-port: ## Run the REST API server on a specific port
@read -p "Enter port number (default: 5000): " port; \
poetry run domd-api --port $${port:-5000}
docs-clean: ## Clean documentation build
rm -rf site/
# Docker targets
docker-build: ## Build Docker image with current user permissions
@echo "Building Docker image ${IMAGE_NAME}:${IMAGE_TAG}..."
docker build \
--build-arg USER_ID=$(shell id -u) \
--build-arg GROUP_ID=$(shell id -g) \
-t ${IMAGE_NAME}:${IMAGE_TAG} .
docker-run: ## Run Docker container with current directory mounted
@echo "Running Docker container from ${IMAGE_NAME}:${IMAGE_TAG}..."
docker run ${DOCKER_RUN_OPTS} \
-v $(CURDIR):${DOCKER_WORKDIR} \
-w ${DOCKER_WORKDIR} \
${IMAGE_NAME}:${IMAGE_TAG} ${DOCKER_RUN_CMD}
docker-shell: ## Start an interactive shell in the container
@echo "Starting shell in ${IMAGE_NAME}:${IMAGE_TAG}..."
docker run ${DOCKER_RUN_OPTS} \
-v $(CURDIR):${DOCKER_WORKDIR} \
-w ${DOCKER_WORKDIR} \
--entrypoint /bin/bash \
${IMAGE_NAME}:${IMAGE_TAG}
docker-setup: ## Set up development environment in container
@echo "Setting up development environment in ${IMAGE_NAME}:${IMAGE_TAG}..."
docker run ${DOCKER_RUN_OPTS} \
-v $(CURDIR):${DOCKER_WORKDIR} \
-w ${DOCKER_WORKDIR} \
${IMAGE_NAME}:${IMAGE_TAG} \
poetry install --with dev,test,lint,docs
docker-prune: ## Clean up unused Docker resources
@echo "Pruning Docker resources..."
docker system prune -f
docker-ls: ## List all containers and images
@echo "=== Running Containers ==="
docker ps -a
@echo "\n=== Available Images ==="
docker images
docker-cp: ## Copy files between host and container
@echo "Usage: make DOCKER_CONTAINER=container_id SRC=/path/to/src DEST=/path/to/dest docker-cp"
docker-test: ## Run tests inside Docker container
@echo "Running tests in Docker container..."
docker run ${DOCKER_RUN_FLAGS} ${IMAGE_NAME}:${IMAGE_TAG} make test
docker-push: ## Push Docker image to registry
@echo "Pushing ${IMAGE_NAME}:${IMAGE_TAG} to registry..."
docker push ${IMAGE_NAME}:${IMAGE_TAG}
docker-clean: ## Remove Docker containers and images
@echo "Removing containers..."
docker ps -aq --filter "name=domd" | xargs -r docker rm -f 2>/dev/null || true
@echo "Removing images..."
docker images -q ${IMAGE_NAME} | xargs -r docker rmi -f 2>/dev/null || true
docker-logs: ## View container logs
docker-compose -f ${DOCKER_COMPOSE_FILE} logs -f
docker-restart: ## Restart containers
docker-compose -f ${DOCKER_COMPOSE_FILE} restart
docker-compose-up: ## Start containers using docker-compose
docker-compose -f ${DOCKER_COMPOSE_FILE} up -d
docker-compose-down: ## Stop and remove containers
docker-compose -f ${DOCKER_COMPOSE_FILE} down
# Build and publish targets
clean: frontend-clean ## Remove build artifacts
@echo "Cleaning build artifacts..."
rm -rf build/ dist/ *.egg-info/ .pytest_cache/ .mypy_cache/ .coverage htmlcov/
find src tests -type d -name '__pycache__' -exec rm -rf {} +
find . -type f -name '*.pyc' -delete
find . -type f -name '*.pyo' -delete
find . -type d -name '.mypy_cache' -exec rm -rf {} +
find . -type f -name '*.py[co]' -delete
find . -path './.venv' -prune -o -type f -name '*.py[co]' -delete 2>/dev/null || true
find . -path './.venv' -prune -o -type d -name '*.egg-info' -exec rm -rf {} + 2>/dev/null || true
@echo "Clean complete."
frontend-clean: ## Clean frontend build artifacts
rm -rf frontend/dist/
rm -rf frontend/node_modules/
# Combined targets
dev: dev-install pre-commit ## Set up development environment
@echo "Development environment ready!"
pre-commit: ## Install pre-commit hooks
poetry run pre-commit install
# Utility targets
version: ## Show current version
@poetry version
update: ## Update dependencies
poetry update
upgrade: update ## Alias for update
# Build and Publish targets
build: clean ## Build the package with Poetry
@echo "Building package..."
poetry version patch
poetry build
publish-test: clean ## Publish to test PyPI
@echo "Publishing to test PyPI..."
poetry version patch
poetry config repositories.testpypi https://test.pypi.org/legacy/
poetry build -v
twine upload --repository testpypi dist/*
publish: clean ## Publish to PyPI
@echo "Publishing to PyPI..."
poetry version patch
poetry build -v
twine upload dist/*
clean: ## Clean build artifacts
@echo "Cleaning build artifacts..."
rm -rf dist/ build/ *.egg-info/
find . -type d -name "__pycache__" -exec rm -rf {} +
find . -type f -name "*.py[co]" -delete
# Development targets
run: ## Run domd on current directory
poetry run domd
run-dry: ## Run domd in dry-run mode
poetry run domd --dry-run --verbose
run-example: ## Run domd on example project
poetry run domd --path examples/ --verbose
# Quality assurance targets
qa: lint test ## Run quality assurance (lint + test)
ci: ## Run CI pipeline locally
$(MAKE) format-check
$(MAKE) lint
$(MAKE) test-cov
$(MAKE) build
pre-commit: ## Run pre-commit hooks on all files
poetry run pre-commit run --all-files
# Utility targets
version: ## Show current version
@poetry version
bump-patch: ## Bump patch version
poetry version patch
bump-minor: ## Bump minor version
poetry version minor
bump-major: ## Bump major version
poetry version major
security: ## Run security checks
poetry run bandit -r src/
poetry run safety check
deps-update: ## Update dependencies
poetry update
deps-show: ## Show dependency tree
poetry show --tree
# Environment targets
env-info: ## Show environment information
@echo "Python version:"
@python --version
@echo "Poetry version:"
@poetry --version
@echo "Project info:"
@poetry show --no-dev
# Health check (dogfooding)
health-check: ## Run domd on itself
poetry run domd --path . --verbose
health-check-dry: ## Preview domd run on itself
poetry run domd --path . --dry-run --verbose
# Example and demo targets
create-examples: ## Create example projects for testing
mkdir -p examples/javascript examples/python examples/docker
echo '{"name": "test", "scripts": {"test": "echo test", "build": "echo build"}}' > examples/javascript/package.json
echo 'test:\n\techo "Testing"' > examples/Makefile
echo 'FROM python:3.9\nRUN echo "Docker test"' > examples/docker/Dockerfile
demo: create-examples ## Run demo on example projects
@echo "Running DoMD demo..."
poetry run domd scan --path examples/ --verbose
# Cleanup targets
clean-all: clean docs-clean ## Clean everything
rm -rf .pytest_cache/
rm -rf .coverage
rm -rf htmlcov/
rm -rf .mypy_cache/
rm -rf examples/
# Git targets
git-clean: ## Clean git repository
git clean -fdx
tag: ## Create git tag with current version
git tag v$(shell poetry version -s)
git push origin v$(shell poetry version -s)
# Database/cache cleanup
clean-cache: ## Clean Python cache files
find . -type d -name __pycache__ -exec rm -rf {} +
find . -type f -name "*.pyc" -delete
find . -type f -name "*.pyo" -delete
# Development workflow shortcuts
dev: dev-install format lint test ## Full development setup and check
quick-test: ## Quick test run (unit tests only)
poetry run pytest tests/ -x -v --tb=short
watch-test: ## Watch files and run tests on changes
poetry run pytest-watch
# Release workflow
release-check: ## Check if ready for release
@echo "Checking release readiness..."
$(MAKE) clean
$(MAKE) format-check
$(MAKE) lint
$(MAKE) test
$(MAKE) build
@echo "✅ Ready for release!"
release-patch: ## Release patch version
$(MAKE) release-check
$(MAKE) bump-patch
$(MAKE) tag
$(MAKE) publish
release-minor: ## Release minor version
$(MAKE) release-check
$(MAKE) bump-minor
$(MAKE) tag
$(MAKE) publish
release-major: ## Release major version
$(MAKE) release-check
$(MAKE) bump-major
$(MAKE) tag
$(MAKE) publish