1
+ SHELL := /bin/bash
2
+
3
+ # -----------------------------------------------------------------------------
4
+ # Display Formatting and Colors
5
+ # -----------------------------------------------------------------------------
6
+ BLUE := $(shell printf "\033[1;34m")
7
+ GREEN := $(shell printf "\033[1;32m")
8
+ RED := $(shell printf "\033[1;31m")
9
+ YELLOW := $(shell printf "\033[1;33m")
10
+ NC := $(shell printf "\033[0m")
11
+ INFO := $(shell printf "$(BLUE ) ℹ$(NC ) ")
12
+ OK := $(shell printf "$(GREEN ) ✓$(NC ) ")
13
+ WARN := $(shell printf "$(YELLOW ) ⚠$(NC ) ")
14
+ ERROR := $(shell printf "$(RED ) ✖$(NC ) ")
15
+
16
+ # =============================================================================
17
+ # Configuration and Environment Variables
18
+ # =============================================================================
1
19
.DEFAULT_GOAL: =help
2
20
.ONESHELL :
3
- VENV_EXISTS =$(shell python3 -c "if __import__('pathlib') .Path('.venv/bin/activate').exists(): print('yes')")
4
- VERSION := $(shell grep -m 1 current_version .bumpversion.cfg | tr -s ' ' | tr -d '"' | tr -d "'" | cut -d' ' -f3)
5
- BUILD_DIR =dist
6
- COLLECTOR_PACKAGE =sql-scripts
7
- BASE_DIR =$(shell pwd)
8
-
21
+ .EXPORT_ALL_VARIABLES :
22
+ MAKEFLAGS += --no-print-directory
23
+
24
+ USING_NPM = $(shell python3 -c "if __import__('pathlib') .Path('package-lock.json').exists(): print('yes')")
25
+ ENV_PREFIX =.venv/bin/
26
+ VENV_EXISTS = $(shell python3 -c "if __import__('pathlib') .Path('.venv/bin/activate').exists(): print('yes')")
27
+ NODE_MODULES_EXISTS = $(shell python3 -c "if __import__('pathlib') .Path('node_modules').exists(): print('yes')")
28
+ BUILD_DIR =dist
29
+ COLLECTOR_PACKAGE =sql-scripts
30
+ BASE_DIR =$(shell pwd)
31
+
9
32
.EXPORT_ALL_VARIABLES :
10
33
11
34
ifndef VERBOSE
@@ -15,15 +38,46 @@ endif
15
38
REPO_INFO ?= $(shell git config --get remote.origin.url)
16
39
COMMIT_SHA ?= git-$(shell git rev-parse --short HEAD)
17
40
41
+ # =============================================================================
42
+ # Help and Documentation
43
+ # =============================================================================
44
+
18
45
help : # # Display this help
19
46
@awk ' BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z0-9_-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST )
20
47
21
- .PHONY : install
48
+ # =============================================================================
49
+ # Developer Utils
50
+ # =============================================================================
51
+ install-pipx : # # Install pipx
52
+ @python3 -m pip install --upgrade --user pipx
53
+
54
+ install-hatch : # # Install Hatch, UV, and Ruff
55
+ @sh ./tools/install-hatch.sh
56
+
57
+ configure-hatch : # # Configure Hatch defaults
58
+ @hatch config set dirs.env.virtual .direnv
59
+ @hatch config set dirs.env.pip-compile .direnv
60
+
61
+ upgrade-hatch : # # Update Hatch, UV, and Ruff
62
+ @hatch self update
63
+
22
64
install : # # Install the project in dev mode.
23
- @if [ " $( VENV_EXISTS) " ]; then source .venv/bin/activate; fi
24
- @if [ ! " $( VENV_EXISTS) " ]; then python3 -m venv .venv && source .venv/bin/activate; fi
25
- .venv/bin/pip install -U wheel setuptools cython pip mypy sqlfluff && .venv/bin/pip install -U -r requirements.txt -r requirements-docs.txt
26
- @echo " => Build environment installed successfully. ** If you want to re-install or update, 'make install'"
65
+ @if [ " $( VENV_EXISTS) " ]; then echo " => Removing existing virtual environment" ; $(MAKE ) destroy-venv; fi
66
+ @$(MAKE ) clean
67
+ @if ! hatch --version > /dev/null; then echo ' => Installing `hatch`' ; $(MAKE ) install-hatch ; fi
68
+ @echo " => Creating Python environments..."
69
+ @$(MAKE ) configure-hatch
70
+ @hatch env create local
71
+ @echo " => Install complete! Note: If you want to re-install re-run 'make install'"
72
+ # .venv/bin/pip install -U wheel setuptools cython pip mypy sqlfluff && .venv/bin/pip install -U -r requirements.txt -r requirements-docs.txt
73
+
74
+ .PHONY : upgrade
75
+ upgrade : # # Upgrade all dependencies to the latest stable versions
76
+ @echo " => Updating all dependencies"
77
+ @echo " => Python Dependencies Updated"
78
+ @hatch run lint:pre-commit autoupdate
79
+ @echo " => Updated Pre-commit"
80
+ @$(MAKE ) install
27
81
28
82
.PHONY : clean
29
83
clean : # # Cleanup temporary build artifacts
@@ -38,6 +92,21 @@ clean: ## Cleanup temporary build a
38
92
@find . -name ' .ipynb_checkpoints' -exec rm -rf {} + > /dev/null 2>&1
39
93
@echo " ${OK} Working directory cleaned"
40
94
95
+ deep-clean : clean destroy-venv destroy-node_modules # # Clean everything up
96
+ @hatch python remove all
97
+ @echo " => Hatch environments pruned and python installations trimmed"
98
+ @uv cache clean
99
+ @echo " => UV Cache cleaned successfully"
100
+
101
+ destroy-venv : # # Destroy the virtual environment
102
+ @hatch env prune
103
+ @hatch env remove lint
104
+ @rm -Rf .venv
105
+ @rm -Rf .direnv
106
+
107
+ destroy-node_modules : # # Destroy the node environment
108
+ @rm -rf node_modules .astro
109
+
41
110
.PHONY : clean-sqlscripts
42
111
clean-sqlscripts :
43
112
@echo " => Cleaning previous build artifacts for sql scripts..."
@@ -94,6 +163,14 @@ package-sqlscripts:
94
163
.PHONY : build
95
164
build : build-sqlscripts # # Build and package the collectors
96
165
166
+ .PHONY : pre-release
167
+ pre-release : # # bump the version and create the release tag
168
+ make docs
169
+ make clean
170
+ hatch run local:bump2version $(increment )
171
+ head .bumpversion.cfg | grep ^current_version
172
+ make build
173
+
97
174
98
175
# ##############
99
176
# docs #
@@ -123,10 +200,4 @@ docs: ## generate HTML documentation and serve it to the browser
123
200
./.venv/bin/mkdocs build
124
201
./.venv/bin/mkdocs serve
125
202
126
- .PHONY : pre-release
127
- pre-release : # # bump the version and create the release tag
128
- make gen-docs
129
- make clean
130
- .venv/bin/bump2version $(increment )
131
- head .bumpversion.cfg | grep ^current_version
132
- make build
203
+
0 commit comments