lechnerio-git-hooks 1.1.8 → 1.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/hooks/post-commit +303 -394
  2. package/package.json +1 -1
package/hooks/post-commit CHANGED
@@ -1,394 +1,303 @@
1
- #!/bin/bash
2
-
3
- RED='\033[0;31m'
4
- GREEN='\033[0;32m'
5
- YELLOW='\033[1;33m'
6
- BLUE='\033[0;34m'
7
- CYAN='\033[0;36m'
8
- GRAY='\033[0;90m'
9
- NC='\033[0m'
10
-
11
- if [ "$_SKIP_POST_COMMIT" = "1" ]; then
12
- exit 0
13
- fi
14
- export _SKIP_POST_COMMIT=1
15
-
16
- DRY_RUN=${1:-false}
17
-
18
- get_version() {
19
- node -p "require('./package.json').version"
20
- }
21
-
22
- get_subpatch() {
23
- local ver=$(get_version)
24
- if [[ "$ver" =~ ^[0-9]+\.[0-9]+\.[0-9]+([a-z])$ ]]; then
25
- echo "${BASH_REMATCH[1]}"
26
- else
27
- echo ""
28
- fi
29
- }
30
-
31
- get_base_version() {
32
- local ver=$(get_version)
33
- echo "$ver" | sed 's/[a-z]$//'
34
- }
35
-
36
- next_subpatch() {
37
- local current_sub=$(get_subpatch)
38
- if [ -z "$current_sub" ]; then
39
- echo "a"
40
- else
41
- echo "$current_sub" | tr 'a-y' 'b-z'
42
- fi
43
- }
44
-
45
- set_version() {
46
- local new_ver="$1"
47
- node -e "
48
- const fs = require('fs');
49
- const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
50
- pkg.version = '$new_ver';
51
- fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');
52
- "
53
- }
54
-
55
- bump_and_amend() {
56
- local new_ver="$1"
57
- local label="$2"
58
- set_version "$new_ver"
59
- git add package.json
60
- git commit --amend --no-edit
61
- git tag -f -a "v${new_ver}" -m "v${new_ver}"
62
- node scripts/generate-changelog.mjs 2>/dev/null
63
- git add data/changelog.json
64
- git commit --amend --no-edit --no-verify
65
- git tag -f -a "v${new_ver}" -m "v${new_ver}"
66
- echo -e "${GREEN}✅ $label version bumped to ${new_ver}${NC}"
67
- }
68
-
69
- commit_message=$(git log -1 --pretty=%B)
70
- if [[ "$commit_message" == *"Bump version"* ]] || [[ "$commit_message" == *"bump version"* ]]; then
71
- echo -e "${YELLOW}⏭️ Skipping post-commit actions for version bump commit${NC}"
72
- exit 0
73
- fi
74
-
75
- echo
76
- echo -e "${GREEN}🎉 Commit completed successfully!${NC}"
77
- echo
78
-
79
- node scripts/generate-changelog.mjs 2>/dev/null
80
- if ! git diff --quiet data/changelog.json 2>/dev/null; then
81
- git add data/changelog.json
82
- git commit --amend --no-edit --no-verify
83
- echo -e "${CYAN}📋 Changelog updated${NC}"
84
- echo
85
- fi
86
-
87
- files_changed=$(git diff --name-only HEAD~1 HEAD 2>/dev/null | wc -l)
88
- lines_changed=$(git diff --shortstat HEAD~1 HEAD 2>/dev/null)
89
-
90
- if [ "$files_changed" -eq 0 ] || [ -z "$lines_changed" ]; then
91
- echo -e "${YELLOW}⚠️ No file changes detected in this commit.${NC}"
92
- echo -e "${YELLOW}⏭️ Skipping version bump.${NC}"
93
- echo
94
-
95
- if [ -n "$POST_ACTION" ]; then
96
- choice="$POST_ACTION"
97
- elif exec < /dev/tty 2>/dev/null; then
98
- echo -e "${CYAN}What would you like to do next?${NC}"
99
- echo
100
- echo "1) Push to GitHub"
101
- echo "2) Merge to Main"
102
- echo "3) Merge to Main + Push"
103
- echo -e "${GRAY}0) None${NC}"
104
- echo
105
- echo -n "Select option (1-3, Enter for Default or 0 to skip): "
106
- read -r choice
107
- choice=${choice:-1}
108
- else
109
- choice=0
110
- fi
111
- echo
112
-
113
- case $choice in
114
- 1)
115
- echo -e "${YELLOW}✈️ Pushing to GitHub...${NC}"
116
- if [ "$DRY_RUN" = "true" ]; then
117
- echo -e "${YELLOW}[DRY RUN] Would execute: git push${NC}"
118
- else
119
- git push --follow-tags && git push --tags
120
- if [ $? -eq 0 ]; then
121
- echo -e "${GREEN} Successfully pushed to GitHub${NC}"
122
- else
123
- echo -e "${RED}❌ Failed to push to GitHub${NC}"
124
- fi
125
- fi
126
- ;;
127
- 2)
128
- echo -e "${YELLOW}🔄 Merging to main...${NC}"
129
- if [ "$DRY_RUN" = "true" ]; then
130
- echo -e "${YELLOW}[DRY RUN] Would execute: git checkout main && git merge $(git branch --show-current)${NC}"
131
- else
132
- current_branch=$(git branch --show-current)
133
- git checkout main
134
- git merge "$current_branch"
135
- if [ $? -eq 0 ]; then
136
- echo -e "${GREEN}✅ Successfully merged to main${NC}"
137
- git checkout "$current_branch"
138
- else
139
- echo -e "${RED}❌ Failed to merge to main${NC}"
140
- git checkout "$current_branch"
141
- fi
142
- fi
143
- ;;
144
- 3)
145
- echo -e "${YELLOW}🔄 Merging to main + pushing...${NC}"
146
- if [ "$DRY_RUN" = "true" ]; then
147
- echo -e "${YELLOW}[DRY RUN] Would execute: git push --follow-tags && git push --tags${NC}"
148
- echo -e "${YELLOW}[DRY RUN] Would execute: git checkout main && git pull && git merge $(git branch --show-current) && git push${NC}"
149
- echo -e "${YELLOW}[DRY RUN] Would execute: git checkout $(git branch --show-current)${NC}"
150
- else
151
- current_branch=$(git branch --show-current)
152
- _merge_push_ok=true
153
- echo -e "${YELLOW}✈️ Pushing ${current_branch}...${NC}"
154
- if ! git push --follow-tags || ! git push --tags; then
155
- echo -e "${RED} Failed to push ${current_branch}${NC}"
156
- _merge_push_ok=false
157
- fi
158
- if [ "$_merge_push_ok" = true ]; then
159
- echo -e "${GREEN}✅ Pushed ${current_branch}${NC}"
160
- if ! git checkout main; then
161
- echo -e "${RED}❌ Failed to checkout main${NC}"
162
- _merge_push_ok=false
163
- fi
164
- fi
165
- if [ "$_merge_push_ok" = true ]; then
166
- if ! git pull; then
167
- echo -e "${RED}❌ Failed to pull main${NC}"
168
- git checkout "$current_branch"
169
- _merge_push_ok=false
170
- fi
171
- fi
172
- if [ "$_merge_push_ok" = true ]; then
173
- if ! git merge "$current_branch"; then
174
- echo -e "${RED}❌ Failed to merge ${current_branch} into main${NC}"
175
- git checkout "$current_branch"
176
- _merge_push_ok=false
177
- fi
178
- fi
179
- if [ "$_merge_push_ok" = true ]; then
180
- echo -e "${GREEN}✅ Merged ${current_branch} into main${NC}"
181
- if ! git push; then
182
- echo -e "${RED} Failed to push main${NC}"
183
- git checkout "$current_branch"
184
- _merge_push_ok=false
185
- fi
186
- fi
187
- if [ "$_merge_push_ok" = true ]; then
188
- echo -e "${GREEN}✅ Pushed main${NC}"
189
- git checkout "$current_branch"
190
- echo -e "${GREEN}✅ Back on ${current_branch}${NC}"
191
- fi
192
- fi
193
- ;;
194
- 0)
195
- echo -e "${YELLOW}⏭️ Skipping additional actions${NC}"
196
- ;;
197
- esac
198
- echo
199
- exit 0
200
- fi
201
-
202
- echo -e "${BLUE}📝 Changes in this commit:${NC}"
203
- echo -e "${YELLOW}$lines_changed${NC}"
204
- echo
205
-
206
- current_ver=$(get_version)
207
- base_ver=$(get_base_version)
208
- sub=$(get_subpatch)
209
- next_sub=$(next_subpatch)
210
-
211
- IFS='.' read -r major minor patch_raw <<< "$base_ver"
212
- patch=$((patch_raw))
213
- next_patch=$((patch + 1))
214
- next_minor=$((minor + 1))
215
- next_major=$((major + 1))
216
-
217
- subtle_ver="${base_ver}${next_sub}"
218
- patch_ver="${major}.${minor}.${next_patch}"
219
- minor_ver="${major}.${next_minor}.0"
220
- major_ver="${next_major}.0.0"
221
-
222
- if [ -n "$VERSION_BUMP" ]; then
223
- version_choice="$VERSION_BUMP"
224
- elif exec < /dev/tty 2>/dev/null; then
225
- echo -e "${CYAN}What version bump would you like to apply?${NC}"
226
- echo
227
- echo -e "1) Subtle Bump ${YELLOW}(default)${NC} ${GRAY}${current_ver} -> ${subtle_ver}${NC} - typos, formatting, comments, etc."
228
- echo -e "2) Bump Patch ${GRAY}${current_ver} -> ${patch_ver}${NC} - bug fixes, small changes"
229
- echo -e "3) Bump Minor ${GRAY}${current_ver} -> ${minor_ver}${NC} - new features, backwards compatible"
230
- echo -e "4) Bump Major ${GRAY}${current_ver} -> ${major_ver}${NC} - breaking changes"
231
- echo -e "${GRAY}0) Nothing - skip version bump${NC}"
232
- echo
233
- echo -n "Select option (1-4, Enter for Default or 0 to skip): "
234
- read -r version_choice
235
- version_choice=${version_choice:-1}
236
- else
237
- echo -e "${YELLOW}⏭️ No TTY available and VERSION_BUMP not set, skipping version bump${NC}"
238
- version_choice=0
239
- fi
240
-
241
- echo
242
-
243
- case $version_choice in
244
- 1)
245
- echo -e "${YELLOW}📦 Subtle bump...${NC}"
246
- if [ "$DRY_RUN" = "true" ]; then
247
- echo -e "${YELLOW}[DRY RUN] Would bump to ${subtle_ver}${NC}"
248
- else
249
- bump_and_amend "$subtle_ver" "Subtle"
250
- fi
251
- ;;
252
- 2)
253
- echo -e "${YELLOW}📦 Bumping patch version...${NC}"
254
- if [ "$DRY_RUN" = "true" ]; then
255
- echo -e "${YELLOW}[DRY RUN] Would bump to ${patch_ver}${NC}"
256
- else
257
- bump_and_amend "$patch_ver" "Patch"
258
- fi
259
- ;;
260
- 3)
261
- echo -e "${YELLOW}📦 Bumping minor version...${NC}"
262
- if [ "$DRY_RUN" = "true" ]; then
263
- echo -e "${YELLOW}[DRY RUN] Would bump to ${minor_ver}${NC}"
264
- else
265
- bump_and_amend "$minor_ver" "Minor"
266
- fi
267
- ;;
268
- 4)
269
- echo -e "${YELLOW}📦 Bumping major version...${NC}"
270
- if [ "$DRY_RUN" = "true" ]; then
271
- echo -e "${YELLOW}[DRY RUN] Would bump to ${major_ver}${NC}"
272
- else
273
- bump_and_amend "$major_ver" "Major"
274
- fi
275
- ;;
276
- 0)
277
- echo -e "${YELLOW}⏭️ Skipping version bump${NC}"
278
- ;;
279
- *)
280
- echo -e "${RED} Invalid option. Skipping version bump${NC}"
281
- ;;
282
- esac
283
-
284
- echo
285
-
286
- if [ -n "$POST_ACTION" ]; then
287
- choice="$POST_ACTION"
288
- elif exec < /dev/tty 2>/dev/null; then
289
- echo -e "${CYAN}What would you like to do next?${NC}"
290
- echo
291
- echo -e "1) Push to GitHub ${YELLOW}(default)${NC}"
292
- echo "2) Merge to Main"
293
- echo "3) Merge to Main + Push"
294
- echo -e "${GRAY}0) None${NC}"
295
- echo
296
- echo -n "Select option (1-3, Enter for Default or 0 to skip): "
297
- read -r choice
298
- choice=${choice:-1}
299
- else
300
- choice=0
301
- fi
302
-
303
- echo
304
-
305
- case $choice in
306
- 1)
307
- echo -e "${YELLOW}✈️ Pushing to GitHub...${NC}"
308
- if [ "$DRY_RUN" = "true" ]; then
309
- echo -e "${YELLOW}[DRY RUN] Would execute: git push --follow-tags && git push --tags${NC}"
310
- else
311
- git push --follow-tags && git push --tags
312
- if [ $? -eq 0 ]; then
313
- echo -e "${GREEN}✅ Successfully pushed to GitHub${NC}"
314
- else
315
- echo -e "${RED}❌ Failed to push to GitHub${NC}"
316
- fi
317
- fi
318
- ;;
319
- 2)
320
- echo -e "${YELLOW}🔄 Merging to main...${NC}"
321
- if [ "$DRY_RUN" = "true" ]; then
322
- echo -e "${YELLOW}[DRY RUN] Would execute: git checkout main && git merge $(git branch --show-current)${NC}"
323
- else
324
- current_branch=$(git branch --show-current)
325
- git checkout main
326
- git merge "$current_branch"
327
- if [ $? -eq 0 ]; then
328
- echo -e "${GREEN}✅ Successfully merged to main${NC}"
329
- git checkout "$current_branch"
330
- else
331
- echo -e "${RED}❌ Failed to merge to main${NC}"
332
- git checkout "$current_branch"
333
- fi
334
- fi
335
- ;;
336
- 3)
337
- echo -e "${YELLOW}🔄 Merging to main + pushing...${NC}"
338
- if [ "$DRY_RUN" = "true" ]; then
339
- echo -e "${YELLOW}[DRY RUN] Would execute: git push --follow-tags && git push --tags${NC}"
340
- echo -e "${YELLOW}[DRY RUN] Would execute: git checkout main && git pull && git merge $(git branch --show-current) && git push${NC}"
341
- echo -e "${YELLOW}[DRY RUN] Would execute: git checkout $(git branch --show-current)${NC}"
342
- else
343
- current_branch=$(git branch --show-current)
344
- _merge_push_ok=true
345
- echo -e "${YELLOW}✈️ Pushing ${current_branch}...${NC}"
346
- if ! git push --follow-tags || ! git push --tags; then
347
- echo -e "${RED}❌ Failed to push ${current_branch}${NC}"
348
- _merge_push_ok=false
349
- fi
350
- if [ "$_merge_push_ok" = true ]; then
351
- echo -e "${GREEN}✅ Pushed ${current_branch}${NC}"
352
- if ! git checkout main; then
353
- echo -e "${RED}❌ Failed to checkout main${NC}"
354
- _merge_push_ok=false
355
- fi
356
- fi
357
- if [ "$_merge_push_ok" = true ]; then
358
- if ! git pull; then
359
- echo -e "${RED}❌ Failed to pull main${NC}"
360
- git checkout "$current_branch"
361
- _merge_push_ok=false
362
- fi
363
- fi
364
- if [ "$_merge_push_ok" = true ]; then
365
- if ! git merge "$current_branch"; then
366
- echo -e "${RED}❌ Failed to merge ${current_branch} into main${NC}"
367
- git checkout "$current_branch"
368
- _merge_push_ok=false
369
- fi
370
- fi
371
- if [ "$_merge_push_ok" = true ]; then
372
- echo -e "${GREEN}✅ Merged ${current_branch} into main${NC}"
373
- if ! git push; then
374
- echo -e "${RED}❌ Failed to push main${NC}"
375
- git checkout "$current_branch"
376
- _merge_push_ok=false
377
- fi
378
- fi
379
- if [ "$_merge_push_ok" = true ]; then
380
- echo -e "${GREEN}✅ Pushed main${NC}"
381
- git checkout "$current_branch"
382
- echo -e "${GREEN}✅ Back on ${current_branch}${NC}"
383
- fi
384
- fi
385
- ;;
386
- 0)
387
- echo -e "${YELLOW}⏭️ Skipping additional actions${NC}"
388
- ;;
389
- *)
390
- echo -e "${RED}❌ Invalid option. Skipping additional actions${NC}"
391
- ;;
392
- esac
393
-
394
- echo
1
+ #!/bin/bash
2
+
3
+ RED='\033[0;31m'
4
+ GREEN='\033[0;32m'
5
+ YELLOW='\033[1;33m'
6
+ BLUE='\033[0;34m'
7
+ CYAN='\033[0;36m'
8
+ GRAY='\033[0;90m'
9
+ NC='\033[0m'
10
+
11
+ if [ "$_SKIP_POST_COMMIT" = "1" ]; then
12
+ exit 0
13
+ fi
14
+ export _SKIP_POST_COMMIT=1
15
+
16
+ DRY_RUN=${1:-false}
17
+
18
+ # --- utility functions ---
19
+
20
+ typecheck_before_push() {
21
+ if [ ! -f "tsconfig.json" ]; then
22
+ return 0
23
+ fi
24
+ echo -e "${CYAN}🔍 Running type check before push...${NC}"
25
+ if npx tsc --noEmit 2>&1; then
26
+ echo -e "${GREEN}✅ Type check passed${NC}"
27
+ return 0
28
+ else
29
+ echo -e "${RED}❌ Type check failed — push aborted${NC}"
30
+ echo -e "${YELLOW}Fix the errors above and try again.${NC}"
31
+ return 1
32
+ fi
33
+ }
34
+
35
+ get_version() {
36
+ node -p "require('./package.json').version"
37
+ }
38
+
39
+ get_subpatch() {
40
+ local ver=$(get_version)
41
+ if [[ "$ver" =~ ^[0-9]+\.[0-9]+\.[0-9]+([a-z])$ ]]; then
42
+ echo "${BASH_REMATCH[1]}"
43
+ else
44
+ echo ""
45
+ fi
46
+ }
47
+
48
+ get_base_version() {
49
+ local ver=$(get_version)
50
+ echo "$ver" | sed 's/[a-z]$//'
51
+ }
52
+
53
+ next_subpatch() {
54
+ local current_sub=$(get_subpatch)
55
+ if [ -z "$current_sub" ]; then
56
+ echo "a"
57
+ else
58
+ echo "$current_sub" | tr 'a-y' 'b-z'
59
+ fi
60
+ }
61
+
62
+ set_version() {
63
+ local new_ver="$1"
64
+ node -e "
65
+ const fs = require('fs');
66
+ const pkg = JSON.parse(fs.readFileSync('package.json', 'utf8'));
67
+ pkg.version = '$new_ver';
68
+ fs.writeFileSync('package.json', JSON.stringify(pkg, null, 2) + '\n');
69
+ "
70
+ }
71
+
72
+ bump_and_amend() {
73
+ local new_ver="$1"
74
+ local label="$2"
75
+ set_version "$new_ver"
76
+ git add package.json
77
+ git commit --amend --no-edit
78
+ git tag -f -a "v${new_ver}" -m "v${new_ver}"
79
+ node scripts/generate-changelog.mjs 2>/dev/null
80
+ git add data/changelog.json
81
+ git commit --amend --no-edit --no-verify
82
+ git tag -f -a "v${new_ver}" -m "v${new_ver}"
83
+ echo -e "${GREEN} $label version bumped to ${new_ver}${NC}"
84
+ }
85
+
86
+ do_push() {
87
+ echo -e "${YELLOW}✈️ Pushing to GitHub...${NC}"
88
+ if [ "$DRY_RUN" = "true" ]; then
89
+ echo -e "${YELLOW}[DRY RUN] Would execute: git push --follow-tags && git push --tags${NC}"
90
+ return
91
+ fi
92
+ typecheck_before_push || return
93
+ git push --follow-tags && git push --tags
94
+ if [ $? -eq 0 ]; then
95
+ echo -e "${GREEN}✅ Successfully pushed to GitHub${NC}"
96
+ else
97
+ echo -e "${RED}❌ Failed to push to GitHub${NC}"
98
+ fi
99
+ }
100
+
101
+ do_merge() {
102
+ echo -e "${YELLOW}🔄 Merging to main...${NC}"
103
+ if [ "$DRY_RUN" = "true" ]; then
104
+ echo -e "${YELLOW}[DRY RUN] Would execute: git checkout main && git merge $(git branch --show-current)${NC}"
105
+ return
106
+ fi
107
+ local current_branch=$(git branch --show-current)
108
+ git checkout main
109
+ git merge "$current_branch"
110
+ if [ $? -eq 0 ]; then
111
+ echo -e "${GREEN}✅ Successfully merged to main${NC}"
112
+ else
113
+ echo -e "${RED}❌ Failed to merge to main${NC}"
114
+ fi
115
+ git checkout "$current_branch"
116
+ }
117
+
118
+ do_merge_and_push() {
119
+ echo -e "${YELLOW}🔄 Merging to main + pushing...${NC}"
120
+ if [ "$DRY_RUN" = "true" ]; then
121
+ echo -e "${YELLOW}[DRY RUN] Would execute: git push --follow-tags && git push --tags${NC}"
122
+ echo -e "${YELLOW}[DRY RUN] Would execute: git checkout main && git pull && git merge <branch> && git push${NC}"
123
+ return
124
+ fi
125
+ typecheck_before_push || return
126
+ local current_branch=$(git branch --show-current)
127
+ echo -e "${YELLOW}✈️ Pushing ${current_branch}...${NC}"
128
+ if ! git push --follow-tags || ! git push --tags; then
129
+ echo -e "${RED}❌ Failed to push ${current_branch}${NC}"
130
+ return
131
+ fi
132
+ echo -e "${GREEN}✅ Pushed ${current_branch}${NC}"
133
+ if ! git checkout main; then
134
+ echo -e "${RED}❌ Failed to checkout main${NC}"
135
+ return
136
+ fi
137
+ if ! git pull; then
138
+ echo -e "${RED}❌ Failed to pull main${NC}"
139
+ git checkout "$current_branch"
140
+ return
141
+ fi
142
+ if ! git merge "$current_branch"; then
143
+ echo -e "${RED}❌ Failed to merge ${current_branch} into main${NC}"
144
+ git checkout "$current_branch"
145
+ return
146
+ fi
147
+ echo -e "${GREEN} Merged ${current_branch} into main${NC}"
148
+ if ! git push; then
149
+ echo -e "${RED} Failed to push main${NC}"
150
+ git checkout "$current_branch"
151
+ return
152
+ fi
153
+ echo -e "${GREEN} Pushed main${NC}"
154
+ git checkout "$current_branch"
155
+ echo -e "${GREEN} Back on ${current_branch}${NC}"
156
+ }
157
+
158
+ run_post_action() {
159
+ local choice
160
+ if [ -n "$POST_ACTION" ]; then
161
+ choice="$POST_ACTION"
162
+ elif exec < /dev/tty 2>/dev/null; then
163
+ echo -e "${CYAN}What would you like to do next?${NC}"
164
+ echo
165
+ echo -e "1) Push to GitHub ${YELLOW}(default)${NC}"
166
+ echo "2) Merge to Main"
167
+ echo "3) Merge to Main + Push"
168
+ echo -e "${GRAY}0) None${NC}"
169
+ echo
170
+ echo -n "Select option (1-3, Enter for Default or 0 to skip): "
171
+ read -r choice
172
+ choice=${choice:-1}
173
+ else
174
+ choice=0
175
+ fi
176
+ echo
177
+
178
+ case $choice in
179
+ 1) do_push ;;
180
+ 2) do_merge ;;
181
+ 3) do_merge_and_push ;;
182
+ 0) echo -e "${YELLOW}⏭️ Skipping additional actions${NC}" ;;
183
+ *) echo -e "${RED}❌ Invalid option. Skipping additional actions${NC}" ;;
184
+ esac
185
+ echo
186
+ }
187
+
188
+ # --- main flow ---
189
+
190
+ commit_message=$(git log -1 --pretty=%B)
191
+ if [[ "$commit_message" == *"Bump version"* ]] || [[ "$commit_message" == *"bump version"* ]]; then
192
+ echo -e "${YELLOW}⏭️ Skipping post-commit actions for version bump commit${NC}"
193
+ exit 0
194
+ fi
195
+
196
+ echo
197
+ echo -e "${GREEN}🎉 Commit completed successfully!${NC}"
198
+ echo
199
+
200
+ node scripts/generate-changelog.mjs 2>/dev/null
201
+ if ! git diff --quiet data/changelog.json 2>/dev/null; then
202
+ git add data/changelog.json
203
+ git commit --amend --no-edit --no-verify
204
+ echo -e "${CYAN}📋 Changelog updated${NC}"
205
+ echo
206
+ fi
207
+
208
+ files_changed=$(git diff --name-only HEAD~1 HEAD 2>/dev/null | wc -l)
209
+ lines_changed=$(git diff --shortstat HEAD~1 HEAD 2>/dev/null)
210
+
211
+ if [ "$files_changed" -eq 0 ] || [ -z "$lines_changed" ]; then
212
+ echo -e "${YELLOW}⚠️ No file changes detected in this commit.${NC}"
213
+ echo -e "${YELLOW}⏭️ Skipping version bump.${NC}"
214
+ echo
215
+ run_post_action
216
+ exit 0
217
+ fi
218
+
219
+ echo -e "${BLUE}📝 Changes in this commit:${NC}"
220
+ echo -e "${YELLOW}$lines_changed${NC}"
221
+ echo
222
+
223
+ current_ver=$(get_version)
224
+ base_ver=$(get_base_version)
225
+ sub=$(get_subpatch)
226
+ next_sub=$(next_subpatch)
227
+
228
+ IFS='.' read -r major minor patch_raw <<< "$base_ver"
229
+ patch=$((patch_raw))
230
+ next_patch=$((patch + 1))
231
+ next_minor=$((minor + 1))
232
+ next_major=$((major + 1))
233
+
234
+ subtle_ver="${base_ver}${next_sub}"
235
+ patch_ver="${major}.${minor}.${next_patch}"
236
+ minor_ver="${major}.${next_minor}.0"
237
+ major_ver="${next_major}.0.0"
238
+
239
+ if [ -n "$VERSION_BUMP" ]; then
240
+ version_choice="$VERSION_BUMP"
241
+ elif exec < /dev/tty 2>/dev/null; then
242
+ echo -e "${CYAN}What version bump would you like to apply?${NC}"
243
+ echo
244
+ echo -e "1) Subtle Bump ${YELLOW}(default)${NC} ${GRAY}${current_ver} -> ${subtle_ver}${NC} - typos, formatting, comments, etc."
245
+ echo -e "2) Bump Patch ${GRAY}${current_ver} -> ${patch_ver}${NC} - bug fixes, small changes"
246
+ echo -e "3) Bump Minor ${GRAY}${current_ver} -> ${minor_ver}${NC} - new features, backwards compatible"
247
+ echo -e "4) Bump Major ${GRAY}${current_ver} -> ${major_ver}${NC} - breaking changes"
248
+ echo -e "${GRAY}0) Nothing - skip version bump${NC}"
249
+ echo
250
+ echo -n "Select option (1-4, Enter for Default or 0 to skip): "
251
+ read -r version_choice
252
+ version_choice=${version_choice:-1}
253
+ else
254
+ echo -e "${YELLOW}⏭️ No TTY available and VERSION_BUMP not set, skipping version bump${NC}"
255
+ version_choice=0
256
+ fi
257
+
258
+ echo
259
+
260
+ case $version_choice in
261
+ 1)
262
+ echo -e "${YELLOW}📦 Subtle bump...${NC}"
263
+ if [ "$DRY_RUN" = "true" ]; then
264
+ echo -e "${YELLOW}[DRY RUN] Would bump to ${subtle_ver}${NC}"
265
+ else
266
+ bump_and_amend "$subtle_ver" "Subtle"
267
+ fi
268
+ ;;
269
+ 2)
270
+ echo -e "${YELLOW}📦 Bumping patch version...${NC}"
271
+ if [ "$DRY_RUN" = "true" ]; then
272
+ echo -e "${YELLOW}[DRY RUN] Would bump to ${patch_ver}${NC}"
273
+ else
274
+ bump_and_amend "$patch_ver" "Patch"
275
+ fi
276
+ ;;
277
+ 3)
278
+ echo -e "${YELLOW}📦 Bumping minor version...${NC}"
279
+ if [ "$DRY_RUN" = "true" ]; then
280
+ echo -e "${YELLOW}[DRY RUN] Would bump to ${minor_ver}${NC}"
281
+ else
282
+ bump_and_amend "$minor_ver" "Minor"
283
+ fi
284
+ ;;
285
+ 4)
286
+ echo -e "${YELLOW}📦 Bumping major version...${NC}"
287
+ if [ "$DRY_RUN" = "true" ]; then
288
+ echo -e "${YELLOW}[DRY RUN] Would bump to ${major_ver}${NC}"
289
+ else
290
+ bump_and_amend "$major_ver" "Major"
291
+ fi
292
+ ;;
293
+ 0)
294
+ echo -e "${YELLOW}⏭️ Skipping version bump${NC}"
295
+ ;;
296
+ *)
297
+ echo -e "${RED}❌ Invalid option. Skipping version bump${NC}"
298
+ ;;
299
+ esac
300
+
301
+ echo
302
+
303
+ run_post_action
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lechnerio-git-hooks",
3
- "version": "1.1.8",
3
+ "version": "1.1.9",
4
4
  "description": "Shared git hooks for lechnerio projects",
5
5
  "type": "module",
6
6
  "scripts": {