gitzy
Version:
interactive conventional commits cli
30 lines (26 loc) • 19.1 kB
JavaScript
var ee=Object.defineProperty;var r=(e,t)=>ee(e,"name",{value:t,configurable:!0});import{Option as te,program as v}from"commander";import re from"enquirer";import{spawn as se,exec as L}from"node:child_process";import w,{writeFileSync as oe}from"node:fs";import R from"node:path";import ne from"node:os";import{lilconfig as ie}from"lilconfig";import ce from"yaml";var $={exports:{}},O={exports:{}},P;function ae(){return P||(P=1,function(e){const t=typeof process<"u"&&process.env.TERM_PROGRAM==="Hyper",o=typeof process<"u"&&process.platform==="win32",c=typeof process<"u"&&process.platform==="linux",s={ballotDisabled:"\u2612",ballotOff:"\u2610",ballotOn:"\u2611",bullet:"\u2022",bulletWhite:"\u25E6",fullBlock:"\u2588",heart:"\u2764",identicalTo:"\u2261",line:"\u2500",mark:"\u203B",middot:"\xB7",minus:"\uFF0D",multiplication:"\xD7",obelus:"\xF7",pencilDownRight:"\u270E",pencilRight:"\u270F",pencilUpRight:"\u2710",percent:"%",pilcrow2:"\u2761",pilcrow:"\xB6",plusMinus:"\xB1",question:"?",section:"\xA7",starsOff:"\u2606",starsOn:"\u2605",upDownArrow:"\u2195"},a=Object.assign({},s,{check:"\u221A",cross:"\xD7",ellipsisLarge:"...",ellipsis:"...",info:"i",questionSmall:"?",pointer:">",pointerSmall:"\xBB",radioOff:"( )",radioOn:"(*)",warning:"\u203C"}),u=Object.assign({},s,{ballotCross:"\u2718",check:"\u2714",cross:"\u2716",ellipsisLarge:"\u22EF",ellipsis:"\u2026",info:"\u2139",questionFull:"\uFF1F",questionSmall:"\uFE56",pointer:c?"\u25B8":"\u276F",pointerSmall:c?"\u2023":"\u203A",radioOff:"\u25EF",radioOn:"\u25C9",warning:"\u26A0"});e.exports=o&&!t?a:u,Reflect.defineProperty(e.exports,"common",{enumerable:!1,value:s}),Reflect.defineProperty(e.exports,"windows",{enumerable:!1,value:a}),Reflect.defineProperty(e.exports,"other",{enumerable:!1,value:u})}(O)),O.exports}r(ae,"requireSymbols");var M;function ue(){if(M)return $.exports;M=1;const e=r(s=>s!==null&&typeof s=="object"&&!Array.isArray(s),"isObject"),t=/[\u001b\u009b][[\]#;?()]*(?:(?:(?:[^\W_]*;?[^\W_]*)\u0007)|(?:(?:[0-9]{1,4}(;[0-9]{0,4})*)?[~0-9=<>cf-nqrtyA-PRZ]))/g,o=r(()=>typeof process<"u"?process.env.FORCE_COLOR!=="0":!1,"hasColor"),c=r(()=>{const s={enabled:o(),visible:!0,styles:{},keys:{}},a=r(i=>{let l=i.open=`\x1B[${i.codes[0]}m`,g=i.close=`\x1B[${i.codes[1]}m`,m=i.regex=new RegExp(`\\u001b\\[${i.codes[1]}m`,"g");return i.wrap=(d,C)=>{d.includes(g)&&(d=d.replace(m,g+l));let T=l+d+g;return C?T.replace(/\r*\n/g,`${g}$&${l}`):T},i},"ansi"),u=r((i,l,g)=>typeof i=="function"?i(l):i.wrap(l,g),"wrap"),p=r((i,l)=>{if(i===""||i==null)return"";if(s.enabled===!1)return i;if(s.visible===!1)return"";let g=""+i,m=g.includes(`
`),d=l.length;for(d>0&&l.includes("unstyle")&&(l=[...new Set(["unstyle",...l])].reverse());d-- >0;)g=u(s.styles[l[d]],g,m);return g},"style"),n=r((i,l,g)=>{s.styles[i]=a({name:i,codes:l}),(s.keys[g]||(s.keys[g]=[])).push(i),Reflect.defineProperty(s,i,{configurable:!0,enumerable:!0,set(d){s.alias(i,d)},get(){let d=r(C=>p(C,d.stack),"color");return Reflect.setPrototypeOf(d,s),d.stack=this.stack?this.stack.concat(i):[i],d}})},"define");return n("reset",[0,0],"modifier"),n("bold",[1,22],"modifier"),n("dim",[2,22],"modifier"),n("italic",[3,23],"modifier"),n("underline",[4,24],"modifier"),n("inverse",[7,27],"modifier"),n("hidden",[8,28],"modifier"),n("strikethrough",[9,29],"modifier"),n("black",[30,39],"color"),n("red",[31,39],"color"),n("green",[32,39],"color"),n("yellow",[33,39],"color"),n("blue",[34,39],"color"),n("magenta",[35,39],"color"),n("cyan",[36,39],"color"),n("white",[37,39],"color"),n("gray",[90,39],"color"),n("grey",[90,39],"color"),n("bgBlack",[40,49],"bg"),n("bgRed",[41,49],"bg"),n("bgGreen",[42,49],"bg"),n("bgYellow",[43,49],"bg"),n("bgBlue",[44,49],"bg"),n("bgMagenta",[45,49],"bg"),n("bgCyan",[46,49],"bg"),n("bgWhite",[47,49],"bg"),n("blackBright",[90,39],"bright"),n("redBright",[91,39],"bright"),n("greenBright",[92,39],"bright"),n("yellowBright",[93,39],"bright"),n("blueBright",[94,39],"bright"),n("magentaBright",[95,39],"bright"),n("cyanBright",[96,39],"bright"),n("whiteBright",[97,39],"bright"),n("bgBlackBright",[100,49],"bgBright"),n("bgRedBright",[101,49],"bgBright"),n("bgGreenBright",[102,49],"bgBright"),n("bgYellowBright",[103,49],"bgBright"),n("bgBlueBright",[104,49],"bgBright"),n("bgMagentaBright",[105,49],"bgBright"),n("bgCyanBright",[106,49],"bgBright"),n("bgWhiteBright",[107,49],"bgBright"),s.ansiRegex=t,s.hasColor=s.hasAnsi=i=>(s.ansiRegex.lastIndex=0,typeof i=="string"&&i!==""&&s.ansiRegex.test(i)),s.alias=(i,l)=>{let g=typeof l=="string"?s[l]:l;if(typeof g!="function")throw new TypeError("Expected alias to be the name of an existing color (string) or a function");g.stack||(Reflect.defineProperty(g,"name",{value:i}),s.styles[i]=g,g.stack=[i]),Reflect.defineProperty(s,i,{configurable:!0,enumerable:!0,set(m){s.alias(i,m)},get(){let m=r(d=>p(d,m.stack),"color2");return Reflect.setPrototypeOf(m,s),m.stack=this.stack?this.stack.concat(g.stack):g.stack,m}})},s.theme=i=>{if(!e(i))throw new TypeError("Expected theme to be an object");for(let l of Object.keys(i))s.alias(l,i[l]);return s},s.alias("unstyle",i=>typeof i=="string"&&i!==""?(s.ansiRegex.lastIndex=0,i.replace(s.ansiRegex,"")):""),s.alias("noop",i=>i),s.none=s.clear=s.noop,s.stripColor=s.unstyle,s.symbols=ae(),s.define=n,s},"create");return $.exports=c(),$.exports.create=c,$.exports}r(ue,"requireAnsiColors");var f=ue(),le="5.9.0";const ge={body:"",breaking:"",issues:"",scope:"",subject:"",type:""},pe={chore:{description:"Other changes that don't modify src or test files",emoji:"\u{1F916}"},ci:{description:"Changes to CI configuration files and scripts",emoji:"\u{1F477}"},docs:{description:"Add or update documentation",emoji:"\u{1F4DD}"},feat:{description:"A new feature",emoji:"\u2728"},fix:{description:"Fix a bug",emoji:"\u{1F41B}"},perf:{description:"Improve performance",emoji:"\u26A1\uFE0F"},refactor:{description:"Refactor code",emoji:"\u267B\uFE0F"},release:{description:"Deploy stuff",emoji:"\u{1F680}"},revert:{description:"Revert changes",emoji:"\u23EA"},style:{description:"Improve structure / format of the code",emoji:"\u{1F3A8}"},test:{description:"Add or update tests",emoji:"\u2705"}},_=["type","scope","subject","body","breaking","issues"],S={breakingChangeEmoji:"\u{1F4A5}",closedIssueEmoji:"\u{1F3C1}",details:pe,disableEmoji:!1,headerMaxLength:64,headerMinLength:3,issuesHint:"#123",issuesPrefix:"closes",questions:_,scopes:[],types:["chore","docs","feat","fix","refactor","test","style","ci","perf","revert","release"],useCommitlintConfig:!1},x=r(e=>`skip "${e}" question and provide your own "${e}" message`,"skipQuestionMessage"),h={description:"interactive conventional commits cli",examples:`
$ gitzy
$ gitzy -p -a
$ gitzy -m "added cool new feature" -t "feat" -s "amazing"
$ gitzy -lD --no-emoji
`,flags:{get body(){return x("body")},get breaking(){return x("breaking")},commitlint:"leverage commitlint's configuration",get dryRun(){return"displays git message but does not commit"},hook:"run gitzy inside a Git hook",get issues(){return x("issues")},noEmoji:"disable all emojis",passthrough:'subsequent command line args passed through to "git"',retry:"retries previous commit, skips all prompts",get scope(){return x("scope")},skip:"skip questions",get subject(){return x("subject")},get type(){return x("type")}}},de={get skip(){const e=new te("-S, --skip <questions...>",h.flags.skip);return e.variadic=!0,e.choices(_),e}},me=r(e=>Object.entries(e).reduce((t,[o,c])=>(c==null||(t[o]=c),t),{}),"cleanObject"),N=72,fe=r(e=>e.replaceAll('"',String.raw`\"`).replaceAll("`","\\`"),"normalizeMessage"),he=r((e,{breakingChangeEmoji:t,disableEmoji:o})=>e?`
BREAKING CHANGE: ${o?"":`${t} `}${e}`:"","createBreaking"),ye=r((e,{closedIssueEmoji:t,disableEmoji:o})=>e?`
${o?"":`${t} `}Closes: ${e}`:"","createIssues"),be=r(e=>e&&e!=="none"?`(${e})`:"","createScope"),Ee=r((e,t=N)=>{const o=new RegExp(`(?![^\\n]{1,${t.toString()}}$)([^\\n]{1,${t.toString()}})\\s`,"g");return e.replace(o,`$1
`)},"wrap"),xe=r((e,t,o,c=!1)=>{const a=!e.disableEmoji&&e.details[t.type].emoji&&o?`${e.details[t.type].emoji} `:"",u=be(t.scope),p=`${t.type+u}: ${a}${t.subject}`,n=t.body.trim()?`
${t.body}`:"",i=he(t.breaking,e),l=ye(t.issues,e),g=Math.max(e.headerMaxLength,N),m=Ee(`${p}${n}${i}${l}`,g);return c?m:fe(m)},"formatCommitMessage"),q=r(e=>f.blue(`\u276F ${e}`),"info"),A=r(e=>f.yellow(`\u276F ${e}`),"hint"),D=r(e=>f.red(`\u276F ${e}`),"danger"),j=r(e=>{console.log(e)},"log"),we=r((e,t=[],o=process.env)=>{se(e,t,{env:o,shell:!0,stdio:[0,1,2]}).on("close",s=>{s&&process.exit(s)})},"executeCommand"),je=r(e=>{j(q("Message...")),j(`
${e}
`)},"executeDryRun"),ke=r(({answers:e,config:t},{dryRun:o=!1,emoji:c=!0,hook:s=!1,passthrough:a=[]})=>{const u=xe(t,e,c,s);if(o){je(u);return}s?oe(".git/COMMIT_EDITMSG",u):we("git",["commit","-m",`"${u}"`,...a])},"executeGitMessage"),$e=1,Ce=.9,ve=.8,Re=.3,Oe=.4,Se=.8,Ae=.3,Be=.3,Ie=.001,Fe=/[\u0300-\u036F]/g;function z(e){return e.toLowerCase().normalize("NFD").replaceAll(Fe,"")}r(z,"normalizeText");function Te(e,t){const o=z(e),c=z(t);if(o===c)return $e;if(o.startsWith(c))return Ce;if(o.includes(c))return ve;let s=0,a=0;for(let n=0;n<o.length&&s<c.length;n++)o[n]===c[s]&&(a++,s++);const u=a/c.length,p=c.length/o.length;return u>=Se&&p>=Ae?Re+u*Oe:0}r(Te,"calculateScore");const H=r((e,t,o,c=Be)=>{if(!o.trim())return e;const s=[];for(const a of e){let u=0;for(const p of t){const n=a[p];if(n){const i=String(n),l=Te(i,o);u=Math.max(u,l)}}u>=c&&s.push({item:a,score:u})}return s.sort((a,u)=>Math.abs(u.score-a.score)>Ie?u.score-a.score:e.indexOf(a.item)-e.indexOf(u.item)),s.map(a=>a.item)},"fuzzySearch"),Le=r(()=>new Promise((e,t)=>{L("git --no-pager diff --cached --quiet --exit-code",o=>{o&&e(""),t(new Error(`No files staged
${A('You can use "gitzy -p -a" to replicate git -am')}`))})}),"checkIfStaged"),Pe=r(()=>new Promise((e,t)=>{L("git rev-parse --is-inside-work-tree",o=>{o&&t(new Error(`Not a git repository
${A('You can try running "git init"')}`)),e("")})}),"checkIfGitRepo"),Me=r((e=[])=>!["--add","-a","--amend"].some(t=>e.includes(t)),"shouldDoGitChecks"),_e=r(e=>{try{return w.statSync(e)}catch{return null}},"tryStat"),Ne=r((e,t)=>{if(t.message.includes("null bytes"))throw new Error(t.message);if(!(["EEXIST","EISDIR","EPERM"].includes(t.code)&&R.dirname(e)!==e))throw new Error(t.message)},"handleError"),qe=r((e,t=!0)=>{const o=_e(e);if(o){if(t&&!o.isDirectory())throw new Error(`Path exists and is not a directory: "${e}"`);return!0}return!1},"directoryExists"),De=r(e=>{if(!qe(e))try{w.mkdirSync(e,{recursive:!0})}catch(t){Ne(e,t)}},"mkdir"),ze=r(e=>{try{w.unlinkSync(e)}catch(t){const o=t;if(o.code!=="ENOENT")throw new Error(o.message)}},"tryUnlink"),He=r(()=>`${ne.tmpdir()}/gitzy/${R.basename(process.cwd())}-store.json`,"gitzyStorePath"),k=Symbol("gitzy");class Ge{static{r(this,"GitzyStore")}[k];path;get data(){return this[k]??this.tryLoad()}constructor(){this.path=He()}clear=r(()=>{this.save({})},"clear");destroy=r(()=>{ze(this.path)},"destroy");load=r(()=>this.data,"load");save(t){this[k]=t,this.writeFile()}json=r(()=>JSON.stringify(this.data,null,2),"json");readParseFile=r(()=>JSON.parse(String(w.readFileSync(this.path))),"readParseFile");tryLoad=r(()=>{try{return this[k]=this.readParseFile()}catch(t){const o=t,c=o.code==="EACCES",s=o.code==="ENOENT"||o.name==="SyntaxError";if(c)throw new Error("gitzy does not have permission to load this file");return s?(this[k]={},{}):{}}},"tryLoad");writeFile=r(()=>{De(R.dirname(this.path)),w.writeFileSync(this.path,this.json(),{mode:384})},"writeFile")}const B=r((e,t)=>ce.parse(t),"loadYaml"),G=r(e=>[`.${e}rc`,`.${e}rc.json`,`.${e}rc.yaml`,`.${e}rc.yml`,`.${e}rc.js`,`.${e}rc.cjs`,`${e}.config.js`,`${e}.config.cjs`],"defaultSearchPlaces"),Ue=r(e=>["package.json",...G(e),...G(e).map(t=>`.config/${t}`)],"getSearchPlaces"),U=r(async e=>ie(e,{loaders:{".yaml":B,".yml":B,noExt:B},searchPlaces:Ue(e)}).search(process.cwd()),"loadConfig"),W=["close","closes","closed","fix","fixes","fixed","resolve","resolves","resolved"],y={breakingChangeEmoji:"breakingChangeEmoji must be a string",closedIssueEmoji:"closedIssueEmoji must be a string",details:'details must look like "{ description: "A new feature", emoji: "\u2728" }"',disableEmoji:"disableEmoji must be a boolean",headerMaxLength:"headerMaxLength must be a number",headerMinLength:"headerMinLength must be a number",issuesHint:"issuesHint must be a string",issuesPrefix:`issuesPrefix must be one of ${W.join(", ")}`,questions:"questions must be an array of strings",scopes:"scopes must be an array of strings",types:"types must be an array of strings",useCommitlintConfig:"useCommitlintConfig must be a boolean"},Y=r((e,t)=>Object.prototype.hasOwnProperty.call(e,t),"hasProperty"),E=r(e=>typeof e=="string","isString"),V=r(e=>typeof e=="boolean","isBoolean"),X=r(e=>typeof e=="number","isNumber"),I=r(e=>typeof e=="object","isObject"),F=r(e=>Array.isArray(e)&&e.every(E),"isArrayOfStrings"),We=r(e=>I(e)&&Object.values(e).every(t=>{const o=t;return I(o)&&Y(o,"description")&&Y(o,"emoji")&&Object.values(o).every(E)}),"isValidDetails"),Ye=r(e=>E(e)&&W.includes(e),"isValidIssues"),Ve=r(e=>{const t=Object.keys(S);return Object.keys(e).some(o=>!t.includes(o))},"hasAdditionalProperties"),Xe={breakingChangeEmoji:r(e=>E(e)||y.breakingChangeEmoji,"breakingChangeEmoji"),closedIssueEmoji:r(e=>E(e)||y.closedIssueEmoji,"closedIssueEmoji"),details:r(e=>We(e)||y.details,"details"),disableEmoji:r(e=>V(e)||y.disableEmoji,"disableEmoji"),headerMaxLength:r(e=>X(e)||y.headerMaxLength,"headerMaxLength"),headerMinLength:r(e=>X(e)||y.headerMinLength,"headerMinLength"),issuesHint:r(e=>E(e)||y.issuesHint,"issuesHint"),issuesPrefix:r(e=>Ye(e)||y.issuesPrefix,"issuesPrefix"),questions:r(e=>F(e)||y.questions,"questions"),scopes:r(e=>F(e)||y.scopes,"scopes"),types:r(e=>F(e)||y.types,"types"),useCommitlintConfig:r(e=>V(e)||y.useCommitlintConfig,"useCommitlintConfig")},Ze=r(e=>I(e)?e&&Ve(e)?"unknown or additional properties detected":Object.entries(e).map(([t,o])=>Xe[t](o))[0]:"invalid configuration","validateConfig"),Z=r(async e=>{const t=await Promise.resolve(Ze(e));if(E(t))throw new Error(t);return t},"validateUserConfig"),Je=r(e=>me({headerMaxLength:e.rules?.["header-max-length"]?.[2],headerMinLength:e.rules?.["header-min-length"]?.[2],scopes:e.rules?.["scope-enum"]?.[2],types:e.rules?.["type-enum"]?.[2]}),"getCommitlintOverrides"),J=r(async()=>{const e=await U("commitlint");if(e){const t=Je(e.config);return await Z(t)?t:null}return null},"getCommitlintConfig"),Ke=r(async e=>{const t=await U("gitzy");if(e&&!t)return J();if(t&&await Z(t.config)){if(t.config.useCommitlintConfig||e){const c=await J();return{...t.config,...c}}return{...t.config}}return null},"getUserConfig"),Qe=f.red("BREAKING CHANGE:"),et=r(e=>f.reset(`${e}:`),"closes"),b={body:{hint:"...supports multi line, press enter to go to next line",message:`Add a longer description
`},breaking:{hint:f.dim("...skip when none"),message:`${f.bold("Add any breaking changes")}
${Qe}`},scope:{hint:f.dim("...type or use arrow keys"),message:"Choose the scope"},subject:{message:"Add a short description"},type:{hint:f.dim("...type or use arrow keys"),message:"Choose the type"}},tt=r(e=>`${f.bold("Add issues this commit closes")}
${et(e)}`,"issuesMessage"),K={maxTitleLength:r(e=>`The subject must be less than ${e.toString()} characters`,"maxTitleLength"),minTitleLength:r(e=>`The subject must have at least ${e.toString()} characters`,"minTitleLength")},rt=r(()=>({format:r(e=>e.trim(),"format"),hint:b.body.hint,message:b.body.message,multiline:!0,name:"body",type:"text"}),"body"),st=r(()=>({hint:b.breaking.hint,message:b.breaking.message,name:"breaking",type:"text"}),"breaking"),ot=r(({config:{issuesHint:e,issuesPrefix:t}})=>({hint:e,message:tt(t),name:"issues",type:"text"}),"issues"),nt=r(({config:{scopes:e}})=>{const t=e.map(o=>({indent:" ",title:o,value:o}));return e.length>0?{choices:t,hint:b.scope.hint,limit:10,message:b.scope.message,name:"scope",suggest:r(o=>H(t,["title"],o),"suggest"),type:"autocomplete"}:null},"scope"),it=3,ct=100,at=25,Q=r(e=>{const t=e?.scope&&e.scope!=="none"?`(${e.scope})`:"";return e?.type?`${e.type}${t}: `:""},"leadingLabel"),ut=r(({config:{disableEmoji:e,headerMaxLength:t,headerMinLength:o}})=>{const c=K.minTitleLength(o),s=K.maxTitleLength(t),{subject:{message:a}}=b,u=e?0:it;return{message:r(p=>{const n=r(()=>{const i=Q(p?.answers),l=p?p.input.length:0,g=t-l-i.length-u,m=g/t*ct,d=`${g.toString()}/${t.toString()}`;return l<o?f.red(d):m>at?f.green(d):m<0?f.red(d):f.yellow(d)},"getCharsLeftText");return f.bold(`${a}(${n()})`)},"message"),name:"subject",type:"input",validate:r((p,n)=>{const i=Q(n?.answers),l=p.length+i.length+u>t;return p.length<o?c:l?s:!0},"validate")}},"subject"),lt=r(({details:e,disableEmoji:t},o,c)=>{const{[o]:{description:s,emoji:a}}=e,u=a&&!t&&c?.emoji,p=u?`${a} `:"";return{hint:s.toLowerCase(),indent:" ",title:`${o==="refactor"&&u?`${p} `:p}${o}:`,value:o}},"choice"),gt=r(({config:e,flags:t})=>{const o=e.types.map(c=>lt(e,c,t));return{choices:o,hint:b.type.hint,limit:10,message:b.type.message,name:"type",suggest:r(c=>H(o,["title","hint"],c),"suggest"),type:"autocomplete"}},"type"),pt={body:rt,breaking:st,issues:ot,scope:nt,subject:ut,type:gt},dt=r(e=>e!=null,"notEmpty"),mt=r(({answers:e,config:t},o)=>t.questions.filter(c=>S.questions.includes(c)&&!o.skip?.includes(c)).map(c=>pt[c]({answers:e,config:t,flags:o})).filter(c=>dt(c)),"createPrompts"),ft={autofill:!0,cancel:r(()=>null,"cancel"),styles:{danger:f.red,submitted:f.cyan}},ht=r(async()=>{const e={answers:ge,config:S},t=new Ge,o=r(async({commitlint:s,dryRun:a,passthrough:u})=>{const p=await Ke(s);p&&(e.config={...e.config,...p}),Me(u)&&!a&&(await Pe(),await Le())},"init"),c=r(async s=>{const a=new re(ft,s),u=mt(e,s);return a.prompt(u)},"promptQuestions");v.configureOutput({outputError:r((s,a)=>{a(`
${D(s)}
`)},"outputError"),writeErr:r(s=>process.stdout.write(s.replace("error: ","")),"writeErr")}).version(le,"-v, --version").description(h.description).option("-d, --body <body>",h.flags.body).option("-b, --breaking <breaking>",h.flags.breaking).option("-D, --dry-run",h.flags.dryRun).option("-i, --issues <body>",h.flags.issues).option("-p, --passthrough <flags...>",h.flags.passthrough).option("-s, --scope <scope>",h.flags.scope).option("-m, --subject <message>",h.flags.subject).option("-t, --type <type>",h.flags.type).option("-l, --commitlint",h.flags.commitlint).option("-r, --retry",h.flags.retry).option("--no-emoji",h.flags.noEmoji).option("-H, --hook",h.flags.hook).addOption(de.skip).addHelpText("after",`
Examples:
${h.examples}
`).name("gitzy").action(async()=>{const s=v.opts(),a={...s,hook:process.env.GIT_DIR!==void 0||s.hook};a.dryRun&&j(q("running in dry mode..."));try{await o(a);const u=a.retry?t.load():{};a.retry&&Object.keys(u).length===0&&j(A("there is no previous gitzy commit to retry..."));const p=await c({...a,...u});t.save(p),e.answers={...e.answers,...p}}catch(u){j(`
${D(u.message)}
`),process.exit(1)}ke(e,a)}),await v.parseAsync(process.argv)},"cli");ht();