-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
161 lines (128 loc) · 4.38 KB
/
Makefile
File metadata and controls
161 lines (128 loc) · 4.38 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
# agent-pmo:5547fd2
# =============================================================================
# Standard Makefile — CommandTree
# Cross-platform: Linux, macOS, Windows (via GNU Make)
# =============================================================================
.PHONY: build test lint fmt fmt-check format clean check ci coverage coverage-check setup spellcheck package
# -----------------------------------------------------------------------------
# OS Detection
# -----------------------------------------------------------------------------
ifeq ($(OS),Windows_NT)
SHELL := powershell.exe
.SHELLFLAGS := -NoProfile -Command
RM = Remove-Item -Recurse -Force -ErrorAction SilentlyContinue
MKDIR = New-Item -ItemType Directory -Force
HOME ?= $(USERPROFILE)
else
RM = rm -rf
MKDIR = mkdir -p
endif
# Coverage threshold (override in CI via env var)
COVERAGE_THRESHOLD ?= 80
# =============================================================================
# PRIMARY TARGETS (uniform interface — do not rename)
# =============================================================================
## build: Compile/assemble all artifacts
build:
@echo "==> Building..."
$(MAKE) _build
## test: Run full test suite with coverage
test:
@echo "==> Testing..."
$(MAKE) _test
## lint: Run all linters (fails on any warning)
lint:
@echo "==> Linting..."
$(MAKE) _lint
## fmt: Format all code in-place
fmt:
@echo "==> Formatting..."
$(MAKE) _fmt
## fmt-check: Check formatting without modifying
fmt-check:
@echo "==> Checking format..."
$(MAKE) _fmt_check
## clean: Remove all build artifacts
clean:
@echo "==> Cleaning..."
$(MAKE) _clean
## check: lint + test (pre-commit)
check: lint test
## ci: lint + test + build (full CI simulation)
ci: fmt-check lint spellcheck test build package
## coverage: Generate coverage report
coverage:
@echo "==> Coverage report..."
$(MAKE) _coverage
## coverage-check: Assert thresholds (exits non-zero if below)
coverage-check:
@echo "==> Checking coverage thresholds..."
$(MAKE) _coverage_check
## setup: Post-create dev environment setup
setup:
@echo "==> Setting up development environment..."
$(MAKE) _setup
@echo "==> Setup complete. Run 'make ci' to validate."
# =============================================================================
# CUSTOM TARGETS (project-specific)
# =============================================================================
## format: Alias for fmt (backwards compatibility)
format: fmt
## spellcheck: Run cspell spell checker
spellcheck:
npx cspell "src/**/*.ts"
## package: Build VSIX package
package: build
npx vsce package
# =============================================================================
# TYPESCRIPT/NODE IMPLEMENTATION
# =============================================================================
UNAME := $(shell uname 2>/dev/null)
EXCLUDE_CI ?= false
VSCODE_TEST_CMD = npx vscode-test --coverage
ifeq ($(EXCLUDE_CI),true)
VSCODE_TEST_CMD += --grep @exclude-ci --invert
endif
ifeq ($(UNAME),Linux)
VSCODE_TEST = xvfb-run -a $(VSCODE_TEST_CMD)
else
VSCODE_TEST = $(VSCODE_TEST_CMD)
endif
_build:
npx tsc -p ./
_test: _build
npm run test:unit
$(VSCODE_TEST)
node tools/check-coverage.mjs
_lint:
npx eslint src
_fmt:
npx prettier --write "src/**/*.ts"
_fmt_check:
npx prettier --check "src/**/*.ts"
_clean:
$(RM) out coverage .vscode-test
_coverage:
@echo "==> HTML report: coverage/index.html"
_coverage_check:
node tools/check-coverage.mjs
_setup:
npm ci
# =============================================================================
# HELP
# =============================================================================
help:
@echo "Available targets:"
@echo " build - Compile/assemble all artifacts"
@echo " test - Run full test suite with coverage"
@echo " lint - Run all linters (errors mode)"
@echo " fmt - Format all code in-place"
@echo " fmt-check - Check formatting (no modification)"
@echo " clean - Remove build artifacts"
@echo " check - lint + test (pre-commit)"
@echo " ci - fmt-check + lint + spellcheck + test + build + package"
@echo " coverage - Generate and open coverage report"
@echo " coverage-check - Assert coverage thresholds"
@echo " spellcheck - Run cspell spell checker"
@echo " package - Build VSIX package"
@echo " setup - Post-create dev environment setup"