-
-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMakefile
More file actions
151 lines (134 loc) · 4.18 KB
/
Makefile
File metadata and controls
151 lines (134 loc) · 4.18 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
# ============================================================
# Makefile - VS Code Extension
# DX-first, portable, explicit, Open Source friendly
#
# This Makefile is OPTIONAL.
# You can always use npm / pnpm / yarn directly.
# ============================================================
SHELL := /bin/sh
.DEFAULT_GOAL := help
# ------------------------------------------------------------
# Colors (optional)
# Disable with: NO_COLOR=1 make <target>
# ------------------------------------------------------------
ifeq ($(NO_COLOR),1)
BOLD :=
GREEN :=
YELLOW :=
RED :=
BLUE :=
RESET :=
else
BOLD := \033[1m
GREEN := \033[0;32m
YELLOW:= \033[0;33m
RED := \033[0;31m
BLUE := \033[0;34m
RESET := \033[0m
endif
# ------------------------------------------------------------
# Package manager resolution
#
# Priority:
# 1. PKG_MANAGER env var
# 2. .pkg-manager file
# 3. pnpm > yarn > npm
# ------------------------------------------------------------
PKG_MANAGER := $(shell \
if [ -n "$$PKG_MANAGER" ]; then \
echo "$$PKG_MANAGER"; \
elif [ -f .pkg-manager ]; then \
cat .pkg-manager; \
elif command -v pnpm >/dev/null 2>&1; then \
echo pnpm; \
elif command -v yarn >/dev/null 2>&1; then \
echo yarn; \
elif command -v npm >/dev/null 2>&1; then \
echo npm; \
else \
echo none; \
fi \
)
# ------------------------------------------------------------
# Help
# ------------------------------------------------------------
.PHONY: help
help:
@echo "$(BOLD)VS Code Extension - Development Commands$(RESET)"
@echo ""
@echo "$(BOLD)Common workflow:$(RESET)"
@echo " make install Install dependencies"
@echo " make build Build the extension"
@echo ""
@echo "$(BOLD)Available commands:$(RESET)"
@echo " make install Install dependencies using npm / pnpm / yarn"
@echo " make build Build the extension"
@echo " make watch Build in watch mode"
@echo " make test Run tests"
@echo " make doctor Show environment diagnostics"
@echo ""
@echo "$(BLUE)Notes:$(RESET)"
@echo "- This Makefile does NOT manage Node versions."
@echo "- If you use direnv and see a 'blocked .envrc' message,"
@echo " run: direnv allow (once) and re-enter the directory."
@echo "- You can disable colors with NO_COLOR=1."
@echo ""
# ------------------------------------------------------------
# Package manager validation
# ------------------------------------------------------------
.PHONY: pm
pm:
@if [ "$(PKG_MANAGER)" = "none" ]; then \
echo "$(RED)ERROR: No package manager found.$(RESET)"; \
echo ""; \
echo "Please install one of the following:"; \
echo " - npm (comes with Node.js)"; \
echo " - pnpm"; \
echo " - yarn"; \
echo ""; \
echo "Then re-run: make install"; \
exit 1; \
fi
@echo "$(GREEN)Using package manager:$(RESET) $(BOLD)$(PKG_MANAGER)$(RESET)"
# ------------------------------------------------------------
# Core targets
# ------------------------------------------------------------
.PHONY: install
install: pm
@echo "$(GREEN)Installing dependencies$(RESET)"
@$(PKG_MANAGER) install
.PHONY: build
build: pm
@echo "$(GREEN)Building VS Code extension$(RESET)"
@$(PKG_MANAGER) run build
.PHONY: watch
watch: pm
@echo "$(GREEN)Starting watch mode$(RESET)"
@$(PKG_MANAGER) run watch
.PHONY: test
test: pm
@echo "$(GREEN)Running tests$(RESET)"
@$(PKG_MANAGER) test
# ------------------------------------------------------------
# Diagnostics
# ------------------------------------------------------------
.PHONY: doctor
doctor:
@echo "$(BOLD)Environment diagnostics$(RESET)"
@echo ""
@echo "Node: $$(node --version 2>/dev/null || echo not found)"
@echo "npm: $$(npm --version 2>/dev/null || echo not found)"
@echo "pnpm: $$(pnpm --version 2>/dev/null || echo not found)"
@echo "yarn: $$(yarn --version 2>/dev/null || echo not found)"
@echo ""
@if command -v direnv >/dev/null 2>&1; then \
echo "direnv: installed"; \
direnv status; \
else \
echo "direnv: not installed (optional)"; \
fi
@echo ""
@echo "$(BLUE)Tip:$(RESET) If something does not work, include this output in issues."
# ------------------------------------------------------------
# End of file
# ------------------------------------------------------------