-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
196 lines (176 loc) · 7.04 KB
/
Copy pathMakefile
File metadata and controls
196 lines (176 loc) · 7.04 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
# Makefile for packaging the Extension and building the docs
YELLOW :=\033[1;33m
RED :=\033[1;31m
GREEN :=\033[1;32m
BLUE :=\033[1;34m
RESET :=\033[0m
.PHONY: all clean install help check package force-install package-clean linter-fix docs docs-clean test tests-clean
all: clean package install ## Clean, then build VSIX package and installs it
clean: package-clean docs-clean ## Remove all generated files (package + docs)
check: ## Linting and type checking
@ts=""; \
ts="$$(date +"%Y-%m-%dT%H:%M:%S%z")"; \
printf "$(YELLOW)\n\nStart Linting and type checking at %s\n\n$(RESET)\n" "$$ts"
@ts=""; \
if npm install && npm run lint && npm run format:check; then \
ts="$$(date +"%Y-%m-%dT%H:%M:%S%z")"; \
printf "$(BLUE)\n\nCheck completed at %s\n\n$(RESET)\n" "$$ts"; \
else \
ts="$$(date +"%Y-%m-%dT%H:%M:%S%z")"; \
printf "$(RED)\n\nError running check. %s\n\n$(RESET)\n" "$$ts"; \
exit 1; \
fi
linter-fix: ## Apply Linter Fixes when possible
@ts=""; \
ts="$$(date +"%Y-%m-%dT%H:%M:%S%z")"; \
printf "$(YELLOW)\n\nStart Linter Fixes at %s\n\n$(RESET)\n" "$$ts"
@ts=""; \
if npm install && npm run lint:fix && npm run format; then \
ts="$$(date +"%Y-%m-%dT%H:%M:%S%z")"; \
printf "$(BLUE)\n\nLinter Fixes completed at %s\n\n$(RESET)\n" "$$ts"; \
else \
ts="$$(date +"%Y-%m-%dT%H:%M:%S%z")"; \
printf "$(RED)\n\nError running Linter Fixes. %s\n\n$(RESET)\n" "$$ts"; \
exit 1; \
fi
test: ## Run unit, integration, and E2E tests
@ts=""; \
ts="$$(date +"%Y-%m-%dT%H:%M:%S%z")"; \
printf "$(YELLOW)\n\nStart Tests at %s\n\n$(RESET)\n" "$$ts"
@ts=""; \
if npm install && npm test; then \
ts="$$(date +"%Y-%m-%dT%H:%M:%S%z")"; \
printf "$(GREEN)\n\nTests completed at %s\n\n$(RESET)\n" "$$ts"; \
else \
ts="$$(date +"%Y-%m-%dT%H:%M:%S%z")"; \
printf "$(RED)\n\nError running tests. %s\n\n$(RESET)\n" "$$ts"; \
exit 1; \
fi
tests-clean: ## Remove generated tests reports
@ts=""; \
if rm -rf .vscode-test; then \
ts="$$(date +"%Y-%m-%dT%H:%M:%S%z")"; \
printf "$(GREEN)\n\nTests-clean completed at %s\n\n$(RESET)\n" "$$ts"; \
else \
ts="$$(date +"%Y-%m-%dT%H:%M:%S%z")"; \
printf "$(RED)\n\nError running Tests-clean. %s\n\n$(RESET)\n" "$$ts"; \
exit 1; \
fi
package: ## Install deps, compile, and create the .vsix package
@ts=""; \
ts="$$(date +"%Y-%m-%dT%H:%M:%S%z")"; \
printf "$(YELLOW)\n\nStart building package at %s\n\n$(RESET)\n" "$$ts"
@ts=""; \
if npm install && npm run compile && npm run package:vsix; then \
ts="$$(date +"%Y-%m-%dT%H:%M:%S%z")"; \
printf "$(GREEN)\n\nPackage completed at %s\n\n$(RESET)\n" "$$ts"; \
else \
ts="$$(date +"%Y-%m-%dT%H:%M:%S%z")"; \
printf "$(RED)\n\nError running package. %s\n\n$(RESET)\n" "$$ts"; \
exit 1; \
fi
package-clean: ## Remove node_modules, build outputs, and generated .vsix
@ts=""; \
if rm -rf node_modules out *.vsix; then \
ts="$$(date +"%Y-%m-%dT%H:%M:%S%z")"; \
printf "$(GREEN)\n\nPackage-clean completed at %s\n\n$(RESET)\n" "$$ts"; \
else \
ts="$$(date +"%Y-%m-%dT%H:%M:%S%z")"; \
printf "$(RED)\n\nError running package-clean. %s\n\n$(RESET)\n" "$$ts"; \
exit 1; \
fi
docs: ## Build documentation (TypeDoc + Sphinx HTML)
@ts=""; \
ts="$$(date +"%Y-%m-%dT%H:%M:%S%z")"; \
printf "$(YELLOW)\n\nStart building docs at %s\n\n$(RESET)\n" "$$ts"
@ts=""; \
py=""; \
sphinx_cmd=""; \
if [ -n "$$VIRTUAL_ENV" ] && [ -x "$$VIRTUAL_ENV/bin/python" ]; then \
py="$$VIRTUAL_ENV/bin/python"; \
elif command -v python3.12 >/dev/null 2>&1; then \
py="$$(command -v python3.12)"; \
elif command -v uv >/dev/null 2>&1; then \
sphinx_cmd="uv run --python 3.12 --with-requirements docs/requirements.txt python -m sphinx"; \
else \
ts="$$(date +"%Y-%m-%dT%H:%M:%S%z")"; \
printf "$(RED)\n\nError building docs: Python 3.12+ is required. Install python3.12 or uv. %s\n\n$(RESET)\n" "$$ts"; \
exit 1; \
fi; \
if [ -n "$$py" ] && ! "$$py" -c 'import sys; raise SystemExit(0 if sys.version_info >= (3, 12) else 1)'; then \
if command -v uv >/dev/null 2>&1; then \
py=""; \
sphinx_cmd="uv run --python 3.12 --with-requirements docs/requirements.txt python -m sphinx"; \
else \
ts="$$(date +"%Y-%m-%dT%H:%M:%S%z")"; \
printf "$(RED)\n\nError building docs: Sphinx 9.1.0 requires Python 3.12+. Using %s (%s). %s\n\n$(RESET)\n" "$$py" "$$($$py --version 2>&1)" "$$ts"; \
exit 1; \
fi; \
fi; \
if [ -n "$$py" ]; then \
sphinx_cmd="$$py -m sphinx"; \
fi; \
if [ -n "$$py" ] && ! "$$py" -m pip install -r docs/requirements.txt; then \
ts="$$(date +"%Y-%m-%dT%H:%M:%S%z")"; \
printf "$(RED)\n\nError building docs: failed to install Python doc dependencies with %s. %s\n\n$(RESET)\n" "$$py" "$$ts"; \
exit 1; \
fi; \
if npm install && npm run lint:docs && eval "$$sphinx_cmd -b html docs/source docs/build/html"; then \
ts="$$(date +"%Y-%m-%dT%H:%M:%S%z")"; \
printf "$(BLUE)\n\nDocs Build finished at %s\n\n$(RESET)\n" "$$ts"; \
else \
ts="$$(date +"%Y-%m-%dT%H:%M:%S%z")"; \
printf "$(RED)\n\nError building docs. %s\n\n$(RESET)\n" "$$ts"; \
exit 1; \
fi
docs-clean: ## Remove generated documentation outputs
@ts=""; \
if rm -rf docs/build docs/typedoc coverage docs/source/__pycache__ docs/source/_generated/*.md docs/source/_generated/*.json; then \
ts="$$(date +"%Y-%m-%dT%H:%M:%S%z")"; \
printf "$(GREEN)\n\nDocs-clean completed at %s\n\n$(RESET)\n" "$$ts"; \
else \
ts="$$(date +"%Y-%m-%dT%H:%M:%S%z")"; \
printf "$(RED)\n\nError running docs-clean. %s\n\n$(RESET)\n" "$$ts"; \
exit 1; \
fi
install: ## Install the first .vsix found in the current directory
@ts=""; \
vsix="$$(find . -maxdepth 1 -type f -name '*.vsix' -print | sort | head -n 1)"; \
if [ -z "$$vsix" ]; then \
ts="$$(date +"%Y-%m-%dT%H:%M:%S%z")"; \
printf "$(RED)\n\nError: no .vsix file found. %s\n\n$(RESET)\n" "$$ts"; \
printf "Run 'make package' first.\n"; \
exit 1; \
fi; \
echo "Installing extension: $$vsix"; \
if code --install-extension "$$vsix"; then \
ts="$$(date +"%Y-%m-%dT%H:%M:%S%z")"; \
printf "$(GREEN)\n\nInstall completed at %s\n\n$(RESET)\n" "$$ts"; \
else \
ts="$$(date +"%Y-%m-%dT%H:%M:%S%z")"; \
printf "$(RED)\n\nError running install. %s\n\n$(RESET)\n" "$$ts"; \
exit 1; \
fi
force-install: ## Force to Install the first .vsix found in the current directory (even if it is downgrading versions)
@ts=""; \
vsix="$$(find . -maxdepth 1 -type f -name '*.vsix' -print | sort | head -n 1)"; \
if [ -z "$$vsix" ]; then \
ts="$$(date +"%Y-%m-%dT%H:%M:%S%z")"; \
printf "$(RED)\n\nError: no .vsix file found. %s\n\n$(RESET)\n" "$$ts"; \
printf "Run 'make package' first.\n"; \
exit 1; \
fi; \
echo "Force Installing extension: $$vsix"; \
if code --install-extension "$$vsix" --force; then \
ts="$$(date +"%Y-%m-%dT%H:%M:%S%z")"; \
printf "$(GREEN)\n\nForce Install completed at %s\n\n$(RESET)\n" "$$ts"; \
else \
ts="$$(date +"%Y-%m-%dT%H:%M:%S%z")"; \
printf "$(RED)\n\nError running force install. %s\n\n$(RESET)\n" "$$ts"; \
exit 1; \
fi
help: ## Show this help
@echo "Usage: make <option>"; \
echo ""; \
echo "Options:"; \
awk 'BEGIN {FS = ":.*##"} /^[a-zA-Z0-9][a-zA-Z0-9_.-]*:.*##/ {printf " %-16s %s\n", $$1, $$2}' $(MAKEFILE_LIST)