Repository navigation
Expand file tree
/
Copy pathmakefile
More file actions
149 lines (118 loc) · 4.44 KB
/
Copy pathmakefile
File metadata and controls
149 lines (118 loc) · 4.44 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
.PHONY: install build test dev clean lint format typecheck example-basic example-advanced example-invoice help
# Default target
.DEFAULT_GOAL := help
# Colors for output
BLUE := \033[0;34m
GREEN := \033[0;32m
YELLOW := \033[0;33m
RED := \033[0;31m
NC := \033[0m # No Color
help: ## Show this help message
@echo "$(BLUE)Papercraft - Available Commands$(NC)"
@echo ""
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " $(GREEN)%-20s$(NC) %s\n", $$1, $$2}'
install: ## Install dependencies
@echo "$(BLUE)Installing dependencies...$(NC)"
pnpm install
@echo "$(GREEN)✅ Dependencies installed$(NC)"
build: ## Build the package
@echo "$(BLUE)Building package...$(NC)"
pnpm run build
@echo "$(GREEN)✅ Build complete$(NC)"
build-watch: ## Build in watch mode
@echo "$(BLUE)Building in watch mode...$(NC)"
pnpm run build:watch
test: ## Run tests
@echo "$(BLUE)Running tests...$(NC)"
pnpm test
test-watch: ## Run tests in watch mode
@echo "$(BLUE)Running tests in watch mode...$(NC)"
pnpm run test:watch
test-coverage: ## Run tests with coverage
@echo "$(BLUE)Running tests with coverage...$(NC)"
pnpm run test:coverage
dev: ## Run dev mode (watches basic example)
@echo "$(BLUE)Starting dev mode...$(NC)"
pnpm run dev
lint: ## Run linter
@echo "$(BLUE)Running linter...$(NC)"
pnpm run lint
lint-fix: ## Run linter and fix issues
@echo "$(BLUE)Running linter with auto-fix...$(NC)"
pnpm run lint:fix
format: ## Format code with Prettier
@echo "$(BLUE)Formatting code...$(NC)"
pnpm run format
@echo "$(GREEN)✅ Code formatted$(NC)"
format-check: ## Check code formatting
@echo "$(BLUE)Checking code formatting...$(NC)"
pnpm run format:check
typecheck: ## Type check with TypeScript
@echo "$(BLUE)Running type check...$(NC)"
pnpm run typecheck
@echo "$(GREEN)✅ Type check passed$(NC)"
example-basic: build ## Run basic example
@echo "$(BLUE)Running basic example...$(NC)"
pnpm run example:basic
example-advanced: build ## Run advanced example
@echo "$(BLUE)Running advanced example...$(NC)"
pnpm run example:advanced
example-invoice: build ## Run invoice example
@echo "$(BLUE)Running invoice example...$(NC)"
pnpm run example:invoice
examples: example-basic example-advanced example-invoice ## Run all examples
clean: ## Clean build artifacts and dependencies
@echo "$(YELLOW)Cleaning...$(NC)"
rm -rf dist
rm -rf node_modules
rm -rf coverage
rm -rf .tsup
rm -f *.pdf
rm -f output-*.pdf
rm -f test-*.pdf
rm -f basic-output.pdf
rm -f invoice.pdf
rm -f pnpm-lock.yaml
@echo "$(GREEN)✅ Cleaned$(NC)"
clean-build: ## Clean only build artifacts
@echo "$(YELLOW)Cleaning build artifacts...$(NC)"
rm -rf dist
rm -rf .tsup
rm -f *.pdf
rm -f output-*.pdf
rm -f test-*.pdf
@echo "$(GREEN)✅ Build artifacts cleaned$(NC)"
link: build ## Link package globally
@echo "$(BLUE)Linking package globally...$(NC)"
pnpm link --global
@echo "$(GREEN)✅ Package linked. Use 'papercraft' command$(NC)"
unlink: ## Unlink package globally
@echo "$(BLUE)Unlinking package...$(NC)"
pnpm unlink --global papercraft
@echo "$(GREEN)✅ Package unlinked$(NC)"
cli-help: build ## Show CLI help
@echo "$(BLUE)CLI Help:$(NC)"
node dist/bin/papercraft.js --help
cli-test: build ## Test CLI with sample HTML
@echo "$(BLUE)Testing CLI...$(NC)"
@echo '<!DOCTYPE html><html><body><h1>CLI Test</h1><p>Generated by Makefile</p></body></html>' > test-cli.html
node dist/bin/papercraft.js -i test-cli.html -o test-cli-output.pdf
@echo "$(GREEN)✅ PDF generated: test-cli-output.pdf$(NC)"
check: typecheck lint test ## Run all checks (typecheck, lint, test)
@echo "$(GREEN)✅ All checks passed!$(NC)"
verify: install build check examples ## Full verification (install, build, check, examples)
@echo "$(GREEN)✅ Full verification passed! 🎉$(NC)"
publish: verify ## Build, test and prepare for publishing
@echo "$(BLUE)Preparing for publish...$(NC)"
pnpm run prepublishOnly
@echo "$(GREEN)✅ Ready to publish!$(NC)"
@echo "$(YELLOW)Run 'pnpm publish' to publish to npm$(NC)"
install-playwright: ## Install Playwright browsers
@echo "$(BLUE)Installing Playwright browsers...$(NC)"
pnpm exec playwright install chromium
@echo "$(GREEN)✅ Playwright browsers installed$(NC)"
benchmark: build ## Run performance benchmark
@echo "$(BLUE)Running benchmark...$(NC)"
pnpm exec tsx benchmark.ts
all: clean install build test examples ## Clean, install, build, test, and run examples
@echo "$(GREEN)✅ All tasks completed!$(NC)"