lechnerio-git-hooks 1.1.9 → 1.2.0

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.
package/hooks/post-commit CHANGED
@@ -86,11 +86,11 @@ bump_and_amend() {
86
86
  do_push() {
87
87
  echo -e "${YELLOW}✈️ Pushing to GitHub...${NC}"
88
88
  if [ "$DRY_RUN" = "true" ]; then
89
- echo -e "${YELLOW}[DRY RUN] Would execute: git push --follow-tags && git push --tags${NC}"
89
+ echo -e "${YELLOW}[DRY RUN] Would execute: git push --follow-tags${NC}"
90
90
  return
91
91
  fi
92
92
  typecheck_before_push || return
93
- git push --follow-tags && git push --tags
93
+ git push --follow-tags
94
94
  if [ $? -eq 0 ]; then
95
95
  echo -e "${GREEN}✅ Successfully pushed to GitHub${NC}"
96
96
  else
@@ -118,14 +118,14 @@ do_merge() {
118
118
  do_merge_and_push() {
119
119
  echo -e "${YELLOW}🔄 Merging to main + pushing...${NC}"
120
120
  if [ "$DRY_RUN" = "true" ]; then
121
- echo -e "${YELLOW}[DRY RUN] Would execute: git push --follow-tags && git push --tags${NC}"
121
+ echo -e "${YELLOW}[DRY RUN] Would execute: git push --follow-tags${NC}"
122
122
  echo -e "${YELLOW}[DRY RUN] Would execute: git checkout main && git pull && git merge <branch> && git push${NC}"
123
123
  return
124
124
  fi
125
125
  typecheck_before_push || return
126
126
  local current_branch=$(git branch --show-current)
127
127
  echo -e "${YELLOW}✈️ Pushing ${current_branch}...${NC}"
128
- if ! git push --follow-tags || ! git push --tags; then
128
+ if ! git push --follow-tags; then
129
129
  echo -e "${RED}❌ Failed to push ${current_branch}${NC}"
130
130
  return
131
131
  fi
package/hooks/pre-push ADDED
@@ -0,0 +1,35 @@
1
+ #!/bin/bash
2
+
3
+ RED='\033[0;31m'
4
+ GREEN='\033[0;32m'
5
+ YELLOW='\033[1;33m'
6
+ CYAN='\033[0;36m'
7
+ NC='\033[0m'
8
+
9
+ if [ ! -f "package.json" ]; then
10
+ exit 0
11
+ fi
12
+
13
+ has_test_script=$(node -p "!!(require('./package.json').scripts && require('./package.json').scripts.test)" 2>/dev/null)
14
+
15
+ if [ "$has_test_script" != "true" ]; then
16
+ echo -e "${YELLOW}⏭️ No test script found, skipping tests${NC}"
17
+ exit 0
18
+ fi
19
+
20
+ if [ -f "pnpm-lock.yaml" ]; then
21
+ pm="pnpm"
22
+ elif [ -f "yarn.lock" ]; then
23
+ pm="yarn"
24
+ else
25
+ pm="npm"
26
+ fi
27
+
28
+ echo -e "${CYAN}🧪 Running ${pm} test...${NC}"
29
+ if $pm test; then
30
+ echo -e "${GREEN}✅ Tests passed${NC}"
31
+ exit 0
32
+ else
33
+ echo -e "${RED}❌ Tests failed — push aborted${NC}"
34
+ exit 1
35
+ fi
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lechnerio-git-hooks",
3
- "version": "1.1.9",
3
+ "version": "1.2.0",
4
4
  "description": "Shared git hooks for lechnerio projects",
5
5
  "type": "module",
6
6
  "scripts": {
package/setup.mjs CHANGED
@@ -43,6 +43,7 @@ function copyWithLF(src, dest) {
43
43
 
44
44
  copyWithLF(resolve(hooksSource, "post-commit"), resolve(huskyDest, "post-commit"))
45
45
  copyWithLF(resolve(hooksSource, "pre-commit"), resolve(huskyDest, "pre-commit"))
46
+ copyWithLF(resolve(hooksSource, "pre-push"), resolve(huskyDest, "pre-push"))
46
47
  copyWithLF(resolve(hooksSource, "commit-msg"), resolve(huskyDest, "commit-msg"))
47
48
  copyWithLF(resolve(scriptsSource, "generate-changelog.mjs"), resolve(scriptsDest, "generate-changelog.mjs"))
48
49
  copyWithLF(resolve(configSource, "commitlint.config.js"), resolve(projectRoot, "commitlint.config.js"))