Skip to content

Commit 37ec41a

Browse files
🎉 Feat(default.ts): add additioan stage/question about breaking changes
1 parent 5e7d1db commit 37ec41a

File tree

5 files changed

+23
-4
lines changed

5 files changed

+23
-4
lines changed

Diff for: CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# commitsmile
22

3+
## 0.5.0
4+
5+
### Minor Changes
6+
7+
- FEAT: Add Breaking Changes stage in commiting.
8+
39
## 0.4.0
410

511
### Minor Changes

Diff for: package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "commitsmile",
3-
"version": "0.4.0",
3+
"version": "0.5.0",
44
"description": "Make smile on your commits",
55
"keywords": [],
66
"homepage": "",

Diff for: src/cli/default.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,15 @@ program
2222
{
2323
changes: async () => select(config.CHANGES),
2424
scopes: async () => select(config.SCOPES),
25+
breakingChanges: async () => prompter.confirm(config.BREAKING_CHANGES),
2526
commitShort: async () => prompter.text(config.COMMIT_SHORT),
2627
commitDescription: async () => prompter.text(config.COMMIT_DESCRIPTION),
2728
commit: async ({ results }) => {
28-
const { changes, scopes, commitShort } = results;
29+
const { changes, scopes, commitShort, breakingChanges } = results;
2930
const commit = (): string => {
3031
const scopesFormat = scopes ? `(${scopes})` : "";
31-
return `${changes}${scopesFormat}: ${commitShort}`;
32+
const breakingChangesFormat = breakingChanges ? "!" : "";
33+
return `${changes}${scopesFormat}${breakingChangesFormat}: ${commitShort}`;
3234
};
3335
prompter.note(commit());
3436
let agree = await prompter.confirm({ message: "Commit message is correct?" });

Diff for: src/defaultConfig.ts

+6
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,12 @@ export const defaultConfig: z.infer<typeof configSchema> = {
7070
{ label: "🍃 API", value: "api" }
7171
]
7272
},
73+
BREAKING_CHANGES: {
74+
message: "Are there any breaking changes?",
75+
active: "Yes",
76+
inactive: "No",
77+
initialValue: false
78+
},
7379
COMMIT_SHORT: {
7480
message: "Write short description of commit",
7581
validate(input: string) {

Diff for: src/utils/types.ts

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
import defaultConfig from "@/defaultConfig";
2-
import type { multiselect, text } from "@clack/prompts";
2+
import type { multiselect, text, confirm } from "@clack/prompts";
33
import z from "zod";
44

55
export type flatMultipleClack = FlatArray<Parameters<typeof multiselect>, 0>;
66

77
const flatMultipleClackZod = z.custom<flatMultipleClack>(() => true);
88

9+
export type TConfirmFlat = FlatArray<Parameters<typeof confirm>, 0>;
10+
export const TConfirmScheme = z.custom<TConfirmFlat>(() => true);
11+
912
export const TSelectScheme = z
1013
.object({
1114
custom: z.object({
@@ -30,13 +33,15 @@ export type TStages = "CHANGES" | "COMMIT_DESCRIPTION" | "COMMIT_SHORT" | "SCOPE
3033
export const configSchema = z.object({
3134
CHANGES: TSelectScheme,
3235
SCOPES: TSelectScheme,
36+
BREAKING_CHANGES: TConfirmScheme,
3337
COMMIT_SHORT: TOptionTextZod,
3438
COMMIT_DESCRIPTION: TOptionTextZod
3539
}) satisfies TStagesZod;
3640

3741
export const UserConfigSchema = z.object({
3842
CHANGES: TSelectScheme.default(defaultConfig.CHANGES),
3943
SCOPES: TSelectScheme.default(defaultConfig.SCOPES),
44+
BREAKING_CHANGES: TConfirmScheme.default(defaultConfig.BREAKING_CHANGES),
4045
COMMIT_SHORT: TOptionTextZod.default(defaultConfig.COMMIT_SHORT),
4146
COMMIT_DESCRIPTION: TOptionTextZod.default(defaultConfig.COMMIT_DESCRIPTION)
4247
});

0 commit comments

Comments
 (0)