-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
218 lines (188 loc) · 7.53 KB
/
Makefile
File metadata and controls
218 lines (188 loc) · 7.53 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
208
209
210
211
212
213
214
215
216
217
218
# VSCode Config Export - Makefile
# Provides convenient commands for development and usage
.PHONY: help install export test lint format clean setup docs
# Default target
.DEFAULT_GOAL := help
# Colors for output
GREEN := \033[32m
YELLOW := \033[33m
RED := \033[31m
NC := \033[0m
help: ## Show this help message
@echo "VSCode Config Export - Available Commands"
@echo "========================================"
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make $(GREEN)<target>$(NC)\n"} /^[a-zA-Z_-]+:.*?##/ { printf " $(GREEN)%-15s$(NC) %s\n", $$1, $$2 } /^##@/ { printf "\n$(YELLOW)%s$(NC)\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
##@ Setup and Installation
setup: ## Set up the development environment
@echo "$(GREEN)Setting up development environment...$(NC)"
chmod +x scripts/*.sh scripts/*.py tests/*.sh
@if command -v npm >/dev/null 2>&1; then \
echo "Installing npm dependencies..."; \
npm install; \
fi
@echo "$(GREEN)Setup complete!$(NC)"
##@ Usage
export: ## Export current VSCode configuration
@echo "$(GREEN)Exporting VSCode configuration...$(NC)"
@./scripts/export.sh
export-python: ## Export using Python script
@echo "$(GREEN)Exporting VSCode configuration (Python)...$(NC)"
@python3 scripts/export.py
install: ## Install exported configuration
@echo "$(YELLOW)Installing VSCode configuration...$(NC)"
@echo "$(RED)Warning: This will modify your VSCode configuration!$(NC)"
@./scripts/install.sh
backup: ## Create a backup of current configuration
@echo "$(GREEN)Creating backup...$(NC)"
@./scripts/backup-manager.sh create
list-backups: ## List all available backups
@echo "$(GREEN)Listing backups...$(NC)"
@./scripts/backup-manager.sh list
restore-backup: ## Restore from backup (interactive)
@echo "$(GREEN)Available backups:$(NC)"
@./scripts/backup-manager.sh list
@echo ""
@echo "To restore, run: make restore-from BACKUP=<backup_path>"
@echo "Example: make restore-from BACKUP=exports/backup-20250903-140530"
restore-from: ## Restore from specific backup (usage: make restore-from BACKUP=path)
@if [ -z "$(BACKUP)" ]; then \
echo "$(RED)Error: Please specify BACKUP path$(NC)"; \
echo "Usage: make restore-from BACKUP=<backup_path>"; \
exit 1; \
fi
@echo "$(YELLOW)Restoring from backup: $(BACKUP)$(NC)"
@./scripts/backup-manager.sh restore "$(BACKUP)"
##@ Development
test: ## Run all tests
@echo "$(GREEN)Running tests...$(NC)"
@./tests/test-export.sh
test-ci: ## Run tests in CI mode
@echo "$(GREEN)Running tests (CI mode)...$(NC)"
@./tests/test-export.sh --ci
lint: ## Lint shell scripts
@echo "$(GREEN)Linting shell scripts...$(NC)"
@if command -v shellcheck >/dev/null 2>&1; then \
find scripts tests -name "*.sh" -exec shellcheck {} \; ; \
else \
echo "$(YELLOW)shellcheck not found. Install with: brew install shellcheck$(NC)"; \
fi
lint-python: ## Lint Python scripts
@echo "$(GREEN)Linting Python scripts...$(NC)"
@if command -v flake8 >/dev/null 2>&1; then \
flake8 scripts/*.py --max-line-length=88; \
else \
echo "$(YELLOW)flake8 not found. Install with: pip install flake8$(NC)"; \
fi
format: ## Format shell scripts
@echo "$(GREEN)Formatting shell scripts...$(NC)"
@if command -v shfmt >/dev/null 2>&1; then \
shfmt -w scripts/*.sh tests/*.sh; \
echo "$(GREEN)Scripts formatted!$(NC)"; \
else \
echo "$(YELLOW)shfmt not found. Install with: brew install shfmt$(NC)"; \
fi
format-python: ## Format Python scripts
@echo "$(GREEN)Formatting Python scripts...$(NC)"
@if command -v black >/dev/null 2>&1; then \
black scripts/*.py; \
echo "$(GREEN)Python scripts formatted!$(NC)"; \
else \
echo "$(YELLOW)black not found. Install with: pip install black$(NC)"; \
fi
##@ Documentation
docs: ## Open documentation
@echo "$(GREEN)Opening documentation...$(NC)"
@if command -v open >/dev/null 2>&1; then \
open README.md; \
elif command -v xdg-open >/dev/null 2>&1; then \
xdg-open README.md; \
else \
echo "See README.md and docs/ directory"; \
fi
##@ Maintenance
clean: ## Clean up temporary files
@echo "$(GREEN)Cleaning up...$(NC)"
@find . -name "*.tmp" -delete 2>/dev/null || true
@find . -name "*.log" -delete 2>/dev/null || true
@find . -name "*.bak" -delete 2>/dev/null || true
@find . -name "__pycache__" -type d -exec rm -rf {} + 2>/dev/null || true
@rm -f vscode-config-*.zip 2>/dev/null || true
@echo "$(GREEN)Cleanup complete!$(NC)"
clean-old-backups: ## Clean backups older than 30 days
@echo "$(GREEN)Cleaning old backups...$(NC)"
@./scripts/backup-manager.sh clean
@echo "$(YELLOW)Note: Changes will be committed to git$(NC)"
clean-all-backups: ## Clean all backups (use with caution)
@echo "$(RED)Warning: This will delete ALL backups and commit to git!$(NC)"
@read -p "Are you sure? [y/N]: " confirm && [ "$$confirm" = "y" ] || exit 1
@rm -rf backups/exports/* backups/installs/* backups/originals/* backups/archives/*
@git add backups/
@git commit -m "chore: clean all backups" || echo "No changes to commit"
@echo "$(GREEN)All backups cleaned and committed!$(NC)"
backup-stats: ## Show backup statistics
@echo "$(GREEN)Backup statistics...$(NC)"
@./scripts/backup-manager.sh stats
archive: ## Create distribution archive
@echo "$(GREEN)Creating distribution archive...$(NC)"
@VERSION=$$(jq -r '.version' package.json 2>/dev/null || echo "1.0.0"); \
ARCHIVE_NAME="vscode-config-export-v$$VERSION.zip"; \
zip -r "$$ARCHIVE_NAME" \
scripts/ docs/ tests/ \
LICENSE README.md CONTRIBUTING.md SECURITY.md CHANGELOG.md package.json Makefile \
-x "*.git*" "*.DS_Store" "node_modules/*"; \
echo "$(GREEN)Archive created: $$ARCHIVE_NAME$(NC)"
##@ Git Operations
commit-export: export ## Export config and commit changes
@echo "$(GREEN)Exporting and committing configuration...$(NC)"
@git add .
@git commit -m "chore: update VSCode configuration export $$(date +%Y-%m-%d)" || echo "No changes to commit"
push: ## Push changes to remote
@echo "$(GREEN)Pushing changes...$(NC)"
@git push
release-prep: test lint ## Prepare for release (test and lint)
@echo "$(GREEN)Preparing for release...$(NC)"
@echo "All checks passed! Ready for release."
##@ Information
status: ## Show project status
@echo "$(GREEN)VSCode Config Export - Project Status$(NC)"
@echo "======================================"
@echo "Git branch: $$(git branch --show-current 2>/dev/null || echo 'Not a git repo')"
@echo "Git status:"
@git status --porcelain 2>/dev/null || echo "Not a git repository"
@echo ""
@echo "Files:"
@ls -la scripts/
@echo ""
@echo "Tests available:"
@ls -la tests/ 2>/dev/null || echo "No tests directory"
version: ## Show version information
@echo "$(GREEN)Version Information$(NC)"
@echo "==================="
@if [ -f package.json ]; then \
echo "Package version: $$(jq -r '.version' package.json)"; \
fi
@if command -v code >/dev/null 2>&1; then \
echo "VSCode version: $$(code --version | head -n1)"; \
else \
echo "VSCode: Not installed or not in PATH"; \
fi
@echo "Shell: $$SHELL"
@if command -v python3 >/dev/null 2>&1; then \
echo "Python: $$(python3 --version)"; \
fi
install-tools: ## Install development tools
@echo "$(GREEN)Installing development tools...$(NC)"
@if command -v brew >/dev/null 2>&1; then \
echo "Installing via Homebrew..."; \
brew install shellcheck shfmt; \
elif command -v apt-get >/dev/null 2>&1; then \
echo "Installing via apt..."; \
sudo apt-get update && sudo apt-get install shellcheck; \
else \
echo "$(YELLOW)Please install shellcheck and shfmt manually$(NC)"; \
fi
@if command -v pip3 >/dev/null 2>&1; then \
echo "Installing Python tools..."; \
pip3 install flake8 black; \
fi
@echo "$(GREEN)Tools installation complete!$(NC)"