better-commits 1.12.0 → 1.14.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.
@@ -34,7 +34,7 @@
34
34
  ]
35
35
  },
36
36
  "check_ticket": {
37
- "append_hashtag": true
37
+ "prepend_hashtag": "Always"
38
38
  },
39
39
  "branch_pre_commands": [
40
40
  "git stash",
package/dist/branch.js CHANGED
@@ -140,17 +140,25 @@ var BRANCH_ACTION_OPTIONS = [
140
140
  function load_setup(cli_name = " better-commits ") {
141
141
  console.clear();
142
142
  p.intro(`${import_picocolors.default.bgCyan(import_picocolors.default.black(cli_name))}`);
143
+ let global_config = null;
144
+ const home_path = get_default_config_path();
145
+ if (import_fs.default.existsSync(home_path)) {
146
+ p.log.step("Found global config");
147
+ global_config = read_config_from_path(home_path);
148
+ }
143
149
  const root = get_git_root();
144
150
  const root_path = `${root}/${CONFIG_FILE_NAME}`;
145
151
  if (import_fs.default.existsSync(root_path)) {
146
152
  p.log.step("Found repository config");
147
- return read_config_from_path(root_path);
148
- }
149
- const home_path = get_default_config_path();
150
- if (import_fs.default.existsSync(home_path)) {
151
- p.log.step("Found global config");
152
- return read_config_from_path(home_path);
153
+ const repo_config = read_config_from_path(root_path);
154
+ return global_config ? {
155
+ ...repo_config,
156
+ overrides: global_config.overrides.shell ? global_config.overrides : repo_config.overrides,
157
+ confirm_with_editor: global_config.confirm_with_editor
158
+ } : repo_config;
153
159
  }
160
+ if (global_config)
161
+ return global_config;
154
162
  const default_config = Config.parse({});
155
163
  p.log.step(
156
164
  "Config not found. Generating default .better-commit.json at $HOME"
@@ -262,6 +270,7 @@ var Config = import_zod2.z.object({
262
270
  confirm_ticket: import_zod2.z.boolean().default(true),
263
271
  add_to_title: import_zod2.z.boolean().default(true),
264
272
  append_hashtag: import_zod2.z.boolean().default(false),
273
+ prepend_hashtag: import_zod2.z.enum(["Never", "Always", "Prompt"]).default("Never"),
265
274
  surround: import_zod2.z.enum(["", "()", "[]", "{}"]).default(""),
266
275
  title_position: import_zod2.z.enum(["start", "end", "before-colon"]).default("start")
267
276
  }).default({}),
package/dist/index.js CHANGED
@@ -171,17 +171,25 @@ var FOOTER_OPTION_VALUES = [
171
171
  function load_setup(cli_name = " better-commits ") {
172
172
  console.clear();
173
173
  p.intro(`${import_picocolors.default.bgCyan(import_picocolors.default.black(cli_name))}`);
174
- const root = get_git_root();
175
- const root_path = `${root}/${CONFIG_FILE_NAME}`;
176
- if (import_fs.default.existsSync(root_path)) {
177
- p.log.step("Found repository config");
178
- return read_config_from_path(root_path);
179
- }
174
+ let global_config = null;
180
175
  const home_path = get_default_config_path();
181
176
  if (import_fs.default.existsSync(home_path)) {
182
177
  p.log.step("Found global config");
183
- return read_config_from_path(home_path);
178
+ global_config = read_config_from_path(home_path);
184
179
  }
180
+ const root = get_git_root();
181
+ const root_path = `${root}/${CONFIG_FILE_NAME}`;
182
+ if (import_fs.default.existsSync(root_path)) {
183
+ p.log.step("Found repository config");
184
+ const repo_config = read_config_from_path(root_path);
185
+ return global_config ? {
186
+ ...repo_config,
187
+ overrides: global_config.overrides.shell ? global_config.overrides : repo_config.overrides,
188
+ confirm_with_editor: global_config.confirm_with_editor
189
+ } : repo_config;
190
+ }
191
+ if (global_config)
192
+ return global_config;
185
193
  const default_config = Config.parse({});
186
194
  p.log.step(
187
195
  "Config not found. Generating default .better-commit.json at $HOME"
@@ -326,6 +334,7 @@ var Config = import_zod2.z.object({
326
334
  confirm_ticket: import_zod2.z.boolean().default(true),
327
335
  add_to_title: import_zod2.z.boolean().default(true),
328
336
  append_hashtag: import_zod2.z.boolean().default(false),
337
+ prepend_hashtag: import_zod2.z.enum(["Never", "Always", "Prompt"]).default("Never"),
329
338
  surround: import_zod2.z.enum(["", "()", "[]", "{}"]).default(""),
330
339
  title_position: import_zod2.z.enum(["start", "end", "before-colon"]).default("start")
331
340
  }).default({}),
@@ -536,7 +545,7 @@ async function main(config) {
536
545
  branch.match(REGEX_START_NUM)
537
546
  ].filter((v) => v != null).map((v) => v && v.length >= 2 ? v[1] : "");
538
547
  if (found.length && found[0]) {
539
- commit_state.ticket = config.check_ticket.append_hashtag ? "#" + found[0] : found[0];
548
+ commit_state.ticket = config.check_ticket.append_hashtag || config.check_ticket.prepend_hashtag === "Prompt" ? "#" + found[0] : found[0];
540
549
  }
541
550
  } catch (err) {
542
551
  }
@@ -551,6 +560,9 @@ async function main(config) {
551
560
  process.exit(0);
552
561
  commit_state.ticket = user_commit_ticket ?? "";
553
562
  }
563
+ if (config.check_ticket.prepend_hashtag === "Always" && commit_state.ticket && !commit_state.ticket.startsWith("#")) {
564
+ commit_state.ticket = "#" + commit_state.ticket;
565
+ }
554
566
  const commit_title = await p3.text(
555
567
  {
556
568
  message: "Write a brief title describing the 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({}),
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({}),
@@ -342,17 +343,25 @@ var BRANCH_ACTION_OPTIONS = [
342
343
  function load_setup(cli_name = " better-commits ") {
343
344
  console.clear();
344
345
  p.intro(`${import_picocolors.default.bgCyan(import_picocolors.default.black(cli_name))}`);
346
+ let global_config = null;
347
+ const home_path = get_default_config_path();
348
+ if (import_fs.default.existsSync(home_path)) {
349
+ p.log.step("Found global config");
350
+ global_config = read_config_from_path(home_path);
351
+ }
345
352
  const root = get_git_root();
346
353
  const root_path = `${root}/${CONFIG_FILE_NAME}`;
347
354
  if (import_fs.default.existsSync(root_path)) {
348
355
  p.log.step("Found repository config");
349
- return read_config_from_path(root_path);
350
- }
351
- const home_path = get_default_config_path();
352
- if (import_fs.default.existsSync(home_path)) {
353
- p.log.step("Found global config");
354
- return read_config_from_path(home_path);
356
+ const repo_config = read_config_from_path(root_path);
357
+ return global_config ? {
358
+ ...repo_config,
359
+ overrides: global_config.overrides.shell ? global_config.overrides : repo_config.overrides,
360
+ confirm_with_editor: global_config.confirm_with_editor
361
+ } : repo_config;
355
362
  }
363
+ if (global_config)
364
+ return global_config;
356
365
  const default_config = Config.parse({});
357
366
  p.log.step(
358
367
  "Config not found. Generating default .better-commit.json at $HOME"
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({}),
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "better-commits",
3
3
  "private": false,
4
- "version": "1.12.0",
4
+ "version": "1.14.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
@@ -65,8 +65,9 @@ Your first time running `better-commits`, a default config will be generated in
65
65
  ### Repository
66
66
 
67
67
  To create a **repository-specific config**, navigate to the root of your project.
68
- - run `better-commits-init`
68
+ - Run `better-commits-init`
69
69
  - This will create a default config named `.better-commits.json`
70
+ - Properties such as `confirm_with_editor` and `overrides` will prefer the global config
70
71
 
71
72
  ### Options
72
73
 
@@ -192,6 +193,7 @@ Better-commits (& better-branch) are highly flexible with sane defaults. These o
192
193
  "confirm_ticket": true,
193
194
  "add_to_title": true,
194
195
  "append_hashtag": false,
196
+ "prepend_hashtag": "Never",
195
197
  "surround": "",
196
198
  "title_position": "start"
197
199
  },
@@ -263,8 +265,14 @@ Better-commits (& better-branch) are highly flexible with sane defaults. These o
263
265
 
264
266
  </details>
265
267
 
268
+ > [!NOTE]<br>
269
+ > Some properties use sets of string values
270
+ > See *confile file explanations* for possible values
271
+
266
272
  ### 🔭 Config File Explanations
267
273
 
274
+ Expand to see explanations and possible values
275
+
268
276
  <details>
269
277
  <summary>Expand / Collapse</summary>
270
278
 
@@ -297,7 +305,8 @@ Better-commits (& better-branch) are highly flexible with sane defaults. These o
297
305
  | `check_ticket.infer_ticket` | If true infer ticket from branch name |
298
306
  | `check_ticket.confirm_ticket` | If true manually confirm inference |
299
307
  | `check_ticket.add_to_title` | If true add ticket to title |
300
- | `check_ticket.append_hashtag` | If true add hashtag to ticket (Ideal for Github Issues) |
308
+ | `check_ticket.append_hashtag` | **Deprecated**: see prepend_hashtag |
309
+ | `check_ticket.prepend_hashtag` | "Never" (default), "Prompt", or "Always" |
301
310
  | `check_ticket.title_position` | "start" (of description) (default), "end", "before-colon" |
302
311
  | `check_ticket.surround` | "" (default), "[]", "()", "{}" - Wraps ticket in title |
303
312
  | `commit_title.max_size` | Max size of title including scope, type, etc... |
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 ? '#' + found[0] : found[0]
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',
package/src/utils.ts CHANGED
@@ -148,18 +148,26 @@ export function load_setup(
148
148
  console.clear();
149
149
  p.intro(`${color.bgCyan(color.black(cli_name))}`);
150
150
 
151
+ let global_config = null
152
+ const home_path = get_default_config_path();
153
+ if (fs.existsSync(home_path)) {
154
+ p.log.step("Found global config");
155
+ global_config = read_config_from_path(home_path);
156
+ }
157
+
151
158
  const root = get_git_root();
152
159
  const root_path = `${root}/${CONFIG_FILE_NAME}`;
153
160
  if (fs.existsSync(root_path)) {
154
161
  p.log.step("Found repository config");
155
- return read_config_from_path(root_path);
162
+ const repo_config = read_config_from_path(root_path);
163
+ return global_config ? {
164
+ ...repo_config,
165
+ overrides: global_config.overrides.shell ? global_config.overrides : repo_config.overrides,
166
+ confirm_with_editor: global_config.confirm_with_editor
167
+ } : repo_config
156
168
  }
157
169
 
158
- const home_path = get_default_config_path();
159
- if (fs.existsSync(home_path)) {
160
- p.log.step("Found global config");
161
- return read_config_from_path(home_path);
162
- }
170
+ if (global_config) return global_config
163
171
 
164
172
  const default_config = Config.parse({});
165
173
  p.log.step(
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
  })