-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
207 lines (179 loc) · 6.93 KB
/
Copy pathMakefile
File metadata and controls
207 lines (179 loc) · 6.93 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
.PHONY: help install sync dev test lint format clean web-install web-dev web-build build-nu build-nudle build-all
# =============================================================================
# Configuration
# =============================================================================
BLUE := \033[0;34m
GREEN := \033[0;32m
YELLOW := \033[1;33m
NC := \033[0m
CORE := src
EXT_DIRS := ext/nu-virtuals ext/nu-dict ext/nu-datetime ext/nu-fin ext/nu-math ext/nu-path ext/nu-uuid ext/nu-shape-lens ext/nu-tree-view
ALL_SRC := $(CORE) $(addsuffix /src,$(EXT_DIRS))
UI_ROOT := src/nu/ui/web
NUDLE_APP := src/nu/ui/web/nudle
# =============================================================================
# Help
# =============================================================================
help:
@echo "$(BLUE)nu monorepo$(NC)"
@echo ""
@echo "$(GREEN)Setup:$(NC)"
@echo " make install Install uv if needed"
@echo " make sync Sync workspace (install all packages)"
@echo " make dev Full dev setup (sync + pre-commit)"
@echo ""
@echo "$(GREEN)Development:$(NC)"
@echo " make test Run all tests"
@echo " make test-pkg PKG=x Run tests for specific package (e.g., PKG=ext/eb-virtuals)"
@echo " make test-core Run core tests"
@echo " make test-ext Run extension tests"
@echo " make test-cov Run tests with coverage"
@echo " make test-fast Run tests (fail fast, no slow)"
@echo ""
@echo "$(GREEN)Code Quality:$(NC)"
@echo " make lint Check code with ruff"
@echo " make format Format code with ruff"
@echo " make check Run format-check + lint"
@echo ""
@echo "$(GREEN)Packages:$(NC)"
@echo " make list List workspace packages"
@echo " make build PKG=x Build specific package"
@echo " make build-nu Build the nu wheel"
@echo " make build-nudle Build the nudle web-bundle wheel"
@echo " make build-all Build both wheels"
@echo ""
@echo "$(GREEN)nudle web:$(NC)"
@echo " make web-install npm install across the ui workspace (core, kit, nudle)"
@echo " make web-dev Run vite dev server (HMR, ws proxy to :8080)"
@echo " make web-build Build the vite bundle into $(NUDLE_APP)/dist"
@echo ""
@echo "$(GREEN)Cleanup:$(NC)"
@echo " make clean Remove build artifacts"
@echo " make clean-all Remove everything including .venv"
# =============================================================================
# Setup
# =============================================================================
install:
@command -v uv >/dev/null 2>&1 || { \
echo "$(BLUE)Installing uv...$(NC)"; \
curl -LsSf https://astral.sh/uv/install.sh | sh; \
}
@echo "$(GREEN)uv ready$(NC)"
sync: install
@echo "$(BLUE)Syncing workspace...$(NC)"
uv sync --all-extras
@echo "$(GREEN)Workspace synced$(NC)"
dev: sync
@echo "$(BLUE)Installing pre-commit hooks...$(NC)"
uv run pre-commit install
@echo "$(GREEN)Dev environment ready$(NC)"
# =============================================================================
# Testing
# =============================================================================
test:
@echo "$(BLUE)Running all tests...$(NC)"
uv run pytest
test-pkg:
ifndef PKG
$(error PKG not set. Usage: make test-pkg PKG=ext/eb-virtuals)
endif
@echo "$(BLUE)Testing $(PKG)...$(NC)"
uv run pytest $(PKG)/tests -v
test-core:
@echo "$(BLUE)Running core tests...$(NC)"
uv run pytest tests/ -q
test-ext:
@echo "$(BLUE)Running extension tests...$(NC)"
@for dir in $(EXT_DIRS); do \
if [ -d "$$dir/tests" ]; then \
echo "$(YELLOW) $$dir$(NC)"; \
uv run pytest $$dir/tests -q || exit 1; \
fi; \
done
test-cov:
@echo "$(BLUE)Running tests with coverage...$(NC)"
uv run pytest --cov --cov-report=html --cov-report=term-missing
@echo "$(GREEN)Report: reports/coverage/index.html$(NC)"
test-fast:
@echo "$(BLUE)Running fast tests...$(NC)"
uv run pytest -m "not slow" -x
# =============================================================================
# Code Quality
# =============================================================================
lint:
@echo "$(BLUE)Linting...$(NC)"
uv run ruff check .
format:
@echo "$(BLUE)Formatting...$(NC)"
uv run ruff format .
uv run ruff check --fix .
@echo "$(GREEN)Done$(NC)"
format-check:
@echo "$(BLUE)Checking format...$(NC)"
uv run ruff format --check .
check: format-check lint
@echo "$(GREEN)All checks passed$(NC)"
# =============================================================================
# Packages
# =============================================================================
list:
@echo "$(BLUE)Workspace packages:$(NC)"
@echo ""
@echo "$(GREEN)Core (src/nu/):$(NC)"
@ls -d src/nu/*/ 2>/dev/null | sed 's|/$$||' | sed 's|^| |' || echo " (none)"
@echo ""
@echo "$(GREEN)Extensions (ext/):$(NC)"
@ls -d ext/*/ 2>/dev/null | sed 's|/$$||' | sed 's|^| |' || echo " (none)"
build:
ifndef PKG
$(error PKG not set. Usage: make build PKG=nu)
endif
@echo "$(BLUE)Building $(PKG)...$(NC)"
cd $(PKG) && uv build
@echo "$(GREEN)Built: $(PKG)/dist/$(NC)"
# =============================================================================
# nudle web + nu wheel
# =============================================================================
web-install:
@echo "$(BLUE)Installing ui workspace deps (core, kit, nudle)...$(NC)"
cd $(UI_ROOT) && npm install
@echo "$(GREEN)Installed$(NC)"
web-dev:
@echo "$(BLUE)Starting vite dev server...$(NC)"
cd $(NUDLE_APP) && npm run dev
web-build:
@echo "$(BLUE)Building nudle web bundle...$(NC)"
cd $(NUDLE_APP) && npm run build
@echo "$(GREEN)Built: $(NUDLE_APP)/dist/$(NC)"
build-nu:
@echo "$(BLUE)Building nu wheel...$(NC)"
uv build --wheel
@echo "$(GREEN)Built: dist/$(NC)"
build-nudle: web-build
@echo "$(BLUE)Building nudle web-bundle wheel...$(NC)"
cd $(NUDLE_APP) && uv build --wheel
@echo "$(GREEN)Built: $(NUDLE_APP)/dist/$(NC)"
build-all: build-nu build-nudle
@echo "$(GREEN)Both wheels built$(NC)"
# =============================================================================
# Cleanup
# =============================================================================
clean:
@echo "$(BLUE)Cleaning...$(NC)"
find . -type d -name "__pycache__" -exec rm -rf {} + 2>/dev/null || true
find . -type d -name "*.egg-info" -exec rm -rf {} + 2>/dev/null || true
find . -type d -name ".pytest_cache" -exec rm -rf {} + 2>/dev/null || true
find . -type d -name ".ruff_cache" -exec rm -rf {} + 2>/dev/null || true
find . -type d -name "dist" -exec rm -rf {} + 2>/dev/null || true
find . -type d -name "build" -exec rm -rf {} + 2>/dev/null || true
rm -rf .coverage htmlcov/ reports/
@echo "$(GREEN)Clean$(NC)"
clean-all: clean
@echo "$(BLUE)Removing .venv...$(NC)"
rm -rf .venv/
@echo "$(GREEN)Deep clean$(NC)"
# =============================================================================
# CI
# =============================================================================
ci: check test-cov
@echo "$(GREEN)CI passed$(NC)"