better-commits 1.20.1-temp.0 → 1.22.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 (62) hide show
  1. package/.better-commits.json +52 -0
  2. package/.github/workflows/publish.yml +34 -0
  3. package/.github/workflows/test.yml +27 -0
  4. package/.prettierignore +5 -0
  5. package/.prettierrc +1 -0
  6. package/dist/branch.js +4 -4
  7. package/dist/{chunk-LPU7O52G.js → chunk-5EGZQSNM.js} +1 -1
  8. package/dist/{chunk-QPUTIRGU.js → chunk-F4EBQBBK.js} +13 -6
  9. package/dist/index.js +28 -24
  10. package/dist/init.js +1 -1
  11. package/package.json +2 -7
  12. package/readme.md +6 -1
  13. package/src/args.test.ts +102 -0
  14. package/src/args.ts +106 -0
  15. package/src/branch-args.test.ts +72 -0
  16. package/src/branch-args.ts +106 -0
  17. package/src/branch-help.ts +114 -0
  18. package/src/branch.ts +95 -0
  19. package/src/default-config-template.ts +249 -0
  20. package/src/git.ts +60 -0
  21. package/src/help.ts +131 -0
  22. package/src/index.test.ts +7 -0
  23. package/src/index.ts +100 -0
  24. package/src/init.test.ts +123 -0
  25. package/src/init.ts +46 -0
  26. package/src/prompts/autocomplete-multiselect.ts +232 -0
  27. package/src/prompts/branch-checkout.prompt.ts +36 -0
  28. package/src/prompts/branch-confirm.prompt.ts +134 -0
  29. package/src/prompts/branch-description.prompt.ts +37 -0
  30. package/src/prompts/branch-runnable.ts +13 -0
  31. package/src/prompts/branch-ticket.prompt.ts +41 -0
  32. package/src/prompts/branch-type.prompt.ts +46 -0
  33. package/src/prompts/branch-user.prompt.ts +50 -0
  34. package/src/prompts/branch-version.prompt.ts +41 -0
  35. package/src/prompts/commit-body.prompt.ts +57 -0
  36. package/src/prompts/commit-confirm.prompt.ts +119 -0
  37. package/src/prompts/commit-footer.prompt.ts +195 -0
  38. package/src/prompts/commit-scope.prompt.ts +76 -0
  39. package/src/prompts/commit-status.prompt.ts +78 -0
  40. package/src/prompts/commit-ticket.prompt.ts +82 -0
  41. package/src/prompts/commit-title.prompt.ts +98 -0
  42. package/src/prompts/commit-type.prompt.ts +96 -0
  43. package/src/prompts/runnable.ts +13 -0
  44. package/src/utils/build-branch.test.ts +141 -0
  45. package/src/utils/build-branch.ts +46 -0
  46. package/src/utils/build-commit-string.test.ts +253 -0
  47. package/src/utils/build-commit-string.ts +158 -0
  48. package/src/utils/commit-title-size.ts +24 -0
  49. package/src/utils/infer.test.ts +83 -0
  50. package/src/utils/infer.ts +114 -0
  51. package/src/utils/messages.ts +25 -0
  52. package/src/utils/no-interactive-branch-validation.test.ts +170 -0
  53. package/src/utils/no-interactive-validation.test.ts +174 -0
  54. package/src/utils/no-interactive-validation.ts +190 -0
  55. package/src/utils.test.ts +164 -0
  56. package/src/utils.ts +235 -0
  57. package/src/valibot-consts.ts +114 -0
  58. package/src/valibot-state.test.ts +48 -0
  59. package/src/valibot-state.ts +266 -0
  60. package/tsconfig.json +15 -0
  61. package/tsup.config.ts +12 -0
  62. package/vitest.config.ts +8 -0
@@ -0,0 +1,52 @@
1
+ {
2
+ "commit_type": {
3
+ "append_emoji_to_label": true,
4
+ "append_emoji_to_commit": false
5
+ },
6
+ "commit_body": {
7
+ "split_by_period": true
8
+ },
9
+ "commit_scope": {
10
+ "enable": true,
11
+ "initial_value": "commit",
12
+ "options": [
13
+ {
14
+ "value": "commit",
15
+ "label": "commit"
16
+ },
17
+ {
18
+ "value": "branch",
19
+ "label": "branch"
20
+ },
21
+ {
22
+ "value": "init",
23
+ "label": "init"
24
+ },
25
+ {
26
+ "value": "util",
27
+ "label": "util"
28
+ },
29
+ {
30
+ "value": "build",
31
+ "label": "build"
32
+ },
33
+ {
34
+ "value": "help",
35
+ "label": "help"
36
+ },
37
+ {
38
+ "value": "",
39
+ "label": "none"
40
+ }
41
+ ]
42
+ },
43
+ "check_ticket": {
44
+ "prepend_hashtag": "Always"
45
+ },
46
+ "branch_pre_commands": [
47
+ "git stash",
48
+ "git checkout main",
49
+ "git pull -r origin main",
50
+ "npm install"
51
+ ]
52
+ }
@@ -0,0 +1,34 @@
1
+ name: Publish to NPM
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+
8
+ jobs:
9
+ publish:
10
+ name: Publish
11
+ runs-on: ubuntu-latest
12
+ permissions:
13
+ contents: write
14
+ issues: write
15
+ pull-requests: write
16
+ id-token: write
17
+ steps:
18
+ - name: Checkout
19
+ uses: actions/checkout@v4
20
+ with:
21
+ fetch-depth: 0
22
+ - name: Setup Node.js
23
+ uses: actions/setup-node@v4
24
+ with:
25
+ node-version: "lts/*"
26
+ registry-url: "https://registry.npmjs.org"
27
+ - name: Install dependencies
28
+ run: npm ci
29
+ - name: Build package
30
+ run: npm run build
31
+ - name: Release
32
+ env:
33
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
34
+ run: npx semantic-release
@@ -0,0 +1,27 @@
1
+ name: Test
2
+
3
+ on:
4
+ pull_request:
5
+ push:
6
+ branches:
7
+ - main
8
+
9
+ jobs:
10
+ test:
11
+ name: npm test
12
+ runs-on: ubuntu-latest
13
+ steps:
14
+ - name: Checkout
15
+ uses: actions/checkout@v4
16
+
17
+ - name: Setup Node.js
18
+ uses: actions/setup-node@v4
19
+ with:
20
+ node-version: "lts/*"
21
+ cache: npm
22
+
23
+ - name: Install dependencies
24
+ run: npm ci
25
+
26
+ - name: Run tests
27
+ run: npm run test
@@ -0,0 +1,5 @@
1
+ # Ignore artifacts:
2
+ build
3
+ coverage
4
+ node_modules
5
+ dist
package/.prettierrc ADDED
@@ -0,0 +1 @@
1
+ {}
package/dist/branch.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #! /usr/bin/env node
2
- import{c as V,e as H,f as D,i as h}from"./chunk-LPU7O52G.js";import{e as T,j as A,k as F,l as E,m as u,o as _,r as G,s as L}from"./chunk-QPUTIRGU.js";import at from"configstore";import{chdir as ct}from"process";import{ValiError as pt,parse as U}from"valibot";var a=class{constructor(t,r,n){this.config=t;this.branch_state=r;this.prompt_cache=n}};import*as l from"@clack/prompts";var f=class extends a{async run(){if(this.#e){let t=await l.select({message:this.#t,initialValue:this.#r,options:A});l.isCancel(t)&&process.exit(),this.#n(t)}}get#t(){return"Checkout a branch or create a worktree?"}get#e(){return this.config.worktrees.enable}get#r(){return this.branch_state.checkout||this.config.branch_action_default}#n(t){this.branch_state.checkout=t}};import*as b from"@clack/prompts";var d=class extends a{async run(){if(!this.#t)return;let t=await b.text({message:this.#r,placeholder:"",initialValue:this.#n,validate:r=>this.#i(r)});b.isCancel(t)&&process.exit(0),this.#o(t??"")}get#t(){return this.config.branch_user.enable}get#e(){return this.config.branch_user.required}get#r(){return this.#e?"Type your git username":h("Type your git username")}get#n(){return this.branch_state.user||G(this.prompt_cache,"username")}#i(t){if(this.#e&&!t)return"Please enter a username"}#o(t){this.branch_state.user=t.replace(/\s+/g,"-").toLowerCase(),L(this.prompt_cache,"username",this.branch_state.user)}};import*as v from"@clack/prompts";var y=class extends a{async run(){if(!this.#t)return;let t=await v.select({message:this.#e,initialValue:this.#r,options:this.#n});v.isCancel(t)&&process.exit(0),this.#i(t)}get#t(){return this.config.branch_type.enable}get#e(){return"Select a branch type"}get#r(){return this.branch_state.type||this.config.commit_type.initial_value}get#n(){return this.config.commit_type.options}#i(t){this.branch_state.type=t}};import*as w from"@clack/prompts";var k=class extends a{async run(){if(!this.#t)return;let t=await w.text({message:this.#r,placeholder:"",validate:r=>this.#n(r),initialValue:this.branch_state.ticket});w.isCancel(t)&&process.exit(0),this.#i(t??"")}get#t(){return this.config.branch_ticket.enable}get#e(){return this.config.branch_ticket.required}get#r(){return this.#e?"Type ticket / issue number":h("Type ticket / issue number")}#n(t){if(this.#e&&!t)return"Please enter a ticket / issue"}#i(t){this.branch_state.ticket=t}};import*as C from"@clack/prompts";var x=class extends a{async run(){if(!this.#t)return;let t=await C.text({message:this.#r,placeholder:"",validate:r=>this.#n(r),initialValue:this.branch_state.version});C.isCancel(t)&&process.exit(0),this.#i(t??"")}get#t(){return this.config.branch_version.enable}get#e(){return this.config.branch_version.required}get#r(){return this.#e?"Type version number":h("Type version number")}#n(t){if(this.#e&&!t)return"Please enter a version"}#i(t){this.branch_state.version=t}};import*as I from"@clack/prompts";var $=class extends a{async run(){let t=await I.text({message:this.#t,placeholder:"",validate:r=>this.#r(r),initialValue:this.branch_state.description});I.isCancel(t)&&process.exit(0),this.#n(t??"")}get#t(){return"Type a short description"}get#e(){return this.config.branch_description.max_length}#r(t){if(!t)return"Please enter a description";if(t.length>this.#e)return`Exceeded max length. Description max [${this.#e}]`}#n(t){this.branch_state.description=t.replace(/\s+/g,"-").toLowerCase()}};import*as m from"@clack/prompts";import{execSync as S}from"child_process";import p from"picocolors";import{chdir as rt}from"process";import{parse as X}from"@bomb.sh/args";var q=["user","type","description","ticket","branch-version","checkout"],Y=["git-dir","work-tree"],Z=["interactive","dry-run","help","version"],P=class{#t;constructor(t){this.#t=t}get interactive(){return!this.#t.no_interactive}get dry_run(){return this.#t.dry_run}get help(){return this.#t.help}get version(){return this.#t.version}get git_args(){return this.#t.git_args}get branch_state(){return this.#t.branch_state}},s=new P(tt(process.argv.slice(2)));function tt(e){let t=X(e,{alias:{h:"help",v:"version"},boolean:Z,string:[...q,...Y]}),r={};return q.forEach(n=>{let i=t[n];if(i){let o=n==="branch-version"?"version":n.replace("-","_");o==="checkout"?r[o]=i??"branch":r[o]=i}}),{help:t.help===!0,version:t.version===!0,git_args:et(t["git-dir"],t["work-tree"]),no_interactive:t.interactive===!1,dry_run:t["dry-run"]===!0,branch_state:r}}function et(e,t){return`${e?`--git-dir=${e}`:""} ${t?`--work-tree=${t}`:""}`.trim()}function j(e,t){let r="";return t.branch_order.forEach(n=>{let i=`branch_${n}`;e[n]&&(r+=e[n]+t[i].separator)}),r.endsWith("-")||r.endsWith("/")||r.endsWith("_")?r.slice(0,-1).trim():r.trim()}function W(e,t,r){let n=r.split("/").pop()||"repo",i=t.worktrees.folder_template;i=i.replace("{{repo_name}}",n).replace("{{branch_description}}",e.description).replace("{{user}}",e.user||"").replace("{{type}}",e.type||"").replace("{{ticket}}",e.ticket||"").replace("{{version}}",e.version||""),i=i.replace(/\s/g,"").replace(/--+/g,"-").replace(/^-+|-+$/g,"");let o=t.worktrees.base_path;return`${o}${o.endsWith("/")?"":"/"}${i}`}var g=class extends a{async run(){this.#i(),this.#o(),this.#a()}get#t(){return this.branch_state.checkout==="worktree"}get#e(){return this.#t?this.config.worktree_pre_commands:this.config.branch_pre_commands}get#r(){return this.#t?this.config.worktree_post_commands:this.config.branch_post_commands}get#n(){return j(this.branch_state,this.config)}#i(){this.#s(this.#e,"Something went wrong when executing pre-commands: ")}#o(){let t=this.#n,r=this.#c(t);if(!this.#t){try{S(`git ${s.git_args} checkout ${r} ${t}`,{stdio:"inherit"}),m.log.info(`Switched to a new branch '${p.bgGreen(" "+p.black(t)+" ")}'`)}catch{process.exit(0)}return}try{let n=W(this.branch_state,this.config,u(s.git_args));S(`git ${s.git_args} worktree add ${n} ${r} ${t}`,{stdio:"inherit"}),m.log.info(`Created a new worktree ${p.bgGreen(" "+p.black(n)+" ")}, checked out branch ${p.bgGreen(" "+p.black(t)+" ")}`),m.log.info(p.bgMagenta(p.black(` cd ${n} `))+" to navigate to your new worktree"),rt(n)}catch{process.exit(0)}}#a(){this.#s(this.#r,"Something went wrong when executing post-commands: ")}#s(t,r){t.forEach(n=>{try{S(n,{stdio:"inherit"})}catch(i){m.log.error(r+i),process.exit(0)}})}#c(t){let r="";try{S(`git ${s.git_args} show-ref ${t}`,{encoding:"utf-8"}),m.log.warning(p.yellow(`${t} already exists! Checking out existing branch.`))}catch{r="-b"}return r}};import{execSync as nt}from"child_process";import c from"picocolors";var it={"--interactive":"Run in interactive prompt mode (default behavior).","--dry-run":"Print branch commands without creating a branch or worktree.","--help":"Show help information and exit."},ot={"--user":"Set branch username segment.","--type":"Set branch type (for example feat, fix, docs).","--description":"Set branch description segment.","--ticket":"Set branch ticket/issue segment.","--branch-version":"Set branch version segment.","--checkout":"Choose branch or worktree checkout mode."},st={"--git-dir":"Set the path to the .git directory.","--work-tree":"Set the path to the working tree root."};function N(e){let n=" ";return Object.entries(e).map(([i,o])=>{let B=Math.max(2,26-i.length);return`${n}${i}${" ".repeat(B)}${o}`}).join(`
3
- `)}function M(e,t){let r=_(),n="(none)";try{n=nt(`git ${s.git_args} branch --show-current`,{stdio:"pipe"}).toString().trim()||"(none)"}catch{}let i=H(e.commit_type.options,s.git_args)||"Unknown",o=e.check_ticket.infer_ticket?D({append_hashtag:e.check_ticket.append_hashtag,prepend_hashtag:e.check_ticket.prepend_hashtag},s.git_args)||"Unknown":"Infer Disabled",B=e.commit_type.options.map(R=>R.value).join(", ").trim(),z=e.commit_scope.options.map(R=>R.value).join(", ").trim(),J=N(it),K=N(st),Q=N(ot);console.log(`
4
- ${c.green("\uF489 better-branch")} ${c.gray("v"+r)}
2
+ import{c as V,e as H,f as D,i as h}from"./chunk-5EGZQSNM.js";import{e as T,j as A,k as F,l as E,m as _,o as f,r as G,s as L}from"./chunk-F4EBQBBK.js";import at from"configstore";import{chdir as ct}from"process";import{ValiError as pt,parse as U}from"valibot";var a=class{constructor(t,e,n){this.config=t;this.branch_state=e;this.prompt_cache=n}};import*as d from"@clack/prompts";var l=class extends a{async run(){if(this.#e){let t=await d.select({message:this.#t,initialValue:this.#r,options:A});d.isCancel(t)&&process.exit(),this.#n(t)}}get#t(){return"Checkout a branch or create a worktree?"}get#e(){return this.config.worktrees.enable}get#r(){return this.branch_state.checkout||this.config.branch_action_default}#n(t){this.branch_state.checkout=t}};import*as y from"@clack/prompts";var b=class extends a{async run(){if(!this.#t)return;let t=await y.text({message:this.#r,placeholder:"",initialValue:this.#n,validate:e=>this.#i(e)});y.isCancel(t)&&process.exit(0),this.#o(t??"")}get#t(){return this.config.branch_user.enable}get#e(){return this.config.branch_user.required}get#r(){return this.#e?"Type your git username":h("Type your git username")}get#n(){return this.branch_state.user||G(this.prompt_cache,"username")}#i(t){if(this.#e&&!t)return"Please enter a username"}#o(t){this.branch_state.user=t.replace(/\s+/g,"-").toLowerCase(),L(this.prompt_cache,"username",this.branch_state.user)}};import*as m from"@clack/prompts";var v=class extends a{async run(){if(!this.#t)return;let e=await(this.config.branch_type.autocomplete?m.autocomplete:m.select)({message:this.#e,initialValue:this.#r,options:this.#n});m.isCancel(e)&&process.exit(0),this.#i(e)}get#t(){return this.config.branch_type.enable}get#e(){return"Select a branch type"}get#r(){return this.branch_state.type||this.config.commit_type.initial_value}get#n(){return this.config.commit_type.options}#i(t){this.branch_state.type=t}};import*as w from"@clack/prompts";var k=class extends a{async run(){if(!this.#t)return;let t=await w.text({message:this.#r,placeholder:"",validate:e=>this.#n(e),initialValue:this.branch_state.ticket});w.isCancel(t)&&process.exit(0),this.#i(t??"")}get#t(){return this.config.branch_ticket.enable}get#e(){return this.config.branch_ticket.required}get#r(){return this.#e?"Type ticket / issue number":h("Type ticket / issue number")}#n(t){if(this.#e&&!t)return"Please enter a ticket / issue"}#i(t){this.branch_state.ticket=t}};import*as C from"@clack/prompts";var x=class extends a{async run(){if(!this.#t)return;let t=await C.text({message:this.#r,placeholder:"",validate:e=>this.#n(e),initialValue:this.branch_state.version});C.isCancel(t)&&process.exit(0),this.#i(t??"")}get#t(){return this.config.branch_version.enable}get#e(){return this.config.branch_version.required}get#r(){return this.#e?"Type version number":h("Type version number")}#n(t){if(this.#e&&!t)return"Please enter a version"}#i(t){this.branch_state.version=t}};import*as I from"@clack/prompts";var $=class extends a{async run(){let t=await I.text({message:this.#t,placeholder:"",validate:e=>this.#r(e),initialValue:this.branch_state.description});I.isCancel(t)&&process.exit(0),this.#n(t??"")}get#t(){return"Type a short description"}get#e(){return this.config.branch_description.max_length}#r(t){if(!t)return"Please enter a description";if(t.length>this.#e)return`Exceeded max length. Description max [${this.#e}]`}#n(t){this.branch_state.description=t.replace(/\s+/g,"-").toLowerCase()}};import*as g from"@clack/prompts";import{execSync as S}from"child_process";import p from"picocolors";import{chdir as rt}from"process";import{parse as X}from"@bomb.sh/args";var q=["user","type","description","ticket","branch-version","checkout"],Y=["git-dir","work-tree"],Z=["interactive","dry-run","help","version"],P=class{#t;constructor(t){this.#t=t}get interactive(){return!this.#t.no_interactive}get dry_run(){return this.#t.dry_run}get help(){return this.#t.help}get version(){return this.#t.version}get git_args(){return this.#t.git_args}get branch_state(){return this.#t.branch_state}},s=new P(tt(process.argv.slice(2)));function tt(r){let t=X(r,{alias:{h:"help",v:"version"},boolean:Z,string:[...q,...Y]}),e={};return q.forEach(n=>{let i=t[n];if(i){let o=n==="branch-version"?"version":n.replace("-","_");o==="checkout"?e[o]=i??"branch":e[o]=i}}),{help:t.help===!0,version:t.version===!0,git_args:et(t["git-dir"],t["work-tree"]),no_interactive:t.interactive===!1,dry_run:t["dry-run"]===!0,branch_state:e}}function et(r,t){return`${r?`--git-dir=${r}`:""} ${t?`--work-tree=${t}`:""}`.trim()}function j(r,t){let e="";return t.branch_order.forEach(n=>{let i=`branch_${n}`;r[n]&&(e+=r[n]+t[i].separator)}),e.endsWith("-")||e.endsWith("/")||e.endsWith("_")?e.slice(0,-1).trim():e.trim()}function W(r,t,e){let n=e.split("/").pop()||"repo",i=t.worktrees.folder_template;i=i.replace("{{repo_name}}",n).replace("{{branch_description}}",r.description).replace("{{user}}",r.user||"").replace("{{type}}",r.type||"").replace("{{ticket}}",r.ticket||"").replace("{{version}}",r.version||""),i=i.replace(/\s/g,"").replace(/--+/g,"-").replace(/^-+|-+$/g,"");let o=t.worktrees.base_path;return`${o}${o.endsWith("/")?"":"/"}${i}`}var u=class extends a{async run(){this.#i(),this.#o(),this.#a()}get#t(){return this.branch_state.checkout==="worktree"}get#e(){return this.#t?this.config.worktree_pre_commands:this.config.branch_pre_commands}get#r(){return this.#t?this.config.worktree_post_commands:this.config.branch_post_commands}get#n(){return j(this.branch_state,this.config)}#i(){this.#s(this.#e,"Something went wrong when executing pre-commands: ")}#o(){let t=this.#n,e=this.#c(t);if(!this.#t){try{S(`git ${s.git_args} checkout ${e} ${t}`,{stdio:"inherit"}),g.log.info(`Switched to a new branch '${p.bgGreen(" "+p.black(t)+" ")}'`)}catch{process.exit(0)}return}try{let n=W(this.branch_state,this.config,_(s.git_args));S(`git ${s.git_args} worktree add ${n} ${e} ${t}`,{stdio:"inherit"}),g.log.info(`Created a new worktree ${p.bgGreen(" "+p.black(n)+" ")}, checked out branch ${p.bgGreen(" "+p.black(t)+" ")}`),g.log.info(p.bgMagenta(p.black(` cd ${n} `))+" to navigate to your new worktree"),rt(n)}catch{process.exit(0)}}#a(){this.#s(this.#r,"Something went wrong when executing post-commands: ")}#s(t,e){t.forEach(n=>{try{S(n,{stdio:"inherit"})}catch(i){g.log.error(e+i),process.exit(0)}})}#c(t){let e="";try{S(`git ${s.git_args} show-ref ${t}`,{encoding:"utf-8"}),g.log.warning(p.yellow(`${t} already exists! Checking out existing branch.`))}catch{e="-b"}return e}};import{execSync as nt}from"child_process";import c from"picocolors";var it={"--interactive":"Run in interactive prompt mode (default behavior).","--dry-run":"Print branch commands without creating a branch or worktree.","--help":"Show help information and exit."},ot={"--user":"Set branch username segment.","--type":"Set branch type (for example feat, fix, docs).","--description":"Set branch description segment.","--ticket":"Set branch ticket/issue segment.","--branch-version":"Set branch version segment.","--checkout":"Choose branch or worktree checkout mode."},st={"--git-dir":"Set the path to the .git directory.","--work-tree":"Set the path to the working tree root."};function N(r){let n=" ";return Object.entries(r).map(([i,o])=>{let B=Math.max(2,26-i.length);return`${n}${i}${" ".repeat(B)}${o}`}).join(`
3
+ `)}function M(r,t){let e=f(),n="(none)";try{n=nt(`git ${s.git_args} branch --show-current`,{stdio:"pipe"}).toString().trim()||"(none)"}catch{}let i=H(r.commit_type.options,s.git_args)||"Unknown",o=r.check_ticket.infer_ticket?D({append_hashtag:r.check_ticket.append_hashtag,prepend_hashtag:r.check_ticket.prepend_hashtag},s.git_args)||"Unknown":"Infer Disabled",B=r.commit_type.options.map(R=>R.value).join(", ").trim(),z=r.commit_scope.options.map(R=>R.value).join(", ").trim(),J=N(it),K=N(st),Q=N(ot);console.log(`
4
+ ${c.green("\uF489 better-branch")} ${c.gray("v"+e)}
5
5
 
6
6
  ${c.gray("BRANCH")}
7
7
  ${n}
@@ -25,4 +25,4 @@ ${Q}
25
25
  ${c.gray("Git Flags (Advanced)")}
26
26
  ${K}
27
27
 
28
- `)}import*as O from"@clack/prompts";var ht=[f,d,y,k,x,$,g],{config:mt,config_source:gt}=E(" better-branch ",s.git_args);ut(mt,gt);async function ut(e,t){if(ct(u(s.git_args)),s.version){let o=_();O.log.step("Better Commits v"+o);return}if(s.help){M(e,t);return}let r=U(T,s.branch_state);if(!s.interactive)try{U(V(e),r)}catch(o){o instanceof pt?O.log.error(`Invalid branch input: ${o.message}`):O.log.error(`Failed to validate branch input: ${o}`),process.exit(0)}let n=e.cache_last_value?new at("better-commits"):F,i=s.interactive?ht:[g];for(let o of i)await new o(e,r,n).run()}
28
+ `)}import*as O from"@clack/prompts";var ht=[l,b,v,k,x,$,u],{config:mt,config_source:gt}=E(" better-branch ",s.git_args);ut(mt,gt);async function ut(r,t){if(ct(_(s.git_args)),s.version){let o=f();O.log.step("Better Commits v"+o);return}if(s.help){M(r,t);return}let e=U(T,s.branch_state);if(!s.interactive)try{U(V(r),e)}catch(o){o instanceof pt?O.log.error(`Invalid branch input: ${o.message}`):O.log.error(`Failed to validate branch input: ${o}`),process.exit(0)}let n=r.cache_last_value?new at("better-commits"):F,i=s.interactive?ht:[u];for(let o of i)await new o(r,e,n).run()}
@@ -1 +1 @@
1
- import{b as m,d as u,f as p}from"./chunk-QPUTIRGU.js";import*as s from"valibot";function _(t,n){let i=t.scope?t.scope.length+2:0,e=t.type?.length??0,r=n.include_ticket?t.ticket?.length??0:0,c=t.title?.length??0;return i+e+r+c}function a(t){return t.map(i=>i===""?'"" (none)':`"${i}"`).join(", ")}function R(t){let n=t.commit_type.options.map(e=>e.value),i=t.commit_scope.options.map(e=>e.value);return s.pipe(s.object(m),s.rawCheck(({dataset:e,addIssue:r})=>{if(!e.typed)return;let c=e.value.type?`"${e.value.type}"`:"(empty)";e.value.type&&!n.includes(e.value.type)&&r({message:`Invalid --type ${c}. Valid types: ${a(n)}.`})}),s.rawCheck(({dataset:e,addIssue:r})=>{if(!e.typed)return;let c=e.value.scope?`"${e.value.scope}"`:"(empty)";e.value.scope&&!t.commit_scope.custom_scope&&!i.includes(e.value.scope)&&r({message:`Invalid --scope ${c}. Valid scopes: ${a(i)}.`})}),s.rawCheck(({dataset:e,addIssue:r})=>{!e.typed||e.value.title.trim()||r({message:"Missing --title. Provide a non-empty commit title."})}),s.rawCheck(({dataset:e,addIssue:r})=>{if(!e.typed)return;let c=_(e.value,{include_ticket:t.check_ticket.add_to_title});c>t.commit_title.max_size&&r({message:`Title exceeds max width. Current size is ${c}, max is ${t.commit_title.max_size} (includes type, scope, and ticket when enabled).`})}),s.rawCheck(({dataset:e,addIssue:r})=>{e.typed&&t.commit_body.required&&!e.value.body.trim()&&r({message:"Missing --body. commit_body.required is enabled in config."})}),s.rawCheck(({dataset:e,addIssue:r})=>{e.typed&&e.value.closes&&!e.value.ticket&&r({message:'Invalid footer values: --closes requires --ticket (for example: --ticket "ABC-123").'})}),s.rawCheck(({dataset:e,addIssue:r})=>{e.typed&&e.value.breaking_body&&!e.value.breaking_title&&r({message:"Invalid breaking change values: --breaking-body requires --breaking-title."})}),s.rawCheck(({dataset:e,addIssue:r})=>{e.typed&&e.value.deprecates_body&&!e.value.deprecates_title&&r({message:"Invalid deprecation values: --deprecates-body requires --deprecates-title."})}))}function q(t){let n=t.commit_type.options.map(i=>i.value);return s.pipe(s.object(u),s.rawCheck(({dataset:i,addIssue:e})=>{if(!i.typed)return;let r=i.value.type?`"${i.value.type}"`:"(empty)";i.value.type&&!n.includes(i.value.type)&&e({message:`Invalid --type ${r}. Valid types: ${a(n)}.`})}),s.rawCheck(({dataset:i,addIssue:e})=>{!i.typed||i.value.description.trim()||e({message:"Missing --description. Provide a non-empty branch description."})}),s.rawCheck(({dataset:i,addIssue:e})=>{if(!i.typed)return;let r=i.value.description.trim();r.length>t.branch_description.max_length&&e({message:`Description exceeds max length. Current length is ${r.length}, max is ${t.branch_description.max_length}.`})}),s.rawCheck(({dataset:i,addIssue:e})=>{i.typed&&t.branch_user.required&&!i.value.user.trim()&&e({message:"Missing --user. branch_user.required is enabled in config."})}),s.rawCheck(({dataset:i,addIssue:e})=>{i.typed&&t.branch_ticket.required&&!i.value.ticket.trim()&&e({message:"Missing --ticket. branch_ticket.required is enabled in config."})}),s.rawCheck(({dataset:i,addIssue:e})=>{i.typed&&t.branch_version.required&&!i.value.version.trim()&&e({message:"Missing --branch-version. branch_version.required is enabled in config."})}))}import{execSync as h}from"child_process";var f=/\/(\w+-\d+)/,v=/^(\w+-\d+)/,y=/^([A-Z]+-[\[a-zA-Z\]\d]+)_/,k=/\/([A-Z]+-[\[a-zA-Z\]\d]+)_/,b=/\/(\d+)/,$=/^(\d+)/;function H(t){if(p.interactive)return;let n={ticket:"",type:""};if(t.check_ticket.infer_ticket){let e=w({append_hashtag:t.check_ticket.append_hashtag,prepend_hashtag:t.check_ticket.prepend_hashtag},p.git_args);n.ticket=e}let i=C(t.commit_type.options,p.git_args);return n.type=i,n}function C(t,n){let i=l(n);return i?E(i,t.map(e=>e.value)):""}function w(t,n){let i=l(n);return i?x(i,t):""}function x(t,n){let i=[t.match(y),t.match(k),t.match(f),t.match(b),t.match(v),t.match($)].filter(e=>e!=null).map(e=>e&&e.length>=2?e[1]:"");return!i.length||!i[0]?"":n.append_hashtag||n.prepend_hashtag==="Always"?`#${i[0]}`:i[0]}function E(t,n){return n.find(e=>{let r=new RegExp(`^${e}-`),c=new RegExp(`-${e}-`),g=new RegExp(`${e}/`);return[t.match(r),t.match(c),t.match(g)].filter(d=>d!=null).length>0})??""}function l(t){try{return h(`git ${t} branch --show-current`,{stdio:"pipe"}).toString().trim()}catch{return""}}import o from"picocolors";function X(t){return`${t} ${o.dim("\xB7 restored from cache")}`}function U(t){return`${t} ${o.dim("\xB7 inferred from branch")}`}function Z(t){return`${t} ${o.dim("\xB7 optional")}`}function j(t){return`${t} ${o.dim("\xB7 <space> to select")}`}function D(t){return`${t} ${o.dim("\xB7 dry run - changes will not be committed")}`}export{_ as a,R as b,q as c,H as d,C as e,w as f,X as g,U as h,Z as i,j,D as k};
1
+ import{b as m,d as u,f as p}from"./chunk-F4EBQBBK.js";import*as s from"valibot";function _(t,n){let i=t.scope?t.scope.length+2:0,e=t.type?.length??0,r=n.include_ticket?t.ticket?.length??0:0,c=t.title?.length??0;return i+e+r+c}function a(t){return t.map(i=>i===""?'"" (none)':`"${i}"`).join(", ")}function R(t){let n=t.commit_type.options.map(e=>e.value),i=t.commit_scope.options.map(e=>e.value);return s.pipe(s.object(m),s.rawCheck(({dataset:e,addIssue:r})=>{if(!e.typed)return;let c=e.value.type?`"${e.value.type}"`:"(empty)";e.value.type&&!n.includes(e.value.type)&&r({message:`Invalid --type ${c}. Valid types: ${a(n)}.`})}),s.rawCheck(({dataset:e,addIssue:r})=>{if(!e.typed)return;let c=e.value.scope?`"${e.value.scope}"`:"(empty)";e.value.scope&&!t.commit_scope.custom_scope&&!i.includes(e.value.scope)&&r({message:`Invalid --scope ${c}. Valid scopes: ${a(i)}.`})}),s.rawCheck(({dataset:e,addIssue:r})=>{!e.typed||e.value.title.trim()||r({message:"Missing --title. Provide a non-empty commit title."})}),s.rawCheck(({dataset:e,addIssue:r})=>{if(!e.typed)return;let c=_(e.value,{include_ticket:t.check_ticket.add_to_title});c>t.commit_title.max_size&&r({message:`Title exceeds max width. Current size is ${c}, max is ${t.commit_title.max_size} (includes type, scope, and ticket when enabled).`})}),s.rawCheck(({dataset:e,addIssue:r})=>{e.typed&&t.commit_body.required&&!e.value.body.trim()&&r({message:"Missing --body. commit_body.required is enabled in config."})}),s.rawCheck(({dataset:e,addIssue:r})=>{e.typed&&e.value.closes&&!e.value.ticket&&r({message:'Invalid footer values: --closes requires --ticket (for example: --ticket "ABC-123").'})}),s.rawCheck(({dataset:e,addIssue:r})=>{e.typed&&e.value.breaking_body&&!e.value.breaking_title&&r({message:"Invalid breaking change values: --breaking-body requires --breaking-title."})}),s.rawCheck(({dataset:e,addIssue:r})=>{e.typed&&e.value.deprecates_body&&!e.value.deprecates_title&&r({message:"Invalid deprecation values: --deprecates-body requires --deprecates-title."})}))}function q(t){let n=t.commit_type.options.map(i=>i.value);return s.pipe(s.object(u),s.rawCheck(({dataset:i,addIssue:e})=>{if(!i.typed)return;let r=i.value.type?`"${i.value.type}"`:"(empty)";i.value.type&&!n.includes(i.value.type)&&e({message:`Invalid --type ${r}. Valid types: ${a(n)}.`})}),s.rawCheck(({dataset:i,addIssue:e})=>{!i.typed||i.value.description.trim()||e({message:"Missing --description. Provide a non-empty branch description."})}),s.rawCheck(({dataset:i,addIssue:e})=>{if(!i.typed)return;let r=i.value.description.trim();r.length>t.branch_description.max_length&&e({message:`Description exceeds max length. Current length is ${r.length}, max is ${t.branch_description.max_length}.`})}),s.rawCheck(({dataset:i,addIssue:e})=>{i.typed&&t.branch_user.required&&!i.value.user.trim()&&e({message:"Missing --user. branch_user.required is enabled in config."})}),s.rawCheck(({dataset:i,addIssue:e})=>{i.typed&&t.branch_ticket.required&&!i.value.ticket.trim()&&e({message:"Missing --ticket. branch_ticket.required is enabled in config."})}),s.rawCheck(({dataset:i,addIssue:e})=>{i.typed&&t.branch_version.required&&!i.value.version.trim()&&e({message:"Missing --branch-version. branch_version.required is enabled in config."})}))}import{execSync as h}from"child_process";var f=/\/(\w+-\d+)/,v=/^(\w+-\d+)/,y=/^([A-Z]+-[\[a-zA-Z\]\d]+)_/,k=/\/([A-Z]+-[\[a-zA-Z\]\d]+)_/,b=/\/(\d+)/,$=/^(\d+)/;function H(t){if(p.interactive)return;let n={ticket:"",type:""};if(t.check_ticket.infer_ticket){let e=w({append_hashtag:t.check_ticket.append_hashtag,prepend_hashtag:t.check_ticket.prepend_hashtag},p.git_args);n.ticket=e}let i=C(t.commit_type.options,p.git_args);return n.type=i,n}function C(t,n){let i=l(n);return i?E(i,t.map(e=>e.value)):""}function w(t,n){let i=l(n);return i?x(i,t):""}function x(t,n){let i=[t.match(y),t.match(k),t.match(f),t.match(b),t.match(v),t.match($)].filter(e=>e!=null).map(e=>e&&e.length>=2?e[1]:"");return!i.length||!i[0]?"":n.append_hashtag||n.prepend_hashtag==="Always"?`#${i[0]}`:i[0]}function E(t,n){return n.find(e=>{let r=new RegExp(`^${e}-`),c=new RegExp(`-${e}-`),g=new RegExp(`${e}/`);return[t.match(r),t.match(c),t.match(g)].filter(d=>d!=null).length>0})??""}function l(t){try{return h(`git ${t} branch --show-current`,{stdio:"pipe"}).toString().trim()}catch{return""}}import o from"picocolors";function X(t){return`${t} ${o.dim("\xB7 restored from cache")}`}function U(t){return`${t} ${o.dim("\xB7 inferred from branch")}`}function Z(t){return`${t} ${o.dim("\xB7 optional")}`}function j(t){return`${t} ${o.dim("\xB7 <space> to select")}`}function D(t){return`${t} ${o.dim("\xB7 <space> to select \xB7 <a> to select all")}`}function L(t){return`${t} ${o.dim("\xB7 dry run - changes will not be committed")}`}export{_ as a,R as b,q as c,H as d,C as e,w as f,X as g,U as h,Z as i,j,D as k,L as l};
@@ -1,6 +1,7 @@
1
- import*as e from"valibot";import*as l from"valibot";var s="custom",b=["closes","trailer","breaking-change","deprecated","custom"],u=l.picklist(["branch","worktree"]),m=l.picklist(["closes","trailer","breaking-change","deprecated","custom"]),d=l.picklist(["user","version","type","ticket","description"]),K=l.picklist(["branch_user","branch_version","branch_type","branch_ticket","branch_description"]),y=["user","version","type","ticket","description"],C=[{value:"app",label:"app"},{value:"shared",label:"shared"},{value:"server",label:"server"},{value:"tools",label:"tools"},{value:"",label:"none"}],k=[{value:"feat",label:"feat",hint:"A new feature",emoji:"\u{1F31F}",trailer:"Changelog: feature"},{value:"fix",label:"fix",hint:"A bug fix",emoji:"\u{1F41B}",trailer:"Changelog: fix"},{value:"docs",label:"docs",hint:"Documentation only changes",emoji:"\u{1F4DA}",trailer:"Changelog: documentation"},{value:"refactor",label:"refactor",hint:"A code change that neither fixes a bug nor adds a feature",emoji:"\u{1F528}",trailer:"Changelog: refactor"},{value:"perf",label:"perf",hint:"A code change that improves performance",emoji:"\u{1F680}",trailer:"Changelog: performance"},{value:"test",label:"test",hint:"Adding missing tests or correcting existing tests",emoji:"\u{1F6A8}",trailer:"Changelog: test"},{value:"build",label:"build",hint:"Changes that affect the build system or external dependencies",emoji:"\u{1F6A7}",trailer:"Changelog: build"},{value:"ci",label:"ci",hint:"Changes to our CI configuration files and scripts",emoji:"\u{1F916}",trailer:"Changelog: ci"},{value:"chore",label:"chore",hint:"Other changes that do not modify src or test files",emoji:"\u{1F9F9}",trailer:"Changelog: chore"},{value:"",label:"none"}];var N=e.pipe(e.optional(e.object({enable:e.optional(e.boolean(),!0),initial_value:e.optional(e.string(),"feat"),max_items:e.optional(e.pipe(e.number(),e.minValue(1)),20),infer_type_from_branch:e.optional(e.boolean(),!0),append_emoji_to_label:e.optional(e.boolean(),!1),append_emoji_to_commit:e.optional(e.boolean(),!1),emoji_commit_position:e.optional(e.picklist(["Start","After-Colon"]),"Start"),options:e.optional(e.array(e.object({value:e.string(),label:e.optional(e.string()),hint:e.optional(e.string()),emoji:e.optional(e.pipe(e.string(),e.emoji())),trailer:e.optional(e.string())})),k)}),{}),e.rawCheck(({dataset:o,addIssue:t})=>{o.typed&&!o.value.options.some(r=>r.value===o.value.initial_value)&&t({message:`Type: initial_value "${o.value.initial_value}" must exist in options`})}),e.transform(o=>({...o,options:o.options.map(t=>({...t,label:t.emoji&&o.append_emoji_to_label?`${t.emoji} ${t.label}`:t.label}))}))),R=e.pipe(e.optional(e.object({enable:e.optional(e.boolean(),!0),custom_scope:e.optional(e.boolean(),!1),max_items:e.optional(e.pipe(e.number(),e.minValue(1)),20),initial_value:e.optional(e.string(),"app"),options:e.optional(e.array(e.object({value:e.string(),label:e.optional(e.string()),hint:e.optional(e.string())})),C)}),{}),e.rawCheck(({dataset:o,addIssue:t})=>{if(!o.typed)return;let r=o.value.options.map(i=>i.value);o.value.custom_scope&&r.push(s),r.includes(o.value.initial_value)||t({message:`Scope: initial_value "${o.value.initial_value}" must exist in options`})}),e.transform(o=>{let t=o.options.map(r=>r.value);return o.custom_scope&&!t.includes(s)?{...o,options:[...o.options,{label:s,value:s,hint:"Write a custom scope"}]}:o})),_=e.object({check_status:e.optional(e.boolean(),!0),commit_type:N,commit_scope:R,check_ticket:e.optional(e.object({infer_ticket:e.optional(e.boolean(),!0),confirm_ticket:e.optional(e.boolean(),!0),add_to_title:e.optional(e.boolean(),!0),append_hashtag:e.optional(e.boolean(),!1),prepend_hashtag:e.optional(e.picklist(["Never","Always","Prompt"]),"Never"),surround:e.optional(e.picklist(["","()","[]","{}"]),""),title_position:e.optional(e.picklist(["start","end","before-colon","beginning"]),"start")}),{}),commit_title:e.optional(e.object({max_size:e.optional(e.pipe(e.number(),e.minValue(1)),70)}),{}),commit_body:e.optional(e.object({enable:e.optional(e.boolean(),!0),required:e.optional(e.boolean(),!1),split_by_period:e.optional(e.boolean(),!1)}),{}),commit_footer:e.optional(e.object({enable:e.optional(e.boolean(),!0),initial_value:e.optional(e.array(m),[]),options:e.optional(e.array(m),b)}),{}),breaking_change:e.optional(e.object({add_exclamation_to_title:e.optional(e.boolean(),!0)}),{}),cache_last_value:e.optional(e.boolean(),!0),confirm_with_editor:e.optional(e.boolean(),!1),confirm_commit:e.optional(e.boolean(),!0),print_commit_output:e.optional(e.boolean(),!0),branch_pre_commands:e.optional(e.array(e.string()),[]),branch_post_commands:e.optional(e.array(e.string()),[]),worktree_pre_commands:e.optional(e.array(e.string()),[]),worktree_post_commands:e.optional(e.array(e.string()),[]),branch_user:e.optional(e.object({enable:e.optional(e.boolean(),!0),required:e.optional(e.boolean(),!1),separator:e.optional(e.picklist(["/","-","_"]),"/")}),{}),branch_type:e.optional(e.object({enable:e.optional(e.boolean(),!0),separator:e.optional(e.picklist(["/","-","_"]),"/")}),{}),branch_version:e.optional(e.object({enable:e.optional(e.boolean(),!1),required:e.optional(e.boolean(),!1),separator:e.optional(e.picklist(["/","-","_"]),"/")}),{}),branch_ticket:e.optional(e.object({enable:e.optional(e.boolean(),!0),required:e.optional(e.boolean(),!1),separator:e.optional(e.picklist(["/","-","_"]),"-")}),{}),branch_description:e.optional(e.object({max_length:e.optional(e.pipe(e.number(),e.minValue(1)),70),separator:e.optional(e.picklist(["","/","-","_"]),"")}),{}),branch_action_default:e.optional(u,"branch"),branch_order:e.optional(e.array(d),y),enable_worktrees:e.optional(e.boolean(),!0),worktrees:e.optional(e.object({enable:e.optional(e.boolean(),!0),base_path:e.optional(e.string(),".."),folder_template:e.optional(e.string(),"{{repo_name}}-{{ticket}}-{{branch_description}}")}),{}),overrides:e.optional(e.object({shell:e.optional(e.string())}),{})}),P={type:e.optional(e.string(),""),scope:e.optional(e.string(),""),title:e.optional(e.string(),""),body:e.optional(e.string(),""),closes:e.optional(e.string(),""),ticket:e.optional(e.string(),""),breaking_title:e.optional(e.string(),""),breaking_body:e.optional(e.string(),""),deprecates:e.optional(e.string(),""),deprecates_title:e.optional(e.string(),""),deprecates_body:e.optional(e.string(),""),custom_footer:e.optional(e.string(),""),trailer:e.optional(e.string(),"")},Q=e.optional(e.object(P),{}),F={user:e.optional(e.string(),""),type:e.optional(e.string(),""),ticket:e.optional(e.string(),""),description:e.optional(e.string(),""),version:e.optional(e.string(),""),checkout:e.optional(u,"branch")},X=e.optional(e.object(F),{});import{parse as L}from"@bomb.sh/args";var O=["type","scope","title","body","closes","ticket","trailer","deprecates","breaking-title","breaking-body","deprecates-title","deprecates-body","custom-footer"],D=["git-dir","work-tree"],$=["interactive","dry-run","help","version"],g=class{#e;constructor(t){this.#e=t}get git_args(){return this.#e.git_args}get interactive(){return!this.#e.no_interactive}get dry_run(){return this.#e.dry_run}get help(){return this.#e.help}get version(){return this.#e.version}get commit_state(){return this.#e.commit_state}},f=new g(V(process.argv.slice(2)));function V(o){let t=L(o,{alias:{h:"help",v:"version"},boolean:$,string:[...O,...D]}),r={};return O.forEach(i=>{let a=t[i];if(a){let p=i.replace("-","_");r[p]=a}}),{help:t.help===!0,version:t.version===!0,git_args:M(t["git-dir"],t["work-tree"]),no_interactive:t.interactive===!1,dry_run:t["dry-run"]===!0,commit_state:r}}function M(o,t){return`${o?`--git-dir=${o}`:""} ${t?`--work-tree=${t}`:""}`.trim()}var x=`{
1
+ import*as e from"valibot";import*as l from"valibot";var s="custom",h=["closes","trailer","breaking-change","deprecated","custom"],u=l.picklist(["branch","worktree"]),m=l.picklist(["closes","trailer","breaking-change","deprecated","custom"]),d=l.picklist(["user","version","type","ticket","description"]),K=l.picklist(["branch_user","branch_version","branch_type","branch_ticket","branch_description"]),C=["user","version","type","ticket","description"],y=[{value:"app",label:"app"},{value:"shared",label:"shared"},{value:"server",label:"server"},{value:"tools",label:"tools"},{value:"",label:"none"}],k=[{value:"feat",label:"feat",hint:"A new feature",emoji:"\u{1F31F}",trailer:"Changelog: feature"},{value:"fix",label:"fix",hint:"A bug fix",emoji:"\u{1F41B}",trailer:"Changelog: fix"},{value:"docs",label:"docs",hint:"Documentation only changes",emoji:"\u{1F4DA}",trailer:"Changelog: documentation"},{value:"refactor",label:"refactor",hint:"A code change that neither fixes a bug nor adds a feature",emoji:"\u{1F528}",trailer:"Changelog: refactor"},{value:"perf",label:"perf",hint:"A code change that improves performance",emoji:"\u{1F680}",trailer:"Changelog: performance"},{value:"test",label:"test",hint:"Adding missing tests or correcting existing tests",emoji:"\u{1F6A8}",trailer:"Changelog: test"},{value:"build",label:"build",hint:"Changes that affect the build system or external dependencies",emoji:"\u{1F6A7}",trailer:"Changelog: build"},{value:"ci",label:"ci",hint:"Changes to our CI configuration files and scripts",emoji:"\u{1F916}",trailer:"Changelog: ci"},{value:"chore",label:"chore",hint:"Other changes that do not modify src or test files",emoji:"\u{1F9F9}",trailer:"Changelog: chore"},{value:"",label:"none"}];var N=e.pipe(e.optional(e.object({enable:e.optional(e.boolean(),!0),initial_value:e.optional(e.string(),"feat"),max_items:e.optional(e.pipe(e.number(),e.minValue(1)),20),infer_type_from_branch:e.optional(e.boolean(),!0),append_emoji_to_label:e.optional(e.boolean(),!1),append_emoji_to_commit:e.optional(e.boolean(),!1),emoji_commit_position:e.optional(e.picklist(["Start","After-Colon"]),"Start"),autocomplete:e.optional(e.boolean(),!0),options:e.optional(e.array(e.object({value:e.string(),label:e.optional(e.string()),hint:e.optional(e.string()),emoji:e.optional(e.pipe(e.string(),e.emoji())),trailer:e.optional(e.string())})),k)}),{}),e.rawCheck(({dataset:o,addIssue:t})=>{o.typed&&!o.value.options.some(r=>r.value===o.value.initial_value)&&t({message:`Type: initial_value "${o.value.initial_value}" must exist in options`})}),e.transform(o=>({...o,options:o.options.map(t=>({...t,label:t.emoji&&o.append_emoji_to_label?`${t.emoji} ${t.label}`:t.label}))}))),R=e.pipe(e.optional(e.object({enable:e.optional(e.boolean(),!0),custom_scope:e.optional(e.boolean(),!1),max_items:e.optional(e.pipe(e.number(),e.minValue(1)),20),initial_value:e.optional(e.string(),"app"),autocomplete:e.optional(e.boolean(),!0),options:e.optional(e.array(e.object({value:e.string(),label:e.optional(e.string()),hint:e.optional(e.string())})),y)}),{}),e.rawCheck(({dataset:o,addIssue:t})=>{if(!o.typed)return;let r=o.value.options.map(i=>i.value);o.value.custom_scope&&r.push(s),r.includes(o.value.initial_value)||t({message:`Scope: initial_value "${o.value.initial_value}" must exist in options`})}),e.transform(o=>{let t=o.options.map(r=>r.value);return o.custom_scope&&!t.includes(s)?{...o,options:[...o.options,{label:s,value:s,hint:"Write a custom scope"}]}:o})),_=e.object({check_status:e.optional(e.boolean(),!0),check_status_autocomplete:e.optional(e.boolean(),!0),commit_type:N,commit_scope:R,check_ticket:e.optional(e.object({infer_ticket:e.optional(e.boolean(),!0),confirm_ticket:e.optional(e.boolean(),!0),add_to_title:e.optional(e.boolean(),!0),append_hashtag:e.optional(e.boolean(),!1),prepend_hashtag:e.optional(e.picklist(["Never","Always","Prompt"]),"Never"),surround:e.optional(e.picklist(["","()","[]","{}"]),""),title_position:e.optional(e.picklist(["start","end","before-colon","beginning"]),"start")}),{}),commit_title:e.optional(e.object({max_size:e.optional(e.pipe(e.number(),e.minValue(1)),70)}),{}),commit_body:e.optional(e.object({enable:e.optional(e.boolean(),!0),required:e.optional(e.boolean(),!1),split_by_period:e.optional(e.boolean(),!1)}),{}),commit_footer:e.optional(e.object({enable:e.optional(e.boolean(),!0),initial_value:e.optional(e.array(m),[]),options:e.optional(e.array(m),h)}),{}),breaking_change:e.optional(e.object({add_exclamation_to_title:e.optional(e.boolean(),!0)}),{}),cache_last_value:e.optional(e.boolean(),!0),confirm_with_editor:e.optional(e.boolean(),!1),confirm_commit:e.optional(e.boolean(),!0),print_commit_output:e.optional(e.boolean(),!0),branch_pre_commands:e.optional(e.array(e.string()),[]),branch_post_commands:e.optional(e.array(e.string()),[]),worktree_pre_commands:e.optional(e.array(e.string()),[]),worktree_post_commands:e.optional(e.array(e.string()),[]),branch_user:e.optional(e.object({enable:e.optional(e.boolean(),!0),required:e.optional(e.boolean(),!1),separator:e.optional(e.picklist(["/","-","_"]),"/")}),{}),branch_type:e.optional(e.object({enable:e.optional(e.boolean(),!0),separator:e.optional(e.picklist(["/","-","_"]),"/"),autocomplete:e.optional(e.boolean(),!0)}),{}),branch_version:e.optional(e.object({enable:e.optional(e.boolean(),!1),required:e.optional(e.boolean(),!1),separator:e.optional(e.picklist(["/","-","_"]),"/")}),{}),branch_ticket:e.optional(e.object({enable:e.optional(e.boolean(),!0),required:e.optional(e.boolean(),!1),separator:e.optional(e.picklist(["/","-","_"]),"-")}),{}),branch_description:e.optional(e.object({max_length:e.optional(e.pipe(e.number(),e.minValue(1)),70),separator:e.optional(e.picklist(["","/","-","_"]),"")}),{}),branch_action_default:e.optional(u,"branch"),branch_order:e.optional(e.array(d),C),enable_worktrees:e.optional(e.boolean(),!0),worktrees:e.optional(e.object({enable:e.optional(e.boolean(),!0),base_path:e.optional(e.string(),".."),folder_template:e.optional(e.string(),"{{repo_name}}-{{ticket}}-{{branch_description}}")}),{}),overrides:e.optional(e.object({shell:e.optional(e.string())}),{})}),P={type:e.optional(e.string(),""),scope:e.optional(e.string(),""),title:e.optional(e.string(),""),body:e.optional(e.string(),""),closes:e.optional(e.string(),""),ticket:e.optional(e.string(),""),breaking_title:e.optional(e.string(),""),breaking_body:e.optional(e.string(),""),deprecates:e.optional(e.string(),""),deprecates_title:e.optional(e.string(),""),deprecates_body:e.optional(e.string(),""),custom_footer:e.optional(e.string(),""),trailer:e.optional(e.string(),"")},Q=e.optional(e.object(P),{}),F={user:e.optional(e.string(),""),type:e.optional(e.string(),""),ticket:e.optional(e.string(),""),description:e.optional(e.string(),""),version:e.optional(e.string(),""),checkout:e.optional(u,"branch")},X=e.optional(e.object(F),{});import{parse as L}from"@bomb.sh/args";var O=["type","scope","title","body","closes","ticket","trailer","deprecates","breaking-title","breaking-body","deprecates-title","deprecates-body","custom-footer"],D=["git-dir","work-tree"],$=["interactive","dry-run","help","version"],g=class{#e;constructor(t){this.#e=t}get git_args(){return this.#e.git_args}get interactive(){return!this.#e.no_interactive}get dry_run(){return this.#e.dry_run}get help(){return this.#e.help}get version(){return this.#e.version}get commit_state(){return this.#e.commit_state}},f=new g(V(process.argv.slice(2)));function V(o){let t=L(o,{alias:{h:"help",v:"version"},boolean:$,string:[...O,...D]}),r={};return O.forEach(i=>{let a=t[i];if(a){let p=i.replace("-","_");r[p]=a}}),{help:t.help===!0,version:t.version===!0,git_args:M(t["git-dir"],t["work-tree"]),no_interactive:t.interactive===!1,dry_run:t["dry-run"]===!0,commit_state:r}}function M(o,t){return`${o?`--git-dir=${o}`:""} ${t?`--work-tree=${t}`:""}`.trim()}var x=`{
2
2
  // Run interactive \`git status\` before composing a commit
3
3
  "check_status": true,
4
+ "check_status_autocomplete": true,
4
5
 
5
6
  /* COMMIT FIELDS */
6
7
  "commit_type": {
@@ -9,6 +10,8 @@ import*as e from"valibot";import*as l from"valibot";var s="custom",b=["closes","
9
10
  // Default selected type from options
10
11
  "initial_value": "feat",
11
12
 
13
+ "max_items": 20,
14
+
12
15
  // Infer type from the current branch name: user/TYPE/my-branch
13
16
  "infer_type_from_branch": true,
14
17
 
@@ -21,6 +24,8 @@ import*as e from"valibot";import*as l from"valibot";var s="custom",b=["closes","
21
24
  // "Start" | "After-Colon"
22
25
  "emoji_commit_position": "Start",
23
26
 
27
+ "autocomplete": true,
28
+
24
29
  "options": [
25
30
  {
26
31
  "value": "feat",
@@ -102,6 +107,7 @@ import*as e from"valibot";import*as l from"valibot";var s="custom",b=["closes","
102
107
  "initial_value": "app",
103
108
 
104
109
  "max_items": 20,
110
+ "autocomplete": true,
105
111
  "options": [
106
112
  { "value": "app", "label": "app" },
107
113
  { "value": "shared", "label": "shared" },
@@ -189,7 +195,8 @@ import*as e from"valibot";import*as l from"valibot";var s="custom",b=["closes","
189
195
 
190
196
  "branch_type": {
191
197
  "enable": true,
192
- "separator": "/"
198
+ "separator": "/",
199
+ "autocomplete": true,
193
200
  },
194
201
 
195
202
  "branch_ticket": {
@@ -239,7 +246,7 @@ import*as e from"valibot";import*as l from"valibot";var s="custom",b=["closes","
239
246
  "shell": "/bin/sh"
240
247
  }
241
248
  }
242
- `;import*as n from"@clack/prompts";import{execSync as B}from"child_process";import c from"fs";import{homedir as S}from"os";import{parse as H}from"jsonc-parser";import h from"picocolors";import{ValiError as U,parse as T}from"valibot";var A=[".better-commits.jsonc",".better-commits.json"],E=A[0],me=[{value:"closes",label:"closes <issue/ticket>",hint:"Attempts to infer ticket from branch"},{value:"trailer",label:"trailer",hint:"Appends trailer based on commit type"},{value:"breaking-change",label:"breaking change",hint:"Add breaking change"},{value:"deprecated",label:"deprecated",hint:"Add deprecated change"},{value:"custom",label:"custom",hint:"Add a custom footer"}],_e=[{value:"branch",label:"Branch"},{value:"worktree",label:"Worktree"}],ge={get:()=>"",set:(o,t)=>{},clear:()=>{}};function fe(o=" better-commits ",t=f.git_args){console.clear(),n.intro(`${h.bgCyan(h.black(o))}`);let r=null,i=W();c.existsSync(i)&&(r=I(i));let a=q(t),p=Y(a);if(p){n.log.step("Reading from Repository Config");let v=I(p);return{config:r?{...v,overrides:r.overrides.shell?r.overrides:v.overrides,confirm_with_editor:r.confirm_with_editor,cache_last_value:r.cache_last_value}:v,config_source:"repository"}}if(r)return n.log.step("Reading from Global Config"),{config:r,config_source:"global"};let w=T(_,{});return n.log.step(`Config not found. Generating default ${E} at $HOME`),c.writeFileSync(i,x),{config:w,config_source:"none"}}function I(o){let t=null;try{t=H(c.readFileSync(o,"utf8"))}catch(r){n.log.error(`Invalid JSON file. Exiting.
243
- `+r),process.exit(0)}return G(t)}function G(o){try{return T(_,o)}catch(t){if(t instanceof U){let i=(t.issues[0].path??[]).map(a=>a.key).filter(a=>typeof a=="string"||typeof a=="number").join(".");n.log.error(`Invalid Configuration: ${h.red(i)}
244
- `+t.message)}process.exit(0)}}function q(o=f.git_args){let t=".";try{t=B(`git ${o} rev-parse --show-toplevel`).toString().trim()}catch{n.log.warn("Could not find git root. If in a --bare repository, ignore this warning.")}return t}function W(){return j(S())??S()+"/"+E}function Y(o){return j(o)}function j(o){for(let t of A){let r=`${o}/${t}`;if(c.existsSync(r))return r}return null}function he(){try{return JSON.parse(c.readFileSync(new URL("../package.json",import.meta.url),"utf8")).version??"unknown"}catch{return"unknown"}}function be(o,t){return t===o.length-1?"":`
245
- `}function de(o){let t=o.trim();return t.endsWith(".")?t.substring(0,t.length-1).trim():o.trim()}function ye(o,t){try{return o.get(t)??""}catch{n.log.warn(`Could not access ${t} from cache. Check that "~/.config" exists. Set "cache_last_value" to false to disable.`)}return""}function Ce(o,t,r){try{o.set(t,r)}catch{n.log.warn(`Could not access ${t} from cache. Check that "~/.config" exists. Set "cache_last_value" to false to disable.`)}}export{s as a,P as b,Q as c,F as d,X as e,f,x as g,E as h,me as i,_e as j,ge as k,fe as l,q as m,Y as n,he as o,be as p,de as q,ye as r,Ce as s};
249
+ `;import*as n from"@clack/prompts";import{execSync as B}from"child_process";import c from"fs";import{homedir as S}from"os";import{parse as H}from"jsonc-parser";import b from"picocolors";import{ValiError as U,parse as T}from"valibot";var A=[".better-commits.jsonc",".better-commits.json"],E=A[0],me=[{value:"closes",label:"closes <issue/ticket>",hint:"Attempts to infer ticket from branch"},{value:"trailer",label:"trailer",hint:"Appends trailer based on commit type"},{value:"breaking-change",label:"breaking change",hint:"Add breaking change"},{value:"deprecated",label:"deprecated",hint:"Add deprecated change"},{value:"custom",label:"custom",hint:"Add a custom footer"}],_e=[{value:"branch",label:"Branch"},{value:"worktree",label:"Worktree"}],ge={get:()=>"",set:(o,t)=>{},clear:()=>{}};function fe(o=" better-commits ",t=f.git_args){console.clear(),n.intro(`${b.bgCyan(b.black(o))}`);let r=null,i=W();c.existsSync(i)&&(r=I(i));let a=q(t),p=Y(a);if(p){n.log.step("Reading from Repository Config");let v=I(p);return{config:r?{...v,overrides:r.overrides.shell?r.overrides:v.overrides,confirm_with_editor:r.confirm_with_editor,cache_last_value:r.cache_last_value}:v,config_source:"repository"}}if(r)return n.log.step("Reading from Global Config"),{config:r,config_source:"global"};let w=T(_,{});return n.log.step(`Config not found. Generating default ${E} at $HOME`),c.writeFileSync(i,x),{config:w,config_source:"none"}}function I(o){let t=null;try{t=H(c.readFileSync(o,"utf8"))}catch(r){n.log.error(`Invalid JSON/JSONC config file at ${o}. Exiting.
250
+ `+r),process.exit(0)}return G(t)}function G(o){try{return T(_,o)}catch(t){if(t instanceof U){let i=(t.issues[0].path??[]).map(a=>a.key).filter(a=>typeof a=="string"||typeof a=="number").join(".");n.log.error(`Invalid Configuration: ${b.red(i)}
251
+ `+t.message)}process.exit(0)}}function q(o=f.git_args){let t=".";try{t=B(`git ${o} rev-parse --show-toplevel`).toString().trim()}catch{n.log.warn("Could not find git root. If in a --bare repository, ignore this warning.")}return t}function W(){return j(S())??S()+"/"+E}function Y(o){return j(o)}function j(o){for(let t of A){let r=`${o}/${t}`;if(c.existsSync(r))return r}return null}function be(){try{return JSON.parse(c.readFileSync(new URL("../package.json",import.meta.url),"utf8")).version??"unknown"}catch{return"unknown"}}function he(o,t){return t===o.length-1?"":`
252
+ `}function de(o){let t=o.trim();return t.endsWith(".")?t.substring(0,t.length-1).trim():o.trim()}function Ce(o,t){try{return o.get(t)??""}catch{n.log.warn(`Could not access ${t} from cache. Check that "~/.config" exists. Set "cache_last_value" to false to disable.`)}return""}function ye(o,t,r){try{o.set(t,r)}catch{n.log.warn(`Could not access ${t} from cache. Check that "~/.config" exists. Set "cache_last_value" to false to disable.`)}}export{s as a,P as b,Q as c,F as d,X as e,f,x as g,E as h,me as i,_e as j,ge as k,fe as l,q as m,Y as n,be as o,he as p,de as q,Ce as r,ye as s};
package/dist/index.js CHANGED
@@ -1,57 +1,61 @@
1
1
  #! /usr/bin/env node
2
- import{a as nt,b as at,d as ct,e as F,f as P,g as f,h as A,i as y,j as $,k as Y}from"./chunk-LPU7O52G.js";import{a as Z,c as z,f as s,i as tt,k as et,l as it,m as ot,o as I,p as rt,q as st,r as g,s as u}from"./chunk-QPUTIRGU.js";import{chdir as kt}from"process";import*as H from"@clack/prompts";import{ValiError as vt,parse as ut}from"valibot";import Ct from"configstore";import*as T from"@clack/prompts";var m=class{constructor(t,e,o){this.config=t;this.commit_state=e;this.prompt_cache=o}};var R=class extends m{async run(){if(this.#o){let{initial_value:t,message:e}=this.#e,o=await T.select({message:e,initialValue:t,maxItems:this.#r,options:this.#t});T.isCancel(o)&&process.exit(0),this.#s(o)}}get#o(){return this.config.commit_type.enable}get#e(){let t=g(this.prompt_cache,"commit_type");if(t)return{initial_value:t,message:f("Commit type")};if(this.config.commit_type.infer_type_from_branch){let e=F(this.#t,s.git_args);if(e)return{message:A("Commit type"),initial_value:e}}return{initial_value:this.config.commit_type.initial_value,message:"Select a commit type"}}get#t(){return this.config.commit_type.options}get#i(){return this.#t.reduce((t,e)=>({...t,[e.value]:{emoji:e.emoji??"",trailer:e.trailer??""}}),{})}get#r(){return this.config.commit_type.max_items}#s(t){u(this.prompt_cache,"commit_type",t);let e=this.#i;this.commit_state.trailer=e[t].trailer,this.commit_state.type=this.config.commit_type.append_emoji_to_commit&&this.config.commit_type.emoji_commit_position==="Start"?`${e[t].emoji} ${t}`.trim():t}};import*as k from"@clack/prompts";var j=class extends m{async run(){if(!this.#o)return;let{initial_value:t,message:e}=this.#e(),o=await k.select({message:e,initialValue:t,maxItems:this.#t,options:this.#i});k.isCancel(o)&&process.exit(0),await this.#s(o)}get#o(){return this.config.commit_scope.enable}#e(){let t=g(this.prompt_cache,"commit_scope");return t?{initial_value:t,message:f("Commit scope")}:{initial_value:this.config.commit_scope.initial_value,message:"Select a commit scope"}}get#t(){return this.config.commit_scope.max_items}get#i(){return this.config.commit_scope.options}get#r(){return this.config.commit_scope.custom_scope}async#s(t){u(this.prompt_cache,"commit_scope",t);let e=t;if(e===Z&&this.#r){let o=await k.text({message:"Write a custom scope",placeholder:""});k.isCancel(o)&&process.exit(0),e=o??""}this.commit_state.scope=e}};import*as N from"@clack/prompts";var E=class extends m{async run(){let{initial_value:t,message:e}=this.#i();if(this.commit_state.ticket=t,this.#e){let o=await N.text({message:e,placeholder:"",initialValue:t});N.isCancel(o)&&process.exit(0),u(this.prompt_cache,"commit_ticket",o),this.commit_state.ticket=o??""}this.#t&&this.commit_state.ticket&&!this.commit_state.ticket.startsWith("#")&&(this.commit_state.ticket="#"+this.commit_state.ticket)}get#o(){return this.config.check_ticket.infer_ticket}get#e(){return this.config.check_ticket.confirm_ticket}get#t(){return this.config.check_ticket.prepend_hashtag==="Always"}#i(){let t=g(this.prompt_cache,"commit_ticket");if(t)return{initial_value:t,message:f("Ticket / issue")};if(this.#o){let e=P({append_hashtag:this.config.check_ticket.append_hashtag,prepend_hashtag:this.config.check_ticket.prepend_hashtag},s.git_args);if(e)return{initial_value:e,message:A("Ticket / issue")}}return{initial_value:this.commit_state.ticket,message:y("Add ticket / issue")}}};import*as G from"@clack/prompts";var D=class extends m{async run(){let{initial_value:t,message:e}=this.#o(),o=await G.text({message:e,initialValue:t,placeholder:"",validate:a=>this.#e(a)});G.isCancel(o)&&process.exit(0),this.#n(o??"")}#o(){let t=g(this.prompt_cache,"commit_title");return t?{initial_value:t,message:f("Commit title")}:{initial_value:this.commit_state.title,message:"Write a brief title describing the commit"}}#e(t){if(!t)return"Please enter a title";if(this.#i(t)>this.#t)return`Exceeded max length. Title max [${this.#t}]`}get#t(){return this.config.commit_title.max_size}#i(t){return nt({type:this.commit_state.type,scope:this.commit_state.scope,ticket:this.commit_state.ticket,title:t},{include_ticket:this.config.check_ticket.add_to_title})}get#r(){return this.config.commit_type.options.reduce((t,e)=>({...t,[e.value]:{emoji:e.emoji??""}}),{})}#s(t){return this.config.commit_type.append_emoji_to_commit&&this.config.commit_type.emoji_commit_position==="After-Colon"?`${this.#r[this.commit_state.type]?.emoji??""} ${t}`.trim():t}#n(t){u(this.prompt_cache,"commit_title",t),this.commit_state.title=st(this.#s(t))}};import*as L from"@clack/prompts";var M=class extends m{async run(){if(!this.#o)return;let{initial_value:t,message:e}=this.#e(),o=await L.text({message:e,initialValue:t,placeholder:"",validate:a=>this.#t(a)});L.isCancel(o)&&process.exit(0),this.#r(o??"")}get#o(){return this.config.commit_body.enable}#e(){let t=g(this.prompt_cache,"commit_body");return t?{initial_value:t,message:f("Commit body")}:{initial_value:"",message:y("Write a detailed description of the changes")}}#t(t){if(this.config.commit_body.required&&!t)return"Please enter a description"}#i(t){return this.config.commit_body.split_by_period?t.split(/\.\s+/).map(o=>o.trim()).join(`.
3
- `):t}#r(t){u(this.prompt_cache,"commit_body",t),this.commit_state.body=this.#i(t)}};import*as h from"@clack/prompts";var V=class extends m{async run(){if(!this.#o)return;let{initial_values:t,message:e}=this.#i(),o=await h.multiselect({message:e,initialValues:t,options:this.#e,required:!1});h.isCancel(o)&&process.exit(0);let a=this.#s(o),r=await this.#n(a);this.#m(o,a,r)}get#o(){return this.config.commit_footer.enable}get#e(){let t=new Set(this.config.commit_footer.options);return tt.filter(e=>t.has(e.value))}get#t(){return this.#e.map(t=>t.value)}#i(){let t=g(this.prompt_cache,"commit_footer");return t?{initial_values:this.#r(t),message:$(f("Commit footers"))}:{initial_values:this.config.commit_footer.initial_value.filter(o=>this.#t.includes(o)),message:$(y("Select optional footers"))}}#r(t){return t.split(",").map(e=>e.trim()).filter(e=>this.#t.includes(e))}#s(t){return{includes_breaking_change:t.includes("breaking-change"),includes_deprecated:t.includes("deprecated"),includes_closes:t.includes("closes"),includes_custom:t.includes("custom"),includes_trailer:t.includes("trailer")}}async#n(t){let e={breaking_title:"",breaking_body:"",deprecated_title:"",deprecated_body:"",custom_footer:""};return t.includes_breaking_change&&(e.breaking_title=await this.#c("Breaking changes: Write a short title / summary"),e.breaking_body=await this.#a(y("Breaking Changes: Write a description & migration instructions"))),t.includes_deprecated&&(e.deprecated_title=await this.#c("Deprecated: Write a short title / summary"),e.deprecated_body=await this.#a(y("Deprecated: Write a description"))),t.includes_custom&&(e.custom_footer=await this.#a("Write a custom footer")),e}async#c(t){let e=await h.text({message:t,placeholder:"",validate:o=>{if(!o)return"Please enter a title / summary"}});return h.isCancel(e)&&process.exit(0),e??""}async#a(t){let e=await h.text({message:t,placeholder:""});return h.isCancel(e)&&process.exit(0),e??""}#m(t,e,o){u(this.prompt_cache,"commit_footer",t.join(",")),this.commit_state.breaking_title=o.breaking_title,this.commit_state.breaking_body=o.breaking_body,this.commit_state.deprecates_title=o.deprecated_title,this.commit_state.deprecates_body=o.deprecated_body,this.commit_state.custom_footer=o.custom_footer,this.commit_state.closes=e.includes_closes?"Closes:":"",e.includes_trailer||(this.commit_state.trailer="")}};import*as d from"@clack/prompts";import{execSync as mt}from"child_process";import p from"picocolors";function J({commit_state:i,config:t,colorize:e=!1,escape_quotes:o=!1,include_trailer:a=!1}){let r="";if(i.type&&(r+=e?p.blue(i.type):i.type),i.scope){let c=e?p.cyan(i.scope):i.scope;r+=`(${c})`}let n=i.ticket,l=t.check_ticket.surround;if(i.ticket&&l){let c=l.charAt(0),C=l.charAt(1);n=`${c}${i.ticket}${C}`}let v=t.check_ticket.title_position==="beginning";n&&t.check_ticket.add_to_title&&v&&(r=`${e?p.magenta(n):n} ${r}`);let w=t.check_ticket.title_position==="before-colon";if(n&&t.check_ticket.add_to_title&&w){let c=i.scope||i.type&&!t.check_ticket.surround?" ":"";r+=e?p.magenta(c+n):c+n}i.breaking_title&&t.breaking_change.add_exclamation_to_title&&(r+=e?p.red("!"):"!"),(i.scope||i.type||n&&w)&&(r+=": ");let U=t.check_ticket.title_position==="start",K=t.check_ticket.title_position==="end";if(n&&t.check_ticket.add_to_title&&U&&(r+=e?p.magenta(n)+" ":n+" "),i.title&&(r+=e?p.reset(i.title):i.title),n&&t.check_ticket.add_to_title&&K&&(r+=" "+(e?p.magenta(n):n)),i.body){let C=i.body.split("\\n").map(x=>e?p.reset(x.trim()):x.trim()).join(`
2
+ import{a as gt,b as dt,d as ft,e as R,f as T,g as f,h as N,i as S,j as Q,k as ht,l as Z}from"./chunk-5EGZQSNM.js";import{a as nt,c as at,f as n,i as ct,k as lt,l as mt,m as pt,o as E,p as ut,q as _t,r as g,s as d}from"./chunk-F4EBQBBK.js";import{chdir as Wt}from"process";import*as Y from"@clack/prompts";import{ValiError as qt,parse as St}from"valibot";import Kt from"configstore";import*as I from"@clack/prompts";var p=class{constructor(t,e,o){this.config=t;this.commit_state=e;this.prompt_cache=o}};var j=class extends p{async run(){if(this.#i){let{initial_value:t,message:e}=this.#e,s=await(this.config.commit_type.autocomplete?I.autocomplete:I.select)({message:e,initialValue:t,maxItems:this.#s,options:this.#t});I.isCancel(s)&&process.exit(0),this.#r(s)}}get#i(){return this.config.commit_type.enable}get#e(){let t=g(this.prompt_cache,"commit_type");if(t)return{initial_value:t,message:f("Commit type")};if(this.config.commit_type.infer_type_from_branch){let e=R(this.#t,n.git_args);if(e)return{message:N("Commit type"),initial_value:e}}return{initial_value:this.config.commit_type.initial_value,message:"Select a commit type"}}get#t(){return this.config.commit_type.options}get#o(){return this.#t.reduce((t,e)=>({...t,[e.value]:{emoji:e.emoji??"",trailer:e.trailer??""}}),{})}get#s(){return this.config.commit_type.max_items}#r(t){d(this.prompt_cache,"commit_type",t);let e=this.#o;this.commit_state.trailer=e[t].trailer,this.commit_state.type=this.config.commit_type.append_emoji_to_commit&&this.config.commit_type.emoji_commit_position==="Start"?`${e[t].emoji} ${t}`.trim():t}};import*as v from"@clack/prompts";var D=class extends p{async run(){if(!this.#i)return;let{initial_value:t,message:e}=this.#e(),s=await(this.config.commit_scope.autocomplete?v.autocomplete:v.select)({message:e,initialValue:t,maxItems:this.#t,options:this.#o});v.isCancel(s)&&process.exit(0),await this.#r(s)}get#i(){return this.config.commit_scope.enable}#e(){let t=g(this.prompt_cache,"commit_scope");return t?{initial_value:t,message:f("Commit scope")}:{initial_value:this.config.commit_scope.initial_value,message:"Select a commit scope"}}get#t(){return this.config.commit_scope.max_items}get#o(){return this.config.commit_scope.options}get#s(){return this.config.commit_scope.custom_scope}async#r(t){d(this.prompt_cache,"commit_scope",t);let e=t;if(e===nt&&this.#s){let o=await v.text({message:"Write a custom scope",placeholder:""});v.isCancel(o)&&process.exit(0),e=o??""}this.commit_state.scope=e}};import*as G from"@clack/prompts";var L=class extends p{async run(){let{initial_value:t,message:e}=this.#o();if(this.commit_state.ticket=t,this.#e){let o=await G.text({message:e,placeholder:"",initialValue:t});G.isCancel(o)&&process.exit(0),d(this.prompt_cache,"commit_ticket",o),this.commit_state.ticket=o??""}this.#t&&this.commit_state.ticket&&!this.commit_state.ticket.startsWith("#")&&(this.commit_state.ticket="#"+this.commit_state.ticket)}get#i(){return this.config.check_ticket.infer_ticket}get#e(){return this.config.check_ticket.confirm_ticket}get#t(){return this.config.check_ticket.prepend_hashtag==="Always"}#o(){let t=g(this.prompt_cache,"commit_ticket");if(t)return{initial_value:t,message:f("Ticket / issue")};if(this.#i){let e=T({append_hashtag:this.config.check_ticket.append_hashtag,prepend_hashtag:this.config.check_ticket.prepend_hashtag},n.git_args);if(e)return{initial_value:e,message:N("Ticket / issue")}}return{initial_value:this.commit_state.ticket,message:S("Add ticket / issue")}}};import*as B from"@clack/prompts";var M=class extends p{async run(){let{initial_value:t,message:e}=this.#i(),o=await B.text({message:e,initialValue:t,placeholder:"",validate:s=>this.#e(s)});B.isCancel(o)&&process.exit(0),this.#n(o??"")}#i(){let t=g(this.prompt_cache,"commit_title");return t?{initial_value:t,message:f("Commit title")}:{initial_value:this.commit_state.title,message:"Write a brief title describing the commit"}}#e(t){if(!t)return"Please enter a title";if(this.#o(t)>this.#t)return`Exceeded max length. Title max [${this.#t}]`}get#t(){return this.config.commit_title.max_size}#o(t){return gt({type:this.commit_state.type,scope:this.commit_state.scope,ticket:this.commit_state.ticket,title:t},{include_ticket:this.config.check_ticket.add_to_title})}get#s(){return this.config.commit_type.options.reduce((t,e)=>({...t,[e.value]:{emoji:e.emoji??""}}),{})}#r(t){return this.config.commit_type.append_emoji_to_commit&&this.config.commit_type.emoji_commit_position==="After-Colon"?`${this.#s[this.commit_state.type]?.emoji??""} ${t}`.trim():t}#n(t){d(this.prompt_cache,"commit_title",t),this.commit_state.title=_t(this.#r(t))}};import*as q from"@clack/prompts";var W=class extends p{async run(){if(!this.#i)return;let{initial_value:t,message:e}=this.#e(),o=await q.text({message:e,initialValue:t,placeholder:"",validate:s=>this.#t(s)});q.isCancel(o)&&process.exit(0),this.#s(o??"")}get#i(){return this.config.commit_body.enable}#e(){let t=g(this.prompt_cache,"commit_body");return t?{initial_value:t,message:f("Commit body")}:{initial_value:"",message:S("Write a detailed description of the changes")}}#t(t){if(this.config.commit_body.required&&!t)return"Please enter a description"}#o(t){return this.config.commit_body.split_by_period?t.split(/\.\s+/).map(o=>o.trim()).join(`.
3
+ `):t}#s(t){d(this.prompt_cache,"commit_body",t),this.commit_state.body=this.#o(t)}};import*as k from"@clack/prompts";var K=class extends p{async run(){if(!this.#i)return;let{initial_values:t,message:e}=this.#o(),o=await k.multiselect({message:e,initialValues:t,options:this.#e,required:!1});k.isCancel(o)&&process.exit(0);let s=this.#r(o),r=await this.#n(s);this.#l(o,s,r)}get#i(){return this.config.commit_footer.enable}get#e(){let t=new Set(this.config.commit_footer.options);return ct.filter(e=>t.has(e.value))}get#t(){return this.#e.map(t=>t.value)}#o(){let t=g(this.prompt_cache,"commit_footer");return t?{initial_values:this.#s(t),message:Q(f("Commit footers"))}:{initial_values:this.config.commit_footer.initial_value.filter(o=>this.#t.includes(o)),message:Q(S("Select optional footers"))}}#s(t){return t.split(",").map(e=>e.trim()).filter(e=>this.#t.includes(e))}#r(t){return{includes_breaking_change:t.includes("breaking-change"),includes_deprecated:t.includes("deprecated"),includes_closes:t.includes("closes"),includes_custom:t.includes("custom"),includes_trailer:t.includes("trailer")}}async#n(t){let e={breaking_title:"",breaking_body:"",deprecated_title:"",deprecated_body:"",custom_footer:""};return t.includes_breaking_change&&(e.breaking_title=await this.#c("Breaking changes: Write a short title / summary"),e.breaking_body=await this.#a(S("Breaking Changes: Write a description & migration instructions"))),t.includes_deprecated&&(e.deprecated_title=await this.#c("Deprecated: Write a short title / summary"),e.deprecated_body=await this.#a(S("Deprecated: Write a description"))),t.includes_custom&&(e.custom_footer=await this.#a("Write a custom footer")),e}async#c(t){let e=await k.text({message:t,placeholder:"",validate:o=>{if(!o)return"Please enter a title / summary"}});return k.isCancel(e)&&process.exit(0),e??""}async#a(t){let e=await k.text({message:t,placeholder:""});return k.isCancel(e)&&process.exit(0),e??""}#l(t,e,o){d(this.prompt_cache,"commit_footer",t.join(",")),this.commit_state.breaking_title=o.breaking_title,this.commit_state.breaking_body=o.breaking_body,this.commit_state.deprecates_title=o.deprecated_title,this.commit_state.deprecates_body=o.deprecated_body,this.commit_state.custom_footer=o.custom_footer,this.commit_state.closes=e.includes_closes?"Closes:":"",e.includes_trailer||(this.commit_state.trailer="")}};import*as h from"@clack/prompts";import{execSync as bt}from"child_process";import u from"picocolors";function z({commit_state:i,config:t,colorize:e=!1,escape_quotes:o=!1,include_trailer:s=!1}){let r="";if(i.type&&(r+=e?u.blue(i.type):i.type),i.scope){let l=e?u.cyan(i.scope):i.scope;r+=`(${l})`}let a=i.ticket,m=t.check_ticket.surround;if(i.ticket&&m){let l=m.charAt(0),O=m.charAt(1);a=`${l}${i.ticket}${O}`}let C=t.check_ticket.title_position==="beginning";a&&t.check_ticket.add_to_title&&C&&(r=`${e?u.magenta(a):a} ${r}`);let x=t.check_ticket.title_position==="before-colon";if(a&&t.check_ticket.add_to_title&&x){let l=i.scope||i.type&&!t.check_ticket.surround?" ":"";r+=e?u.magenta(l+a):l+a}i.breaking_title&&t.breaking_change.add_exclamation_to_title&&(r+=e?u.red("!"):"!"),(i.scope||i.type||a&&x)&&(r+=": ");let b=t.check_ticket.title_position==="start",V=t.check_ticket.title_position==="end";if(a&&t.check_ticket.add_to_title&&b&&(r+=e?u.magenta(a)+" ":a+" "),i.title&&(r+=e?u.reset(i.title):i.title),a&&t.check_ticket.add_to_title&&V&&(r+=" "+(e?u.magenta(a):a)),i.body){let O=i.body.split("\\n").map(w=>e?u.reset(w.trim()):w.trim()).join(`
4
4
  `);r+=`
5
5
 
6
- ${C}`}if(i.breaking_title){let c=e?p.red(`BREAKING CHANGE: ${i.breaking_title}`):`BREAKING CHANGE: ${i.breaking_title}`;r+=`
6
+ ${O}`}if(i.breaking_title){let l=e?u.red(`BREAKING CHANGE: ${i.breaking_title}`):`BREAKING CHANGE: ${i.breaking_title}`;r+=`
7
7
 
8
- ${c}`}if(i.breaking_body){let c=e?p.red(i.breaking_body):i.breaking_body;r+=`
8
+ ${l}`}if(i.breaking_body){let l=e?u.red(i.breaking_body):i.breaking_body;r+=`
9
9
 
10
- ${c}`}if(i.deprecates_title){let c=e?p.yellow(`DEPRECATED: ${i.deprecates_title}`):`DEPRECATED: ${i.deprecates_title}`;r+=`
10
+ ${l}`}if(i.deprecates_title){let l=e?u.yellow(`DEPRECATED: ${i.deprecates_title}`):`DEPRECATED: ${i.deprecates_title}`;r+=`
11
11
 
12
- ${c}`}if(i.deprecates_body){let c=e?p.yellow(i.deprecates_body):i.deprecates_body;r+=`
12
+ ${l}`}if(i.deprecates_body){let l=e?u.yellow(i.deprecates_body):i.deprecates_body;r+=`
13
13
 
14
- ${c}`}if(i.custom_footer){let C=i.custom_footer.split("\\n").map(x=>e?p.reset(x.trim()):x.trim()).join(`
14
+ ${l}`}if(i.custom_footer){let O=i.custom_footer.split("\\n").map(w=>e?u.reset(w.trim()):w.trim()).join(`
15
15
  `);r+=`
16
16
 
17
- ${C}`}return i.closes&&i.ticket&&(r+=e?`
17
+ ${O}`}return i.closes&&i.ticket&&(r+=e?`
18
18
 
19
- ${p.reset(i.closes)} ${p.magenta(i.ticket)}`:`
19
+ ${u.reset(i.closes)} ${u.magenta(i.ticket)}`:`
20
20
 
21
- ${i.closes} ${i.ticket}`),a&&i.trailer&&(r+=e?`
21
+ ${i.closes} ${i.ticket}`),s&&i.trailer&&(r+=e?`
22
22
 
23
- ${p.dim(i.trailer)}`:`
23
+ ${u.dim(i.trailer)}`:`
24
24
 
25
- ${i.trailer}`),o&&(r=r.replaceAll('"','\\"').replaceAll("`","\\`")),r}var O=class extends m{async run(){this.#o&&(mt(`${this.#n} --edit`,this.#i),process.exit(0)),this.#e&&d.note(J({commit_state:this.commit_state,config:this.config,colorize:!0,escape_quotes:!1,include_trailer:!0}),"Commit Preview"),await this.#a()||(d.log.info("Exiting without commit"),process.exit(0));try{d.log.info(s.dry_run?Y("Committing changes..."):"Committing changes..."),mt(this.#n,s.dry_run?this.#r:this.#i)}catch(e){d.log.error("Something went wrong when committing: "+e);return}this.#m()}get#o(){return s.interactive&&this.config.confirm_with_editor}get#e(){return this.config.print_commit_output}get#t(){return this.config.confirm_commit}get#i(){return this.config.overrides.shell?{shell:this.config.overrides.shell,stdio:"inherit"}:{stdio:"inherit"}}get#r(){return this.config.overrides.shell?{shell:this.config.overrides.shell,stdio:"pipe"}:{stdio:"pipe"}}get#s(){return this.commit_state.trailer?`--trailer="${this.commit_state.trailer}"`:""}get#n(){return`git ${s.git_args} commit -m "${J({commit_state:this.commit_state,config:this.config,colorize:!1,escape_quotes:!0,include_trailer:!1})}" ${this.#s} ${this.#c}`.trim()}get#c(){return s.dry_run?"--dry-run --porcelain --untracked-files=no":""}async#a(){if(!s.interactive||!this.#t)return!0;let t=await d.confirm({message:s.dry_run?Y("Confirm Commit?"):"Confirm Commit?"});return d.isCancel(t)&&process.exit(0),t}#m(){d.log.success("Commit Complete");let t=this.prompt_cache.get("username");this.prompt_cache.clear(),t&&this.prompt_cache.set("username",t)}};import*as b from"@clack/prompts";import S from"picocolors";import{execSync as lt}from"child_process";import*as W from"@clack/prompts";import Q from"picocolors";var pt=["M","T","R","D","A","C"];function X(){let i="";try{i=lt(`git ${s.git_args} status --porcelain`,{stdio:"pipe"}).toString()}catch(a){return W.log.error(Q.red("Failed to git status"+a)),{index:[],work_tree:[]}}let t=i.split(`
26
- `),e=[],o=[];return t.forEach(a=>{let r=a.trimEnd();if(!r)return;let n=r.substring(2).trim(),l=r.charAt(0).trim(),v=r.charAt(1).trim();(l==="?"||v==="?")&&e.push(n),pt.includes(l)&&o.push(n),pt.includes(v)&&e.push(n)}),{index:o,work_tree:e}}function _t(i){let t=i.join(" ");if(t)try{lt(`git ${s.git_args} add ${t}`,{stdio:"pipe"}).toString(),W.log.success(Q.green("Changes successfully staged"))}catch{W.log.error(Q.red("Failed to stage changes"))}}var q=class extends m{async run(){if(!this.#o)return;let t=X();if(this.#e(t),t.work_tree.length){let e=await this.#i(t.work_tree);e.length&&_t(e)}this.#r()}get#o(){return this.config.check_status}#e(t){b.log.step(S.black(S.bgGreen(" Checking Git Status ")));let e=this.#t(t.index,S.green);if(b.log.success(`Changes to be committed:
27
- `+e),!t.work_tree.length)return;let o=this.#t(t.work_tree,S.red);b.log.error(`Changes not staged for commit:
28
- `+o)}#t(t,e){return t.reduce((o,a,r)=>e(o+a+rt(t,r)),"")}async#i(t){let e=await b.multiselect({message:$("Some files have not been staged, would you like to add them now?"),options:[{value:".",label:"."},...t.map(o=>({value:o,label:o}))],required:!1});return b.isCancel(e)&&process.exit(0),e}#r(){X().index.length||(b.log.error(S.red('no changes added to commit (use "git add" and/or "git commit -a")')),process.exit(0))}};import{execSync as ft}from"child_process";import _ from"picocolors";var dt={"better-branch":"Create a branch or worktree from a guided prompt flow.","better-commits-init":"Create a .better-commits.json config in this repository."},ht={"--interactive":"Run in interactive prompt mode (default behavior).","--dry-run":"Print the commit command without creating a commit.","--help":"Show help information and exit."},bt={"--type":"Set commit type (for example feat, fix, docs).","--scope":"Set commit scope.","--title":"Set commit title/description.","--body":"Set commit body text.","--closes":"Set issue/ticket id for a closes footer.","--ticket":"Set ticket value used in the title.","--trailer":"Set trailer footer value.","--deprecates":"Set issue/ticket id for a deprecates footer.","--breaking-title":"Set breaking-change title footer.","--breaking-body":"Set breaking-change body footer.","--deprecates-title":"Set deprecates footer title text.","--deprecates-body":"Set deprecates footer body text.","--custom-footer":"Set a custom footer line."},yt={"--git-dir":"Set the path to the .git directory.","--work-tree":"Set the path to the working tree root."};function B(i){let o=" ";return Object.entries(i).map(([a,r])=>{let n=Math.max(2,26-a.length);return`${o}${a}${" ".repeat(n)}${r}`}).join(`
29
- `)}function gt(i,t){let e=I(),o="(none)";try{o=ft(`git ${s.git_args} branch --show-current`,{stdio:"pipe"}).toString().trim()||"(none)"}catch{}let a=F(i.commit_type.options,s.git_args)||"Unknown",r=i.check_ticket.infer_ticket?P({append_hashtag:i.check_ticket.append_hashtag,prepend_hashtag:i.check_ticket.prepend_hashtag},s.git_args)||"Unknown":"Infer Disabled",n=i.commit_type.options.map(c=>c.value).join(", ").trim(),l=i.commit_scope.options.map(c=>c.value).join(", ").trim(),v=B(ht),w=B(yt),U=B(bt),K=B(dt);console.log(`
25
+ ${i.trailer}`),o&&(r=r.replaceAll('"','\\"').replaceAll("`","\\`")),r}var F=class extends p{async run(){this.#i&&(bt(`${this.#n} --edit`,this.#o),process.exit(0)),this.#e&&h.note(z({commit_state:this.commit_state,config:this.config,colorize:!0,escape_quotes:!1,include_trailer:!0}),"Commit Preview"),await this.#a()||(h.log.info("Exiting without commit"),process.exit(0));try{h.log.info(n.dry_run?Z("Committing changes..."):"Committing changes..."),bt(this.#n,n.dry_run?this.#s:this.#o)}catch(e){h.log.error("Something went wrong when committing: "+e);return}this.#l()}get#i(){return n.interactive&&this.config.confirm_with_editor}get#e(){return this.config.print_commit_output}get#t(){return this.config.confirm_commit}get#o(){return this.config.overrides.shell?{shell:this.config.overrides.shell,stdio:"inherit"}:{stdio:"inherit"}}get#s(){return this.config.overrides.shell?{shell:this.config.overrides.shell,stdio:"pipe"}:{stdio:"pipe"}}get#r(){return this.commit_state.trailer?`--trailer="${this.commit_state.trailer}"`:""}get#n(){return`git ${n.git_args} commit -m "${z({commit_state:this.commit_state,config:this.config,colorize:!1,escape_quotes:!0,include_trailer:!1})}" ${this.#r} ${this.#c}`.trim()}get#c(){return n.dry_run?"--dry-run --porcelain --untracked-files=no":""}async#a(){if(!n.interactive||!this.#t)return!0;let t=await h.confirm({message:n.dry_run?Z("Confirm Commit?"):"Confirm Commit?"});return h.isCancel(t)&&process.exit(0),t}#l(){h.log.success("Commit Complete");let t=this.prompt_cache.get("username");this.prompt_cache.clear(),t&&this.prompt_cache.set("username",t)}};import*as $ from"@clack/prompts";import A from"picocolors";import{execSync as vt}from"child_process";import*as H from"@clack/prompts";import tt from"picocolors";var yt=["M","T","R","D","A","C"];function et(){let i="";try{i=vt(`git ${n.git_args} status --porcelain`,{stdio:"pipe"}).toString()}catch(s){return H.log.error(tt.red("Failed to git status"+s)),{index:[],work_tree:[]}}let t=i.split(`
26
+ `),e=[],o=[];return t.forEach(s=>{let r=s.trimEnd();if(!r)return;let a=r.substring(2).trim(),m=r.charAt(0).trim(),C=r.charAt(1).trim();(m==="?"||C==="?")&&e.push(a),yt.includes(m)&&o.push(a),yt.includes(C)&&e.push(a)}),{index:o,work_tree:e}}function kt(i){let t=i.join(" ");if(t)try{vt(`git ${n.git_args} add ${t}`,{stdio:"pipe"}).toString(),H.log.success(tt.green("Changes successfully staged"))}catch{H.log.error(tt.red("Failed to stage changes"))}}import{styleText as c}from"node:util";import{AutocompletePrompt as Ft}from"@clack/core";import{S_BAR as P,S_BAR_END as Pt,S_CHECKBOX_INACTIVE as $t,S_CHECKBOX_SELECTED as At,limitOptions as Et,settings as Rt,symbol as Tt}from"@clack/prompts";function Nt(i,t){if(!i)return!0;let e=(t.label??String(t.value??"")).toLowerCase(),o=(t.hint??"").toLowerCase(),s=String(t.value).toLowerCase(),r=i.toLowerCase();return e.includes(r)||o.includes(r)||s.includes(r)}function jt(i,t){return i===""||t.ctrl===!0&&t.name==="a"}var it=class extends Ft{constructor(e){super({options:e.options,multiple:!0,filter:e.filter??((o,s)=>Nt(o,s)),validate:o=>e.required&&(!Array.isArray(o)||o.length===0)?"Please select at least one item":e.validate?.(o),initialValue:e.initialValues,signal:e.signal,input:e.input,output:e.output,render(){let o=e.withGuide??Rt.withGuide,s=`${o?`${c("gray",P)}
27
+ `:""}${Tt(this.state)} ${e.message}
28
+ `,r=this.userInput,a=this.userInputWithCursor,m=this.options,C=this.filteredOptions.length!==m.length?c("dim",` (${this.filteredOptions.length} match${this.filteredOptions.length===1?"":"es"})`):"";switch(this.state){case"submit":return`${s}${o?`${c("gray",P)} `:""}${c("dim",`${this.selectedValues.length} items selected`)}`;case"cancel":return`${s}${o?`${c("gray",P)} `:""}${c(["strikethrough","dim"],r)}`;default:{let x=this.state==="error"?"yellow":"cyan",b=o?`${c(x,P)} `:"",V=o?c(x,Pt):"",l=[`${c("dim","\u2191/\u2193")} to navigate`,`${c("dim",this.isNavigating?"Space/Tab:":"Tab:")} select`,`${c("dim","Ctrl+a:")} select visible`,`${c("dim","Enter:")} confirm`,`${c("dim","Type:")} to search`],O=this.filteredOptions.length===0&&r?[`${b}${c("yellow","No matches found")}`]:[],w=this.state==="error"?[`${b}${c("yellow",this.error)}`]:[],ot=[...`${s}${o?c(x,P):""}`.split(`
29
+ `),`${b}${c("dim","Search:")} ${a}${C}`,...O,...w],st=[`${b}${l.join(" \u2022 ")}`,V],Ot=Et({cursor:this.cursor,options:this.filteredOptions,style:(y,wt)=>{let It=this.selectedValues.includes(y.value),J=y.label??String(y.value??""),Vt=y.hint&&this.focusedValue!==void 0&&y.value===this.focusedValue?c("dim",` (${y.hint})`):"",rt=It?c("green",At):c("dim",$t);return y.disabled?`${c("gray",$t)} ${c(["strikethrough","gray"],J)}`:wt?`${rt} ${J}${Vt}`:`${rt} ${c("dim",J)}`},maxItems:e.maxItems,output:e.output,rowPadding:ot.length+st.length});return[...ot,...Ot.map(y=>`${b}${y}`),...st].join(`
30
+ `)}}}});this.promptOptions=e;this.on("key",(o,s)=>{jt(o,s)&&(this.#i(),this.isNavigating=!0,this.#e())})}#i(){let e=this.filteredOptions.filter(s=>!s.disabled).map(s=>s.value);if(!e.length)return;let o=e.every(s=>this.selectedValues.includes(s));this.selectedValues=o?this.selectedValues.filter(s=>!e.includes(s)):[...this.selectedValues,...e.filter(s=>!this.selectedValues.includes(s))]}#e(){let e=this.rl;e?.write("",{ctrl:!0,name:"e"}),this._cursor=e?.cursor??this.userInput.length}};function Ct(i){return new it(i).prompt()}var U=class extends p{async run(){if(!this.#i)return;let t=et();if(this.#e(t),t.work_tree.length){let e=await this.#o(t.work_tree);e.length&&kt(e)}this.#s()}get#i(){return this.config.check_status}#e(t){$.log.step(A.black(A.bgGreen(" Checking Git Status ")));let e=this.#t(t.index,A.green);if($.log.success(`Changes to be committed:
31
+ `+e),!t.work_tree.length)return;let o=this.#t(t.work_tree,A.red);$.log.error(`Changes not staged for commit:
32
+ `+o)}#t(t,e){return t.reduce((o,s,r)=>e(o+s+ut(t,r)),"")}async#o(t){let e=this.config.check_status_autocomplete?await Ct({message:"Some files have not been staged, add them now?",options:t.map(o=>({value:o,label:o})),required:!1}):await $.multiselect({message:ht("Some files have not been staged, add them now?"),options:t.map(o=>({value:o,label:o})),required:!1});return $.isCancel(e)&&process.exit(0),e}#s(){et().index.length||($.log.error(A.red('no changes added to commit (use "git add" and/or "git commit -a")')),process.exit(0))}};import{execSync as Dt}from"child_process";import _ from"picocolors";var Lt={"better-branch":"Create a branch or worktree from a guided prompt flow.","better-commits-init":"Create a .better-commits.json config in this repository."},Gt={"--interactive":"Run in interactive prompt mode (default behavior).","--dry-run":"Print the commit command without creating a commit.","--help":"Show help information and exit."},Mt={"--type":"Set commit type (for example feat, fix, docs).","--scope":"Set commit scope.","--title":"Set commit title/description.","--body":"Set commit body text.","--closes":"Set issue/ticket id for a closes footer.","--ticket":"Set ticket value used in the title.","--trailer":"Set trailer footer value.","--deprecates":"Set issue/ticket id for a deprecates footer.","--breaking-title":"Set breaking-change title footer.","--breaking-body":"Set breaking-change body footer.","--deprecates-title":"Set deprecates footer title text.","--deprecates-body":"Set deprecates footer body text.","--custom-footer":"Set a custom footer line."},Bt={"--git-dir":"Set the path to the .git directory.","--work-tree":"Set the path to the working tree root."};function X(i){let o=" ";return Object.entries(i).map(([s,r])=>{let a=Math.max(2,26-s.length);return`${o}${s}${" ".repeat(a)}${r}`}).join(`
33
+ `)}function xt(i,t){let e=E(),o="(none)";try{o=Dt(`git ${n.git_args} branch --show-current`,{stdio:"pipe"}).toString().trim()||"(none)"}catch{}let s=R(i.commit_type.options,n.git_args)||"Unknown",r=i.check_ticket.infer_ticket?T({append_hashtag:i.check_ticket.append_hashtag,prepend_hashtag:i.check_ticket.prepend_hashtag},n.git_args)||"Unknown":"Infer Disabled",a=i.commit_type.options.map(l=>l.value).join(", ").trim(),m=i.commit_scope.options.map(l=>l.value).join(", ").trim(),C=X(Gt),x=X(Bt),b=X(Mt),V=X(Lt);console.log(`
30
34
  ${_.green("\uF489 better-commits")} ${_.gray("v"+e)}
31
35
 
32
36
  ${_.gray("BRANCH")}
33
37
  ${o}
34
- ${_.gray("Type")} ${_.blue(a)} ${_.gray("\xB7")} ${_.gray("Ticket")} ${_.magenta(r)}
38
+ ${_.gray("Type")} ${_.blue(s)} ${_.gray("\xB7")} ${_.gray("Ticket")} ${_.magenta(r)}
35
39
 
36
40
  ${_.gray("CONFIGURATION")}
37
41
  ${t}
38
42
 
39
43
  ${_.gray("Types")}
40
- ${n}
44
+ ${a}
41
45
 
42
46
  ${_.gray("Scopes")}
43
- ${l}
47
+ ${m}
44
48
 
45
49
  ${_.gray("CLI FLAGS")}
46
- ${v}
50
+ ${C}
47
51
 
48
52
  ${_.gray("Commit Flags")}
49
- ${U}
53
+ ${b}
50
54
 
51
55
  ${_.gray("Git Flags (Advanced)")}
52
- ${w}
56
+ ${x}
53
57
 
54
58
  ${_.gray("ADDITIONAL COMMANDS")}
55
- ${K}
59
+ ${V}
56
60
 
57
- `)}var xt=[q,R,j,E,D,M,V,O],{config:$t,config_source:Ot}=it();St($t,Ot);async function St(i,t){if(kt(ot()),s.version){let l=I();H.log.step("Better Commits v"+l);return}if(s.help){gt(i,t);return}let e=ct(i),o={...s.commit_state,type:(s.commit_state.type||e?.type)??"",ticket:(s.commit_state.ticket||e?.ticket)??""},a=ut(z,o);if(!s.interactive)try{ut(at(i),a)}catch(l){l instanceof vt?H.log.error(`Invalid commit input: ${l.message}`):H.log.error(`Failed to validate commit input: ${l}`),process.exit(0)}let r=i.cache_last_value?new Ct("better-commits"):et,n=s.interactive?xt:[O];for(let l of n)await new l(i,a,r).run()}export{St as main};
61
+ `)}var Ht=[U,j,D,L,M,W,K,F],{config:Ut,config_source:Xt}=mt();Yt(Ut,Xt);async function Yt(i,t){if(Wt(pt()),n.version){let m=E();Y.log.step("Better Commits v"+m);return}if(n.help){xt(i,t);return}let e=ft(i),o={...n.commit_state,type:(n.commit_state.type||e?.type)??"",ticket:(n.commit_state.ticket||e?.ticket)??""},s=St(at,o);if(!n.interactive)try{St(dt(i),s)}catch(m){m instanceof qt?Y.log.error(`Invalid commit input: ${m.message}`):Y.log.error(`Failed to validate commit input: ${m}`),process.exit(0)}let r=i.cache_last_value?new Kt("better-commits"):lt,a=n.interactive?Ht:[F];for(let m of a)await new m(i,s,r).run()}export{Yt as main};
package/dist/init.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #! /usr/bin/env node
2
- import{g as c,h as e,m as a,n as p}from"./chunk-QPUTIRGU.js";import*as t from"@clack/prompts";import l from"fs";import o from"picocolors";try{await m()}catch{t.log.error(`${o.red("Could not determine git root folder. better-commits-init must be used in a git repository")}`)}async function m(){console.clear(),t.intro(`${o.bgCyan(o.black(" better-commits-init "))}`);let r=a(),i=p(r),s=`${r}/${e}`;if(i){let n=await t.confirm({message:`${i.split("/").pop()} already exists. Replace with default ${e}?`});if(t.isCancel(n)||!n){t.outro("Cancelled");return}}l.writeFileSync(s,c),t.log.success(`${o.green(`Successfully created ${s.split("/").pop()}`)}`),t.outro(`Run ${o.bgBlack(o.white("better-commits"))} to start the CLI`)}export{m as create_init_config};
2
+ import{g as c,h as e,m as a,n as p}from"./chunk-F4EBQBBK.js";import*as t from"@clack/prompts";import l from"fs";import o from"picocolors";await m();async function m(){console.clear(),t.intro(`${o.bgCyan(o.black(" better-commits-init "))}`);let r=a(),i=p(r),s=`${r}/${e}`;if(i){let n=await t.confirm({message:`${i.split("/").pop()} already exists. Replace with default ${e}?`});if(t.isCancel(n)||!n){t.outro("Cancelled");return}}try{l.writeFileSync(s,c)}catch{t.log.error(`${o.red("Could not determine git root folder. better-commits-init must be used in a git repository")}`)}t.log.success(`${o.green(`Successfully created ${s.split("/").pop()}`)}`),t.outro(`Run ${o.bgBlack(o.white("better-commits"))} to start the CLI`)}export{m as create_init_config};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "better-commits",
3
3
  "private": false,
4
- "version": "1.20.1-temp.0",
4
+ "version": "1.22.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
  "type": "module",
@@ -20,11 +20,6 @@
20
20
  "bcommits": "./dist/index.js",
21
21
  "git-bc": "./dist/index.js"
22
22
  },
23
- "files": [
24
- "dist",
25
- "LICENSE",
26
- "readme.md"
27
- ],
28
23
  "license": "MIT",
29
24
  "repository": {
30
25
  "type": "git",
@@ -51,7 +46,7 @@
51
46
  "@semantic-release/git": "^10.0.1",
52
47
  "@semantic-release/npm": "^13.1.3",
53
48
  "@types/configstore": "^6.0.0",
54
- "@types/node": "^18.14.5",
49
+ "@types/node": "^24.10.1",
55
50
  "jiti": "^1.17.0",
56
51
  "prettier": "3.2.5",
57
52
  "semantic-release": "^25.0.2",
package/readme.md CHANGED
@@ -87,6 +87,7 @@ To create a **repository-specific config**, navigate to the root of your project
87
87
  {
88
88
  // Run interactive `git status` before composing a commit
89
89
  "check_status": true,
90
+ "check_status_autocomplete": true,
90
91
 
91
92
  /* COMMIT FIELDS */
92
93
  "commit_type": {
@@ -109,6 +110,8 @@ To create a **repository-specific config**, navigate to the root of your project
109
110
  // "Start" | "After-Colon"
110
111
  "emoji_commit_position": "Start",
111
112
 
113
+ "autocomplete": true,
114
+
112
115
  "options": [
113
116
  {
114
117
  "value": "feat",
@@ -190,6 +193,7 @@ To create a **repository-specific config**, navigate to the root of your project
190
193
  "initial_value": "app",
191
194
 
192
195
  "max_items": 20,
196
+ "autocomplete": true,
193
197
  "options": [
194
198
  { "value": "app", "label": "app" },
195
199
  { "value": "shared", "label": "shared" },
@@ -278,6 +282,7 @@ To create a **repository-specific config**, navigate to the root of your project
278
282
  "branch_type": {
279
283
  "enable": true,
280
284
  "separator": "/",
285
+ "autocomplete": true,
281
286
  },
282
287
 
283
288
  "branch_ticket": {
@@ -442,7 +447,7 @@ better-branch --no-interactive --type feat --ticket TAC-123 --description "add p
442
447
 
443
448
  #### Multi-line
444
449
 
445
- If your are having issues with multilines for commits on windows, you can override the shell via your `.better-commits.jsonc` config.
450
+ If you are having issues with multilines for commits on windows, you can override the shell via your `.better-commits.jsonc` config.
446
451
 
447
452
  Example
448
453