@zairakai/js-dev-tools 3.19.0 → 3.21.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.
Files changed (48) hide show
  1. package/.editorconfig +6 -72
  2. package/.gitlab/ci/parts/base.yml +95 -0
  3. package/.gitlab/ci/parts/publish.yml +156 -0
  4. package/.gitlab/ci/parts/quality.yml +161 -0
  5. package/.gitlab/ci/parts/security.yml +40 -0
  6. package/.gitlab/ci/parts/updates.yml +60 -0
  7. package/.gitlab/ci/pipeline-js-app.yml +19 -38
  8. package/.gitlab/ci/pipeline-js-package.yml +23 -528
  9. package/README.md +51 -6
  10. package/config/.markdownlintignore +9 -1
  11. package/config/.prettierignore +8 -0
  12. package/config/.stylelintignore +7 -0
  13. package/config/eslint.config.js +7 -1
  14. package/config/knip.config.js +2 -2
  15. package/package.json +33 -29
  16. package/scripts/build.sh +28 -28
  17. package/scripts/ci-quality.sh +6 -6
  18. package/scripts/config.sh +164 -148
  19. package/scripts/doctor.sh +12 -12
  20. package/scripts/eslint-fix.sh +8 -8
  21. package/scripts/eslint.sh +15 -15
  22. package/scripts/install-bats.sh +143 -146
  23. package/scripts/install-hooks.sh +108 -111
  24. package/scripts/install-markdownlint.sh +4 -4
  25. package/scripts/install-shellcheck.sh +135 -138
  26. package/scripts/knip.sh +7 -7
  27. package/scripts/markdownlint.sh +38 -38
  28. package/scripts/outdated.sh +30 -29
  29. package/scripts/prettier-fix.sh +13 -13
  30. package/scripts/prettier.sh +13 -13
  31. package/scripts/setup-project.sh +691 -629
  32. package/scripts/stylelint-fix.sh +17 -17
  33. package/scripts/stylelint.sh +18 -18
  34. package/scripts/test.sh +13 -11
  35. package/scripts/typecheck.sh +11 -11
  36. package/scripts/update-dependencies.mjs +68 -68
  37. package/scripts/validate-shellcheck.sh +18 -18
  38. package/stubs/githooks/commit-msg +18 -18
  39. package/stubs/githooks/pre-commit +19 -19
  40. package/stubs/githooks/pre-push +18 -18
  41. package/stubs/githooks/prepare-commit-msg +6 -6
  42. package/stubs/gitlab-ci/gitlab-ci.yml.stub +1 -1
  43. package/stubs/governance/CONTRIBUTING.md.stub +5 -3
  44. package/stubs/quality/eslint.config.js.stub +1 -1
  45. package/stubs/quality/knip.config.js.stub +1 -1
  46. package/stubs/style/prettier.config.js.stub +3 -3
  47. package/stubs/style/stylelint.config.js.stub +1 -1
  48. package/stubs/testing/vitest.config.js.stub +1 -1
@@ -15,213 +15,210 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
15
15
  # shellcheck disable=SC1091
16
16
  source "${SCRIPT_DIR}/config.sh"
17
17
 
18
- # ============================================================================
19
18
  # Configuration
20
- # ============================================================================
19
+ # ================
21
20
 
22
21
  CI_MODE="${CI:-false}"
23
22
  TOOL_VERSIONS_FILE="${DEV_TOOLS_ROOT}/.tool-versions"
24
23
  INSTALL_DIR="${HOME}/.local/share/bats"
25
24
  BIN_DIR="${HOME}/.local/bin"
26
25
 
27
- # ============================================================================
28
26
  # Helpers
29
- # ============================================================================
27
+ # ================
30
28
 
31
29
  get_bats_version() {
32
- local version=""
30
+ local version=""
33
31
 
34
- if [[ -f "${TOOL_VERSIONS_FILE}" ]]; then
35
- version="$(grep "^bats=" "${TOOL_VERSIONS_FILE}" | awk -F "=" '{print $2}' || echo "")"
36
- if [[ -n "${version}" ]]; then
37
- log_info "Found .tool-versions: ${version}"
38
- fi
32
+ if [[ -f "${TOOL_VERSIONS_FILE}" ]]; then
33
+ version="$(grep "^bats=" "${TOOL_VERSIONS_FILE}" | awk -F "=" '{print $2}' || echo "")"
34
+ if [[ -n "${version}" ]]; then
35
+ log_info "Found .tool-versions: ${version}"
39
36
  fi
37
+ fi
40
38
 
41
- if [[ -z "${version}" ]]; then
42
- version="1.11.0"
43
- log_info "Using default version: ${version}"
44
- fi
39
+ if [[ -z "${version}" ]]; then
40
+ version="1.11.0"
41
+ log_info "Using default version: ${version}"
42
+ fi
45
43
 
46
- if [[ ! "${version}" =~ ^v ]]; then
47
- version="v${version}"
48
- fi
44
+ if [[ ! "${version}" =~ ^v ]]; then
45
+ version="v${version}"
46
+ fi
49
47
 
50
- echo "${version}"
48
+ echo "${version}"
51
49
  }
52
50
 
53
51
  version_ge() {
54
- local ver1="${1#v}"
55
- local ver2="${2#v}"
52
+ local ver1="${1#v}"
53
+ local ver2="${2#v}"
56
54
 
57
- if [[ "${ver1}" == "${ver2}" ]]; then
58
- return 0
59
- fi
55
+ if [[ "${ver1}" == "${ver2}" ]]; then
56
+ return 0
57
+ fi
60
58
 
61
- local IFS=.
62
- # shellcheck disable=SC2206
63
- local ver1_arr=($ver1) ver2_arr=($ver2)
59
+ local IFS=.
60
+ # shellcheck disable=SC2206
61
+ local ver1_arr=($ver1) ver2_arr=($ver2)
64
62
 
65
- local i
66
- for ((i=${#ver1_arr[@]}; i<${#ver2_arr[@]}; i++)); do
67
- ver1_arr[i]=0
68
- done
63
+ local i
64
+ for ((i=${#ver1_arr[@]}; i<${#ver2_arr[@]}; i++)); do
65
+ ver1_arr[i]=0
66
+ done
69
67
 
70
- for ((i=0; i<${#ver1_arr[@]}; i++)); do
71
- if [[ -z "${ver2_arr[i]:-}" ]]; then
72
- ver2_arr[i]=0
73
- fi
68
+ for ((i=0; i<${#ver1_arr[@]}; i++)); do
69
+ if [[ -z "${ver2_arr[i]:-}" ]]; then
70
+ ver2_arr[i]=0
71
+ fi
74
72
 
75
- if ((10#${ver1_arr[i]} > 10#${ver2_arr[i]})); then
76
- return 0
77
- fi
73
+ if ((10#${ver1_arr[i]} > 10#${ver2_arr[i]})); then
74
+ return 0
75
+ fi
78
76
 
79
- if ((10#${ver1_arr[i]} < 10#${ver2_arr[i]})); then
80
- return 1
81
- fi
82
- done
77
+ if ((10#${ver1_arr[i]} < 10#${ver2_arr[i]})); then
78
+ return 1
79
+ fi
80
+ done
83
81
 
84
- return 0
82
+ return 0
85
83
  }
86
84
 
87
85
  check_bats_installed() {
88
- local required_version="$1"
86
+ local required_version="$1"
89
87
 
90
- if ! command_exists bats; then
91
- return 1
92
- fi
88
+ if ! command_exists bats; then
89
+ return 1
90
+ fi
93
91
 
94
- local current_version
95
- current_version="$(bats --version 2>/dev/null | awk '{print $2}' || echo "")"
92
+ local current_version
93
+ current_version="$(bats --version 2>/dev/null | awk '{print $2}' || echo "")"
96
94
 
97
- if [[ -z "${current_version}" ]]; then
98
- log_warning "Could not determine BATS version"
99
- return 1
100
- fi
95
+ if [[ -z "${current_version}" ]]; then
96
+ log_warning "Could not determine BATS version"
97
+ return 1
98
+ fi
101
99
 
102
- log_info "Current version: ${current_version}"
100
+ log_info "Current version: ${current_version}"
103
101
 
104
- if version_ge "${current_version}" "${required_version}"; then
105
- log_success "BATS ${current_version} is sufficient (need >=${required_version})"
106
- return 0
107
- fi
102
+ if version_ge "${current_version}" "${required_version}"; then
103
+ log_success "BATS ${current_version} is sufficient (need >=${required_version})"
104
+ return 0
105
+ fi
108
106
 
109
- log_warning "Version ${current_version} is outdated (need >=${required_version})"
107
+ log_warning "Version ${current_version} is outdated (need >=${required_version})"
110
108
 
111
- if [[ "${CI_MODE}" != "true" ]]; then
112
- echo ""
113
- read -rp "Upgrade to ${required_version}? (y/N) " -n 1
114
- echo ""
109
+ if [[ "${CI_MODE}" != "true" ]]; then
110
+ echo ""
111
+ read -rp "Upgrade to ${required_version}? (y/N) " -n 1
112
+ echo ""
115
113
 
116
- if [[ ! $REPLY =~ ^[Yy]$ ]]; then
117
- log_info "Keeping existing installation"
118
- return 0
119
- fi
120
- else
121
- log_info "CI mode: upgrading automatically"
114
+ if [[ ! $REPLY =~ ^[Yy]$ ]]; then
115
+ log_info "Keeping existing installation"
116
+ return 0
122
117
  fi
118
+ else
119
+ log_info "CI mode: upgrading automatically"
120
+ fi
123
121
 
124
- return 1
122
+ return 1
125
123
  }
126
124
 
127
125
  install_bats_core() {
128
- local version="$1"
126
+ local version="$1"
129
127
 
130
- log_step "Installing BATS ${version} from source…"
131
- mkdir -p "${INSTALL_DIR}" "${BIN_DIR}"
128
+ log_step "Installing BATS ${version} from source…"
129
+ mkdir -p "${INSTALL_DIR}" "${BIN_DIR}"
132
130
 
133
- if [[ -d "${INSTALL_DIR}/bats-core" ]]; then
134
- log_info "BATS repository exists, updating…"
135
- git -C "${INSTALL_DIR}/bats-core" fetch --tags --quiet
136
- git -C "${INSTALL_DIR}/bats-core" checkout "${version}" --quiet
137
- else
138
- log_info "Cloning BATS repository…"
139
- git clone --quiet --depth 1 --branch "${version}" \
140
- https://github.com/bats-core/bats-core.git "${INSTALL_DIR}/bats-core"
141
- fi
131
+ if [[ -d "${INSTALL_DIR}/bats-core" ]]; then
132
+ log_info "BATS repository exists, updating…"
133
+ git -C "${INSTALL_DIR}/bats-core" fetch --tags --quiet
134
+ git -C "${INSTALL_DIR}/bats-core" checkout "${version}" --quiet
135
+ else
136
+ log_info "Cloning BATS repository…"
137
+ git clone --quiet --depth 1 --branch "${version}" \
138
+ https://github.com/bats-core/bats-core.git "${INSTALL_DIR}/bats-core"
139
+ fi
142
140
 
143
- "${INSTALL_DIR}/bats-core/install.sh" "${HOME}/.local"
144
- log_success "BATS core installed to: ${BIN_DIR}/bats"
145
-
146
- if [[ ":$PATH:" != *":${BIN_DIR}:"* ]]; then
147
- echo ""
148
- log_warning "${BIN_DIR} is not in your PATH"
149
- echo ""
150
- echo "Add this to your ~/.bashrc or ~/.zshrc:"
151
- echo ""
152
- echo -e " ${CYAN}export PATH=\"\${HOME}/.local/bin:\${PATH}\"${NC}"
153
- echo ""
154
- fi
141
+ "${INSTALL_DIR}/bats-core/install.sh" "${HOME}/.local"
142
+ log_success "BATS core installed to: ${BIN_DIR}/bats"
143
+
144
+ if [[ ":$PATH:" != *":${BIN_DIR}:"* ]]; then
145
+ echo ""
146
+ log_warning "${BIN_DIR} is not in your PATH"
147
+ echo ""
148
+ echo "Add this to your ~/.bashrc or ~/.zshrc:"
149
+ echo ""
150
+ echo -e " ${CYAN}export PATH=\"\${HOME}/.local/bin:\${PATH}\"${NC}"
151
+ echo ""
152
+ fi
155
153
  }
156
154
 
157
155
  install_bats_libraries() {
158
- log_step "Installing BATS support libraries…"
159
-
160
- local libraries=(
161
- "bats-support:https://github.com/bats-core/bats-support.git"
162
- "bats-assert:https://github.com/bats-core/bats-assert.git"
163
- "bats-file:https://github.com/bats-core/bats-file.git"
164
- )
165
-
166
- local lib_info lib_name lib_url lib_path
167
- for lib_info in "${libraries[@]}"; do
168
- lib_name="${lib_info%%:*}"
169
- lib_url="${lib_info#*:}"
170
- lib_path="${INSTALL_DIR}/${lib_name}"
171
-
172
- if [[ -d "${lib_path}" ]]; then
173
- log_info "${lib_name} already installed"
174
- else
175
- log_info "Installing ${lib_name}…"
176
- git clone --quiet --depth 1 "${lib_url}" "${lib_path}"
177
- log_success "${lib_name} installed"
178
- fi
179
- done
156
+ log_step "Installing BATS support libraries…"
157
+
158
+ local libraries=(
159
+ "bats-support:https://github.com/bats-core/bats-support.git"
160
+ "bats-assert:https://github.com/bats-core/bats-assert.git"
161
+ "bats-file:https://github.com/bats-core/bats-file.git"
162
+ )
163
+
164
+ local lib_info lib_name lib_url lib_path
165
+ for lib_info in "${libraries[@]}"; do
166
+ lib_name="${lib_info%%:*}"
167
+ lib_url="${lib_info#*:}"
168
+ lib_path="${INSTALL_DIR}/${lib_name}"
169
+
170
+ if [[ -d "${lib_path}" ]]; then
171
+ log_info "${lib_name} already installed"
172
+ else
173
+ log_info "Installing ${lib_name}…"
174
+ git clone --quiet --depth 1 "${lib_url}" "${lib_path}"
175
+ log_success "${lib_name} installed"
176
+ fi
177
+ done
180
178
  }
181
179
 
182
- # ============================================================================
183
180
  # Main
184
- # ============================================================================
181
+ # ================
185
182
 
186
183
  main() {
187
- local required_version
188
- required_version="$(get_bats_version)"
184
+ local required_version
185
+ required_version="$(get_bats_version)"
186
+
187
+ echo ""
188
+ log_header "BATS Installer"
189
+ echo ""
189
190
 
191
+ if check_bats_installed "${required_version}"; then
190
192
  echo ""
191
- log_header "BATS Installer"
193
+ log_info "No action needed - BATS is already available"
192
194
  echo ""
195
+ exit 0
196
+ fi
193
197
 
194
- if check_bats_installed "${required_version}"; then
195
- echo ""
196
- log_info "No action needed — BATS is already available"
197
- echo ""
198
- exit 0
199
- fi
198
+ echo ""
199
+ log_warning "BATS not found or outdated - installing…"
200
+ echo ""
200
201
 
201
- echo ""
202
- log_warning "BATS not found or outdated — installing…"
203
- echo ""
202
+ install_bats_core "${required_version}"
203
+ install_bats_libraries
204
204
 
205
- install_bats_core "${required_version}"
206
- install_bats_libraries
205
+ echo ""
206
+ log_success "BATS installation complete"
207
+ echo ""
207
208
 
209
+ if command_exists bats; then
210
+ bats --version
208
211
  echo ""
209
- log_success "BATS installation complete"
212
+ log_info "Libraries installed in: ${INSTALL_DIR}"
210
213
  echo ""
211
-
212
- if command_exists bats; then
213
- bats --version
214
- echo ""
215
- log_info "Libraries installed in: ${INSTALL_DIR}"
216
- echo ""
217
- log_info "Run tests with:"
218
- echo -e " ${CYAN}make bats${NC}"
219
- echo -e " ${CYAN}bats tests/bats/ --recursive${NC}"
220
- echo ""
221
- else
222
- log_error "BATS installation verification failed"
223
- exit 1
224
- fi
214
+ log_info "Run tests with:"
215
+ echo -e " ${CYAN}make bats${NC}"
216
+ echo -e " ${CYAN}bats tests/bats/ --recursive${NC}"
217
+ echo ""
218
+ else
219
+ log_error "BATS installation verification failed"
220
+ exit 1
221
+ fi
225
222
  }
226
223
 
227
224
  main "$@"
@@ -15,153 +15,150 @@ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
15
15
  # shellcheck disable=SC1091
16
16
  source "${SCRIPT_DIR}/config.sh"
17
17
 
18
- # ============================================================================
19
18
  # Configuration
20
- # ============================================================================
19
+ # ================
21
20
 
22
21
  HOOKS_SOURCE_DIR="${DEV_TOOLS_ROOT}/stubs/githooks"
23
22
  HOOKS_TARGET_DIR="${PROJECT_ROOT}/.git/hooks"
24
23
 
25
24
  # Available hooks (auto-discovered from stubs/githooks directory)
26
25
  HOOKS=(
27
- "commit-msg"
28
- "prepare-commit-msg"
29
- "pre-commit"
30
- "pre-push"
26
+ "commit-msg"
27
+ "prepare-commit-msg"
28
+ "pre-commit"
29
+ "pre-push"
31
30
  )
32
31
 
33
- # ============================================================================
34
32
  # Functions
35
- # ============================================================================
33
+ # ================
36
34
 
37
35
  install_hooks() {
38
- log_header "📦 Installing Git Hooks"
36
+ log_header "📦 Installing Git Hooks"
39
37
 
40
- if [[ ! -d ".git" ]]; then
41
- log_error "Not a git repository"
42
- log_info "Git hooks can only be installed in a git repository"
43
- exit 1
44
- fi
38
+ if [[ ! -d ".git" ]]; then
39
+ log_error "Not a git repository"
40
+ log_info "Git hooks can only be installed in a git repository"
41
+ exit 1
42
+ fi
45
43
 
46
- if [[ ! -d "$HOOKS_SOURCE_DIR" ]]; then
47
- log_error "Hooks source directory not found: $HOOKS_SOURCE_DIR"
48
- exit 1
49
- fi
44
+ if [[ ! -d "$HOOKS_SOURCE_DIR" ]]; then
45
+ log_error "Hooks source directory not found: $HOOKS_SOURCE_DIR"
46
+ exit 1
47
+ fi
50
48
 
51
- mkdir -p "$HOOKS_TARGET_DIR"
49
+ mkdir -p "$HOOKS_TARGET_DIR"
52
50
 
53
- local installed=0
51
+ local installed=0
54
52
 
55
- for hook in "${HOOKS[@]}"; do
56
- local source="${HOOKS_SOURCE_DIR}/${hook}"
57
- local target="${HOOKS_TARGET_DIR}/${hook}"
53
+ for hook in "${HOOKS[@]}"; do
54
+ local source="${HOOKS_SOURCE_DIR}/${hook}"
55
+ local target="${HOOKS_TARGET_DIR}/${hook}"
58
56
 
59
- if [[ ! -f "$source" ]]; then
60
- log_warning "Hook not found: ${hook} (skipping)"
61
- continue
62
- fi
57
+ if [[ ! -f "$source" ]]; then
58
+ log_warning "Hook not found: ${hook} (skipping)"
59
+ continue
60
+ fi
63
61
 
64
- echo -e " ${BLUE}•${NC} ${hook}"
62
+ echo -e " ${BLUE}•${NC} ${hook}"
65
63
 
66
- # Backup existing hook if present
67
- if [[ -f "$target" ]] && [[ ! -L "$target" ]]; then
68
- local backup
69
- backup="${target}.backup-$(date +%Y%m%d-%H%M%S)"
70
- mv "$target" "$backup"
71
- log_warning " Existing hook backed up to: ${backup}"
72
- fi
64
+ # Backup existing hook if present
65
+ if [[ -f "$target" ]] && [[ ! -L "$target" ]]; then
66
+ local backup
67
+ backup="${target}.backup-$(date +%Y%m%d-%H%M%S)"
68
+ mv "$target" "$backup"
69
+ log_warning " Existing hook backed up to: ${backup}"
70
+ fi
73
71
 
74
- # Remove existing symlink
75
- rm -f "$target"
72
+ # Remove existing symlink
73
+ rm -f "$target"
76
74
 
77
- # Install hook
78
- ln -s "$source" "$target"
79
- log_success " ${hook} installed"
75
+ # Install hook
76
+ ln -s "$source" "$target"
77
+ log_success " ${hook} installed"
80
78
 
81
- installed=$((installed + 1))
82
- done
79
+ installed=$((installed + 1))
80
+ done
83
81
 
84
- echo ""
82
+ echo ""
85
83
 
86
- if [[ $installed -eq 0 ]]; then
87
- log_warning "No hooks were installed"
88
- exit 1
89
- fi
84
+ if [[ $installed -eq 0 ]]; then
85
+ log_warning "No hooks were installed"
86
+ exit 1
87
+ fi
90
88
 
91
- log_header "✅ ${installed} Hook(s) Installed Successfully"
92
-
93
- echo ""
94
- log_info "Installed hooks:"
95
- for hook in "${HOOKS[@]}"; do
96
- case "$hook" in
97
- commit-msg)
98
- echo -e " ${GREEN}✓${NC} ${hook} ${YELLOW}→${NC} Validate Conventional Commits format"
99
- ;;
100
- prepare-commit-msg)
101
- echo -e " ${GREEN}✓${NC} ${hook} ${YELLOW}→${NC} Auto-prefix ticket number from branch"
102
- ;;
103
- pre-commit)
104
- echo -e " ${GREEN}✓${NC} ${hook} ${YELLOW}→${NC} Quality checks (ESLint, Prettier, Markdown)"
105
- ;;
106
- pre-push)
107
- echo -e " ${GREEN}✓${NC} ${hook} ${YELLOW}→${NC} Full quality gate before push"
108
- ;;
109
- *)
110
- echo -e " ${GREEN}✓${NC} ${hook}"
111
- ;;
112
- esac
113
- done
114
-
115
- echo ""
116
- log_info "To bypass hooks (emergency only):"
117
- echo -e " ${CYAN}git commit --no-verify${NC}"
118
- echo ""
89
+ log_header "✅ ${installed} Hook(s) Installed Successfully"
90
+
91
+ echo ""
92
+ log_info "Installed hooks:"
93
+ for hook in "${HOOKS[@]}"; do
94
+ case "$hook" in
95
+ commit-msg)
96
+ echo -e " ${GREEN}✓${NC} ${hook} ${YELLOW}→${NC} Validate Conventional Commits format"
97
+ ;;
98
+ prepare-commit-msg)
99
+ echo -e " ${GREEN}✓${NC} ${hook} ${YELLOW}→${NC} Auto-prefix ticket number from branch"
100
+ ;;
101
+ pre-commit)
102
+ echo -e " ${GREEN}✓${NC} ${hook} ${YELLOW}→${NC} Quality checks (ESLint, Prettier, Markdown)"
103
+ ;;
104
+ pre-push)
105
+ echo -e " ${GREEN}✓${NC} ${hook} ${YELLOW}→${NC} Full quality gate before push"
106
+ ;;
107
+ *)
108
+ echo -e " ${GREEN}✓${NC} ${hook}"
109
+ ;;
110
+ esac
111
+ done
112
+
113
+ echo ""
114
+ log_info "To bypass hooks (emergency only):"
115
+ echo -e " ${CYAN}git commit --no-verify${NC}"
116
+ echo ""
119
117
  }
120
118
 
121
119
  remove_hooks() {
122
- log_header "🗑️ Removing Git Hooks"
123
-
124
- if [[ ! -d ".git" ]]; then
125
- log_error "Not a git repository"
126
- exit 1
120
+ log_header "🗑️ Removing Git Hooks"
121
+
122
+ if [[ ! -d ".git" ]]; then
123
+ log_error "Not a git repository"
124
+ exit 1
125
+ fi
126
+
127
+ local removed=0
128
+
129
+ for hook in "${HOOKS[@]}"; do
130
+ local target="${HOOKS_TARGET_DIR}/${hook}"
131
+
132
+ if [[ -L "$target" ]]; then
133
+ # Only remove if it's a symlink (managed by us)
134
+ echo -e " ${BLUE}•${NC} ${hook}"
135
+ rm -f "$target"
136
+ log_success " ${hook} removed"
137
+ removed=$((removed + 1))
138
+ elif [[ -f "$target" ]]; then
139
+ log_warning " ${hook} exists but is not a symlink (skipping)"
127
140
  fi
141
+ done
128
142
 
129
- local removed=0
130
-
131
- for hook in "${HOOKS[@]}"; do
132
- local target="${HOOKS_TARGET_DIR}/${hook}"
133
-
134
- if [[ -L "$target" ]]; then
135
- # Only remove if it's a symlink (managed by us)
136
- echo -e " ${BLUE}•${NC} ${hook}"
137
- rm -f "$target"
138
- log_success " ${hook} removed"
139
- removed=$((removed + 1))
140
- elif [[ -f "$target" ]]; then
141
- log_warning " ${hook} exists but is not a symlink (skipping)"
142
- fi
143
- done
143
+ echo ""
144
144
 
145
- echo ""
145
+ if [[ $removed -eq 0 ]]; then
146
+ log_info "No hooks were removed"
147
+ exit 0
148
+ fi
146
149
 
147
- if [[ $removed -eq 0 ]]; then
148
- log_info "No hooks were removed"
149
- exit 0
150
- fi
151
-
152
- log_header "✅ ${removed} Hook(s) Removed"
153
- echo ""
150
+ log_header "✅ ${removed} Hook(s) Removed"
151
+ echo ""
154
152
  }
155
153
 
156
- # ============================================================================
157
154
  # Main
158
- # ============================================================================
155
+ # ================
159
156
 
160
157
  case "${1:-install}" in
161
- --remove|-r)
162
- remove_hooks
163
- ;;
164
- --install|-i|install|*)
165
- install_hooks
166
- ;;
158
+ --remove|-r)
159
+ remove_hooks
160
+ ;;
161
+ --install|-i|install|*)
162
+ install_hooks
163
+ ;;
167
164
  esac
@@ -16,10 +16,10 @@ source "${SCRIPT_DIR}/config.sh"
16
16
  log_header "Markdownlint Installer"
17
17
 
18
18
  if [[ -f "$MARKDOWNLINT_BIN" ]]; then
19
- version=$("$MARKDOWNLINT_BIN" --version 2>/dev/null || echo "unknown")
20
- log_success "markdownlint-cli2 already installed: ${version}"
21
- log_info "Run: make markdownlint"
22
- exit 0
19
+ version=$("$MARKDOWNLINT_BIN" --version 2>/dev/null || echo "unknown")
20
+ log_success "markdownlint-cli2 already installed: ${version}"
21
+ log_info "Run: make markdownlint"
22
+ exit 0
23
23
  fi
24
24
 
25
25
  log_info "markdownlint-cli2 not found in node_modules/.bin/"