better-commits 1.9.0 → 1.11.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 +46 -14
- package/dist/index.js +40 -10
- package/dist/init.js +23 -5
- package/dist/utils.js +29 -5
- package/dist/zod-state.js +23 -5
- package/package.json +1 -1
- package/readme.md +36 -6
- package/src/branch.ts +25 -5
- package/src/index.ts +19 -7
- package/src/utils.ts +16 -2
- package/src/zod-state.ts +14 -1
package/dist/branch.js
CHANGED
|
@@ -43,10 +43,10 @@ var OPTIONAL_PROMPT = `${import_picocolors.default.dim("(optional)")}`;
|
|
|
43
43
|
var CACHE_PROMPT = `${import_picocolors.default.dim("(value will be saved)")}`;
|
|
44
44
|
var REGEX_SLASH_TAG = new RegExp(/\/(\w+-\d+)/);
|
|
45
45
|
var REGEX_START_TAG = new RegExp(/^(\w+-\d+)/);
|
|
46
|
-
var REGEX_SLASH_NUM = new RegExp(/\/(\d+)/);
|
|
47
|
-
var REGEX_START_NUM = new RegExp(/^(\d+)/);
|
|
48
46
|
var REGEX_START_UND = new RegExp(/^([A-Z]+-[\[a-zA-Z\]\d]+)_/);
|
|
49
47
|
var REGEX_SLASH_UND = new RegExp(/\/([A-Z]+-[\[a-zA-Z\]\d]+)_/);
|
|
48
|
+
var REGEX_SLASH_NUM = new RegExp(/\/(\d+)/);
|
|
49
|
+
var REGEX_START_NUM = new RegExp(/^(\d+)/);
|
|
50
50
|
var DEFAULT_TYPE_OPTIONS = [
|
|
51
51
|
{ value: "feat", label: "feat", hint: "A new feature", emoji: "\u2728", trailer: "Changelog: feature" },
|
|
52
52
|
{ value: "fix", label: "fix", hint: "A bug fix", emoji: "\u{1F41B}", trailer: "Changelog: fix" },
|
|
@@ -116,6 +116,15 @@ var Z_FOOTER_OPTIONS = import_zod.z.enum([
|
|
|
116
116
|
"deprecated",
|
|
117
117
|
"custom"
|
|
118
118
|
]);
|
|
119
|
+
var Z_BRANCH_FIELDS = import_zod.z.enum(["user", "version", "type", "ticket", "description"]);
|
|
120
|
+
var Z_BRANCH_CONFIG_FIELDS = import_zod.z.enum([
|
|
121
|
+
"branch_user",
|
|
122
|
+
"branch_version",
|
|
123
|
+
"branch_type",
|
|
124
|
+
"branch_ticket",
|
|
125
|
+
"branch_description"
|
|
126
|
+
]);
|
|
127
|
+
var BRANCH_ORDER_DEFAULTS = ["user", "version", "type", "ticket", "description"];
|
|
119
128
|
var Z_BRANCH_ACTIONS = import_zod.z.enum(["branch", "worktree"]);
|
|
120
129
|
var FOOTER_OPTION_VALUES = [
|
|
121
130
|
"closes",
|
|
@@ -253,7 +262,8 @@ var Config = import_zod2.z.object({
|
|
|
253
262
|
confirm_ticket: import_zod2.z.boolean().default(true),
|
|
254
263
|
add_to_title: import_zod2.z.boolean().default(true),
|
|
255
264
|
append_hashtag: import_zod2.z.boolean().default(false),
|
|
256
|
-
|
|
265
|
+
surround: import_zod2.z.enum(["", "()", "[]", "{}"]).default(""),
|
|
266
|
+
title_position: import_zod2.z.enum(["start", "end", "before-colon"]).default("start")
|
|
257
267
|
}).default({}),
|
|
258
268
|
commit_title: import_zod2.z.object({
|
|
259
269
|
max_size: import_zod2.z.number().positive().default(70)
|
|
@@ -285,15 +295,22 @@ var Config = import_zod2.z.object({
|
|
|
285
295
|
enable: import_zod2.z.boolean().default(true),
|
|
286
296
|
separator: import_zod2.z.enum(["/", "-", "_"]).default("/")
|
|
287
297
|
}).default({}),
|
|
298
|
+
branch_version: import_zod2.z.object({
|
|
299
|
+
enable: import_zod2.z.boolean().default(false),
|
|
300
|
+
required: import_zod2.z.boolean().default(false),
|
|
301
|
+
separator: import_zod2.z.enum(["/", "-", "_"]).default("/")
|
|
302
|
+
}).default({}),
|
|
288
303
|
branch_ticket: import_zod2.z.object({
|
|
289
304
|
enable: import_zod2.z.boolean().default(true),
|
|
290
305
|
required: import_zod2.z.boolean().default(false),
|
|
291
306
|
separator: import_zod2.z.enum(["/", "-", "_"]).default("-")
|
|
292
307
|
}).default({}),
|
|
293
308
|
branch_description: import_zod2.z.object({
|
|
294
|
-
max_length: import_zod2.z.number().positive().default(70)
|
|
309
|
+
max_length: import_zod2.z.number().positive().default(70),
|
|
310
|
+
separator: import_zod2.z.enum(["", "/", "-", "_"]).default("")
|
|
295
311
|
}).default({}),
|
|
296
312
|
branch_action_default: Z_BRANCH_ACTIONS.default("branch"),
|
|
313
|
+
branch_order: import_zod2.z.array(Z_BRANCH_FIELDS).default(BRANCH_ORDER_DEFAULTS),
|
|
297
314
|
enable_worktrees: import_zod2.z.boolean().default(true),
|
|
298
315
|
overrides: import_zod2.z.object({ shell: import_zod2.z.string().optional() }).default({})
|
|
299
316
|
}).default({});
|
|
@@ -316,7 +333,8 @@ var BranchState = import_zod2.z.object({
|
|
|
316
333
|
user: import_zod2.z.string().default(""),
|
|
317
334
|
type: import_zod2.z.string().default(""),
|
|
318
335
|
ticket: import_zod2.z.string().default(""),
|
|
319
|
-
description: import_zod2.z.string().default("")
|
|
336
|
+
description: import_zod2.z.string().default(""),
|
|
337
|
+
version: import_zod2.z.string().default("")
|
|
320
338
|
}).default({});
|
|
321
339
|
|
|
322
340
|
// src/branch.ts
|
|
@@ -381,6 +399,20 @@ async function main(config) {
|
|
|
381
399
|
process.exit(0);
|
|
382
400
|
branch_state.ticket = ticket;
|
|
383
401
|
}
|
|
402
|
+
if (config.branch_version.enable) {
|
|
403
|
+
const version_required = config.branch_version.required;
|
|
404
|
+
const version = await p2.text({
|
|
405
|
+
message: `Type version number ${version_required ? "" : OPTIONAL_PROMPT}`.trim(),
|
|
406
|
+
placeholder: "",
|
|
407
|
+
validate: (val) => {
|
|
408
|
+
if (version_required && !val)
|
|
409
|
+
return "Please enter a version";
|
|
410
|
+
}
|
|
411
|
+
});
|
|
412
|
+
if (p2.isCancel(version))
|
|
413
|
+
process.exit(0);
|
|
414
|
+
branch_state.version = version;
|
|
415
|
+
}
|
|
384
416
|
const description_max_length = config.branch_description.max_length;
|
|
385
417
|
const description = await p2.text({
|
|
386
418
|
message: "Type a short description",
|
|
@@ -456,15 +488,15 @@ async function main(config) {
|
|
|
456
488
|
}
|
|
457
489
|
function build_branch(branch, config) {
|
|
458
490
|
let res = "";
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
return res;
|
|
491
|
+
config.branch_order.forEach((b) => {
|
|
492
|
+
const config_key = `branch_${b}`;
|
|
493
|
+
if (branch[b])
|
|
494
|
+
res += branch[b] + config[config_key].separator;
|
|
495
|
+
});
|
|
496
|
+
if (res.endsWith("-") || res.endsWith("/") || res.endsWith("_")) {
|
|
497
|
+
return res.slice(0, -1).trim();
|
|
498
|
+
}
|
|
499
|
+
return res.trim();
|
|
468
500
|
}
|
|
469
501
|
function get_user_from_cache() {
|
|
470
502
|
try {
|
package/dist/index.js
CHANGED
|
@@ -59,10 +59,10 @@ var OPTIONAL_PROMPT = `${import_picocolors.default.dim("(optional)")}`;
|
|
|
59
59
|
var CACHE_PROMPT = `${import_picocolors.default.dim("(value will be saved)")}`;
|
|
60
60
|
var REGEX_SLASH_TAG = new RegExp(/\/(\w+-\d+)/);
|
|
61
61
|
var REGEX_START_TAG = new RegExp(/^(\w+-\d+)/);
|
|
62
|
-
var REGEX_SLASH_NUM = new RegExp(/\/(\d+)/);
|
|
63
|
-
var REGEX_START_NUM = new RegExp(/^(\d+)/);
|
|
64
62
|
var REGEX_START_UND = new RegExp(/^([A-Z]+-[\[a-zA-Z\]\d]+)_/);
|
|
65
63
|
var REGEX_SLASH_UND = new RegExp(/\/([A-Z]+-[\[a-zA-Z\]\d]+)_/);
|
|
64
|
+
var REGEX_SLASH_NUM = new RegExp(/\/(\d+)/);
|
|
65
|
+
var REGEX_START_NUM = new RegExp(/^(\d+)/);
|
|
66
66
|
var DEFAULT_TYPE_OPTIONS = [
|
|
67
67
|
{ value: "feat", label: "feat", hint: "A new feature", emoji: "\u2728", trailer: "Changelog: feature" },
|
|
68
68
|
{ value: "fix", label: "fix", hint: "A bug fix", emoji: "\u{1F41B}", trailer: "Changelog: fix" },
|
|
@@ -151,6 +151,15 @@ var Z_FOOTER_OPTIONS = import_zod.z.enum([
|
|
|
151
151
|
"deprecated",
|
|
152
152
|
"custom"
|
|
153
153
|
]);
|
|
154
|
+
var Z_BRANCH_FIELDS = import_zod.z.enum(["user", "version", "type", "ticket", "description"]);
|
|
155
|
+
var Z_BRANCH_CONFIG_FIELDS = import_zod.z.enum([
|
|
156
|
+
"branch_user",
|
|
157
|
+
"branch_version",
|
|
158
|
+
"branch_type",
|
|
159
|
+
"branch_ticket",
|
|
160
|
+
"branch_description"
|
|
161
|
+
]);
|
|
162
|
+
var BRANCH_ORDER_DEFAULTS = ["user", "version", "type", "ticket", "description"];
|
|
154
163
|
var Z_BRANCH_ACTIONS = import_zod.z.enum(["branch", "worktree"]);
|
|
155
164
|
var FOOTER_OPTION_VALUES = [
|
|
156
165
|
"closes",
|
|
@@ -317,7 +326,8 @@ var Config = import_zod2.z.object({
|
|
|
317
326
|
confirm_ticket: import_zod2.z.boolean().default(true),
|
|
318
327
|
add_to_title: import_zod2.z.boolean().default(true),
|
|
319
328
|
append_hashtag: import_zod2.z.boolean().default(false),
|
|
320
|
-
|
|
329
|
+
surround: import_zod2.z.enum(["", "()", "[]", "{}"]).default(""),
|
|
330
|
+
title_position: import_zod2.z.enum(["start", "end", "before-colon"]).default("start")
|
|
321
331
|
}).default({}),
|
|
322
332
|
commit_title: import_zod2.z.object({
|
|
323
333
|
max_size: import_zod2.z.number().positive().default(70)
|
|
@@ -349,15 +359,22 @@ var Config = import_zod2.z.object({
|
|
|
349
359
|
enable: import_zod2.z.boolean().default(true),
|
|
350
360
|
separator: import_zod2.z.enum(["/", "-", "_"]).default("/")
|
|
351
361
|
}).default({}),
|
|
362
|
+
branch_version: import_zod2.z.object({
|
|
363
|
+
enable: import_zod2.z.boolean().default(false),
|
|
364
|
+
required: import_zod2.z.boolean().default(false),
|
|
365
|
+
separator: import_zod2.z.enum(["/", "-", "_"]).default("/")
|
|
366
|
+
}).default({}),
|
|
352
367
|
branch_ticket: import_zod2.z.object({
|
|
353
368
|
enable: import_zod2.z.boolean().default(true),
|
|
354
369
|
required: import_zod2.z.boolean().default(false),
|
|
355
370
|
separator: import_zod2.z.enum(["/", "-", "_"]).default("-")
|
|
356
371
|
}).default({}),
|
|
357
372
|
branch_description: import_zod2.z.object({
|
|
358
|
-
max_length: import_zod2.z.number().positive().default(70)
|
|
373
|
+
max_length: import_zod2.z.number().positive().default(70),
|
|
374
|
+
separator: import_zod2.z.enum(["", "/", "-", "_"]).default("")
|
|
359
375
|
}).default({}),
|
|
360
376
|
branch_action_default: Z_BRANCH_ACTIONS.default("branch"),
|
|
377
|
+
branch_order: import_zod2.z.array(Z_BRANCH_FIELDS).default(BRANCH_ORDER_DEFAULTS),
|
|
361
378
|
enable_worktrees: import_zod2.z.boolean().default(true),
|
|
362
379
|
overrides: import_zod2.z.object({ shell: import_zod2.z.string().optional() }).default({})
|
|
363
380
|
}).default({});
|
|
@@ -380,7 +397,8 @@ var BranchState = import_zod2.z.object({
|
|
|
380
397
|
user: import_zod2.z.string().default(""),
|
|
381
398
|
type: import_zod2.z.string().default(""),
|
|
382
399
|
ticket: import_zod2.z.string().default(""),
|
|
383
|
-
description: import_zod2.z.string().default("")
|
|
400
|
+
description: import_zod2.z.string().default(""),
|
|
401
|
+
version: import_zod2.z.string().default("")
|
|
384
402
|
}).default({});
|
|
385
403
|
|
|
386
404
|
// src/git.ts
|
|
@@ -658,22 +676,34 @@ function build_commit_string(commit_state, config, colorize = false, escape_quot
|
|
|
658
676
|
const scope = colorize ? import_picocolors3.default.cyan(commit_state.scope) : commit_state.scope;
|
|
659
677
|
commit_string += `(${scope})`;
|
|
660
678
|
}
|
|
679
|
+
let title_ticket = commit_state.ticket;
|
|
680
|
+
const surround = config.check_ticket.surround;
|
|
681
|
+
if (commit_state.ticket && surround) {
|
|
682
|
+
const open_token = surround.charAt(0);
|
|
683
|
+
const close_token = surround.charAt(1);
|
|
684
|
+
title_ticket = `${open_token}${commit_state.ticket}${close_token}`;
|
|
685
|
+
}
|
|
686
|
+
const position_before_colon = config.check_ticket.title_position === "before-colon";
|
|
687
|
+
if (title_ticket && config.check_ticket.add_to_title && position_before_colon) {
|
|
688
|
+
const spacing = commit_state.scope || commit_state.type && !config.check_ticket.surround ? " " : "";
|
|
689
|
+
commit_string += colorize ? import_picocolors3.default.magenta(spacing + title_ticket) : spacing + title_ticket;
|
|
690
|
+
}
|
|
661
691
|
if (commit_state.breaking_title && config.breaking_change.add_exclamation_to_title) {
|
|
662
692
|
commit_string += colorize ? import_picocolors3.default.red("!") : "!";
|
|
663
693
|
}
|
|
664
|
-
if (commit_state.scope || commit_state.type) {
|
|
694
|
+
if (commit_state.scope || commit_state.type || title_ticket && position_before_colon) {
|
|
665
695
|
commit_string += ": ";
|
|
666
696
|
}
|
|
667
697
|
const position_start = config.check_ticket.title_position === "start";
|
|
668
698
|
const position_end = config.check_ticket.title_position === "end";
|
|
669
|
-
if (
|
|
670
|
-
commit_string += colorize ? import_picocolors3.default.magenta(
|
|
699
|
+
if (title_ticket && config.check_ticket.add_to_title && position_start) {
|
|
700
|
+
commit_string += colorize ? import_picocolors3.default.magenta(title_ticket) + " " : title_ticket + " ";
|
|
671
701
|
}
|
|
672
702
|
if (commit_state.title) {
|
|
673
703
|
commit_string += colorize ? import_picocolors3.default.reset(commit_state.title) : commit_state.title;
|
|
674
704
|
}
|
|
675
|
-
if (
|
|
676
|
-
commit_string += " " + (colorize ? import_picocolors3.default.magenta(
|
|
705
|
+
if (title_ticket && config.check_ticket.add_to_title && position_end) {
|
|
706
|
+
commit_string += " " + (colorize ? import_picocolors3.default.magenta(title_ticket) : title_ticket);
|
|
677
707
|
}
|
|
678
708
|
if (commit_state.body) {
|
|
679
709
|
const temp = commit_state.body.split("\\n");
|
package/dist/init.js
CHANGED
|
@@ -41,10 +41,10 @@ var OPTIONAL_PROMPT = `${import_picocolors.default.dim("(optional)")}`;
|
|
|
41
41
|
var CACHE_PROMPT = `${import_picocolors.default.dim("(value will be saved)")}`;
|
|
42
42
|
var REGEX_SLASH_TAG = new RegExp(/\/(\w+-\d+)/);
|
|
43
43
|
var REGEX_START_TAG = new RegExp(/^(\w+-\d+)/);
|
|
44
|
-
var REGEX_SLASH_NUM = new RegExp(/\/(\d+)/);
|
|
45
|
-
var REGEX_START_NUM = new RegExp(/^(\d+)/);
|
|
46
44
|
var REGEX_START_UND = new RegExp(/^([A-Z]+-[\[a-zA-Z\]\d]+)_/);
|
|
47
45
|
var REGEX_SLASH_UND = new RegExp(/\/([A-Z]+-[\[a-zA-Z\]\d]+)_/);
|
|
46
|
+
var REGEX_SLASH_NUM = new RegExp(/\/(\d+)/);
|
|
47
|
+
var REGEX_START_NUM = new RegExp(/^(\d+)/);
|
|
48
48
|
var DEFAULT_TYPE_OPTIONS = [
|
|
49
49
|
{ value: "feat", label: "feat", hint: "A new feature", emoji: "\u2728", trailer: "Changelog: feature" },
|
|
50
50
|
{ value: "fix", label: "fix", hint: "A bug fix", emoji: "\u{1F41B}", trailer: "Changelog: fix" },
|
|
@@ -114,6 +114,15 @@ var Z_FOOTER_OPTIONS = import_zod.z.enum([
|
|
|
114
114
|
"deprecated",
|
|
115
115
|
"custom"
|
|
116
116
|
]);
|
|
117
|
+
var Z_BRANCH_FIELDS = import_zod.z.enum(["user", "version", "type", "ticket", "description"]);
|
|
118
|
+
var Z_BRANCH_CONFIG_FIELDS = import_zod.z.enum([
|
|
119
|
+
"branch_user",
|
|
120
|
+
"branch_version",
|
|
121
|
+
"branch_type",
|
|
122
|
+
"branch_ticket",
|
|
123
|
+
"branch_description"
|
|
124
|
+
]);
|
|
125
|
+
var BRANCH_ORDER_DEFAULTS = ["user", "version", "type", "ticket", "description"];
|
|
117
126
|
var Z_BRANCH_ACTIONS = import_zod.z.enum(["branch", "worktree"]);
|
|
118
127
|
var FOOTER_OPTION_VALUES = [
|
|
119
128
|
"closes",
|
|
@@ -205,7 +214,8 @@ var Config = import_zod2.z.object({
|
|
|
205
214
|
confirm_ticket: import_zod2.z.boolean().default(true),
|
|
206
215
|
add_to_title: import_zod2.z.boolean().default(true),
|
|
207
216
|
append_hashtag: import_zod2.z.boolean().default(false),
|
|
208
|
-
|
|
217
|
+
surround: import_zod2.z.enum(["", "()", "[]", "{}"]).default(""),
|
|
218
|
+
title_position: import_zod2.z.enum(["start", "end", "before-colon"]).default("start")
|
|
209
219
|
}).default({}),
|
|
210
220
|
commit_title: import_zod2.z.object({
|
|
211
221
|
max_size: import_zod2.z.number().positive().default(70)
|
|
@@ -237,15 +247,22 @@ var Config = import_zod2.z.object({
|
|
|
237
247
|
enable: import_zod2.z.boolean().default(true),
|
|
238
248
|
separator: import_zod2.z.enum(["/", "-", "_"]).default("/")
|
|
239
249
|
}).default({}),
|
|
250
|
+
branch_version: import_zod2.z.object({
|
|
251
|
+
enable: import_zod2.z.boolean().default(false),
|
|
252
|
+
required: import_zod2.z.boolean().default(false),
|
|
253
|
+
separator: import_zod2.z.enum(["/", "-", "_"]).default("/")
|
|
254
|
+
}).default({}),
|
|
240
255
|
branch_ticket: import_zod2.z.object({
|
|
241
256
|
enable: import_zod2.z.boolean().default(true),
|
|
242
257
|
required: import_zod2.z.boolean().default(false),
|
|
243
258
|
separator: import_zod2.z.enum(["/", "-", "_"]).default("-")
|
|
244
259
|
}).default({}),
|
|
245
260
|
branch_description: import_zod2.z.object({
|
|
246
|
-
max_length: import_zod2.z.number().positive().default(70)
|
|
261
|
+
max_length: import_zod2.z.number().positive().default(70),
|
|
262
|
+
separator: import_zod2.z.enum(["", "/", "-", "_"]).default("")
|
|
247
263
|
}).default({}),
|
|
248
264
|
branch_action_default: Z_BRANCH_ACTIONS.default("branch"),
|
|
265
|
+
branch_order: import_zod2.z.array(Z_BRANCH_FIELDS).default(BRANCH_ORDER_DEFAULTS),
|
|
249
266
|
enable_worktrees: import_zod2.z.boolean().default(true),
|
|
250
267
|
overrides: import_zod2.z.object({ shell: import_zod2.z.string().optional() }).default({})
|
|
251
268
|
}).default({});
|
|
@@ -268,7 +285,8 @@ var BranchState = import_zod2.z.object({
|
|
|
268
285
|
user: import_zod2.z.string().default(""),
|
|
269
286
|
type: import_zod2.z.string().default(""),
|
|
270
287
|
ticket: import_zod2.z.string().default(""),
|
|
271
|
-
description: import_zod2.z.string().default("")
|
|
288
|
+
description: import_zod2.z.string().default(""),
|
|
289
|
+
version: import_zod2.z.string().default("")
|
|
272
290
|
}).default({});
|
|
273
291
|
|
|
274
292
|
// src/init.ts
|
package/dist/utils.js
CHANGED
|
@@ -32,6 +32,7 @@ var utils_exports = {};
|
|
|
32
32
|
__export(utils_exports, {
|
|
33
33
|
A_FOR_ALL: () => A_FOR_ALL,
|
|
34
34
|
BRANCH_ACTION_OPTIONS: () => BRANCH_ACTION_OPTIONS,
|
|
35
|
+
BRANCH_ORDER_DEFAULTS: () => BRANCH_ORDER_DEFAULTS,
|
|
35
36
|
CACHE_PROMPT: () => CACHE_PROMPT,
|
|
36
37
|
COMMIT_FOOTER_OPTIONS: () => COMMIT_FOOTER_OPTIONS,
|
|
37
38
|
CONFIG_FILE_NAME: () => CONFIG_FILE_NAME,
|
|
@@ -48,6 +49,8 @@ __export(utils_exports, {
|
|
|
48
49
|
REGEX_START_UND: () => REGEX_START_UND,
|
|
49
50
|
SPACE_TO_SELECT: () => SPACE_TO_SELECT,
|
|
50
51
|
Z_BRANCH_ACTIONS: () => Z_BRANCH_ACTIONS,
|
|
52
|
+
Z_BRANCH_CONFIG_FIELDS: () => Z_BRANCH_CONFIG_FIELDS,
|
|
53
|
+
Z_BRANCH_FIELDS: () => Z_BRANCH_FIELDS,
|
|
51
54
|
Z_FOOTER_OPTIONS: () => Z_FOOTER_OPTIONS,
|
|
52
55
|
addNewLine: () => addNewLine,
|
|
53
56
|
clean_commit_title: () => clean_commit_title,
|
|
@@ -137,7 +140,8 @@ var Config = import_zod.z.object({
|
|
|
137
140
|
confirm_ticket: import_zod.z.boolean().default(true),
|
|
138
141
|
add_to_title: import_zod.z.boolean().default(true),
|
|
139
142
|
append_hashtag: import_zod.z.boolean().default(false),
|
|
140
|
-
|
|
143
|
+
surround: import_zod.z.enum(["", "()", "[]", "{}"]).default(""),
|
|
144
|
+
title_position: import_zod.z.enum(["start", "end", "before-colon"]).default("start")
|
|
141
145
|
}).default({}),
|
|
142
146
|
commit_title: import_zod.z.object({
|
|
143
147
|
max_size: import_zod.z.number().positive().default(70)
|
|
@@ -169,15 +173,22 @@ var Config = import_zod.z.object({
|
|
|
169
173
|
enable: import_zod.z.boolean().default(true),
|
|
170
174
|
separator: import_zod.z.enum(["/", "-", "_"]).default("/")
|
|
171
175
|
}).default({}),
|
|
176
|
+
branch_version: import_zod.z.object({
|
|
177
|
+
enable: import_zod.z.boolean().default(false),
|
|
178
|
+
required: import_zod.z.boolean().default(false),
|
|
179
|
+
separator: import_zod.z.enum(["/", "-", "_"]).default("/")
|
|
180
|
+
}).default({}),
|
|
172
181
|
branch_ticket: import_zod.z.object({
|
|
173
182
|
enable: import_zod.z.boolean().default(true),
|
|
174
183
|
required: import_zod.z.boolean().default(false),
|
|
175
184
|
separator: import_zod.z.enum(["/", "-", "_"]).default("-")
|
|
176
185
|
}).default({}),
|
|
177
186
|
branch_description: import_zod.z.object({
|
|
178
|
-
max_length: import_zod.z.number().positive().default(70)
|
|
187
|
+
max_length: import_zod.z.number().positive().default(70),
|
|
188
|
+
separator: import_zod.z.enum(["", "/", "-", "_"]).default("")
|
|
179
189
|
}).default({}),
|
|
180
190
|
branch_action_default: Z_BRANCH_ACTIONS.default("branch"),
|
|
191
|
+
branch_order: import_zod.z.array(Z_BRANCH_FIELDS).default(BRANCH_ORDER_DEFAULTS),
|
|
181
192
|
enable_worktrees: import_zod.z.boolean().default(true),
|
|
182
193
|
overrides: import_zod.z.object({ shell: import_zod.z.string().optional() }).default({})
|
|
183
194
|
}).default({});
|
|
@@ -200,7 +211,8 @@ var BranchState = import_zod.z.object({
|
|
|
200
211
|
user: import_zod.z.string().default(""),
|
|
201
212
|
type: import_zod.z.string().default(""),
|
|
202
213
|
ticket: import_zod.z.string().default(""),
|
|
203
|
-
description: import_zod.z.string().default("")
|
|
214
|
+
description: import_zod.z.string().default(""),
|
|
215
|
+
version: import_zod.z.string().default("")
|
|
204
216
|
}).default({});
|
|
205
217
|
|
|
206
218
|
// src/utils.ts
|
|
@@ -213,10 +225,10 @@ var OPTIONAL_PROMPT = `${import_picocolors.default.dim("(optional)")}`;
|
|
|
213
225
|
var CACHE_PROMPT = `${import_picocolors.default.dim("(value will be saved)")}`;
|
|
214
226
|
var REGEX_SLASH_TAG = new RegExp(/\/(\w+-\d+)/);
|
|
215
227
|
var REGEX_START_TAG = new RegExp(/^(\w+-\d+)/);
|
|
216
|
-
var REGEX_SLASH_NUM = new RegExp(/\/(\d+)/);
|
|
217
|
-
var REGEX_START_NUM = new RegExp(/^(\d+)/);
|
|
218
228
|
var REGEX_START_UND = new RegExp(/^([A-Z]+-[\[a-zA-Z\]\d]+)_/);
|
|
219
229
|
var REGEX_SLASH_UND = new RegExp(/\/([A-Z]+-[\[a-zA-Z\]\d]+)_/);
|
|
230
|
+
var REGEX_SLASH_NUM = new RegExp(/\/(\d+)/);
|
|
231
|
+
var REGEX_START_NUM = new RegExp(/^(\d+)/);
|
|
220
232
|
var DEFAULT_TYPE_OPTIONS = [
|
|
221
233
|
{ value: "feat", label: "feat", hint: "A new feature", emoji: "\u2728", trailer: "Changelog: feature" },
|
|
222
234
|
{ value: "fix", label: "fix", hint: "A bug fix", emoji: "\u{1F41B}", trailer: "Changelog: fix" },
|
|
@@ -305,6 +317,15 @@ var Z_FOOTER_OPTIONS = import_zod2.z.enum([
|
|
|
305
317
|
"deprecated",
|
|
306
318
|
"custom"
|
|
307
319
|
]);
|
|
320
|
+
var Z_BRANCH_FIELDS = import_zod2.z.enum(["user", "version", "type", "ticket", "description"]);
|
|
321
|
+
var Z_BRANCH_CONFIG_FIELDS = import_zod2.z.enum([
|
|
322
|
+
"branch_user",
|
|
323
|
+
"branch_version",
|
|
324
|
+
"branch_type",
|
|
325
|
+
"branch_ticket",
|
|
326
|
+
"branch_description"
|
|
327
|
+
]);
|
|
328
|
+
var BRANCH_ORDER_DEFAULTS = ["user", "version", "type", "ticket", "description"];
|
|
308
329
|
var Z_BRANCH_ACTIONS = import_zod2.z.enum(["branch", "worktree"]);
|
|
309
330
|
var FOOTER_OPTION_VALUES = [
|
|
310
331
|
"closes",
|
|
@@ -407,6 +428,7 @@ function clean_commit_title(title) {
|
|
|
407
428
|
0 && (module.exports = {
|
|
408
429
|
A_FOR_ALL,
|
|
409
430
|
BRANCH_ACTION_OPTIONS,
|
|
431
|
+
BRANCH_ORDER_DEFAULTS,
|
|
410
432
|
CACHE_PROMPT,
|
|
411
433
|
COMMIT_FOOTER_OPTIONS,
|
|
412
434
|
CONFIG_FILE_NAME,
|
|
@@ -423,6 +445,8 @@ function clean_commit_title(title) {
|
|
|
423
445
|
REGEX_START_UND,
|
|
424
446
|
SPACE_TO_SELECT,
|
|
425
447
|
Z_BRANCH_ACTIONS,
|
|
448
|
+
Z_BRANCH_CONFIG_FIELDS,
|
|
449
|
+
Z_BRANCH_FIELDS,
|
|
426
450
|
Z_FOOTER_OPTIONS,
|
|
427
451
|
addNewLine,
|
|
428
452
|
clean_commit_title,
|
package/dist/zod-state.js
CHANGED
|
@@ -50,10 +50,10 @@ var OPTIONAL_PROMPT = `${import_picocolors.default.dim("(optional)")}`;
|
|
|
50
50
|
var CACHE_PROMPT = `${import_picocolors.default.dim("(value will be saved)")}`;
|
|
51
51
|
var REGEX_SLASH_TAG = new RegExp(/\/(\w+-\d+)/);
|
|
52
52
|
var REGEX_START_TAG = new RegExp(/^(\w+-\d+)/);
|
|
53
|
-
var REGEX_SLASH_NUM = new RegExp(/\/(\d+)/);
|
|
54
|
-
var REGEX_START_NUM = new RegExp(/^(\d+)/);
|
|
55
53
|
var REGEX_START_UND = new RegExp(/^([A-Z]+-[\[a-zA-Z\]\d]+)_/);
|
|
56
54
|
var REGEX_SLASH_UND = new RegExp(/\/([A-Z]+-[\[a-zA-Z\]\d]+)_/);
|
|
55
|
+
var REGEX_SLASH_NUM = new RegExp(/\/(\d+)/);
|
|
56
|
+
var REGEX_START_NUM = new RegExp(/^(\d+)/);
|
|
57
57
|
var DEFAULT_TYPE_OPTIONS = [
|
|
58
58
|
{ value: "feat", label: "feat", hint: "A new feature", emoji: "\u2728", trailer: "Changelog: feature" },
|
|
59
59
|
{ value: "fix", label: "fix", hint: "A bug fix", emoji: "\u{1F41B}", trailer: "Changelog: fix" },
|
|
@@ -123,6 +123,15 @@ var Z_FOOTER_OPTIONS = import_zod.z.enum([
|
|
|
123
123
|
"deprecated",
|
|
124
124
|
"custom"
|
|
125
125
|
]);
|
|
126
|
+
var Z_BRANCH_FIELDS = import_zod.z.enum(["user", "version", "type", "ticket", "description"]);
|
|
127
|
+
var Z_BRANCH_CONFIG_FIELDS = import_zod.z.enum([
|
|
128
|
+
"branch_user",
|
|
129
|
+
"branch_version",
|
|
130
|
+
"branch_type",
|
|
131
|
+
"branch_ticket",
|
|
132
|
+
"branch_description"
|
|
133
|
+
]);
|
|
134
|
+
var BRANCH_ORDER_DEFAULTS = ["user", "version", "type", "ticket", "description"];
|
|
126
135
|
var Z_BRANCH_ACTIONS = import_zod.z.enum(["branch", "worktree"]);
|
|
127
136
|
var FOOTER_OPTION_VALUES = [
|
|
128
137
|
"closes",
|
|
@@ -203,7 +212,8 @@ var Config = import_zod2.z.object({
|
|
|
203
212
|
confirm_ticket: import_zod2.z.boolean().default(true),
|
|
204
213
|
add_to_title: import_zod2.z.boolean().default(true),
|
|
205
214
|
append_hashtag: import_zod2.z.boolean().default(false),
|
|
206
|
-
|
|
215
|
+
surround: import_zod2.z.enum(["", "()", "[]", "{}"]).default(""),
|
|
216
|
+
title_position: import_zod2.z.enum(["start", "end", "before-colon"]).default("start")
|
|
207
217
|
}).default({}),
|
|
208
218
|
commit_title: import_zod2.z.object({
|
|
209
219
|
max_size: import_zod2.z.number().positive().default(70)
|
|
@@ -235,15 +245,22 @@ var Config = import_zod2.z.object({
|
|
|
235
245
|
enable: import_zod2.z.boolean().default(true),
|
|
236
246
|
separator: import_zod2.z.enum(["/", "-", "_"]).default("/")
|
|
237
247
|
}).default({}),
|
|
248
|
+
branch_version: import_zod2.z.object({
|
|
249
|
+
enable: import_zod2.z.boolean().default(false),
|
|
250
|
+
required: import_zod2.z.boolean().default(false),
|
|
251
|
+
separator: import_zod2.z.enum(["/", "-", "_"]).default("/")
|
|
252
|
+
}).default({}),
|
|
238
253
|
branch_ticket: import_zod2.z.object({
|
|
239
254
|
enable: import_zod2.z.boolean().default(true),
|
|
240
255
|
required: import_zod2.z.boolean().default(false),
|
|
241
256
|
separator: import_zod2.z.enum(["/", "-", "_"]).default("-")
|
|
242
257
|
}).default({}),
|
|
243
258
|
branch_description: import_zod2.z.object({
|
|
244
|
-
max_length: import_zod2.z.number().positive().default(70)
|
|
259
|
+
max_length: import_zod2.z.number().positive().default(70),
|
|
260
|
+
separator: import_zod2.z.enum(["", "/", "-", "_"]).default("")
|
|
245
261
|
}).default({}),
|
|
246
262
|
branch_action_default: Z_BRANCH_ACTIONS.default("branch"),
|
|
263
|
+
branch_order: import_zod2.z.array(Z_BRANCH_FIELDS).default(BRANCH_ORDER_DEFAULTS),
|
|
247
264
|
enable_worktrees: import_zod2.z.boolean().default(true),
|
|
248
265
|
overrides: import_zod2.z.object({ shell: import_zod2.z.string().optional() }).default({})
|
|
249
266
|
}).default({});
|
|
@@ -266,7 +283,8 @@ var BranchState = import_zod2.z.object({
|
|
|
266
283
|
user: import_zod2.z.string().default(""),
|
|
267
284
|
type: import_zod2.z.string().default(""),
|
|
268
285
|
ticket: import_zod2.z.string().default(""),
|
|
269
|
-
description: import_zod2.z.string().default("")
|
|
286
|
+
description: import_zod2.z.string().default(""),
|
|
287
|
+
version: import_zod2.z.string().default("")
|
|
270
288
|
}).default({});
|
|
271
289
|
// Annotate the CommonJS export names for ESM import in node:
|
|
272
290
|
0 && (module.exports = {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "better-commits",
|
|
3
3
|
"private": false,
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.11.0",
|
|
5
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": [
|
package/readme.md
CHANGED
|
@@ -192,6 +192,7 @@ Better-commits (& better-branch) are highly flexible with sane defaults. These o
|
|
|
192
192
|
"confirm_ticket": true,
|
|
193
193
|
"add_to_title": true,
|
|
194
194
|
"append_hashtag": false,
|
|
195
|
+
"surround": "",
|
|
195
196
|
"title_position": "start"
|
|
196
197
|
},
|
|
197
198
|
"commit_title": {
|
|
@@ -230,15 +231,28 @@ Better-commits (& better-branch) are highly flexible with sane defaults. These o
|
|
|
230
231
|
"enable": true,
|
|
231
232
|
"separator": "/"
|
|
232
233
|
},
|
|
234
|
+
"branch_version": {
|
|
235
|
+
"enable": false,
|
|
236
|
+
"required": false,
|
|
237
|
+
"separator": "/"
|
|
238
|
+
},
|
|
233
239
|
"branch_ticket": {
|
|
234
240
|
"enable": true,
|
|
235
241
|
"required": false,
|
|
236
242
|
"separator": "-"
|
|
237
243
|
},
|
|
238
244
|
"branch_description": {
|
|
239
|
-
"max_length": 70
|
|
245
|
+
"max_length": 70,
|
|
246
|
+
"separator": ""
|
|
240
247
|
},
|
|
241
248
|
"branch_action_default": "branch",
|
|
249
|
+
"branch_order": [
|
|
250
|
+
"user",
|
|
251
|
+
"version",
|
|
252
|
+
"type",
|
|
253
|
+
"ticket",
|
|
254
|
+
"description"
|
|
255
|
+
],
|
|
242
256
|
"enable_worktrees": true,
|
|
243
257
|
"overrides": {
|
|
244
258
|
"shell": "/bin/sh"
|
|
@@ -283,7 +297,8 @@ Better-commits (& better-branch) are highly flexible with sane defaults. These o
|
|
|
283
297
|
| `check_ticket.confirm_ticket` | If true manually confirm inference |
|
|
284
298
|
| `check_ticket.add_to_title` | If true add ticket to title |
|
|
285
299
|
| `check_ticket.append_hashtag` | If true add hashtag to ticket (Ideal for Github Issues) |
|
|
286
|
-
| `check_ticket.title_position` |
|
|
300
|
+
| `check_ticket.title_position` | "start" (of description) (default), "end", "before-colon" |
|
|
301
|
+
| `check_ticket.surround` | "" (default), "[]", "()", "{}" - Wraps ticket in title |
|
|
287
302
|
| `commit_title.max_size` | Max size of title including scope, type, etc... |
|
|
288
303
|
| `commit_body.enable` | If true include body |
|
|
289
304
|
| `commit_body.required` | If true body is required |
|
|
@@ -293,18 +308,33 @@ Better-commits (& better-branch) are highly flexible with sane defaults. These o
|
|
|
293
308
|
| `breaking_change.add_exclamation_to_title` | If true adds exclamation mark to title for breaking changes |
|
|
294
309
|
| `confirm_commit` | If true manually confirm commit at end |
|
|
295
310
|
| `print_commit_output` | If true pretty print commit preview |
|
|
311
|
+
| `overrides.shell` | Override default shell, useful for windows users |
|
|
312
|
+
|
|
313
|
+
Branch configuration (same config file, split for readability)
|
|
314
|
+
|
|
315
|
+
| Property | Description |
|
|
316
|
+
| -------- | ----------- |
|
|
296
317
|
| `branch_pre_commands` | Array of shell commands to run before branching |
|
|
297
318
|
| `branch_post_commands` | Array of shell commands to run after branching |
|
|
298
319
|
| `worktree_pre_commands` | Array of shell commands to run before creating worktree |
|
|
299
320
|
| `worktree_post_commands` | Array of shell commands to run after creating worktree |
|
|
300
321
|
| `branch_user.enable` | If enabled include user name |
|
|
301
322
|
| `branch_user.required` | If enabled require user name |
|
|
302
|
-
| `branch_user.separator` | Branch delimeter
|
|
323
|
+
| `branch_user.separator` | Branch delimeter - "/" (default), "-", "_" |
|
|
324
|
+
| `branch_type.enable` | If enabled include type |
|
|
325
|
+
| `branch_type.separator` | Branch delimeter - "/" (default), "-", "_" |
|
|
326
|
+
| `branch_ticket.enable` | If enabled include ticket |
|
|
327
|
+
| `branch_ticket.required` | If enabled require ticket |
|
|
328
|
+
| `branch_ticket.separator` | Branch delimeter - "/", "-" (default), "_" |
|
|
303
329
|
| `branch_description.max_length` | Max length branch name |
|
|
304
|
-
| `
|
|
330
|
+
| `branch_description.separator` | Branch delimeter - "" (default), "/", "-", "_" |
|
|
331
|
+
| `branch_version.enable` | If enabled include version |
|
|
332
|
+
| `branch_version.required` | If enabled require version |
|
|
333
|
+
| `branch_version.separator` | Branch delimeter - "", "/" (default), "-", "_" |
|
|
334
|
+
| `branch_order` | Order of branch name values (doesn't effect prompt order) |
|
|
335
|
+
| `branch_action_default` | "branch" or "worktree" |
|
|
305
336
|
| `enable_worktrees` | If false, always default to branch action |
|
|
306
|
-
|
|
307
|
-
|
|
337
|
+
|
|
308
338
|
</details>
|
|
309
339
|
|
|
310
340
|
### 🔎 Inference
|
package/src/branch.ts
CHANGED
|
@@ -7,6 +7,8 @@ import {
|
|
|
7
7
|
load_setup,
|
|
8
8
|
OPTIONAL_PROMPT,
|
|
9
9
|
Z_BRANCH_ACTIONS,
|
|
10
|
+
Z_BRANCH_CONFIG_FIELDS,
|
|
11
|
+
Z_BRANCH_FIELDS,
|
|
10
12
|
} from "./utils";
|
|
11
13
|
import { BranchState } from "./zod-state";
|
|
12
14
|
import * as p from "@clack/prompts";
|
|
@@ -77,6 +79,21 @@ async function main(config: z.infer<typeof Config>) {
|
|
|
77
79
|
branch_state.ticket = ticket;
|
|
78
80
|
}
|
|
79
81
|
|
|
82
|
+
if (config.branch_version.enable) {
|
|
83
|
+
const version_required = config.branch_version.required;
|
|
84
|
+
const version = await p.text({
|
|
85
|
+
message: `Type version number ${
|
|
86
|
+
version_required ? "" : OPTIONAL_PROMPT
|
|
87
|
+
}`.trim(),
|
|
88
|
+
placeholder: "",
|
|
89
|
+
validate: (val) => {
|
|
90
|
+
if (version_required && !val) return "Please enter a version";
|
|
91
|
+
},
|
|
92
|
+
});
|
|
93
|
+
if (p.isCancel(version)) process.exit(0);
|
|
94
|
+
branch_state.version = version;
|
|
95
|
+
}
|
|
96
|
+
|
|
80
97
|
const description_max_length = config.branch_description.max_length;
|
|
81
98
|
const description = await p.text({
|
|
82
99
|
message: "Type a short description",
|
|
@@ -165,11 +182,14 @@ function build_branch(
|
|
|
165
182
|
config: z.infer<typeof Config>
|
|
166
183
|
) {
|
|
167
184
|
let res = "";
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
185
|
+
config.branch_order.forEach((b: z.infer<typeof Z_BRANCH_FIELDS>) => {
|
|
186
|
+
const config_key: z.infer<typeof Z_BRANCH_CONFIG_FIELDS> = `branch_${b}`
|
|
187
|
+
if (branch[b]) res += branch[b] + config[config_key].separator
|
|
188
|
+
})
|
|
189
|
+
if (res.endsWith('-') || res.endsWith('/') || res.endsWith('_')) {
|
|
190
|
+
return res.slice(0, -1).trim();
|
|
191
|
+
}
|
|
192
|
+
return res.trim();
|
|
173
193
|
}
|
|
174
194
|
|
|
175
195
|
function get_user_from_cache(): string {
|
package/src/index.ts
CHANGED
|
@@ -247,27 +247,40 @@ function build_commit_string(commit_state: z.infer<typeof CommitState>,
|
|
|
247
247
|
commit_string += `(${scope})`
|
|
248
248
|
}
|
|
249
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
|
+
|
|
250
264
|
if (commit_state.breaking_title && config.breaking_change.add_exclamation_to_title) {
|
|
251
265
|
commit_string += colorize ? color.red('!') : '!'
|
|
252
266
|
}
|
|
253
267
|
|
|
254
|
-
if (commit_state.scope || commit_state.type) {
|
|
268
|
+
if (commit_state.scope || commit_state.type || (title_ticket && position_before_colon)) {
|
|
255
269
|
commit_string += ': '
|
|
256
270
|
}
|
|
257
271
|
|
|
258
272
|
const position_start = config.check_ticket.title_position === "start"
|
|
259
273
|
const position_end = config.check_ticket.title_position === "end"
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
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 + ' '
|
|
263
276
|
}
|
|
264
277
|
|
|
265
278
|
if (commit_state.title) {
|
|
266
279
|
commit_string += colorize ? color.reset(commit_state.title) : commit_state.title
|
|
267
280
|
}
|
|
268
281
|
|
|
269
|
-
if(
|
|
270
|
-
commit_string += ' ' + (colorize ? color.magenta(
|
|
282
|
+
if(title_ticket && config.check_ticket.add_to_title && position_end) {
|
|
283
|
+
commit_string += ' ' + (colorize ? color.magenta(title_ticket) : title_ticket)
|
|
271
284
|
}
|
|
272
285
|
|
|
273
286
|
if (commit_state.body) {
|
|
@@ -314,7 +327,6 @@ function build_commit_string(commit_state: z.infer<typeof CommitState>,
|
|
|
314
327
|
commit_string = commit_string.replaceAll('"', '\\"')
|
|
315
328
|
}
|
|
316
329
|
|
|
317
|
-
|
|
318
330
|
return commit_string;
|
|
319
331
|
}
|
|
320
332
|
|
package/src/utils.ts
CHANGED
|
@@ -16,11 +16,16 @@ export const OPTIONAL_PROMPT = `${color.dim("(optional)")}`;
|
|
|
16
16
|
export const CACHE_PROMPT = `${color.dim("(value will be saved)")}`;
|
|
17
17
|
export const REGEX_SLASH_TAG = new RegExp(/\/(\w+-\d+)/);
|
|
18
18
|
export const REGEX_START_TAG = new RegExp(/^(\w+-\d+)/);
|
|
19
|
-
export const REGEX_SLASH_NUM = new RegExp(/\/(\d+)/);
|
|
20
|
-
export const REGEX_START_NUM = new RegExp(/^(\d+)/);
|
|
21
19
|
export const REGEX_START_UND = new RegExp(/^([A-Z]+-[\[a-zA-Z\]\d]+)_/);
|
|
22
20
|
export const REGEX_SLASH_UND = new RegExp(/\/([A-Z]+-[\[a-zA-Z\]\d]+)_/);
|
|
23
21
|
|
|
22
|
+
// TODO: This might conflict with version from better-branch
|
|
23
|
+
// - Maybe negative lookup against .
|
|
24
|
+
// - Maybe check the order
|
|
25
|
+
// - Maybe use order to split and check values
|
|
26
|
+
export const REGEX_SLASH_NUM = new RegExp(/\/(\d+)/);
|
|
27
|
+
export const REGEX_START_NUM = new RegExp(/^(\d+)/);
|
|
28
|
+
|
|
24
29
|
export const DEFAULT_TYPE_OPTIONS = [
|
|
25
30
|
{ value: "feat", label: "feat", hint: "A new feature", emoji: "✨", trailer: "Changelog: feature"},
|
|
26
31
|
{ value: "fix", label: "fix", hint: "A bug fix", emoji: "🐛", trailer: "Changelog: fix"},
|
|
@@ -110,6 +115,15 @@ export const Z_FOOTER_OPTIONS = z.enum([
|
|
|
110
115
|
"deprecated",
|
|
111
116
|
"custom",
|
|
112
117
|
]);
|
|
118
|
+
export const Z_BRANCH_FIELDS = z.enum(["user", "version", "type", "ticket", "description"]);
|
|
119
|
+
export const Z_BRANCH_CONFIG_FIELDS = z.enum([
|
|
120
|
+
"branch_user",
|
|
121
|
+
"branch_version",
|
|
122
|
+
"branch_type",
|
|
123
|
+
"branch_ticket",
|
|
124
|
+
"branch_description"
|
|
125
|
+
]);
|
|
126
|
+
export const BRANCH_ORDER_DEFAULTS: z.infer<typeof Z_BRANCH_FIELDS>[] = ["user", "version", "type", "ticket", "description"]
|
|
113
127
|
export const Z_BRANCH_ACTIONS = z.enum(["branch", "worktree"]);
|
|
114
128
|
export const FOOTER_OPTION_VALUES: z.infer<typeof Z_FOOTER_OPTIONS>[] = [
|
|
115
129
|
"closes",
|
package/src/zod-state.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import {
|
|
3
|
+
BRANCH_ORDER_DEFAULTS,
|
|
3
4
|
CUSTOM_SCOPE_KEY,
|
|
4
5
|
DEFAULT_SCOPE_OPTIONS,
|
|
5
6
|
DEFAULT_TYPE_OPTIONS,
|
|
6
7
|
FOOTER_OPTION_VALUES,
|
|
7
8
|
Z_BRANCH_ACTIONS,
|
|
9
|
+
Z_BRANCH_FIELDS,
|
|
8
10
|
Z_FOOTER_OPTIONS,
|
|
9
11
|
} from "./utils";
|
|
10
12
|
|
|
@@ -95,7 +97,8 @@ export const Config = z
|
|
|
95
97
|
confirm_ticket: z.boolean().default(true),
|
|
96
98
|
add_to_title: z.boolean().default(true),
|
|
97
99
|
append_hashtag: z.boolean().default(false),
|
|
98
|
-
|
|
100
|
+
surround: z.enum(["", "()", "[]", "{}"]).default(""),
|
|
101
|
+
title_position: z.enum(["start", "end", "before-colon"]).default("start"),
|
|
99
102
|
})
|
|
100
103
|
.default({}),
|
|
101
104
|
commit_title: z
|
|
@@ -140,6 +143,13 @@ export const Config = z
|
|
|
140
143
|
separator: z.enum(["/", "-", "_"]).default("/"),
|
|
141
144
|
})
|
|
142
145
|
.default({}),
|
|
146
|
+
branch_version: z
|
|
147
|
+
.object({
|
|
148
|
+
enable: z.boolean().default(false),
|
|
149
|
+
required: z.boolean().default(false),
|
|
150
|
+
separator: z.enum(["/", "-", "_"]).default("/"),
|
|
151
|
+
})
|
|
152
|
+
.default({}),
|
|
143
153
|
branch_ticket: z
|
|
144
154
|
.object({
|
|
145
155
|
enable: z.boolean().default(true),
|
|
@@ -150,9 +160,11 @@ export const Config = z
|
|
|
150
160
|
branch_description: z
|
|
151
161
|
.object({
|
|
152
162
|
max_length: z.number().positive().default(70),
|
|
163
|
+
separator: z.enum(["", "/", "-", "_"]).default(""),
|
|
153
164
|
})
|
|
154
165
|
.default({}),
|
|
155
166
|
branch_action_default: Z_BRANCH_ACTIONS.default("branch"),
|
|
167
|
+
branch_order: z.array(Z_BRANCH_FIELDS).default(BRANCH_ORDER_DEFAULTS),
|
|
156
168
|
enable_worktrees: z.boolean().default(true),
|
|
157
169
|
overrides: z.object({ shell: z.string().optional() }).default({}),
|
|
158
170
|
})
|
|
@@ -182,5 +194,6 @@ export const BranchState = z
|
|
|
182
194
|
type: z.string().default(""),
|
|
183
195
|
ticket: z.string().default(""),
|
|
184
196
|
description: z.string().default(""),
|
|
197
|
+
version: z.string().default("")
|
|
185
198
|
})
|
|
186
199
|
.default({});
|