better-commits 1.0.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.
@@ -0,0 +1,67 @@
1
+ import { z } from "zod"
2
+ import { DEFAULT_SCOPE_OPTIONS, DEFAULT_TYPE_OPTIONS, FOOTER_OPTION_VALUES, Z_FOOTER_OPTIONS } from "./utils"
3
+
4
+ // TODO: add "Ref", "Fixes", ability to change phrase "Closes/closes/closes:"
5
+ export const Config = z.object({
6
+ check_status: z.boolean().default(true),
7
+ commit_type: z.object({
8
+ enable: z.boolean().default(true),
9
+ initial_value: z.string().default('feat'),
10
+ options: z.array(z.object({
11
+ value: z.string(),
12
+ label: z.string().optional(),
13
+ hint: z.string().optional(),
14
+ })).default(DEFAULT_TYPE_OPTIONS)
15
+ }).default({}).refine(val => {
16
+ const options = val.options.map(v => v.value)
17
+ return options.includes(val.initial_value)
18
+ }, (val) => ({ message: `Type: initial_value "${val.initial_value}" must exist in options` })),
19
+ commit_scope: z.object({
20
+ enable: z.boolean().default(true),
21
+ initial_value: z.string().default('app'),
22
+ options: z.array(z.object({
23
+ value: z.string(),
24
+ label: z.string().optional(),
25
+ hint: z.string().optional(),
26
+ })).default(DEFAULT_SCOPE_OPTIONS)
27
+ }).default({})
28
+ .refine(val => {
29
+ const options = val.options.map(v => v.value)
30
+ return options.includes(val.initial_value)
31
+ }, (val) => ({ message: `Scope: initial_value "${val.initial_value}" must exist in options` })),
32
+ check_ticket: z.object({
33
+ infer_ticket: z.boolean().default(true),
34
+ confirm_ticket: z.boolean().default(true),
35
+ add_to_title: z.boolean().default(true)
36
+ }).default({}),
37
+ commit_title: z.object({
38
+ max_size: z.number().positive().default(70)
39
+ }).default({}),
40
+ commit_body: z.object({
41
+ enable: z.boolean().default(true),
42
+ required: z.boolean().default(false),
43
+ }).default({}),
44
+ commit_footer: z.object({
45
+ enable: z.boolean().default(true),
46
+ initial_value: z.array(Z_FOOTER_OPTIONS).default([]),
47
+ options: z.array(Z_FOOTER_OPTIONS).default(FOOTER_OPTION_VALUES),
48
+ }).default({}),
49
+ breaking_change: z.object({
50
+ add_exclamation_to_title: z.boolean().default(true)
51
+ }).default({}),
52
+ confirm_commit: z.boolean().default(true)
53
+ }).default({})
54
+
55
+ export const CommitState = z.object({
56
+ type: z.string().default(''),
57
+ scope:z.string().default(''),
58
+ title:z.string().default(''),
59
+ body:z.string().default(''),
60
+ closes:z.string().default(''),
61
+ ticket: z.string().default(''),
62
+ breaking_title: z.string().default(''),
63
+ breaking_body: z.string().default(''),
64
+ deprecates: z.string().default(''),
65
+ deprecates_title: z.string().default(''),
66
+ deprecates_body: z.string().default(''),
67
+ }).default({})
package/tsconfig.json ADDED
@@ -0,0 +1,14 @@
1
+ {
2
+ "compilerOptions": {
3
+ "module": "ESNext",
4
+ "target": "ESNext",
5
+ "declaration": true,
6
+ "moduleResolution": "node",
7
+ "emitDeclarationOnly": true,
8
+ "strict": true,
9
+ "esModuleInterop": true,
10
+ "forceConsistentCasingInFileNames": true,
11
+ "allowJs": true,
12
+ "types": ["node"]
13
+ }
14
+ }