better-commits 1.8.1 โ†’ 1.10.0

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/dist/branch.js CHANGED
@@ -48,49 +48,56 @@ var REGEX_START_NUM = new RegExp(/^(\d+)/);
48
48
  var REGEX_START_UND = new RegExp(/^([A-Z]+-[\[a-zA-Z\]\d]+)_/);
49
49
  var REGEX_SLASH_UND = new RegExp(/\/([A-Z]+-[\[a-zA-Z\]\d]+)_/);
50
50
  var DEFAULT_TYPE_OPTIONS = [
51
- { value: "feat", label: "feat", hint: "A new feature", emoji: "\u2728" },
52
- { value: "fix", label: "fix", hint: "A bug fix", emoji: "\u{1F41B}" },
51
+ { value: "feat", label: "feat", hint: "A new feature", emoji: "\u2728", trailer: "Changelog: feature" },
52
+ { value: "fix", label: "fix", hint: "A bug fix", emoji: "\u{1F41B}", trailer: "Changelog: fix" },
53
53
  {
54
54
  value: "docs",
55
55
  label: "docs",
56
56
  hint: "Documentation only changes",
57
- emoji: "\u{1F4DA}"
57
+ emoji: "\u{1F4DA}",
58
+ trailer: "Changelog: documentation"
58
59
  },
59
60
  {
60
61
  value: "refactor",
61
62
  label: "refactor",
62
63
  hint: "A code change that neither fixes a bug nor adds a feature",
63
- emoji: "\u{1F528}"
64
+ emoji: "\u{1F528}",
65
+ trailer: "Changelog: refactor"
64
66
  },
65
67
  {
66
68
  value: "perf",
67
69
  label: "perf",
68
70
  hint: "A code change that improves performance",
69
- emoji: "\u{1F680}"
71
+ emoji: "\u{1F680}",
72
+ trailer: "Changelog: performance"
70
73
  },
71
74
  {
72
75
  value: "test",
73
76
  label: "test",
74
77
  hint: "Adding missing tests or correcting existing tests",
75
- emoji: "\u{1F6A8}"
78
+ emoji: "\u{1F6A8}",
79
+ trailer: "Changelog: test"
76
80
  },
77
81
  {
78
82
  value: "build",
79
83
  label: "build",
80
84
  hint: "Changes that affect the build system or external dependencies",
81
- emoji: "\u{1F6A7}"
85
+ emoji: "\u{1F6A7}",
86
+ trailer: "Changelog: build"
82
87
  },
83
88
  {
84
89
  value: "ci",
85
90
  label: "ci",
86
91
  hint: "Changes to our CI configuration files and scripts",
87
- emoji: "\u{1F916}"
92
+ emoji: "\u{1F916}",
93
+ trailer: "Changelog: ci"
88
94
  },
89
95
  {
90
96
  value: "chore",
91
97
  label: "chore",
92
98
  hint: "Other changes that do not modify src or test files",
93
- emoji: "\u{1F9F9}"
99
+ emoji: "\u{1F9F9}",
100
+ trailer: "Changelog: chore"
94
101
  },
95
102
  { value: "", label: "none" }
96
103
  ];
@@ -104,6 +111,7 @@ var DEFAULT_SCOPE_OPTIONS = [
104
111
  var CUSTOM_SCOPE_KEY = "custom";
105
112
  var Z_FOOTER_OPTIONS = import_zod.z.enum([
106
113
  "closes",
114
+ "trailer",
107
115
  "breaking-change",
108
116
  "deprecated",
109
117
  "custom"
@@ -111,6 +119,7 @@ var Z_FOOTER_OPTIONS = import_zod.z.enum([
111
119
  var Z_BRANCH_ACTIONS = import_zod.z.enum(["branch", "worktree"]);
112
120
  var FOOTER_OPTION_VALUES = [
113
121
  "closes",
122
+ "trailer",
114
123
  "breaking-change",
115
124
  "deprecated",
116
125
  "custom"
@@ -187,7 +196,8 @@ var Config = import_zod2.z.object({
187
196
  value: import_zod2.z.string(),
188
197
  label: import_zod2.z.string().optional(),
189
198
  hint: import_zod2.z.string().optional(),
190
- emoji: import_zod2.z.string().emoji().optional()
199
+ emoji: import_zod2.z.string().emoji().optional(),
200
+ trailer: import_zod2.z.string().optional()
191
201
  })
192
202
  ).default(DEFAULT_TYPE_OPTIONS)
193
203
  }).default({}).transform((val) => {
@@ -243,7 +253,8 @@ var Config = import_zod2.z.object({
243
253
  confirm_ticket: import_zod2.z.boolean().default(true),
244
254
  add_to_title: import_zod2.z.boolean().default(true),
245
255
  append_hashtag: import_zod2.z.boolean().default(false),
246
- title_position: import_zod2.z.enum(["start", "end"]).default("start")
256
+ surround: import_zod2.z.enum(["", "()", "[]", "{}"]).default(""),
257
+ title_position: import_zod2.z.enum(["start", "end", "before-colon"]).default("start")
247
258
  }).default({}),
248
259
  commit_title: import_zod2.z.object({
249
260
  max_size: import_zod2.z.number().positive().default(70)
@@ -299,7 +310,8 @@ var CommitState = import_zod2.z.object({
299
310
  deprecates: import_zod2.z.string().default(""),
300
311
  deprecates_title: import_zod2.z.string().default(""),
301
312
  deprecates_body: import_zod2.z.string().default(""),
302
- custom_footer: import_zod2.z.string().default("")
313
+ custom_footer: import_zod2.z.string().default(""),
314
+ trailer: import_zod2.z.string().default("")
303
315
  }).default({});
304
316
  var BranchState = import_zod2.z.object({
305
317
  user: import_zod2.z.string().default(""),
package/dist/index.js CHANGED
@@ -64,49 +64,56 @@ var REGEX_START_NUM = new RegExp(/^(\d+)/);
64
64
  var REGEX_START_UND = new RegExp(/^([A-Z]+-[\[a-zA-Z\]\d]+)_/);
65
65
  var REGEX_SLASH_UND = new RegExp(/\/([A-Z]+-[\[a-zA-Z\]\d]+)_/);
66
66
  var DEFAULT_TYPE_OPTIONS = [
67
- { value: "feat", label: "feat", hint: "A new feature", emoji: "\u2728" },
68
- { value: "fix", label: "fix", hint: "A bug fix", emoji: "\u{1F41B}" },
67
+ { value: "feat", label: "feat", hint: "A new feature", emoji: "\u2728", trailer: "Changelog: feature" },
68
+ { value: "fix", label: "fix", hint: "A bug fix", emoji: "\u{1F41B}", trailer: "Changelog: fix" },
69
69
  {
70
70
  value: "docs",
71
71
  label: "docs",
72
72
  hint: "Documentation only changes",
73
- emoji: "\u{1F4DA}"
73
+ emoji: "\u{1F4DA}",
74
+ trailer: "Changelog: documentation"
74
75
  },
75
76
  {
76
77
  value: "refactor",
77
78
  label: "refactor",
78
79
  hint: "A code change that neither fixes a bug nor adds a feature",
79
- emoji: "\u{1F528}"
80
+ emoji: "\u{1F528}",
81
+ trailer: "Changelog: refactor"
80
82
  },
81
83
  {
82
84
  value: "perf",
83
85
  label: "perf",
84
86
  hint: "A code change that improves performance",
85
- emoji: "\u{1F680}"
87
+ emoji: "\u{1F680}",
88
+ trailer: "Changelog: performance"
86
89
  },
87
90
  {
88
91
  value: "test",
89
92
  label: "test",
90
93
  hint: "Adding missing tests or correcting existing tests",
91
- emoji: "\u{1F6A8}"
94
+ emoji: "\u{1F6A8}",
95
+ trailer: "Changelog: test"
92
96
  },
93
97
  {
94
98
  value: "build",
95
99
  label: "build",
96
100
  hint: "Changes that affect the build system or external dependencies",
97
- emoji: "\u{1F6A7}"
101
+ emoji: "\u{1F6A7}",
102
+ trailer: "Changelog: build"
98
103
  },
99
104
  {
100
105
  value: "ci",
101
106
  label: "ci",
102
107
  hint: "Changes to our CI configuration files and scripts",
103
- emoji: "\u{1F916}"
108
+ emoji: "\u{1F916}",
109
+ trailer: "Changelog: ci"
104
110
  },
105
111
  {
106
112
  value: "chore",
107
113
  label: "chore",
108
114
  hint: "Other changes that do not modify src or test files",
109
- emoji: "\u{1F9F9}"
115
+ emoji: "\u{1F9F9}",
116
+ trailer: "Changelog: chore"
110
117
  },
111
118
  { value: "", label: "none" }
112
119
  ];
@@ -123,6 +130,11 @@ var COMMIT_FOOTER_OPTIONS = [
123
130
  label: "closes <issue/ticket>",
124
131
  hint: "Attempts to infer ticket from branch"
125
132
  },
133
+ {
134
+ value: "trailer",
135
+ label: "trailer",
136
+ hint: "Appends trailer based on commit type"
137
+ },
126
138
  {
127
139
  value: "breaking-change",
128
140
  label: "breaking change",
@@ -134,6 +146,7 @@ var COMMIT_FOOTER_OPTIONS = [
134
146
  var CUSTOM_SCOPE_KEY = "custom";
135
147
  var Z_FOOTER_OPTIONS = import_zod.z.enum([
136
148
  "closes",
149
+ "trailer",
137
150
  "breaking-change",
138
151
  "deprecated",
139
152
  "custom"
@@ -141,6 +154,7 @@ var Z_FOOTER_OPTIONS = import_zod.z.enum([
141
154
  var Z_BRANCH_ACTIONS = import_zod.z.enum(["branch", "worktree"]);
142
155
  var FOOTER_OPTION_VALUES = [
143
156
  "closes",
157
+ "trailer",
144
158
  "breaking-change",
145
159
  "deprecated",
146
160
  "custom"
@@ -246,7 +260,8 @@ var Config = import_zod2.z.object({
246
260
  value: import_zod2.z.string(),
247
261
  label: import_zod2.z.string().optional(),
248
262
  hint: import_zod2.z.string().optional(),
249
- emoji: import_zod2.z.string().emoji().optional()
263
+ emoji: import_zod2.z.string().emoji().optional(),
264
+ trailer: import_zod2.z.string().optional()
250
265
  })
251
266
  ).default(DEFAULT_TYPE_OPTIONS)
252
267
  }).default({}).transform((val) => {
@@ -302,7 +317,8 @@ var Config = import_zod2.z.object({
302
317
  confirm_ticket: import_zod2.z.boolean().default(true),
303
318
  add_to_title: import_zod2.z.boolean().default(true),
304
319
  append_hashtag: import_zod2.z.boolean().default(false),
305
- title_position: import_zod2.z.enum(["start", "end"]).default("start")
320
+ surround: import_zod2.z.enum(["", "()", "[]", "{}"]).default(""),
321
+ title_position: import_zod2.z.enum(["start", "end", "before-colon"]).default("start")
306
322
  }).default({}),
307
323
  commit_title: import_zod2.z.object({
308
324
  max_size: import_zod2.z.number().positive().default(70)
@@ -358,7 +374,8 @@ var CommitState = import_zod2.z.object({
358
374
  deprecates: import_zod2.z.string().default(""),
359
375
  deprecates_title: import_zod2.z.string().default(""),
360
376
  deprecates_body: import_zod2.z.string().default(""),
361
- custom_footer: import_zod2.z.string().default("")
377
+ custom_footer: import_zod2.z.string().default(""),
378
+ trailer: import_zod2.z.string().default("")
362
379
  }).default({});
363
380
  var BranchState = import_zod2.z.object({
364
381
  user: import_zod2.z.string().default(""),
@@ -455,8 +472,8 @@ async function main(config) {
455
472
  initial_value = type_from_branch;
456
473
  }
457
474
  }
458
- const value_to_emoji = config.commit_type.options.reduce(
459
- (acc, curr) => ({ ...acc, [curr.value]: curr.emoji ?? "" }),
475
+ const value_to_data = config.commit_type.options.reduce(
476
+ (acc, curr) => ({ ...acc, [curr.value]: { emoji: curr.emoji ?? "", trailer: curr.trailer ?? "" } }),
460
477
  {}
461
478
  );
462
479
  const commit_type = await p3.select(
@@ -468,7 +485,8 @@ async function main(config) {
468
485
  );
469
486
  if (p3.isCancel(commit_type))
470
487
  process.exit(0);
471
- commit_state.type = config.commit_type.append_emoji_to_commit ? `${value_to_emoji[commit_type]} ${commit_type}`.trim() : commit_type;
488
+ commit_state.trailer = value_to_data[commit_type].trailer;
489
+ commit_state.type = config.commit_type.append_emoji_to_commit ? `${value_to_data[commit_type].emoji} ${commit_type}`.trim() : commit_type;
472
490
  }
473
491
  if (config.commit_scope.enable) {
474
492
  let commit_scope = await p3.select({
@@ -607,9 +625,12 @@ async function main(config) {
607
625
  process.exit(0);
608
626
  commit_state.custom_footer = custom_footer;
609
627
  }
628
+ if (!commit_footer.includes("trailer")) {
629
+ commit_state.trailer = "";
630
+ }
610
631
  }
611
632
  let continue_commit = true;
612
- p3.note(build_commit_string(commit_state, config, true, false), "Commit Preview");
633
+ p3.note(build_commit_string(commit_state, config, true, false, true), "Commit Preview");
613
634
  if (config.confirm_commit) {
614
635
  continue_commit = await p3.confirm({ message: "Confirm Commit?" });
615
636
  if (p3.isCancel(continue_commit))
@@ -621,14 +642,15 @@ async function main(config) {
621
642
  }
622
643
  try {
623
644
  const options = config.overrides.shell ? { shell: config.overrides.shell } : {};
624
- const output = (0, import_child_process3.execSync)(`git commit -m "${build_commit_string(commit_state, config, false, true)}"`, options).toString().trim();
645
+ const trailer = commit_state.trailer ? `--trailer="${commit_state.trailer}"` : "";
646
+ const output = (0, import_child_process3.execSync)(`git commit -m "${build_commit_string(commit_state, config, false, true, false)}" ${trailer}`, options).toString().trim();
625
647
  if (config.print_commit_output)
626
648
  p3.log.info(output);
627
649
  } catch (err) {
628
650
  p3.log.error("Something went wrong when committing: " + err);
629
651
  }
630
652
  }
631
- function build_commit_string(commit_state, config, colorize = false, escape_quotes = false) {
653
+ function build_commit_string(commit_state, config, colorize = false, escape_quotes = false, include_trailer = false) {
632
654
  let commit_string = "";
633
655
  if (commit_state.type) {
634
656
  commit_string += colorize ? import_picocolors3.default.blue(commit_state.type) : commit_state.type;
@@ -637,22 +659,34 @@ function build_commit_string(commit_state, config, colorize = false, escape_quot
637
659
  const scope = colorize ? import_picocolors3.default.cyan(commit_state.scope) : commit_state.scope;
638
660
  commit_string += `(${scope})`;
639
661
  }
662
+ let title_ticket = commit_state.ticket;
663
+ const surround = config.check_ticket.surround;
664
+ if (commit_state.ticket && surround) {
665
+ const open_token = surround.charAt(0);
666
+ const close_token = surround.charAt(1);
667
+ title_ticket = `${open_token}${commit_state.ticket}${close_token}`;
668
+ }
669
+ const position_before_colon = config.check_ticket.title_position === "before-colon";
670
+ if (title_ticket && config.check_ticket.add_to_title && position_before_colon) {
671
+ const spacing = commit_state.scope || commit_state.type && !config.check_ticket.surround ? " " : "";
672
+ commit_string += colorize ? import_picocolors3.default.magenta(spacing + title_ticket) : spacing + title_ticket;
673
+ }
640
674
  if (commit_state.breaking_title && config.breaking_change.add_exclamation_to_title) {
641
675
  commit_string += colorize ? import_picocolors3.default.red("!") : "!";
642
676
  }
643
- if (commit_state.scope || commit_state.type) {
677
+ if (commit_state.scope || commit_state.type || title_ticket && position_before_colon) {
644
678
  commit_string += ": ";
645
679
  }
646
680
  const position_start = config.check_ticket.title_position === "start";
647
681
  const position_end = config.check_ticket.title_position === "end";
648
- if (commit_state.ticket && config.check_ticket.add_to_title && position_start) {
649
- commit_string += colorize ? import_picocolors3.default.magenta(commit_state.ticket) + " " : commit_state.ticket + " ";
682
+ if (title_ticket && config.check_ticket.add_to_title && position_start) {
683
+ commit_string += colorize ? import_picocolors3.default.magenta(title_ticket) + " " : title_ticket + " ";
650
684
  }
651
685
  if (commit_state.title) {
652
686
  commit_string += colorize ? import_picocolors3.default.reset(commit_state.title) : commit_state.title;
653
687
  }
654
- if (commit_state.ticket && config.check_ticket.add_to_title && position_end) {
655
- commit_string += " " + (colorize ? import_picocolors3.default.magenta(commit_state.ticket) : commit_state.ticket);
688
+ if (title_ticket && config.check_ticket.add_to_title && position_end) {
689
+ commit_string += " " + (colorize ? import_picocolors3.default.magenta(title_ticket) : title_ticket);
656
690
  }
657
691
  if (commit_state.body) {
658
692
  const temp = commit_state.body.split("\\n");
@@ -702,6 +736,13 @@ ${res}`;
702
736
  ${import_picocolors3.default.reset(commit_state.closes)} ${import_picocolors3.default.magenta(commit_state.ticket)}` : `
703
737
 
704
738
  ${commit_state.closes} ${commit_state.ticket}`;
739
+ }
740
+ if (include_trailer && commit_state.trailer) {
741
+ commit_string += colorize ? `
742
+
743
+ ${import_picocolors3.default.dim(commit_state.trailer)}` : `
744
+
745
+ ${commit_state.trailer}`;
705
746
  }
706
747
  if (escape_quotes) {
707
748
  commit_string = commit_string.replaceAll('"', '\\"');
package/dist/init.js CHANGED
@@ -46,49 +46,56 @@ var REGEX_START_NUM = new RegExp(/^(\d+)/);
46
46
  var REGEX_START_UND = new RegExp(/^([A-Z]+-[\[a-zA-Z\]\d]+)_/);
47
47
  var REGEX_SLASH_UND = new RegExp(/\/([A-Z]+-[\[a-zA-Z\]\d]+)_/);
48
48
  var DEFAULT_TYPE_OPTIONS = [
49
- { value: "feat", label: "feat", hint: "A new feature", emoji: "\u2728" },
50
- { value: "fix", label: "fix", hint: "A bug fix", emoji: "\u{1F41B}" },
49
+ { value: "feat", label: "feat", hint: "A new feature", emoji: "\u2728", trailer: "Changelog: feature" },
50
+ { value: "fix", label: "fix", hint: "A bug fix", emoji: "\u{1F41B}", trailer: "Changelog: fix" },
51
51
  {
52
52
  value: "docs",
53
53
  label: "docs",
54
54
  hint: "Documentation only changes",
55
- emoji: "\u{1F4DA}"
55
+ emoji: "\u{1F4DA}",
56
+ trailer: "Changelog: documentation"
56
57
  },
57
58
  {
58
59
  value: "refactor",
59
60
  label: "refactor",
60
61
  hint: "A code change that neither fixes a bug nor adds a feature",
61
- emoji: "\u{1F528}"
62
+ emoji: "\u{1F528}",
63
+ trailer: "Changelog: refactor"
62
64
  },
63
65
  {
64
66
  value: "perf",
65
67
  label: "perf",
66
68
  hint: "A code change that improves performance",
67
- emoji: "\u{1F680}"
69
+ emoji: "\u{1F680}",
70
+ trailer: "Changelog: performance"
68
71
  },
69
72
  {
70
73
  value: "test",
71
74
  label: "test",
72
75
  hint: "Adding missing tests or correcting existing tests",
73
- emoji: "\u{1F6A8}"
76
+ emoji: "\u{1F6A8}",
77
+ trailer: "Changelog: test"
74
78
  },
75
79
  {
76
80
  value: "build",
77
81
  label: "build",
78
82
  hint: "Changes that affect the build system or external dependencies",
79
- emoji: "\u{1F6A7}"
83
+ emoji: "\u{1F6A7}",
84
+ trailer: "Changelog: build"
80
85
  },
81
86
  {
82
87
  value: "ci",
83
88
  label: "ci",
84
89
  hint: "Changes to our CI configuration files and scripts",
85
- emoji: "\u{1F916}"
90
+ emoji: "\u{1F916}",
91
+ trailer: "Changelog: ci"
86
92
  },
87
93
  {
88
94
  value: "chore",
89
95
  label: "chore",
90
96
  hint: "Other changes that do not modify src or test files",
91
- emoji: "\u{1F9F9}"
97
+ emoji: "\u{1F9F9}",
98
+ trailer: "Changelog: chore"
92
99
  },
93
100
  { value: "", label: "none" }
94
101
  ];
@@ -102,6 +109,7 @@ var DEFAULT_SCOPE_OPTIONS = [
102
109
  var CUSTOM_SCOPE_KEY = "custom";
103
110
  var Z_FOOTER_OPTIONS = import_zod.z.enum([
104
111
  "closes",
112
+ "trailer",
105
113
  "breaking-change",
106
114
  "deprecated",
107
115
  "custom"
@@ -109,6 +117,7 @@ var Z_FOOTER_OPTIONS = import_zod.z.enum([
109
117
  var Z_BRANCH_ACTIONS = import_zod.z.enum(["branch", "worktree"]);
110
118
  var FOOTER_OPTION_VALUES = [
111
119
  "closes",
120
+ "trailer",
112
121
  "breaking-change",
113
122
  "deprecated",
114
123
  "custom"
@@ -139,7 +148,8 @@ var Config = import_zod2.z.object({
139
148
  value: import_zod2.z.string(),
140
149
  label: import_zod2.z.string().optional(),
141
150
  hint: import_zod2.z.string().optional(),
142
- emoji: import_zod2.z.string().emoji().optional()
151
+ emoji: import_zod2.z.string().emoji().optional(),
152
+ trailer: import_zod2.z.string().optional()
143
153
  })
144
154
  ).default(DEFAULT_TYPE_OPTIONS)
145
155
  }).default({}).transform((val) => {
@@ -195,7 +205,8 @@ var Config = import_zod2.z.object({
195
205
  confirm_ticket: import_zod2.z.boolean().default(true),
196
206
  add_to_title: import_zod2.z.boolean().default(true),
197
207
  append_hashtag: import_zod2.z.boolean().default(false),
198
- title_position: import_zod2.z.enum(["start", "end"]).default("start")
208
+ surround: import_zod2.z.enum(["", "()", "[]", "{}"]).default(""),
209
+ title_position: import_zod2.z.enum(["start", "end", "before-colon"]).default("start")
199
210
  }).default({}),
200
211
  commit_title: import_zod2.z.object({
201
212
  max_size: import_zod2.z.number().positive().default(70)
@@ -251,7 +262,8 @@ var CommitState = import_zod2.z.object({
251
262
  deprecates: import_zod2.z.string().default(""),
252
263
  deprecates_title: import_zod2.z.string().default(""),
253
264
  deprecates_body: import_zod2.z.string().default(""),
254
- custom_footer: import_zod2.z.string().default("")
265
+ custom_footer: import_zod2.z.string().default(""),
266
+ trailer: import_zod2.z.string().default("")
255
267
  }).default({});
256
268
  var BranchState = import_zod2.z.object({
257
269
  user: import_zod2.z.string().default(""),
package/dist/utils.js CHANGED
@@ -80,7 +80,8 @@ var Config = import_zod.z.object({
80
80
  value: import_zod.z.string(),
81
81
  label: import_zod.z.string().optional(),
82
82
  hint: import_zod.z.string().optional(),
83
- emoji: import_zod.z.string().emoji().optional()
83
+ emoji: import_zod.z.string().emoji().optional(),
84
+ trailer: import_zod.z.string().optional()
84
85
  })
85
86
  ).default(DEFAULT_TYPE_OPTIONS)
86
87
  }).default({}).transform((val) => {
@@ -136,7 +137,8 @@ var Config = import_zod.z.object({
136
137
  confirm_ticket: import_zod.z.boolean().default(true),
137
138
  add_to_title: import_zod.z.boolean().default(true),
138
139
  append_hashtag: import_zod.z.boolean().default(false),
139
- title_position: import_zod.z.enum(["start", "end"]).default("start")
140
+ surround: import_zod.z.enum(["", "()", "[]", "{}"]).default(""),
141
+ title_position: import_zod.z.enum(["start", "end", "before-colon"]).default("start")
140
142
  }).default({}),
141
143
  commit_title: import_zod.z.object({
142
144
  max_size: import_zod.z.number().positive().default(70)
@@ -192,7 +194,8 @@ var CommitState = import_zod.z.object({
192
194
  deprecates: import_zod.z.string().default(""),
193
195
  deprecates_title: import_zod.z.string().default(""),
194
196
  deprecates_body: import_zod.z.string().default(""),
195
- custom_footer: import_zod.z.string().default("")
197
+ custom_footer: import_zod.z.string().default(""),
198
+ trailer: import_zod.z.string().default("")
196
199
  }).default({});
197
200
  var BranchState = import_zod.z.object({
198
201
  user: import_zod.z.string().default(""),
@@ -216,49 +219,56 @@ var REGEX_START_NUM = new RegExp(/^(\d+)/);
216
219
  var REGEX_START_UND = new RegExp(/^([A-Z]+-[\[a-zA-Z\]\d]+)_/);
217
220
  var REGEX_SLASH_UND = new RegExp(/\/([A-Z]+-[\[a-zA-Z\]\d]+)_/);
218
221
  var DEFAULT_TYPE_OPTIONS = [
219
- { value: "feat", label: "feat", hint: "A new feature", emoji: "\u2728" },
220
- { value: "fix", label: "fix", hint: "A bug fix", emoji: "\u{1F41B}" },
222
+ { value: "feat", label: "feat", hint: "A new feature", emoji: "\u2728", trailer: "Changelog: feature" },
223
+ { value: "fix", label: "fix", hint: "A bug fix", emoji: "\u{1F41B}", trailer: "Changelog: fix" },
221
224
  {
222
225
  value: "docs",
223
226
  label: "docs",
224
227
  hint: "Documentation only changes",
225
- emoji: "\u{1F4DA}"
228
+ emoji: "\u{1F4DA}",
229
+ trailer: "Changelog: documentation"
226
230
  },
227
231
  {
228
232
  value: "refactor",
229
233
  label: "refactor",
230
234
  hint: "A code change that neither fixes a bug nor adds a feature",
231
- emoji: "\u{1F528}"
235
+ emoji: "\u{1F528}",
236
+ trailer: "Changelog: refactor"
232
237
  },
233
238
  {
234
239
  value: "perf",
235
240
  label: "perf",
236
241
  hint: "A code change that improves performance",
237
- emoji: "\u{1F680}"
242
+ emoji: "\u{1F680}",
243
+ trailer: "Changelog: performance"
238
244
  },
239
245
  {
240
246
  value: "test",
241
247
  label: "test",
242
248
  hint: "Adding missing tests or correcting existing tests",
243
- emoji: "\u{1F6A8}"
249
+ emoji: "\u{1F6A8}",
250
+ trailer: "Changelog: test"
244
251
  },
245
252
  {
246
253
  value: "build",
247
254
  label: "build",
248
255
  hint: "Changes that affect the build system or external dependencies",
249
- emoji: "\u{1F6A7}"
256
+ emoji: "\u{1F6A7}",
257
+ trailer: "Changelog: build"
250
258
  },
251
259
  {
252
260
  value: "ci",
253
261
  label: "ci",
254
262
  hint: "Changes to our CI configuration files and scripts",
255
- emoji: "\u{1F916}"
263
+ emoji: "\u{1F916}",
264
+ trailer: "Changelog: ci"
256
265
  },
257
266
  {
258
267
  value: "chore",
259
268
  label: "chore",
260
269
  hint: "Other changes that do not modify src or test files",
261
- emoji: "\u{1F9F9}"
270
+ emoji: "\u{1F9F9}",
271
+ trailer: "Changelog: chore"
262
272
  },
263
273
  { value: "", label: "none" }
264
274
  ];
@@ -275,6 +285,11 @@ var COMMIT_FOOTER_OPTIONS = [
275
285
  label: "closes <issue/ticket>",
276
286
  hint: "Attempts to infer ticket from branch"
277
287
  },
288
+ {
289
+ value: "trailer",
290
+ label: "trailer",
291
+ hint: "Appends trailer based on commit type"
292
+ },
278
293
  {
279
294
  value: "breaking-change",
280
295
  label: "breaking change",
@@ -286,6 +301,7 @@ var COMMIT_FOOTER_OPTIONS = [
286
301
  var CUSTOM_SCOPE_KEY = "custom";
287
302
  var Z_FOOTER_OPTIONS = import_zod2.z.enum([
288
303
  "closes",
304
+ "trailer",
289
305
  "breaking-change",
290
306
  "deprecated",
291
307
  "custom"
@@ -293,6 +309,7 @@ var Z_FOOTER_OPTIONS = import_zod2.z.enum([
293
309
  var Z_BRANCH_ACTIONS = import_zod2.z.enum(["branch", "worktree"]);
294
310
  var FOOTER_OPTION_VALUES = [
295
311
  "closes",
312
+ "trailer",
296
313
  "breaking-change",
297
314
  "deprecated",
298
315
  "custom"
package/dist/zod-state.js CHANGED
@@ -55,49 +55,56 @@ var REGEX_START_NUM = new RegExp(/^(\d+)/);
55
55
  var REGEX_START_UND = new RegExp(/^([A-Z]+-[\[a-zA-Z\]\d]+)_/);
56
56
  var REGEX_SLASH_UND = new RegExp(/\/([A-Z]+-[\[a-zA-Z\]\d]+)_/);
57
57
  var DEFAULT_TYPE_OPTIONS = [
58
- { value: "feat", label: "feat", hint: "A new feature", emoji: "\u2728" },
59
- { value: "fix", label: "fix", hint: "A bug fix", emoji: "\u{1F41B}" },
58
+ { value: "feat", label: "feat", hint: "A new feature", emoji: "\u2728", trailer: "Changelog: feature" },
59
+ { value: "fix", label: "fix", hint: "A bug fix", emoji: "\u{1F41B}", trailer: "Changelog: fix" },
60
60
  {
61
61
  value: "docs",
62
62
  label: "docs",
63
63
  hint: "Documentation only changes",
64
- emoji: "\u{1F4DA}"
64
+ emoji: "\u{1F4DA}",
65
+ trailer: "Changelog: documentation"
65
66
  },
66
67
  {
67
68
  value: "refactor",
68
69
  label: "refactor",
69
70
  hint: "A code change that neither fixes a bug nor adds a feature",
70
- emoji: "\u{1F528}"
71
+ emoji: "\u{1F528}",
72
+ trailer: "Changelog: refactor"
71
73
  },
72
74
  {
73
75
  value: "perf",
74
76
  label: "perf",
75
77
  hint: "A code change that improves performance",
76
- emoji: "\u{1F680}"
78
+ emoji: "\u{1F680}",
79
+ trailer: "Changelog: performance"
77
80
  },
78
81
  {
79
82
  value: "test",
80
83
  label: "test",
81
84
  hint: "Adding missing tests or correcting existing tests",
82
- emoji: "\u{1F6A8}"
85
+ emoji: "\u{1F6A8}",
86
+ trailer: "Changelog: test"
83
87
  },
84
88
  {
85
89
  value: "build",
86
90
  label: "build",
87
91
  hint: "Changes that affect the build system or external dependencies",
88
- emoji: "\u{1F6A7}"
92
+ emoji: "\u{1F6A7}",
93
+ trailer: "Changelog: build"
89
94
  },
90
95
  {
91
96
  value: "ci",
92
97
  label: "ci",
93
98
  hint: "Changes to our CI configuration files and scripts",
94
- emoji: "\u{1F916}"
99
+ emoji: "\u{1F916}",
100
+ trailer: "Changelog: ci"
95
101
  },
96
102
  {
97
103
  value: "chore",
98
104
  label: "chore",
99
105
  hint: "Other changes that do not modify src or test files",
100
- emoji: "\u{1F9F9}"
106
+ emoji: "\u{1F9F9}",
107
+ trailer: "Changelog: chore"
101
108
  },
102
109
  { value: "", label: "none" }
103
110
  ];
@@ -111,6 +118,7 @@ var DEFAULT_SCOPE_OPTIONS = [
111
118
  var CUSTOM_SCOPE_KEY = "custom";
112
119
  var Z_FOOTER_OPTIONS = import_zod.z.enum([
113
120
  "closes",
121
+ "trailer",
114
122
  "breaking-change",
115
123
  "deprecated",
116
124
  "custom"
@@ -118,6 +126,7 @@ var Z_FOOTER_OPTIONS = import_zod.z.enum([
118
126
  var Z_BRANCH_ACTIONS = import_zod.z.enum(["branch", "worktree"]);
119
127
  var FOOTER_OPTION_VALUES = [
120
128
  "closes",
129
+ "trailer",
121
130
  "breaking-change",
122
131
  "deprecated",
123
132
  "custom"
@@ -137,7 +146,8 @@ var Config = import_zod2.z.object({
137
146
  value: import_zod2.z.string(),
138
147
  label: import_zod2.z.string().optional(),
139
148
  hint: import_zod2.z.string().optional(),
140
- emoji: import_zod2.z.string().emoji().optional()
149
+ emoji: import_zod2.z.string().emoji().optional(),
150
+ trailer: import_zod2.z.string().optional()
141
151
  })
142
152
  ).default(DEFAULT_TYPE_OPTIONS)
143
153
  }).default({}).transform((val) => {
@@ -193,7 +203,8 @@ var Config = import_zod2.z.object({
193
203
  confirm_ticket: import_zod2.z.boolean().default(true),
194
204
  add_to_title: import_zod2.z.boolean().default(true),
195
205
  append_hashtag: import_zod2.z.boolean().default(false),
196
- title_position: import_zod2.z.enum(["start", "end"]).default("start")
206
+ surround: import_zod2.z.enum(["", "()", "[]", "{}"]).default(""),
207
+ title_position: import_zod2.z.enum(["start", "end", "before-colon"]).default("start")
197
208
  }).default({}),
198
209
  commit_title: import_zod2.z.object({
199
210
  max_size: import_zod2.z.number().positive().default(70)
@@ -249,7 +260,8 @@ var CommitState = import_zod2.z.object({
249
260
  deprecates: import_zod2.z.string().default(""),
250
261
  deprecates_title: import_zod2.z.string().default(""),
251
262
  deprecates_body: import_zod2.z.string().default(""),
252
- custom_footer: import_zod2.z.string().default("")
263
+ custom_footer: import_zod2.z.string().default(""),
264
+ trailer: import_zod2.z.string().default("")
253
265
  }).default({});
254
266
  var BranchState = import_zod2.z.object({
255
267
  user: import_zod2.z.string().default(""),
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "better-commits",
3
3
  "private": false,
4
- "version": "1.8.1",
5
- "description": "A CLI for creating better commits following the conventional commit guidelines",
4
+ "version": "1.10.0",
5
+ "description": "A CLI for creating better commits following the conventional commits specification",
6
6
  "author": "Erik Verduin (https://github.com/everduin94)",
7
7
  "keywords": [
8
8
  "typescript",
package/readme.md CHANGED
@@ -10,7 +10,7 @@
10
10
  </h3>
11
11
 
12
12
  <p align="center">
13
- A CLI for writing better commits, following the conventional commit guidelines.
13
+ A CLI for writing better commits, following the conventional commits specification.
14
14
  </p>
15
15
 
16
16
 
@@ -28,6 +28,12 @@ https://github.com/Everduin94/better-commits/assets/14320878/8fb15d46-17c4-4e5d-
28
28
  - Configure globally or per repository
29
29
  - Config validation and error messaging
30
30
 
31
+ As a side-effect of formatting messages
32
+ - Auto populate PR title / body
33
+ - Automate semantic releases
34
+ - Automate changelogs
35
+ - Automatically link & close related tickets / issues
36
+
31
37
  ## ๐Ÿ“ฆ Installation
32
38
 
33
39
  ```sh
@@ -89,55 +95,64 @@ Better-commits (& better-branch) are highly flexible with sane defaults. These o
89
95
  "value": "feat",
90
96
  "label": "feat",
91
97
  "hint": "A new feature",
92
- "emoji": "โœจ"
98
+ "emoji": "โœจ",
99
+ "trailer": "Changelog: feature"
93
100
  },
94
101
  {
95
102
  "value": "fix",
96
103
  "label": "fix",
97
104
  "hint": "A bug fix",
98
- "emoji": "๐Ÿ›"
105
+ "emoji": "๐Ÿ›",
106
+ "trailer": "Changelog: fix"
99
107
  },
100
108
  {
101
109
  "value": "docs",
102
110
  "label": "docs",
103
111
  "hint": "Documentation only changes",
104
- "emoji": "๐Ÿ“š"
112
+ "emoji": "๐Ÿ“š",
113
+ "trailer": "Changelog: documentation"
105
114
  },
106
115
  {
107
116
  "value": "refactor",
108
117
  "label": "refactor",
109
118
  "hint": "A code change that neither fixes a bug nor adds a feature",
110
- "emoji": "๐Ÿ”จ"
119
+ "emoji": "๐Ÿ”จ",
120
+ "trailer": "Changelog: refactor"
111
121
  },
112
122
  {
113
123
  "value": "perf",
114
124
  "label": "perf",
115
125
  "hint": "A code change that improves performance",
116
- "emoji": "๐Ÿš€"
126
+ "emoji": "๐Ÿš€",
127
+ "trailer": "Changelog: performance"
117
128
  },
118
129
  {
119
130
  "value": "test",
120
131
  "label": "test",
121
132
  "hint": "Adding missing tests or correcting existing tests",
122
- "emoji": "๐Ÿšจ"
133
+ "emoji": "๐Ÿšจ",
134
+ "trailer": "Changelog: test"
123
135
  },
124
136
  {
125
137
  "value": "build",
126
138
  "label": "build",
127
139
  "hint": "Changes that affect the build system or external dependencies",
128
- "emoji": "๐Ÿšง"
140
+ "emoji": "๐Ÿšง",
141
+ "trailer": "Changelog: build"
129
142
  },
130
143
  {
131
144
  "value": "ci",
132
145
  "label": "ci",
133
146
  "hint": "Changes to our CI configuration files and scripts",
134
- "emoji": "๐Ÿค–"
147
+ "emoji": "๐Ÿค–",
148
+ "trailer": "Changelog: ci"
135
149
  },
136
150
  {
137
151
  "value": "chore",
138
152
  "label": "chore",
139
153
  "hint": "Other changes that do not modify src or test files",
140
- "emoji": "๐Ÿงน"
154
+ "emoji": "๐Ÿงน",
155
+ "trailer": "Changelog: chore"
141
156
  },
142
157
  {
143
158
  "value": "",
@@ -177,7 +192,8 @@ Better-commits (& better-branch) are highly flexible with sane defaults. These o
177
192
  "confirm_ticket": true,
178
193
  "add_to_title": true,
179
194
  "append_hashtag": false,
180
- "title_position": "start"
195
+ "title_position": "start",
196
+ "surround": ""
181
197
  },
182
198
  "commit_title": {
183
199
  "max_size": 70
@@ -191,6 +207,7 @@ Better-commits (& better-branch) are highly flexible with sane defaults. These o
191
207
  "initial_value": [],
192
208
  "options": [
193
209
  "closes",
210
+ "trailer",
194
211
  "breaking-change",
195
212
  "deprecated",
196
213
  "custom"
@@ -257,6 +274,7 @@ Better-commits (& better-branch) are highly flexible with sane defaults. These o
257
274
  | `commit_type.options.label` | Commit type prompt label |
258
275
  | `commit_type.options.hint` | Commit type inline hint (like this) |
259
276
  | `commit_type.options.emoji` | Commit type emoji |
277
+ | `commit_type.options.trailer` | Commit type trailer |
260
278
  | `commit_scope.enable` | If true include commit scope |
261
279
  | `commit_scope.custom_scope` | If true allow custom scope at run-time |
262
280
  | `commit_scope.initial_value` | Default commit scope selected |
@@ -266,7 +284,8 @@ Better-commits (& better-branch) are highly flexible with sane defaults. These o
266
284
  | `check_ticket.confirm_ticket` | If true manually confirm inference |
267
285
  | `check_ticket.add_to_title` | If true add ticket to title |
268
286
  | `check_ticket.append_hashtag` | If true add hashtag to ticket (Ideal for Github Issues) |
269
- | `check_ticket.title_position` | If "start" ticket at start if "end" ticket at end |
287
+ | `check_ticket.title_position` | "start" (of description) (default), "end", "before-colon" |
288
+ | `check_ticket.surround` | "" (default), "[]", "()", "{}" - Wraps ticket in title |
270
289
  | `commit_title.max_size` | Max size of title including scope, type, etc... |
271
290
  | `commit_body.enable` | If true include body |
272
291
  | `commit_body.required` | If true body is required |
@@ -349,6 +368,10 @@ If you use `better-commits` to create your *first* commit on a new branch
349
368
 
350
369
  If you're using Github issues to track your work, and select the `closes` footer option when writing your commit. Github will **automatically link and close** that issue when your **pr is merged**
351
370
 
371
+ ### Changelogs
372
+
373
+ `better-commits` can append a commit trailer per commit type. This allows you to [automate change logs](https://docs.gitlab.com/ee/user/project/changelogs.html) with tools like Gitlab.
374
+
352
375
  ### Fun Facts
353
376
  [better-commits](https://packagephobia.com/result?p=better-commits) is much smaller than its alternative [commitizen](https://packagephobia.com/result?p=commitizen)
354
377
 
@@ -378,3 +401,14 @@ Example
378
401
  "shell": "c:\\Program Files\\Git\\bin\\bash.exe"
379
402
  }
380
403
  ```
404
+
405
+
406
+ <h1 align="center">๐ŸŒŸ Sponsors</h1>
407
+
408
+ <h3 align="center">
409
+
410
+ [![flotes-g-2](https://github.com/Everduin94/Everduin94/assets/14320878/b0fd0aa5-ca9d-4a2d-8579-7616140927a7)](https://flotes.app)
411
+
412
+ [Markdown Notetaking - Built for Learning](https://flotes.app)
413
+
414
+ </h3>
package/src/index.ts CHANGED
@@ -50,8 +50,8 @@ export async function main(config: z.infer<typeof Config>) {
50
50
  initial_value = type_from_branch
51
51
  }
52
52
  }
53
- const value_to_emoji: Record<string,string> = config.commit_type.options.reduce(
54
- (acc, curr) => ({ ...acc, [curr.value]: curr.emoji ?? '' }), {}
53
+ const value_to_data: Record<string, {emoji: string, trailer: string}> = config.commit_type.options.reduce(
54
+ (acc, curr) => ({ ...acc, [curr.value]: {emoji: curr.emoji ?? '', trailer: curr.trailer ?? '' }}), {}
55
55
  )
56
56
  const commit_type = await p.select(
57
57
  {
@@ -61,8 +61,9 @@ export async function main(config: z.infer<typeof Config>) {
61
61
  }
62
62
  )
63
63
  if (p.isCancel(commit_type)) process.exit(0)
64
+ commit_state.trailer = value_to_data[commit_type].trailer;
64
65
  commit_state.type = config.commit_type.append_emoji_to_commit ?
65
- `${value_to_emoji[commit_type]} ${commit_type}`.trim()
66
+ `${value_to_data[commit_type].emoji} ${commit_type}`.trim()
66
67
  : commit_type;
67
68
  }
68
69
 
@@ -201,11 +202,15 @@ export async function main(config: z.infer<typeof Config>) {
201
202
  if (p.isCancel(custom_footer)) process.exit(0)
202
203
  commit_state.custom_footer = custom_footer;
203
204
  }
205
+
206
+ if (!commit_footer.includes('trailer')) {
207
+ commit_state.trailer = '';
208
+ }
204
209
  }
205
210
 
206
211
 
207
212
  let continue_commit = true;
208
- p.note(build_commit_string(commit_state, config, true, false), 'Commit Preview')
213
+ p.note(build_commit_string(commit_state, config, true, false, true), 'Commit Preview')
209
214
  if (config.confirm_commit) {
210
215
  continue_commit = await p.confirm({message: 'Confirm Commit?'}) as boolean;
211
216
  if (p.isCancel(continue_commit)) process.exit(0)
@@ -218,14 +223,20 @@ export async function main(config: z.infer<typeof Config>) {
218
223
 
219
224
  try {
220
225
  const options = config.overrides.shell ? { shell: config.overrides.shell } : {}
221
- const output = execSync(`git commit -m "${build_commit_string(commit_state, config, false, true)}"`, options).toString().trim();
226
+ const trailer = commit_state.trailer ? `--trailer="${commit_state.trailer}"` : '';
227
+ const output = execSync(`git commit -m "${build_commit_string(commit_state, config, false, true, false)}" ${trailer}`, options).toString().trim();
222
228
  if (config.print_commit_output) p.log.info(output)
223
229
  } catch(err) {
224
230
  p.log.error('Something went wrong when committing: ' + err)
225
231
  }
226
232
  }
227
233
 
228
- function build_commit_string(commit_state: z.infer<typeof CommitState>, config: z.infer<typeof Config>, colorize: boolean = false, escape_quotes: boolean = false): string {
234
+ function build_commit_string(commit_state: z.infer<typeof CommitState>,
235
+ config: z.infer<typeof Config>,
236
+ colorize: boolean = false,
237
+ escape_quotes: boolean = false,
238
+ include_trailer: boolean = false
239
+ ): string {
229
240
  let commit_string = '';
230
241
  if (commit_state.type) {
231
242
  commit_string += colorize ? color.blue(commit_state.type) : commit_state.type
@@ -236,27 +247,40 @@ function build_commit_string(commit_state: z.infer<typeof CommitState>, config:
236
247
  commit_string += `(${scope})`
237
248
  }
238
249
 
250
+ let title_ticket = commit_state.ticket;
251
+ const surround = config.check_ticket.surround;
252
+ if (commit_state.ticket && surround) {
253
+ const open_token = surround.charAt(0);
254
+ const close_token = surround.charAt(1);
255
+ title_ticket = `${open_token}${commit_state.ticket}${close_token}`
256
+ }
257
+
258
+ const position_before_colon = config.check_ticket.title_position === "before-colon"
259
+ if (title_ticket && config.check_ticket.add_to_title && position_before_colon) {
260
+ const spacing = commit_state.scope || (commit_state.type && !config.check_ticket.surround) ? ' ' : '';
261
+ commit_string += colorize ? color.magenta(spacing + title_ticket) : spacing + title_ticket
262
+ }
263
+
239
264
  if (commit_state.breaking_title && config.breaking_change.add_exclamation_to_title) {
240
265
  commit_string += colorize ? color.red('!') : '!'
241
266
  }
242
267
 
243
- if (commit_state.scope || commit_state.type) {
268
+ if (commit_state.scope || commit_state.type || (title_ticket && position_before_colon)) {
244
269
  commit_string += ': '
245
270
  }
246
271
 
247
272
  const position_start = config.check_ticket.title_position === "start"
248
273
  const position_end = config.check_ticket.title_position === "end"
249
-
250
- if(commit_state.ticket && config.check_ticket.add_to_title && position_start) {
251
- commit_string += colorize ? color.magenta(commit_state.ticket) + ' ' : commit_state.ticket + ' '
274
+ if(title_ticket && config.check_ticket.add_to_title && position_start) {
275
+ commit_string += colorize ? color.magenta(title_ticket) + ' ' : title_ticket + ' '
252
276
  }
253
277
 
254
278
  if (commit_state.title) {
255
279
  commit_string += colorize ? color.reset(commit_state.title) : commit_state.title
256
280
  }
257
281
 
258
- if(commit_state.ticket && config.check_ticket.add_to_title && position_end) {
259
- commit_string += ' ' + (colorize ? color.magenta(commit_state.ticket) : commit_state.ticket)
282
+ if(title_ticket && config.check_ticket.add_to_title && position_end) {
283
+ commit_string += ' ' + (colorize ? color.magenta(title_ticket) : title_ticket)
260
284
  }
261
285
 
262
286
  if (commit_state.body) {
@@ -295,6 +319,10 @@ function build_commit_string(commit_state: z.infer<typeof CommitState>, config:
295
319
  commit_string += colorize ? `\n\n${color.reset(commit_state.closes)} ${color.magenta(commit_state.ticket)}` : `\n\n${commit_state.closes} ${commit_state.ticket}`;
296
320
  }
297
321
 
322
+ if (include_trailer && commit_state.trailer) {
323
+ commit_string += colorize ? `\n\n${color.dim(commit_state.trailer)}` : `\n\n${commit_state.trailer}`
324
+ }
325
+
298
326
  if (escape_quotes) {
299
327
  commit_string = commit_string.replaceAll('"', '\\"')
300
328
  }
package/src/utils.ts CHANGED
@@ -22,49 +22,56 @@ export const REGEX_START_UND = new RegExp(/^([A-Z]+-[\[a-zA-Z\]\d]+)_/);
22
22
  export const REGEX_SLASH_UND = new RegExp(/\/([A-Z]+-[\[a-zA-Z\]\d]+)_/);
23
23
 
24
24
  export const DEFAULT_TYPE_OPTIONS = [
25
- { value: "feat", label: "feat", hint: "A new feature", emoji: "โœจ" },
26
- { value: "fix", label: "fix", hint: "A bug fix", emoji: "๐Ÿ›" },
25
+ { value: "feat", label: "feat", hint: "A new feature", emoji: "โœจ", trailer: "Changelog: feature"},
26
+ { value: "fix", label: "fix", hint: "A bug fix", emoji: "๐Ÿ›", trailer: "Changelog: fix"},
27
27
  {
28
28
  value: "docs",
29
29
  label: "docs",
30
30
  hint: "Documentation only changes",
31
31
  emoji: "๐Ÿ“š",
32
+ trailer: "Changelog: documentation"
32
33
  },
33
34
  {
34
35
  value: "refactor",
35
36
  label: "refactor",
36
37
  hint: "A code change that neither fixes a bug nor adds a feature",
37
38
  emoji: "๐Ÿ”จ",
39
+ trailer: "Changelog: refactor"
38
40
  },
39
41
  {
40
42
  value: "perf",
41
43
  label: "perf",
42
44
  hint: "A code change that improves performance",
43
45
  emoji: "๐Ÿš€",
46
+ trailer: "Changelog: performance"
44
47
  },
45
48
  {
46
49
  value: "test",
47
50
  label: "test",
48
51
  hint: "Adding missing tests or correcting existing tests",
49
52
  emoji: "๐Ÿšจ",
53
+ trailer: "Changelog: test"
50
54
  },
51
55
  {
52
56
  value: "build",
53
57
  label: "build",
54
58
  hint: "Changes that affect the build system or external dependencies",
55
59
  emoji: "๐Ÿšง",
60
+ trailer: "Changelog: build"
56
61
  },
57
62
  {
58
63
  value: "ci",
59
64
  label: "ci",
60
65
  hint: "Changes to our CI configuration files and scripts",
61
66
  emoji: "๐Ÿค–",
67
+ trailer: "Changelog: ci"
62
68
  },
63
69
  {
64
70
  value: "chore",
65
71
  label: "chore",
66
72
  hint: "Other changes that do not modify src or test files",
67
73
  emoji: "๐Ÿงน",
74
+ trailer: "Changelog: chore"
68
75
  },
69
76
  { value: "", label: "none" },
70
77
  ];
@@ -81,6 +88,11 @@ export const COMMIT_FOOTER_OPTIONS = [
81
88
  label: "closes <issue/ticket>",
82
89
  hint: "Attempts to infer ticket from branch",
83
90
  },
91
+ {
92
+ value: "trailer",
93
+ label: "trailer",
94
+ hint: "Appends trailer based on commit type",
95
+ },
84
96
  {
85
97
  value: "breaking-change",
86
98
  label: "breaking change",
@@ -93,6 +105,7 @@ export const CUSTOM_SCOPE_KEY: "custom" = "custom";
93
105
 
94
106
  export const Z_FOOTER_OPTIONS = z.enum([
95
107
  "closes",
108
+ "trailer",
96
109
  "breaking-change",
97
110
  "deprecated",
98
111
  "custom",
@@ -100,6 +113,7 @@ export const Z_FOOTER_OPTIONS = z.enum([
100
113
  export const Z_BRANCH_ACTIONS = z.enum(["branch", "worktree"]);
101
114
  export const FOOTER_OPTION_VALUES: z.infer<typeof Z_FOOTER_OPTIONS>[] = [
102
115
  "closes",
116
+ "trailer",
103
117
  "breaking-change",
104
118
  "deprecated",
105
119
  "custom",
package/src/zod-state.ts CHANGED
@@ -25,6 +25,7 @@ export const Config = z
25
25
  label: z.string().optional(),
26
26
  hint: z.string().optional(),
27
27
  emoji: z.string().emoji().optional(),
28
+ trailer: z.string().optional(),
28
29
  })
29
30
  )
30
31
  .default(DEFAULT_TYPE_OPTIONS),
@@ -94,7 +95,8 @@ export const Config = z
94
95
  confirm_ticket: z.boolean().default(true),
95
96
  add_to_title: z.boolean().default(true),
96
97
  append_hashtag: z.boolean().default(false),
97
- title_position: z.enum(["start", "end"]).default("start"),
98
+ surround: z.enum(["", "()", "[]", "{}"]).default(""),
99
+ title_position: z.enum(["start", "end", "before-colon"]).default("start"),
98
100
  })
99
101
  .default({}),
100
102
  commit_title: z
@@ -171,6 +173,7 @@ export const CommitState = z
171
173
  deprecates_title: z.string().default(""),
172
174
  deprecates_body: z.string().default(""),
173
175
  custom_footer: z.string().default(""),
176
+ trailer: z.string().default("")
174
177
  })
175
178
  .default({});
176
179