better-commits 1.3.0 → 1.4.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.
@@ -23,6 +23,10 @@
23
23
  "value": "util",
24
24
  "label": "util"
25
25
  },
26
+ {
27
+ "value": "build",
28
+ "label": "build"
29
+ },
26
30
  {
27
31
  "value": "",
28
32
  "label": "none"
@@ -31,5 +35,6 @@
31
35
  },
32
36
  "check_ticket": {
33
37
  "append_hashtag": true
34
- }
38
+ },
39
+ "branch_pre_commands": ["git checkout main", "git pull -r origin main", "npm install"]
35
40
  }
package/dist/branch.js CHANGED
@@ -181,13 +181,16 @@ var Config = import_zod2.z.object({
181
181
  branch_pre_commands: import_zod2.z.array(import_zod2.z.string()).default([]),
182
182
  branch_post_commands: import_zod2.z.array(import_zod2.z.string()).default([]),
183
183
  branch_user: import_zod2.z.object({
184
+ enable: import_zod2.z.boolean().default(true),
184
185
  required: import_zod2.z.boolean().default(false),
185
186
  separator: import_zod2.z.enum(["/", "-", "_"]).default("/")
186
187
  }).default({}),
187
188
  branch_type: import_zod2.z.object({
189
+ enable: import_zod2.z.boolean().default(true),
188
190
  separator: import_zod2.z.enum(["/", "-", "_"]).default("/")
189
191
  }).default({}),
190
192
  branch_ticket: import_zod2.z.object({
193
+ enable: import_zod2.z.boolean().default(true),
191
194
  required: import_zod2.z.boolean().default(false),
192
195
  separator: import_zod2.z.enum(["/", "-", "_"]).default("-")
193
196
  }).default({}),
@@ -224,26 +227,28 @@ var import_child_process2 = require("child_process");
224
227
  main(load_setup(" better-branch "));
225
228
  async function main(config) {
226
229
  const branch_state = BranchState.parse({});
227
- const cache_user_name = get_user_from_cache();
228
- const user_name_required = config.branch_user.required;
229
- const user_name = await p2.text({
230
- message: `Type your git username ${user_name_required ? "" : OPTIONAL_PROMPT} ${CACHE_PROMPT}`.trim(),
231
- placeholder: "",
232
- initialValue: cache_user_name,
233
- validate: (val) => {
234
- if (user_name_required && !val)
235
- return "Please enter a username";
236
- }
237
- });
238
- if (p2.isCancel(user_name))
239
- process.exit(0);
240
- branch_state.user = user_name?.replace(/\s+/g, "-")?.toLowerCase() ?? "";
241
- set_user_cache(branch_state.user);
242
- if (config.commit_type.enable) {
230
+ if (config.branch_user.enable) {
231
+ const cache_user_name = get_user_from_cache();
232
+ const user_name_required = config.branch_user.required;
233
+ const user_name = await p2.text({
234
+ message: `Type your git username ${user_name_required ? "" : OPTIONAL_PROMPT} ${CACHE_PROMPT}`.trim(),
235
+ placeholder: "",
236
+ initialValue: cache_user_name,
237
+ validate: (val) => {
238
+ if (user_name_required && !val)
239
+ return "Please enter a username";
240
+ }
241
+ });
242
+ if (p2.isCancel(user_name))
243
+ process.exit(0);
244
+ branch_state.user = user_name?.replace(/\s+/g, "-")?.toLowerCase() ?? "";
245
+ set_user_cache(branch_state.user);
246
+ }
247
+ if (config.branch_type.enable) {
243
248
  let initial_value = config.commit_type.initial_value;
244
249
  const commit_type = await p2.select(
245
250
  {
246
- message: `Select a commit type`,
251
+ message: `Select a branch type`,
247
252
  initialValue: initial_value,
248
253
  options: config.commit_type.options
249
254
  }
@@ -252,18 +257,20 @@ async function main(config) {
252
257
  process.exit(0);
253
258
  branch_state.type = commit_type;
254
259
  }
255
- const ticked_required = config.branch_ticket.required;
256
- const ticket = await p2.text({
257
- message: `Type ticket / issue number ${ticked_required ? "" : OPTIONAL_PROMPT}`.trim(),
258
- placeholder: "",
259
- validate: (val) => {
260
- if (ticked_required && !val)
261
- return "Please enter a ticket / issue";
262
- }
263
- });
264
- if (p2.isCancel(ticket))
265
- process.exit(0);
266
- branch_state.ticket = ticket;
260
+ if (config.branch_ticket.enable) {
261
+ const ticked_required = config.branch_ticket.required;
262
+ const ticket = await p2.text({
263
+ message: `Type ticket / issue number ${ticked_required ? "" : OPTIONAL_PROMPT}`.trim(),
264
+ placeholder: "",
265
+ validate: (val) => {
266
+ if (ticked_required && !val)
267
+ return "Please enter a ticket / issue";
268
+ }
269
+ });
270
+ if (p2.isCancel(ticket))
271
+ process.exit(0);
272
+ branch_state.ticket = ticket;
273
+ }
267
274
  const description_max_length = config.branch_description.max_length;
268
275
  const description = await p2.text({
269
276
  message: "Type a short description",
package/dist/index.js CHANGED
@@ -233,13 +233,16 @@ var Config = import_zod2.z.object({
233
233
  branch_pre_commands: import_zod2.z.array(import_zod2.z.string()).default([]),
234
234
  branch_post_commands: import_zod2.z.array(import_zod2.z.string()).default([]),
235
235
  branch_user: import_zod2.z.object({
236
+ enable: import_zod2.z.boolean().default(true),
236
237
  required: import_zod2.z.boolean().default(false),
237
238
  separator: import_zod2.z.enum(["/", "-", "_"]).default("/")
238
239
  }).default({}),
239
240
  branch_type: import_zod2.z.object({
241
+ enable: import_zod2.z.boolean().default(true),
240
242
  separator: import_zod2.z.enum(["/", "-", "_"]).default("/")
241
243
  }).default({}),
242
244
  branch_ticket: import_zod2.z.object({
245
+ enable: import_zod2.z.boolean().default(true),
243
246
  required: import_zod2.z.boolean().default(false),
244
247
  separator: import_zod2.z.enum(["/", "-", "_"]).default("-")
245
248
  }).default({}),
package/dist/init.js CHANGED
@@ -139,13 +139,16 @@ var Config = import_zod2.z.object({
139
139
  branch_pre_commands: import_zod2.z.array(import_zod2.z.string()).default([]),
140
140
  branch_post_commands: import_zod2.z.array(import_zod2.z.string()).default([]),
141
141
  branch_user: import_zod2.z.object({
142
+ enable: import_zod2.z.boolean().default(true),
142
143
  required: import_zod2.z.boolean().default(false),
143
144
  separator: import_zod2.z.enum(["/", "-", "_"]).default("/")
144
145
  }).default({}),
145
146
  branch_type: import_zod2.z.object({
147
+ enable: import_zod2.z.boolean().default(true),
146
148
  separator: import_zod2.z.enum(["/", "-", "_"]).default("/")
147
149
  }).default({}),
148
150
  branch_ticket: import_zod2.z.object({
151
+ enable: import_zod2.z.boolean().default(true),
149
152
  required: import_zod2.z.boolean().default(false),
150
153
  separator: import_zod2.z.enum(["/", "-", "_"]).default("-")
151
154
  }).default({}),
package/dist/utils.js CHANGED
@@ -135,13 +135,16 @@ var Config = import_zod.z.object({
135
135
  branch_pre_commands: import_zod.z.array(import_zod.z.string()).default([]),
136
136
  branch_post_commands: import_zod.z.array(import_zod.z.string()).default([]),
137
137
  branch_user: import_zod.z.object({
138
+ enable: import_zod.z.boolean().default(true),
138
139
  required: import_zod.z.boolean().default(false),
139
140
  separator: import_zod.z.enum(["/", "-", "_"]).default("/")
140
141
  }).default({}),
141
142
  branch_type: import_zod.z.object({
143
+ enable: import_zod.z.boolean().default(true),
142
144
  separator: import_zod.z.enum(["/", "-", "_"]).default("/")
143
145
  }).default({}),
144
146
  branch_ticket: import_zod.z.object({
147
+ enable: import_zod.z.boolean().default(true),
145
148
  required: import_zod.z.boolean().default(false),
146
149
  separator: import_zod.z.enum(["/", "-", "_"]).default("-")
147
150
  }).default({}),
package/dist/zod-state.js CHANGED
@@ -145,13 +145,16 @@ var Config = import_zod2.z.object({
145
145
  branch_pre_commands: import_zod2.z.array(import_zod2.z.string()).default([]),
146
146
  branch_post_commands: import_zod2.z.array(import_zod2.z.string()).default([]),
147
147
  branch_user: import_zod2.z.object({
148
+ enable: import_zod2.z.boolean().default(true),
148
149
  required: import_zod2.z.boolean().default(false),
149
150
  separator: import_zod2.z.enum(["/", "-", "_"]).default("/")
150
151
  }).default({}),
151
152
  branch_type: import_zod2.z.object({
153
+ enable: import_zod2.z.boolean().default(true),
152
154
  separator: import_zod2.z.enum(["/", "-", "_"]).default("/")
153
155
  }).default({}),
154
156
  branch_ticket: import_zod2.z.object({
157
+ enable: import_zod2.z.boolean().default(true),
155
158
  required: import_zod2.z.boolean().default(false),
156
159
  separator: import_zod2.z.enum(["/", "-", "_"]).default("-")
157
160
  }).default({}),
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "better-commits",
3
3
  "private": false,
4
- "version": "1.3.0",
4
+ "version": "1.4.0",
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
@@ -189,13 +189,16 @@ All properties are optional, they can be removed from your configuration and wil
189
189
  "branch_pre_commands": [],
190
190
  "branch_post_commands": [],
191
191
  "branch_user": {
192
+ "enable": true,
192
193
  "required": false,
193
194
  "separator": "/"
194
195
  },
195
196
  "branch_type": {
197
+ "enable": true,
196
198
  "separator": "/"
197
199
  },
198
200
  "branch_ticket": {
201
+ "enable": true,
199
202
  "required": false,
200
203
  "separator": "-"
201
204
  },
package/src/branch.ts CHANGED
@@ -13,25 +13,28 @@ main(load_setup(' better-branch '))
13
13
 
14
14
  async function main(config: z.infer<typeof Config>) {
15
15
  const branch_state = BranchState.parse({});
16
- const cache_user_name = get_user_from_cache()
17
- const user_name_required = config.branch_user.required
18
- const user_name = await p.text({
19
- message: `Type your git username ${user_name_required ? '' : OPTIONAL_PROMPT} ${CACHE_PROMPT}`.trim(),
20
- placeholder: '',
21
- initialValue: cache_user_name,
22
- validate: (val) => {
23
- if (user_name_required && !val) return 'Please enter a username'
24
- }
25
- })
26
- if (p.isCancel(user_name)) process.exit(0)
27
- branch_state.user = user_name?.replace(/\s+/g, '-')?.toLowerCase() ?? '';
28
- set_user_cache(branch_state.user)
29
16
 
30
- if (config.commit_type.enable) {
17
+ if (config.branch_user.enable) {
18
+ const cache_user_name = get_user_from_cache()
19
+ const user_name_required = config.branch_user.required
20
+ const user_name = await p.text({
21
+ message: `Type your git username ${user_name_required ? '' : OPTIONAL_PROMPT} ${CACHE_PROMPT}`.trim(),
22
+ placeholder: '',
23
+ initialValue: cache_user_name,
24
+ validate: (val) => {
25
+ if (user_name_required && !val) return 'Please enter a username'
26
+ }
27
+ })
28
+ if (p.isCancel(user_name)) process.exit(0)
29
+ branch_state.user = user_name?.replace(/\s+/g, '-')?.toLowerCase() ?? '';
30
+ set_user_cache(branch_state.user)
31
+ }
32
+
33
+ if (config.branch_type.enable) {
31
34
  let initial_value = config.commit_type.initial_value
32
35
  const commit_type = await p.select(
33
36
  {
34
- message: `Select a commit type`,
37
+ message: `Select a branch type`,
35
38
  initialValue: initial_value,
36
39
  options: config.commit_type.options,
37
40
  }
@@ -40,17 +43,19 @@ async function main(config: z.infer<typeof Config>) {
40
43
  branch_state.type = commit_type;
41
44
  }
42
45
 
43
- const ticked_required = config.branch_ticket.required
44
- const ticket = await p.text({
45
- message: `Type ticket / issue number ${ticked_required ? '' : OPTIONAL_PROMPT}`.trim(),
46
- placeholder: '',
47
- validate: (val) => {
48
- if (ticked_required && !val) return 'Please enter a ticket / issue'
49
- }
50
- })
51
- if (p.isCancel(ticket)) process.exit(0)
52
- branch_state.ticket = ticket;
53
-
46
+ if (config.branch_ticket.enable) {
47
+ const ticked_required = config.branch_ticket.required
48
+ const ticket = await p.text({
49
+ message: `Type ticket / issue number ${ticked_required ? '' : OPTIONAL_PROMPT}`.trim(),
50
+ placeholder: '',
51
+ validate: (val) => {
52
+ if (ticked_required && !val) return 'Please enter a ticket / issue'
53
+ }
54
+ })
55
+ if (p.isCancel(ticket)) process.exit(0)
56
+ branch_state.ticket = ticket;
57
+ }
58
+
54
59
 
55
60
  const description_max_length = config.branch_description.max_length
56
61
  const description = await p.text({
package/src/zod-state.ts CHANGED
@@ -75,13 +75,16 @@ export const Config = z.object({
75
75
  branch_pre_commands: z.array(z.string()).default([]),
76
76
  branch_post_commands: z.array(z.string()).default([]),
77
77
  branch_user: z.object({
78
+ enable: z.boolean().default(true),
78
79
  required: z.boolean().default(false),
79
80
  separator: z.enum(['/', '-', '_']).default('/')
80
81
  }).default({}),
81
82
  branch_type: z.object({
83
+ enable: z.boolean().default(true),
82
84
  separator: z.enum(['/', '-', '_']).default('/')
83
85
  }).default({}),
84
86
  branch_ticket: z.object({
87
+ enable: z.boolean().default(true),
85
88
  required: z.boolean().default(false),
86
89
  separator: z.enum(['/', '-', '_']).default('-')
87
90
  }).default({}),