better-commits 1.0.5 → 1.0.8-print-output
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/index.js +34 -11
- package/dist/init.js +10 -7
- package/dist/utils.js +8 -6
- package/dist/zod-state.js +10 -7
- package/package.json +1 -1
- package/readme.md +50 -17
- package/src/index.ts +30 -19
- package/src/utils.ts +8 -6
- package/src/zod-state.ts +2 -1
package/dist/index.js
CHANGED
|
@@ -47,12 +47,14 @@ var REGEX_START_TAG = new RegExp(/^(\w+-\d+)/);
|
|
|
47
47
|
var REGEX_SLASH_NUM = new RegExp(/\/(\d+)/);
|
|
48
48
|
var REGEX_START_NUM = new RegExp(/^(\d+)/);
|
|
49
49
|
var DEFAULT_TYPE_OPTIONS = [
|
|
50
|
-
{ value: "feat", label: "feat" },
|
|
51
|
-
{ value: "fix", label: "fix" },
|
|
52
|
-
{ value: "docs", label: "docs" },
|
|
53
|
-
{ value: "refactor", label: "refactor" },
|
|
54
|
-
{ value: "perf", label: "perf" },
|
|
55
|
-
{ value: "test", label: "test" },
|
|
50
|
+
{ value: "feat", label: "feat", hint: "A new feature" },
|
|
51
|
+
{ value: "fix", label: "fix", hint: "A bug fix" },
|
|
52
|
+
{ value: "docs", label: "docs", hint: "Documentation only changes" },
|
|
53
|
+
{ value: "refactor", label: "refactor", hint: "A code change that neither fixes a bug nor adds a feature" },
|
|
54
|
+
{ value: "perf", label: "perf", hint: "A code change that improves performance" },
|
|
55
|
+
{ value: "test", label: "test", hint: "Adding missing tests or correcting existing tests" },
|
|
56
|
+
{ value: "build", label: "build", hint: "Changes that affect the build system or external dependencies" },
|
|
57
|
+
{ value: "ci", label: "ci", hint: "Changes to our CI configuration files and scripts" },
|
|
56
58
|
{ value: "", label: "none" }
|
|
57
59
|
];
|
|
58
60
|
var DEFAULT_SCOPE_OPTIONS = [
|
|
@@ -153,7 +155,8 @@ var Config = import_zod2.z.object({
|
|
|
153
155
|
breaking_change: import_zod2.z.object({
|
|
154
156
|
add_exclamation_to_title: import_zod2.z.boolean().default(true)
|
|
155
157
|
}).default({}),
|
|
156
|
-
confirm_commit: import_zod2.z.boolean().default(true)
|
|
158
|
+
confirm_commit: import_zod2.z.boolean().default(true),
|
|
159
|
+
print_commit_output: import_zod2.z.boolean().default(true)
|
|
157
160
|
}).default({});
|
|
158
161
|
var CommitState = import_zod2.z.object({
|
|
159
162
|
type: import_zod2.z.string().default(""),
|
|
@@ -279,7 +282,8 @@ async function main(config) {
|
|
|
279
282
|
}
|
|
280
283
|
if (config.check_ticket.confirm_ticket) {
|
|
281
284
|
const user_commit_ticket = await p.text({
|
|
282
|
-
message: commit_state.ticket ? `Ticket / issue
|
|
285
|
+
message: commit_state.ticket ? `Ticket / issue inferred from branch ${import_picocolors2.default.dim("(confirm / edit)")}` : `Add ticket / issue ${OPTIONAL_PROMPT}`,
|
|
286
|
+
placeholder: "",
|
|
283
287
|
initialValue: commit_state.ticket
|
|
284
288
|
});
|
|
285
289
|
if (p.isCancel(user_commit_ticket))
|
|
@@ -315,7 +319,7 @@ async function main(config) {
|
|
|
315
319
|
});
|
|
316
320
|
if (p.isCancel(commit_body))
|
|
317
321
|
process.exit(0);
|
|
318
|
-
commit_state.body = commit_body;
|
|
322
|
+
commit_state.body = commit_body ?? "";
|
|
319
323
|
}
|
|
320
324
|
if (config.commit_footer.enable) {
|
|
321
325
|
const commit_footer = await p.multiselect({
|
|
@@ -335,10 +339,14 @@ async function main(config) {
|
|
|
335
339
|
return "Please enter a title / summary";
|
|
336
340
|
}
|
|
337
341
|
});
|
|
342
|
+
if (p.isCancel(breaking_changes_title))
|
|
343
|
+
process.exit(0);
|
|
338
344
|
const breaking_changes_body = await p.text({
|
|
339
345
|
message: `Breaking Changes: Write a description & migration instructions ${OPTIONAL_PROMPT}`,
|
|
340
346
|
placeholder: ""
|
|
341
347
|
});
|
|
348
|
+
if (p.isCancel(breaking_changes_body))
|
|
349
|
+
process.exit(0);
|
|
342
350
|
commit_state.breaking_title = breaking_changes_title;
|
|
343
351
|
commit_state.breaking_body = breaking_changes_body;
|
|
344
352
|
}
|
|
@@ -351,10 +359,14 @@ async function main(config) {
|
|
|
351
359
|
return "Please enter a title / summary";
|
|
352
360
|
}
|
|
353
361
|
});
|
|
362
|
+
if (p.isCancel(deprecated_title))
|
|
363
|
+
process.exit(0);
|
|
354
364
|
const deprecated_body = await p.text({
|
|
355
365
|
message: `Deprecated: Write a description ${OPTIONAL_PROMPT}`,
|
|
356
366
|
placeholder: ""
|
|
357
367
|
});
|
|
368
|
+
if (p.isCancel(deprecated_body))
|
|
369
|
+
process.exit(0);
|
|
358
370
|
commit_state.deprecates_body = deprecated_body;
|
|
359
371
|
commit_state.deprecates_title = deprecated_title;
|
|
360
372
|
}
|
|
@@ -366,6 +378,8 @@ async function main(config) {
|
|
|
366
378
|
message: "Write a custom footer",
|
|
367
379
|
placeholder: ""
|
|
368
380
|
});
|
|
381
|
+
if (p.isCancel(custom_footer))
|
|
382
|
+
process.exit(0);
|
|
369
383
|
commit_state.custom_footer = custom_footer;
|
|
370
384
|
}
|
|
371
385
|
}
|
|
@@ -376,8 +390,17 @@ async function main(config) {
|
|
|
376
390
|
if (p.isCancel(continue_commit))
|
|
377
391
|
process.exit(0);
|
|
378
392
|
}
|
|
379
|
-
if (continue_commit)
|
|
380
|
-
|
|
393
|
+
if (!continue_commit) {
|
|
394
|
+
p.log.info("Exiting without commit");
|
|
395
|
+
process.exit(0);
|
|
396
|
+
}
|
|
397
|
+
try {
|
|
398
|
+
const output = (0, import_child_process2.execSync)(`git commit -m "${build_commit_string(commit_state, config, false)}"`).toString().trim();
|
|
399
|
+
if (config.print_commit_output)
|
|
400
|
+
p.log.info(output);
|
|
401
|
+
} catch (err) {
|
|
402
|
+
p.log.error("Something went wrong when committing: " + err);
|
|
403
|
+
}
|
|
381
404
|
}
|
|
382
405
|
function build_commit_string(commit_state, config, colorize = false) {
|
|
383
406
|
let commit_string = "";
|
package/dist/init.js
CHANGED
|
@@ -37,12 +37,14 @@ var REGEX_START_TAG = new RegExp(/^(\w+-\d+)/);
|
|
|
37
37
|
var REGEX_SLASH_NUM = new RegExp(/\/(\d+)/);
|
|
38
38
|
var REGEX_START_NUM = new RegExp(/^(\d+)/);
|
|
39
39
|
var DEFAULT_TYPE_OPTIONS = [
|
|
40
|
-
{ value: "feat", label: "feat" },
|
|
41
|
-
{ value: "fix", label: "fix" },
|
|
42
|
-
{ value: "docs", label: "docs" },
|
|
43
|
-
{ value: "refactor", label: "refactor" },
|
|
44
|
-
{ value: "perf", label: "perf" },
|
|
45
|
-
{ value: "test", label: "test" },
|
|
40
|
+
{ value: "feat", label: "feat", hint: "A new feature" },
|
|
41
|
+
{ value: "fix", label: "fix", hint: "A bug fix" },
|
|
42
|
+
{ value: "docs", label: "docs", hint: "Documentation only changes" },
|
|
43
|
+
{ value: "refactor", label: "refactor", hint: "A code change that neither fixes a bug nor adds a feature" },
|
|
44
|
+
{ value: "perf", label: "perf", hint: "A code change that improves performance" },
|
|
45
|
+
{ value: "test", label: "test", hint: "Adding missing tests or correcting existing tests" },
|
|
46
|
+
{ value: "build", label: "build", hint: "Changes that affect the build system or external dependencies" },
|
|
47
|
+
{ value: "ci", label: "ci", hint: "Changes to our CI configuration files and scripts" },
|
|
46
48
|
{ value: "", label: "none" }
|
|
47
49
|
];
|
|
48
50
|
var DEFAULT_SCOPE_OPTIONS = [
|
|
@@ -104,7 +106,8 @@ var Config = import_zod2.z.object({
|
|
|
104
106
|
breaking_change: import_zod2.z.object({
|
|
105
107
|
add_exclamation_to_title: import_zod2.z.boolean().default(true)
|
|
106
108
|
}).default({}),
|
|
107
|
-
confirm_commit: import_zod2.z.boolean().default(true)
|
|
109
|
+
confirm_commit: import_zod2.z.boolean().default(true),
|
|
110
|
+
print_commit_output: import_zod2.z.boolean().default(true)
|
|
108
111
|
}).default({});
|
|
109
112
|
var CommitState = import_zod2.z.object({
|
|
110
113
|
type: import_zod2.z.string().default(""),
|
package/dist/utils.js
CHANGED
|
@@ -61,12 +61,14 @@ var REGEX_START_TAG = new RegExp(/^(\w+-\d+)/);
|
|
|
61
61
|
var REGEX_SLASH_NUM = new RegExp(/\/(\d+)/);
|
|
62
62
|
var REGEX_START_NUM = new RegExp(/^(\d+)/);
|
|
63
63
|
var DEFAULT_TYPE_OPTIONS = [
|
|
64
|
-
{ value: "feat", label: "feat" },
|
|
65
|
-
{ value: "fix", label: "fix" },
|
|
66
|
-
{ value: "docs", label: "docs" },
|
|
67
|
-
{ value: "refactor", label: "refactor" },
|
|
68
|
-
{ value: "perf", label: "perf" },
|
|
69
|
-
{ value: "test", label: "test" },
|
|
64
|
+
{ value: "feat", label: "feat", hint: "A new feature" },
|
|
65
|
+
{ value: "fix", label: "fix", hint: "A bug fix" },
|
|
66
|
+
{ value: "docs", label: "docs", hint: "Documentation only changes" },
|
|
67
|
+
{ value: "refactor", label: "refactor", hint: "A code change that neither fixes a bug nor adds a feature" },
|
|
68
|
+
{ value: "perf", label: "perf", hint: "A code change that improves performance" },
|
|
69
|
+
{ value: "test", label: "test", hint: "Adding missing tests or correcting existing tests" },
|
|
70
|
+
{ value: "build", label: "build", hint: "Changes that affect the build system or external dependencies" },
|
|
71
|
+
{ value: "ci", label: "ci", hint: "Changes to our CI configuration files and scripts" },
|
|
70
72
|
{ value: "", label: "none" }
|
|
71
73
|
];
|
|
72
74
|
var DEFAULT_SCOPE_OPTIONS = [
|
package/dist/zod-state.js
CHANGED
|
@@ -46,12 +46,14 @@ var REGEX_START_TAG = new RegExp(/^(\w+-\d+)/);
|
|
|
46
46
|
var REGEX_SLASH_NUM = new RegExp(/\/(\d+)/);
|
|
47
47
|
var REGEX_START_NUM = new RegExp(/^(\d+)/);
|
|
48
48
|
var DEFAULT_TYPE_OPTIONS = [
|
|
49
|
-
{ value: "feat", label: "feat" },
|
|
50
|
-
{ value: "fix", label: "fix" },
|
|
51
|
-
{ value: "docs", label: "docs" },
|
|
52
|
-
{ value: "refactor", label: "refactor" },
|
|
53
|
-
{ value: "perf", label: "perf" },
|
|
54
|
-
{ value: "test", label: "test" },
|
|
49
|
+
{ value: "feat", label: "feat", hint: "A new feature" },
|
|
50
|
+
{ value: "fix", label: "fix", hint: "A bug fix" },
|
|
51
|
+
{ value: "docs", label: "docs", hint: "Documentation only changes" },
|
|
52
|
+
{ value: "refactor", label: "refactor", hint: "A code change that neither fixes a bug nor adds a feature" },
|
|
53
|
+
{ value: "perf", label: "perf", hint: "A code change that improves performance" },
|
|
54
|
+
{ value: "test", label: "test", hint: "Adding missing tests or correcting existing tests" },
|
|
55
|
+
{ value: "build", label: "build", hint: "Changes that affect the build system or external dependencies" },
|
|
56
|
+
{ value: "ci", label: "ci", hint: "Changes to our CI configuration files and scripts" },
|
|
55
57
|
{ value: "", label: "none" }
|
|
56
58
|
];
|
|
57
59
|
var DEFAULT_SCOPE_OPTIONS = [
|
|
@@ -113,7 +115,8 @@ var Config = import_zod2.z.object({
|
|
|
113
115
|
breaking_change: import_zod2.z.object({
|
|
114
116
|
add_exclamation_to_title: import_zod2.z.boolean().default(true)
|
|
115
117
|
}).default({}),
|
|
116
|
-
confirm_commit: import_zod2.z.boolean().default(true)
|
|
118
|
+
confirm_commit: import_zod2.z.boolean().default(true),
|
|
119
|
+
print_commit_output: import_zod2.z.boolean().default(true)
|
|
117
120
|
}).default({});
|
|
118
121
|
var CommitState = import_zod2.z.object({
|
|
119
122
|
type: 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.0.
|
|
4
|
+
"version": "1.0.8-print-output",
|
|
5
5
|
"description": "A CLI for creating better commits following the conventional commit guidelines",
|
|
6
6
|
"author": "Erik Verduin (https://github.com/everduin94)",
|
|
7
7
|
"keywords": [
|
package/readme.md
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Better Commits
|
|
2
2
|
|
|
3
|
-
](https://www.npmjs.com/package/better-commits)
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
[](https://github.com/Everduin94/better-commits)
|
|
4
|
+
[](https://www.npmjs.com/package/better-commits)
|
|
5
|
+
<a href="https://github.com/everduin94/better-commits/issues">
|
|
6
|
+
<img alt="Issues" src="https://img.shields.io/github/issues/everduin94/better-commits?style=for-the-badge&logo=gitbook&color=cba6f7&logoColor=D9E0EE&labelColor=302D41"></a>
|
|
7
7
|
|
|
8
8
|
A CLI for writing better commits, following the conventional commit guidelines, written with Typescript | ZOD | Clack
|
|
9
9
|
|
|
10
|
-
https://user-images.githubusercontent.com/14320878/
|
|
10
|
+
https://user-images.githubusercontent.com/14320878/225088948-43073a0e-400c-4c5f-a6e3-4f4961cfe43d.mov
|
|
11
11
|
|
|
12
12
|
## ✨ Features
|
|
13
13
|
- Follows the conventional commit guidelines
|
|
@@ -43,12 +43,17 @@ To modify, these prompts, see `configuration`.
|
|
|
43
43
|
|
|
44
44
|
## ⚙️ Configuration
|
|
45
45
|
|
|
46
|
-
|
|
46
|
+
|
|
47
|
+
### Global
|
|
48
|
+
|
|
49
|
+
Your first time running `better-commits`, a default config will be generated in your `$HOME` directory, named `.better-commits.json`
|
|
50
|
+
- This config will be used if a repository-specific config cannot be found.
|
|
51
|
+
|
|
52
|
+
### Repository
|
|
47
53
|
|
|
48
54
|
To create a **repository-specific config**, navigate to the root of your project.
|
|
49
55
|
- run `better-commits-init`
|
|
50
|
-
|
|
51
|
-
This will create a config named `.better-commits.json` with all of the defaults. From there, you can modify it to suit your needs.
|
|
56
|
+
- This will create a default config named `.better-commits.json`
|
|
52
57
|
|
|
53
58
|
All properties are optional, they can be removed from your configuration and will be replaced by the defaults at run-time.
|
|
54
59
|
|
|
@@ -64,27 +69,43 @@ All properties are optional, they can be removed from your configuration and wil
|
|
|
64
69
|
"options": [
|
|
65
70
|
{
|
|
66
71
|
"value": "feat",
|
|
67
|
-
"label": "feat"
|
|
72
|
+
"label": "feat",
|
|
73
|
+
"hint": "A new feature"
|
|
68
74
|
},
|
|
69
75
|
{
|
|
70
76
|
"value": "fix",
|
|
71
|
-
"label": "fix"
|
|
77
|
+
"label": "fix",
|
|
78
|
+
"hint": "A bug fix"
|
|
72
79
|
},
|
|
73
80
|
{
|
|
74
81
|
"value": "docs",
|
|
75
|
-
"label": "docs"
|
|
82
|
+
"label": "docs",
|
|
83
|
+
"hint": "Documentation only changes"
|
|
76
84
|
},
|
|
77
85
|
{
|
|
78
86
|
"value": "refactor",
|
|
79
|
-
"label": "refactor"
|
|
87
|
+
"label": "refactor",
|
|
88
|
+
"hint": "A code change that neither fixes a bug nor adds a feature"
|
|
80
89
|
},
|
|
81
90
|
{
|
|
82
91
|
"value": "perf",
|
|
83
|
-
"label": "perf"
|
|
92
|
+
"label": "perf",
|
|
93
|
+
"hint": "A code change that improves performance"
|
|
84
94
|
},
|
|
85
95
|
{
|
|
86
96
|
"value": "test",
|
|
87
|
-
"label": "test"
|
|
97
|
+
"label": "test",
|
|
98
|
+
"hint": "Adding missing tests or correcting existing tests"
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
"value": "build",
|
|
102
|
+
"label": "build",
|
|
103
|
+
"hint": "Changes that affect the build system or external dependencies"
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
"value": "ci",
|
|
107
|
+
"label": "ci",
|
|
108
|
+
"hint": "Changes to our CI configuration files and scripts"
|
|
88
109
|
},
|
|
89
110
|
{
|
|
90
111
|
"value": "",
|
|
@@ -137,13 +158,15 @@ All properties are optional, they can be removed from your configuration and wil
|
|
|
137
158
|
"options": [
|
|
138
159
|
"closes",
|
|
139
160
|
"breaking-change",
|
|
140
|
-
"deprecated"
|
|
161
|
+
"deprecated",
|
|
162
|
+
"custom"
|
|
141
163
|
]
|
|
142
164
|
},
|
|
143
165
|
"breaking_change": {
|
|
144
166
|
"add_exclamation_to_title": true
|
|
145
167
|
},
|
|
146
|
-
"confirm_commit": true
|
|
168
|
+
"confirm_commit": true,
|
|
169
|
+
"print_commit_output": true
|
|
147
170
|
}
|
|
148
171
|
```
|
|
149
172
|
|
|
@@ -159,6 +182,8 @@ To simplify the CLI, some rules are enforced at runtime to make sure the program
|
|
|
159
182
|
- `commit_footer` options are supplied from a fixed list, because they have specific functionality
|
|
160
183
|
- thus, you can remove from that list, but you can't add custom values to it
|
|
161
184
|
|
|
185
|
+
TODO: Add table explaining properties
|
|
186
|
+
|
|
162
187
|
#### 🔎 Inference
|
|
163
188
|
|
|
164
189
|
`better-commits` will attempt to infer the ticket/issue and the type from your branch name. It will auto populate the corresponding field if found.
|
|
@@ -186,6 +211,14 @@ To simplify the CLI, some rules are enforced at runtime to make sure the program
|
|
|
186
211
|
- 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**
|
|
187
212
|
- [better-commits](https://packagephobia.com/result?p=better-commits) is much smaller than its alternative [commitizen](https://packagephobia.com/result?p=commitizen)
|
|
188
213
|
- `better-commits` uses native `git` commands under the hood. So any hooks, tools, or staging should work as if it was a normal commit.
|
|
214
|
+
- You can add this badge to your repository to display that you're using a better-commits repository config
|
|
215
|
+
```
|
|
216
|
+
[](https://github.com/Everduin94/better-commits)
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
[](https://github.com/Everduin94/better-commits)
|
|
220
|
+
|
|
221
|
+
|
|
189
222
|
|
|
190
223
|
## ❓ Troubleshooting
|
|
191
224
|
|
package/src/index.ts
CHANGED
|
@@ -13,7 +13,6 @@ import { CONFIG_FILE_NAME, get_default_config_path, check_missing_stage, addNewL
|
|
|
13
13
|
main(load_setup());
|
|
14
14
|
|
|
15
15
|
function load_setup(): z.infer<typeof Config> {
|
|
16
|
-
|
|
17
16
|
console.clear();
|
|
18
17
|
p.intro(`${color.bgCyan(color.black(' better-commits '))}`);
|
|
19
18
|
|
|
@@ -34,7 +33,6 @@ function load_setup(): z.infer<typeof Config> {
|
|
|
34
33
|
p.log.step('Config not found. Generating default .better-commit.json at $HOME')
|
|
35
34
|
fs.writeFileSync(home_path, JSON.stringify(default_config, null, '\t'));
|
|
36
35
|
return default_config;
|
|
37
|
-
|
|
38
36
|
}
|
|
39
37
|
|
|
40
38
|
function read_config_from_path(config_path: string) {
|
|
@@ -102,7 +100,7 @@ async function main(config: z.infer<typeof Config>) {
|
|
|
102
100
|
initialValue: initial_value,
|
|
103
101
|
options: config.commit_type.options,
|
|
104
102
|
}
|
|
105
|
-
)
|
|
103
|
+
)
|
|
106
104
|
if (p.isCancel(commit_type)) process.exit(0)
|
|
107
105
|
commit_state.type = commit_type;
|
|
108
106
|
}
|
|
@@ -112,7 +110,7 @@ async function main(config: z.infer<typeof Config>) {
|
|
|
112
110
|
message: 'Select a commit scope',
|
|
113
111
|
initialValue: config.commit_scope.initial_value,
|
|
114
112
|
options: config.commit_scope.options
|
|
115
|
-
})
|
|
113
|
+
})
|
|
116
114
|
if (p.isCancel(commit_scope)) process.exit(0)
|
|
117
115
|
commit_state.scope = commit_scope;
|
|
118
116
|
}
|
|
@@ -130,14 +128,14 @@ async function main(config: z.infer<typeof Config>) {
|
|
|
130
128
|
// Can't find branch, fail silently
|
|
131
129
|
}
|
|
132
130
|
}
|
|
131
|
+
|
|
133
132
|
if (config.check_ticket.confirm_ticket) {
|
|
134
133
|
const user_commit_ticket = await p.text({
|
|
135
|
-
message: commit_state.ticket ? `Ticket / issue
|
|
134
|
+
message: commit_state.ticket ? `Ticket / issue inferred from branch ${color.dim('(confirm / edit)')}`: `Add ticket / issue ${OPTIONAL_PROMPT}`,
|
|
135
|
+
placeholder: '',
|
|
136
136
|
initialValue: commit_state.ticket,
|
|
137
|
-
})
|
|
137
|
+
})
|
|
138
138
|
if (p.isCancel(user_commit_ticket)) process.exit(0)
|
|
139
|
-
// TODO: Symbol can be null. Would be ideal if it just returned empty string.
|
|
140
|
-
// Seems like a bug that it only returns undefined if previously set.
|
|
141
139
|
commit_state.ticket = user_commit_ticket ?? '';
|
|
142
140
|
}
|
|
143
141
|
|
|
@@ -154,8 +152,7 @@ async function main(config: z.infer<typeof Config>) {
|
|
|
154
152
|
},
|
|
155
153
|
|
|
156
154
|
}
|
|
157
|
-
)
|
|
158
|
-
|
|
155
|
+
)
|
|
159
156
|
if (p.isCancel(commit_title)) process.exit(0)
|
|
160
157
|
commit_state.title = clean_commit_title(commit_title);
|
|
161
158
|
|
|
@@ -167,9 +164,9 @@ async function main(config: z.infer<typeof Config>) {
|
|
|
167
164
|
if (config.commit_body.required && !val) return 'Please enter a description'
|
|
168
165
|
}
|
|
169
166
|
|
|
170
|
-
})
|
|
167
|
+
})
|
|
171
168
|
if (p.isCancel(commit_body)) process.exit(0)
|
|
172
|
-
commit_state.body = commit_body;
|
|
169
|
+
commit_state.body = commit_body ?? '';
|
|
173
170
|
}
|
|
174
171
|
|
|
175
172
|
if (config.commit_footer.enable) {
|
|
@@ -188,11 +185,13 @@ async function main(config: z.infer<typeof Config>) {
|
|
|
188
185
|
validate: (value) => {
|
|
189
186
|
if (!value) return 'Please enter a title / summary'
|
|
190
187
|
}
|
|
191
|
-
})
|
|
188
|
+
})
|
|
189
|
+
if (p.isCancel(breaking_changes_title)) process.exit(0)
|
|
192
190
|
const breaking_changes_body = await p.text({
|
|
193
191
|
message: `Breaking Changes: Write a description & migration instructions ${OPTIONAL_PROMPT}`,
|
|
194
192
|
placeholder: '',
|
|
195
|
-
})
|
|
193
|
+
})
|
|
194
|
+
if (p.isCancel(breaking_changes_body)) process.exit(0)
|
|
196
195
|
commit_state.breaking_title = breaking_changes_title;
|
|
197
196
|
commit_state.breaking_body = breaking_changes_body;
|
|
198
197
|
}
|
|
@@ -204,11 +203,13 @@ async function main(config: z.infer<typeof Config>) {
|
|
|
204
203
|
validate: (value) => {
|
|
205
204
|
if (!value) return 'Please enter a title / summary'
|
|
206
205
|
}
|
|
207
|
-
})
|
|
206
|
+
})
|
|
207
|
+
if (p.isCancel(deprecated_title)) process.exit(0)
|
|
208
208
|
const deprecated_body = await p.text({
|
|
209
209
|
message: `Deprecated: Write a description ${OPTIONAL_PROMPT}`,
|
|
210
210
|
placeholder: '',
|
|
211
|
-
})
|
|
211
|
+
})
|
|
212
|
+
if (p.isCancel(deprecated_body)) process.exit(0)
|
|
212
213
|
commit_state.deprecates_body = deprecated_body;
|
|
213
214
|
commit_state.deprecates_title = deprecated_title;
|
|
214
215
|
}
|
|
@@ -221,7 +222,8 @@ async function main(config: z.infer<typeof Config>) {
|
|
|
221
222
|
const custom_footer = await p.text({
|
|
222
223
|
message: 'Write a custom footer',
|
|
223
224
|
placeholder: '',
|
|
224
|
-
})
|
|
225
|
+
})
|
|
226
|
+
if (p.isCancel(custom_footer)) process.exit(0)
|
|
225
227
|
commit_state.custom_footer = custom_footer;
|
|
226
228
|
}
|
|
227
229
|
}
|
|
@@ -234,7 +236,17 @@ async function main(config: z.infer<typeof Config>) {
|
|
|
234
236
|
if (p.isCancel(continue_commit)) process.exit(0)
|
|
235
237
|
}
|
|
236
238
|
|
|
237
|
-
if (continue_commit)
|
|
239
|
+
if (!continue_commit) {
|
|
240
|
+
p.log.info('Exiting without commit')
|
|
241
|
+
process.exit(0)
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
try {
|
|
245
|
+
const output = execSync(`git commit -m "${build_commit_string(commit_state, config, false)}"`).toString().trim();
|
|
246
|
+
if (config.print_commit_output) p.log.info(output)
|
|
247
|
+
} catch(err) {
|
|
248
|
+
p.log.error('Something went wrong when committing: ' + err)
|
|
249
|
+
}
|
|
238
250
|
}
|
|
239
251
|
|
|
240
252
|
function build_commit_string(commit_state: z.infer<typeof CommitState>, config: z.infer<typeof Config>, colorize: boolean = false): string {
|
|
@@ -300,7 +312,6 @@ function build_commit_string(commit_state: z.infer<typeof CommitState>, config:
|
|
|
300
312
|
commit_string += colorize ? `\n\n${color.reset(commit_state.closes)} ${color.magenta(commit_state.ticket)}` : `\n\n${commit_state.closes} ${commit_state.ticket}`;
|
|
301
313
|
}
|
|
302
314
|
|
|
303
|
-
|
|
304
315
|
return commit_string;
|
|
305
316
|
}
|
|
306
317
|
|
package/src/utils.ts
CHANGED
|
@@ -12,12 +12,14 @@ export const REGEX_START_TAG = new RegExp(/^(\w+-\d+)/)
|
|
|
12
12
|
export const REGEX_SLASH_NUM = new RegExp(/\/(\d+)/)
|
|
13
13
|
export const REGEX_START_NUM = new RegExp(/^(\d+)/)
|
|
14
14
|
export const DEFAULT_TYPE_OPTIONS = [
|
|
15
|
-
{ value: 'feat', label: 'feat' },
|
|
16
|
-
{ value: 'fix', label: 'fix' },
|
|
17
|
-
{ value: 'docs', label: 'docs'},
|
|
18
|
-
{ value: 'refactor', label: 'refactor'},
|
|
19
|
-
{ value: 'perf', label: 'perf'},
|
|
20
|
-
{ value: 'test', label: 'test'},
|
|
15
|
+
{ value: 'feat', label: 'feat' , hint: 'A new feature'},
|
|
16
|
+
{ value: 'fix', label: 'fix' , hint: 'A bug fix'},
|
|
17
|
+
{ value: 'docs', label: 'docs', hint: 'Documentation only changes'},
|
|
18
|
+
{ value: 'refactor', label: 'refactor', hint: 'A code change that neither fixes a bug nor adds a feature'},
|
|
19
|
+
{ value: 'perf', label: 'perf', hint: 'A code change that improves performance'},
|
|
20
|
+
{ value: 'test', label: 'test', hint: 'Adding missing tests or correcting existing tests'},
|
|
21
|
+
{ value: 'build', label: 'build', hint: 'Changes that affect the build system or external dependencies'},
|
|
22
|
+
{ value: 'ci', label: 'ci', hint: 'Changes to our CI configuration files and scripts'},
|
|
21
23
|
{ value: '', label: 'none'},
|
|
22
24
|
]
|
|
23
25
|
export const DEFAULT_SCOPE_OPTIONS = [
|
package/src/zod-state.ts
CHANGED
|
@@ -51,7 +51,8 @@ export const Config = z.object({
|
|
|
51
51
|
breaking_change: z.object({
|
|
52
52
|
add_exclamation_to_title: z.boolean().default(true)
|
|
53
53
|
}).default({}),
|
|
54
|
-
confirm_commit: z.boolean().default(true)
|
|
54
|
+
confirm_commit: z.boolean().default(true),
|
|
55
|
+
print_commit_output: z.boolean().default(true)
|
|
55
56
|
}).default({})
|
|
56
57
|
|
|
57
58
|
export const CommitState = z.object({
|