@mihairo/cmt 1.1.3 → 1.1.5

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,6 @@ 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.1.0",
128
127
  "customTypes": [
129
128
  {
130
129
  "type": "wip",
package/cmt CHANGED
@@ -6,9 +6,9 @@
6
6
  # =============================================================================
7
7
  set -euo pipefail
8
8
 
9
- CC_VERSION="1.1.2"
10
- CC_CONFIG_FILE=".cmt.json"
11
- CC_SCHEMA_URL="https://raw.githubusercontent.com/mihai-ro/cmt/main/schema/cmt.schema.json"
9
+ CMT_VERSION="1.1.5" # x-release-please-version
10
+ CMT_CONFIG_FILE=".cmt.json"
11
+ CMT_SCHEMA_URL="https://raw.githubusercontent.com/mihai-ro/cmt/main/schema/cmt.schema.json"
12
12
 
13
13
  # colours
14
14
  if [[ -z "${NO_COLOR:-}" ]] && ([[ -t 1 ]] || [[ -c /dev/tty ]]); then
@@ -58,7 +58,7 @@ BUILTIN_TYPES=(
58
58
 
59
59
  # config loader
60
60
  load_config() {
61
- local cfg="${CC_CONFIG_FILE}"
61
+ local cfg="${CMT_CONFIG_FILE}"
62
62
 
63
63
  TYPES=("${BUILTIN_TYPES[@]}")
64
64
  CUSTOM_SCOPES=()
@@ -563,7 +563,7 @@ cmd_commit() {
563
563
  fi
564
564
  fi
565
565
 
566
- printf "\n ${ACCENT_BOLD}cmt${RESET} ${MUTED}conventional commits v%s${RESET}\n" "$CC_VERSION" >/dev/tty
566
+ printf "\n ${ACCENT_BOLD}cmt${RESET} ${MUTED}conventional commits v%s${RESET}\n" "$CMT_VERSION" >/dev/tty
567
567
  printf " ${MUTED}─────────────────────────────────────${RESET}\n" >/dev/tty
568
568
 
569
569
  SELECTED_TYPE="" SELECTED_SCOPE="" SELECTED_DESC=""
@@ -708,6 +708,7 @@ _hook_snippet() {
708
708
  for _p in "${_cmt_path}" "\$HOME/.local/bin/cmt" "/usr/local/bin/cmt" "/opt/homebrew/bin/cmt"; do
709
709
  [ -x "\$_p" ] && { "\$_p" commit --write-only > "\$1"; exit 0; }
710
710
  done
711
+ exit 0
711
712
  # <<< cmt
712
713
  SNIPPET
713
714
  }
@@ -720,6 +721,7 @@ _lint_snippet() {
720
721
  for _p in "${_cmt_path}" "\$HOME/.local/bin/cmt" "/usr/local/bin/cmt" "/opt/homebrew/bin/cmt"; do
721
722
  [ -x "\$_p" ] && { "\$_p" lint "\$1"; exit \$?; }
722
723
  done
724
+ exit 0
723
725
  # <<< cmt-lint
724
726
  SNIPPET
725
727
  }
@@ -727,23 +729,23 @@ SNIPPET
727
729
  # install or append cmt block to a hook file
728
730
  # usage: _install_hook <path> <needs_shebang> <cmt_path> [snippet_fn]
729
731
  _install_hook() {
730
- local path="$1" shebang="${2:-1}" cc_path="$3" snippet_fn="${4:-_hook_snippet}"
732
+ local path="$1" shebang="${2:-1}" cmt_path="$3" snippet_fn="${4:-_hook_snippet}"
731
733
  local marker; [[ "$snippet_fn" == "_lint_snippet" ]] && marker="cmt-lint" || marker="cmt"
732
734
 
733
735
  if [[ -f "$path" ]]; then
734
736
  if grep -q ">>> ${marker}" "$path" 2>/dev/null; then
735
737
  local tmp; tmp=$(mktemp)
736
738
  awk "/# >>> ${marker}/{skip=1} !skip{print} /# <<< ${marker}/{skip=0}" "$path" > "$tmp"
737
- "$snippet_fn" "$cc_path" >> "$tmp"
739
+ "$snippet_fn" "$cmt_path" >> "$tmp"
738
740
  mv "$tmp" "$path"
739
741
  success "Updated ${marker} block in $(basename "$(dirname "$path")")/$(basename "$path")"
740
742
  else
741
- "$snippet_fn" "$cc_path" >> "$path"
743
+ "$snippet_fn" "$cmt_path" >> "$path"
742
744
  success "Appended to $(basename "$(dirname "$path")")/$(basename "$path")"
743
745
  fi
744
746
  else
745
747
  [[ "$shebang" == "1" ]] && printf '#!/usr/bin/env bash\n' > "$path"
746
- "$snippet_fn" "$cc_path" >> "$path"
748
+ "$snippet_fn" "$cmt_path" >> "$path"
747
749
  chmod +x "$path"
748
750
  success "Created $(basename "$(dirname "$path")")/$(basename "$path")"
749
751
  fi
@@ -802,7 +804,7 @@ cmd_types() {
802
804
  printf " %s ${BOLD}%-12s${RESET}${badge} ${MUTED}%s${RESET}\n" "$e" "$t" "$d"
803
805
  done
804
806
  printf "\n"
805
- if [[ -f "$CC_CONFIG_FILE" ]]; then
807
+ if [[ -f "$CMT_CONFIG_FILE" ]]; then
806
808
  printf " ${MUTED}custom types from .cmt.json included above${RESET}\n\n"
807
809
  else
808
810
  printf " ${MUTED}run cmt init to configure custom types${RESET}\n\n"
@@ -814,16 +816,15 @@ cmd_types() {
814
816
  cmd_init() {
815
817
  git rev-parse --git-dir > /dev/null 2>&1 || die "Not inside a git repository"
816
818
 
817
- local git_root cc_path
819
+ local git_root cmt_path
818
820
  git_root=$(git rev-parse --show-toplevel)
819
- cc_path=$(realpath "$0")
821
+ cmt_path=$(realpath "$0")
820
822
 
821
823
  # .cmt.json
822
- if [[ ! -f "${git_root}/${CC_CONFIG_FILE}" ]]; then
823
- cat > "${git_root}/${CC_CONFIG_FILE}" << JSONEOF
824
+ if [[ ! -f "${git_root}/${CMT_CONFIG_FILE}" ]]; then
825
+ cat > "${git_root}/${CMT_CONFIG_FILE}" << JSONEOF
824
826
  {
825
- "\$schema": "${CC_SCHEMA_URL}",
826
- "version": "${CC_VERSION}",
827
+ "\$schema": "${CMT_SCHEMA_URL}",
827
828
  "customTypes": [
828
829
  { "type": "wip", "emoji": "🚧", "semver": "none", "description": "Work in progress" }
829
830
  ],
@@ -848,15 +849,15 @@ JSONEOF
848
849
 
849
850
  if [[ $use_husky -eq 1 ]]; then
850
851
  mkdir -p "${git_root}/.husky"
851
- _install_hook "${git_root}/.husky/prepare-commit-msg" 0 "$cc_path"
852
+ _install_hook "${git_root}/.husky/prepare-commit-msg" 0 "$cmt_path"
852
853
  if [[ $use_lint -eq 1 ]]; then
853
- _install_hook "${git_root}/.husky/commit-msg" 0 "$cc_path" _lint_snippet
854
+ _install_hook "${git_root}/.husky/commit-msg" 0 "$cmt_path" _lint_snippet
854
855
  fi
855
856
  printf " ${DIM}Commit .husky/ hooks to share with your team.${RESET}\n"
856
857
  else
857
- _install_hook "${git_root}/.git/hooks/prepare-commit-msg" 1 "$cc_path"
858
+ _install_hook "${git_root}/.git/hooks/prepare-commit-msg" 1 "$cmt_path"
858
859
  if [[ $use_lint -eq 1 ]]; then
859
- _install_hook "${git_root}/.git/hooks/commit-msg" 1 "$cc_path" _lint_snippet
860
+ _install_hook "${git_root}/.git/hooks/commit-msg" 1 "$cmt_path" _lint_snippet
860
861
  fi
861
862
  fi
862
863
 
@@ -911,8 +912,8 @@ cmd_uninstall() {
911
912
  done
912
913
 
913
914
  # remove .cmt.json config
914
- if [[ -f "${git_root}/${CC_CONFIG_FILE}" ]]; then
915
- rm "${git_root}/${CC_CONFIG_FILE}"
915
+ if [[ -f "${git_root}/${CMT_CONFIG_FILE}" ]]; then
916
+ rm "${git_root}/${CMT_CONFIG_FILE}"
916
917
  success "Removed .cmt.json"
917
918
  removed=1
918
919
  fi
@@ -924,13 +925,13 @@ cmd_uninstall() {
924
925
 
925
926
  # cmd: version
926
927
  cmd_version() {
927
- printf "cmt version %s\n" "$CC_VERSION"
928
+ printf "cmt version %s\n" "$CMT_VERSION"
928
929
  }
929
930
 
930
931
  # cmd: help
931
932
  cmd_help() {
932
933
  printf "
933
- ${BOLD}${CYAN}cmt${RESET} v${CC_VERSION} — Conventional Commits CLI
934
+ ${BOLD}${CYAN}cmt${RESET} v${CMT_VERSION} — Conventional Commits CLI
934
935
 
935
936
  ${BOLD}USAGE${RESET}
936
937
  cmt <command> [options]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mihairo/cmt",
3
- "version": "1.1.3",
3
+ "version": "1.1.5",
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",
@@ -12,14 +12,6 @@
12
12
  "description": "JSON Schema pointer — enables editor intellisense. Leave as-is."
13
13
  },
14
14
 
15
- "version": {
16
- "type": "string",
17
- "description": "Config schema version. Currently '1.1.2'.",
18
- "pattern": "^\\d+\\.\\d+\\.\\d+$",
19
- "default": "1.1.2",
20
- "examples": ["1.1.2"]
21
- },
22
-
23
15
  "customTypes": {
24
16
  "type": "array",
25
17
  "description": "Additional commit types appended after the built-in ones (feat, fix, docs, …).",
@@ -124,7 +116,6 @@
124
116
  "examples": [
125
117
  {
126
118
  "$schema": "https://raw.githubusercontent.com/mihai-ro/cmt/main/schema/cc.schema.json",
127
- "version": "1.1.2",
128
119
  "customTypes": [
129
120
  {
130
121
  "type": "wip",