better-commits 1.11.0 → 1.13.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/.better-commits.json +1 -1
- package/dist/branch.js +2 -0
- package/dist/index.js +12 -1
- package/dist/init.js +2 -0
- package/dist/utils.js +2 -0
- package/dist/zod-state.js +2 -0
- package/package.json +1 -1
- package/readme.md +15 -1
- package/src/index.ts +16 -2
- package/src/zod-state.ts +2 -0
package/.better-commits.json
CHANGED
package/dist/branch.js
CHANGED
|
@@ -262,6 +262,7 @@ var Config = import_zod2.z.object({
|
|
|
262
262
|
confirm_ticket: import_zod2.z.boolean().default(true),
|
|
263
263
|
add_to_title: import_zod2.z.boolean().default(true),
|
|
264
264
|
append_hashtag: import_zod2.z.boolean().default(false),
|
|
265
|
+
prepend_hashtag: import_zod2.z.enum(["Never", "Always", "Prompt"]).default("Never"),
|
|
265
266
|
surround: import_zod2.z.enum(["", "()", "[]", "{}"]).default(""),
|
|
266
267
|
title_position: import_zod2.z.enum(["start", "end", "before-colon"]).default("start")
|
|
267
268
|
}).default({}),
|
|
@@ -280,6 +281,7 @@ var Config = import_zod2.z.object({
|
|
|
280
281
|
breaking_change: import_zod2.z.object({
|
|
281
282
|
add_exclamation_to_title: import_zod2.z.boolean().default(true)
|
|
282
283
|
}).default({}),
|
|
284
|
+
confirm_with_editor: import_zod2.z.boolean().default(false),
|
|
283
285
|
confirm_commit: import_zod2.z.boolean().default(true),
|
|
284
286
|
print_commit_output: import_zod2.z.boolean().default(true),
|
|
285
287
|
branch_pre_commands: import_zod2.z.array(import_zod2.z.string()).default([]),
|
package/dist/index.js
CHANGED
|
@@ -326,6 +326,7 @@ var Config = import_zod2.z.object({
|
|
|
326
326
|
confirm_ticket: import_zod2.z.boolean().default(true),
|
|
327
327
|
add_to_title: import_zod2.z.boolean().default(true),
|
|
328
328
|
append_hashtag: import_zod2.z.boolean().default(false),
|
|
329
|
+
prepend_hashtag: import_zod2.z.enum(["Never", "Always", "Prompt"]).default("Never"),
|
|
329
330
|
surround: import_zod2.z.enum(["", "()", "[]", "{}"]).default(""),
|
|
330
331
|
title_position: import_zod2.z.enum(["start", "end", "before-colon"]).default("start")
|
|
331
332
|
}).default({}),
|
|
@@ -344,6 +345,7 @@ var Config = import_zod2.z.object({
|
|
|
344
345
|
breaking_change: import_zod2.z.object({
|
|
345
346
|
add_exclamation_to_title: import_zod2.z.boolean().default(true)
|
|
346
347
|
}).default({}),
|
|
348
|
+
confirm_with_editor: import_zod2.z.boolean().default(false),
|
|
347
349
|
confirm_commit: import_zod2.z.boolean().default(true),
|
|
348
350
|
print_commit_output: import_zod2.z.boolean().default(true),
|
|
349
351
|
branch_pre_commands: import_zod2.z.array(import_zod2.z.string()).default([]),
|
|
@@ -535,7 +537,7 @@ async function main(config) {
|
|
|
535
537
|
branch.match(REGEX_START_NUM)
|
|
536
538
|
].filter((v) => v != null).map((v) => v && v.length >= 2 ? v[1] : "");
|
|
537
539
|
if (found.length && found[0]) {
|
|
538
|
-
commit_state.ticket = config.check_ticket.append_hashtag ? "#" + found[0] : found[0];
|
|
540
|
+
commit_state.ticket = config.check_ticket.append_hashtag || config.check_ticket.prepend_hashtag === "Prompt" ? "#" + found[0] : found[0];
|
|
539
541
|
}
|
|
540
542
|
} catch (err) {
|
|
541
543
|
}
|
|
@@ -550,6 +552,9 @@ async function main(config) {
|
|
|
550
552
|
process.exit(0);
|
|
551
553
|
commit_state.ticket = user_commit_ticket ?? "";
|
|
552
554
|
}
|
|
555
|
+
if (config.check_ticket.prepend_hashtag === "Always" && commit_state.ticket && !commit_state.ticket.startsWith("#")) {
|
|
556
|
+
commit_state.ticket = "#" + commit_state.ticket;
|
|
557
|
+
}
|
|
553
558
|
const commit_title = await p3.text(
|
|
554
559
|
{
|
|
555
560
|
message: "Write a brief title describing the commit",
|
|
@@ -646,6 +651,12 @@ async function main(config) {
|
|
|
646
651
|
commit_state.trailer = "";
|
|
647
652
|
}
|
|
648
653
|
}
|
|
654
|
+
if (config.confirm_with_editor) {
|
|
655
|
+
const options = config.overrides.shell ? { shell: config.overrides.shell, stdio: "inherit" } : { stdio: "inherit" };
|
|
656
|
+
const trailer = commit_state.trailer ? `--trailer="${commit_state.trailer}"` : "";
|
|
657
|
+
(0, import_child_process3.execSync)(`git commit -m "${build_commit_string(commit_state, config, false, true, false)}" ${trailer} --edit`, options);
|
|
658
|
+
process.exit(0);
|
|
659
|
+
}
|
|
649
660
|
let continue_commit = true;
|
|
650
661
|
p3.note(build_commit_string(commit_state, config, true, false, true), "Commit Preview");
|
|
651
662
|
if (config.confirm_commit) {
|
package/dist/init.js
CHANGED
|
@@ -214,6 +214,7 @@ var Config = import_zod2.z.object({
|
|
|
214
214
|
confirm_ticket: import_zod2.z.boolean().default(true),
|
|
215
215
|
add_to_title: import_zod2.z.boolean().default(true),
|
|
216
216
|
append_hashtag: import_zod2.z.boolean().default(false),
|
|
217
|
+
prepend_hashtag: import_zod2.z.enum(["Never", "Always", "Prompt"]).default("Never"),
|
|
217
218
|
surround: import_zod2.z.enum(["", "()", "[]", "{}"]).default(""),
|
|
218
219
|
title_position: import_zod2.z.enum(["start", "end", "before-colon"]).default("start")
|
|
219
220
|
}).default({}),
|
|
@@ -232,6 +233,7 @@ var Config = import_zod2.z.object({
|
|
|
232
233
|
breaking_change: import_zod2.z.object({
|
|
233
234
|
add_exclamation_to_title: import_zod2.z.boolean().default(true)
|
|
234
235
|
}).default({}),
|
|
236
|
+
confirm_with_editor: import_zod2.z.boolean().default(false),
|
|
235
237
|
confirm_commit: import_zod2.z.boolean().default(true),
|
|
236
238
|
print_commit_output: import_zod2.z.boolean().default(true),
|
|
237
239
|
branch_pre_commands: import_zod2.z.array(import_zod2.z.string()).default([]),
|
package/dist/utils.js
CHANGED
|
@@ -140,6 +140,7 @@ var Config = import_zod.z.object({
|
|
|
140
140
|
confirm_ticket: import_zod.z.boolean().default(true),
|
|
141
141
|
add_to_title: import_zod.z.boolean().default(true),
|
|
142
142
|
append_hashtag: import_zod.z.boolean().default(false),
|
|
143
|
+
prepend_hashtag: import_zod.z.enum(["Never", "Always", "Prompt"]).default("Never"),
|
|
143
144
|
surround: import_zod.z.enum(["", "()", "[]", "{}"]).default(""),
|
|
144
145
|
title_position: import_zod.z.enum(["start", "end", "before-colon"]).default("start")
|
|
145
146
|
}).default({}),
|
|
@@ -158,6 +159,7 @@ var Config = import_zod.z.object({
|
|
|
158
159
|
breaking_change: import_zod.z.object({
|
|
159
160
|
add_exclamation_to_title: import_zod.z.boolean().default(true)
|
|
160
161
|
}).default({}),
|
|
162
|
+
confirm_with_editor: import_zod.z.boolean().default(false),
|
|
161
163
|
confirm_commit: import_zod.z.boolean().default(true),
|
|
162
164
|
print_commit_output: import_zod.z.boolean().default(true),
|
|
163
165
|
branch_pre_commands: import_zod.z.array(import_zod.z.string()).default([]),
|
package/dist/zod-state.js
CHANGED
|
@@ -212,6 +212,7 @@ var Config = import_zod2.z.object({
|
|
|
212
212
|
confirm_ticket: import_zod2.z.boolean().default(true),
|
|
213
213
|
add_to_title: import_zod2.z.boolean().default(true),
|
|
214
214
|
append_hashtag: import_zod2.z.boolean().default(false),
|
|
215
|
+
prepend_hashtag: import_zod2.z.enum(["Never", "Always", "Prompt"]).default("Never"),
|
|
215
216
|
surround: import_zod2.z.enum(["", "()", "[]", "{}"]).default(""),
|
|
216
217
|
title_position: import_zod2.z.enum(["start", "end", "before-colon"]).default("start")
|
|
217
218
|
}).default({}),
|
|
@@ -230,6 +231,7 @@ var Config = import_zod2.z.object({
|
|
|
230
231
|
breaking_change: import_zod2.z.object({
|
|
231
232
|
add_exclamation_to_title: import_zod2.z.boolean().default(true)
|
|
232
233
|
}).default({}),
|
|
234
|
+
confirm_with_editor: import_zod2.z.boolean().default(false),
|
|
233
235
|
confirm_commit: import_zod2.z.boolean().default(true),
|
|
234
236
|
print_commit_output: import_zod2.z.boolean().default(true),
|
|
235
237
|
branch_pre_commands: import_zod2.z.array(import_zod2.z.string()).default([]),
|
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.13.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
|
+
"prepend_hashtag": "Never",
|
|
195
196
|
"surround": "",
|
|
196
197
|
"title_position": "start"
|
|
197
198
|
},
|
|
@@ -217,6 +218,7 @@ Better-commits (& better-branch) are highly flexible with sane defaults. These o
|
|
|
217
218
|
"add_exclamation_to_title": true
|
|
218
219
|
},
|
|
219
220
|
"confirm_commit": true,
|
|
221
|
+
"confirm_with_editor": false,
|
|
220
222
|
"print_commit_output": true,
|
|
221
223
|
"branch_pre_commands": [],
|
|
222
224
|
"branch_post_commands": [],
|
|
@@ -262,8 +264,14 @@ Better-commits (& better-branch) are highly flexible with sane defaults. These o
|
|
|
262
264
|
|
|
263
265
|
</details>
|
|
264
266
|
|
|
267
|
+
> [!NOTE]<br>
|
|
268
|
+
> Some properties use sets of string values
|
|
269
|
+
> See *confile file explanations* for possible values
|
|
270
|
+
|
|
265
271
|
### 🔭 Config File Explanations
|
|
266
272
|
|
|
273
|
+
Expand to see explanations and possible values
|
|
274
|
+
|
|
267
275
|
<details>
|
|
268
276
|
<summary>Expand / Collapse</summary>
|
|
269
277
|
|
|
@@ -296,7 +304,8 @@ Better-commits (& better-branch) are highly flexible with sane defaults. These o
|
|
|
296
304
|
| `check_ticket.infer_ticket` | If true infer ticket from branch name |
|
|
297
305
|
| `check_ticket.confirm_ticket` | If true manually confirm inference |
|
|
298
306
|
| `check_ticket.add_to_title` | If true add ticket to title |
|
|
299
|
-
| `check_ticket.append_hashtag` |
|
|
307
|
+
| `check_ticket.append_hashtag` | **Deprecated**: see prepend_hashtag |
|
|
308
|
+
| `check_ticket.prepend_hashtag` | "Never" (default), "Prompt", or "Always" |
|
|
300
309
|
| `check_ticket.title_position` | "start" (of description) (default), "end", "before-colon" |
|
|
301
310
|
| `check_ticket.surround` | "" (default), "[]", "()", "{}" - Wraps ticket in title |
|
|
302
311
|
| `commit_title.max_size` | Max size of title including scope, type, etc... |
|
|
@@ -307,6 +316,7 @@ Better-commits (& better-branch) are highly flexible with sane defaults. These o
|
|
|
307
316
|
| `commit_footer.options` | Footer options |
|
|
308
317
|
| `breaking_change.add_exclamation_to_title` | If true adds exclamation mark to title for breaking changes |
|
|
309
318
|
| `confirm_commit` | If true manually confirm commit at end |
|
|
319
|
+
| `confirm_with_editor` | Confirm / Edit commit with $GIT_EDITOR / $EDITOR |
|
|
310
320
|
| `print_commit_output` | If true pretty print commit preview |
|
|
311
321
|
| `overrides.shell` | Override default shell, useful for windows users |
|
|
312
322
|
|
|
@@ -405,6 +415,10 @@ If you're using Github issues to track your work, and select the `closes` footer
|
|
|
405
415
|
|
|
406
416
|
`better-commits` uses native `git` commands under the hood. So any hooks, tools, or staging should work as if it was a normal commit.
|
|
407
417
|
|
|
418
|
+
Setting `confirm_with_editor=true` will allow you to edit/confirm a commit with your editor.
|
|
419
|
+
- For example, to edit with Neovim: `git config --global core.editor "nvim"`
|
|
420
|
+
- For VS Code, `git config --global core.editor "code -n --wait"`
|
|
421
|
+
|
|
408
422
|
You can add this badge to your repository to display that you're using a better-commits repository config
|
|
409
423
|
|
|
410
424
|
| Markdown | Result |
|
package/src/index.ts
CHANGED
|
@@ -98,7 +98,9 @@ export async function main(config: z.infer<typeof Config>) {
|
|
|
98
98
|
.filter(v => v != null)
|
|
99
99
|
.map(v => v && v.length >= 2 ? v[1] : '')
|
|
100
100
|
if (found.length && found[0]) {
|
|
101
|
-
commit_state.ticket = config.check_ticket.append_hashtag
|
|
101
|
+
commit_state.ticket = config.check_ticket.append_hashtag
|
|
102
|
+
|| config.check_ticket.prepend_hashtag === 'Prompt'
|
|
103
|
+
? '#' + found[0] : found[0]
|
|
102
104
|
}
|
|
103
105
|
} catch(err: any) {
|
|
104
106
|
// Can't find branch, fail silently
|
|
@@ -115,6 +117,12 @@ export async function main(config: z.infer<typeof Config>) {
|
|
|
115
117
|
commit_state.ticket = user_commit_ticket ?? '';
|
|
116
118
|
}
|
|
117
119
|
|
|
120
|
+
if (config.check_ticket.prepend_hashtag === 'Always'
|
|
121
|
+
&& commit_state.ticket
|
|
122
|
+
&& !commit_state.ticket.startsWith('#')) {
|
|
123
|
+
commit_state.ticket = '#' + commit_state.ticket;
|
|
124
|
+
}
|
|
125
|
+
|
|
118
126
|
const commit_title = await p.text(
|
|
119
127
|
{
|
|
120
128
|
message: 'Write a brief title describing the commit',
|
|
@@ -207,7 +215,13 @@ export async function main(config: z.infer<typeof Config>) {
|
|
|
207
215
|
commit_state.trailer = '';
|
|
208
216
|
}
|
|
209
217
|
}
|
|
210
|
-
|
|
218
|
+
|
|
219
|
+
if (config.confirm_with_editor) {
|
|
220
|
+
const options = config.overrides.shell ? { shell: config.overrides.shell, stdio: 'inherit' } : { stdio: 'inherit' }
|
|
221
|
+
const trailer = commit_state.trailer ? `--trailer="${commit_state.trailer}"` : '';
|
|
222
|
+
execSync(`git commit -m "${build_commit_string(commit_state, config, false, true, false)}" ${trailer} --edit`, options);
|
|
223
|
+
process.exit(0);
|
|
224
|
+
}
|
|
211
225
|
|
|
212
226
|
let continue_commit = true;
|
|
213
227
|
p.note(build_commit_string(commit_state, config, true, false, true), 'Commit Preview')
|
package/src/zod-state.ts
CHANGED
|
@@ -97,6 +97,7 @@ export const Config = z
|
|
|
97
97
|
confirm_ticket: z.boolean().default(true),
|
|
98
98
|
add_to_title: z.boolean().default(true),
|
|
99
99
|
append_hashtag: z.boolean().default(false),
|
|
100
|
+
prepend_hashtag: z.enum(['Never', 'Always', 'Prompt']).default("Never"),
|
|
100
101
|
surround: z.enum(["", "()", "[]", "{}"]).default(""),
|
|
101
102
|
title_position: z.enum(["start", "end", "before-colon"]).default("start"),
|
|
102
103
|
})
|
|
@@ -124,6 +125,7 @@ export const Config = z
|
|
|
124
125
|
add_exclamation_to_title: z.boolean().default(true),
|
|
125
126
|
})
|
|
126
127
|
.default({}),
|
|
128
|
+
confirm_with_editor: z.boolean().default(false),
|
|
127
129
|
confirm_commit: z.boolean().default(true),
|
|
128
130
|
print_commit_output: z.boolean().default(true),
|
|
129
131
|
branch_pre_commands: z.array(z.string()).default([]),
|