@mihairo/cmt 1.1.2 → 1.1.4
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 +0 -1
- package/cmt +24 -27
- package/package.json +1 -1
- package/schema/cmt.schema.json +0 -9
package/README.md
CHANGED
package/cmt
CHANGED
|
@@ -6,9 +6,9 @@
|
|
|
6
6
|
# =============================================================================
|
|
7
7
|
set -euo pipefail
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
CMT_VERSION="1.1.4" # 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="${
|
|
61
|
+
local cfg="${CMT_CONFIG_FILE}"
|
|
62
62
|
|
|
63
63
|
TYPES=("${BUILTIN_TYPES[@]}")
|
|
64
64
|
CUSTOM_SCOPES=()
|
|
@@ -559,13 +559,11 @@ cmd_commit() {
|
|
|
559
559
|
git rev-parse --git-dir > /dev/null 2>&1 || die "Not inside a git repository"
|
|
560
560
|
if git diff --cached --quiet 2>/dev/null; then
|
|
561
561
|
warn "No staged changes detected. Did you forget \`git add\`?"
|
|
562
|
-
|
|
563
|
-
read -r cont </dev/tty
|
|
564
|
-
[[ "$cont" =~ ^[yY]$ ]] || exit 0
|
|
562
|
+
exit 0
|
|
565
563
|
fi
|
|
566
564
|
fi
|
|
567
565
|
|
|
568
|
-
printf "\n ${ACCENT_BOLD}cmt${RESET} ${MUTED}conventional commits v%s${RESET}\n" "$
|
|
566
|
+
printf "\n ${ACCENT_BOLD}cmt${RESET} ${MUTED}conventional commits v%s${RESET}\n" "$CMT_VERSION" >/dev/tty
|
|
569
567
|
printf " ${MUTED}─────────────────────────────────────${RESET}\n" >/dev/tty
|
|
570
568
|
|
|
571
569
|
SELECTED_TYPE="" SELECTED_SCOPE="" SELECTED_DESC=""
|
|
@@ -729,23 +727,23 @@ SNIPPET
|
|
|
729
727
|
# install or append cmt block to a hook file
|
|
730
728
|
# usage: _install_hook <path> <needs_shebang> <cmt_path> [snippet_fn]
|
|
731
729
|
_install_hook() {
|
|
732
|
-
local path="$1" shebang="${2:-1}"
|
|
730
|
+
local path="$1" shebang="${2:-1}" cmt_path="$3" snippet_fn="${4:-_hook_snippet}"
|
|
733
731
|
local marker; [[ "$snippet_fn" == "_lint_snippet" ]] && marker="cmt-lint" || marker="cmt"
|
|
734
732
|
|
|
735
733
|
if [[ -f "$path" ]]; then
|
|
736
734
|
if grep -q ">>> ${marker}" "$path" 2>/dev/null; then
|
|
737
735
|
local tmp; tmp=$(mktemp)
|
|
738
736
|
awk "/# >>> ${marker}/{skip=1} !skip{print} /# <<< ${marker}/{skip=0}" "$path" > "$tmp"
|
|
739
|
-
"$snippet_fn" "$
|
|
737
|
+
"$snippet_fn" "$cmt_path" >> "$tmp"
|
|
740
738
|
mv "$tmp" "$path"
|
|
741
739
|
success "Updated ${marker} block in $(basename "$(dirname "$path")")/$(basename "$path")"
|
|
742
740
|
else
|
|
743
|
-
"$snippet_fn" "$
|
|
741
|
+
"$snippet_fn" "$cmt_path" >> "$path"
|
|
744
742
|
success "Appended to $(basename "$(dirname "$path")")/$(basename "$path")"
|
|
745
743
|
fi
|
|
746
744
|
else
|
|
747
745
|
[[ "$shebang" == "1" ]] && printf '#!/usr/bin/env bash\n' > "$path"
|
|
748
|
-
"$snippet_fn" "$
|
|
746
|
+
"$snippet_fn" "$cmt_path" >> "$path"
|
|
749
747
|
chmod +x "$path"
|
|
750
748
|
success "Created $(basename "$(dirname "$path")")/$(basename "$path")"
|
|
751
749
|
fi
|
|
@@ -804,7 +802,7 @@ cmd_types() {
|
|
|
804
802
|
printf " %s ${BOLD}%-12s${RESET}${badge} ${MUTED}%s${RESET}\n" "$e" "$t" "$d"
|
|
805
803
|
done
|
|
806
804
|
printf "\n"
|
|
807
|
-
if [[ -f "$
|
|
805
|
+
if [[ -f "$CMT_CONFIG_FILE" ]]; then
|
|
808
806
|
printf " ${MUTED}custom types from .cmt.json included above${RESET}\n\n"
|
|
809
807
|
else
|
|
810
808
|
printf " ${MUTED}run cmt init to configure custom types${RESET}\n\n"
|
|
@@ -816,16 +814,15 @@ cmd_types() {
|
|
|
816
814
|
cmd_init() {
|
|
817
815
|
git rev-parse --git-dir > /dev/null 2>&1 || die "Not inside a git repository"
|
|
818
816
|
|
|
819
|
-
local git_root
|
|
817
|
+
local git_root cmt_path
|
|
820
818
|
git_root=$(git rev-parse --show-toplevel)
|
|
821
|
-
|
|
819
|
+
cmt_path=$(realpath "$0")
|
|
822
820
|
|
|
823
821
|
# .cmt.json
|
|
824
|
-
if [[ ! -f "${git_root}/${
|
|
825
|
-
cat > "${git_root}/${
|
|
822
|
+
if [[ ! -f "${git_root}/${CMT_CONFIG_FILE}" ]]; then
|
|
823
|
+
cat > "${git_root}/${CMT_CONFIG_FILE}" << JSONEOF
|
|
826
824
|
{
|
|
827
|
-
"\$schema": "${
|
|
828
|
-
"version": "${CC_VERSION}",
|
|
825
|
+
"\$schema": "${CMT_SCHEMA_URL}",
|
|
829
826
|
"customTypes": [
|
|
830
827
|
{ "type": "wip", "emoji": "🚧", "semver": "none", "description": "Work in progress" }
|
|
831
828
|
],
|
|
@@ -850,15 +847,15 @@ JSONEOF
|
|
|
850
847
|
|
|
851
848
|
if [[ $use_husky -eq 1 ]]; then
|
|
852
849
|
mkdir -p "${git_root}/.husky"
|
|
853
|
-
_install_hook "${git_root}/.husky/prepare-commit-msg" 0 "$
|
|
850
|
+
_install_hook "${git_root}/.husky/prepare-commit-msg" 0 "$cmt_path"
|
|
854
851
|
if [[ $use_lint -eq 1 ]]; then
|
|
855
|
-
_install_hook "${git_root}/.husky/commit-msg" 0 "$
|
|
852
|
+
_install_hook "${git_root}/.husky/commit-msg" 0 "$cmt_path" _lint_snippet
|
|
856
853
|
fi
|
|
857
854
|
printf " ${DIM}Commit .husky/ hooks to share with your team.${RESET}\n"
|
|
858
855
|
else
|
|
859
|
-
_install_hook "${git_root}/.git/hooks/prepare-commit-msg" 1 "$
|
|
856
|
+
_install_hook "${git_root}/.git/hooks/prepare-commit-msg" 1 "$cmt_path"
|
|
860
857
|
if [[ $use_lint -eq 1 ]]; then
|
|
861
|
-
_install_hook "${git_root}/.git/hooks/commit-msg" 1 "$
|
|
858
|
+
_install_hook "${git_root}/.git/hooks/commit-msg" 1 "$cmt_path" _lint_snippet
|
|
862
859
|
fi
|
|
863
860
|
fi
|
|
864
861
|
|
|
@@ -913,8 +910,8 @@ cmd_uninstall() {
|
|
|
913
910
|
done
|
|
914
911
|
|
|
915
912
|
# remove .cmt.json config
|
|
916
|
-
if [[ -f "${git_root}/${
|
|
917
|
-
rm "${git_root}/${
|
|
913
|
+
if [[ -f "${git_root}/${CMT_CONFIG_FILE}" ]]; then
|
|
914
|
+
rm "${git_root}/${CMT_CONFIG_FILE}"
|
|
918
915
|
success "Removed .cmt.json"
|
|
919
916
|
removed=1
|
|
920
917
|
fi
|
|
@@ -926,13 +923,13 @@ cmd_uninstall() {
|
|
|
926
923
|
|
|
927
924
|
# cmd: version
|
|
928
925
|
cmd_version() {
|
|
929
|
-
printf "cmt version %s\n" "$
|
|
926
|
+
printf "cmt version %s\n" "$CMT_VERSION"
|
|
930
927
|
}
|
|
931
928
|
|
|
932
929
|
# cmd: help
|
|
933
930
|
cmd_help() {
|
|
934
931
|
printf "
|
|
935
|
-
${BOLD}${CYAN}cmt${RESET} v${
|
|
932
|
+
${BOLD}${CYAN}cmt${RESET} v${CMT_VERSION} — Conventional Commits CLI
|
|
936
933
|
|
|
937
934
|
${BOLD}USAGE${RESET}
|
|
938
935
|
cmt <command> [options]
|
package/package.json
CHANGED
package/schema/cmt.schema.json
CHANGED
|
@@ -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",
|