better-commits 1.20.0-cli-flags → 1.20.1-temp.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.
Files changed (71) hide show
  1. package/dist/branch.js +1 -1
  2. package/dist/{chunk-SIF4LZUS.js → chunk-LPU7O52G.js} +1 -1
  3. package/dist/chunk-QPUTIRGU.js +245 -0
  4. package/dist/index.js +2 -2
  5. package/dist/init.js +1 -1
  6. package/package.json +7 -1
  7. package/readme.md +141 -173
  8. package/.better-commits.json +0 -52
  9. package/.github/workflows/publish.yml +0 -34
  10. package/.github/workflows/test.yml +0 -27
  11. package/.opencode/package-lock.json +0 -115
  12. package/.opencode/plans/cli-args.md +0 -182
  13. package/.prettierignore +0 -5
  14. package/.prettierrc +0 -1
  15. package/.svelte-kit/ambient.d.ts +0 -289
  16. package/.svelte-kit/generated/client/app.js +0 -28
  17. package/.svelte-kit/generated/client/matchers.js +0 -1
  18. package/.svelte-kit/generated/client/nodes/0.js +0 -1
  19. package/.svelte-kit/generated/client/nodes/1.js +0 -1
  20. package/.svelte-kit/tsconfig.json +0 -49
  21. package/0001-feat-branch-124-update-worktrees-feature.patch +0 -316
  22. package/dist/chunk-OFJCRS3N.js +0 -4
  23. package/docs/ai-skills.yaml +0 -48
  24. package/docs/clack.md +0 -143
  25. package/docs/valibot.md +0 -228
  26. package/src/args.test.ts +0 -102
  27. package/src/args.ts +0 -106
  28. package/src/branch-args.test.ts +0 -72
  29. package/src/branch-args.ts +0 -106
  30. package/src/branch-help.ts +0 -114
  31. package/src/branch.ts +0 -95
  32. package/src/git.ts +0 -60
  33. package/src/help.ts +0 -131
  34. package/src/index.test.ts +0 -7
  35. package/src/index.ts +0 -100
  36. package/src/init.ts +0 -25
  37. package/src/prompts/branch-checkout.prompt.ts +0 -36
  38. package/src/prompts/branch-confirm.prompt.ts +0 -134
  39. package/src/prompts/branch-description.prompt.ts +0 -37
  40. package/src/prompts/branch-runnable.ts +0 -13
  41. package/src/prompts/branch-ticket.prompt.ts +0 -41
  42. package/src/prompts/branch-type.prompt.ts +0 -43
  43. package/src/prompts/branch-user.prompt.ts +0 -50
  44. package/src/prompts/branch-version.prompt.ts +0 -41
  45. package/src/prompts/commit-body.prompt.ts +0 -57
  46. package/src/prompts/commit-confirm.prompt.ts +0 -119
  47. package/src/prompts/commit-footer.prompt.ts +0 -195
  48. package/src/prompts/commit-scope.prompt.ts +0 -73
  49. package/src/prompts/commit-status.prompt.ts +0 -75
  50. package/src/prompts/commit-ticket.prompt.ts +0 -82
  51. package/src/prompts/commit-title.prompt.ts +0 -98
  52. package/src/prompts/commit-type.prompt.ts +0 -93
  53. package/src/prompts/runnable.ts +0 -13
  54. package/src/utils/build-branch.test.ts +0 -141
  55. package/src/utils/build-branch.ts +0 -46
  56. package/src/utils/build-commit-string.test.ts +0 -253
  57. package/src/utils/build-commit-string.ts +0 -158
  58. package/src/utils/commit-title-size.ts +0 -24
  59. package/src/utils/infer.test.ts +0 -83
  60. package/src/utils/infer.ts +0 -114
  61. package/src/utils/messages.ts +0 -25
  62. package/src/utils/no-interactive-branch-validation.test.ts +0 -170
  63. package/src/utils/no-interactive-validation.test.ts +0 -174
  64. package/src/utils/no-interactive-validation.ts +0 -190
  65. package/src/utils.ts +0 -219
  66. package/src/valibot-consts.ts +0 -114
  67. package/src/valibot-state.test.ts +0 -48
  68. package/src/valibot-state.ts +0 -265
  69. package/tsconfig.json +0 -15
  70. package/tsup.config.ts +0 -12
  71. package/vitest.config.ts +0 -8
@@ -1,114 +0,0 @@
1
- import { execSync } from "child_process";
2
- import { InferOutput } from "valibot";
3
- import { branch_flags } from "./branch-args";
4
- import { get_package_version } from "./utils";
5
- import { infer_ticket_from_git, infer_type_from_git } from "./utils/infer";
6
- import { Config } from "./valibot-state";
7
- import color from "picocolors";
8
-
9
- const CLI_FLAG_DEFINITIONS: Record<string, string> = {
10
- "--interactive": "Run in interactive prompt mode (default behavior).",
11
- "--dry-run": "Print branch commands without creating a branch or worktree.",
12
- "--help": "Show help information and exit.",
13
- };
14
-
15
- const BRANCH_FLAG_DEFINITIONS: Record<string, string> = {
16
- "--user": "Set branch username segment.",
17
- "--type": "Set branch type (for example feat, fix, docs).",
18
- "--description": "Set branch description segment.",
19
- "--ticket": "Set branch ticket/issue segment.",
20
- "--branch-version": "Set branch version segment.",
21
- "--checkout": "Choose branch or worktree checkout mode.",
22
- };
23
-
24
- const GIT_FLAG_DEFINITIONS: Record<string, string> = {
25
- "--git-dir": "Set the path to the .git directory.",
26
- "--work-tree": "Set the path to the working tree root.",
27
- };
28
-
29
- function to_definition_lines(definitions: Record<string, string>): string {
30
- const description_column = 26;
31
- const minimum_spacing = 2;
32
- const indent = " ";
33
-
34
- return Object.entries(definitions)
35
- .map(([name, description]) => {
36
- const spaces = Math.max(
37
- minimum_spacing,
38
- description_column - name.length,
39
- );
40
- return `${indent}${name}${" ".repeat(spaces)}${description}`;
41
- })
42
- .join("\n");
43
- }
44
-
45
- export function print_help_text(
46
- config: InferOutput<typeof Config>,
47
- config_source: "repository" | "global" | "none",
48
- ) {
49
- const version = get_package_version();
50
-
51
- let branch = "(none)";
52
- try {
53
- branch =
54
- execSync(`git ${branch_flags.git_args} branch --show-current`, {
55
- stdio: "pipe",
56
- })
57
- .toString()
58
- .trim() || "(none)";
59
- } catch {
60
- // noop
61
- }
62
-
63
- const inferred_type =
64
- infer_type_from_git(config.commit_type.options, branch_flags.git_args) ||
65
- "Unknown";
66
- const inferred_ticket = config.check_ticket.infer_ticket
67
- ? infer_ticket_from_git(
68
- {
69
- append_hashtag: config.check_ticket.append_hashtag,
70
- prepend_hashtag: config.check_ticket.prepend_hashtag,
71
- },
72
- branch_flags.git_args,
73
- ) || "Unknown"
74
- : "Infer Disabled";
75
-
76
- const types = config.commit_type.options
77
- .map((option) => option.value)
78
- .join(", ")
79
- .trim();
80
- const scopes = config.commit_scope.options
81
- .map((option) => option.value)
82
- .join(", ")
83
- .trim();
84
- const cli_flags = to_definition_lines(CLI_FLAG_DEFINITIONS);
85
- const git_flags = to_definition_lines(GIT_FLAG_DEFINITIONS);
86
- const branch_flags_help = to_definition_lines(BRANCH_FLAG_DEFINITIONS);
87
-
88
- console.log(`
89
- ${color.green(" better-branch")} ${color.gray("v" + version)}
90
-
91
- ${color.gray("BRANCH")}
92
- ${branch}
93
- ${color.gray("Type")} ${color.blue(inferred_type)} ${color.gray("·")} ${color.gray("Ticket")} ${color.magenta(inferred_ticket)}
94
-
95
- ${color.gray("CONFIGURATION")}
96
- ${config_source}
97
-
98
- ${color.gray("Types")}
99
- ${types}
100
-
101
- ${color.gray("Scopes")}
102
- ${scopes}
103
-
104
- ${color.gray("CLI FLAGS")}
105
- ${cli_flags}
106
-
107
- ${color.gray("Branch Flags")}
108
- ${branch_flags_help}
109
-
110
- ${color.gray("Git Flags (Advanced)")}
111
- ${git_flags}
112
-
113
- `);
114
- }
package/src/branch.ts DELETED
@@ -1,95 +0,0 @@
1
- #! /usr/bin/env node
2
-
3
- import Configstore from "configstore";
4
- import { chdir } from "process";
5
- import { InferOutput, ValiError, parse } from "valibot";
6
- import { BranchState, CommitState, Config } from "./valibot-state";
7
- import {
8
- load_setup,
9
- get_git_root,
10
- NOOP_PROMPT_CACHE,
11
- ConfigSource,
12
- } from "./utils";
13
- import { BranchRunnable } from "./prompts/branch-runnable";
14
- import { BranchCheckoutPrompt } from "./prompts/branch-checkout.prompt";
15
- import { BranchUserPrompt } from "./prompts/branch-user.prompt";
16
- import { BranchTypePrompt } from "./prompts/branch-type.prompt";
17
- import { BranchTicketPrompt } from "./prompts/branch-ticket.prompt";
18
- import { BranchVersionPrompt } from "./prompts/branch-version.prompt";
19
- import { BranchDescriptionPrompt } from "./prompts/branch-description.prompt";
20
- import { BranchConfirmPrompt } from "./prompts/branch-confirm.prompt";
21
- import { branch_flags } from "./branch-args";
22
- import { print_help_text } from "./branch-help";
23
- import { create_strict_branch_state } from "./utils/no-interactive-validation";
24
- import { get_package_version } from "./utils";
25
- import * as p from "@clack/prompts";
26
-
27
- type PromptCtor = new (
28
- config: InferOutput<typeof Config>,
29
- commit_state: InferOutput<typeof BranchState>,
30
- prompt_cache: Configstore,
31
- ) => BranchRunnable;
32
-
33
- const promptCtors: PromptCtor[] = [
34
- BranchCheckoutPrompt,
35
- BranchUserPrompt,
36
- BranchTypePrompt,
37
- BranchTicketPrompt,
38
- BranchVersionPrompt,
39
- BranchDescriptionPrompt,
40
- BranchConfirmPrompt,
41
- ];
42
-
43
- const { config, config_source } = load_setup(
44
- " better-branch ",
45
- branch_flags.git_args,
46
- );
47
-
48
- main(config, config_source);
49
-
50
- async function main(
51
- config: InferOutput<typeof Config>,
52
- config_source: ConfigSource,
53
- ) {
54
- chdir(get_git_root(branch_flags.git_args));
55
-
56
- if (branch_flags.version) {
57
- const version = get_package_version();
58
- p.log.step("Better Commits v" + version);
59
- return;
60
- }
61
-
62
- if (branch_flags.help) {
63
- print_help_text(config, config_source);
64
- return;
65
- }
66
-
67
- const branch_state = parse(BranchState, branch_flags.branch_state);
68
-
69
- if (!branch_flags.interactive) {
70
- try {
71
- parse(create_strict_branch_state(config), branch_state);
72
- } catch (err) {
73
- if (err instanceof ValiError) {
74
- p.log.error(`Invalid branch input: ${err.message}`);
75
- } else {
76
- p.log.error(`Failed to validate branch input: ${err}`);
77
- }
78
- process.exit(0);
79
- }
80
- }
81
-
82
- const prompt_cache = config.cache_last_value
83
- ? new Configstore("better-commits")
84
- : NOOP_PROMPT_CACHE;
85
- const prompts_to_run = branch_flags.interactive
86
- ? promptCtors
87
- : [BranchConfirmPrompt];
88
- for (const Prompt of prompts_to_run) {
89
- await new Prompt(config, branch_state, prompt_cache).run();
90
- }
91
- }
92
-
93
- // TODO: No idea what's happening here
94
- // If you don't use CommitState, (even in unreachable code), parse fails on Config
95
- CommitState;
package/src/git.ts DELETED
@@ -1,60 +0,0 @@
1
- #! /usr/bin/env node
2
- import { execSync } from "child_process";
3
- import * as p from "@clack/prompts";
4
- import color from "picocolors";
5
- import { flags } from "./args";
6
-
7
- const porcelain_states = ["M", "T", "R", "D", "A", "C"];
8
-
9
- export function git_status(): { index: string[]; work_tree: string[] } {
10
- let status = "";
11
- try {
12
- status = execSync(`git ${flags.git_args} status --porcelain`, {
13
- stdio: "pipe",
14
- }).toString();
15
- } catch (err) {
16
- p.log.error(color.red("Failed to git status" + err));
17
- return { index: [], work_tree: [] };
18
- }
19
-
20
- const lines = status.split("\n");
21
- const work_tree: string[] = [];
22
- const index: string[] = [];
23
- lines.forEach((v) => {
24
- const line = v.trimEnd();
25
- if (!line) return;
26
-
27
- const path_plus_file = line.substring(2).trim();
28
- const first_char = line.charAt(0).trim();
29
- const second_char = line.charAt(1).trim();
30
-
31
- // Untracked, always dirty
32
- if (first_char === "?" || second_char === "?") {
33
- work_tree.push(path_plus_file);
34
- }
35
-
36
- if (porcelain_states.includes(first_char)) {
37
- index.push(path_plus_file);
38
- }
39
-
40
- if (porcelain_states.includes(second_char)) {
41
- work_tree.push(path_plus_file);
42
- }
43
- });
44
-
45
- return { index, work_tree };
46
- }
47
-
48
- export function git_add(files: string[]) {
49
- const space_delimited_files = files.join(" ");
50
- if (space_delimited_files) {
51
- try {
52
- execSync(`git ${flags.git_args} add ${space_delimited_files}`, {
53
- stdio: "pipe",
54
- }).toString();
55
- p.log.success(color.green("Changes successfully staged"));
56
- } catch (err) {
57
- p.log.error(color.red("Failed to stage changes"));
58
- }
59
- }
60
- }
package/src/help.ts DELETED
@@ -1,131 +0,0 @@
1
- import { execSync } from "child_process";
2
- import { InferOutput } from "valibot";
3
- import { flags } from "./args";
4
- import { get_package_version } from "./utils";
5
- import { infer_ticket_from_git, infer_type_from_git } from "./utils/infer";
6
- import { Config } from "./valibot-state";
7
- import color from "picocolors";
8
-
9
- const ADDITIONAL_COMMAND_DEFINITIONS: Record<string, string> = {
10
- "better-branch": "Create a branch or worktree from a guided prompt flow.",
11
- "better-commits-init":
12
- "Create a .better-commits.json config in this repository.",
13
- };
14
-
15
- const CLI_FLAG_DEFINITIONS: Record<string, string> = {
16
- "--interactive": "Run in interactive prompt mode (default behavior).",
17
- "--dry-run": "Print the commit command without creating a commit.",
18
- "--help": "Show help information and exit.",
19
- };
20
-
21
- const COMMIT_FLAG_DEFINITIONS: Record<string, string> = {
22
- "--type": "Set commit type (for example feat, fix, docs).",
23
- "--scope": "Set commit scope.",
24
- "--title": "Set commit title/description.",
25
- "--body": "Set commit body text.",
26
- "--closes": "Set issue/ticket id for a closes footer.",
27
- "--ticket": "Set ticket value used in the title.",
28
- "--trailer": "Set trailer footer value.",
29
- "--deprecates": "Set issue/ticket id for a deprecates footer.",
30
- "--breaking-title": "Set breaking-change title footer.",
31
- "--breaking-body": "Set breaking-change body footer.",
32
- "--deprecates-title": "Set deprecates footer title text.",
33
- "--deprecates-body": "Set deprecates footer body text.",
34
- "--custom-footer": "Set a custom footer line.",
35
- };
36
-
37
- const GIT_FLAG_DEFINITIONS: Record<string, string> = {
38
- "--git-dir": "Set the path to the .git directory.",
39
- "--work-tree": "Set the path to the working tree root.",
40
- };
41
-
42
- function to_definition_lines(definitions: Record<string, string>): string {
43
- const description_column = 26;
44
- const minimum_spacing = 2;
45
- const indent = " ";
46
-
47
- return Object.entries(definitions)
48
- .map(([name, description]) => {
49
- const spaces = Math.max(
50
- minimum_spacing,
51
- description_column - name.length,
52
- );
53
- return `${indent}${name}${" ".repeat(spaces)}${description}`;
54
- })
55
- .join("\n");
56
- }
57
-
58
- export function print_help_text(
59
- config: InferOutput<typeof Config>,
60
- config_source: "repository" | "global" | "none",
61
- ) {
62
- const version = get_package_version();
63
-
64
- let branch = "(none)";
65
- try {
66
- branch =
67
- execSync(`git ${flags.git_args} branch --show-current`, { stdio: "pipe" })
68
- .toString()
69
- .trim() || "(none)";
70
- } catch {
71
- // noop
72
- }
73
-
74
- const inferred_type =
75
- infer_type_from_git(config.commit_type.options, flags.git_args) ||
76
- "Unknown";
77
- const inferred_ticket = config.check_ticket.infer_ticket
78
- ? infer_ticket_from_git(
79
- {
80
- append_hashtag: config.check_ticket.append_hashtag,
81
- prepend_hashtag: config.check_ticket.prepend_hashtag,
82
- },
83
- flags.git_args,
84
- ) || "Unknown"
85
- : "Infer Disabled";
86
-
87
- const types = config.commit_type.options
88
- .map((option) => option.value)
89
- .join(", ")
90
- .trim();
91
- const scopes = config.commit_scope.options
92
- .map((option) => option.value)
93
- .join(", ")
94
- .trim();
95
- const cli_flags = to_definition_lines(CLI_FLAG_DEFINITIONS);
96
- const git_flags = to_definition_lines(GIT_FLAG_DEFINITIONS);
97
- const commit_flags = to_definition_lines(COMMIT_FLAG_DEFINITIONS);
98
- const additional_commands = to_definition_lines(
99
- ADDITIONAL_COMMAND_DEFINITIONS,
100
- );
101
-
102
- console.log(`
103
- ${color.green(" better-commits")} ${color.gray("v" + version)}
104
-
105
- ${color.gray("BRANCH")}
106
- ${branch}
107
- ${color.gray("Type")} ${color.blue(inferred_type)} ${color.gray("·")} ${color.gray("Ticket")} ${color.magenta(inferred_ticket)}
108
-
109
- ${color.gray("CONFIGURATION")}
110
- ${config_source}
111
-
112
- ${color.gray("Types")}
113
- ${types}
114
-
115
- ${color.gray("Scopes")}
116
- ${scopes}
117
-
118
- ${color.gray("CLI FLAGS")}
119
- ${cli_flags}
120
-
121
- ${color.gray("Commit Flags")}
122
- ${commit_flags}
123
-
124
- ${color.gray("Git Flags (Advanced)")}
125
- ${git_flags}
126
-
127
- ${color.gray("ADDITIONAL COMMANDS")}
128
- ${additional_commands}
129
-
130
- `);
131
- }
package/src/index.test.ts DELETED
@@ -1,7 +0,0 @@
1
- import { describe, expect, it } from "vitest";
2
-
3
- describe("project test setup", () => {
4
- it("runs Vitest in this TypeScript project", () => {
5
- expect(true).toBe(true);
6
- });
7
- });
package/src/index.ts DELETED
@@ -1,100 +0,0 @@
1
- #! /usr/bin/env node
2
-
3
- import { chdir } from "process";
4
- import * as p from "@clack/prompts";
5
- import { InferInput, InferOutput, ValiError, parse } from "valibot";
6
- import { CommitState, Config } from "./valibot-state";
7
- import {
8
- load_setup,
9
- get_git_root,
10
- NOOP_PROMPT_CACHE,
11
- ConfigSource,
12
- } from "./utils";
13
- import { create_strict_commit_state } from "./utils/no-interactive-validation";
14
- import Configstore from "configstore";
15
- import { CommitTypePrompt } from "./prompts/commit-type.prompt";
16
- import { Runnable } from "./prompts/runnable";
17
- import { CommitScopePrompt } from "./prompts/commit-scope.prompt";
18
- import { CommitTicketPrompt } from "./prompts/commit-ticket.prompt";
19
- import { CommitTitlePrompt } from "./prompts/commit-title.prompt";
20
- import { CommitBodyPrompt } from "./prompts/commit-body.prompt";
21
- import { CommitFooterPrompt } from "./prompts/commit-footer.prompt";
22
- import { CommitConfirmPrompt } from "./prompts/commit-confirm.prompt";
23
- import { CommitStatusPrompt } from "./prompts/commit-status.prompt";
24
- import { flags } from "./args";
25
- import { get_package_version } from "./utils";
26
- import { infer_not_interactive } from "./utils/infer";
27
- import { print_help_text } from "./help";
28
-
29
- type PromptCtor = new (
30
- config: InferOutput<typeof Config>,
31
- commit_state: InferOutput<typeof CommitState>,
32
- prompt_cache: Configstore,
33
- ) => Runnable;
34
-
35
- const promptCtors: PromptCtor[] = [
36
- CommitStatusPrompt,
37
- CommitTypePrompt,
38
- CommitScopePrompt,
39
- CommitTicketPrompt,
40
- CommitTitlePrompt,
41
- CommitBodyPrompt,
42
- CommitFooterPrompt,
43
- CommitConfirmPrompt,
44
- ];
45
-
46
- const { config, config_source } = load_setup();
47
-
48
- main(config, config_source);
49
-
50
- export async function main(
51
- config: InferOutput<typeof Config>,
52
- config_source: ConfigSource,
53
- ) {
54
- chdir(get_git_root());
55
-
56
- if (flags.version) {
57
- const version = get_package_version();
58
- p.log.step("Better Commits v" + version);
59
- return;
60
- }
61
-
62
- if (flags.help) {
63
- print_help_text(config, config_source);
64
- return;
65
- }
66
-
67
- const infer_state = infer_not_interactive(config);
68
- const flags_plus_infer: InferInput<typeof CommitState> = {
69
- ...flags.commit_state,
70
- type: (flags.commit_state.type || infer_state?.type) ?? "",
71
- ticket: (flags.commit_state.ticket || infer_state?.ticket) ?? "",
72
- };
73
-
74
- const commit_state = parse(CommitState, flags_plus_infer);
75
-
76
- if (!flags.interactive) {
77
- try {
78
- parse(create_strict_commit_state(config), commit_state);
79
- } catch (err) {
80
- if (err instanceof ValiError) {
81
- p.log.error(`Invalid --no-interactive commit input: ${err.message}`);
82
- } else {
83
- p.log.error(`Failed to validate --no-interactive commit input: ${err}`);
84
- }
85
- process.exit(0);
86
- }
87
- }
88
-
89
- const prompt_cache = config.cache_last_value
90
- ? new Configstore("better-commits")
91
- : NOOP_PROMPT_CACHE;
92
-
93
- const prompts_to_run = flags.interactive
94
- ? promptCtors
95
- : [CommitConfirmPrompt];
96
-
97
- for (const Prompt of prompts_to_run) {
98
- await new Prompt(config, commit_state, prompt_cache).run();
99
- }
100
- }
package/src/init.ts DELETED
@@ -1,25 +0,0 @@
1
- #! /usr/bin/env node
2
-
3
- import * as p from "@clack/prompts";
4
- import fs from "fs";
5
- import color from "picocolors";
6
- import { parse } from "valibot";
7
- import { CONFIG_FILE_NAME, get_git_root } from "./utils";
8
- import { Config } from "./valibot-state";
9
-
10
- try {
11
- console.clear();
12
- p.intro(`${color.bgCyan(color.black(" better-commits-init "))}`);
13
- const root = get_git_root();
14
- const root_path = `${root}/${CONFIG_FILE_NAME}`;
15
- const default_config = parse(Config, {});
16
- fs.writeFileSync(root_path, JSON.stringify(default_config, null, 4));
17
- p.log.success(`${color.green("Successfully created .better-commits.json")}`);
18
- p.outro(
19
- `Run ${color.bgBlack(color.white("better-commits"))} to start the CLI`,
20
- );
21
- } catch (err: any) {
22
- p.log.error(
23
- `${color.red("Could not determine git root folder. better-commits-init must be used in a git repository")}`,
24
- );
25
- }
@@ -1,36 +0,0 @@
1
- import { InferOutput } from "valibot";
2
- import { BranchRunnable } from "./branch-runnable";
3
- import { V_BRANCH_ACTIONS } from "../valibot-consts";
4
- import * as p from "@clack/prompts";
5
- import { BRANCH_ACTION_OPTIONS } from "../utils";
6
-
7
- export class BranchCheckoutPrompt extends BranchRunnable {
8
- async run(): Promise<void> {
9
- if (this.#is_enabled) {
10
- const branch_or_worktree = await p.select({
11
- message: this.#message,
12
- initialValue: this.#initival_values,
13
- options: BRANCH_ACTION_OPTIONS,
14
- });
15
-
16
- if (p.isCancel(branch_or_worktree)) process.exit();
17
- this.#post_run_effects(branch_or_worktree);
18
- }
19
- }
20
-
21
- get #message() {
22
- return `Checkout a branch or create a worktree?`;
23
- }
24
-
25
- get #is_enabled() {
26
- return this.config.worktrees.enable;
27
- }
28
-
29
- get #initival_values() {
30
- return this.branch_state.checkout || this.config.branch_action_default;
31
- }
32
-
33
- #post_run_effects(value: InferOutput<typeof V_BRANCH_ACTIONS>) {
34
- this.branch_state.checkout = value;
35
- }
36
- }