better-commits 1.13.0 → 1.15.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.
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"
@@ -264,7 +272,7 @@ var Config = import_zod2.z.object({
264
272
  append_hashtag: import_zod2.z.boolean().default(false),
265
273
  prepend_hashtag: import_zod2.z.enum(["Never", "Always", "Prompt"]).default("Never"),
266
274
  surround: import_zod2.z.enum(["", "()", "[]", "{}"]).default(""),
267
- title_position: import_zod2.z.enum(["start", "end", "before-colon"]).default("start")
275
+ title_position: import_zod2.z.enum(["start", "end", "before-colon", "beginning"]).default("start")
268
276
  }).default({}),
269
277
  commit_title: import_zod2.z.object({
270
278
  max_size: import_zod2.z.number().positive().default(70)
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"
@@ -328,7 +336,7 @@ var Config = import_zod2.z.object({
328
336
  append_hashtag: import_zod2.z.boolean().default(false),
329
337
  prepend_hashtag: import_zod2.z.enum(["Never", "Always", "Prompt"]).default("Never"),
330
338
  surround: import_zod2.z.enum(["", "()", "[]", "{}"]).default(""),
331
- title_position: import_zod2.z.enum(["start", "end", "before-colon"]).default("start")
339
+ title_position: import_zod2.z.enum(["start", "end", "before-colon", "beginning"]).default("start")
332
340
  }).default({}),
333
341
  commit_title: import_zod2.z.object({
334
342
  max_size: import_zod2.z.number().positive().default(70)
@@ -694,6 +702,10 @@ function build_commit_string(commit_state, config, colorize = false, escape_quot
694
702
  const close_token = surround.charAt(1);
695
703
  title_ticket = `${open_token}${commit_state.ticket}${close_token}`;
696
704
  }
705
+ const position_beginning = config.check_ticket.title_position === "beginning";
706
+ if (title_ticket && config.check_ticket.add_to_title && position_beginning) {
707
+ commit_string = `${colorize ? import_picocolors3.default.magenta(title_ticket) : title_ticket} ${commit_string}`;
708
+ }
697
709
  const position_before_colon = config.check_ticket.title_position === "before-colon";
698
710
  if (title_ticket && config.check_ticket.add_to_title && position_before_colon) {
699
711
  const spacing = commit_state.scope || commit_state.type && !config.check_ticket.surround ? " " : "";
package/dist/init.js CHANGED
@@ -216,7 +216,7 @@ var Config = import_zod2.z.object({
216
216
  append_hashtag: import_zod2.z.boolean().default(false),
217
217
  prepend_hashtag: import_zod2.z.enum(["Never", "Always", "Prompt"]).default("Never"),
218
218
  surround: import_zod2.z.enum(["", "()", "[]", "{}"]).default(""),
219
- title_position: import_zod2.z.enum(["start", "end", "before-colon"]).default("start")
219
+ title_position: import_zod2.z.enum(["start", "end", "before-colon", "beginning"]).default("start")
220
220
  }).default({}),
221
221
  commit_title: import_zod2.z.object({
222
222
  max_size: import_zod2.z.number().positive().default(70)
package/dist/utils.js CHANGED
@@ -142,7 +142,7 @@ var Config = import_zod.z.object({
142
142
  append_hashtag: import_zod.z.boolean().default(false),
143
143
  prepend_hashtag: import_zod.z.enum(["Never", "Always", "Prompt"]).default("Never"),
144
144
  surround: import_zod.z.enum(["", "()", "[]", "{}"]).default(""),
145
- title_position: import_zod.z.enum(["start", "end", "before-colon"]).default("start")
145
+ title_position: import_zod.z.enum(["start", "end", "before-colon", "beginning"]).default("start")
146
146
  }).default({}),
147
147
  commit_title: import_zod.z.object({
148
148
  max_size: import_zod.z.number().positive().default(70)
@@ -343,17 +343,25 @@ var BRANCH_ACTION_OPTIONS = [
343
343
  function load_setup(cli_name = " better-commits ") {
344
344
  console.clear();
345
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
+ }
346
352
  const root = get_git_root();
347
353
  const root_path = `${root}/${CONFIG_FILE_NAME}`;
348
354
  if (import_fs.default.existsSync(root_path)) {
349
355
  p.log.step("Found repository config");
350
- return read_config_from_path(root_path);
351
- }
352
- const home_path = get_default_config_path();
353
- if (import_fs.default.existsSync(home_path)) {
354
- p.log.step("Found global config");
355
- 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;
356
362
  }
363
+ if (global_config)
364
+ return global_config;
357
365
  const default_config = Config.parse({});
358
366
  p.log.step(
359
367
  "Config not found. Generating default .better-commit.json at $HOME"
package/dist/zod-state.js CHANGED
@@ -214,7 +214,7 @@ var Config = import_zod2.z.object({
214
214
  append_hashtag: import_zod2.z.boolean().default(false),
215
215
  prepend_hashtag: import_zod2.z.enum(["Never", "Always", "Prompt"]).default("Never"),
216
216
  surround: import_zod2.z.enum(["", "()", "[]", "{}"]).default(""),
217
- title_position: import_zod2.z.enum(["start", "end", "before-colon"]).default("start")
217
+ title_position: import_zod2.z.enum(["start", "end", "before-colon", "beginning"]).default("start")
218
218
  }).default({}),
219
219
  commit_title: import_zod2.z.object({
220
220
  max_size: import_zod2.z.number().positive().default(70)
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "better-commits",
3
3
  "private": false,
4
- "version": "1.13.0",
4
+ "version": "1.15.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
@@ -4,9 +4,7 @@
4
4
 
5
5
  [![better commits is enabled](https://img.shields.io/badge/better--commits-enabled?style=for-the-badge&logo=git&color=a6e3a1&logoColor=D9E0EE&labelColor=302D41)](https://github.com/Everduin94/better-commits)
6
6
  [![downloads](https://img.shields.io/npm/dt/better-commits.svg?style=for-the-badge&logo=npm&color=74c7ec&logoColor=D9E0EE&labelColor=302D41)](https://www.npmjs.com/package/better-commits)
7
- <a href="https://github.com/everduin94/better-commits/issues">
8
- <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>
9
-
7
+ [![discord](https://img.shields.io/badge/discord-join--discord?style=for-the-badge&logo=discord&color=cba6f7&logoColor=D9E0EE&labelColor=302D41)](https://discord.gg/grHVnZwYup)
10
8
  </h3>
11
9
 
12
10
  <p align="center">
@@ -65,8 +63,9 @@ Your first time running `better-commits`, a default config will be generated in
65
63
  ### Repository
66
64
 
67
65
  To create a **repository-specific config**, navigate to the root of your project.
68
- - run `better-commits-init`
66
+ - Run `better-commits-init`
69
67
  - This will create a default config named `.better-commits.json`
68
+ - Properties such as `confirm_with_editor` and `overrides` will prefer the global config
70
69
 
71
70
  ### Options
72
71
 
@@ -265,8 +264,8 @@ Better-commits (& better-branch) are highly flexible with sane defaults. These o
265
264
  </details>
266
265
 
267
266
  > [!NOTE]<br>
268
- > Some properties use sets of string values
269
- > See *confile file explanations* for possible values
267
+ > Some properties allow a set of specifc string values
268
+ > - See *config file explanations* for possible values
270
269
 
271
270
  ### 🔭 Config File Explanations
272
271
 
@@ -306,7 +305,7 @@ Expand to see explanations and possible values
306
305
  | `check_ticket.add_to_title` | If true add ticket to title |
307
306
  | `check_ticket.append_hashtag` | **Deprecated**: see prepend_hashtag |
308
307
  | `check_ticket.prepend_hashtag` | "Never" (default), "Prompt", or "Always" |
309
- | `check_ticket.title_position` | "start" (of description) (default), "end", "before-colon" |
308
+ | `check_ticket.title_position` | "start" (of description) (default), "end", "before-colon", "beginning" (of the entire commit title) |
310
309
  | `check_ticket.surround` | "" (default), "[]", "()", "{}" - Wraps ticket in title |
311
310
  | `commit_title.max_size` | Max size of title including scope, type, etc... |
312
311
  | `commit_body.enable` | If true include body |
@@ -419,6 +418,9 @@ Setting `confirm_with_editor=true` will allow you to edit/confirm a commit with
419
418
  - For example, to edit with Neovim: `git config --global core.editor "nvim"`
420
419
  - For VS Code, `git config --global core.editor "code -n --wait"`
421
420
 
421
+ > [!NOTE]<br>
422
+ > Enjoy learning, open source technology, and note-taking? [Join our Discord!](https://discord.gg/grHVnZwYup)
423
+
422
424
  You can add this badge to your repository to display that you're using a better-commits repository config
423
425
 
424
426
  | Markdown | Result |
package/src/index.ts CHANGED
@@ -268,6 +268,11 @@ function build_commit_string(commit_state: z.infer<typeof CommitState>,
268
268
  const close_token = surround.charAt(1);
269
269
  title_ticket = `${open_token}${commit_state.ticket}${close_token}`
270
270
  }
271
+
272
+ const position_beginning = config.check_ticket.title_position === 'beginning';
273
+ if (title_ticket && config.check_ticket.add_to_title && position_beginning) {
274
+ commit_string = `${colorize ? color.magenta(title_ticket) : title_ticket} ${commit_string}`;
275
+ }
271
276
 
272
277
  const position_before_colon = config.check_ticket.title_position === "before-colon"
273
278
  if (title_ticket && config.check_ticket.add_to_title && position_before_colon) {
@@ -343,4 +348,3 @@ function build_commit_string(commit_state: z.infer<typeof CommitState>,
343
348
 
344
349
  return commit_string;
345
350
  }
346
-
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
@@ -99,7 +99,7 @@ export const Config = z
99
99
  append_hashtag: z.boolean().default(false),
100
100
  prepend_hashtag: z.enum(['Never', 'Always', 'Prompt']).default("Never"),
101
101
  surround: z.enum(["", "()", "[]", "{}"]).default(""),
102
- title_position: z.enum(["start", "end", "before-colon"]).default("start"),
102
+ title_position: z.enum(["start", "end", "before-colon", "beginning"]).default("start"),
103
103
  })
104
104
  .default({}),
105
105
  commit_title: z