git-rake
Version:
Interactive CLI tool to safely prune, delete, and restore Git branches
9 lines (8 loc) • 39.7 kB
JavaScript
import{Command as Wo}from"commander";import{useCallback as xo,useRef as yo,useEffect as Bo}from"react";import{useInput as wo,useApp as So}from"ink";import{createContext as er,useContext as tr,useState as xe,useMemo as Xe}from"react";var Oe={name:"Auto",colors:{primary:"blue",text:"",muted:"grey",selection:"magentaBright",success:"green",warning:"yellow",alert:"red"}};var ke={name:"GitHub (light)",colors:{primary:"#0969da",success:"#1a7f37",warning:"#9a6700",alert:"#cf222e",text:"#24292f",muted:"#656d76",selection:"#0969da"}};var De={name:"Catppuccin (latte)",colors:{primary:"#1e66f5",success:"#40a02b",warning:"#df8e1d",alert:"#d20f39",text:"#4c4f69",muted:"#6c6f85",selection:"#1e66f5"}},Ne={name:"Catppuccin (mocha)",colors:{primary:"#89b4fa",success:"#a6e3a1",warning:"#f9e2af",alert:"#f38ba8",text:"#cdd6f4",muted:"#6c7086",selection:"#89b4fa"}};var Ue={name:"Gruvbox (light)",colors:{primary:"#076678",success:"#79740e",warning:"#b57614",alert:"#9d0006",text:"#3c3836",muted:"#928374",selection:"#076678"}},Fe={name:"Gruvbox (dark)",colors:{primary:"#83a598",success:"#b8bb26",warning:"#fabd2f",alert:"#fb4934",text:"#ebdbb2",muted:"#928374",selection:"#83a598"}};var Ve={name:"Tokyo Night (dark)",colors:{primary:"#7aa2f7",success:"#9ece6a",warning:"#ff9e64",alert:"#f7768e",text:"#9aa5ce",muted:"#cfc9c2",selection:"#9ece6a"}},$e={name:"Tokyo Night - Day (light)",colors:{primary:"#3760bf",success:"#385f0d",warning:"#8f5e15",alert:"#8c4351",text:"#3760bf",muted:"#333333",selection:"#3760bf"}};var je={name:"Ayu (dark)",colors:{primary:"#59c2ff",success:"#91b362",warning:"#ffb454",alert:"#f28779",text:"#bfbdb6",muted:"#a9b1d6",selection:"#73d0ff"}};var He={name:"Dracula",colors:{primary:"#bd93f9",success:"#50fa7b",warning:"#f1fa8c",alert:"#ff5555",text:"#f8f8f2",muted:"#6272a4",selection:"#bd93f9"}};var We={name:"VS Code (light)",colors:{primary:"#0078d4",success:"#107c10",warning:"#ff8c00",alert:"#d13438",text:"#323130",muted:"#616161",selection:"#0078d4"}},_e={name:"VS Code (dark)",colors:{primary:"#569cd6",success:"#4ec9b0",warning:"#dcdcaa",alert:"#f44747",text:"#d4d4d4",muted:"#808080",selection:"#569cd6"}};var Qe={auto:Oe,"github-light":ke,"catppuccin-latte":De,"catppuccin-mocha":Ne,"gruvbox-light":Ue,"gruvbox-dark":Fe,"tokyo-night":Ve,"tokyo-night-day":$e,ayu:je,dracula:He,"vscode-light":We,"vscode-dark":_e};function Ye(o){return Qe[o]??Qe.auto}import{jsx as rr}from"react/jsx-runtime";var Ke=er(void 0);function ze({children:o,config:e}){let[t,r]=xe("branches"),[n,a]=xe(!1),[s,i]=xe(!1),c=Xe(()=>Ye(e.theme),[e.theme]),m=Xe(()=>({currentView:t,setCurrentView:r,inputLocked:n,setInputLocked:a,showExitWarning:s,setShowExitWarning:i,config:e,theme:c}),[t,n,s,e,c]);return rr(Ke.Provider,{value:m,children:o})}function d(){let o=tr(Ke);if(o===void 0)throw new Error("useAppUIContext must be used within an AppUIProvider");return o}import ao,{useMemo as io}from"react";import{Box as Ie,Text as co,useInput as lo}from"ink";import{createContext as or,useContext as nr,useState as ye,useCallback as qe,useMemo as sr}from"react";import{jsx as ir}from"react/jsx-runtime";var ar={searchMode:!1,searchQuery:"",filterType:"all",setSearchMode:()=>{},setSearchQuery:()=>{},appendSearchQuery:()=>{},setFilterType:()=>{}},Je=or(ar);function Ze({children:o}){let[e,t]=ye(!1),[r,n]=ye(""),[a,s]=ye("all"),i=qe(l=>{t(l)},[]),c=qe(l=>{n(p=>p+l)},[]),m=sr(()=>({searchMode:e,searchQuery:r,filterType:a,setSearchMode:i,setSearchQuery:n,appendSearchQuery:c,setFilterType:s}),[e,r,a,i,c]);return ir(Je.Provider,{value:m,children:o})}function v(){return nr(Je)}import{useCallback as ne}from"react";function se(){let{searchMode:o,filterType:e,setSearchQuery:t,appendSearchQuery:r,setSearchMode:n,setFilterType:a}=v(),{setInputLocked:s}=d(),i=ne((p,u)=>(u.escape&&t(""),o?u.escape||u.return?(n(!1),s(!1),!0):u.delete||u.backspace?(t(g=>g.length<=0?"":g.slice(0,-1)),!0):(p&&!u.ctrl&&!u.meta&&!u.shift&&r(p),!0):!1),[o,t,r,s,n]),c=ne(()=>{n(!0),s(!0)},[n,s]),m=ne(()=>{n(!1),t("")},[n,t]),l=ne(()=>{let p=["all","merged","unmerged","stale","selected"],g=(p.indexOf(e)+1)%p.length;a(p[g])},[e,a]);return{handleSearchInput:i,activateSearch:c,clearSearch:m,cycleFilter:l}}import{useCallback as ce,useState as lt}from"react";import{useMemo as J,useCallback as E,useEffect as fr,useRef as at}from"react";import{createContext as cr,useContext as lr,useState as et,useMemo as pr,useCallback as mr}from"react";import{jsx as ur}from"react/jsx-runtime";var hr={branches:[],selectedBranches:new Map,selectedBranchName:"",setSelectedBranchName:()=>{},setSelectedBranches:()=>{},toggleSelectedBranch:()=>{}},tt=cr(hr);function rt({children:o,branches:e}){let[t,r]=et(new Map),[n,a]=et(""),s=mr(c=>{r(m=>{let l=new Map(m);return l.has(c.name)?l.delete(c.name):l.set(c.name,c),l})},[]),i=pr(()=>({branches:e,selectedBranches:t,selectedBranchName:n,setSelectedBranchName:a,setSelectedBranches:r,toggleSelectedBranch:s}),[e,t,n,s]);return ur(tt.Provider,{value:i,children:o})}function W(){return lr(tt)}function ot(o,e){return o.filter(t=>!(!t.isRemote&&!e.showLocal||t.isRemote&&!e.showRemote||t.isMerged&&!e.showMerged||!t.isMerged&&!e.showUnmerged||t.isStale&&!e.showStale))}function Be(o){switch(o){case"all":return{showMerged:!0,showUnmerged:!0,showStale:!0,showLocal:!0,showRemote:!1};case"merged":return{showMerged:!0,showUnmerged:!1,showStale:!0,showLocal:!0,showRemote:!1};case"stale":return{showMerged:!0,showUnmerged:!0,showStale:!0,showLocal:!0,showRemote:!1};case"unmerged":return{showMerged:!1,showUnmerged:!0,showStale:!0,showLocal:!0,showRemote:!1};default:return Be("all")}}function nt(o){switch(o){case"all":return"All";case"merged":return"Merged";case"stale":return"Stale";case"unmerged":return"Unmerged";case"selected":return"Selected";default:return"All"}}function st(o,e){let t=e.trim();if(!t)return o;let r=t.toLowerCase();return o.filter(n=>n.name.toLowerCase().includes(r))}var it=10;function dr(o,e){if(e.length===0)return 0;let t=e.findIndex(r=>r.name===o);return t!==-1?t:0}function ct(o,e){return Math.max(0,Math.min(o,e-1))}function G(){let{branches:o,selectedBranches:e,selectedBranchName:t,setSelectedBranchName:r,setSelectedBranches:n,toggleSelectedBranch:a}=W(),{filterType:s,searchQuery:i}=v(),c=J(()=>Array.from(e.values()),[e]),m=J(()=>{let x=Be(s),w=ot(o,x);return i.trim()&&(w=st(w,i)),w},[o,i,s]),l=J(()=>s==="selected"?c:m,[s,c,m]),p=l.length,u=at(0),g=at(0),h=J(()=>{let x=l.length;if(x===0)return 0;let w=l.findIndex(Zt=>Zt.name===t);if(w!==-1)return w;let oe=g.current>=u.current-1&&u.current>0,Jt=u.current>x;return oe&&Jt?x-1:dr(t,l)},[t,l]),f=J(()=>{let x=ct(h,p);return l[x]||null},[l,h,p]);fr(()=>{l.length>0&&f&&f.name&&t!==f.name&&r(f.name),g.current=h,u.current=l.length},[l,f,t,r,h]);let S=E(x=>{x.isCurrent||a(x)},[a]),P=E(()=>{n(new Map)},[n]),T=E(()=>{let x=new Map(e);l.forEach(w=>{x.delete(w.name)}),n(x)},[l,e,n]),D=E(()=>{let x=new Map(e);l.forEach(w=>{w.isCurrent||x.set(w.name,w)}),n(x)},[l,e,n]),C=E(x=>{if(l.length===0)return;let w=ct(x,p),oe=l[w];oe&&r(oe.name)},[l,p,r]),N=E(()=>{C(h+1)},[C,h]),H=E(()=>{C(h-1)},[C,h]),k=E(()=>{C(Math.min(h+it,p-1))},[C,h,p]),U=E(()=>{C(Math.max(h-it,0))},[C,h]),B=E((x,w)=>x.upArrow||w==="k"?(C(h-1),!0):x.downArrow||w==="j"?(N(),!0):x.pageDown?(k(),!0):x.pageUp?(U(),!0):!1,[C,N,k,U,h]);return{availableBranches:l,selectedBranches:c,currentBranch:f,displayBounds:p,selectedIndex:h,toggleBranchSelection:S,clearSelectedBranches:P,deselectAvailableBranches:T,selectAllAvailableBranches:D,handleListNavigation:B,navigateDown:N,navigateUp:H,navigatePageDown:k,navigatePageUp:U}}import{pino as we}from"pino";import{join as Se}from"path";import{homedir as gr}from"os";import{mkdirSync as xr}from"fs";var Te=null,be=!1;function ae(o=!1){be=o;let e=process.env.DEV==="true"?Se(process.cwd(),"logs"):Se(gr(),".git-rake","logs");try{xr(e,{recursive:!0})}catch{}let t=Se(e,"git-rake.log");Te=we({level:o?"debug":"warn",timestamp:we.stdTimeFunctions.isoTime,formatters:{level(r){return{level:r}}}},we.destination({dest:t,mkdir:!0,sync:!1}))}function ie(){return Te||ae(!1),Te}function yr(o,e){ie().error(e||{},o)}function Br(o,e){ie().warn(e||{},o)}function wr(o,e){be&&ie().info(e||{},o)}function Sr(o,e){be&&ie().debug(e||{},o)}var R={error:yr,warn:Br,info:wr,debug:Sr};function pt(o,e,t){let{clearSelectedBranches:r}=G(),{clearSearch:n}=se(),{filterType:a,setFilterType:s}=v(),[i,c]=lt(null),[m,l]=lt("all"),p=ce(async(f,S)=>{if(S.length===0)return;let P=S.map(T=>({type:f,branch:T}));await o.performBatchOperations(P),r()},[o,r]),u=ce(f=>{l(a),s("selected"),c(f)},[a,s]),g=ce(async()=>{if(!(!i||!e||!t))try{await p(i,e),await t()}catch(f){throw R.error("Operation failed",{operation:i,branchCount:e.length,error:f instanceof Error?f.message:"Unknown error"}),f}finally{s("all"),n(),c(null)}},[i,e,t,p,s,n]),h=ce(()=>{s(m),c(null)},[m,s]);return{performOperation:p,pendingOperation:i,enterConfirmationMode:u,executeOperationAndExit:g,exitConfirmationMode:h}}var F={DELETE:"delete",TRASH:"trash",RESTORE:"restore"},le={[F.DELETE]:{type:"alert",icon:"\u{1F6A8}",name:"Delete"},[F.TRASH]:{type:"warning",icon:"\u26A0\uFE0F",name:"Trash"},[F.RESTORE]:{type:"warning",icon:"\u21A9\uFE0F",name:"Restore"}};import{memo as Hr,useCallback as Wr}from"react";import{Box as wt,Text as _r,useInput as Qr}from"ink";import Tr,{useMemo as Ce}from"react";import{Box as V,Text as _}from"ink";function mt(o){let t=new Date().getTime()-o.getTime(),r=Math.floor(t/(1e3*60)),n=Math.floor(t/(1e3*60*60)),a=Math.floor(t/(1e3*60*60*24)),s=Math.floor(a/7),i=Math.floor(a/30),c=Math.floor(a/365);return r<5?"now":r<60?`${r}m ago`:n<24?`${n}h ago`:a<7?`${a}d ago`:s<4?`${s}w ago`:i<12?`${i}mo ago`:`${c}y ago`}function pe(o,e){return o.isMerged?{text:"merged",color:e.colors.alert}:o.isStale?{text:"stale",color:e.colors.warning}:{text:"unmerged",color:e.colors.text}}function ht(o,e,t){return o.isCurrent?"x":t?e?"\u25CF":"\u25CB":" "}import{jsx as A,jsxs as br}from"react/jsx-runtime";var ut=Tr.memo(function({branch:e,isSelected:t,isMarked:r,showSelection:n,columnLayout:a}){let{theme:s}=d(),i=Ce(()=>ht(e,r,n),[e,r,n]),c=t?s.colors.selection:s.colors.text,m=Ce(()=>mt(e.lastCommitDate),[e.lastCommitDate]),l=Ce(()=>pe(e,s),[e,s]),p=u=>{if(u===null)return{text:"\u2014",color:c};switch(u){case">":return{text:"ahead",color:s.colors.success};case"<":return{text:"behind",color:s.colors.warning};case"<>":return{text:"diverged",color:s.colors.alert};case"=":return{text:"in sync",color:s.colors.success};case"[gone]":return{text:"gone",color:s.colors.alert};default:return{text:"\u2014",color:s.colors.primary}}};return br(V,{paddingX:1,paddingY:0,overflow:"hidden",width:"100%",children:[A(V,{...a.selection.styles,children:A(_,{color:c,children:i})}),A(V,{...a.branchName.styles,children:A(_,{color:c,wrap:"truncate-end",children:e.name})}),a.status.visible&&A(V,{...a.status.styles,children:A(_,{color:t?c:l.color,wrap:"truncate-end",children:l.text})}),a.updated.visible&&A(V,{...a.updated.styles,children:A(_,{color:c,wrap:"truncate-end",children:m})}),a.upstream.visible&&A(V,{...a.upstream.styles,children:A(_,{color:t?c:p(e.upstreamTrackShort).color,wrap:"truncate-end",children:p(e.upstreamTrackShort).text})}),a.lastCommit.visible&&A(V,{...a.lastCommit.styles,children:A(_,{color:c,wrap:"truncate-end",children:e.lastCommitMessage})})]})});import{Box as $,Text as Q}from"ink";import{jsx as I,jsxs as Cr}from"react/jsx-runtime";function ft({columnLayout:o}){let{theme:e}=d();return Cr($,{paddingX:1,paddingY:0,borderBottom:!0,borderColor:e.colors.primary,flexShrink:0,overflow:"hidden",width:"100%",children:[I($,{...o.selection.styles,children:I(Q,{color:e.colors.primary,children:" "})}),I($,{...o.branchName.styles,children:I(Q,{color:e.colors.primary,bold:!0,wrap:"truncate-end",children:"BRANCH NAME"})}),o.status.visible&&I($,{...o.status.styles,children:I(Q,{color:e.colors.primary,bold:!0,wrap:"truncate-end",children:"STATUS"})}),o.updated.visible&&I($,{...o.updated.styles,children:I(Q,{color:e.colors.primary,bold:!0,wrap:"truncate-end",children:"UPDATED"})}),o.upstream.visible&&I($,{...o.upstream.styles,children:I(Q,{color:e.colors.primary,bold:!0,wrap:"truncate-end",children:"UPSTREAM"})}),o.lastCommit.visible&&I($,{...o.lastCommit.styles,children:I(Q,{color:e.colors.primary,bold:!0,wrap:"truncate-end",children:"LAST COMMIT"})})]})}import{useMemo as vr}from"react";import{useScreenSize as Rr}from"fullscreen-ink";var me={STATUS:55,UPDATED:65,UPSTREAM:76,LAST_COMMIT:90},Y={flexGrow:0,flexShrink:0,minWidth:0,overflow:"hidden",marginRight:1,width:10};function dt(){let{width:o}=Rr();return vr(()=>({selection:{visible:!0,styles:{...Y,width:3}},branchName:{visible:!0,styles:{...Y,width:40}},status:{visible:o>=me.STATUS,styles:{...Y}},updated:{visible:o>=me.UPDATED,styles:{...Y}},upstream:{visible:o>=me.UPSTREAM,styles:{...Y}},lastCommit:{visible:o>=me.LAST_COMMIT,styles:{...Y,width:0,flexGrow:1,flexShrink:1,marginRight:0}}}),[o])}import{cloneElement as Nr,memo as Ur,Fragment as Fr}from"react";import{Box as Bt,Text as Vr}from"ink";import Ar,{useRef as Ir,useEffect as Pr,useState as Er}from"react";import{measureElement as Gr}from"ink";import{useScreenSize as Mr}from"fullscreen-ink";function gt(o){let e=Ir(null),[t,r]=Er(0),{height:n,width:a}=Mr();return Pr(()=>{if(e.current){let{height:i}=Gr(e.current);r(i)}},[n,a]),{component:Ar.cloneElement(o,{ref:e}),height:t}}function xt(o,e,t,r,n=!1){let a=e-r,s=o.length>a;if(!s)return{visibleItems:o,visibleCount:o.length,scrollOffset:0,needsScrolling:!1};let i=Math.max(1,a),c=n?t-Math.floor(i/2):t,m=Math.max(0,Math.min(c,o.length-i));return{visibleItems:o.slice(m,m+i),visibleCount:i,scrollOffset:m,needsScrolling:s}}import{Box as Lr,Text as Or}from"ink";import{jsx as Dr,jsxs as kr}from"react/jsx-runtime";function yt({currentIndex:o,totalItems:e,hasMoreAbove:t,hasMoreBelow:r}){let{theme:n}=d(),a="";return t&&r?a=" (\u2191/\u2193)":t?a=" (\u2191)":r&&(a=" (\u2193)"),Dr(Lr,{justifyContent:"center",marginTop:1,children:kr(Or,{color:n.colors.primary,children:[o+1," of ",e," items",a]})})}import{Fragment as $r,jsx as Z,jsxs as jr}from"react/jsx-runtime";var ve=Ur(function({items:e,renderItem:t,selectedIndex:r,centerSelected:n=!1}){let{component:a,height:s}=gt(Z(Bt,{flexGrow:1,height:"100%",flexDirection:"column",children:e.length===0&&Z(Bt,{justifyContent:"center",alignItems:"center",height:10,children:Z(Vr,{children:"No items"})})})),i=2,{visibleItems:c,scrollOffset:m,visibleCount:l,needsScrolling:p}=xt(e,s,r,i,n),u=p?Z(yt,{currentIndex:r,totalItems:e.length,hasMoreAbove:m>0,hasMoreBelow:m+l<e.length}):null;return Nr(a,{children:jr($r,{children:[c.map((g,h)=>{let f=m+h;return Z(Fr,{children:t(g,f,f===r)},f)}),u]})})});import{jsx as ee,jsxs as Yr}from"react/jsx-runtime";var St=Hr(function({branches:e}){let{theme:t,inputLocked:r}=d(),{selectedBranches:n}=W(),{searchQuery:a}=v(),{selectedIndex:s,currentBranch:i,toggleBranchSelection:c,handleListNavigation:m,navigateDown:l,navigateUp:p}=G(),u=dt(),g=Wr((h,f,S)=>ee(ut,{branch:h,isSelected:S,isMarked:n.has(h.name),showSelection:!h.isCurrent,columnLayout:u},h.ref),[n,u]);return Qr((h,f)=>{if(!m(f,h)&&(h===" "||h.toLowerCase()==="s")&&i){c(i),h==="S"?p():l();return}},{isActive:!r}),Yr(wt,{flexDirection:"column",children:[ee(ft,{columnLayout:u}),e.length===0?ee(wt,{justifyContent:"center",alignItems:"center",flexGrow:1,children:ee(_r,{color:t.colors.muted,children:a?`No branches found for "${a}"`:"No branches found"})}):ee(ve,{items:e,renderItem:g,selectedIndex:s,centerSelected:!0})]})});import{Box as ue,Text as zr}from"ink";import{Text as Tt}from"ink";import{Fragment as Ct,jsx as bt,jsxs as vt}from"react/jsx-runtime";function Rt({children:o,title:e}){let{theme:t}=d();return vt(Ct,{children:[bt(Tt,{color:t.colors.primary,bold:!0,children:e}),o&&vt(Ct,{children:[bt(Tt,{children:" \u2022 "}),o]})]})}import{Text as At}from"ink";import{Fragment as Kr,jsx as It,jsxs as Xr}from"react/jsx-runtime";function Pt({helpText:o,showExitWarning:e}){let{theme:t}=d();return It(Kr,{children:e?It(At,{color:t.colors.warning,children:"Press Ctrl+C again to exit"}):Xr(At,{color:t.colors.muted,children:[o," \u2022 ctrl+c: exit"]})})}function he(o,e){switch(o){case"warning":return e.colors.warning;case"alert":return e.colors.alert;case"success":return e.colors.success;default:return e.colors.primary}}import{jsx as te,jsxs as Et}from"react/jsx-runtime";function j({children:o,statusBarContent:e,helpText:t,currentPath:r,statusBarType:n="default"}){let{theme:a,showExitWarning:s}=d();return Et(ue,{flexDirection:"column",height:"100%",width:"100%",children:[te(ue,{paddingX:1,flexShrink:0,children:Et(zr,{color:a.colors.muted,children:["Cwd: ",r]})}),te(ue,{flexShrink:0,borderStyle:"single",borderColor:he(n,a),paddingX:1,children:te(Rt,{title:"Git Rake",children:e})}),o,te(ue,{flexShrink:0,borderStyle:"single",borderColor:a.colors.muted,paddingX:1,children:te(Pt,{helpText:t,showExitWarning:s})})]})}import{Box as qr,Text as Jr}from"ink";import{default as Zr}from"ink-spinner";import{jsx as Gt,jsxs as eo}from"react/jsx-runtime";function fe({text:o,type:e="dots",height:t=6}){let{theme:r}=d();return Gt(qr,{justifyContent:"center",alignItems:"center",height:t,children:eo(Jr,{color:r.colors.primary,children:[Gt(Zr,{type:e})," ",o]})})}import{useMemo as Nt}from"react";import{useState as to}from"react";import{Text as re,useInput as ro}from"ink";import{jsx as Mt,jsxs as Re}from"react/jsx-runtime";function Lt({type:o,icon:e,action:t,selectedCount:r,onConfirm:n,onCancel:a}){let{theme:s}=d(),[i,c]=to(!1),m=async()=>{c(!0);try{await n()}finally{c(!1)}};ro((p,u)=>{(u.return||p==="y"||p==="Y")&&m(),(u.escape||p==="n"||p==="N")&&a()},{isActive:!i});let l=he(o,s);return Re(re,{children:[Re(re,{color:l,children:[e," ",t]}),Re(re,{color:s.colors.text,children:[" ",r," ",r===1?"branch":"branches","?"," "]}),Mt(re,{color:l,children:"[Y/n]"}),i&&Mt(re,{children:" \u2022 Processing..."})]})}import{useMemo as no}from"react";import{Text as de}from"ink";import{Fragment as oo,jsx as Ae,jsxs as Ot}from"react/jsx-runtime";function kt({items:o,separator:e=" \u2022 ",labelColor:t,valueColor:r}){return Ae(oo,{children:o.map((n,a)=>Ot(de,{children:[a>0&&Ae(de,{color:t,children:e}),Ot(de,{color:t,children:[n.label," ",Ae(de,{color:r,children:n.value})]})]},a))})}import{jsx as so}from"react/jsx-runtime";function Dt({selectedCount:o,availableCount:e,totalBranches:t,filterDisplay:r,searchMode:n,searchQuery:a,showSearch:s,theme:i}){let c=no(()=>{let m=[{label:"Selected:",value:o.toString()},{label:`${n?"Found":"Showing"}:`,value:`${e}/${t}`},{label:"Filter:",value:r}];return s&&(n||a)&&m.push({label:"Search:",value:a+(n?"|":"")}),m},[o,e,t,r,n,a,s]);return so(kt,{items:c,labelColor:i.colors.text,valueColor:i.colors.primary})}import{jsx as Ut}from"react/jsx-runtime";function Ft({pendingOperation:o,selectedBranches:e,onConfirm:t,onCancel:r}){let{searchMode:n,searchQuery:a,filterType:s}=v(),{branches:i}=W(),{theme:c}=d(),{displayBounds:m}=G(),l=Nt(()=>{let p=o?"Selected":nt(s);return{selectedCount:e.length,availableCount:m,totalBranches:i.length,filterDisplay:p,searchMode:n,searchQuery:a,showSearch:!o,theme:c}},[o,e.length,m,i.length,s,n,a,c]);return Nt(()=>{if(!o)return Ut(Dt,{...l});let p=le[o];return Ut(Lt,{type:p.type,icon:p.icon,action:p.name,selectedCount:e.length,onConfirm:t,onCancel:r})},[o,e.length,t,r,l])}import{Fragment as po,jsx as L}from"react/jsx-runtime";var Vt=ao.memo(function({restoreMode:e,currentPath:t,gitRepo:r,loading:n,refreshBranches:a}){let{inputLocked:s,setCurrentView:i,theme:c}=d(),{filterType:m}=v(),{handleSearchInput:l,activateSearch:p,cycleFilter:u}=se(),{availableBranches:g,selectedBranches:h,selectAllAvailableBranches:f,handleListNavigation:S,deselectAvailableBranches:P}=G(),{pendingOperation:T,enterConfirmationMode:D,executeOperationAndExit:C,exitConfirmationMode:N}=pt(r,h,a);lo((B,x)=>{if(!n){if(T)return S(x,B),void 0;if(!l(B,x)&&!s){if(B==="/"){p();return}if(B==="f"){u();return}if(B==="a"){f();return}if(B==="A"){P();return}if(B==="v"){i("branch");return}if(B==="t"&&h.length>0&&!e){D(F.TRASH);return}if(B==="d"&&h.length>0){D(F.DELETE);return}if(B==="r"&&h.length>0&&e){D(F.RESTORE);return}}}});let H=T?le[T].type:"default",k=io(()=>T?"\u2191\u2193: navigate \u2022 Space: deselect \u2022 Y/Enter: confirm \u2022 N/Esc: cancel":`\u2191\u2193: navigate \u2022 space: select \u2022 a: select all \u2022 /: search \u2022 f: filter \u2022 v: view \u2022 d: delete permanently \u2022 ${e?"r: restore":"t: trash"}`,[T,e]);return L(j,{statusBarContent:L(Ft,{pendingOperation:T,selectedBranches:h,onConfirm:C,onCancel:N}),statusBarType:H,helpText:k,currentPath:t,children:L(Ie,{flexGrow:1,flexDirection:"column",children:g.length===0?n?L(Ie,{justifyContent:"center",alignItems:"center",flexGrow:1,children:L(fe,{text:"Loading branches..."})}):L(Ie,{justifyContent:"center",alignItems:"center",flexGrow:1,children:L(co,{color:c.colors.text,children:m==="selected"&&h.length===0?"No branches selected":"No branches found"})}):L(po,{children:L(St,{branches:g})})})})});import mo,{useState as $t,useEffect as ho,useMemo as uo}from"react";import{Box as M,Text as b,useInput as fo}from"ink";import{Fragment as go,jsx as y,jsxs as O}from"react/jsx-runtime";var jt=mo.memo(function({gitRepo:e,currentPath:t}){let{theme:r,setCurrentView:n,inputLocked:a}=d(),{currentBranch:s}=G(),[i,c]=$t(""),[m,l]=$t(!1);ho(()=>{if(!s){c("");return}l(!0),e.getBranchLog(s.ref,15).then(c).catch(()=>c("Failed to load branch log")).finally(()=>l(!1))},[s,e]),fo((h,f)=>{f.escape&&n("branches")},{isActive:!a});let p="Esc: back to branches",u=y(b,{color:r.colors.text,children:s?.name}),g=uo(()=>s?pe(s,r):{text:"Loading...",color:"white"},[s,r]);return s?y(j,{statusBarContent:u,helpText:p,currentPath:t,children:O(M,{flexDirection:"column",children:[O(M,{flexDirection:"column",paddingX:1,paddingY:1,children:[O(M,{flexDirection:"row",children:[y(b,{color:r.colors.primary,children:"Status: "}),y(b,{color:g.color,wrap:"truncate-end",children:g.text})]}),O(M,{flexDirection:"row",children:[y(b,{color:r.colors.primary,children:"Remote: "}),y(b,{color:r.colors.text,children:s.isRemote?"Remote":"Local"})]}),s.lastCommitAuthor&&O(M,{flexDirection:"row",children:[y(b,{color:r.colors.primary,children:"Author: "}),y(b,{color:r.colors.text,children:s.lastCommitAuthor})]}),!s.isRemote&&O(M,{flexDirection:"row",children:[y(b,{color:r.colors.primary,children:"Tracking: "}),s.upstreamBranch!==null?O(go,{children:[y(b,{color:r.colors.text,children:s.upstreamBranch}),s.upstreamTrack!==null&&O(b,{color:r.colors.warning,children:[" ",s.upstreamTrack]})]}):y(b,{color:r.colors.muted,children:"No upstream"})]})]}),y(M,{paddingX:1,paddingY:1,children:y(b,{color:r.colors.primary,bold:!0,children:"Recent Commits"})}),y(M,{flexDirection:"column",flexGrow:1,paddingX:1,overflow:"hidden",children:m?y(fe,{text:"Loading branch log..."}):y(b,{color:r.colors.text,children:i})})]})}):y(j,{statusBarContent:u,helpText:p,currentPath:t,children:y(M,{flexDirection:"column",children:O(M,{paddingX:1,paddingY:1,flexGrow:1,justifyContent:"center",alignItems:"center",children:[y(b,{bold:!0,children:"Branch Preview"}),y(b,{children:"Select a branch to view details"})]})})})});import{jsx as Ht}from"react/jsx-runtime";function Wt({restoreMode:o=!1,gitRepo:e,currentPath:t,loading:r,refreshBranches:n}){let{currentView:a,showExitWarning:s,setShowExitWarning:i}=d(),c=yo(null),{exit:m}=So(),l=xo(()=>{s?m():(i(!0),c.current&&clearTimeout(c.current),c.current=setTimeout(()=>{i(!1),c.current=null},1e3))},[s,m,i,c]);return Bo(()=>()=>{c.current&&clearTimeout(c.current)},[]),wo((u,g)=>{g.ctrl&&u==="c"&&l()}),(()=>{switch(a){case"branch":return Ht(jt,{gitRepo:e,currentPath:t});case"branches":default:return Ht(Vt,{restoreMode:o,currentPath:t,gitRepo:e,loading:r,refreshBranches:n})}})()}import{simpleGit as To}from"simple-git";import{differenceInDays as bo}from"date-fns/differenceInDays";import{spawn as Co}from"child_process";var X=class{git;NAMESPACES={heads:"refs/heads/",trash:"refs/rake-trash/",remotes:"refs/remotes/"};mergeCompareBranch;workingDir;trashTtlDays;staleDaysThreshold;excludedBranches;constructor(e,t){this.workingDir=t||process.cwd(),this.git=To(this.workingDir),this.mergeCompareBranch=e.mergeCompareBranch,this.trashTtlDays=e.trashTtlDays,this.staleDaysThreshold=e.staleDaysThreshold,this.excludedBranches=e.excludedBranches,this.excludedBranches.push(this.mergeCompareBranch)}async isGitRepository(){try{return await this.git.status(),!0}catch{return!1}}buildFullRef(e,t){return this.NAMESPACES[t]+e}parseUserInput(e,t){let r=this.NAMESPACES[t],n=r.slice(5);return e.startsWith(r)?e.slice(r.length):e.startsWith(n)?e.slice(n.length):e}async getCurrentBranch(){return(await this.git.status()).current||"HEAD"}async getMergedHashes(e){try{return(await this.git.raw(["for-each-ref","--merged="+this.mergeCompareBranch,"--format=%(objectname)","--omit-empty",e])).trim().split(`
`).filter(Boolean)}catch(t){return R.error("Error getting merged hashes",{refsNamespace:e,error:t instanceof Error?t.message:String(t)}),[]}}async deleteBranch(e,t=!1){await this.git.deleteLocalBranch(e,t)}async moveBranchToTrash(e){await this.moveBranchesToTrash([e])}async moveBranchesToTrash(e){if(e.length===0)return;let t=await this.getBranchOperations(e,"heads");await this.trashBranchesWithRetry(t)}async restoreBranchFromTrash(e){await this.restoreBranchesFromTrash([e])}async restoreBranchesFromTrash(e){if(e.length===0)return;let t=await this.getBranchOperations(e,"trash");await this.restoreBranchesWithRetry(t)}async getBranches(e,t){try{let r=e==="heads"?await this.getCurrentBranch():"",n=this.NAMESPACES[e],a=this.excludedBranches.map(p=>`--exclude=${n}${p}`),s=["%(refname)","%(refname:lstrip=2)","%(committerdate:iso)","%(subject)","%(objectname)","%(authorname)","%(upstream:short)","%(upstream:track)","%(upstream:trackshort)"].join("%09"),i=await this.git.raw(["for-each-ref",`--format=${s}`,"--omit-empty","--sort=-committerdate",...a,n]);if(!i.trim())return[];let c=i.trim().split(`
`),m=new Set(await this.getMergedHashes(n)),l=[];for(let p=0;p<c.length;p++){let u=c[p];if(!u)continue;let[g,h,f,S,P,T,D,C,N]=u.split(" "),H=new Date(f),k=bo(new Date,H),U={ref:g,lastCommitDate:H,lastCommitMessage:S,lastCommitHash:P,lastCommitAuthor:T,isMerged:m.has(P),isStale:k>this.staleDaysThreshold,staleDays:k,isCurrent:h===r,isRemote:e==="remotes",upstreamBranch:D||null,upstreamTrack:C||null,upstreamTrackShort:N||null};if(e==="trash"){let B=this.parseTrashRefName(h),x={...U,name:B.branchName,deletionDate:new Date(B.date)};l.push(x),t?.(x,l.length-1)}else{let B={...U,name:e==="remotes"?h.replace("origin/",""):h};l.push(B),t?.(B,l.length-1)}}return l}catch(r){return R.error("Error getting branches",{branchType:e,error:r instanceof Error?r.message:String(r)}),[]}}async cleanupTrash(){let e=new Date;e.setDate(e.getDate()-this.trashTtlDays);try{let r=(await this.getBranches("trash")).reduce((a,s)=>(s.deletionDate<e&&a.push({action:"delete",ref:s.ref}),a),[]);if(r.length===0)return;let n=await this.executeBatchRefUpdates(r);if(!n.success)throw R.error("Failed to delete expired trash refs",{expiredCount:r.length,error:n.error}),new Error(`Trash cleanup failed: ${n.error}`)}catch(t){throw R.error("Failed to cleanup trash",{error:t instanceof Error?t.message:String(t)}),t}}async executeBatchRefUpdates(e){if(e.length===0)return{success:!0,conflictingRefs:[]};let t=e.map(r=>{switch(r.action){case"create":return`create ${r.ref} ${r.value}`;case"update":return`update ${r.ref} ${r.value}`;case"delete":return`delete ${r.ref}`;case"verify":return`verify ${r.ref} ${r.value||""}`;default:throw new Error(`Unknown action: ${r.action}`)}}).join(`
`)+`
`;return new Promise(r=>{let n=Co("git",["update-ref","--stdin"],{cwd:this.workingDir}),a="";n.stderr.on("data",s=>{a+=s.toString()}),n.on("close",s=>{if(s===0){r({success:!0,conflictingRefs:[]});return}let i=this.parseConflictingRefs(a);r({success:!1,conflictingRefs:i,error:a})}),n.on("error",s=>{r({success:!1,conflictingRefs:[],error:s.message})}),n.stdin.write(t),n.stdin.end()})}parseConflictingRefs(e){let t=[],r=/fatal: cannot lock ref '([^']+)': .*already exists/g,n;for(;(n=r.exec(e))!==null;)t.push(n[1]);return t}stripIncrement(e){return e.replace(/\{\d+\}$/,"")}buildIncrementedRef(e,t){return t===0?e:`${e}{${t}}`}parseTrashRefName(e){let t=e.lastIndexOf("@");if(t===-1)throw new Error(`Invalid trash ref format - missing date: ${e}`);let r=e.substring(0,t),n=e.substring(t+1);if(!r)throw new Error(`Invalid trash ref format - empty branch name: ${e}`);if(!/^\d{4}-\d{2}-\d{2}$/.test(n))throw new Error(`Invalid trash ref format - bad date format: ${e} (expected YYYY-MM-DD)`);let a=new Date(n);if(isNaN(a.getTime())||a.toISOString().split("T")[0]!==n)throw new Error(`Invalid trash ref format - invalid date: ${e} (${n} is not a valid date)`);return{branchName:r,date:n}}buildTrashRefName(e){let t=new Date().toISOString().split("T")[0];return`${e}@${t}`}createTrashCommands(e){return e.flatMap(({name:t,sha:r})=>[{action:"create",ref:this.buildFullRef(this.buildTrashRefName(t),"trash"),value:r},{action:"delete",ref:this.buildFullRef(t,"heads")}])}createRestoreCommands(e){return e.flatMap(({name:t,sha:r})=>{let n=this.parseTrashRefName(t).branchName;return[{action:"create",ref:this.buildFullRef(n,"heads"),value:r},{action:"delete",ref:this.buildFullRef(t,"trash")}]})}createDeleteCommands(e){return e.map(t=>({action:"delete",ref:t.ref}))}async trashBranchesWithRetry(e){if(e.length===0)return;let t=await this.executeBatchRefUpdates(this.createTrashCommands(e));if(t.success)return;if(t.conflictingRefs.length===0)throw new Error(`Trash operation failed: ${t.error}`);let r=await this.resolveNameConflicts(t.conflictingRefs,e,this.NAMESPACES.trash);if(t=await this.executeBatchRefUpdates(this.createTrashCommands(r)),!t.success)throw new Error(`Conflict resolution failed: ${t.error}`)}async restoreBranchesWithRetry(e){if(e.length===0)return;let t=await this.executeBatchRefUpdates(this.createRestoreCommands(e));if(t.success)return;if(t.conflictingRefs.length===0)throw new Error(`Restore operation failed: ${t.error}`);let r=await this.resolveNameConflicts(t.conflictingRefs,e,this.NAMESPACES.heads);if(t=await this.executeBatchRefUpdates(this.createRestoreCommands(r)),!t.success)throw new Error(`Conflict resolution failed: ${t.error}`)}async resolveNameConflicts(e,t,r){if(e.length===0)return t;let n=new Map,a=await this.getAllRefsInNamespace(r);for(let s of e){let i=s.slice(r.length),c=this.stripIncrement(i),m=this.findNextAvailableIncrementFromRefs(c,a),l=this.buildIncrementedRef(c,m);R.info(`Resolving naming conflict. Original: '${i}', Final: '${l}'`),n.set(i,l)}return t.map(s=>({...s,name:n.get(s.name)||s.name}))}async getAllRefsInNamespace(e){try{let t=await this.git.raw(["for-each-ref","--format=%(refname:lstrip=2)","--omit-empty",e]);return t.trim()?t.trim().split(`
`).filter(Boolean):[]}catch(t){return R.error("Error getting refs in namespace",{namespace:e,error:t instanceof Error?t.message:String(t)}),[]}}async getBranchOperations(e,t){if(e.length===0)return[];try{let r=await this.git.raw(["for-each-ref","--format=%(refname:lstrip=2) %(objectname)","--omit-empty",this.NAMESPACES[t]]);if(!r.trim())return[];let n=new Set(e),a=[],s=new Set;for(let i of r.trim().split(`
`)){let[c,m]=i.split(" ");if(!c||!m)continue;let l;t==="trash"?l=this.parseTrashRefName(c).branchName:l=c,n.has(l)&&(a.push({name:c,sha:m}),s.add(l))}if(s.size!==e.length){let i=e.filter(c=>!s.has(c));throw new Error(`Branches not found in ${t}: ${i.join(", ")}`)}return a}catch(r){throw R.error("Error fetching branch operations",{branchCount:e.length,namespace:this.NAMESPACES[t],error:r instanceof Error?r.message:String(r)}),r}}findNextAvailableIncrementFromRefs(e,t){let r=this.stripIncrement(e),n=0;for(let a of t)if(a.startsWith(r+"{")&&a.endsWith("}")){let s=a.slice(r.length+1,-1),i=parseInt(s,10);isNaN(i)||(n=Math.max(n,i))}return n+1}async pruneRemoteBranches(){try{return(await this.git.raw(["remote","prune","origin","--dry-run"])).split(`
`).filter(r=>r.includes("origin/")).map(r=>r.match(/origin\/(.+)/)?.[1]).filter(Boolean)}catch{return[]}}async executePruneRemoteBranches(){await this.git.raw(["remote","prune","origin"])}async getBranchLog(e,t=10){try{return await this.git.raw(["log","--oneline","--graph","--decorate",`--max-count=${t}`,e])}catch{return"No commits found"}}async performBatchOperations(e){let t=e.reduce((r,n)=>(r[n.type].push(n),r),{trash:[],delete:[],restore:[],prune:[]});if(t.trash.length>0){let r=t.trash.map(n=>n.branch.name);await this.moveBranchesToTrash(r)}if(t.restore.length>0){let r=t.restore.map(n=>n.branch.name);await this.restoreBranchesFromTrash(r)}if(t.delete.length>0){let r=t.delete.map(a=>a.branch),n=await this.executeBatchRefUpdates(this.createDeleteCommands(r));if(!n.success)throw new Error(`Delete operation failed: ${n.error}`)}t.prune.length>0&&await this.executePruneRemoteBranches()}};import{useState as Pe,useEffect as vo,useCallback as Ro}from"react";function _t({gitRepo:o,config:e,includeRemote:t=!1,restoreMode:r=!1,currentPath:n}){let[a,s]=Pe([]),[i,c]=Pe(!0),[m,l]=Pe(""),p=Ro(async()=>{try{if(c(!0),l(""),!await o.isGitRepository()){l(`Not a git repository: ${n}`);return}let u=[];if(r)u=await o.getBranches("trash",(g,h)=>{s(f=>[...f.slice(0,h),g,...f.slice(h+1)])});else{let g=await o.getBranches("heads",(h,f)=>{s(S=>[...S.slice(0,f),h,...S.slice(f+1)])});if(u=[...g],t||e.includeRemote){let h=await o.getBranches("remotes",(f,S)=>{let P=g.length+S;s(T=>[...T.slice(0,P),f,...T.slice(P+1)])});u=[...g,...h]}}s(u),c(!1)}catch(u){l(u instanceof Error?u.message:"Unknown error"),c(!1)}},[o,e,t,r,n]);return vo(()=>{p()},[p]),{branches:a,loading:i,error:m,loadBranches:p}}import{Box as Ao,Text as Qt}from"ink";import{jsx as Ee,jsxs as Io}from"react/jsx-runtime";function Yt({error:o,currentPath:e}){let{theme:t}=d(),r="ESC: exit \u2022 Ctrl+C: force exit",n=Ee(Qt,{color:t.colors.alert,bold:!0,children:"Error"});return Ee(j,{statusBarContent:n,helpText:r,currentPath:e,children:Ee(Ao,{flexDirection:"column",padding:1,children:Io(Qt,{color:t.colors.alert,children:["Error: ",o]})})})}import{StrictMode as Eo,useMemo as Go,useEffect as Mo,useRef as Lo}from"react";import{useCallback as Po}from"react";function Xt({gitRepo:o,config:e}){return Po(async()=>{if(e.autoCleanupTrash)try{await o.cleanupTrash()}catch(t){R.error("Background trash cleanup failed after app load",{autoCleanupEnabled:e.autoCleanupTrash,error:t instanceof Error?t.message:String(t)})}},[o,e.autoCleanupTrash])}import{jsx as K}from"react/jsx-runtime";function Ge({config:o,restoreMode:e,workingDir:t,includeRemote:r}){let n=Go(()=>new X(o,t),[o,t]),a=t||process.cwd(),{branches:s,error:i,loadBranches:c,loading:m}=_t({gitRepo:n,config:o,includeRemote:r||!1,restoreMode:e||!1,currentPath:a}),l=Xt({gitRepo:n,config:o}),p=Lo(!1);return Mo(()=>{s.length>0&&!p.current&&(p.current=!0,l())},[s.length,l]),i?K(Yt,{error:i,currentPath:a}):K(Eo,{children:K(ze,{config:o,children:K(Ze,{children:K(rt,{branches:s,children:K(Wt,{restoreMode:e||!1,gitRepo:n,currentPath:a,loading:m,refreshBranches:c})})})})})}import Uo from"react";import{cosmiconfigSync as Kt}from"cosmiconfig";import{homedir as Oo}from"os";import{simpleGit as ko}from"simple-git";var Do={staleDaysThreshold:30,trashTtlDays:90,mergeCompareBranch:"main",theme:"auto",includeRemote:!1,autoCleanupTrash:!0,excludedBranches:["main","master","trunk","develop","dev","release","production","prod","staging"]};async function No(o){try{return(await ko(o||process.cwd()).revparse(["--show-toplevel"])).trim()}catch{return null}}async function zt(o){let e=await No(o).then(s=>s||process.cwd()),t={},r={},n=Oo(),a=Kt("gitrake",{stopDir:n});try{let s=a.search(n);s&&!s.isEmpty&&(t=s.config)}catch{}if(e){let s=Kt("gitrake",{stopDir:e});try{let i=s.search(e);i&&!i.isEmpty&&(r=i.config)}catch{}}return{...Do,...t,...r}}import{withFullScreen as Fo}from"fullscreen-ink";var qt=async o=>{let e=o.optsWithGlobals().cwd;return await zt(e||null)},ge=async(o,e={})=>{let t=o.optsWithGlobals(),r=await qt(o);ae(!!t.debug||process.env.DEV==="true");let n=Fo(Uo.createElement(Ge,{...e,config:r,workingDir:t.cwd||null}),{exitOnCtrlC:!1});await n.start(),await n.waitUntilExit(),process.env.DEV&&process.exit(0)},z=async o=>{let e=o.optsWithGlobals(),t=await qt(o);return ae(!!e.debug||process.env.DEV==="true"),{gitRepo:new X(t,e.cwd||null),config:t,allOptions:e}};async function Vo(o,e){let{gitRepo:t}=await z(e);o||(console.error("No branch name provided"),process.exit(1));try{let r=t.parseUserInput(o,"trash");await t.restoreBranchFromTrash(r),console.log(`\u2705 Restored branch: ${r}`),process.exit(0)}catch(r){console.error(`\u274C Failed to restore branch ${o}:`,r instanceof Error?r.message:r),process.exit(1)}}var Me=async(o,e,t)=>{o?await Vo(o,t):ge(t,{restoreMode:!0})};async function $o(o){let{gitRepo:e}=await z(o);try{let t=await e.getBranches("trash");t.length===0&&(console.log("No branches in trash"),process.exit(0)),console.log("Branches in trash:"),t.forEach(r=>{console.log(` \u2022 ${r.name} (${r.deletionDate.toLocaleDateString()})`)}),process.exit(0)}catch(t){console.error("Failed to list trash:",t instanceof Error?t.message:t),process.exit(1)}}async function jo(o,e){let{gitRepo:t}=await z(e);try{let r=t.parseUserInput(o,"heads");await t.moveBranchToTrash(r),console.log(`\u2705 Moved branch ${r} to trash`),process.exit(0)}catch(r){console.error(`\u274C Failed to move branch ${o} to trash:`),console.error(r),process.exit(1)}}async function Ho(o){let{gitRepo:e}=await z(o);try{await e.cleanupTrash(),console.log("\u2705 Pruned old trash entries"),process.exit(0)}catch(t){console.error("Failed to prune trash:",t instanceof Error?t.message:t),process.exit(1)}}var Le=async(o,e,t)=>{e.prune?await Ho(t):e.list?await $o(t):o?await jo(o,t):ge(t)};var q=new Wo;q.name("git-rake").description("Interactive CLI tool to safely delete, trash, and restore Git branches").version("0.1.0").option("--cwd <path>","Working directory (defaults to current directory)").option("--debug","Enable debug logging to ~/.git-rake/logs/git-rake.log");process.env.DEV==="true"&&q.option("-r, --include-remote","Include remote tracking branches");q.action(async()=>{console.log("Available commands:"),console.log(" trash, branch Interactive branch management (trash/delete)"),console.log(" trash --list List trashed branches"),console.log(" trash --prune Prune old trash entries"),console.log(" trash <branch> Move branch to trash"),console.log(" restore Interactive restore mode"),console.log(" restore <branch> Restore specific branch"),console.log(""),console.log("Aliases:"),console.log(" branch Alias for trash command"),console.log(""),console.log('Run "git-rake <command> --help" for more information on a command.'),process.exit(0)});q.command("restore").argument("[branch-name]","(Optional) Name of individual branch to restore from trash.").description("Restore branches from trash.").summary("You can either restore a single branch or enter interactive mode to restore multiple branches.").action(Me);q.command("trash").alias("branch").argument("[branch-name]","(Optional) Name of individual branch to trash.").option("-l, --list","List trashed branches").option("-p, --prune","Prune old entries from trash").description("Interactive branch management (trash/delete), list trashed branches, move branches to trash, or prune old trash").summary("Enter interactive mode for branch management (default), list trashed branches (--list), move a specific branch to trash (<branch-name>), or prune old trash (--prune). Alias: branch").action(Le);q.parseAsync();export{Ge as App};