-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
155 lines (129 loc) · 5.48 KB
/
Makefile
File metadata and controls
155 lines (129 loc) · 5.48 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
.PHONY: all clean install build package publish publish-ovsx publish-vsx git-tag test test-unit test-integration test-renderer test-all coverage docker-up docker-down
# Variables
NODE_BIN := node
NPM_BIN := npm
VSCE_CMD := npx -y @vscode/vsce@2.24.0
OVSX_CMD := npx -y ovsx
# Get version and name from package.json using node
EXTENSION_NAME := $(shell $(NODE_BIN) -p "require('./package.json').name")
EXTENSION_VERSION := $(shell $(NODE_BIN) -p "require('./package.json').version")
VSIX_FILE := $(EXTENSION_NAME)-$(EXTENSION_VERSION).vsix
# Default target
all: clean install build package
# Clean build artifacts
clean:
rm -rf out dist *.vsix node_modules
# Install dependencies
install:
$(NPM_BIN) install
# Build the extension
build:
$(NPM_BIN) run vscode:prepublish
# Package the extension
package: build
@echo "Replacing README.md with MARKETPLACE.md for packaging..."
@if [ -f README.md ]; then cp README.md README.md.bak; fi
@cp MARKETPLACE.md README.md
@trap 'if [ -f README.md.bak ]; then mv README.md.bak README.md; fi' EXIT INT TERM; \
$(VSCE_CMD) package; \
EXIT_CODE=$$?; \
if [ -f README.md.bak ]; then mv README.md.bak README.md; fi; \
echo "Restored original README.md"; \
exit $$EXIT_CODE
# Publish the extension to VS Code Marketplace and Open VSX Registry
publish: package
@echo "Publishing $(VSIX_FILE) to VS Code Marketplace..."
test -f ./pat || (echo "Error: pat file not found. Please create a file named 'pat' containing your Personal Access Token." && exit 1)
$(VSCE_CMD) publish --packagePath $(VSIX_FILE) -p $(shell cat ./pat)
@echo "Successfully published to VS Code Marketplace."
@echo "Publishing $(VSIX_FILE) to Open VSX Registry..."
test -f ./pat-open-vsx || (echo "Error: pat-open-vsx file not found. Please create a file named 'pat-open-vsx' containing your Open VSX Access Token." && exit 1)
$(OVSX_CMD) publish $(VSIX_FILE) -p $(shell cat ./pat-open-vsx)
@echo "Successfully published to Open VSX Registry."
# Publish the extension to VS Code Marketplace only
publish-vsx: package
@echo "Publishing $(VSIX_FILE) to VS Code Marketplace..."
test -f ./pat || (echo "Error: pat file not found" && exit 1)
$(VSCE_CMD) publish --packagePath $(VSIX_FILE) -p $(shell cat ./pat)
# Publish the extension to Open VSX Registry only
publish-ovsx: package
@echo "Publishing $(VSIX_FILE) to Open VSX Registry..."
test -f ./pat-open-vsx || (echo "Error: pat-open-vsx file not found" && exit 1)
$(OVSX_CMD) publish $(VSIX_FILE) -p $(shell cat ./pat-open-vsx)
# Watch mode for development
watch:
$(NPM_BIN) run watch
# Testing targets
test:
$(NPM_BIN) run test
test-unit:
$(NPM_BIN) run test:unit
test-integration:
$(NPM_BIN) run test:integration
test-renderer:
$(NPM_BIN) run test:renderer
test-all:
$(NPM_BIN) run test:all
coverage:
$(NPM_BIN) run coverage
coverage-report:
$(NPM_BIN) run coverage:report
@echo "Coverage report generated in ./coverage/index.html"
# Docker testing targets
docker-up:
docker-compose -f docker-compose.test.yml up -d
@echo "PostgreSQL test containers started"
@echo "Versions available on ports: 12(5412), 14(5414), 15(5415), 16(5416), 17(5417)"
docker-down:
docker-compose -f docker-compose.test.yml down
docker-logs:
docker-compose -f docker-compose.test.yml logs -f
docker-clean:
docker-compose -f docker-compose.test.yml down -v
@echo "Test containers and volumes removed"
# Full test suite
test-full: docker-up test-all coverage docker-down
@echo "Full test suite completed"
# Git tag and version bump (interactive)
git-tag:
@echo "Current version: $(EXTENSION_VERSION)"
@read -p "Enter the new version number (e.g., 1.0.1): " VERSION; \
VERSION=$${VERSION#v}; \
if [ -z "$$VERSION" ]; then echo "Version cannot be empty"; exit 1; fi; \
echo "Updating package.json version to $$VERSION..."; \
$(NODE_BIN) -e "let pkg=require('./package.json'); pkg.version='$$VERSION'; require('fs').writeFileSync('package.json', JSON.stringify(pkg, null, 2));"; \
echo "package.json updated."; \
git add package.json; \
git commit -m "Bump version to $$VERSION"; \
git tag -a "v$$VERSION" -m "Release v$$VERSION"; \
git push origin main; \
git push origin "v$$VERSION"; \
echo "Git tag v$$VERSION created and pushed."
# Help target
help:
@echo "Available targets:"
@echo " all : Clean, install, build, and package"
@echo " clean : Remove build artifacts"
@echo " install : Install dependencies"
@echo " build : Build the extension"
@echo " package : Create VSIX package"
@echo " publish : Publish to BOTH VS Code Marketplace and Open VSX"
@echo " publish-vsx : Publish to VS Code Marketplace only"
@echo " publish-ovsx : Publish to Open VSX Registry only"
@echo " git-tag : Interactive version bump, commit, tag, and push"
@echo ""
@echo "Testing targets:"
@echo " test : Run unit tests"
@echo " test-unit : Run unit tests only"
@echo " test-integration: Run integration tests"
@echo " test-renderer : Run renderer component tests"
@echo " test-all : Run all tests"
@echo " coverage : Generate coverage report"
@echo " coverage-report : Generate HTML coverage report"
@echo ""
@echo "Docker testing targets:"
@echo " docker-up : Start PostgreSQL test containers (12-17)"
@echo " docker-down : Stop and remove test containers"
@echo " docker-logs : View container logs"
@echo " docker-clean : Remove containers and volumes"
@echo " test-full : Run full test suite with Docker (docker-up → test-all → docker-down)"