@mihairo/cmt 1.1.3 → 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 +23 -24
- 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=()
|
|
@@ -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" "$
|
|
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=""
|
|
@@ -727,23 +727,23 @@ SNIPPET
|
|
|
727
727
|
# install or append cmt block to a hook file
|
|
728
728
|
# usage: _install_hook <path> <needs_shebang> <cmt_path> [snippet_fn]
|
|
729
729
|
_install_hook() {
|
|
730
|
-
local path="$1" shebang="${2:-1}"
|
|
730
|
+
local path="$1" shebang="${2:-1}" cmt_path="$3" snippet_fn="${4:-_hook_snippet}"
|
|
731
731
|
local marker; [[ "$snippet_fn" == "_lint_snippet" ]] && marker="cmt-lint" || marker="cmt"
|
|
732
732
|
|
|
733
733
|
if [[ -f "$path" ]]; then
|
|
734
734
|
if grep -q ">>> ${marker}" "$path" 2>/dev/null; then
|
|
735
735
|
local tmp; tmp=$(mktemp)
|
|
736
736
|
awk "/# >>> ${marker}/{skip=1} !skip{print} /# <<< ${marker}/{skip=0}" "$path" > "$tmp"
|
|
737
|
-
"$snippet_fn" "$
|
|
737
|
+
"$snippet_fn" "$cmt_path" >> "$tmp"
|
|
738
738
|
mv "$tmp" "$path"
|
|
739
739
|
success "Updated ${marker} block in $(basename "$(dirname "$path")")/$(basename "$path")"
|
|
740
740
|
else
|
|
741
|
-
"$snippet_fn" "$
|
|
741
|
+
"$snippet_fn" "$cmt_path" >> "$path"
|
|
742
742
|
success "Appended to $(basename "$(dirname "$path")")/$(basename "$path")"
|
|
743
743
|
fi
|
|
744
744
|
else
|
|
745
745
|
[[ "$shebang" == "1" ]] && printf '#!/usr/bin/env bash\n' > "$path"
|
|
746
|
-
"$snippet_fn" "$
|
|
746
|
+
"$snippet_fn" "$cmt_path" >> "$path"
|
|
747
747
|
chmod +x "$path"
|
|
748
748
|
success "Created $(basename "$(dirname "$path")")/$(basename "$path")"
|
|
749
749
|
fi
|
|
@@ -802,7 +802,7 @@ cmd_types() {
|
|
|
802
802
|
printf " %s ${BOLD}%-12s${RESET}${badge} ${MUTED}%s${RESET}\n" "$e" "$t" "$d"
|
|
803
803
|
done
|
|
804
804
|
printf "\n"
|
|
805
|
-
if [[ -f "$
|
|
805
|
+
if [[ -f "$CMT_CONFIG_FILE" ]]; then
|
|
806
806
|
printf " ${MUTED}custom types from .cmt.json included above${RESET}\n\n"
|
|
807
807
|
else
|
|
808
808
|
printf " ${MUTED}run cmt init to configure custom types${RESET}\n\n"
|
|
@@ -814,16 +814,15 @@ cmd_types() {
|
|
|
814
814
|
cmd_init() {
|
|
815
815
|
git rev-parse --git-dir > /dev/null 2>&1 || die "Not inside a git repository"
|
|
816
816
|
|
|
817
|
-
local git_root
|
|
817
|
+
local git_root cmt_path
|
|
818
818
|
git_root=$(git rev-parse --show-toplevel)
|
|
819
|
-
|
|
819
|
+
cmt_path=$(realpath "$0")
|
|
820
820
|
|
|
821
821
|
# .cmt.json
|
|
822
|
-
if [[ ! -f "${git_root}/${
|
|
823
|
-
cat > "${git_root}/${
|
|
822
|
+
if [[ ! -f "${git_root}/${CMT_CONFIG_FILE}" ]]; then
|
|
823
|
+
cat > "${git_root}/${CMT_CONFIG_FILE}" << JSONEOF
|
|
824
824
|
{
|
|
825
|
-
"\$schema": "${
|
|
826
|
-
"version": "${CC_VERSION}",
|
|
825
|
+
"\$schema": "${CMT_SCHEMA_URL}",
|
|
827
826
|
"customTypes": [
|
|
828
827
|
{ "type": "wip", "emoji": "🚧", "semver": "none", "description": "Work in progress" }
|
|
829
828
|
],
|
|
@@ -848,15 +847,15 @@ JSONEOF
|
|
|
848
847
|
|
|
849
848
|
if [[ $use_husky -eq 1 ]]; then
|
|
850
849
|
mkdir -p "${git_root}/.husky"
|
|
851
|
-
_install_hook "${git_root}/.husky/prepare-commit-msg" 0 "$
|
|
850
|
+
_install_hook "${git_root}/.husky/prepare-commit-msg" 0 "$cmt_path"
|
|
852
851
|
if [[ $use_lint -eq 1 ]]; then
|
|
853
|
-
_install_hook "${git_root}/.husky/commit-msg" 0 "$
|
|
852
|
+
_install_hook "${git_root}/.husky/commit-msg" 0 "$cmt_path" _lint_snippet
|
|
854
853
|
fi
|
|
855
854
|
printf " ${DIM}Commit .husky/ hooks to share with your team.${RESET}\n"
|
|
856
855
|
else
|
|
857
|
-
_install_hook "${git_root}/.git/hooks/prepare-commit-msg" 1 "$
|
|
856
|
+
_install_hook "${git_root}/.git/hooks/prepare-commit-msg" 1 "$cmt_path"
|
|
858
857
|
if [[ $use_lint -eq 1 ]]; then
|
|
859
|
-
_install_hook "${git_root}/.git/hooks/commit-msg" 1 "$
|
|
858
|
+
_install_hook "${git_root}/.git/hooks/commit-msg" 1 "$cmt_path" _lint_snippet
|
|
860
859
|
fi
|
|
861
860
|
fi
|
|
862
861
|
|
|
@@ -911,8 +910,8 @@ cmd_uninstall() {
|
|
|
911
910
|
done
|
|
912
911
|
|
|
913
912
|
# remove .cmt.json config
|
|
914
|
-
if [[ -f "${git_root}/${
|
|
915
|
-
rm "${git_root}/${
|
|
913
|
+
if [[ -f "${git_root}/${CMT_CONFIG_FILE}" ]]; then
|
|
914
|
+
rm "${git_root}/${CMT_CONFIG_FILE}"
|
|
916
915
|
success "Removed .cmt.json"
|
|
917
916
|
removed=1
|
|
918
917
|
fi
|
|
@@ -924,13 +923,13 @@ cmd_uninstall() {
|
|
|
924
923
|
|
|
925
924
|
# cmd: version
|
|
926
925
|
cmd_version() {
|
|
927
|
-
printf "cmt version %s\n" "$
|
|
926
|
+
printf "cmt version %s\n" "$CMT_VERSION"
|
|
928
927
|
}
|
|
929
928
|
|
|
930
929
|
# cmd: help
|
|
931
930
|
cmd_help() {
|
|
932
931
|
printf "
|
|
933
|
-
${BOLD}${CYAN}cmt${RESET} v${
|
|
932
|
+
${BOLD}${CYAN}cmt${RESET} v${CMT_VERSION} — Conventional Commits CLI
|
|
934
933
|
|
|
935
934
|
${BOLD}USAGE${RESET}
|
|
936
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",
|