@mihairo/cmt 1.1.0 → 1.1.1

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/README.md CHANGED
@@ -124,7 +124,7 @@ validate it automatically — no extension needed.
124
124
  ```json
125
125
  {
126
126
  "$schema": "https://raw.githubusercontent.com/mihai-ro/cmt/main/schema/cmt.schema.json",
127
- "version": "1.0.0",
127
+ "version": "1.1.0",
128
128
  "customTypes": [
129
129
  {
130
130
  "type": "wip",
package/cmt CHANGED
@@ -6,7 +6,7 @@
6
6
  # =============================================================================
7
7
  set -euo pipefail
8
8
 
9
- CC_VERSION="1.0.0"
9
+ CC_VERSION="1.1.0"
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
230
+ local _n=${#_items[@]} _cur=0 _top=0 _view=7 _k1 _k2 _k3 _last_dl=0
231
231
 
232
232
  exec 9<>/dev/tty
233
233
 
@@ -259,17 +259,17 @@ _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
262
263
  _draw() {
264
+ _last_dl=0
263
265
  local _i _end
264
266
  _end=$(( _top + _view ))
265
267
  [[ $_end -gt $_n ]] && _end=$_n
266
- local _visible=$(( _end - _top ))
267
268
 
268
- # scroll hint above
269
+ # scroll hint above — only when items are hidden above
269
270
  if [[ $_top -gt 0 ]]; then
270
271
  printf " ${MUTED}↑ %d more${RESET}\033[K\n" "$_top" >&9
271
- else
272
- printf "\033[K\n" >&9
272
+ _last_dl=$(( _last_dl + 1 ))
273
273
  fi
274
274
 
275
275
  for (( _i=_top; _i<_end; _i++ )); do
@@ -278,6 +278,7 @@ _pick() {
278
278
  else
279
279
  printf " ${MUTED}·${RESET} ${MUTED}%s${RESET}\033[K\n" "${_items[$_i]}" >&9
280
280
  fi
281
+ _last_dl=$(( _last_dl + 1 ))
281
282
  done
282
283
 
283
284
  # scroll hint below
@@ -287,11 +288,9 @@ _pick() {
287
288
  else
288
289
  printf "\033[K\n" >&9
289
290
  fi
291
+ _last_dl=$(( _last_dl + 1 ))
290
292
  }
291
293
 
292
- # total drawn lines = _view items + 2 hint lines — fixed for this pick session
293
- local _dl=$(( _view < _n ? _view + 2 : _n + 2 ))
294
-
295
294
  printf "\033[?25l" >&9
296
295
  printf "\n ${ACCENT_BOLD}%s${RESET}\n\n" "$_prompt" >&9
297
296
  _draw
@@ -314,12 +313,13 @@ _pick() {
314
313
  j) _pick_move_down ;;
315
314
  q|$'\003') stty "$_old" <&9 2>/dev/null; trap - EXIT INT TERM; exec 9>&-; exit 1 ;;
316
315
  esac
317
- printf "\033[%dA" "$_dl" >&9
316
+ printf "\033[%dA" "$_last_dl" >&9
317
+ printf "\033[J" >&9
318
318
  _draw
319
319
  done
320
320
 
321
321
  # collapse to just the selected line
322
- printf "\033[%dA" "$_dl" >&9
322
+ printf "\033[%dA" "$_last_dl" >&9
323
323
  printf "\033[J" >&9
324
324
  printf " ${ACCENT_BOLD}❯${RESET} ${BOLD}%s${RESET}\n" "${_items[$_cur]}" >&9
325
325
 
@@ -335,7 +335,7 @@ _pick() {
335
335
  _pick_fallback() {
336
336
  local _var="$1" _prompt="$2"; shift 2
337
337
  local -a _items=("$@") _i=1 _choice
338
- printf "\n\033[1m%s\033[0m\n\n" "$_prompt" >/dev/tty
338
+ printf "\n\033[1m%s\033[0m\n" "$_prompt" >/dev/tty
339
339
  for _item in "${_items[@]}"; do
340
340
  printf " %2d) %s\n" "$_i" "$_item" >/dev/tty
341
341
  _i=$(( _i + 1 ))
@@ -677,7 +677,7 @@ lint_message() {
677
677
 
678
678
  # report
679
679
  local exit_code=0
680
- printf "\n ${ACCENT_BOLD}lint${RESET} ${MUTED}%s${RESET}\n\n" "$header"
680
+ printf "\n ${ACCENT_BOLD}lint${RESET} ${MUTED}%s${RESET}\n" "$header"
681
681
 
682
682
  if [[ ${#errors[@]} -gt 0 ]]; then
683
683
  for e in "${errors[@]}"; do
@@ -764,7 +764,7 @@ cmd_log() {
764
764
  load_config
765
765
 
766
766
  local limit="${1:-20}"
767
- printf "\n ${ACCENT_BOLD}log${RESET} ${MUTED}last %s commits${RESET}\n\n" "$limit"
767
+ printf "\n ${ACCENT_BOLD}log${RESET} ${MUTED}last %s commits${RESET}\n" "$limit"
768
768
 
769
769
  local _p_log_type='^([a-z][a-z0-9_-]*)[(:!]'
770
770
  while IFS='|' read -r hash short_hash date author subject; do
@@ -798,7 +798,7 @@ cmd_log() {
798
798
  # cmd: types
799
799
  cmd_types() {
800
800
  load_config
801
- printf "\n ${ACCENT_BOLD}commit types${RESET}\n\n"
801
+ printf "\n ${ACCENT_BOLD}commit types${RESET}\n"
802
802
  for entry in "${TYPES[@]}"; do
803
803
  local t e s d badge
804
804
  IFS='|' read -r t e s d <<< "$entry"
@@ -831,7 +831,7 @@ cmd_init() {
831
831
  cat > "${git_root}/${CC_CONFIG_FILE}" << JSONEOF
832
832
  {
833
833
  "\$schema": "${CC_SCHEMA_URL}",
834
- "version": "1.0.0",
834
+ "version": "${CC_VERSION}",
835
835
  "customTypes": [
836
836
  { "type": "wip", "emoji": "🚧", "semver": "none", "description": "Work in progress" }
837
837
  ],
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mihairo/cmt",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
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.0.0'.",
17
+ "description": "Config schema version. Currently '1.1.0'.",
18
18
  "pattern": "^\\d+\\.\\d+\\.\\d+$",
19
- "default": "1.0.0",
20
- "examples": ["1.0.0"]
19
+ "default": "1.1.0",
20
+ "examples": ["1.1.0"]
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.0.0",
127
+ "version": "1.1.0",
128
128
  "customTypes": [
129
129
  {
130
130
  "type": "wip",