-
-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathMakefile
More file actions
292 lines (273 loc) · 9.43 KB
/
Makefile
File metadata and controls
292 lines (273 loc) · 9.43 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
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
.PHONY: help build test lint type-check clean install release-rc release-patch release-minor release-major publish-rc publish prepublish
# Default target
help:
@echo "Authorizer React - Makefile Commands"
@echo ""
@echo "Development:"
@echo " make install - Install dependencies"
@echo " make build - Build the library"
@echo " make start - Start watch mode"
@echo " make test - Run tests"
@echo " make lint - Run linter"
@echo " make type-check - Run TypeScript type checking"
@echo " make clean - Clean build artifacts"
@echo ""
@echo "Release (RC):"
@echo " make release-rc [VERSION=X.X.X-rc.X] - Create RC release (interactive)"
@echo " make publish-rc - Publish RC (git commit/tag/push + npm)"
@echo ""
@echo "Release (Stable):"
@echo " make release-patch - Bump patch version (1.0.0 -> 1.0.1, interactive)"
@echo " make release-minor - Bump minor version (1.0.0 -> 1.1.0, interactive)"
@echo " make release-major - Bump major version (1.0.0 -> 2.0.0, interactive)"
@echo " make publish - Publish stable (git commit/tag/push + npm)"
@echo ""
@echo "Note: All release commands are interactive and will:"
@echo " - Show current and new version"
@echo " - Ask for confirmation before making changes"
@echo ""
@echo "Example:"
@echo " make release-rc VERSION=2.0.0-rc.1"
@echo " make release-patch # Will auto-calculate and ask for confirmation"
# Development commands
install:
@echo "📦 Installing dependencies..."
npm install
build:
@echo "🔨 Building library..."
npm run build
@echo "✅ Build complete!"
start:
@echo "👀 Starting watch mode..."
npm start
test:
@echo "🧪 Running tests..."
npm test
lint:
@echo "🔍 Running linter..."
npm run lint
type-check:
@echo "📝 Type checking..."
npm run type-check
clean:
@echo "🧹 Cleaning build artifacts..."
rm -rf dist
rm -rf node_modules/.cache
@echo "✅ Clean complete!"
# Release commands
release-rc:
@CURRENT=$$(npm pkg get version | tr -d '"'); \
if [ -z "$(VERSION)" ]; then \
echo ""; \
echo "Current version: $$CURRENT"; \
echo ""; \
echo "Enter the RC version (e.g., 2.0.0-rc.1):"; \
read -r VERSION; \
if [ -z "$$VERSION" ]; then \
echo "❌ Error: VERSION is required"; \
exit 1; \
fi; \
else \
VERSION=$(VERSION); \
fi; \
echo ""; \
echo "🚀 Creating RC release: $$VERSION"; \
echo "📝 Will update package.json from $$CURRENT to $$VERSION"; \
echo ""; \
echo "⚠️ This will:"; \
echo " - Update package.json version to $$VERSION"; \
echo " - Build the library"; \
echo ""; \
read -p "Continue? (y/N): " confirm; \
if [ "$$confirm" != "y" ] && [ "$$confirm" != "Y" ]; then \
echo "❌ Release cancelled"; \
exit 1; \
fi; \
echo ""; \
echo "📝 Updating package.json version..."; \
npm pkg set version=$$VERSION; \
echo "🔨 Building library..."; \
npm run build; \
echo ""; \
echo "✅ RC release $$VERSION ready!"; \
echo ""; \
echo "📋 Release Checklist:"; \
echo " ✓ Version updated to $$VERSION"; \
echo " ✓ Library built successfully"; \
echo ""; \
echo "Next step:"; \
echo " make publish-rc # Will handle git commit, tag, push, and npm publish"
release-patch:
@CURRENT=$$(npm pkg get version | tr -d '"'); \
BASE=$$(echo "$$CURRENT" | sed 's/-.*//'); \
NEW=$$(node -p "const v='$$BASE'.split('.'); v[2]=(parseInt(v[2])+1).toString(); v.join('.')"); \
echo ""; \
echo "🚀 Creating patch release..."; \
echo "📝 Current version: $$CURRENT"; \
echo "📝 New version: $$NEW"; \
echo ""; \
echo "⚠️ This will:"; \
echo " - Update package.json version from $$CURRENT to $$NEW"; \
echo " - Build the library"; \
echo ""; \
read -p "Continue? (y/N): " confirm; \
if [ "$$confirm" != "y" ] && [ "$$confirm" != "Y" ]; then \
echo "❌ Release cancelled"; \
exit 1; \
fi; \
echo ""; \
npm pkg set version=$$NEW; \
echo "📝 Version updated to: $$NEW"; \
make build; \
echo "✅ Patch release $$NEW ready!"
release-minor:
@CURRENT=$$(npm pkg get version | tr -d '"'); \
BASE=$$(echo "$$CURRENT" | sed 's/-.*//'); \
NEW=$$(node -p "const v='$$BASE'.split('.'); v[1]=(parseInt(v[1])+1).toString(); v[2]='0'; v.join('.')"); \
echo ""; \
echo "🚀 Creating minor release..."; \
echo "📝 Current version: $$CURRENT"; \
echo "📝 New version: $$NEW"; \
echo ""; \
echo "⚠️ This will:"; \
echo " - Update package.json version from $$CURRENT to $$NEW"; \
echo " - Build the library"; \
echo ""; \
read -p "Continue? (y/N): " confirm; \
if [ "$$confirm" != "y" ] && [ "$$confirm" != "Y" ]; then \
echo "❌ Release cancelled"; \
exit 1; \
fi; \
echo ""; \
npm pkg set version=$$NEW; \
echo "📝 Version updated to: $$NEW"; \
make build; \
echo "✅ Minor release $$NEW ready!"
release-major:
@CURRENT=$$(npm pkg get version | tr -d '"'); \
BASE=$$(echo "$$CURRENT" | sed 's/-.*//'); \
NEW=$$(node -p "const v='$$BASE'.split('.'); v[0]=(parseInt(v[0])+1).toString(); v[1]='0'; v[2]='0'; v.join('.')"); \
echo ""; \
echo "🚀 Creating major release..."; \
echo "📝 Current version: $$CURRENT"; \
echo "📝 New version: $$NEW"; \
echo ""; \
echo "⚠️ This will:"; \
echo " - Update package.json version from $$CURRENT to $$NEW"; \
echo " - Build the library"; \
echo ""; \
read -p "Continue? (y/N): " confirm; \
if [ "$$confirm" != "y" ] && [ "$$confirm" != "Y" ]; then \
echo "❌ Release cancelled"; \
exit 1; \
fi; \
echo ""; \
npm pkg set version=$$NEW; \
echo "📝 Version updated to: $$NEW"; \
make build; \
echo "✅ Major release $$NEW ready!"
# Publish commands
publish-rc:
@VERSION=$$(npm pkg get version | tr -d '"'); \
if [[ ! "$$VERSION" =~ -rc\.[0-9]+$$ ]]; then \
echo "❌ Error: Version $$VERSION doesn't look like an RC (should end with -rc.X)"; \
exit 1; \
fi; \
echo ""; \
echo "📦 Publishing RC to npm..."; \
echo "📦 Package: @authorizerdev/authorizer-react"; \
echo "📦 Version: $$VERSION"; \
echo "📦 Tag: rc"; \
echo ""; \
echo "⚠️ This will:"; \
echo " 1. Commit changes (if any)"; \
echo " 2. Create git tag v$$VERSION"; \
echo " 3. Push to origin"; \
echo " 4. Publish to npm registry"; \
echo ""; \
read -p "Continue? (y/N): " confirm; \
if [ "$$confirm" != "y" ] && [ "$$confirm" != "Y" ]; then \
echo "❌ Publish cancelled"; \
exit 1; \
fi; \
echo ""; \
echo "🔍 Checking git status..."; \
if [ -n "$$(git status --porcelain)" ]; then \
echo "📝 Staging changes..."; \
git add .; \
echo "💾 Committing changes..."; \
git commit -m "chore: release $$VERSION" || echo "⚠️ Commit failed or nothing to commit"; \
else \
echo "✓ No uncommitted changes"; \
fi; \
if ! git rev-parse "v$$VERSION" >/dev/null 2>&1; then \
echo "🏷️ Creating git tag v$$VERSION..."; \
git tag v$$VERSION; \
else \
echo "⚠️ Tag v$$VERSION already exists"; \
fi; \
echo "📤 Pushing to origin..."; \
git push origin main 2>/dev/null || git push origin master 2>/dev/null || echo "⚠️ Push failed or already up to date"; \
git push origin v$$VERSION 2>/dev/null || echo "⚠️ Tag push failed or already exists"; \
echo ""; \
echo "📦 Publishing to npm..."; \
npm publish --tag rc --access public; \
echo ""; \
echo "✅ Published @authorizerdev/authorizer-react@$$VERSION to npm with 'rc' tag!"
publish:
@VERSION=$$(npm pkg get version | tr -d '"'); \
if [[ "$$VERSION" =~ -rc\.[0-9]+$$ ]]; then \
echo "❌ Error: Version $$VERSION is an RC. Use 'make publish-rc' instead"; \
exit 1; \
fi; \
echo ""; \
echo "📦 Publishing stable release to npm..."; \
echo "📦 Package: @authorizerdev/authorizer-react"; \
echo "📦 Version: $$VERSION"; \
echo "📦 Tag: latest"; \
echo ""; \
echo "⚠️ This will:"; \
echo " 1. Commit changes (if any)"; \
echo " 2. Create git tag v$$VERSION"; \
echo " 3. Push to origin"; \
echo " 4. Publish to npm registry as latest"; \
echo ""; \
read -p "Continue? (y/N): " confirm; \
if [ "$$confirm" != "y" ] && [ "$$confirm" != "Y" ]; then \
echo "❌ Publish cancelled"; \
exit 1; \
fi; \
echo ""; \
echo "🔍 Checking git status..."; \
if [ -n "$$(git status --porcelain)" ]; then \
echo "📝 Staging changes..."; \
git add .; \
echo "💾 Committing changes..."; \
git commit -m "chore: release $$VERSION" || echo "⚠️ Commit failed or nothing to commit"; \
else \
echo "✓ No uncommitted changes"; \
fi; \
if ! git rev-parse "v$$VERSION" >/dev/null 2>&1; then \
echo "🏷️ Creating git tag v$$VERSION..."; \
git tag v$$VERSION; \
else \
echo "⚠️ Tag v$$VERSION already exists"; \
fi; \
echo "📤 Pushing to origin..."; \
git push origin main 2>/dev/null || git push origin master 2>/dev/null || echo "⚠️ Push failed or already up to date"; \
git push origin v$$VERSION 2>/dev/null || echo "⚠️ Tag push failed or already exists"; \
echo ""; \
echo "📦 Publishing to npm..."; \
npm publish --access public; \
echo ""; \
echo "✅ Published @authorizerdev/authorizer-react@$$VERSION to npm!"
# Pre-publish checks
prepublish: clean build type-check lint
@echo "✅ All pre-publish checks passed!"
# Full release workflow (for stable releases)
full-release-patch: prepublish release-patch
@echo "✅ Full patch release workflow complete!"
full-release-minor: prepublish release-minor
@echo "✅ Full minor release workflow complete!"
full-release-major: prepublish release-major
@echo "✅ Full major release workflow complete!"