better-commits 1.20.0-cli-flags → 1.20.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.
@@ -1,28 +0,0 @@
1
- export { matchers } from './matchers.js';
2
-
3
- export const nodes = [
4
- () => import('./nodes/0'),
5
- () => import('./nodes/1')
6
- ];
7
-
8
- export const server_loads = [];
9
-
10
- export const dictionary = {
11
-
12
- };
13
-
14
- export const hooks = {
15
- handleError: (({ error }) => { console.error(error) }),
16
-
17
- reroute: (() => {}),
18
- transport: {}
19
- };
20
-
21
- export const decoders = Object.fromEntries(Object.entries(hooks.transport).map(([k, v]) => [k, v.decode]));
22
- export const encoders = Object.fromEntries(Object.entries(hooks.transport).map(([k, v]) => [k, v.encode]));
23
-
24
- export const hash = false;
25
-
26
- export const decode = (type, value) => decoders[type](value);
27
-
28
- export { default as root } from '../root.js';
@@ -1 +0,0 @@
1
- export const matchers = {};
@@ -1 +0,0 @@
1
- export { default as component } from "../../../../../node_modules/@sveltejs/kit/src/runtime/components/svelte-5/layout.svelte";
@@ -1 +0,0 @@
1
- export { default as component } from "../../../../../node_modules/@sveltejs/kit/src/runtime/components/svelte-5/error.svelte";
@@ -1,49 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "paths": {
4
- "$app/types": [
5
- "./types/index.d.ts"
6
- ]
7
- },
8
- "rootDirs": [
9
- "..",
10
- "./types"
11
- ],
12
- "verbatimModuleSyntax": true,
13
- "isolatedModules": true,
14
- "lib": [
15
- "esnext",
16
- "DOM",
17
- "DOM.Iterable"
18
- ],
19
- "moduleResolution": "bundler",
20
- "module": "esnext",
21
- "noEmit": true,
22
- "target": "esnext"
23
- },
24
- "include": [
25
- "ambient.d.ts",
26
- "non-ambient.d.ts",
27
- "./types/**/$types.d.ts",
28
- "../vite.config.js",
29
- "../vite.config.ts",
30
- "../src/**/*.js",
31
- "../src/**/*.ts",
32
- "../src/**/*.svelte",
33
- "../test/**/*.js",
34
- "../test/**/*.ts",
35
- "../test/**/*.svelte",
36
- "../tests/**/*.js",
37
- "../tests/**/*.ts",
38
- "../tests/**/*.svelte"
39
- ],
40
- "exclude": [
41
- "../node_modules/**",
42
- "../src/service-worker.js",
43
- "../src/service-worker/**/*.js",
44
- "../src/service-worker.ts",
45
- "../src/service-worker/**/*.ts",
46
- "../src/service-worker.d.ts",
47
- "../src/service-worker/**/*.d.ts"
48
- ]
49
- }
@@ -1,316 +0,0 @@
1
- From 8f6f28a9e249988ac00350defdb852c0bcdea615 Mon Sep 17 00:00:00 2001
2
- From: everduin94 <everduin94@gmail.com>
3
- Date: Thu, 4 Sep 2025 08:53:43 -0500
4
- Subject: [PATCH] feat(branch): #124 update worktrees feature
5
-
6
- DEPRECATED: replaced enable_worktrees in favor of worktrees.enable
7
-
8
- Closes: #124
9
- ---
10
- .better-commits.json | 6 +---
11
- readme.md | 85 +++++++++++++++++++++-----------------------
12
- src/branch.ts | 37 +++++++++----------
13
- src/utils.ts | 26 --------------
14
- src/valibot-state.ts | 15 ++++----
15
- 5 files changed, 68 insertions(+), 101 deletions(-)
16
-
17
- diff --git a/.better-commits.json b/.better-commits.json
18
- index a2a964b..3dce2fc 100644
19
- --- a/.better-commits.json
20
- +++ b/.better-commits.json
21
- @@ -41,9 +41,5 @@
22
- "git checkout main",
23
- "git pull -r origin main",
24
- "npm install"
25
- - ],
26
- - "worktree_config": {
27
- - "base_path": "../",
28
- - "folder_template": "{{repo_name}}-{{user}}-{{type}}-{{branch_description}}"
29
- - }
30
- + ]
31
- }
32
- diff --git a/readme.md b/readme.md
33
- index 7376317..cf46fb1 100644
34
- --- a/readme.md
35
- +++ b/readme.md
36
- @@ -42,16 +42,15 @@ npm install -g better-commits
37
-
38
- ## 🚀 Usage
39
-
40
- -When you're ready to commit. To run the CLI in your terminal:
41
- +To run the CLI in your terminal:
42
-
43
- ```sh
44
- -better-commits
45
- -# or
46
- -npx better-commits
47
- +better-commits # Create a new commit
48
- +better-branch # Create a new branch
49
- ```
50
-
51
- -It will prompt a series of questions. These prompts will build a commit message, which you can preview, before confirming the commit.
52
- -Some of the values in these prompts will be infered by your branch name and auto populated. You can adjust this in your `.better-commits.json` configuration file.
53
- +`better-commits` will prompt a series of questions. These prompts will build a commit message, which you can preview, before confirming the commit.
54
- +Some of the values in these prompts will be inferred by your branch name and auto populated. You can adjust this in your `.better-commits.json` configuration file.
55
-
56
- To better understand these prompts and their intention, read [Conventional Commits Summary](https://www.conventionalcommits.org/en/v1.0.0-beta.4/#summary)
57
-
58
- @@ -251,10 +250,10 @@ Better-commits (& better-branch) are highly flexible with sane defaults. These o
59
- },
60
- "branch_action_default": "branch",
61
- "branch_order": ["user", "version", "type", "ticket", "description"],
62
- - "enable_worktrees": true,
63
- - "worktree_config": {
64
- - "base_path": "../",
65
- - "folder_template": "{{repo_name}}-{{branch_description}}"
66
- + "worktrees": {
67
- + "enable": true,
68
- + "base_path": "..",
69
- + "folder_template": "{{repo_name}}-{{ticket}}-{{branch_description}}"
70
- },
71
- "overrides": {
72
- "shell": "/bin/sh"
73
- @@ -327,30 +326,31 @@ Expand to see explanations and possible values
74
-
75
- Branch configuration (same config file, split for readability)
76
-
77
- -| Property | Description |
78
- -| ------------------------------- | --------------------------------------------------------- |
79
- -| `branch_pre_commands` | Array of shell commands to run before branching |
80
- -| `branch_post_commands` | Array of shell commands to run after branching |
81
- -| `worktree_pre_commands` | Array of shell commands to run before creating worktree |
82
- -| `worktree_post_commands` | Array of shell commands to run after creating worktree |
83
- -| `branch_user.enable` | If enabled include user name |
84
- -| `branch_user.required` | If enabled require user name |
85
- -| `branch_user.separator` | Branch delimeter - "/" (default), "-", "\_" |
86
- -| `branch_type.enable` | If enabled include type |
87
- -| `branch_type.separator` | Branch delimeter - "/" (default), "-", "\_" |
88
- -| `branch_ticket.enable` | If enabled include ticket |
89
- -| `branch_ticket.required` | If enabled require ticket |
90
- -| `branch_ticket.separator` | Branch delimeter - "/", "-" (default), "\_" |
91
- -| `branch_description.max_length` | Max length branch name |
92
- -| `branch_description.separator` | Branch delimeter - "" (default), "/", "-", "\_" |
93
- -| `branch_version.enable` | If enabled include version |
94
- -| `branch_version.required` | If enabled require version |
95
- -| `branch_version.separator` | Branch delimeter - "", "/" (default), "-", "\_" |
96
- -| `branch_order` | Order of branch name values (doesn't effect prompt order) |
97
- -| `branch_action_default` | "branch" or "worktree" |
98
- -| `enable_worktrees` | If false, always default to branch action |
99
- -| `worktree_config.base_path` | Directory where worktrees are created (default: "../") |
100
- -| `worktree_config.folder_template` | Template for worktree folder names with variables like {{repo_name}}, {{branch_description}}, {{user}}, {{type}}, {{ticket}}, {{version}} |
101
- +| Property | Description |
102
- +| ------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- |
103
- +| `branch_pre_commands` | Array of shell commands to run before branching |
104
- +| `branch_post_commands` | Array of shell commands to run after branching |
105
- +| `worktree_pre_commands` | Array of shell commands to run before creating worktree |
106
- +| `worktree_post_commands` | Array of shell commands to run after creating worktree |
107
- +| `branch_user.enable` | If enabled include user name |
108
- +| `branch_user.required` | If enabled require user name |
109
- +| `branch_user.separator` | Branch delimeter - "/" (default), "-", "\_" |
110
- +| `branch_type.enable` | If enabled include type |
111
- +| `branch_type.separator` | Branch delimeter - "/" (default), "-", "\_" |
112
- +| `branch_ticket.enable` | If enabled include ticket |
113
- +| `branch_ticket.required` | If enabled require ticket |
114
- +| `branch_ticket.separator` | Branch delimeter - "/", "-" (default), "\_" |
115
- +| `branch_description.max_length` | Max length branch name |
116
- +| `branch_description.separator` | Branch delimeter - "" (default), "/", "-", "\_" |
117
- +| `branch_version.enable` | If enabled include version |
118
- +| `branch_version.required` | If enabled require version |
119
- +| `branch_version.separator` | Branch delimeter - "", "/" (default), "-", "\_" |
120
- +| `branch_order` | Order of branch name values (doesn't effect prompt order) |
121
- +| `branch_action_default` | "branch" or "worktree" |
122
- +| `enable_worktrees` | `Deprecated` see `worktrees.enable` |
123
- +| `worktrees.enable` | If false, always default to branch action |
124
- +| `worktrees.base_path` | Directory where worktrees are created (default: "..") |
125
- +| `worktrees.folder_template` | Template for worktree folder names with variables like {{repo_name}}, {{branch_description}}, {{user}}, {{type}}, {{ticket}}, {{version}} |
126
-
127
- </details>
128
-
129
- @@ -368,16 +368,13 @@ Branch configuration (same config file, split for readability)
130
-
131
- ## 🌳 Better Branch
132
-
133
- -> [!NOTE]<br>
134
- -> Using `better-branch` with `better-commits` can supercharge your git workflow.
135
- -> Make sure to try it out!
136
- -
137
- Better branch is a secondary feature that works with better commits
138
-
139
- - Supports consistent branch naming conventions
140
- - Uses same type-list/prompt from your config
141
- - Enables better-commits to infer type & ticket
142
- - Caches your username for speedy branching
143
- +- Convenient worktree creation
144
-
145
- To run the CLI in your terminal:
146
-
147
- @@ -387,13 +384,14 @@ better-branch
148
-
149
- ### Worktree Support
150
-
151
- -`better-branch` will prompt for **Branch** or **Worktree**. Creating a **Worktree** with `better-branch` is a great way to create worktrees while maintaining consistent branch naming conventions.
152
- -
153
- -The worktree flow creates a folder/worktree with your **branch description** and a git branch inside with your **full branch name**.
154
- +`better-branch` will prompt for **Branch** or **Worktree**. The Worktree flow creates a folder/worktree from your **branch description** and a git branch inside with your **full branch name**.
155
-
156
- > [!NOTE]<br>
157
- > Creating a worktree named `everduin94/feat/TAC-123-add-worktrees` with the native git command would create a nested folder for each `/`. `better-branch` removes the hassle by creating 1 folder while still using the full name for the branch.
158
-
159
- +> [!TIP]
160
- +> By default, `better-branch` will create **worktrees** as a sibling folder. To change this, see `worktrees.base_path`.
161
- +
162
- ### Pre/Post Branch Checkout Hooks
163
-
164
- Optionally configure pre and post checkout commands, for example:
165
- @@ -425,7 +423,7 @@ If you're using Github issues to track your work, and select the `closes` footer
166
-
167
- `better-commits` can append a commit trailer per commit type. This allows you to [automate change logs](https://docs.gitlab.com/ee/user/project/changelogs.html) with tools like Gitlab.
168
-
169
- -### Fun Facts
170
- +### Misc
171
-
172
- `better-commits` uses native `git` commands under the hood. So any hooks, tools, or staging should work as if it was a normal commit.
173
-
174
- @@ -434,9 +432,6 @@ Setting `confirm_with_editor=true` will allow you to edit/confirm a commit with
175
- - For example, to edit with Neovim: `git config --global core.editor "nvim"`
176
- - For VS Code, `git config --global core.editor "code -n --wait"`
177
-
178
- -> [!NOTE]<br>
179
- -> Enjoy learning, open source technology, and note-taking? [Join our Discord!](https://discord.gg/grHVnZwYup)
180
- -
181
- You can add this badge to your repository to display that you're using a better-commits repository config
182
-
183
- | Markdown | Result |
184
- diff --git a/src/branch.ts b/src/branch.ts
185
- index 14b3f0f..bd70311 100644
186
- --- a/src/branch.ts
187
- +++ b/src/branch.ts
188
- @@ -17,7 +17,7 @@ import {
189
- CACHE_PROMPT,
190
- OPTIONAL_PROMPT,
191
- load_setup,
192
- - get_repo_name,
193
- + get_git_root,
194
- } from "./utils";
195
- import { flags } from "./args";
196
-
197
- @@ -25,9 +25,10 @@ main(load_setup(" better-branch "));
198
-
199
- async function main(config: Output<typeof Config>) {
200
- const branch_state = parse(BranchState, {});
201
- + chdir(get_git_root());
202
-
203
- let checkout_type: Output<typeof V_BRANCH_ACTIONS> = "branch";
204
- - if (config.enable_worktrees) {
205
- + if (config.worktrees.enable) {
206
- const branch_or_worktree = await p.select({
207
- message: `Checkout a branch or create a worktree?`,
208
- initialValue: config.branch_action_default,
209
- @@ -198,26 +199,26 @@ function build_worktree_path(
210
- branch_state: Output<typeof BranchState>,
211
- config: Output<typeof Config>,
212
- ): string {
213
- - const repo_name = get_repo_name();
214
- - let worktree_name = config.worktree_config.folder_template;
215
- -
216
- - // Replace template variables
217
- + const gitRoot = get_git_root();
218
- + const repo_name = gitRoot.split("/").pop() || "repo";
219
- +
220
- + let worktree_name = config.worktrees.folder_template;
221
- +
222
- worktree_name = worktree_name
223
- - .replace(/\{\{repo_name\}\}/g, repo_name)
224
- - .replace(/\{\{branch_description\}\}/g, branch_state.description)
225
- - .replace(/\{\{user\}\}/g, branch_state.user || "")
226
- - .replace(/\{\{type\}\}/g, branch_state.type || "")
227
- - .replace(/\{\{ticket\}\}/g, branch_state.ticket || "")
228
- - .replace(/\{\{version\}\}/g, branch_state.version || "");
229
- -
230
- - // Clean up any double hyphens or leading/trailing hyphens
231
- + .replace("{{repo_name}}", repo_name)
232
- + .replace("{{branch_description}}", branch_state.description)
233
- + .replace("{{user}}", branch_state.user || "")
234
- + .replace("{{type}}", branch_state.type || "")
235
- + .replace("{{ticket}}", branch_state.ticket || "")
236
- + .replace("{{version}}", branch_state.version || "");
237
- +
238
- worktree_name = worktree_name
239
- + .replace(/\s/g, "")
240
- .replace(/--+/g, "-")
241
- .replace(/^-+|-+$/g, "");
242
- -
243
- - // Combine with base path
244
- - const base_path = config.worktree_config.base_path;
245
- - return `${base_path}${base_path.endsWith('/') ? '' : '/'}${worktree_name}`;
246
- +
247
- + const base_path = config.worktrees.base_path;
248
- + return `${base_path}${base_path.endsWith("/") ? "" : "/"}${worktree_name}`;
249
- }
250
-
251
- function get_user_from_cache(): string {
252
- diff --git a/src/utils.ts b/src/utils.ts
253
- index 7166c2a..0c0403d 100644
254
- --- a/src/utils.ts
255
- +++ b/src/utils.ts
256
- @@ -224,29 +224,3 @@ export function set_value_cache(
257
- );
258
- }
259
- }
260
- -
261
- -export function get_repo_name(): string {
262
- - try {
263
- - // First try to get repo name from git remote
264
- - const remote = execSync(`git ${flags.git_args} remote get-url origin`, {
265
- - stdio: "pipe",
266
- - }).toString().trim();
267
- -
268
- - // Extract repo name from remote URL
269
- - const match = remote.match(/\/([^\/]+?)(\.git)?$/);
270
- - if (match && match[1]) {
271
- - return match[1];
272
- - }
273
- - } catch (err) {
274
- - // If git remote fails, fall back to directory name
275
- - }
276
- -
277
- - try {
278
- - // Fall back to git root directory name
279
- - const gitRoot = get_git_root();
280
- - const repoName = gitRoot.split('/').pop() || 'repo';
281
- - return repoName;
282
- - } catch (err) {
283
- - return 'repo';
284
- - }
285
- -}
286
- diff --git a/src/valibot-state.ts b/src/valibot-state.ts
287
- index 7256ca3..de943a3 100644
288
- --- a/src/valibot-state.ts
289
- +++ b/src/valibot-state.ts
290
- @@ -211,15 +211,16 @@ export const Config = v.object({
291
- branch_action_default: v.optional(V_BRANCH_ACTIONS, "branch"),
292
- branch_order: v.optional(v.array(V_BRANCH_FIELDS), BRANCH_ORDER_DEFAULTS),
293
- enable_worktrees: v.optional(v.boolean(), true),
294
- - worktree_config: v.optional(
295
- + worktrees: v.optional(
296
- v.object({
297
- - base_path: v.optional(v.string(), "../"),
298
- - folder_template: v.optional(v.string(), "{{repo_name}}-{{branch_description}}"),
299
- + enable: v.optional(v.boolean(), true),
300
- + base_path: v.optional(v.string(), ".."),
301
- + folder_template: v.optional(
302
- + v.string(),
303
- + "{{repo_name}}-{{ticket}}-{{branch_description}}",
304
- + ),
305
- }),
306
- - {
307
- - base_path: "../",
308
- - folder_template: "{{repo_name}}-{{branch_description}}",
309
- - },
310
- + {},
311
- ),
312
- overrides: v.optional(
313
- v.object({
314
- --
315
- 2.39.5 (Apple Git-154)
316
-
@@ -1,48 +0,0 @@
1
- program: better-commits
2
- version: 1
3
- rules:
4
- - prefer_non_interactive: true
5
- - always_dry_run_first: true
6
- - config_precedence: repo_then_home
7
- - repo_config_path: .better-commits.json
8
- - home_config_path: ~/.better-commits.json
9
-
10
- skills:
11
- - id: create_commit_non_interactive
12
- goal: Create a commit without prompts using CLI flags.
13
- command: better-commits --no-interactive [flags]
14
- required_flags:
15
- - --title
16
- optional_flags:
17
- - --type
18
- - --scope
19
- - --body
20
- - --ticket
21
- - --closes
22
- - --trailer
23
- - --breaking-title
24
- - --breaking-body
25
- - --deprecates-title
26
- - --deprecates-body
27
- - --custom-footer
28
- inference:
29
- - If --type is missing, infer from branch when possible.
30
- - If --ticket is missing, infer from branch when possible.
31
- flow:
32
- - Run dry-run first.
33
- - If valid, rerun without --dry-run.
34
- dry_run_example: better-commits --no-interactive --dry-run --title "add parser"
35
- commit_example: better-commits --no-interactive --type feat --title "add parser"
36
-
37
- - id: edit_config_interview
38
- goal: Create or update .better-commits.json based on user preferences and verify it.
39
- flow:
40
- - Choose target config: repo .better-commits.json, else ~/.better-commits.json.
41
- - If repo config is needed and missing, run better-commits-init in repo root.
42
- - Ask focused questions and edit JSON only.
43
- - Preserve unknown keys.
44
- - Validate with a dry-run commit command.
45
- validation_command: better-commits --no-interactive --dry-run --type feat --title "config validation"
46
- success_criteria:
47
- - command exits successfully
48
- - no schema or config validation errors
package/docs/clack.md DELETED
@@ -1,143 +0,0 @@
1
- # Clack Usage
2
-
3
- `better-commits` uses [`@clack/prompts`](https://github.com/natemoo-re/clack) as its sole interactive UI layer. All terminal prompts, logging, and banners go through clack — there is no `readline`, `inquirer`, or other prompt library in use.
4
-
5
- ## Packages
6
-
7
- | Package | Version | Role |
8
- | ---------------- | -------- | ------------------------------------------------------ |
9
- | `@clack/prompts` | `^0.7.0` | Directly imported in all source files |
10
- | `@clack/core` | `^0.3.1` | Peer dependency of `@clack/prompts`, used transitively |
11
-
12
- All files import clack with the alias:
13
-
14
- ```ts
15
- import * as p from "@clack/prompts";
16
- ```
17
-
18
- ## Files That Use Clack
19
-
20
- - `src/index.ts` — main `better-commits` CLI flow
21
- - `src/branch.ts` — `better-branch` CLI flow
22
- - `src/utils.ts` — config loading and setup
23
- - `src/git.ts` — git operation feedback
24
- - `src/init.ts` — config initialization
25
-
26
- ## API Reference
27
-
28
- ### `p.intro(message)`
29
-
30
- Renders a styled banner at the start of each CLI entrypoint.
31
-
32
- ```ts
33
- // src/utils.ts
34
- p.intro(color.bgCyan(color.black(cli_name)));
35
-
36
- // src/init.ts
37
- p.intro(color.bgCyan(color.black(" better-commits-init ")));
38
- ```
39
-
40
- ### `p.outro(message)`
41
-
42
- Renders a closing message at the end of a CLI flow. Only used in `src/init.ts` after writing the config file.
43
-
44
- ```ts
45
- p.outro("Run better-commits to start the CLI");
46
- ```
47
-
48
- ### `p.note(message, title)`
49
-
50
- Prints a multi-line boxed panel. Used in `src/index.ts` to display a formatted commit preview before confirmation.
51
-
52
- ```ts
53
- p.note(commit_string, "Commit Preview");
54
- ```
55
-
56
- ### `p.select(options)`
57
-
58
- Single-selection list prompt. Used for:
59
-
60
- | Location | Prompt |
61
- | --------------- | ----------------------------------------- |
62
- | `src/index.ts` | "Select a commit type" |
63
- | `src/index.ts` | "Select a commit scope" |
64
- | `src/branch.ts` | "Checkout a branch or create a worktree?" |
65
- | `src/branch.ts` | "Select a branch type" |
66
-
67
- ### `p.multiselect(options)`
68
-
69
- Multi-selection checkbox prompt. Used for:
70
-
71
- | Location | Prompt |
72
- | -------------- | -------------------------------------------------------------------------------- |
73
- | `src/index.ts` | "would you like to add them now?" — lists unstaged files |
74
- | `src/index.ts` | "Select optional footers" — closes, trailer, breaking-change, deprecated, custom |
75
-
76
- The footers prompt uses `required: false` to make it skippable.
77
-
78
- ### `p.text(options)`
79
-
80
- Free-text input with optional `validate` and `initialValue`. Used across 15+ prompts, including:
81
-
82
- | Location | Prompt |
83
- | --------------- | ------------------------------------------------------------------ |
84
- | `src/index.ts` | "Write a custom scope" |
85
- | `src/index.ts` | "Add ticket / issue" (pre-filled from branch name inference) |
86
- | `src/index.ts` | "Write a brief title describing the commit" (validates `max_size`) |
87
- | `src/index.ts` | "Write a detailed description of the changes" |
88
- | `src/index.ts` | "Breaking changes: Write a short title / summary" |
89
- | `src/index.ts` | "Breaking Changes: Write a description & migration instructions" |
90
- | `src/index.ts` | "Deprecated: Write a short title / summary" |
91
- | `src/index.ts` | "Deprecated: Write a description" |
92
- | `src/index.ts` | "Write a custom footer" |
93
- | `src/branch.ts` | "Type your git username" |
94
- | `src/branch.ts` | "Type ticket / issue number" |
95
- | `src/branch.ts` | "Type version number" |
96
- | `src/branch.ts` | "Type a short description" (enforces `max_length`) |
97
-
98
- ### `p.confirm(options)`
99
-
100
- Yes/No confirmation prompt. Used once in `src/index.ts`:
101
-
102
- ```ts
103
- const confirmed = await p.confirm({ message: "Confirm Commit?" });
104
- ```
105
-
106
- Only shown when `config.confirm_commit` is `true`. The boolean result controls whether the git commit executes.
107
-
108
- ### `p.isCancel(value)`
109
-
110
- Checks if the user cancelled a prompt (via `Ctrl+C`). Called immediately after **every** prompt throughout the codebase. On cancel, `process.exit(0)` is called for a graceful exit.
111
-
112
- - Called **19 times** in `src/index.ts`
113
- - Called **7 times** in `src/branch.ts`
114
-
115
- Pattern used throughout:
116
-
117
- ```ts
118
- const value = await p.text({ message: "..." });
119
- if (p.isCancel(value)) process.exit(0);
120
- ```
121
-
122
- ### `p.log.*`
123
-
124
- Structured log functions used in place of `console.log` across all files.
125
-
126
- | Method | Color | Usage |
127
- | -------------------- | ------- | ----------------------------------------------------------------------------- |
128
- | `p.log.step(msg)` | neutral | Info messages: "Found global config", "Checking Git Status" |
129
- | `p.log.success(msg)` | green | "Commit Complete", "Successfully created .better-commits.json" |
130
- | `p.log.error(msg)` | red | Failed git commands, invalid config, failed staging |
131
- | `p.log.warn(msg)` | yellow | Missing git root, cache failures, invalid config paths |
132
- | `p.log.warning(msg)` | yellow | Alias for `warn`; used once in `src/branch.ts` for duplicate branch detection |
133
- | `p.log.info(msg)` | blue | "Committing changes...", "Exiting without commit", branch creation success |
134
-
135
- ## CLI Interaction Flow
136
-
137
- Every CLI command follows this structure:
138
-
139
- 1. `p.intro()` — welcome banner
140
- 2. Series of `p.select` / `p.multiselect` / `p.text` / `p.confirm` prompts, each immediately guarded by `p.isCancel()`
141
- 3. `p.log.*` — structured feedback at each meaningful step (config loading, git operations, errors)
142
- 4. `p.note()` — optional formatted commit preview before final confirmation (`src/index.ts` only)
143
- 5. `p.outro()` — closing message (`src/init.ts` only; main flows end with `p.log.success`)