better-commits 1.6.0 → 1.7.1
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 +174 -32
- package/dist/index.js +122 -32
- package/dist/init.js +101 -27
- package/dist/utils.js +130 -32
- package/dist/zod-state.js +92 -26
- package/package.json +1 -1
- package/readme.md +114 -31
- package/src/branch.ts +74 -6
- package/src/utils.ts +165 -79
- package/src/zod-state.ts +179 -116
package/dist/branch.js
CHANGED
|
@@ -47,13 +47,48 @@ var REGEX_SLASH_UND = new RegExp(/\/([A-Z]+-[\[a-zA-Z\]\d]+)_/);
|
|
|
47
47
|
var DEFAULT_TYPE_OPTIONS = [
|
|
48
48
|
{ value: "feat", label: "feat", hint: "A new feature", emoji: "\u2728" },
|
|
49
49
|
{ value: "fix", label: "fix", hint: "A bug fix", emoji: "\u{1F41B}" },
|
|
50
|
-
{
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
{
|
|
50
|
+
{
|
|
51
|
+
value: "docs",
|
|
52
|
+
label: "docs",
|
|
53
|
+
hint: "Documentation only changes",
|
|
54
|
+
emoji: "\u{1F4DA}"
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
value: "refactor",
|
|
58
|
+
label: "refactor",
|
|
59
|
+
hint: "A code change that neither fixes a bug nor adds a feature",
|
|
60
|
+
emoji: "\u{1F528}"
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
value: "perf",
|
|
64
|
+
label: "perf",
|
|
65
|
+
hint: "A code change that improves performance",
|
|
66
|
+
emoji: "\u{1F680}"
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
value: "test",
|
|
70
|
+
label: "test",
|
|
71
|
+
hint: "Adding missing tests or correcting existing tests",
|
|
72
|
+
emoji: "\u{1F6A8}"
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
value: "build",
|
|
76
|
+
label: "build",
|
|
77
|
+
hint: "Changes that affect the build system or external dependencies",
|
|
78
|
+
emoji: "\u{1F6A7}"
|
|
79
|
+
},
|
|
80
|
+
{
|
|
81
|
+
value: "ci",
|
|
82
|
+
label: "ci",
|
|
83
|
+
hint: "Changes to our CI configuration files and scripts",
|
|
84
|
+
emoji: "\u{1F916}"
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
value: "chore",
|
|
88
|
+
label: "chore",
|
|
89
|
+
hint: "Other changes that do not modify src or test files",
|
|
90
|
+
emoji: "\u{1F9F9}"
|
|
91
|
+
},
|
|
57
92
|
{ value: "", label: "none" }
|
|
58
93
|
];
|
|
59
94
|
var DEFAULT_SCOPE_OPTIONS = [
|
|
@@ -64,8 +99,23 @@ var DEFAULT_SCOPE_OPTIONS = [
|
|
|
64
99
|
{ value: "", label: "none" }
|
|
65
100
|
];
|
|
66
101
|
var CUSTOM_SCOPE_KEY = "custom";
|
|
67
|
-
var Z_FOOTER_OPTIONS = import_zod.z.enum([
|
|
68
|
-
|
|
102
|
+
var Z_FOOTER_OPTIONS = import_zod.z.enum([
|
|
103
|
+
"closes",
|
|
104
|
+
"breaking-change",
|
|
105
|
+
"deprecated",
|
|
106
|
+
"custom"
|
|
107
|
+
]);
|
|
108
|
+
var Z_BRANCH_ACTIONS = import_zod.z.enum(["branch", "worktree"]);
|
|
109
|
+
var FOOTER_OPTION_VALUES = [
|
|
110
|
+
"closes",
|
|
111
|
+
"breaking-change",
|
|
112
|
+
"deprecated",
|
|
113
|
+
"custom"
|
|
114
|
+
];
|
|
115
|
+
var BRANCH_ACTION_OPTIONS = [
|
|
116
|
+
{ value: "branch", label: "Branch" },
|
|
117
|
+
{ value: "worktree", label: "Worktree" }
|
|
118
|
+
];
|
|
69
119
|
function load_setup(cli_name = " better-commits ") {
|
|
70
120
|
console.clear();
|
|
71
121
|
p.intro(`${import_picocolors.default.bgCyan(import_picocolors.default.black(cli_name))}`);
|
|
@@ -81,7 +131,9 @@ function load_setup(cli_name = " better-commits ") {
|
|
|
81
131
|
return read_config_from_path(home_path);
|
|
82
132
|
}
|
|
83
133
|
const default_config = Config.parse({});
|
|
84
|
-
p.log.step(
|
|
134
|
+
p.log.step(
|
|
135
|
+
"Config not found. Generating default .better-commit.json at $HOME"
|
|
136
|
+
);
|
|
85
137
|
import_fs.default.writeFileSync(home_path, JSON.stringify(default_config, null, 4));
|
|
86
138
|
return default_config;
|
|
87
139
|
}
|
|
@@ -104,7 +156,15 @@ function validate_config(config) {
|
|
|
104
156
|
}
|
|
105
157
|
}
|
|
106
158
|
function get_git_root() {
|
|
107
|
-
|
|
159
|
+
let path = ".";
|
|
160
|
+
try {
|
|
161
|
+
path = (0, import_child_process.execSync)("git rev-parse --show-toplevel").toString().trim();
|
|
162
|
+
} catch (err) {
|
|
163
|
+
p.log.warn(
|
|
164
|
+
"Could not find git root. If in a --bare repository, ignore this warning."
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
return path;
|
|
108
168
|
}
|
|
109
169
|
function get_default_config_path() {
|
|
110
170
|
return (0, import_os.homedir)() + "/" + CONFIG_FILE_NAME;
|
|
@@ -119,12 +179,14 @@ var Config = import_zod2.z.object({
|
|
|
119
179
|
infer_type_from_branch: import_zod2.z.boolean().default(true),
|
|
120
180
|
append_emoji_to_label: import_zod2.z.boolean().default(false),
|
|
121
181
|
append_emoji_to_commit: import_zod2.z.boolean().default(false),
|
|
122
|
-
options: import_zod2.z.array(
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
182
|
+
options: import_zod2.z.array(
|
|
183
|
+
import_zod2.z.object({
|
|
184
|
+
value: import_zod2.z.string(),
|
|
185
|
+
label: import_zod2.z.string().optional(),
|
|
186
|
+
hint: import_zod2.z.string().optional(),
|
|
187
|
+
emoji: import_zod2.z.string().emoji().optional()
|
|
188
|
+
})
|
|
189
|
+
).default(DEFAULT_TYPE_OPTIONS)
|
|
128
190
|
}).default({}).transform((val) => {
|
|
129
191
|
const options = val.options.map((v) => ({
|
|
130
192
|
...v,
|
|
@@ -133,30 +195,46 @@ var Config = import_zod2.z.object({
|
|
|
133
195
|
return { ...val, options };
|
|
134
196
|
}).refine(
|
|
135
197
|
(val) => val.options.map((v) => v.value).includes(val.initial_value),
|
|
136
|
-
(val) => ({
|
|
198
|
+
(val) => ({
|
|
199
|
+
message: `Type: initial_value "${val.initial_value}" must exist in options`
|
|
200
|
+
})
|
|
137
201
|
),
|
|
138
202
|
commit_scope: import_zod2.z.object({
|
|
139
203
|
enable: import_zod2.z.boolean().default(true),
|
|
140
204
|
custom_scope: import_zod2.z.boolean().default(false),
|
|
141
205
|
initial_value: import_zod2.z.string().default("app"),
|
|
142
|
-
options: import_zod2.z.array(
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
206
|
+
options: import_zod2.z.array(
|
|
207
|
+
import_zod2.z.object({
|
|
208
|
+
value: import_zod2.z.string(),
|
|
209
|
+
label: import_zod2.z.string().optional(),
|
|
210
|
+
hint: import_zod2.z.string().optional()
|
|
211
|
+
})
|
|
212
|
+
).default(DEFAULT_SCOPE_OPTIONS)
|
|
147
213
|
}).default({}).transform((val) => {
|
|
148
214
|
const options = val.options.map((v) => v.value);
|
|
149
215
|
if (val.custom_scope && !options.includes(CUSTOM_SCOPE_KEY)) {
|
|
150
216
|
return {
|
|
151
217
|
...val,
|
|
152
|
-
options: [
|
|
218
|
+
options: [
|
|
219
|
+
...val.options,
|
|
220
|
+
{
|
|
221
|
+
label: CUSTOM_SCOPE_KEY,
|
|
222
|
+
value: CUSTOM_SCOPE_KEY,
|
|
223
|
+
hint: "Write a custom scope"
|
|
224
|
+
}
|
|
225
|
+
]
|
|
153
226
|
};
|
|
154
227
|
}
|
|
155
228
|
return val;
|
|
156
|
-
}).refine(
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
229
|
+
}).refine(
|
|
230
|
+
(val) => {
|
|
231
|
+
const options = val.options.map((v) => v.value);
|
|
232
|
+
return options.includes(val.initial_value);
|
|
233
|
+
},
|
|
234
|
+
(val) => ({
|
|
235
|
+
message: `Scope: initial_value "${val.initial_value}" must exist in options`
|
|
236
|
+
})
|
|
237
|
+
),
|
|
160
238
|
check_ticket: import_zod2.z.object({
|
|
161
239
|
infer_ticket: import_zod2.z.boolean().default(true),
|
|
162
240
|
confirm_ticket: import_zod2.z.boolean().default(true),
|
|
@@ -200,6 +278,8 @@ var Config = import_zod2.z.object({
|
|
|
200
278
|
branch_description: import_zod2.z.object({
|
|
201
279
|
max_length: import_zod2.z.number().positive().default(70)
|
|
202
280
|
}).default({}),
|
|
281
|
+
branch_action_default: Z_BRANCH_ACTIONS.default("branch"),
|
|
282
|
+
enable_worktrees: import_zod2.z.boolean().default(true),
|
|
203
283
|
overrides: import_zod2.z.object({ shell: import_zod2.z.string().optional() }).default({})
|
|
204
284
|
}).default({});
|
|
205
285
|
var CommitState = import_zod2.z.object({
|
|
@@ -224,13 +304,25 @@ var BranchState = import_zod2.z.object({
|
|
|
224
304
|
}).default({});
|
|
225
305
|
|
|
226
306
|
// src/branch.ts
|
|
227
|
-
var import_simple_git = __toESM(require("simple-git"));
|
|
228
307
|
var p2 = __toESM(require("@clack/prompts"));
|
|
229
308
|
var import_configstore = __toESM(require("configstore"));
|
|
230
309
|
var import_child_process2 = require("child_process");
|
|
310
|
+
var import_picocolors2 = __toESM(require("picocolors"));
|
|
311
|
+
var import_process = require("process");
|
|
231
312
|
main(load_setup(" better-branch "));
|
|
232
313
|
async function main(config) {
|
|
233
314
|
const branch_state = BranchState.parse({});
|
|
315
|
+
let checkout_type = "branch";
|
|
316
|
+
if (config.enable_worktrees) {
|
|
317
|
+
const branch_or_worktree = await p2.select({
|
|
318
|
+
message: `Checkout a branch or create a worktree?`,
|
|
319
|
+
initialValue: config.branch_action_default,
|
|
320
|
+
options: BRANCH_ACTION_OPTIONS
|
|
321
|
+
});
|
|
322
|
+
if (p2.isCancel(branch_or_worktree))
|
|
323
|
+
process.exit();
|
|
324
|
+
checkout_type = branch_or_worktree;
|
|
325
|
+
}
|
|
234
326
|
if (config.branch_user.enable) {
|
|
235
327
|
const cache_user_name = get_user_from_cache();
|
|
236
328
|
const user_name_required = config.branch_user.required;
|
|
@@ -296,9 +388,45 @@ async function main(config) {
|
|
|
296
388
|
}
|
|
297
389
|
});
|
|
298
390
|
const branch_name = build_branch(branch_state, config);
|
|
299
|
-
const
|
|
300
|
-
|
|
301
|
-
|
|
391
|
+
const branch_flag = verify_branch_name(branch_name);
|
|
392
|
+
if (checkout_type === "branch") {
|
|
393
|
+
try {
|
|
394
|
+
(0, import_child_process2.execSync)(`git checkout ${branch_flag} ${branch_name}`, {
|
|
395
|
+
stdio: "inherit"
|
|
396
|
+
});
|
|
397
|
+
p2.log.info(
|
|
398
|
+
`Switched to a new branch '${import_picocolors2.default.bgGreen(
|
|
399
|
+
" " + import_picocolors2.default.black(branch_name) + " "
|
|
400
|
+
)}'`
|
|
401
|
+
);
|
|
402
|
+
} catch (err) {
|
|
403
|
+
process.exit(0);
|
|
404
|
+
}
|
|
405
|
+
} else {
|
|
406
|
+
try {
|
|
407
|
+
const ticket = branch_state.ticket ? `${branch_state.ticket}-` : "";
|
|
408
|
+
const worktree_name = `${ticket}${branch_state.description}`;
|
|
409
|
+
(0, import_child_process2.execSync)(
|
|
410
|
+
`git worktree add ${worktree_name} ${branch_flag} ${branch_name}`,
|
|
411
|
+
{
|
|
412
|
+
stdio: "inherit"
|
|
413
|
+
}
|
|
414
|
+
);
|
|
415
|
+
p2.log.info(
|
|
416
|
+
`Created a new worktree ${import_picocolors2.default.bgGreen(
|
|
417
|
+
+" " + import_picocolors2.default.black(worktree_name) + " "
|
|
418
|
+
)}, checked out branch ${import_picocolors2.default.bgGreen(
|
|
419
|
+
" " + import_picocolors2.default.black(branch_name) + " "
|
|
420
|
+
)}`
|
|
421
|
+
);
|
|
422
|
+
p2.log.info(
|
|
423
|
+
import_picocolors2.default.bgMagenta(import_picocolors2.default.black(` cd ${worktree_name} `)) + " to navigate to your new worktree"
|
|
424
|
+
);
|
|
425
|
+
(0, import_process.chdir)(worktree_name);
|
|
426
|
+
} catch (err) {
|
|
427
|
+
process.exit(0);
|
|
428
|
+
}
|
|
429
|
+
}
|
|
302
430
|
config.branch_post_commands.forEach((command) => {
|
|
303
431
|
try {
|
|
304
432
|
(0, import_child_process2.execSync)(command, { stdio: "inherit" });
|
|
@@ -331,6 +459,20 @@ function get_user_from_cache() {
|
|
|
331
459
|
}
|
|
332
460
|
return "";
|
|
333
461
|
}
|
|
462
|
+
function verify_branch_name(branch_name) {
|
|
463
|
+
let branch_flag = "";
|
|
464
|
+
try {
|
|
465
|
+
(0, import_child_process2.execSync)(`git show-ref ${branch_name}`, { encoding: "utf-8" });
|
|
466
|
+
p2.log.warning(
|
|
467
|
+
import_picocolors2.default.yellow(
|
|
468
|
+
`${branch_name} already exists! Checking out existing branch.`
|
|
469
|
+
)
|
|
470
|
+
);
|
|
471
|
+
} catch (err) {
|
|
472
|
+
branch_flag = "-b";
|
|
473
|
+
}
|
|
474
|
+
return branch_flag;
|
|
475
|
+
}
|
|
334
476
|
function set_user_cache(val) {
|
|
335
477
|
try {
|
|
336
478
|
const config_store = new import_configstore.default("better-commits");
|
package/dist/index.js
CHANGED
|
@@ -63,13 +63,48 @@ var REGEX_SLASH_UND = new RegExp(/\/([A-Z]+-[\[a-zA-Z\]\d]+)_/);
|
|
|
63
63
|
var DEFAULT_TYPE_OPTIONS = [
|
|
64
64
|
{ value: "feat", label: "feat", hint: "A new feature", emoji: "\u2728" },
|
|
65
65
|
{ value: "fix", label: "fix", hint: "A bug fix", emoji: "\u{1F41B}" },
|
|
66
|
-
{
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
{
|
|
66
|
+
{
|
|
67
|
+
value: "docs",
|
|
68
|
+
label: "docs",
|
|
69
|
+
hint: "Documentation only changes",
|
|
70
|
+
emoji: "\u{1F4DA}"
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
value: "refactor",
|
|
74
|
+
label: "refactor",
|
|
75
|
+
hint: "A code change that neither fixes a bug nor adds a feature",
|
|
76
|
+
emoji: "\u{1F528}"
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
value: "perf",
|
|
80
|
+
label: "perf",
|
|
81
|
+
hint: "A code change that improves performance",
|
|
82
|
+
emoji: "\u{1F680}"
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
value: "test",
|
|
86
|
+
label: "test",
|
|
87
|
+
hint: "Adding missing tests or correcting existing tests",
|
|
88
|
+
emoji: "\u{1F6A8}"
|
|
89
|
+
},
|
|
90
|
+
{
|
|
91
|
+
value: "build",
|
|
92
|
+
label: "build",
|
|
93
|
+
hint: "Changes that affect the build system or external dependencies",
|
|
94
|
+
emoji: "\u{1F6A7}"
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
value: "ci",
|
|
98
|
+
label: "ci",
|
|
99
|
+
hint: "Changes to our CI configuration files and scripts",
|
|
100
|
+
emoji: "\u{1F916}"
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
value: "chore",
|
|
104
|
+
label: "chore",
|
|
105
|
+
hint: "Other changes that do not modify src or test files",
|
|
106
|
+
emoji: "\u{1F9F9}"
|
|
107
|
+
},
|
|
73
108
|
{ value: "", label: "none" }
|
|
74
109
|
];
|
|
75
110
|
var DEFAULT_SCOPE_OPTIONS = [
|
|
@@ -80,14 +115,33 @@ var DEFAULT_SCOPE_OPTIONS = [
|
|
|
80
115
|
{ value: "", label: "none" }
|
|
81
116
|
];
|
|
82
117
|
var COMMIT_FOOTER_OPTIONS = [
|
|
83
|
-
{
|
|
84
|
-
|
|
118
|
+
{
|
|
119
|
+
value: "closes",
|
|
120
|
+
label: "closes <issue/ticket>",
|
|
121
|
+
hint: "Attempts to infer ticket from branch"
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
value: "breaking-change",
|
|
125
|
+
label: "breaking change",
|
|
126
|
+
hint: "Add breaking change"
|
|
127
|
+
},
|
|
85
128
|
{ value: "deprecated", label: "deprecated", hint: "Add deprecated change" },
|
|
86
129
|
{ value: "custom", label: "custom", hint: "Add a custom footer" }
|
|
87
130
|
];
|
|
88
131
|
var CUSTOM_SCOPE_KEY = "custom";
|
|
89
|
-
var Z_FOOTER_OPTIONS = import_zod.z.enum([
|
|
90
|
-
|
|
132
|
+
var Z_FOOTER_OPTIONS = import_zod.z.enum([
|
|
133
|
+
"closes",
|
|
134
|
+
"breaking-change",
|
|
135
|
+
"deprecated",
|
|
136
|
+
"custom"
|
|
137
|
+
]);
|
|
138
|
+
var Z_BRANCH_ACTIONS = import_zod.z.enum(["branch", "worktree"]);
|
|
139
|
+
var FOOTER_OPTION_VALUES = [
|
|
140
|
+
"closes",
|
|
141
|
+
"breaking-change",
|
|
142
|
+
"deprecated",
|
|
143
|
+
"custom"
|
|
144
|
+
];
|
|
91
145
|
function load_setup(cli_name = " better-commits ") {
|
|
92
146
|
console.clear();
|
|
93
147
|
p.intro(`${import_picocolors.default.bgCyan(import_picocolors.default.black(cli_name))}`);
|
|
@@ -103,7 +157,9 @@ function load_setup(cli_name = " better-commits ") {
|
|
|
103
157
|
return read_config_from_path(home_path);
|
|
104
158
|
}
|
|
105
159
|
const default_config = Config.parse({});
|
|
106
|
-
p.log.step(
|
|
160
|
+
p.log.step(
|
|
161
|
+
"Config not found. Generating default .better-commit.json at $HOME"
|
|
162
|
+
);
|
|
107
163
|
import_fs.default.writeFileSync(home_path, JSON.stringify(default_config, null, 4));
|
|
108
164
|
return default_config;
|
|
109
165
|
}
|
|
@@ -128,7 +184,9 @@ function validate_config(config) {
|
|
|
128
184
|
function infer_type_from_branch(types) {
|
|
129
185
|
let branch = "";
|
|
130
186
|
try {
|
|
131
|
-
branch = (0, import_child_process.execSync)("git branch --show-current", {
|
|
187
|
+
branch = (0, import_child_process.execSync)("git branch --show-current", {
|
|
188
|
+
stdio: "pipe"
|
|
189
|
+
}).toString();
|
|
132
190
|
} catch (err) {
|
|
133
191
|
return "";
|
|
134
192
|
}
|
|
@@ -136,13 +194,25 @@ function infer_type_from_branch(types) {
|
|
|
136
194
|
const start_dash = new RegExp(`^${t}-`);
|
|
137
195
|
const between_dash = new RegExp(`-${t}-`);
|
|
138
196
|
const before_slash = new RegExp(`${t}/`);
|
|
139
|
-
const re = [
|
|
197
|
+
const re = [
|
|
198
|
+
branch.match(start_dash),
|
|
199
|
+
branch.match(between_dash),
|
|
200
|
+
branch.match(before_slash)
|
|
201
|
+
].filter((v) => v != null);
|
|
140
202
|
return re?.length;
|
|
141
203
|
});
|
|
142
204
|
return found ?? "";
|
|
143
205
|
}
|
|
144
206
|
function get_git_root() {
|
|
145
|
-
|
|
207
|
+
let path = ".";
|
|
208
|
+
try {
|
|
209
|
+
path = (0, import_child_process.execSync)("git rev-parse --show-toplevel").toString().trim();
|
|
210
|
+
} catch (err) {
|
|
211
|
+
p.log.warn(
|
|
212
|
+
"Could not find git root. If in a --bare repository, ignore this warning."
|
|
213
|
+
);
|
|
214
|
+
}
|
|
215
|
+
return path;
|
|
146
216
|
}
|
|
147
217
|
function get_default_config_path() {
|
|
148
218
|
return (0, import_os.homedir)() + "/" + CONFIG_FILE_NAME;
|
|
@@ -171,12 +241,14 @@ var Config = import_zod2.z.object({
|
|
|
171
241
|
infer_type_from_branch: import_zod2.z.boolean().default(true),
|
|
172
242
|
append_emoji_to_label: import_zod2.z.boolean().default(false),
|
|
173
243
|
append_emoji_to_commit: import_zod2.z.boolean().default(false),
|
|
174
|
-
options: import_zod2.z.array(
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
244
|
+
options: import_zod2.z.array(
|
|
245
|
+
import_zod2.z.object({
|
|
246
|
+
value: import_zod2.z.string(),
|
|
247
|
+
label: import_zod2.z.string().optional(),
|
|
248
|
+
hint: import_zod2.z.string().optional(),
|
|
249
|
+
emoji: import_zod2.z.string().emoji().optional()
|
|
250
|
+
})
|
|
251
|
+
).default(DEFAULT_TYPE_OPTIONS)
|
|
180
252
|
}).default({}).transform((val) => {
|
|
181
253
|
const options = val.options.map((v) => ({
|
|
182
254
|
...v,
|
|
@@ -185,30 +257,46 @@ var Config = import_zod2.z.object({
|
|
|
185
257
|
return { ...val, options };
|
|
186
258
|
}).refine(
|
|
187
259
|
(val) => val.options.map((v) => v.value).includes(val.initial_value),
|
|
188
|
-
(val) => ({
|
|
260
|
+
(val) => ({
|
|
261
|
+
message: `Type: initial_value "${val.initial_value}" must exist in options`
|
|
262
|
+
})
|
|
189
263
|
),
|
|
190
264
|
commit_scope: import_zod2.z.object({
|
|
191
265
|
enable: import_zod2.z.boolean().default(true),
|
|
192
266
|
custom_scope: import_zod2.z.boolean().default(false),
|
|
193
267
|
initial_value: import_zod2.z.string().default("app"),
|
|
194
|
-
options: import_zod2.z.array(
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
268
|
+
options: import_zod2.z.array(
|
|
269
|
+
import_zod2.z.object({
|
|
270
|
+
value: import_zod2.z.string(),
|
|
271
|
+
label: import_zod2.z.string().optional(),
|
|
272
|
+
hint: import_zod2.z.string().optional()
|
|
273
|
+
})
|
|
274
|
+
).default(DEFAULT_SCOPE_OPTIONS)
|
|
199
275
|
}).default({}).transform((val) => {
|
|
200
276
|
const options = val.options.map((v) => v.value);
|
|
201
277
|
if (val.custom_scope && !options.includes(CUSTOM_SCOPE_KEY)) {
|
|
202
278
|
return {
|
|
203
279
|
...val,
|
|
204
|
-
options: [
|
|
280
|
+
options: [
|
|
281
|
+
...val.options,
|
|
282
|
+
{
|
|
283
|
+
label: CUSTOM_SCOPE_KEY,
|
|
284
|
+
value: CUSTOM_SCOPE_KEY,
|
|
285
|
+
hint: "Write a custom scope"
|
|
286
|
+
}
|
|
287
|
+
]
|
|
205
288
|
};
|
|
206
289
|
}
|
|
207
290
|
return val;
|
|
208
|
-
}).refine(
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
291
|
+
}).refine(
|
|
292
|
+
(val) => {
|
|
293
|
+
const options = val.options.map((v) => v.value);
|
|
294
|
+
return options.includes(val.initial_value);
|
|
295
|
+
},
|
|
296
|
+
(val) => ({
|
|
297
|
+
message: `Scope: initial_value "${val.initial_value}" must exist in options`
|
|
298
|
+
})
|
|
299
|
+
),
|
|
212
300
|
check_ticket: import_zod2.z.object({
|
|
213
301
|
infer_ticket: import_zod2.z.boolean().default(true),
|
|
214
302
|
confirm_ticket: import_zod2.z.boolean().default(true),
|
|
@@ -252,6 +340,8 @@ var Config = import_zod2.z.object({
|
|
|
252
340
|
branch_description: import_zod2.z.object({
|
|
253
341
|
max_length: import_zod2.z.number().positive().default(70)
|
|
254
342
|
}).default({}),
|
|
343
|
+
branch_action_default: Z_BRANCH_ACTIONS.default("branch"),
|
|
344
|
+
enable_worktrees: import_zod2.z.boolean().default(true),
|
|
255
345
|
overrides: import_zod2.z.object({ shell: import_zod2.z.string().optional() }).default({})
|
|
256
346
|
}).default({});
|
|
257
347
|
var CommitState = import_zod2.z.object({
|