better-commits 1.20.0-cli-flags → 1.20.1-temp.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/dist/branch.js +1 -1
  2. package/dist/{chunk-SIF4LZUS.js → chunk-LPU7O52G.js} +1 -1
  3. package/dist/chunk-QPUTIRGU.js +245 -0
  4. package/dist/index.js +2 -2
  5. package/dist/init.js +1 -1
  6. package/package.json +7 -1
  7. package/readme.md +141 -173
  8. package/.better-commits.json +0 -52
  9. package/.github/workflows/publish.yml +0 -34
  10. package/.github/workflows/test.yml +0 -27
  11. package/.opencode/package-lock.json +0 -115
  12. package/.opencode/plans/cli-args.md +0 -182
  13. package/.prettierignore +0 -5
  14. package/.prettierrc +0 -1
  15. package/.svelte-kit/ambient.d.ts +0 -289
  16. package/.svelte-kit/generated/client/app.js +0 -28
  17. package/.svelte-kit/generated/client/matchers.js +0 -1
  18. package/.svelte-kit/generated/client/nodes/0.js +0 -1
  19. package/.svelte-kit/generated/client/nodes/1.js +0 -1
  20. package/.svelte-kit/tsconfig.json +0 -49
  21. package/0001-feat-branch-124-update-worktrees-feature.patch +0 -316
  22. package/dist/chunk-OFJCRS3N.js +0 -4
  23. package/docs/ai-skills.yaml +0 -48
  24. package/docs/clack.md +0 -143
  25. package/docs/valibot.md +0 -228
  26. package/src/args.test.ts +0 -102
  27. package/src/args.ts +0 -106
  28. package/src/branch-args.test.ts +0 -72
  29. package/src/branch-args.ts +0 -106
  30. package/src/branch-help.ts +0 -114
  31. package/src/branch.ts +0 -95
  32. package/src/git.ts +0 -60
  33. package/src/help.ts +0 -131
  34. package/src/index.test.ts +0 -7
  35. package/src/index.ts +0 -100
  36. package/src/init.ts +0 -25
  37. package/src/prompts/branch-checkout.prompt.ts +0 -36
  38. package/src/prompts/branch-confirm.prompt.ts +0 -134
  39. package/src/prompts/branch-description.prompt.ts +0 -37
  40. package/src/prompts/branch-runnable.ts +0 -13
  41. package/src/prompts/branch-ticket.prompt.ts +0 -41
  42. package/src/prompts/branch-type.prompt.ts +0 -43
  43. package/src/prompts/branch-user.prompt.ts +0 -50
  44. package/src/prompts/branch-version.prompt.ts +0 -41
  45. package/src/prompts/commit-body.prompt.ts +0 -57
  46. package/src/prompts/commit-confirm.prompt.ts +0 -119
  47. package/src/prompts/commit-footer.prompt.ts +0 -195
  48. package/src/prompts/commit-scope.prompt.ts +0 -73
  49. package/src/prompts/commit-status.prompt.ts +0 -75
  50. package/src/prompts/commit-ticket.prompt.ts +0 -82
  51. package/src/prompts/commit-title.prompt.ts +0 -98
  52. package/src/prompts/commit-type.prompt.ts +0 -93
  53. package/src/prompts/runnable.ts +0 -13
  54. package/src/utils/build-branch.test.ts +0 -141
  55. package/src/utils/build-branch.ts +0 -46
  56. package/src/utils/build-commit-string.test.ts +0 -253
  57. package/src/utils/build-commit-string.ts +0 -158
  58. package/src/utils/commit-title-size.ts +0 -24
  59. package/src/utils/infer.test.ts +0 -83
  60. package/src/utils/infer.ts +0 -114
  61. package/src/utils/messages.ts +0 -25
  62. package/src/utils/no-interactive-branch-validation.test.ts +0 -170
  63. package/src/utils/no-interactive-validation.test.ts +0 -174
  64. package/src/utils/no-interactive-validation.ts +0 -190
  65. package/src/utils.ts +0 -219
  66. package/src/valibot-consts.ts +0 -114
  67. package/src/valibot-state.test.ts +0 -48
  68. package/src/valibot-state.ts +0 -265
  69. package/tsconfig.json +0 -15
  70. package/tsup.config.ts +0 -12
  71. package/vitest.config.ts +0 -8
package/dist/branch.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #! /usr/bin/env node
2
- import{c as V,e as H,f as D,i as h}from"./chunk-SIF4LZUS.js";import{f as T,j as A,k as F,l as E,m as u,n as _,q as G,r as L}from"./chunk-OFJCRS3N.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(`
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
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
4
  ${c.green("\uF489 better-branch")} ${c.gray("v"+r)}
5
5
 
@@ -1 +1 @@
1
- import{c as m,e as u,g as p}from"./chunk-OFJCRS3N.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-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};
@@ -0,0 +1,245 @@
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=`{
2
+ // Run interactive \`git status\` before composing a commit
3
+ "check_status": true,
4
+
5
+ /* COMMIT FIELDS */
6
+ "commit_type": {
7
+ "enable": true,
8
+
9
+ // Default selected type from options
10
+ "initial_value": "feat",
11
+
12
+ // Infer type from the current branch name: user/TYPE/my-branch
13
+ "infer_type_from_branch": true,
14
+
15
+ // Include emoji in prompt label
16
+ "append_emoji_to_label": false,
17
+
18
+ // Include emoji from prompt label in commit message
19
+ "append_emoji_to_commit": false,
20
+
21
+ // "Start" | "After-Colon"
22
+ "emoji_commit_position": "Start",
23
+
24
+ "options": [
25
+ {
26
+ "value": "feat",
27
+ "label": "feat",
28
+ "hint": "A new feature",
29
+ "emoji": "\u{1F31F}",
30
+ "trailer": "Changelog: feature"
31
+ },
32
+ {
33
+ "value": "fix",
34
+ "label": "fix",
35
+ "hint": "A bug fix",
36
+ "emoji": "\u{1F41B}",
37
+ "trailer": "Changelog: fix"
38
+ },
39
+ {
40
+ "value": "docs",
41
+ "label": "docs",
42
+ "hint": "Documentation only changes",
43
+ "emoji": "\u{1F4DA}",
44
+ "trailer": "Changelog: documentation"
45
+ },
46
+ {
47
+ "value": "refactor",
48
+ "label": "refactor",
49
+ "hint": "A code change that neither fixes a bug nor adds a feature",
50
+ "emoji": "\u{1F528}",
51
+ "trailer": "Changelog: refactor"
52
+ },
53
+ {
54
+ "value": "perf",
55
+ "label": "perf",
56
+ "hint": "A code change that improves performance",
57
+ "emoji": "\u{1F680}",
58
+ "trailer": "Changelog: performance"
59
+ },
60
+ {
61
+ "value": "test",
62
+ "label": "test",
63
+ "hint": "Adding missing tests or correcting existing tests",
64
+ "emoji": "\u{1F6A8}",
65
+ "trailer": "Changelog: test"
66
+ },
67
+ {
68
+ "value": "build",
69
+ "label": "build",
70
+ "hint": "Changes that affect the build system or external dependencies",
71
+ "emoji": "\u{1F6A7}",
72
+ "trailer": "Changelog: build"
73
+ },
74
+ {
75
+ "value": "ci",
76
+ "label": "ci",
77
+ "hint": "Changes to our CI configuration files and scripts",
78
+ "emoji": "\u{1F916}",
79
+ "trailer": "Changelog: ci"
80
+ },
81
+ {
82
+ "value": "chore",
83
+ "label": "chore",
84
+ "hint": "Other changes that do not modify src or test files",
85
+ "emoji": "\u{1F9F9}",
86
+ "trailer": "Changelog: chore"
87
+ },
88
+ {
89
+ "value": "",
90
+ "label": "none"
91
+ }
92
+ ]
93
+ },
94
+
95
+ "commit_scope": {
96
+ "enable": true,
97
+
98
+ // If true, users can type a scope not listed in options
99
+ "custom_scope": false,
100
+
101
+ // Default selected scope from options
102
+ "initial_value": "app",
103
+
104
+ "max_items": 20,
105
+ "options": [
106
+ { "value": "app", "label": "app" },
107
+ { "value": "shared", "label": "shared" },
108
+ { "value": "server", "label": "server" },
109
+ { "value": "tools", "label": "tools" },
110
+ { "value": "", "label": "none" }
111
+ ]
112
+ },
113
+
114
+ "check_ticket": {
115
+ // Infer ticket / issue from the branch name - user/type/TICKET-my-branch
116
+ "infer_ticket": true,
117
+
118
+ // Prompt for confirmation / edit before using an inferred ticket
119
+ "confirm_ticket": true,
120
+
121
+ // Add the ticket to the commit title - feat(app): TICKET my commit title
122
+ "add_to_title": true,
123
+
124
+ // Deprecated, prefer \`prepend_hashtag\`
125
+ "append_hashtag": false,
126
+
127
+ // "Never" | "Prompt" | "Always" - 12345 --> #12345
128
+ "prepend_hashtag": "Never",
129
+
130
+ // Wrap the ticket in the commit title: "" | "[]" | "()" | "{}"
131
+ "surround": "",
132
+
133
+ // "start" | "end" | "before-colon" | "beginning"
134
+ "title_position": "start"
135
+ },
136
+
137
+ "commit_title": {
138
+ // Includes total size of title + type + scope + ticket
139
+ "max_size": 70
140
+ },
141
+
142
+ "commit_body": {
143
+ "enable": true,
144
+ "required": false,
145
+
146
+ // Split sentences into multiple lines automatically
147
+ "split_by_period": false
148
+ },
149
+
150
+ "commit_footer": {
151
+ "enable": true,
152
+ "initial_value": [],
153
+
154
+ // "closes", "trailer", "breaking-change", "deprecated", "custom"
155
+ "options": ["closes", "trailer", "breaking-change", "deprecated", "custom"]
156
+ },
157
+
158
+ "breaking_change": {
159
+ // Adds \`!\` to the commit title when a breaking change is selected
160
+ "add_exclamation_to_title": true
161
+ },
162
+
163
+ // Confirm / edit with $GIT_EDITOR or $EDITOR
164
+ "confirm_with_editor": false,
165
+
166
+ // Show a final confirmation prompt before running git commit
167
+ "confirm_commit": true,
168
+
169
+ // Reuse the last known value from a previous canceled or failed commit
170
+ "cache_last_value": true,
171
+
172
+ // Pretty-print the final commit preview before execution
173
+ "print_commit_output": true,
174
+
175
+ /* BRANCH FIELDS */
176
+ // Optional shell commands to run before / after creating branches or worktrees
177
+ "branch_pre_commands": [],
178
+ "branch_post_commands": [],
179
+ "worktree_pre_commands": [],
180
+ "worktree_post_commands": [],
181
+
182
+ "branch_user": {
183
+ "enable": true,
184
+ "required": false,
185
+
186
+ // "/" | "-" | "_" - user/feat/my-branch
187
+ "separator": "/"
188
+ },
189
+
190
+ "branch_type": {
191
+ "enable": true,
192
+ "separator": "/"
193
+ },
194
+
195
+ "branch_ticket": {
196
+ "enable": true,
197
+ "required": false,
198
+ "separator": "-"
199
+ },
200
+
201
+ "branch_version": {
202
+ "enable": false,
203
+ "required": false,
204
+ "separator": "/"
205
+ },
206
+
207
+ "branch_description": {
208
+ // Maximum length for the description segment of the branch name
209
+ "max_length": 70,
210
+
211
+ // Allowed values: "" | "/" | "-" | "_"
212
+ "separator": ""
213
+ },
214
+
215
+ // "branch" | "worktree"
216
+ "branch_action_default": "branch",
217
+
218
+ // Order of values in the final branch name
219
+ "branch_order": ["user", "version", "type", "ticket", "description"],
220
+
221
+ // Deprecated, prefer \`worktrees.enable\`
222
+ "enable_worktrees": true,
223
+
224
+ "worktrees": {
225
+ // If false, always create a branch instead of prompting for a worktree
226
+ "enable": true,
227
+
228
+ // Directory where worktrees are created
229
+ "base_path": "..",
230
+
231
+ // Available template variables include:
232
+ // {{repo_name}}, {{branch_description}}, {{user}}, {{type}}, {{ticket}}, {{version}}
233
+ "folder_template": "{{repo_name}}-{{ticket}}-{{branch_description}}"
234
+ },
235
+
236
+ /* OTHER FIELDS */
237
+ "overrides": {
238
+ // Useful on Windows or for shells with different multiline behavior
239
+ "shell": "/bin/sh"
240
+ }
241
+ }
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};
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
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-SIF4LZUS.js";import{a as Z,d as z,g as s,i as tt,k as et,l as it,m as ot,n as I,o as rt,p as st,q as g,r as u}from"./chunk-OFJCRS3N.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(`.
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
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(`
4
4
  `);r+=`
5
5
 
@@ -54,4 +54,4 @@ ${w}
54
54
  ${_.gray("ADDITIONAL COMMANDS")}
55
55
  ${K}
56
56
 
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 --no-interactive commit input: ${l.message}`):H.log.error(`Failed to validate --no-interactive 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};
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};
package/dist/init.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #! /usr/bin/env node
2
- import{b as r,h as e,m as i}from"./chunk-OFJCRS3N.js";import*as t from"@clack/prompts";import c from"fs";import o from"picocolors";import{parse as l}from"valibot";try{console.clear(),t.intro(`${o.bgCyan(o.black(" better-commits-init "))}`);let s=`${i()}/${e}`,m=l(r,{});c.writeFileSync(s,JSON.stringify(m,null,4)),t.log.success(`${o.green("Successfully created .better-commits.json")}`),t.outro(`Run ${o.bgBlack(o.white("better-commits"))} to start the CLI`)}catch{t.log.error(`${o.red("Could not determine git root folder. better-commits-init must be used in a git repository")}`)}
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};
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "better-commits",
3
3
  "private": false,
4
- "version": "1.20.0-cli-flags",
4
+ "version": "1.20.1-temp.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,6 +20,11 @@
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
+ ],
23
28
  "license": "MIT",
24
29
  "repository": {
25
30
  "type": "git",
@@ -30,6 +35,7 @@
30
35
  "@clack/core": "^1.2.0",
31
36
  "@clack/prompts": "^1.2.0",
32
37
  "configstore": "^5.0.1",
38
+ "jsonc-parser": "^3.3.1",
33
39
  "picocolors": "^1.0.0",
34
40
  "valibot": "^1.3.1"
35
41
  },