-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathMakefile
More file actions
117 lines (107 loc) · 4.61 KB
/
Copy pathMakefile
File metadata and controls
117 lines (107 loc) · 4.61 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
# Makefile for Date Range Reporter Plugin
# Builds a distributable zip file for Super Productivity
PROJECT = sp-dashboard
PLUGIN_DIR = $(PROJECT)
ZIP_FILE = $(PROJECT).zip
VERSION := $(shell grep '"version"' package.json | sed 's/.*"version": "\(.*\)".*/\1/')
DESCRIPTION := $(shell grep '"description"' package.json | sed 's/.*"description": "\(.*\)".*/\1/')
RELEASE_FILE = $(PROJECT)-v$(VERSION).zip
.PHONY: build clean help release release-check test
# Default target
build: clean
@echo "Building plugin zip file..."
@echo "Preparing build directory..."
@mkdir -p build/$(PLUGIN_DIR)
@cp -R $(PLUGIN_DIR)/* build/$(PLUGIN_DIR)/
@echo "Generating manifest.json from template..."
@VERSION="$(VERSION)" DESCRIPTION="$(DESCRIPTION)" sh -c '\
sed -e "s/{{VERSION}}/$$VERSION/g" -e "s|{{DESCRIPTION}}|$$DESCRIPTION|g" \
$(PLUGIN_DIR)/manifest.json.template > build/$(PLUGIN_DIR)/manifest.json'
@rm -f build/$(PLUGIN_DIR)/manifest.json.template
@echo "Minifying HTML (inline CSS/JS preserved) -> build/$(PLUGIN_DIR)/index.html"
@npm run build:min
@cd build/$(PLUGIN_DIR) && zip -r ../../$(ZIP_FILE) . -x "manifest.json.template"
@echo "✓ Plugin packaged successfully: $(ZIP_FILE)"
screenshot:
@echo "Generating screenshots..."
@node scripts/screenshot.js
@echo "✓ Screenshots updated in assets/"
# Clean up generated files
clean:
@echo "Cleaning up..."
@rm -f $(ZIP_FILE) $(RELEASE_FILE) $(PLUGIN_DIR)/manifest.json
@rm -rf build
@echo "✓ Cleaned"
# Run tests
test:
@echo "Running tests..."
@npm test
@echo "✓ Tests completed"
# Pre-release checks
release-check:
@echo "Checking prerequisites for release v$(VERSION)..."
@if ! command -v gh >/dev/null 2>&1; then \
echo "❌ Error: GitHub CLI (gh) is not installed"; \
echo " Install with: brew install gh"; \
exit 1; \
fi
@if [ -z "$$(git status --porcelain)" ]; then \
echo "✓ Working directory is clean"; \
else \
echo "❌ Error: Uncommitted changes found"; \
echo " Please commit or stash your changes first"; \
exit 1; \
fi
@if git rev-parse "v$(VERSION)" >/dev/null 2>&1; then \
echo "⚠️ Warning: Tag v$(VERSION) already exists"; \
echo " Delete it with: git tag -d v$(VERSION) && git push --delete origin v$(VERSION)"; \
exit 1; \
fi
@echo "✓ All checks passed"
# Create a complete GitHub release (build, tag, push, and create release)
release: release-check build
@echo ""
@echo "════════════════════════════════════════════════════════════"
@echo "Creating GitHub release v$(VERSION)"
@echo "════════════════════════════════════════════════════════════"
@echo ""
@echo "→ Creating git tag v$(VERSION)..."
@git tag -a "v$(VERSION)" -m "Release v$(VERSION)"
@echo "✓ Tag created"
@echo ""
@echo "→ Pushing tag to origin..."
@git push origin "v$(VERSION)"
@echo "✓ Tag pushed"
@echo ""
@echo "→ Creating GitHub release..."
@gh release create "v$(VERSION)" \
--title "v$(VERSION)" \
--notes "Release v$(VERSION) of $(PROJECT) plugin" \
--generate-notes \
$(ZIP_FILE)
@echo ""
@echo "════════════════════════════════════════════════════════════"
@echo "✓ Release v$(VERSION) created successfully!"
@echo "════════════════════════════════════════════════════════════"
@echo ""
@echo "View at: https://github.com/$$(git config --get remote.origin.url | sed 's/.*github.com[:/]\(.*\)\.git/\1/')/releases/tag/v$(VERSION)"
pr:
gh pr create --fill
# Show help
help:
@echo "$(PROJECT) Plugin - Build System"
@echo ""
@echo "Available targets:"
@echo " make build - Build the plugin zip file (default)"
@echo " make test - Run unit tests"
@echo " make release - Complete release process (v$(VERSION))"
@echo " • Checks prerequisites"
@echo " • Builds plugin zip"
@echo " • Creates and pushes git tag"
@echo " • Creates GitHub release"
@echo " make release-check - Verify release prerequisites"
@echo " make clean - Remove generated zip files"
@echo " make screenshot - Generate/update screenshots via Puppeteer"
@echo " make help - Show this help message"
@echo ""
@echo "Current version: $(VERSION)"