@mihairo/cmt 1.1.1 → 1.1.3

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/cmt CHANGED
@@ -6,7 +6,7 @@
6
6
  # =============================================================================
7
7
  set -euo pipefail
8
8
 
9
- CC_VERSION="1.1.0"
9
+ CC_VERSION="1.1.2"
10
10
  CC_CONFIG_FILE=".cmt.json"
11
11
  CC_SCHEMA_URL="https://raw.githubusercontent.com/mihai-ro/cmt/main/schema/cmt.schema.json"
12
12
 
@@ -227,7 +227,7 @@ load_config() {
227
227
  _pick() {
228
228
  local _var="$1" _prompt="$2"; shift 2
229
229
  local -a _items=("$@")
230
- local _n=${#_items[@]} _cur=0 _top=0 _view=7 _k1 _k2 _k3 _last_dl=0
230
+ local _n=${#_items[@]} _cur=0 _top=0 _view=7 _k1 _k2 _k3
231
231
 
232
232
  exec 9<>/dev/tty
233
233
 
@@ -235,7 +235,7 @@ _pick() {
235
235
  _old=$(stty -g <&9 2>/dev/null) || { exec 9>&-; _pick_fallback "$_var" "$_prompt" "${_items[@]}"; return; }
236
236
  stty -echo -icanon min 1 time 0 <&9 2>/dev/null || { exec 9>&-; _pick_fallback "$_var" "$_prompt" "${_items[@]}"; return; }
237
237
 
238
- trap "stty '$_old' <&9 2>/dev/null; printf '\033[?25h' >&9 2>/dev/null; exec 9>&-" EXIT INT TERM
238
+ trap "trap - EXIT INT TERM; stty '$_old' <&9 2>/dev/null; printf '\033[?25h' >&9 2>/dev/null; exec 9>&- 2>/dev/null" EXIT INT TERM
239
239
 
240
240
  _pick_move_up() {
241
241
  _cur=$(( (_cur - 1 + _n) % _n ))
@@ -259,9 +259,7 @@ _pick() {
259
259
  }
260
260
 
261
261
  # draw the visible window of _view items starting at _top
262
- # updates _last_dl with the number of lines actually drawn
263
262
  _draw() {
264
- _last_dl=0
265
263
  local _i _end
266
264
  _end=$(( _top + _view ))
267
265
  [[ $_end -gt $_n ]] && _end=$_n
@@ -269,7 +267,6 @@ _pick() {
269
267
  # scroll hint above — only when items are hidden above
270
268
  if [[ $_top -gt 0 ]]; then
271
269
  printf " ${MUTED}↑ %d more${RESET}\033[K\n" "$_top" >&9
272
- _last_dl=$(( _last_dl + 1 ))
273
270
  fi
274
271
 
275
272
  for (( _i=_top; _i<_end; _i++ )); do
@@ -278,7 +275,6 @@ _pick() {
278
275
  else
279
276
  printf " ${MUTED}·${RESET} ${MUTED}%s${RESET}\033[K\n" "${_items[$_i]}" >&9
280
277
  fi
281
- _last_dl=$(( _last_dl + 1 ))
282
278
  done
283
279
 
284
280
  # scroll hint below
@@ -288,11 +284,11 @@ _pick() {
288
284
  else
289
285
  printf "\033[K\n" >&9
290
286
  fi
291
- _last_dl=$(( _last_dl + 1 ))
292
287
  }
293
288
 
294
289
  printf "\033[?25l" >&9
295
290
  printf "\n ${ACCENT_BOLD}%s${RESET}\n\n" "$_prompt" >&9
291
+ printf "\033[s" >&9
296
292
  _draw
297
293
 
298
294
  while true; do
@@ -313,14 +309,12 @@ _pick() {
313
309
  j) _pick_move_down ;;
314
310
  q|$'\003') stty "$_old" <&9 2>/dev/null; trap - EXIT INT TERM; exec 9>&-; exit 1 ;;
315
311
  esac
316
- printf "\033[%dA" "$_last_dl" >&9
317
- printf "\033[J" >&9
312
+ printf "\033[u\033[J" >&9
318
313
  _draw
319
314
  done
320
315
 
321
316
  # collapse to just the selected line
322
- printf "\033[%dA" "$_last_dl" >&9
323
- printf "\033[J" >&9
317
+ printf "\033[u\033[J" >&9
324
318
  printf " ${ACCENT_BOLD}❯${RESET} ${BOLD}%s${RESET}\n" "${_items[$_cur]}" >&9
325
319
 
326
320
  stty "$_old" <&9 2>/dev/null
@@ -565,9 +559,7 @@ cmd_commit() {
565
559
  git rev-parse --git-dir > /dev/null 2>&1 || die "Not inside a git repository"
566
560
  if git diff --cached --quiet 2>/dev/null; then
567
561
  warn "No staged changes detected. Did you forget \`git add\`?"
568
- printf "${DIM}Continue anyway? [y/N]:${RESET} " >/dev/tty
569
- read -r cont </dev/tty
570
- [[ "$cont" =~ ^[yY]$ ]] || exit 0
562
+ exit 0
571
563
  fi
572
564
  fi
573
565
 
@@ -983,13 +975,15 @@ ${BOLD}CONFIG${RESET} .cmt.json (JSON Schema → intellisense in VS Code / Jet
983
975
 
984
976
  # dispatch
985
977
  main() {
986
- case "${1:-help}" in
987
- commit|c) shift; cmd_commit "$@" ;;
988
- lint|l) shift; cmd_lint "$@" ;;
989
- init) shift; cmd_init "$@" ;;
990
- log) shift; cmd_log "$@" ;;
991
- types|t) shift; cmd_types "$@" ;;
992
- uninstall) shift; cmd_uninstall "$@" ;;
978
+ local cmd="${1:-commit}"
979
+ [[ $# -gt 0 ]] && shift
980
+ case "$cmd" in
981
+ commit|c) cmd_commit "$@" ;;
982
+ lint|l) cmd_lint "$@" ;;
983
+ init) cmd_init "$@" ;;
984
+ log) cmd_log "$@" ;;
985
+ types|t) cmd_types "$@" ;;
986
+ uninstall) cmd_uninstall "$@" ;;
993
987
  version|-v|--version) cmd_version ;;
994
988
  help|-h|--help|*) cmd_help ;;
995
989
  esac
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mihairo/cmt",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "description": "Zero-dependency conventional commits CLI — interactive picker, linter, and git hook installer. One bash script, works in any repo.",
5
5
  "keywords": [
6
6
  "conventional-commits",
@@ -14,10 +14,10 @@
14
14
 
15
15
  "version": {
16
16
  "type": "string",
17
- "description": "Config schema version. Currently '1.1.0'.",
17
+ "description": "Config schema version. Currently '1.1.2'.",
18
18
  "pattern": "^\\d+\\.\\d+\\.\\d+$",
19
- "default": "1.1.0",
20
- "examples": ["1.1.0"]
19
+ "default": "1.1.2",
20
+ "examples": ["1.1.2"]
21
21
  },
22
22
 
23
23
  "customTypes": {
@@ -124,7 +124,7 @@
124
124
  "examples": [
125
125
  {
126
126
  "$schema": "https://raw.githubusercontent.com/mihai-ro/cmt/main/schema/cc.schema.json",
127
- "version": "1.1.0",
127
+ "version": "1.1.2",
128
128
  "customTypes": [
129
129
  {
130
130
  "type": "wip",