bisgit 0.8.1 → 0.9.1

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.
package/README.md CHANGED
@@ -6,6 +6,8 @@ Run `gi` or `bisgit` for full TUI.
6
6
 
7
7
  ## Commands
8
8
 
9
+ Each of these commands work with `gi` or `bisgit`. Just found out gi isn't going to work in powershell because it's already an alias for get-item.
10
+
9
11
  ### Commit Tooling
10
12
 
11
13
  - `gi sha <commit>` copies the shortend sha to clipboard (uses HEAD as default)
@@ -42,9 +44,12 @@ Run `gi` or `bisgit` for full TUI.
42
44
  - `gi churn` shows you the 25 most edited files.
43
45
  - `gi exclude` and `gi include` allows you to ignore files locally without modifying the .gitignore file.
44
46
  - `gi remote-default` shows whether the remote default branch is 'main', 'master', etc.
47
+ - `gi update` updates the cli via npm
45
48
 
46
49
  ## Tips
47
50
 
48
51
  - If using this in VS Code's integrated terminal, I'd recommend disabling `terminal.integrated.stickyScroll.enabled` or adding gi to `terminal.integrated.stickyScroll.ignoredCommands`
49
52
 
50
53
  I turned many of my git aliases into commands. The original aliases are found this [gist](https://gist.github.com/alexanderdombroski/ddac491daeff48c5f1346ba2960462fa).
54
+
55
+ This also works as a wrapper for git and gh commands. Some commands that don't normally do anything are given a purpose, such as `git switch` or `git config` with no arguments.
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import{a as o,m as s,o as i}from"./chunk-QMJXU6BD.js";import{spawnSync as n}from"node:child_process";function r(e,a,t){let{status:c}=n(e,a,{stdio:"ignore"});c!==0&&(t&&console.error(t),process.exit(1))}var d=()=>r("git",["rev-parse","--git-dir"],"Need to use command in a git repository."),m=()=>r("git",["rev-parse","HEAD"],"Need to create first commit."),f=(e="origin")=>r("git",["remote","get-url",e],`Need to add remote '${e}'.`),l=e=>r("git",["show-ref","--branches",e],`Branch '${e}' isn't tracked locally and may not exist.`),x=async()=>{await i()||(console.error("You should stash or commit your changes first."),process.exit(1))},h=async e=>{await o(e)||(console.error(`${e} must exist for this operation and it doesn't for some reason`),process.exit(1))},q=async()=>{await s()&&(console.error("Operation not allowed in a 'detached HEAD' state"),process.exit(1))},y=e=>r("git",["rev-parse","--abbrev-ref","--symbolic-full-name",`${e}@{u}`],`branch '${e}' has no upstream`);function v(e="Error: missing required argument"){if(process.argv[3])return process.argv[3];console.error(e),process.exit(1)}async function w(){let{status:e}=n("git",["diff","--staged","--quiet"],{stdio:"ignore"});e===0&&(console.error("You have no staged changes"),process.exit(1))}export{d as a,m as b,f as c,l as d,x as e,h as f,q as g,y as h,v as i,w as j};
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ function t(){return process.argv[2]}function n(){return process.argv.slice(3)}async function o(){let[r,e]=n();return r||(console.error("Requires <branch> or <remote> <branch>"),process.exit(1)),e?{remote:r,branch:e}:{remote:"origin",branch:r}}export{t as a,n as b,o as c};
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import{Box as c,Text as m,useApp as s,useInput as l}from"ink";import u from"ink-select-input";import{jsx as o,jsxs as T}from"react/jsx-runtime";function a({prompt:i,onSelect:n,items:r}){let{exit:e}=s();return l((t,p)=>{p.escape&&e()}),T(c,{flexDirection:"column",children:[o(m,{children:i}),o(u,{items:r,onSelect:async t=>{await n(t),e()}})]})}export{a};
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import{exec as u,spawn as l,execFile as g}from"node:child_process";import{promisify as d}from"node:util";function w(r,s,t){let e=l(r,s,t??{});t?.silent||(e.stdout?.on("data",o=>{console.log(String(o))}),e.stderr?.on("data",o=>{console.error(String(o))})),e.on("close",o=>{t?.triggerExit&&process.exit(o)})}var m=d(u),y=d(g);async function h(r){let{stdout:s}=await m(r),t=s.trimEnd();return t?t.split(/\r?\n/):[]}async function S(r,s,t={}){let{promise:e,resolve:o,reject:c}=Promise.withResolvers(),n=l(r,s,t),p="",a="";return n.stdout?.on("data",i=>p+=i),n.stderr?.on("data",i=>a+=i),n.on("close",i=>o({code:i,stdout:p,stderr:a})),n.on("error",i=>c(i)),e}async function O(r,s="inherit"){let{promise:t,resolve:e,reject:o}=Promise.withResolvers(),c=l("git",["-c","color.ui=always",...r],{stdio:s});return c.on("close",n=>{n===0?e({code:n}):o({code:n})}),c.on("error",o),t}export{w as a,m as b,h as c,S as d,O as e};
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import{b as a,c as o,d as g}from"./chunk-OSOEWQKA.js";import d from"fs/promises";async function v(t){try{return await d.access(t),!0}catch{return!1}}async function h(){return await o("git ls-files")}async function y(){return await o("git ls-files --others --exclude-standard")}async function B(){let[t,r]=await Promise.all([h(),y()]),e=[...t,...r].sort(([i],[s])=>i.localeCompare(s)),n={};for(let i of e){let s=i.split("/"),c=n;for(let u of s)c[u]||(c[u]={}),c=c[u]}return n}function w(t,r=""){let e=[];for(let[n,i]of Object.entries(t)){let s=r?`${r}/${n}`:n;e.push(s),Object.keys(i).length>0&&e.push(...w(i,s))}return e}async function D(){let[t,r]=await Promise.all([await o("git config --list --global"),await o("git config --list --local")]);return[...t,...r].filter(Boolean).map(e=>e.trim()).filter(e=>!e.startsWith("alias")).map(e=>{let n=e.indexOf("=");if(n===-1)return[e,""];let i=e.slice(0,n),s=e.slice(n+1);return[i,s]})}import{normalize as p}from"node:path";async function x(){let{stdout:t}=await a("git branch --show-current");return t.trim()}async function E(t){t??=await x();let{stdout:r}=await a(`git config --get branch.${t}.remote`);return r.trim()}async function k(t,r){try{let{stdout:e}=await a(`git rev-list --count ${t}/${r}..${r}`);return parseInt(e.trim(),10)}catch(e){return console.error("Error getting commits ahead:",e),NaN}}async function M(t,r){try{let{stdout:e}=await a(`git rev-list --count ${r}..${t}/${r}`);return parseInt(e.trim(),10)}catch(e){return console.error("Error getting commits behind:",e),NaN}}async function A(t){let{stdout:r}=await a(`git rev-parse --git-path ${t}`);return p(r.trim())}async function G(){let{stdout:t}=await a("git rev-parse --git-dir");return p(t.trim())}async function I(){let{stdout:t}=await a("git rev-parse --show-toplevel");return p(t.trim())}async function z(t){let{code:r}=await g("git",["remote","get-url",t],{stdio:"ignore"});return r===0}async function H(){let{stdout:t}=await a("git rev-parse --abbrev-ref HEAD");return t.trim()==="HEAD"}async function O(t,r){let e="git fetch";t&&(e+=` ${t}`),r&&(e+=` ${r}`),await a(e)}async function j(){let{stdout:t}=await g("git",["status","--porcelain"]);return!t?.trim()}async function $(t,r){let{stdout:e}=await a(`git merge-base ${t} ${r}`);return e.trim()}async function U(t,r){let e=await $(t,r),{stdout:n}=await g("git",["merge-tree",e,r,t]);return!n?.split(/\r?\n/)?.includes("+=======")}async function V(t){let{stdout:r}=await a(`git rev-parse ${t}`);return r.trim()}async function W(t,r,e){return await o(`git rev-list ${e?"--reverse":""} ${t}..${r}`)}async function q(){return await o("git for-each-ref --format='%(refname:short)' refs/heads")}async function J(){let{stdout:t}=await a("git remote -v");return t.trim().split(/\r?\n/).map(e=>{let n=e.match(/^(\S+)\s+(\S+)\s+\((fetch|push)\)$/);if(!n)return null;let[,i,s,c]=n;return{name:i,url:s,type:c}}).filter(e=>e!==null)}async function K(t){try{let{stdout:r}=await a(`git log -1 --format='%an|%ae|%ad|%h' -- "${t}"`,{encoding:"utf8"}),[e,n,i,s]=r.trim().split("|");return{authorName:e,authorEmail:n,authorDate:i,shortHash:s}}catch{return{}}}async function Q(t,r){let e=r?`git diff --numstat ${t} ${r}`:b(t)?`git stash show --numstat --format="" --include-untracked ${t}`:`git show --numstat --format="" ${t}`;return(await o(e)).map(i=>{let[s,c,u]=i.split(" ");if(s==="-"&&c==="-")return{file:u,added:null,deleted:null,changeType:"binary"};let m=Number(s),l=Number(c),f="modified";return m>0&&l===0?f="added":m===0&&l>0&&(f="deleted"),{file:u,added:m,deleted:l,changeType:f}})}function b(t){return/^stash@\{\d+\}$/.test(t)}async function P(){return await o("git status --porcelain")}async function Z(){return(await P()).map(e=>({staged:e[1]===" ",changeType:e[0]||e[1],name:e.slice(3)}))}export{v as a,B as b,w as c,D as d,x as e,E as f,k as g,M as h,A as i,G as j,I as k,z as l,H as m,O as n,j as o,$ as p,U as q,V as r,W as s,q as t,J as u,K as v,Q as w,b as x,P as y,Z as z};
@@ -0,0 +1,13 @@
1
+ #!/usr/bin/env node
2
+ import{b as u,c as X}from"./chunk-5WTQIRZS.js";import{a as mt}from"./chunk-NHXDQYDU.js";import{a as at,b as P,c as h,d as V,e as A,f as N,g as U,h as ct,i as y,j as v}from"./chunk-54ESUAMF.js";import{a as C,e as w,f as tt,g as W,h as G,i as k,j as et,k as ot,l as rt,n as M,o as x,p as R,q as it,r as nt,s as F,t as st,w as H,x as L,y as I}from"./chunk-QMJXU6BD.js";import{a as b,b as s,c as E,d,e as f}from"./chunk-OSOEWQKA.js";import B from"node:path";async function lt(){let t=await I(),e=/^(UU|DU|UD)/;return!!t?.some(o=>e.test(o))}async function j(){let t=await et(),[e,o,i,n,r]=await Promise.all([await C(B.join(t,"MERGE_HEAD")),await C(B.join(t,"rebase-merge")),await C(B.join(t,"rebase-apply")),await C(B.join(t,"CHERRY_PICK_HEAD")),await C(B.join(t,"REVERT_HEAD"))]);return{merge:e,rebaseMerge:o,rebaseApply:i,cherryPick:n,revert:r}}async function ft(){let{merge:t,rebaseMerge:e,rebaseApply:o,cherryPick:i,revert:n}=await j(),r="";if(t)r="merge";else if(e||o)r="rebase";else if(i)r="cherry-pick";else if(n)r="revert";else{let a=await lt()?"Conflicts exist, but likely are from a stash and are not abortable. Resolve them manually.":"Nothing to abort.";console.log(a);return}console.log(`Aborting the ${r}`),await f([r,"--abort"])}async function pt(){await U(),await v(),b("git",["commit","--amend","--no-edit",...u()],{stdio:"inherit",silent:!0,triggerExit:!0})}import{render as oe}from"ink";import{render as te}from"ink";import{Suspense as Yt,use as zt,useEffect as Jt}from"react";import{Text as gt,useApp as Kt}from"ink";import Zt from"ink-spinner";import{jsx as O,jsxs as Xt}from"react/jsx-runtime";function m(t){let{msg:e}=t;return O(Yt,{fallback:Xt(gt,{children:[O(Zt,{type:"dots"}),"\xA0",e]}),children:O(Qt,{...t})})}function Qt({msg:t,promise:e}){let o=zt(e),{exit:i}=Kt();return Jt(()=>{i()},[o]),O(gt,{children:`\u2714 ${typeof o=="string"?o:t}`})}import{jsx as ee}from"react/jsx-runtime";async function ut(){let t=process.argv[3],e=process.argv[4]??await w();if(V(t),V(e),t===e)return console.log(`No reason to merge '${t}' into '${e}'`);let o=await tt(t);h(o),te(ee(m,{msg:"Updating target branch and merging",promise:(async()=>{try{await q(o,t)}catch{console.error(`Error when updating branch ${t} with remote ${o}. Fix divergent branches before merging into ${e}`);return}await w()!==e&&await s(`git switch ${e}`),b("git",["merge",t],{stdio:"inherit",silent:!0})})()}))}async function q(t,e){await M(t,e);let[o,i,n]=await Promise.all([W(t,e),G(t,e),w()]);if(i!==0){if(o===0&&n!==e){await s(`git fetch ${t} ${e}:${e}`);return}if(await s(`git switch ${e}`),o===0){await s(`git merge ${t}/${e}`);return}await f(["merge",`${t}/${e}`],["ignore","ignore","inherit"])}}async function T(){P(),h();let{stdout:t,code:e}=await d("git",["rev-parse","--abbrev-ref","origin/HEAD"]);if(e===0)return dt(t.trim());await s("git remote set-head origin -a");let{stdout:o}=await s("git rev-parse --abbrev-ref origin/HEAD");return dt(o.trim())}async function wt(){let{remote:t,branch:e}=await T();console.log(`Remote default branch is '${t}/${e}'`)}async function dt(t){let e=t.split("/"),o=t.split("/").map((i,n)=>e.slice(0,n+1).join("/"));for(let i of o)if(await rt(i)){let n=t.slice(i.length+1);return{remote:i,branch:n}}throw new Error("Failed to get default remote")}import{jsx as ie}from"react/jsx-runtime";var re=["master","main","development","lingoport"];async function ht(){await A();let{branch:t,remote:e}=await T();await s(`git switch ${t}`);let o=(async()=>{let{stdout:r}=await s("git fetch --prune --prune-tags");return await q(e,t),{prunedRefs:r.trim()}})();oe(ie(m,{msg:"Fetching and pruning remote references",promise:o}));let{prunedRefs:i}=await o;i&&console.log(i);let n=await st();for(let r of n){if(r===t||re.includes(r))continue;let{code:a}=await d("git",["diff","--quiet",t,r]);if(a===0){Y(r);continue}let{code:c}=await d("git",["merge-base","--is-ancestor",r,t]);if(c===0){Y(r);continue}let l=await R(r,t),{stdout:p}=await d("git",["merge-tree",l,t,r]);p?.trim()||Y(r)}}function Y(t){f(["branch","-D",t])}import{spawn as ne}from"node:child_process";import{createInterface as se}from"node:readline/promises";async function yt(){P;let e=[...(await ae()).entries()].sort(([,i],[,n])=>n-i).slice(0,25),o=e[0][1].toString().length;console.info(e.map(([i,n])=>`${String(n).padEnd(o)} ${i}:`).join(`
3
+ `))}async function ae(){let{promise:t,resolve:e,reject:o}=Promise.withResolvers(),i=new Map,n=ne("git",["log","--all","-M","-C","--name-only","--format=format:"]),r=se({input:n.stdout,crlfDelay:1/0});return r.on("line",a=>{let c=a.trim();c&&i.set(c,(i.get(c)??0)+1)}),r.on("close",()=>e(i)),n.on("error",o),t}import{render as $t}from"ink";import{jsx as Ct}from"react/jsx-runtime";async function xt(){await v();let t=u()[0];if(!t){let r=(await me()).map(c=>({value:c,label:`${c.name} ${c.email} (${c.commits})`}));$t(Ct(mt,{items:r,prompt:"Who assisted in this commit?",onSelect:async({value:{name:c,email:l}})=>{await bt(c,l.slice(1,-1))}}));return}let e=(async()=>{let n=await ce(t);return n.email||(console.error(`Couldn't find an email for ${t}`),process.exit(1)),n})();$t(Ct(m,{msg:"Fetching name and email",promise:e}));let{name:o,email:i}=await e;bt(o,i)}async function ce(t){let{stdout:e}=await s(`gh api users/${t}`);return JSON.parse(e.trim())}async function me(){let t=await E('git log --format="%an|<%ae>"'),e=new Map;for(let o of t){let[i,n]=o.split("|"),r=`${i}|${n}`;e.has(r)||e.set(r,{name:i,email:n,commits:0}),e.get(r).commits+=1}return[...e.values()].toSorted((o,i)=>i.commits-o.commits)}async function bt(t,e){f(["commit","--edit","-m","<insert summary>","-m",`Co-authored-by: ${t} <${e}>`])}import{render as z}from"ink";import{isDeepStrictEqual as le}from"node:util";import{jsx as J}from"react/jsx-runtime";async function Rt(){let t=y("Error: missing id of PR to checkout");await A();let e=(async()=>Promise.all([s(`gh co ${t}`),s(`gh pr view ${t} --json baseRefName -q .baseRefName`)]))();z(J(m,{msg:`Checking out pr #${t}`,promise:e}));let[,{stdout:o}]=await e,i=o.trim(),n=(async()=>{await s(`git switch ${i}`),await s("git pull"),await s("git switch -")})();z(J(m,{msg:`Updating ${i} branch merge destination`,promise:n})),await n;let r=(async()=>{let g=await R(i,"HEAD");return await s(`git reset ${g} --soft`),await fe("HEAD")})();z(J(m,{msg:"Creating an editable, explorable, local PR experience",promise:r}));let[a,c]=await Promise.all([r,pe(t)]),{files:l,additions:p,deletions:D}=c;if(le(a,c))return console.info(`Files: ${l}, +${p} -${D}`);console.info("The PR stat doesn't match the local stat."),console.info("LOCAL"),console.table(a),console.info("GITHUB"),console.table(c),console.info("One option to fix (there'll likely be conflicts):"),console.info("1. git stash -u"),console.info(`2. git merge ${i}`),console.info("3. git stash pop")}async function fe(t){let{stdout:e}=await s(`git diff --shortstat ${t}`),o=/(\d+)\s+files? changed(?:, (\d+) insertions?\(\+\))?(?:, (\d+) deletions?\(-\))?/,i=e.trim().match(o);if(!i)throw new Error(`Couldn't generate short stat for ref(s): ${t}`);let[,n,r,a]=i;return{files:parseInt(n,10),additions:r?parseInt(r,10):0,deletions:a?parseInt(a,10):0}}async function pe(t){let{stdout:e}=await s(`gh pr view ${t} --json deletions,files,additions`),o=JSON.parse(e.trim());return o.files=o.files.length,o}import{spawn as ge}from"node:child_process";import{createInterface as ue}from"node:readline/promises";import K from"chalk";async function Pt(){let t=y("Error: missing target branch argument"),e=await R("HEAD",t),{promise:o,resolve:i,reject:n}=Promise.withResolvers(),r=ge("git",["merge-tree",e,"HEAD",t]),a=ue({input:r.stdout,crlfDelay:1/0}),c=!1,l=0;a.on("line",g=>{g=g.trimEnd(),g==="+<<<<<<< .our"?(c=!0,console.info(K.red(g)),l+=1):g==="+>>>>>>> .their"?(c=!1,console.info(K.green(g))):g==="+======="?console.info(K.yellow(g)):c&&console.info(g)}),a.on("close",()=>i(l)),r.on("error",n);let p=await o,D=p?`\u274C ${p} conflicts would occur!`:"\u2705 No conflicts. Safe to merge.";console.info(D)}async function At(){let{merge:t,rebaseMerge:e,rebaseApply:o,cherryPick:i,revert:n}=await j(),r="";if(t)r="merge";else if(e||o)r="rebase";else if(i)r="cherry-pick";else if(n)r="revert";else{console.log("Nothing to continue.");return}console.log(`Continuing the ${r}`),await f([r,"--continue"])}import{appendFileSync as we}from"node:fs";import{readFile as de}from"node:fs/promises";async function _(t){return(await de(t,"utf-8")).split(/\r?\n/).map(o=>o.trim()).filter(o=>o&&!o.startsWith("#"))}async function vt(){let t=await k("info/exclude");await N(t);let e=await _(t);u().forEach(o=>{e.includes(o)?console.info(`Already Exists: '${o}'`):(we(t,`${o}
4
+ `),console.info(`Added '${o}'`))}),console.info(`
5
+ See file at ${t}`)}async function St(){let t=u();if(t[0]){let e=await he(t[0]);console.info(e.join(`
6
+ `))}else f(["status","--short"])}async function he(t){return L(t)?await E(`git stash show -p --include-untracked --name-only ${t}`):await E(`git show --name-only --pretty=format:"" ${t}`)}import{spawn as ye}from"node:child_process";async function Dt(){let t=y("Error: missing valid target ref argument");await v();let e=await nt(t);await f(["commit",`--fixup=${e}`]);let i=(await F(`${e}^`,"HEAD",!0)).map(r=>$e(r));(await Promise.all(i)).every(Boolean)||(console.warn("Rebase conflict would occur!"),await s("git reset HEAD~1 --soft"),process.exit(1)),await s(`git rebase -i --autosquash ${e}^`)}async function $e(t){let{stdout:e}=await s(`git diff ${t}^ ${t}`),{promise:o,resolve:i,reject:n}=Promise.withResolvers(),r=ye("git",["apply","--check","--3way","-q"],{stdio:["pipe","ignore","ignore"]});return r.on("close",a=>{i(a===0)}),r.on("error",n),r.stdin.write(e),r.stdin.end(),o}import{readFile as be,writeFile as Ce}from"node:fs/promises";async function Et(){let t=await k("info/exclude");await N(t);let e=await _(t),o=u();o.filter(a=>!e.includes(a)).forEach(a=>console.info(`No match: '${a}'`));let n=(await be(t,"utf-8")).split(/\r?\n/).map(a=>a.trim()),r=n.filter(a=>!o.includes(a));await Ce(t,r.join(`
7
+ `)),console.info(`
8
+ Removed ${n.length-r.length} entries from ${t}`)}import{render as xe}from"ink";import{jsx as ve}from"react/jsx-runtime";async function kt(){let t=(async()=>{let n=await Re();return await Pe(n)})();xe(ve(m,{msg:"Fetching repo languages",promise:t}));let e=await t,o=Object.values(e).reduce((n,r)=>n+r,0),i=Object.entries(e).map(([n,r])=>`${n}: ${Math.round(r/o*100)}% - ${Ae(r)}`);console.log(i.join(`
9
+ `))}async function Re(){let{stdout:t}=await s("gh repo view --json nameWithOwner -q .nameWithOwner");return t.trim()}async function Pe(t){let{stdout:e}=await s(`gh api repos/${t}/languages`);return JSON.parse(e.trim())}function Ae(t,e=2){if(t===0)return"0 B";let o=1024,i=e<0?0:e,n=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],r=Math.floor(Math.log(t)/Math.log(o));return`${parseFloat((t/Math.pow(o,r)).toFixed(i))} ${n[r]}`}import $ from"chalk";async function Bt(){y();let t=u(),[e,o]=t.filter(n=>n!=="-v"),i=[];if(L(e)?(i.push(...await H(`${e}^3`)),i.push(...await H(`${e}^2`))):i.push(...await H(e,o)),t.includes("-v")){let n={added:"A",modified:"M",deleted:"D",binary:"B"};i.forEach(r=>{let c=`${Se(r.changeType)(n[r.changeType])} ${r.file} |`;r.added&&(c+=$.green(` +${r.added}`)),r.deleted&&(c+=$.red(` -${r.deleted}`)),console.info(c)})}else{let n=new Set(i.map(({file:p})=>p)).size,[r,a]=i.reduce((p,{added:D,deleted:g})=>[p[0]+(D??0),p[1]+(g??0)],[0,0]),c=$.green(`+${r}`),l=$.red(`-${a}`);console.info(`${n} files: ${c} ${l}`)}}var Se=t=>{switch(t){case"modified":return $.yellow;case"added":return $.green;case"deleted":return $.red;default:return e=>e}};async function qt(){let t=await ot();console.log(t)}import{render as Wt}from"ink";function Tt(){return new Date().toLocaleString("en-US",{year:"2-digit",month:"2-digit",day:"2-digit",hour:"numeric",minute:"2-digit",hour12:!0}).replace(",","")}async function S(){let t=Tt();await s("git add -A"),await f(["commit","-m",`"WIP ${t}"`])}import{nanoid as De}from"nanoid";import Ee from"chalk";import{jsx as Gt}from"react/jsx-runtime";async function Mt(){let{remote:t,branch:e}=await T(),o=process.argv[3]??e;await x()||await S(),await it(o,"HEAD")||(console.warn("Conflicts would occur. Not safe to rebranch."),process.exit(1));let i=await w(),n=(async()=>{await q(t,o)})();Wt(Gt(m,{msg:`Updating branch ${o}`,promise:n})),await n;let r=`${De(8)}`,a=(async()=>{await s(`git switch ${i}`),await s(`git branch ${r}`),await s(`git switch ${o}`),await s(`git branch -D ${i}`),await s(`git switch -c ${i}`);let c=await F(o,r,!0);for(let l of c)try{await s(`git cherry-pick ${l}`)}catch{let p=Ee.yellow(`git branch -D ${i} && git branch -m ${r} ${i}`);throw new Error(`\u274C cherry pick failed at ${l}
10
+ Run this to restore backup branch
11
+ > ${p}`)}await s(`git branch -D ${r}`)})();Wt(Gt(m,{msg:`Rewriting branch ${i}`,promise:a})),await a,console.info(`Successfully recreated branch ${i} from ${o}`)}import{execSync as ke}from"node:child_process";async function Ft(){P();let t=Be(process.argv[3]),{default:e}=await import("clipboardy");await e.write(t),console.log(`'${t}' copied to clipboard`)}function Be(t="HEAD"){return ke(`git rev-parse --short ${t}`,{encoding:"utf-8"}).trim()}import{render as qe}from"ink";import{jsx as Te}from"react/jsx-runtime";async function Ht(){let{remote:t,branch:e}=await X();h(t);let{code:o}=await d("git",["show-ref","--branches",e]);o||(console.warn(`Branch '${e}' already exists.`),process.exit(1)),await A();let i=M(t,e);qe(Te(m,{msg:`Fetching branch ${e} from ${t}`,promise:i})),await i,await f(["switch","-c",e,"--track",`${t}/${e}`])}async function Z(){let{stdout:t}=await s("npm list -g bisgit --depth=0 --json");return JSON.parse(t.trim()).dependencies.bisgit.version}async function Lt(){console.info(await Z())}async function We(){let{code:t}=await d("npm",["outdated","-g","bisgit"]);return t===0}async function Ge(){let{stdout:t}=await s("npm view bisgit version",{encoding:"utf8"});return t.trim()}async function It(){if(await We())return console.info("Already up to date");console.info(`Updating: ${await Z()} -> ${await Ge()}`),b("npm",["i","-g","bisgit@latest"])}async function Nt(){let[t,e]=await Promise.allSettled([await Fe("user.name"),await Me()]);t.status==="fulfilled"&&console.info(`Git: ${t.value}`),e.status==="fulfilled"&&console.info(`Github: ${e.value}`)}async function Me(){let{stdout:t}=await s("gh api user --jq .login");return t.trim()}async function Fe(t){let{stdout:e}=await s(`git config ${t}`);return e.trim()}import{render as Oe}from"ink";import{Text as He,useApp as Le,useInput as Ie}from"ink";import{useState as Ne}from"react";import{Fragment as je,jsx as Ue,jsxs as Ut}from"react/jsx-runtime";function jt({prompt:t,msg:e,onConfirm:o,requireConfirmation:i}){let[n,r]=Ne(""),{exit:a}=Le();return Ie((c,l)=>{if(n)return;let p=c.toLowerCase();p==="y"||l.return&&!i?r("Yes"):(p==="n"||l.return&&i)&&(r("No"),a())}),Ut(je,{children:[Ut(He,{children:[t," [",i?"y/N":"Y/n","] ",n]}),n==="Yes"&&Ue(m,{msg:e,promise:o()})]})}import{jsx as _e}from"react/jsx-runtime";async function Ot(){if(at(),await x())return console.log("Already a clean working tree");let t=await I();if(!t)throw new Error("git status cmd failed");let e=new Q(t);e.displayReport(),Oe(_e(jt,{prompt:"Approve these changes?",msg:"Running git reset && git clean",onConfirm:async()=>(await s("git reset --hard"),await s("git clean -df"),`Altered ${e.willDelete.length+e.willRecreate.length+e.willRevert.length} files and folders.`)}))}var Q=class{willDelete=[];willRecreate=[];willRevert=[];constructor(e){e.forEach(o=>{if(o){o=o.trim();let i=o.indexOf(" ");if(i===-1)throw new Error("error parsing status porcelain");let n=o.slice(0,i).trim(),r=o.slice(i+1);n.includes("?")||n.includes("A")?this.willDelete.push(r):n==="DU"||n==="D"?this.willRecreate.push(r):this.willRevert.push(r)}}),this.willDelete.sort(),this.willRecreate.sort(),this.willRevert.sort()}displayReport(){this.displaySection("Will Recreate:",this.willRecreate),this.displaySection("Will Revert:",this.willRevert),this.displaySection("Will Delete:",this.willDelete)}displaySection(e,o){o.length&&console.log(`${e}
12
+ ${o.map(i=>`- ${i}`).join(`
13
+ `)}`)}};import{nanoid as Ve}from"nanoid";import{render as Ye}from"ink";import{jsx as ze}from"react/jsx-runtime";async function _t(){await U();let t=process.argv[3]??"origin";h(t);let e=await w();ct(e);let o="",n=(async()=>{let r=[s(`git fetch ${t} ${e} --force`)];await x()||r.push(S()),await Promise.all(r);let[a,c]=await Promise.all([W(t,e),G(t,e)]);if(!(a===0&&c===0)){if(a!==0){let l=`${e}-${Ve(8)}`;o=`Created branch ${l}`,await s(`git branch ${l}`)}await s(`git reset --hard ${t}/${e}`)}})();Ye(ze(m,{msg:`Force pull reseting ${e} -> ${t}`,promise:n})),await n,o&&console.info(o)}var Vt={abort:ft,amend:pt,autoprune:ht,backmerge:ut,churn:yt,coauthor:xt,"code-review":Rt,conflict:Pt,continue:At,exclude:vt,files:St,fixup:Dt,include:Et,languages:kt,lines:Bt,pwd:qt,rebranch:Mt,"remote-default":wt,savepoint:S,sha:Ft,track:Ht,update:It,"--version":Lt,whoami:Nt,wipe:Ot,yank:_t};async function wn(t){return await Vt[t]?.(),Object.hasOwn(Vt,t)}export{wn as runCommand};
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import{a as m}from"./chunk-NHXDQYDU.js";import{e as s}from"./chunk-54ESUAMF.js";import{d as e,t as c}from"./chunk-QMJXU6BD.js";import{b as n}from"./chunk-OSOEWQKA.js";import l from"chalk";async function a(){let o=await e();for(let[i,r]of o)console.info(`${l.yellow(i)} = ${r}`)}import{render as w}from"ink";import{jsx as h}from"react/jsx-runtime";async function f(){await s();let i=(await c()).map(t=>({value:t,label:t}));w(h(m,{prompt:"Which branch would you like to switch to?",items:i,onSelect:async({value:t})=>{await n(`git switch ${t}`)}}))}var p={switch:f,config:a};async function $(o){return await p[o]?.(),Object.hasOwn(p,o)}export{$ as runOverload};
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import{a as Ne,b as We,c as Ie,e as Oe,k as Ke,r as He,t as $e,u as Ge,v as Ve,w as J,z as _e}from"./chunk-QMJXU6BD.js";import{b as P,c as Fe}from"./chunk-OSOEWQKA.js";import{render as Hn}from"ink";import{createContext as ho,useContext as xo,useState as vo}from"react";import{jsx as yo}from"react/jsx-runtime";var Ue=ho(void 0),qe=({children:e})=>{let[t,r]=vo({}),o=(i,s)=>{r(a=>({...a,[i]:s}))},n=i=>{let s=Array.isArray(i)?i:[i];r(a=>{let c={...a};for(let l of s)delete c[l];return c})};return yo(Ue.Provider,{value:{keybindings:t,setKeybinding:o,removeKeybinding:n},children:e})},M=()=>{let e=xo(Ue);if(!e)throw new Error("useKeybindings must be used within a KeybindingsProvider");return e};import{useEffect as Wn}from"react";import{Text as In,Box as fo,useInput as On}from"ink";import{useStdout as So}from"ink";function d(){let{stdout:e}=So(),t=e.rows-2,r=Math.floor(t/2),o=e.columns>100?96:e.columns-4;return{width:e.columns,height:e.rows,sectionHeight:t,sectionHalfHeight:r,modalWidth:o}}import{Box as ze,Text as Mo}from"ink";import{useState as ce,createContext as bo,useContext as wo}from"react";import{jsx as To}from"react/jsx-runtime";var O={Files:"Files","File Meta":"Files",Staged:"Status",Changes:"Status",Unmerged:"Status",Status:"Status",Log:"Log","Commit Details":"Log",Branches:"Branches",Worktrees:"Branches",Remotes:"Branches",Stashes:"Stashes","Stash Details":"Stashes"},Y=Object.keys(O),Ye=bo({});function Qe({children:e}){let[t,r]=ce(!1),o=()=>r(!0),n=()=>r(!1),[i,s]=ce("Status"),[a,c]=ce("Staged"),l=f=>{t||(c(f),s(O[f]))},m=f=>{t||(s(f),c(f))},g=()=>{t||c(f=>{let b=Y.at((Y.indexOf(f)+1)%Y.length);return s(O[b]),b})},S=()=>{t||c(f=>{let b=Y.at(Y.indexOf(f)-1);return s(O[b]),b})};return To(Ye.Provider,{value:{activeGroup:i,setActiveGroup:m,activeSection:a,setActiveSection:l,prevSection:S,nextSection:g,isLocked:t,lock:o,unlock:n},children:e})}function y(){let e=wo(Ye);if(Object.keys(e).length===0)throw new Error("useNavContext must be used within a NavProvider");return e}import{memo as Po}from"react";import{jsx as le}from"react/jsx-runtime";var Co=Array.from(new Set(Object.values(O))),Je=Po(({activeGroup:e})=>le(ze,{width:"100%",flexDirection:"row",height:1,children:Co.map((t,r)=>le(ze,{borderStyle:"classic",borderLeft:!!r,borderRight:!1,borderTop:!1,borderBottom:!1,children:le(Mo,{color:t===e?"cyan":"",children:` [${r+1}]: ${t} `})},t))}),(e,t)=>e.activeGroup===t.activeGroup);import{Text as Rn,useInput as Ln}from"ink";import{Box as Uo,useInput as qo}from"ink";import{Box as ot,measureElement as Oo,Text as de}from"ink";import{Box as Xe,measureElement as Eo,Text as Ze}from"ink";import{useMemo as Do,useRef as Ao}from"react";import{Fragment as Bo,jsx as X,jsxs as ko}from"react/jsx-runtime";function w(e){let{title:t,footer:r,children:o,width:n,height:i,innerHeight:s,isModal:a,backgroundColor:c}=e,{width:l}=d(),m=n??l,g=Ao(null),S=Do(()=>{if(!g.current)return 0;let{width:u}=Eo(g.current);return u},[g.current]),f=S-8,b={...e,height:s,width:S},{activeSection:x}=y(),p=x===t||a?"cyan":"";return X(Xe,{ref:g,flexDirection:"column",height:i,width:m,backgroundColor:c,children:S!==0&&ko(Bo,{children:[t&&X(Ze,{color:p,wrap:"truncate-end",children:"\u256D\u2500\u2500\u2500\u2500 "+t+" "+"\u2500".repeat(f-t.length)+"\u256E"}),X(Xe,{flexDirection:"column",...b,borderStyle:"round",borderColor:p,borderTop:!t,borderBottom:!r,paddingLeft:1,children:o}),r&&X(Ze,{color:p,wrap:"truncate-end",children:"\u2570"+"\u2500".repeat(f-r.length)+" "+r+" \u2500\u2500\u2500\u2500\u256F"})]})})}import{createContext as Lo,useContext as Fo}from"react";import{useEffect as Ro,useState as ue}from"react";function T(e,t=[]){let[r,o]=ue(void 0),[n,i]=ue(!1),[s,a]=ue(0),c=()=>a(l=>l+1);return Ro(()=>{let l=!1;return i(!1),o(void 0),e().then(m=>{l||(o(m),i(!0))}).catch(()=>{l||i(!0)}),()=>{l=!0}},[s,...t]),{value:r,resolved:n,refresh:c}}import{jsx as No}from"react/jsx-runtime";var je=Lo({});function et({children:e}){let{value:t=[],refresh:r}=T(_e);return No(je.Provider,{value:{status:t,refresh:r},children:e})}function K(){let e=Fo(je);if(Object.keys(e).length===0)throw new Error("useStatus must be used within an StatusProvider");return e}function tt(e){let{activeSection:t}=y();return{calcSectionHeight:o=>e.includes(t)?t===o?Wo(e.length):Io(e.length):`${100/e.length}%`}}var Wo=e=>{switch(e){case 2:return"75%";case 3:case 4:return"50%";default:throw new Error(`Variable Section Height not configured for ${e}`)}},Io=e=>{switch(e){case 2:case 3:return"25%";case 4:return"16.5%";default:throw new Error(`Variable Section Height not configured for ${e}`)}};import{useEffect as Ko,useMemo as Ho,useRef as $o,useState as Go}from"react";import{jsx as B,jsxs as Vo}from"react/jsx-runtime";function rt(){let{status:e}=K(),{sectionHeight:t}=d(),{sections:r,showMerged:o}=Ho(()=>{let n=e.some(({changeType:s})=>s==="U"),i=["Staged","Changes"];return n&&i.push("Unmerged"),{sections:i,showMerged:n}},[e]);return Vo(ot,{width:"50%",height:t,flexDirection:"column",children:[B(me,{title:"Staged",sections:r,children:e?.map(({name:n})=>B(de,{wrap:"truncate-end",children:n},n))}),B(me,{title:"Changes",sections:r,children:e?.map(({name:n})=>B(de,{wrap:"truncate-end",children:n},n))}),o&&B(me,{title:"Unmerged",sections:r,children:e?.map(({name:n})=>B(de,{wrap:"truncate-end",children:n},n))})]})}function me({title:e,sections:t,children:r}){let o=$o(null),{activeSection:n}=y(),[i,s]=Go(0);Ko(()=>{if(o.current){let{height:c}=Oo(o.current);s(c-1)}},[o.current,n]);let{calcSectionHeight:a}=tt(t);return B(ot,{ref:o,height:a(e),children:B(w,{title:e,innerHeight:i,children:r})})}import{jsx as _o}from"react/jsx-runtime";function nt(){let{sectionHeight:e}=d();return _o(w,{title:"Status",width:"50%",innerHeight:e-1,children:null})}import{useEffect as it}from"react";import{jsx as st,jsxs as Yo}from"react/jsx-runtime";function at(){let{width:e,sectionHeight:t}=d(),{refresh:r}=K();it(()=>{r()},[]);let{setKeybinding:o,removeKeybinding:n}=M();return it(()=>(o("r","refresh"),()=>n("r")),[]),qo((i,s)=>{i==="r"&&r()}),Yo(Uo,{width:e,height:t,flexDirection:"row",children:[st(rt,{}),st(nt,{})]})}import{useEffect as Wt,useState as It}from"react";import{Box as Vr,useInput as _r}from"ink";import{Text as Qo}from"ink";import{jsx as ct}from"react/jsx-runtime";function lt({sha:e}){let{resolved:t,value:r}=T(()=>zo(e),[e]);return ct(w,{title:"Commit Details",width:"50%",height:"100%",children:e&&t&&ct(Qo,{children:r})})}async function zo(e){if(!e)return;let{stdout:t}=await P(`git show ${e} --name-only`);return t.trim()}import{useCallback as cr,useEffect as lr}from"react";import{Box as Z,Text as ge,useInput as ur}from"ink";import{useEffect as ut,useRef as Jo,useState as pe}from"react";function H(e,t){let[r,o]=pe(0),[n,i]=pe(0),s=Jo(void 0),[a,c]=pe(0),l=()=>c(p=>p+1);ut(()=>{let p=0;if(s.current!==void 0){let h=e.findIndex(v=>v===s.current);h>=0&&(p=h)}i(p);let u=Math.min(Math.max(p-Math.floor(t/2),0),Math.max(0,e.length-t));o(u)},[e,t,a]),ut(()=>{s.current=e[n]},[n,e]);let m=Math.max(0,e.length-t),g=e.length-1,S=()=>{i(p=>{let u=Math.min(p+1,g);return o(h=>u>=h+t?Math.min(h+1,m):h),u})},f=()=>{i(p=>{let u=Math.max(p-1,0);return o(h=>u<h?Math.max(h-1,0):h),u})},b=e.slice(r,r+t),x=e[n];return{scrollDown:S,scrollUp:f,outList:b,selectedIndex:n,renderedIndex:n-r,selectedValue:x,refresh:l}}import{useInput as Xo}from"ink";import{createContext as Zo,useContext as jo}from"react";import{useEffect as ft,useState as dt}from"react";import{jsx as er}from"react/jsx-runtime";var mt="\u2190",pt="\u2192",gt=Zo({});function ht({children:e}){let[t,r]=dt("truncate-end"),[o,n]=dt(0),{removeKeybinding:i,setKeybinding:s}=M();return ft(()=>(o&&(t==="truncate-start"?s(mt,"pan left"):s(pt,"pan right")),()=>{i([pt,mt])}),[t,o]),Xo((a,c)=>{o&&(c.rightArrow?r("truncate-start"):c.leftArrow&&r("truncate-end"))}),er(gt.Provider,{value:{mode:t,_isToggleable:o,_setIsToggleable:n},children:e})}function k(){let e=jo(gt);if(Object.keys(e).length===0)throw new Error("useTruncationMode must be used within an TruncationModeProvider");let{mode:t,_setIsToggleable:r}=e;return ft(()=>(r(o=>o+1),()=>r(o=>o-1)),[]),{mode:t}}import{createContext as tr,useContext as or,useEffect as xt,useMemo as rr,useRef as vt,useState as yt}from"react";import{useInput as nr}from"ink";import{jsx as ar}from"react/jsx-runtime";var St=tr({});function bt({children:e}){let{activeSection:t}=y(),{sectionHeight:r}=d(),o=r-3,{value:{tree:n,files:i}={},resolved:s}=T(ir),a=vt(new Set),c=vt(new Set(["."])),[l,m]=yt();xt(()=>{n&&i&&(a.current=new Set(Object.keys(n)),m(i[0]))},[s]);let g=rr(()=>i?.filter(x=>a.current.has(x))??[],[a.current.size,s]),[S,f]=yt(0),b=()=>f(x=>x+1);return nr((x,p)=>{if(t!=="Files"||!n||!l)return;if(p.upArrow){let h=Math.max(0,g.indexOf(l)-1);m(g[h]),b()}else if(p.downArrow){let h=Math.min(g.length-1,g.indexOf(l)+1);m(g[h]),b()}let u;if(p.leftArrow?u="collapse":p.rightArrow&&(u="expand"),u){let h=fe(n,l);if(!h)return;for(let v of Object.keys(h)){let E=`${l}/${v}`;u==="expand"?a.current.add(E):a.current.delete(E)}b()}}),xt(()=>{if(c.current.clear(),c.current.add("."),g.length<=o){g.forEach(q=>c.current.add(q));return}let x=l?sr(l):[],p=Math.max(1,o-x.length),u=g.filter(q=>!x.includes(q)),h=l?u.indexOf(l):0,v=Math.max(0,h-Math.floor(p/2)),E=v+p;E>u.length&&(E=u.length,v=Math.max(0,E-p));let z=u.slice(v,E);[...x,...z].forEach(q=>{c.current.add(q)})},[g.length,l,o]),ar(St.Provider,{value:{version:S,tree:n,visibleFiles:c.current,expandedFiles:a.current,selectedFile:l},children:e})}function A(){let e=or(St);if(Object.keys(e).length===0)throw new Error("useTreeNavigation must be used within an TreeNavigationProvider");return e}var fe=(e,t)=>{let r=t.split("/"),o=e;for(let n of r)o=o[n];return o},ir=async()=>{let e=await We(),t=Ie(e);return{tree:e,files:t}},sr=e=>{let t=e.split("/"),r=[];for(let o=1;o<t.length;o++)r.push(t.slice(0,o).join("/"));return r};import{jsx as N,jsxs as mr}from"react/jsx-runtime";function wt({setSha:e,mode:t}){let{label:r,value:o}=t,{sectionHeight:n}=d(),{activeSection:i,isLocked:s}=y(),{selectedFile:a}=A(),{mode:c}=k(),l=cr(()=>o.length&&a?o(a):o(),[o,a]),{resolved:m,value:g=[]}=T(l,[r]),{scrollUp:S,scrollDown:f,outList:b,selectedValue:x,renderedIndex:p}=H(g,n-2),u=x?.sha;lr(()=>{e(u)},[u]),ur((v,E)=>{i!=="Log"||s||(E.upArrow?S():E.downArrow&&f())});let h=dr.includes(t.label);return N(w,{overflowY:"hidden",height:"100%",title:"Log",width:"50%",children:m&&b.map(({sha:v,message:E},z)=>mr(Z,{flexDirection:"row",flexWrap:"nowrap",children:[N(Z,{minWidth:2,children:v===u?N(ge,{color:h&&z===p?"magenta":void 0,children:"> "}):null}),N(Z,{minWidth:8,children:N(ge,{color:"yellow",children:v})}),N(Z,{children:N(ge,{wrap:c,children:E})})]},`${v}-${t.label}${h?z:""}`))})}var dr=["blame","reflog"];import{useState as Dr}from"react";import{useInput as Ar}from"ink";import Br from"ink-text-input";import{useInput as pr}from"ink";import{createContext as fr,useContext as gr,useEffect as hr,useState as he}from"react";import{Fragment as xr,jsx as yr,jsxs as vr}from"react/jsx-runtime";var Tt=fr({});function C(){let e=gr(Tt);if(Object.keys(e).length===0)throw new Error("useKeybindings must be used within a KeybindingsProvider");return e}function Mt({children:e}){let[t,r]=he(null),{lock:o,unlock:n}=y(),[i,s]=he(!1),[a,c]=he(),l=()=>{n(),s(!1),a?.(),r(null)},m=()=>{o(),s(!0)},g=()=>{i?l():m()},S=(x,p)=>{l(),c(p?.onClose),r(x)};pr((x,p)=>{p.escape&&l()});let{setKeybinding:f,removeKeybinding:b}=M();return hr(()=>{if(i)return f("esc","close"),()=>{b("esc")}},[i]),yr(Tt.Provider,{value:{setModal:S,open:m,close:l,toggle:g,isOpen:i},children:vr(xr,{children:[e,t]})})}import{Box as At}from"ink";import xe from"node:path";import ve from"node:os";import Sr from"node:fs/promises";import{createContext as br,useContext as wr}from"react";import{jsx as Cr}from"react/jsx-runtime";var Pt=br({});function Ct({children:e,bgColor:t}){return Cr(Pt.Provider,{value:{bgColor:t},children:e})}var Et=()=>{let e=wr(Pt);if(Object.keys(e).length===0)throw new Error("useKeybindings must be used within a KeybindingsProvider");return e};async function Dt(){if(!process.stdin.isTTY||!process.stdout.isTTY)return;if(process.env.TERM_PROGRAM==="vscode")return await Pr();let e=Tr();return(!process.stdin.isRaw||process.stdin.isPaused())&&(console.error("Error querying the terminal background color"),process.exit(1)),e}async function Tr(){return new Promise(e=>{let t="\x1B]11;?\x07",r="",o,n=s=>{clearTimeout(o),process.stdin.off("data",i);try{process.stdin.setRawMode(!1)}catch{}e(s)},i=s=>{r+=s.toString("ascii");let a=r.match(/\x1b]11;rgb:([0-9a-fA-F]{1,4})\/([0-9a-fA-F]{1,4})\/([0-9a-fA-F]{1,4})\x07/);a&&n(Mr(a[1],a[2],a[3]))};try{process.stdin.setRawMode(!0),process.stdin.resume(),process.stdin.on("data",i),o=setTimeout(()=>n(void 0),150),process.stdout.write(t)}catch{n(void 0)}})}function Mr(e,t,r){return"#"+[e,t,r].map(o=>Math.round(parseInt(o,16)*255/((1<<4*o.length)-1)).toString(16).padStart(2,"0")).join("")}async function Pr(){let e="Code";process.env.TERM_PROGRAM_VERSION?.includes("insider")&&(e="Code - Insiders");let t;switch(process.platform){case"win32":t=xe.join(ve.homedir(),"AppData","Roaming",e,"User","settings.json");break;case"linux":t=xe.join(ve.homedir(),".config",e,"User","settings.json");break;case"darwin":t=xe.join(ve.homedir(),"Library","Application Support",e,"User","settings.json");break;default:return}if(!await Ne(t))return;let r=await Sr.readFile(t,{encoding:"utf-8"}),{default:o}=await import("strip-json-comments"),n=o(r).replace(/,\s*(\}|\])/g,"$1");switch(JSON.parse(n)["workbench.colorTheme"]){case"Default Dark Modern":case void 0:return"#181818";case"Visual Studio Dark":case"Default Dark+":return"#1e1e1e";case"Default High Contrast":return"#000000";case"Default Light+":case"Visual Studio Light":case"Default High Contrast Light":return"#ffffff";case"Default Light Modern":return"#f8f8f8";default:return}}import{jsx as ye}from"react/jsx-runtime";var Er=36;function $({children:e,title:t,width:r=Er}){let o=d(),{width:n}=o,i=Math.floor((n-r)/2),{bgColor:s}=Et();return ye(At,{...o,position:"absolute",children:ye(At,{alignSelf:"center",marginLeft:i,marginRight:i,children:ye(w,{title:t,width:r,isModal:!0,backgroundColor:s,children:e})})})}import{jsx as Bt}from"react/jsx-runtime";function j({title:e,handleSubmit:t}){let[r,o]=Dr(""),{isOpen:n,close:i}=C();return Ar((s,a)=>{a.return&&n&&(t(r),o(""),i())}),n&&Bt($,{title:e,children:Bt(Br,{value:r,onChange:o})})}import{useInput as kr}from"ink";import Rr from"ink-select-input";import{jsx as kt}from"react/jsx-runtime";function ee({title:e,handleSubmit:t,options:r,initialIndex:o,width:n}){let{isOpen:i,close:s}=C();return kr((a,c)=>{c.return&&i&&s()}),i&&kt($,{title:e,width:n,children:kt(Rr,{items:r,onSelect:t,initialIndex:o})})}var V=[{value:()=>G("git log --oneline -n 400"),label:"log"},{value:()=>G("git log --oneline --tags --no-walk --decorate"),label:"tags"},{value:()=>G("git reflog"),label:"reflog"},{value:()=>G('git log --oneline --author="$(git config user.name)"'),label:"my commits"},{value:e=>G(`git log --oneline "${e}"`),label:"file"},{value:e=>G(`git blame --follow "${e}"`),label:"blame"}];async function G(e){let{stdout:t}=await P(e);return t.trim().split(/\r?\n/).map(Lr)}function Lr(e){let t=e.indexOf(" ");return{sha:e.slice(0,t),message:e.slice(t+1)}}import{createContext as Fr,useContext as Nr,useEffect as Wr,useState as Ir}from"react";import{jsx as Or}from"react/jsx-runtime";var Rt=Fr({});function Lt({children:e}){let[t,r]=Ir(),o=(n,...i)=>{n(...i).catch(s=>r(s.stderr??s.message))};return Wr(()=>{if(t)throw new Error(t)},[t]),Or(Rt.Provider,{value:{attempt:o,err:t},children:e})}function _(){let e=Nr(Rt);if(Object.keys(e).length===0)throw new Error("useErrorCatcher must be used within an ErrorCatcherProvider");return e}import{createContext as Kr,useContext as Hr,useState as $r}from"react";import{jsx as Gr}from"react/jsx-runtime";var Ft=Kr({});function Nt({children:e}){let[t,r]=$r(),o=i=>r(i),n=i=>{let s=t===i;return s&&r(void 0),s};return Gr(Ft.Provider,{value:{sendMessage:o,receiveMessage:n},children:e})}function te(){let e=Hr(Ft);if(Object.keys(e).length===0)throw new Error("useMessaging must be used within an MessagingProvider");return e}import{jsx as Se,jsxs as Ur}from"react/jsx-runtime";function be(){let{setModal:e,toggle:t}=C(),[r,o]=It(),{width:n,sectionHeight:i}=d(),[s,a]=It(V[0]),{receiveMessage:c}=te();Wt(()=>{c("log-file")&&a(V[4]),c("blame-file")&&a(V[5])},[]);let{isLocked:l}=y(),{attempt:m}=_();_r((f,b)=>{f==="m"&&(e(Se(ee,{options:V,title:"Log Type",handleSubmit:x=>a(x),initialIndex:V.indexOf(s)})),t()),!l&&f==="c"&&r&&m(()=>P(`git checkout ${r}`))});let{setKeybinding:g,removeKeybinding:S}=M();return Wt(()=>(g("c","checkout"),g("m","mode"),()=>{S(["c","m"])}),[]),Ur(Vr,{width:n,height:i,children:[Se(wt,{setSha:o,mode:s}),Se(lt,{sha:r})]})}import{useEffect as en}from"react";import{Box as Vt}from"ink";import{Box as we,Text as Ot,useInput as qr}from"ink";import{useEffect as Yr}from"react";import{Fragment as zr,jsx as W,jsxs as Qr}from"react/jsx-runtime";function Kt(){let{activeSection:e,isLocked:t}=y(),{sectionHalfHeight:r}=d(),{value:o=[],refresh:n}=T($e),{value:i,refresh:s}=T(Oe),{setKeybinding:a,removeKeybinding:c}=M();Yr(()=>{if(e==="Branches")return a("s","switch"),()=>{c("s")}},[e]);let{outList:l,selectedValue:m,scrollUp:g,scrollDown:S}=H(o,r-2),f=async v=>{await P(`git branch ${v}`),n()},b=async()=>{await P(`git branch -D ${m}`),n()},x=async()=>{await P(`git switch ${m}`),n(),s()},{setModal:p,open:u}=C(),{attempt:h}=_();return qr((v,E)=>{e!=="Branches"||t||(E.upArrow?g():E.downArrow?S():v==="c"?(p(W(j,{title:"Name your new branch",handleSubmit:f})),u()):v==="d"?h(b):v==="s"&&h(x))}),W(zr,{children:W(w,{width:"100%",title:"Branches",innerHeight:r-1,children:l.map(v=>Qr(we,{flexDirection:"row",flexWrap:"nowrap",children:[W(we,{minWidth:2,children:v===m?W(Ot,{children:"> "}):null}),W(we,{children:W(Ot,{color:v===i?"magenta":void 0,children:v})})]},v))})})}import{Text as Te}from"ink";import{Fragment as Jr}from"react";import{jsx as Me,jsxs as Ht}from"react/jsx-runtime";function $t(){let{value:e}=T(Ge);return Me(w,{width:"50%",title:"Remotes",children:e?.map(({url:t,name:r,type:o})=>Ht(Jr,{children:[Ht(Te,{wrap:"truncate-end",children:[r," (",o,")"]}),Me(Te,{wrap:"truncate-end",children:t}),Me(Te,{children:" "})]},`${r}-${o}`))})}import{Text as Pe}from"ink";import{Fragment as Xr}from"react";import{jsx as oe,jsxs as jr}from"react/jsx-runtime";function Gt(){let{sectionHalfHeight:e}=d(),{value:t}=T(Zr);return oe(w,{width:"100%",title:"Worktrees",innerHeight:e-1,children:t?.map(({branch:r,detached:o,path:n,head:i})=>jr(Xr,{children:[oe(Pe,{children:o?i:r}),oe(Pe,{children:n}),oe(Pe,{children:" "})]},n))})}async function Zr(){let{stdout:e}=await P("git worktree list --porcelain"),t=e.trim().split(/\r?\n/),r=[],o=[];for(let n of t)n.trim()===""?o.length&&(r.push(o),o=[]):o.push(n);return o.length&&r.push(o),r.map(n=>{let i={detached:!1};for(let s of n)s.startsWith("worktree ")?i.path=s.slice(9):s.startsWith("HEAD ")?i.head=s.slice(5):s.startsWith("branch ")?i.branch=s.slice(7):s==="detached"&&(i.detached=!0);return i})}import{Fragment as tn,jsx as re,jsxs as _t}from"react/jsx-runtime";function Ut(){let{width:e,sectionHeight:t}=d(),{setKeybinding:r,removeKeybinding:o}=M();return en(()=>(r("c","create"),r("d","delete"),()=>{o(["c","d"])}),[]),re(tn,{children:_t(Vt,{width:e,height:t,children:[_t(Vt,{flexDirection:"column",width:"50%",height:t,children:[re(Kt,{}),re(Gt,{})]}),re($t,{})]})})}import{Component as on,useEffect as rn}from"react";import{Text as qt}from"ink";import{jsx as Ce}from"react/jsx-runtime";function ne({title:e,message:t,width:r}){let{isOpen:o}=C(),{mode:n}=k();return o&&Ce($,{title:e,width:r,children:Array.isArray(t)?t.map(i=>Ce(qt,{wrap:n,children:i})):Ce(qt,{children:t})})}import{jsx as Yt}from"react/jsx-runtime";var ie=class extends on{state={hasError:!1};constructor(t){super(t)}static getDerivedStateFromError(t){return{hasError:!0,message:t?.stderr??t?.message}}dismissError(){this.setState({hasError:!1})}componentDidCatch(t,r){let o=t?.stderr??t?.message;this.setState({hasError:!0,message:o})}render(){return this.state.hasError?Yt(nn,{dismissError:this.dismissError.bind(this),message:this.state.message,children:this.props.children}):this.props.children}};function nn({message:e,dismissError:t,children:r}){let{setModal:o,open:n}=C(),{modalWidth:i}=d();return rn(()=>{if(e){let s=e.split(/\r?\n/).map(a=>a.trim());o(Yt(ne,{title:"Error",message:s,width:i}),{onClose:t}),n()}},[e]),r}import{Box as xn,useInput as vn}from"ink";import{useEffect as yn}from"react";import{Box as Ee,Text as Xt}from"ink";import De from"node:path";import{memo as sn,useEffect as Qt,useState as an}from"react";import{Fragment as dn,jsx as R,jsxs as Ae}from"react/jsx-runtime";var cn="\u2190",ln="\u2191",Zt="\u2192",jt="\u2193",zt=`${cn}${ln}${jt}${Zt}`;function eo(){let{sectionHeight:e}=d(),{activeSection:t}=y(),{setKeybinding:r,removeKeybinding:o}=M();Qt(()=>{if(t==="Files")return r(zt,"NAVIGATION_KEY"),()=>o(zt)},[t]);let{tree:n,version:i}=A(),{value:s}=T(Ke),[,a]=an(0);return Qt(()=>{a(c=>c+1)},[i]),R(w,{title:"Files",innerHeight:e,width:"50%",children:s&&n&&R(to,{name:De.basename(s),contents:n,depth:0,fp:s})})}function to(e){let{contents:t,depth:r,fp:o,rp:n="."}=e,i=Object.keys(t).length===0,{selectedFile:s,visibleFiles:a,expandedFiles:c}=A(),l=n===s;if(!a.has(n))return null;let m=r+2;if(i)return R(Jt,{...e,depth:m,isSelected:l},o);let g=`${n}/`,S=un(c,f=>f.startsWith(g))||r===0;return Ae(dn,{children:[Ae(Ee,{flexDirection:"row",flexWrap:"nowrap",children:[R(Ee,{width:2,children:R(Xt,{children:S?jt:Zt})}),R(Ee,{width:"100%",children:R(Jt,{...e,isSelected:l})})]}),S&&Object.entries(t).map(([f,b])=>{let x=De.join(n,f),p=De.join(o,f);return R(to,{name:f,contents:b,depth:m,rp:x,fp:p})})]})}var Jt=sn(({name:e,depth:t,isSelected:r})=>Ae(Xt,{wrap:"truncate-end",color:r?"yellow":void 0,children:["\xA0".repeat(t),e]}),(e,t)=>e.isSelected===t.isSelected&&e.fp===t.fp);function un(e,t){for(let r of e)if(t(r))return!0;return!1}import{Box as ro,Text as I}from"ink";import{Box as mn,measureElement as pn,Text as oo}from"ink";import{useMemo as fn,useRef as gn}from"react";import{jsx as Be}from"react/jsx-runtime";function se({text:e}){let t=gn(null),r=fn(()=>{if(!t.current)return 0;let{width:a}=pn(t.current);return a-4},[t.current]),o=Math.max(0,r-e.length),n=Math.floor(o/2),i=o-n,s=`${"=".repeat(n)} ${e} ${"=".repeat(i)}`;return Be(mn,{width:"100%",ref:t,children:e.length>r?Be(oo,{children:e}):Be(oo,{children:s})})}import{jsx as ke,jsxs as L}from"react/jsx-runtime";function no(){let{sectionHeight:e}=d(),{selectedFile:t}=A(),{value:r={}}=T(()=>Ve(t),[t]),{authorDate:o,authorEmail:n,authorName:i,shortHash:s}=r,{value:{added:a,deleted:c}={},resolved:l}=T(async()=>hn(s,t),[s,t]),{mode:m}=k();return ke(ro,{width:"50%",height:e,children:L(w,{width:"100%",title:"File Meta",innerHeight:e-1,children:[t&&ke(se,{text:t}),s&&L(I,{wrap:m,children:["Last Commit: ",s]}),i&&L(I,{wrap:m,children:["Edited By: ",i]}),o&&L(I,{wrap:m,children:["Edit On: ",o]}),n&&L(I,{wrap:m,children:["Contact: ",n]}),l&&(a||c)&&L(ro,{flexDirection:"row",flexWrap:"nowrap",children:[ke(I,{children:"Changes:\xA0"}),L(I,{color:"green",children:["+",a??0,"\xA0"]}),L(I,{color:"red",children:["-",c??0]})]})]})})}var hn=async(e,t)=>!e||!t?{}:(await J(e)).find(({file:o})=>t===o)??{};import{jsx as Re,jsxs as Sn}from"react/jsx-runtime";function io(){let{width:e,sectionHeight:t}=d(),{selectedFile:r,tree:o}=A(),{setKeybinding:n,removeKeybinding:i}=M();yn(()=>(n("l","log"),n("b","blame"),()=>{i(["l","b"])}),[]);let{setActiveGroup:s}=y(),{sendMessage:a}=te(),{setModal:c,open:l}=C();return vn((m,g)=>{m==="l"?(a("log-file"),s("Log")):m==="b"&&(Object.keys(fe(o??{},r)).length===0?(a("blame-file"),s("Log")):(c(Re(ne,{title:"Sorry",message:["Can't blame a folder."]})),l()))}),Sn(xn,{width:e,height:t,children:[Re(eo,{}),Re(no,{})]})}import{Box as Dn}from"ink";import{Box as so,Text as ao,useInput as bn}from"ink";import{useEffect as wn}from"react";import{jsx as U,jsxs as Mn}from"react/jsx-runtime";function co({setStash:e}){let{sectionHeight:t}=d(),{mode:r}=k(),{attempt:o}=_(),{setModal:n,open:i}=C(),{activeSection:s,isLocked:a}=y(),{value:c=[],refresh:l}=T(Tn),{outList:m,selectedValue:g,selectedIndex:S,scrollUp:f,scrollDown:b}=H(c,t-2);wn(()=>{e(`stash@{${S}}`)},[S]);let x=u=>async()=>{await P(`git stash ${u} stash@{${S}}`),l()},p=async()=>{let u=`stash@{${S}}`,h=await He(u);n(U(j,{title:`reword ${u}`,handleSubmit:async v=>{await P(`git stash drop ${u}`),await P(`git stash store ${h} -m "${v}"`),l()}})),i()};return bn((u,h)=>{a||(u==="s"?(n(U(ee,{title:"Stash",options:[{value:"git stash",label:"tracked only"},{value:"git stash -u",label:"tracked & untracked"}],handleSubmit:({value:v})=>o(async()=>{await P(v),l()})})),i()):u==="a"?o(x("apply")):u==="p"?o(x("pop")):u==="d"?o(x("drop")):u==="r"&&o(p),s==="Stashes"&&(h.upArrow?f():h.downArrow&&b()))}),U(w,{title:"Stashes",width:"50%",height:"100%",children:m.map(u=>Mn(so,{flexDirection:"row",flexWrap:"nowrap",children:[U(so,{minWidth:2,children:u===g?U(ao,{children:"> "}):null}),U(ao,{wrap:r,children:u})]},u))})}async function Tn(){return await Fe("git stash list")}import{Box as Pn,Text as Le}from"ink";import{jsx as En,jsxs as Q}from"react/jsx-runtime";function lo({stash:e}){let{value:t=[]}=T(()=>Cn(e),[e]);return Q(w,{title:"Stash Details",width:"50%",height:"100%",children:[e&&En(se,{text:e}),t.map(({file:r,added:o,deleted:n,changeType:i})=>i!=="binary"&&Q(Pn,{flexDirection:"row",flexWrap:"nowrap",children:[Q(Le,{children:[r,":\xA0"]}),Q(Le,{color:"green",children:["+",o??0,"\xA0"]}),Q(Le,{color:"red",children:["-",n??0]})]}))]})}async function Cn(e){if(e)return await J(e)}import{useEffect as An,useState as Bn}from"react";import{jsx as uo,jsxs as kn}from"react/jsx-runtime";function mo(){let{sectionHeight:e,width:t}=d(),[r,o]=Bn(),{setKeybinding:n,removeKeybinding:i}=M();return An(()=>(n("s","stash"),n("d","drop"),n("a","apply"),n("p","pop"),n("r","reword"),()=>i(["s","p","d","a","r"])),[]),kn(Dn,{width:t,height:e,children:[uo(co,{setStash:o}),uo(lo,{stash:r})]})}import{jsx as D,jsxs as Nn}from"react/jsx-runtime";function po(){let{prevSection:e,nextSection:t,activeGroup:r,setActiveGroup:o,setActiveSection:n,activeSection:i}=y(),{status:s}=K(),a=s.some(({changeType:c})=>c==="U");return Ln((c,l)=>{l.tab&&l.shift?i==="Status"&&!a?n("Changes"):e():l.tab?i==="Changes"&&!a?n("Status"):t():c==="1"?o("Files"):c==="2"?o("Status"):c==="3"?o("Log"):c==="4"?o("Branches"):c==="5"&&o("Stashes")}),D(ie,{children:D(Lt,{children:D(Nt,{children:D(bt,{children:D(Fn,{group:r})})})})})}function Fn({group:e}){switch(e){case"Files":return D(io,{});case"Status":return D(at,{});case"Log":return D(be,{});case"Branches":return D(Ut,{});case"Stashes":return D(mo,{});default:return Nn(Rn,{children:['Error, unknown page "',e,'"']})}}import{jsx as ae,jsxs as Kn}from"react/jsx-runtime";function go(){let{isLocked:e,activeGroup:t}=y();On((i,s)=>{e||i.toLowerCase()==="q"&&process.exit()});let r=d(),{keybindings:o,setKeybinding:n}=M();return Wn(()=>n("q","quit"),[]),Kn(fo,{flexDirection:"column",...r,children:[ae(Je,{activeGroup:t}),ae(po,{}),ae(fo,{flexDirection:"row",children:Object.entries(o).map(([i,s])=>ae(In,{children:`[${i}]: ${s} `},s))})]})}import{jsx as F}from"react/jsx-runtime";function $n(){return F(Qe,{children:F(qe,{children:F(ht,{children:F(Mt,{children:F(et,{children:F(go,{})})})})})})}var mu=async()=>{let e=await Dt();Hn(F(Ct,{bgColor:e,children:F($n,{})}),{patchConsole:!0})};export{mu as renderApp};
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import{a as r}from"./chunk-R7DNYVL6.js";var i=["init","clone","add","status","diff","commit","restore","reset","branch","checkout","switch","merge","log","stash","tag","worktree","fetch","pull","push","remote","submodule","show","apply","cherry-pick","rebase","revert","bisect","blame","grep","clean","fsck","reflog","bundle","daemon","cat-file","check-ignore","checkout-index","commit-tree","count-objects","diff-index","for-each-ref","hash-object","ls-files","ls-tree","merge-base","read-tree","rev-list","rev-parse","show-ref","symbolic-ref","update-index","update-ref","verify-pack","write-tree","column"];function t(e){return i.includes(e)}var n=["auth","browse","codespace","gist","issue","org","pr","project","release","repo","cache","run","workflow","agent-task","alias","api","attestation","completion","config","extension","gpg-key","label","preview","ruleset","search","secret","ssh-key","status","variable"];function s(e){return n.includes(e)}var o=e=>{r(e,process.argv.slice(2),{stdio:"inherit",silent:!0})};async function f(e){return t(e)?(o("git"),!0):s(e)?(o("gh"),!0):!1}export{f as runWrapper};
2
+ import{a as r}from"./chunk-OSOEWQKA.js";var i=["init","clone","add","status","diff","commit","restore","reset","branch","checkout","switch","merge","log","stash","tag","worktree","fetch","pull","push","remote","submodule","show","apply","cherry-pick","rebase","revert","bisect","blame","grep","clean","fsck","reflog","bundle","daemon","cat-file","check-ignore","checkout-index","commit-tree","count-objects","diff-index","for-each-ref","hash-object","ls-files","ls-tree","merge-base","read-tree","rev-list","rev-parse","show-ref","symbolic-ref","update-index","update-ref","verify-pack","write-tree","column"];function t(e){return i.includes(e)}var n=["auth","browse","codespace","gist","issue","org","pr","project","release","repo","cache","run","workflow","agent-task","alias","api","attestation","completion","config","extension","gpg-key","label","preview","ruleset","search","secret","ssh-key","status","variable"];function s(e){return n.includes(e)}var o=e=>{r(e,process.argv.slice(2),{stdio:"inherit",silent:!0})};async function f(e){return t(e)?(o("git"),!0):s(e)?(o("gh"),!0):!1}export{f as runWrapper};
package/dist/main.js CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env node
2
- import{a as o,d as t}from"./chunks/chunk-HKY7QTE6.js";import"./chunks/chunk-7XT4D6II.js";import"./chunks/chunk-R7DNYVL6.js";async function a(){let r=o();if(!r){t();let{renderApp:i}=await import("./chunks/pages-YLGVYIE5.js");return i()}let{runCommand:n}=await import("./chunks/commands-YU4ZLADN.js");if(await n(r))return;let{runWrapper:e}=await import("./chunks/wrapper-PHXQ7CVF.js");await e(r)||(console.error("unknown command"),process.exit(1))}a().catch(r=>{console.error(`An error occurred: ${r.stderr??r.message}`),process.exit(1)});
2
+ import{a as o,b as n}from"./chunks/chunk-5WTQIRZS.js";import{a as e}from"./chunks/chunk-54ESUAMF.js";import"./chunks/chunk-QMJXU6BD.js";import"./chunks/chunk-OSOEWQKA.js";async function c(){let r=o();if(!r){e();let{renderApp:t}=await import("./chunks/pages-4AL5BU4I.js");return t()}if(n().length===0){let{runOverload:t}=await import("./chunks/overloads-2R6UG34D.js");if(await t(r))return}let{runCommand:i}=await import("./chunks/commands-4WDZKEWQ.js");if(await i(r))return;let{runWrapper:a}=await import("./chunks/wrapper-3UWAD2Z4.js");await a(r)||(console.error("unknown command"),process.exit(1))}c().catch(r=>{console.error(`An error occurred: ${r.stderr??r.message}`),process.exit(1)});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bisgit",
3
- "version": "0.8.1",
3
+ "version": "0.9.1",
4
4
  "description": "Git CLI tool to simplify common advanced git workflows",
5
5
  "main": "dist/main.js",
6
6
  "bin": {
@@ -41,25 +41,25 @@
41
41
  "prepare": "husky"
42
42
  },
43
43
  "devDependencies": {
44
- "@types/node": "^25.1.0",
45
- "@types/react": "^19.2.10",
46
- "@typescript-eslint/eslint-plugin": "^8.54.0",
47
- "@typescript-eslint/parser": "^8.54.0",
48
- "esbuild": "^0.27.2",
44
+ "@types/node": "^24.11.0",
45
+ "@types/react": "^19.2.14",
46
+ "@typescript-eslint/eslint-plugin": "^8.56.1",
47
+ "@typescript-eslint/parser": "^8.56.1",
48
+ "esbuild": "^0.27.3",
49
49
  "esbuild-lazy-analyzer": "^1.4.0",
50
50
  "esbuild-visualizer": "^0.7.0",
51
- "eslint": "^9.39.2",
51
+ "eslint": "^9.39.3",
52
52
  "eslint-plugin-import": "^2.32.0",
53
53
  "husky": "^9.1.7",
54
- "lint-staged": "^16.2.7",
54
+ "lint-staged": "^16.3.2",
55
55
  "npm-run-all": "^4.1.5",
56
56
  "prettier": "^3.8.1",
57
- "react-devtools-core": "^6.1.5"
57
+ "react-devtools-core": "^7.0.1"
58
58
  },
59
59
  "dependencies": {
60
60
  "chalk": "^5.6.2",
61
- "clipboardy": "^5.1.0",
62
- "ink": "^6.6.0",
61
+ "clipboardy": "^5.3.1",
62
+ "ink": "^6.8.0",
63
63
  "ink-select-input": "^6.2.0",
64
64
  "ink-spinner": "^5.0.0",
65
65
  "ink-text-input": "^6.0.0",
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- import{b as n,c,d as m}from"./chunk-R7DNYVL6.js";import h from"fs/promises";async function T(t){try{return await h.access(t),!0}catch{return!1}}async function p(){return await c("git ls-files")}async function y(){return await c("git ls-files --others --exclude-standard")}async function v(){let[t,e]=await Promise.all([p(),y()]),r=[...t,...e].sort(([s],[o])=>s.localeCompare(o)),i={};for(let s of r){let o=s.split("/"),a=i;for(let u of o)a[u]||(a[u]={}),a=a[u]}return i}function w(t,e=""){let r=[];for(let[i,s]of Object.entries(t)){let o=e?`${e}/${i}`:i;r.push(o),Object.keys(s).length>0&&r.push(...w(s,o))}return r}import{normalize as f}from"node:path";async function x(){let{stdout:t}=await n("git branch --show-current");return t.trim()}async function C(t){t??=await x();let{stdout:e}=await n(`git config --get branch.${t}.remote`);return e.trim()}async function N(t,e){try{let{stdout:r}=await n(`git rev-list --count ${t}/${e}..${e}`);return parseInt(r.trim(),10)}catch(r){return console.error("Error getting commits ahead:",r),NaN}}async function E(t,e){try{let{stdout:r}=await n(`git rev-list --count ${e}..${t}/${e}`);return parseInt(r.trim(),10)}catch(r){return console.error("Error getting commits behind:",r),NaN}}async function F(t){let{stdout:e}=await n(`git rev-parse --git-path ${t}`);return f(e.trim())}async function S(){let{stdout:t}=await n("git rev-parse --git-dir");return f(t.trim())}async function k(){let{stdout:t}=await n("git rev-parse --show-toplevel");return f(t.trim())}async function G(t){let{code:e}=await m("git",["remote","get-url",t],{stdio:"ignore"});return e===0}async function I(){let{stdout:t}=await n("git rev-parse --abbrev-ref HEAD");return t.trim()==="HEAD"}async function M(t,e){let r="git fetch";t&&(r+=` ${t}`),e&&(r+=` ${e}`),await n(r)}async function z(){let{stdout:t}=await m("git",["status","--porcelain"]);return!t?.trim()}async function A(){return await c("git status --porcelain")}async function $(t,e){let{stdout:r}=await n(`git merge-base ${t} ${e}`);return r.trim()}async function H(t,e){let r=await $(t,e),{stdout:i}=await m("git",["merge-tree",r,e,t]);return!i?.split(/\r?\n/)?.includes("+=======")}async function O(t){let{stdout:e}=await n(`git rev-parse ${t}`);return e.trim()}async function j(t,e,r){return await c(`git rev-list ${r?"--reverse":""} ${t}..${e}`)}async function V(){return await c("git for-each-ref --format='%(refname:short)' refs/heads")}async function q(){let{stdout:t}=await n("git remote -v");return t.trim().split(/\r?\n/).map(r=>{let i=r.match(/^(\S+)\s+(\S+)\s+\((fetch|push)\)$/);if(!i)return null;let[,s,o,a]=i;return{name:s,url:o,type:a}}).filter(r=>r!==null)}async function J(t){try{let{stdout:e}=await n(`git log -1 --format='%an|%ae|%ad|%h' -- "${t}"`,{encoding:"utf8"}),[r,i,s,o]=e.trim().split("|");return{authorName:r,authorEmail:i,authorDate:s,shortHash:o}}catch{return{}}}async function K(t,e){let r=e?`git diff --numstat ${t} ${e}`:b(t)?`git stash show --numstat --format="" --include-untracked ${t}`:`git show --numstat --format="" ${t}`;return(await c(r)).map(s=>{let[o,a,u]=s.split(" ");if(o==="-"&&a==="-")return{file:u,added:null,deleted:null,changeType:"binary"};let g=Number(o),l=Number(a),d="modified";return g>0&&l===0?d="added":g===0&&l>0&&(d="deleted"),{file:u,added:g,deleted:l,changeType:d}})}function b(t){return/^stash@\{\d+\}$/.test(t)}export{T as a,v as b,w as c,x as d,C as e,N as f,E as g,F as h,S as i,k as j,G as k,I as l,M as m,z as n,A as o,$ as p,H as q,O as r,j as s,V as t,q as u,J as v,K as w,b as x};
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- import{a as s,l as i,n}from"./chunk-7XT4D6II.js";function u(){return process.argv[2]}function g(){return process.argv.slice(3)}async function p(){let[r,t]=g();return r||(console.error("Requires <branch> or <remote> <branch>"),process.exit(1)),t?{remote:r,branch:t}:{remote:"origin",branch:r}}import{spawnSync as a}from"node:child_process";function e(r,t,o){let{status:c}=a(r,t,{stdio:"ignore"});c!==0&&(o&&console.error(o),process.exit(1))}var h=()=>e("git",["rev-parse","--git-dir"],"Need to use command in a git repository."),x=()=>e("git",["rev-parse","HEAD"],"Need to create first commit."),q=(r="origin")=>e("git",["remote","get-url",r],`Need to add remote '${r}'.`),v=r=>e("git",["show-ref","--branches",r],`Branch '${r}' isn't tracked locally and may not exist.`),y=async()=>{await n()||(console.error("You should stash or commit your changes first."),process.exit(1))},b=async r=>{await s(r)||(console.error(`${r} must exist for this operation and it doesn't for some reason`),process.exit(1))},w=async()=>{await i()&&(console.error("Operation not allowed in a 'detached HEAD' state"),process.exit(1))},A=r=>e("git",["rev-parse","--abbrev-ref","--symbolic-full-name",`${r}@{u}`],`branch '${r}' has no upstream`);function C(r="Error: missing required argument"){if(process.argv[3])return process.argv[3];console.error(r),process.exit(1)}async function $(){let{status:r}=a("git",["diff","--staged","--quiet"],{stdio:"ignore"});r===0&&(console.error("You have no staged changes"),process.exit(1))}export{u as a,g as b,p as c,h as d,x as e,q as f,v as g,y as h,b as i,w as j,A as k,C as l,$ as m};
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- import{exec as d,spawn as p}from"node:child_process";import{promisify as u}from"node:util";function w(n,s,t){let e=p(n,s,t??{});t?.silent||(e.stdout?.on("data",o=>{console.log(String(o))}),e.stderr?.on("data",o=>{console.error(String(o))})),e.on("close",o=>{t?.triggerExit&&process.exit(o)})}var g=u(d);async function x(n){let{stdout:s}=await g(n),t=s.trim();return t?t.split(/\r?\n/):[]}async function y(n,s,t={}){let{promise:e,resolve:o,reject:c}=Promise.withResolvers(),r=p(n,s,t),l="",a="";return r.stdout?.on("data",i=>l+=i),r.stderr?.on("data",i=>a+=i),r.on("close",i=>o({code:i,stdout:l,stderr:a})),r.on("error",i=>c(i)),e}async function h(n,s="inherit"){let{promise:t,resolve:e,reject:o}=Promise.withResolvers(),c=p("git",["-c","color.ui=always",...n],{stdio:s});return c.on("close",r=>{r===0?e({code:r}):o({code:r})}),c.on("error",o),t}export{w as a,g as b,x as c,y as d,h as e};
@@ -1,13 +0,0 @@
1
- #!/usr/bin/env node
2
- import{b as u,c as X,d as at,e as R,f as h,g as V,h as A,i as N,j as U,k as ct,l as y,m as S}from"./chunk-HKY7QTE6.js";import{a as x,d as w,e as tt,f as W,g as I,h as k,i as et,j as ot,k as rt,m as G,n as C,o as M,p as P,q as it,r as nt,s as F,t as st,w as H,x as L}from"./chunk-7XT4D6II.js";import{a as b,b as s,c as E,d,e as f}from"./chunk-R7DNYVL6.js";import B from"node:path";async function mt(){let t=await M(),e=/^(UU|DU|UD)/;return!!t?.some(o=>e.test(o))}async function O(){let t=await et(),[e,o,n,r,i]=await Promise.all([await x(B.join(t,"MERGE_HEAD")),await x(B.join(t,"rebase-merge")),await x(B.join(t,"rebase-apply")),await x(B.join(t,"CHERRY_PICK_HEAD")),await x(B.join(t,"REVERT_HEAD"))]);return{merge:e,rebaseMerge:o,rebaseApply:n,cherryPick:r,revert:i}}async function lt(){let{merge:t,rebaseMerge:e,rebaseApply:o,cherryPick:n,revert:r}=await O(),i="";if(t)i="merge";else if(e||o)i="rebase";else if(n)i="cherry-pick";else if(r)i="revert";else{let a=await mt()?"Conflicts exist, but likely are from a stash and are not abortable. Resolve them manually.":"Nothing to abort.";console.log(a);return}console.log(`Aborting the ${i}`),await f([i,"--abort"])}async function ft(){await U(),await S(),b("git",["commit","--amend","--no-edit",...u()],{stdio:"inherit",silent:!0,triggerExit:!0})}import{render as re}from"ink";import{render as ee}from"ink";import{Suspense as zt,use as Jt,useEffect as Kt}from"react";import{Text as pt,useApp as Zt}from"ink";import Qt from"ink-spinner";import{jsx as j,jsxs as te}from"react/jsx-runtime";function m(t){let{msg:e}=t;return j(zt,{fallback:te(pt,{children:[j(Qt,{type:"dots"}),"\xA0",e]}),children:j(Xt,{...t})})}function Xt({msg:t,promise:e}){let o=Jt(e),{exit:n}=Zt();return Kt(()=>{n()},[o]),j(pt,{children:`\u2714 ${typeof o=="string"?o:t}`})}import{jsx as oe}from"react/jsx-runtime";async function gt(){let t=process.argv[3],e=process.argv[4]??await w();if(V(t),V(e),t===e)return console.log(`No reason to merge '${t}' into '${e}'`);let o=await tt(t);h(o),ee(oe(m,{msg:"Updating target branch and merging",promise:(async()=>{try{await T(o,t)}catch{console.error(`Error when updating branch ${t} with remote ${o}. Fix divergent branches before merging into ${e}`);return}await w()!==e&&await s(`git switch ${e}`),b("git",["merge",t],{stdio:"inherit",silent:!0})})()}))}async function T(t,e){await G(t,e);let[o,n,r]=await Promise.all([W(t,e),I(t,e),w()]);if(n!==0){if(o===0&&r!==e){await s(`git fetch ${t} ${e}:${e}`);return}if(await s(`git switch ${e}`),o===0){await s(`git merge ${t}/${e}`);return}await f(["merge",`${t}/${e}`],["ignore","ignore","inherit"])}}async function q(){R(),h();let{stdout:t,code:e}=await d("git",["rev-parse","--abbrev-ref","origin/HEAD"]);if(e===0)return ut(t.trim());await s("git remote set-head origin -a");let{stdout:o}=await s("git rev-parse --abbrev-ref origin/HEAD");return ut(o.trim())}async function dt(){let{remote:t,branch:e}=await q();console.log(`Remote default branch is '${t}/${e}'`)}async function ut(t){let e=t.split("/"),o=t.split("/").map((n,r)=>e.slice(0,r+1).join("/"));for(let n of o)if(await rt(n)){let r=t.slice(n.length+1);return{remote:n,branch:r}}throw new Error("Failed to get default remote")}import{jsx as ne}from"react/jsx-runtime";var ie=["master","main","development","lingoport"];async function wt(){await A();let{branch:t,remote:e}=await q();await s(`git switch ${t}`);let o=(async()=>{await f(["fetch","--prune","--prune-tags"]),await T(e,t)})();re(ne(m,{msg:"Fetching and pruning remote references",promise:o})),await o;let n=await st();for(let r of n){if(r===t||ie.includes(r))continue;let{code:i}=await d("git",["diff","--quiet",t,r]);if(i===0){Y(r);continue}let{code:a}=await d("git",["merge-base","--is-ancestor",r,t]);if(a===0){Y(r);continue}let c=await P(r,t),{stdout:l}=await d("git",["merge-tree",c,t,r]);l?.trim()||Y(r)}}function Y(t){f(["branch","-D",t])}import{spawn as se}from"node:child_process";import{createInterface as ae}from"node:readline/promises";async function ht(){R;let e=[...(await ce()).entries()].sort(([,n],[,r])=>r-n).slice(0,25),o=e[0][1].toString().length;console.info(e.map(([n,r])=>`${String(r).padEnd(o)} ${n}:`).join(`
3
- `))}async function ce(){let{promise:t,resolve:e,reject:o}=Promise.withResolvers(),n=new Map,r=se("git",["log","--all","-M","-C","--name-only","--format=format:"]),i=ae({input:r.stdout,crlfDelay:1/0});return i.on("line",a=>{let c=a.trim();c&&n.set(c,(n.get(c)??0)+1)}),i.on("close",()=>e(n)),r.on("error",o),t}import{render as bt}from"ink";import{Box as me,Text as le,useApp as fe,useInput as pe}from"ink";import ge from"ink-select-input";import{jsx as yt,jsxs as ue}from"react/jsx-runtime";function $t({prompt:t,onSelect:e,items:o}){let{exit:n}=fe();return pe((r,i)=>{i.escape&&n()}),ue(me,{flexDirection:"column",children:[yt(le,{children:t}),yt(ge,{items:o,onSelect:e})]})}import{jsx as Ct}from"react/jsx-runtime";async function Pt(){await S();let t=u()[0];if(!t){let i=(await we()).map(c=>({value:c,label:`${c.name} ${c.email} (${c.commits})`}));bt(Ct($t,{items:i,prompt:"Who assisted in this commit?",onSelect:({value:{name:c,email:l}})=>{xt(c,l.slice(1,-1))}}));return}let e=(async()=>{let r=await de(t);return r.email||(console.error(`Couldn't find an email for ${t}`),process.exit(1)),r})();bt(Ct(m,{msg:"Fetching name and email",promise:e}));let{name:o,email:n}=await e;xt(o,n)}async function de(t){let{stdout:e}=await s(`gh api users/${t}`);return JSON.parse(e.trim())}async function we(){let t=await E('git log --format="%an|<%ae>"'),e=new Map;for(let o of t){let[n,r]=o.split("|"),i=`${n}|${r}`;e.has(i)||e.set(i,{name:n,email:r,commits:0}),e.get(i).commits+=1}return[...e.values()].toSorted((o,n)=>n.commits-o.commits)}async function xt(t,e){f(["commit","--edit","-m","<insert summary>","-m",`Co-authored-by: ${t} <${e}>`])}import{render as z}from"ink";import{isDeepStrictEqual as he}from"node:util";import{jsx as J}from"react/jsx-runtime";async function Rt(){let t=y("Error: missing id of PR to checkout");await A();let e=(async()=>Promise.all([s(`gh co ${t}`),s(`gh pr view ${t} --json baseRefName -q .baseRefName`)]))();z(J(m,{msg:`Checking out pr #${t}`,promise:e}));let[,{stdout:o}]=await e,n=o.trim(),r=(async()=>{await s(`git switch ${n}`),await s("git pull"),await s("git switch -")})();z(J(m,{msg:`Updating ${n} branch merge destination`,promise:r})),await r;let i=(async()=>{let g=await P(n,"HEAD");return await s(`git reset ${g} --soft`),await ye("HEAD")})();z(J(m,{msg:"Creating an editable, explorable, local PR experience",promise:i}));let[a,c]=await Promise.all([i,$e(t)]),{files:l,additions:p,deletions:D}=c;if(he(a,c))return console.info(`Files: ${l}, +${p} -${D}`);console.info("The PR stat doesn't match the local stat."),console.info("LOCAL"),console.table(a),console.info("GITHUB"),console.table(c),console.info("One option to fix (there'll likely be conflicts):"),console.info("1. git stash -u"),console.info(`2. git merge ${n}`),console.info("3. git stash pop")}async function ye(t){let{stdout:e}=await s(`git diff --shortstat ${t}`),o=/(\d+)\s+files? changed(?:, (\d+) insertions?\(\+\))?(?:, (\d+) deletions?\(-\))?/,n=e.trim().match(o);if(!n)throw new Error(`Couldn't generate short stat for ref(s): ${t}`);let[,r,i,a]=n;return{files:parseInt(r,10),additions:i?parseInt(i,10):0,deletions:a?parseInt(a,10):0}}async function $e(t){let{stdout:e}=await s(`gh pr view ${t} --json deletions,files,additions`),o=JSON.parse(e.trim());return o.files=o.files.length,o}import{spawn as be}from"node:child_process";import{createInterface as xe}from"node:readline/promises";import K from"chalk";async function At(){let t=y("Error: missing target branch argument"),e=await P("HEAD",t),{promise:o,resolve:n,reject:r}=Promise.withResolvers(),i=be("git",["merge-tree",e,"HEAD",t]),a=xe({input:i.stdout,crlfDelay:1/0}),c=!1,l=0;a.on("line",g=>{g=g.trimEnd(),g==="+<<<<<<< .our"?(c=!0,console.info(K.red(g)),l+=1):g==="+>>>>>>> .their"?(c=!1,console.info(K.green(g))):g==="+======="?console.info(K.yellow(g)):c&&console.info(g)}),a.on("close",()=>n(l)),i.on("error",r);let p=await o,D=p?`\u274C ${p} conflicts would occur!`:"\u2705 No conflicts. Safe to merge.";console.info(D)}async function St(){let{merge:t,rebaseMerge:e,rebaseApply:o,cherryPick:n,revert:r}=await O(),i="";if(t)i="merge";else if(e||o)i="rebase";else if(n)i="cherry-pick";else if(r)i="revert";else{console.log("Nothing to continue.");return}console.log(`Continuing the ${i}`),await f([i,"--continue"])}import{appendFileSync as Pe}from"node:fs";import{readFile as Ce}from"node:fs/promises";async function _(t){return(await Ce(t,"utf-8")).split(/\r?\n/).map(o=>o.trim()).filter(o=>o&&!o.startsWith("#"))}async function vt(){let t=await k("info/exclude");await N(t);let e=await _(t);u().forEach(o=>{e.includes(o)?console.info(`Already Exists: '${o}'`):(Pe(t,`${o}
4
- `),console.info(`Added '${o}'`))}),console.info(`
5
- See file at ${t}`)}async function Dt(){let t=u();if(t[0]){let e=await Re(t[0]);console.info(e.join(`
6
- `))}else f(["status","--short"])}async function Re(t){return L(t)?await E(`git stash show -p --include-untracked --name-only ${t}`):await E(`git show --name-only --pretty=format:"" ${t}`)}import{spawn as Ae}from"node:child_process";async function Et(){let t=y("Error: missing valid target ref argument");await S();let e=await nt(t);await f(["commit",`--fixup=${e}`]);let n=(await F(`${e}^`,"HEAD",!0)).map(i=>Se(i));(await Promise.all(n)).every(Boolean)||(console.warn("Rebase conflict would occur!"),await s("git reset HEAD~1 --soft"),process.exit(1)),await s(`git rebase -i --autosquash ${e}^`)}async function Se(t){let{stdout:e}=await s(`git diff ${t}^ ${t}`),{promise:o,resolve:n,reject:r}=Promise.withResolvers(),i=Ae("git",["apply","--check","--3way","-q"],{stdio:["pipe","ignore","ignore"]});return i.on("close",a=>{n(a===0)}),i.on("error",r),i.stdin.write(e),i.stdin.end(),o}import{readFile as ve,writeFile as De}from"node:fs/promises";async function kt(){let t=await k("info/exclude");await N(t);let e=await _(t),o=u();o.filter(a=>!e.includes(a)).forEach(a=>console.info(`No match: '${a}'`));let r=(await ve(t,"utf-8")).split(/\r?\n/).map(a=>a.trim()),i=r.filter(a=>!o.includes(a));await De(t,i.join(`
7
- `)),console.info(`
8
- Removed ${r.length-i.length} entries from ${t}`)}import{render as Ee}from"ink";import{jsx as qe}from"react/jsx-runtime";async function Bt(){let t=(async()=>{let r=await ke();return await Be(r)})();Ee(qe(m,{msg:"Fetching repo languages",promise:t}));let e=await t,o=Object.values(e).reduce((r,i)=>r+i,0),n=Object.entries(e).map(([r,i])=>`${r}: ${Math.round(i/o*100)}% - ${Te(i)}`);console.log(n.join(`
9
- `))}async function ke(){let{stdout:t}=await s("gh repo view --json nameWithOwner -q .nameWithOwner");return t.trim()}async function Be(t){let{stdout:e}=await s(`gh api repos/${t}/languages`);return JSON.parse(e.trim())}function Te(t,e=2){if(t===0)return"0 B";let o=1024,n=e<0?0:e,r=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],i=Math.floor(Math.log(t)/Math.log(o));return`${parseFloat((t/Math.pow(o,i)).toFixed(n))} ${r[i]}`}import $ from"chalk";async function Tt(){y();let t=u(),[e,o]=t.filter(r=>r!=="-v"),n=[];if(L(e)?(n.push(...await H(`${e}^3`)),n.push(...await H(`${e}^2`))):n.push(...await H(e,o)),t.includes("-v")){let r={added:"A",modified:"M",deleted:"D",binary:"B"};n.forEach(i=>{let c=`${We(i.changeType)(r[i.changeType])} ${i.file} |`;i.added&&(c+=$.green(` +${i.added}`)),i.deleted&&(c+=$.red(` -${i.deleted}`)),console.info(c)})}else{let r=new Set(n.map(({file:p})=>p)).size,[i,a]=n.reduce((p,{added:D,deleted:g})=>[p[0]+(D??0),p[1]+(g??0)],[0,0]),c=$.green(`+${i}`),l=$.red(`-${a}`);console.info(`${r} files: ${c} ${l}`)}}var We=t=>{switch(t){case"modified":return $.yellow;case"added":return $.green;case"deleted":return $.red;default:return e=>e}};async function qt(){let t=await ot();console.log(t)}import{render as It}from"ink";function Wt(){return new Date().toLocaleString("en-US",{year:"2-digit",month:"2-digit",day:"2-digit",hour:"numeric",minute:"2-digit",hour12:!0}).replace(",","")}async function v(){let t=Wt();await s("git add -A"),await f(["commit","-m",`"WIP ${t}"`])}import{nanoid as Ie}from"nanoid";import Ge from"chalk";import{jsx as Gt}from"react/jsx-runtime";async function Mt(){let{remote:t,branch:e}=await q(),o=process.argv[3]??e;await C()||await v(),await it(o,"HEAD")||(console.warn("Conflicts would occur. Not safe to rebranch."),process.exit(1));let n=await w(),r=(async()=>{await T(t,o)})();It(Gt(m,{msg:`Updating branch ${o}`,promise:r})),await r;let i=`${Ie(8)}`,a=(async()=>{await s(`git switch ${n}`),await s(`git branch ${i}`),await s(`git switch ${o}`),await s(`git branch -D ${n}`),await s(`git switch -c ${n}`);let c=await F(o,i,!0);for(let l of c)try{await s(`git cherry-pick ${l}`)}catch{let p=Ge.yellow(`git branch -D ${n} && git branch -m ${i} ${n}`);throw new Error(`\u274C cherry pick failed at ${l}
10
- Run this to restore backup branch
11
- > ${p}`)}await s(`git branch -D ${i}`)})();It(Gt(m,{msg:`Rewriting branch ${n}`,promise:a})),await a,console.info(`Successfully recreated branch ${n} from ${o}`)}import{execSync as Me}from"node:child_process";async function Ft(){R();let t=Fe(process.argv[3]),{default:e}=await import("clipboardy");await e.write(t),console.log(`'${t}' copied to clipboard`)}function Fe(t="HEAD"){return Me(`git rev-parse --short ${t}`,{encoding:"utf-8"}).trim()}import{render as He}from"ink";import{jsx as Le}from"react/jsx-runtime";async function Ht(){let{remote:t,branch:e}=await X();h(t),await A();let o=G(t,e);He(Le(m,{msg:`Fetching branch ${e} from ${t}`,promise:o})),await o,await f(["switch","-c",e,"--track",`${t}/${e}`])}async function Z(){let{stdout:t}=await s("npm list -g bisgit --depth=0 --json");return JSON.parse(t.trim()).dependencies.bisgit.version}async function Lt(){console.info(await Z())}async function Ne(){let{code:t}=await d("npm",["outdated","-g","bisgit"]);return t===0}async function Ue(){let{stdout:t}=await s("npm view bisgit version",{encoding:"utf8"});return t.trim()}async function Nt(){if(await Ne())return console.info("Already up to date");console.info(`Updating: ${await Z()} -> ${await Ue()}`),b("npm",["i","-g","bisgit@latest"])}async function Ut(){let[t,e]=await Promise.allSettled([await je("user.name"),await Oe()]);t.status==="fulfilled"&&console.info(`Git: ${t.value}`),e.status==="fulfilled"&&console.info(`Github: ${e.value}`)}async function Oe(){let{stdout:t}=await s("gh api user --jq .login");return t.trim()}async function je(t){let{stdout:e}=await s(`git config ${t}`);return e.trim()}import{render as Ze}from"ink";import{Text as _e,useApp as Ve,useInput as Ye}from"ink";import{useState as ze}from"react";import{Fragment as Ke,jsx as Je,jsxs as Ot}from"react/jsx-runtime";function jt({prompt:t,msg:e,onConfirm:o,requireConfirmation:n}){let[r,i]=ze(""),{exit:a}=Ve();return Ye((c,l)=>{if(r)return;let p=c.toLowerCase();p==="y"||l.return&&!n?i("Yes"):(p==="n"||l.return&&n)&&(i("No"),a())}),Ot(Ke,{children:[Ot(_e,{children:[t," [",n?"y/N":"Y/n","] ",r]}),r==="Yes"&&Je(m,{msg:e,promise:o()})]})}import{jsx as Qe}from"react/jsx-runtime";async function _t(){if(at(),await C())return console.log("Already a clean working tree");let t=await M();if(!t)throw new Error("git status cmd failed");let e=new Q(t);e.displayReport(),Ze(Qe(jt,{prompt:"Approve these changes?",msg:"Running git reset && git clean",onConfirm:async()=>(await s("git reset --hard"),await s("git clean -df"),`Altered ${e.willDelete.length+e.willRecreate.length+e.willRevert.length} files and folders.`)}))}var Q=class{willDelete=[];willRecreate=[];willRevert=[];constructor(e){e.forEach(o=>{if(o){o=o.trim();let n=o.indexOf(" ");if(n===-1)throw new Error("error parsing status porcelain");let r=o.slice(0,n).trim(),i=o.slice(n+1);r.includes("?")||r.includes("A")?this.willDelete.push(i):r==="DU"||r==="D"?this.willRecreate.push(i):this.willRevert.push(i)}}),this.willDelete.sort(),this.willRecreate.sort(),this.willRevert.sort()}displayReport(){this.displaySection("Will Recreate:",this.willRecreate),this.displaySection("Will Revert:",this.willRevert),this.displaySection("Will Delete:",this.willDelete)}displaySection(e,o){o.length&&console.log(`${e}
12
- ${o.map(n=>`- ${n}`).join(`
13
- `)}`)}};import{nanoid as Xe}from"nanoid";import{render as to}from"ink";import{jsx as eo}from"react/jsx-runtime";async function Vt(){await U();let t=process.argv[3]??"origin";h(t);let e=await w();ct(e);let o="",r=(async()=>{let i=[s(`git fetch ${t} ${e} --force`)];await C()||i.push(v()),await Promise.all(i);let[a,c]=await Promise.all([W(t,e),I(t,e)]);if(!(a===0&&c===0)){if(a!==0){let l=`${e}-${Xe(8)}`;o=`Created branch ${l}`,await s(`git branch ${l}`)}await s(`git reset --hard ${t}/${e}`)}})();to(eo(m,{msg:`Force pull reseting ${e} -> ${t}`,promise:r})),await r,o&&console.info(o)}var Yt={abort:lt,amend:ft,autoprune:wt,backmerge:gt,churn:ht,coauthor:Pt,"code-review":Rt,conflict:At,continue:St,exclude:vt,files:Dt,fixup:Et,include:kt,languages:Bt,lines:Tt,pwd:qt,rebranch:Mt,"remote-default":dt,savepoint:v,sha:Ft,track:Ht,update:Nt,"--version":Lt,whoami:Ut,wipe:_t,yank:Vt};async function vn(t){return await Yt[t]?.(),Object.hasOwn(Yt,t)}export{vn as runCommand};
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- import{a as Le,b as Re,c as Ne,d as Fe,j as We,o as Ie,r as Oe,t as Ke,u as $e,v as Ge,w as Q}from"./chunk-7XT4D6II.js";import{b as P,c as De}from"./chunk-R7DNYVL6.js";import{render as gn}from"ink";import{createContext as ro,useContext as no,useState as io}from"react";import{jsx as so}from"react/jsx-runtime";var He=ro(void 0),Ve=({children:e})=>{let[t,r]=io({}),o=(i,s)=>{r(a=>({...a,[i]:s}))},n=i=>{let s=Array.isArray(i)?i:[i];r(a=>{let l={...a};for(let c of s)delete l[c];return l})};return so(He.Provider,{value:{keybindings:t,setKeybinding:o,removeKeybinding:n},children:e})},M=()=>{let e=no(He);if(!e)throw new Error("useKeybindings must be used within a KeybindingsProvider");return e};import{useEffect as mn}from"react";import{Text as un,Box as to,useInput as pn}from"ink";import{useStdout as ao}from"ink";function g(){let{stdout:e}=ao(),t=e.rows-2,r=Math.floor(t/2),o=e.columns>100?96:e.columns-4;return{width:e.columns,height:e.rows,sectionHeight:t,sectionHalfHeight:r,modalWidth:o}}import{Box as Ye,Text as uo}from"ink";import{useState as se,createContext as co,useContext as lo}from"react";import{jsx as mo}from"react/jsx-runtime";var I={Files:"Files","File Meta":"Files",Status:"Status",Log:"Log","Commit Details":"Log",Branches:"Branches",Worktrees:"Branches",Remotes:"Branches",Stashes:"Stashes","Stash Details":"Stashes"},U=Object.keys(I),_e=co({});function Ue({children:e}){let[t,r]=se(!1),o=()=>r(!0),n=()=>r(!1),[i,s]=se("Status"),[a,l]=se("Status"),c=p=>{t||(l(p),s(I[p]))},m=p=>{t||(s(p),l(p))},f=()=>{t||l(p=>{let S=U.at((U.indexOf(p)+1)%U.length);return s(I[S]),S})},b=()=>{t||l(p=>{let S=U.at(U.indexOf(p)-1);return s(I[S]),S})};return mo(_e.Provider,{value:{activeGroup:i,setActiveGroup:m,activeSection:a,setActiveSection:c,prevSection:b,nextSection:f,isLocked:t,lock:o,unlock:n},children:e})}function w(){let e=lo(_e);if(Object.keys(e).length===0)throw new Error("useNavContext must be used within a NavProvider");return e}import{memo as po}from"react";import{jsx as ae}from"react/jsx-runtime";var fo=Array.from(new Set(Object.values(I))),qe=po(({activeGroup:e})=>ae(Ye,{width:"100%",flexDirection:"row",height:1,children:fo.map((t,r)=>ae(Ye,{borderStyle:"classic",borderLeft:!!r,borderRight:!1,borderTop:!1,borderBottom:!1,children:ae(uo,{color:t===e?"cyan":"",children:` [${r+1}]: ${t} `})},t))}),(e,t)=>e.activeGroup===t.activeGroup);import{Text as an,useInput as cn}from"ink";import{Box as So,Text as wo}from"ink";import{Box as Qe,measureElement as go,Text as ze}from"ink";import{useMemo as ho,useRef as xo}from"react";import{Fragment as vo,jsx as z,jsxs as yo}from"react/jsx-runtime";function T(e){let{title:t,footer:r,children:o,width:n,height:i,innerHeight:s,isModal:a,backgroundColor:l}=e,{width:c}=g(),m=n??c,f=xo(null),b=ho(()=>{if(!f.current)return 0;let{width:d}=go(f.current);return d},[f.current]),p=b-8,S={...e,height:s,width:b},{activeSection:x}=w(),u=x===t||a?"cyan":"";return z(Qe,{ref:f,flexDirection:"column",height:i,width:m,backgroundColor:l,children:b!==0&&yo(vo,{children:[t&&z(ze,{color:u,wrap:"truncate-end",children:"\u256D\u2500\u2500\u2500\u2500 "+t+" "+"\u2500".repeat(p-t.length)+"\u256E"}),z(Qe,{flexDirection:"column",...S,borderStyle:"round",borderColor:u,borderTop:!t,borderBottom:!r,paddingLeft:1,children:o}),r&&z(ze,{color:u,wrap:"truncate-end",children:"\u2570"+"\u2500".repeat(p-r.length)+" "+r+" \u2500\u2500\u2500\u2500\u256F"})]})})}import{useEffect as bo,useState as ce}from"react";function y(e,t=[]){let[r,o]=ce(void 0),[n,i]=ce(!1),[s,a]=ce(0),l=()=>a(c=>c+1);return bo(()=>{let c=!1;return i(!1),o(void 0),e().then(m=>{c||(o(m),i(!0))}).catch(()=>{c||i(!0)}),()=>{c=!0}},[s,...t]),{value:r,resolved:n,refresh:l}}import{jsx as le}from"react/jsx-runtime";function Je(){let{width:e,sectionHeight:t}=g(),{value:r}=y(Ie);return le(So,{width:e,height:t,children:le(T,{title:"Status",innerHeight:t-1,children:r?.map(o=>le(wo,{children:o},o))})})}import{useEffect as Mt,useState as Pt}from"react";import{Box as vr,useInput as yr}from"ink";import{Text as To}from"ink";import{jsx as Xe}from"react/jsx-runtime";function Ze({sha:e}){let{resolved:t,value:r}=y(()=>Mo(e),[e]);return Xe(T,{title:"Commit Details",width:"50%",height:"100%",children:e&&t&&Xe(To,{children:r})})}async function Mo(e){if(!e)return;let{stdout:t}=await P(`git show ${e} --name-only`);return t.trim()}import{useCallback as Io,useEffect as Oo}from"react";import{Box as J,Text as ue,useInput as Ko}from"ink";import{useEffect as je,useRef as Po,useState as de}from"react";function O(e,t){let[r,o]=de(0),[n,i]=de(0),s=Po(void 0),[a,l]=de(0),c=()=>l(u=>u+1);je(()=>{let u=0;if(s.current!==void 0){let h=e.findIndex(v=>v===s.current);h>=0&&(u=h)}i(u);let d=Math.min(Math.max(u-Math.floor(t/2),0),Math.max(0,e.length-t));o(d)},[e,t,a]),je(()=>{s.current=e[n]},[n,e]);let m=Math.max(0,e.length-t),f=e.length-1,b=()=>{i(u=>{let d=Math.min(u+1,f);return o(h=>d>=h+t?Math.min(h+1,m):h),d})},p=()=>{i(u=>{let d=Math.max(u-1,0);return o(h=>d<h?Math.max(h-1,0):h),d})},S=e.slice(r,r+t),x=e[n];return{scrollDown:b,scrollUp:p,outList:S,selectedIndex:n,renderedIndex:n-r,selectedValue:x,refresh:c}}import{useInput as Co}from"ink";import{createContext as Eo,useContext as Ao}from"react";import{useEffect as rt,useState as et}from"react";import{jsx as Bo}from"react/jsx-runtime";var tt="\u2190",ot="\u2192",nt=Eo({});function it({children:e}){let[t,r]=et("truncate-end"),[o,n]=et(0),{removeKeybinding:i,setKeybinding:s}=M();return rt(()=>(o&&(t==="truncate-start"?s(tt,"pan left"):s(ot,"pan right")),()=>{i([ot,tt])}),[t,o]),Co((a,l)=>{o&&(l.rightArrow?r("truncate-start"):l.leftArrow&&r("truncate-end"))}),Bo(nt.Provider,{value:{mode:t,_isToggleable:o,_setIsToggleable:n},children:e})}function k(){let e=Ao(nt);if(Object.keys(e).length===0)throw new Error("useTruncationMode must be used within an TruncationModeProvider");let{mode:t,_setIsToggleable:r}=e;return rt(()=>(r(o=>o+1),()=>r(o=>o-1)),[]),{mode:t}}import{createContext as ko,useContext as Do,useEffect as st,useMemo as Lo,useRef as at,useState as ct}from"react";import{useInput as Ro}from"ink";import{jsx as Wo}from"react/jsx-runtime";var lt=ko({});function dt({children:e}){let{activeSection:t}=w(),{sectionHeight:r}=g(),o=r-3,{value:{tree:n,files:i}={},resolved:s}=y(No),a=at(new Set),l=at(new Set(["."])),[c,m]=ct();st(()=>{n&&i&&(a.current=new Set(Object.keys(n)),m(i[0]))},[s]);let f=Lo(()=>i?.filter(x=>a.current.has(x))??[],[a.current.size,s]),[b,p]=ct(0),S=()=>p(x=>x+1);return Ro((x,u)=>{if(t!=="Files"||!n||!c)return;if(u.upArrow){let h=Math.max(0,f.indexOf(c)-1);m(f[h]),S()}else if(u.downArrow){let h=Math.min(f.length-1,f.indexOf(c)+1);m(f[h]),S()}let d;if(u.leftArrow?d="collapse":u.rightArrow&&(d="expand"),d){let h=me(n,c);if(!h)return;for(let v of Object.keys(h)){let E=`${c}/${v}`;d==="expand"?a.current.add(E):a.current.delete(E)}S()}}),st(()=>{if(l.current.clear(),l.current.add("."),f.length<=o){f.forEach(_=>l.current.add(_));return}let x=c?Fo(c):[],u=Math.max(1,o-x.length),d=f.filter(_=>!x.includes(_)),h=c?d.indexOf(c):0,v=Math.max(0,h-Math.floor(u/2)),E=v+u;E>d.length&&(E=d.length,v=Math.max(0,E-u));let q=d.slice(v,E);[...x,...q].forEach(_=>{l.current.add(_)})},[f.length,c,o]),Wo(lt.Provider,{value:{version:b,tree:n,visibleFiles:l.current,expandedFiles:a.current,selectedFile:c},children:e})}function B(){let e=Do(lt);if(Object.keys(e).length===0)throw new Error("useTreeNavigation must be used within an TreeNavigationProvider");return e}var me=(e,t)=>{let r=t.split("/"),o=e;for(let n of r)o=o[n];return o},No=async()=>{let e=await Re(),t=Ne(e);return{tree:e,files:t}},Fo=e=>{let t=e.split("/"),r=[];for(let o=1;o<t.length;o++)r.push(t.slice(0,o).join("/"));return r};import{jsx as R,jsxs as Go}from"react/jsx-runtime";function mt({setSha:e,mode:t}){let{label:r,value:o}=t,{sectionHeight:n}=g(),{activeSection:i,isLocked:s}=w(),{selectedFile:a}=B(),{mode:l}=k(),c=Io(()=>o.length&&a?o(a):o(),[o,a]),{resolved:m,value:f=[]}=y(c,[r]),{scrollUp:b,scrollDown:p,outList:S,selectedValue:x,renderedIndex:u}=O(f,n-2),d=x?.sha;Oo(()=>{e(d)},[d]),Ko((v,E)=>{i!=="Log"||s||(E.upArrow?b():E.downArrow&&p())});let h=$o.includes(t.label);return R(T,{overflowY:"hidden",height:"100%",title:"Log",width:"50%",children:m&&S.map(({sha:v,message:E},q)=>Go(J,{flexDirection:"row",flexWrap:"nowrap",children:[R(J,{minWidth:2,children:v===d?R(ue,{color:h&&q===u?"magenta":void 0,children:"> "}):null}),R(J,{minWidth:8,children:R(ue,{color:"yellow",children:v})}),R(J,{children:R(ue,{wrap:l,children:E})})]},`${v}-${t.label}${h?q:""}`))})}var $o=["blame","reflog"];import{useState as rr}from"react";import{useInput as nr}from"ink";import ir from"ink-text-input";import{useInput as Ho}from"ink";import{createContext as Vo,useContext as _o,useEffect as Uo,useState as pe}from"react";import{Fragment as Yo,jsx as Qo,jsxs as qo}from"react/jsx-runtime";var ut=Vo({});function C(){let e=_o(ut);if(Object.keys(e).length===0)throw new Error("useKeybindings must be used within a KeybindingsProvider");return e}function pt({children:e}){let[t,r]=pe(null),{lock:o,unlock:n}=w(),[i,s]=pe(!1),[a,l]=pe(),c=()=>{n(),s(!1),a?.(),r(null)},m=()=>{o(),s(!0)},f=()=>{i?c():m()},b=(x,u)=>{c(),l(u?.onClose),r(x)};Ho((x,u)=>{u.escape&&c()});let{setKeybinding:p,removeKeybinding:S}=M();return Uo(()=>{if(i)return p("esc","close"),()=>{S("esc")}},[i]),Qo(ut.Provider,{value:{setModal:b,open:m,close:c,toggle:f,isOpen:i},children:qo(Yo,{children:[e,t]})})}import{Box as xt}from"ink";import fe from"node:path";import ge from"node:os";import zo from"node:fs/promises";import{createContext as Jo,useContext as Xo}from"react";import{jsx as tr}from"react/jsx-runtime";var ft=Jo({});function gt({children:e}){let{value:t}=y(Zo);return tr(ft.Provider,{value:{bgColor:t},children:e})}var ht=()=>{let e=Xo(ft);if(Object.keys(e).length===0)throw new Error("useKeybindings must be used within a KeybindingsProvider");return e};async function Zo(){if(!(!process.stdin.isTTY||!process.stdout.isTTY))return process.env.TERM_PROGRAM==="vscode"?await er():new Promise(e=>{let t="\x1B]11;?\x07",r="",o,n=s=>{clearTimeout(o),process.stdin.off("data",i);try{process.stdin.setRawMode(!1),process.stdin.pause()}catch{}e(s)},i=s=>{r+=s.toString("ascii");let a=r.match(/\x1b]11;rgb:([0-9a-fA-F]{1,4})\/([0-9a-fA-F]{1,4})\/([0-9a-fA-F]{1,4})\x07/);if(a){let l=jo(a[1],a[2],a[3]);n(l)}};try{process.stdin.setRawMode(!0),process.stdin.resume(),process.stdin.on("data",i),o=setTimeout(()=>n(void 0),150),process.stdout.write(t)}catch{n(void 0)}})}function jo(e,t,r){return"#"+[e,t,r].map(o=>Math.round(parseInt(o,16)*255/((1<<4*o.length)-1)).toString(16).padStart(2,"0")).join("")}async function er(){let e="Code";process.env.TERM_PROGRAM_VERSION?.includes("insider")&&(e="Code - Insiders");let t;switch(process.platform){case"win32":t=fe.join(ge.homedir(),"AppData","Roaming",e,"User","settings.json");break;case"linux":t=fe.join(ge.homedir(),".config",e,"User","settings.json");break;case"darwin":t=fe.join(ge.homedir(),"Library","Application Support",e,"User","settings.json");break;default:return}if(!await Le(t))return;let r=await zo.readFile(t,{encoding:"utf-8"}),{default:o}=await import("strip-json-comments"),n=o(r).replace(/,\s*(\}|\])/g,"$1");switch(JSON.parse(n)["workbench.colorTheme"]){case"Default Dark Modern":case void 0:return"#181818";case"Visual Studio Dark":case"Default Dark+":return"#1e1e1e";case"Default High Contrast":return"#000000";case"Default Light+":case"Visual Studio Light":case"Default High Contrast Light":return"#ffffff";case"Default Light Modern":return"#f8f8f8";default:return}}import{jsx as he}from"react/jsx-runtime";var or=36;function K({children:e,title:t,width:r=or}){let o=g(),{width:n}=o,i=Math.floor((n-r)/2),{bgColor:s}=ht();return he(xt,{...o,position:"absolute",children:he(xt,{alignSelf:"center",marginLeft:i,marginRight:i,children:he(T,{title:t,width:r,isModal:!0,backgroundColor:s,children:e})})})}import{jsx as vt}from"react/jsx-runtime";function X({title:e,handleSubmit:t}){let[r,o]=rr(""),{isOpen:n,close:i}=C();return nr((s,a)=>{a.return&&n&&(t(r),o(""),i())}),n&&vt(K,{title:e,children:vt(ir,{value:r,onChange:o})})}import{useInput as sr}from"ink";import ar from"ink-select-input";import{jsx as yt}from"react/jsx-runtime";function Z({title:e,handleSubmit:t,options:r,initialIndex:o,width:n}){let{isOpen:i,close:s}=C();return sr((a,l)=>{l.return&&i&&s()}),i&&yt(K,{title:e,width:n,children:yt(ar,{items:r,onSelect:t,initialIndex:o})})}var G=[{value:()=>$("git log --oneline -n 400"),label:"log"},{value:()=>$("git log --oneline --tags --no-walk --decorate"),label:"tags"},{value:()=>$("git reflog"),label:"reflog"},{value:()=>$('git log --oneline --author="$(git config user.name)"'),label:"my commits"},{value:e=>$(`git log --oneline "${e}"`),label:"file"},{value:e=>$(`git blame --follow "${e}"`),label:"blame"}];async function $(e){let{stdout:t}=await P(e);return t.trim().split(/\r?\n/).map(cr)}function cr(e){let t=e.indexOf(" ");return{sha:e.slice(0,t),message:e.slice(t+1)}}import{createContext as lr,useContext as dr,useEffect as mr,useState as ur}from"react";import{jsx as pr}from"react/jsx-runtime";var bt=lr({});function St({children:e}){let[t,r]=ur(),o=(n,...i)=>{n(...i).catch(s=>r(s.stderr??s.message))};return mr(()=>{if(t)throw new Error(t)},[t]),pr(bt.Provider,{value:{attempt:o,err:t},children:e})}function H(){let e=dr(bt);if(Object.keys(e).length===0)throw new Error("useErrorCatcher must be used within an ErrorCatcherProvider");return e}import{createContext as fr,useContext as gr,useState as hr}from"react";import{jsx as xr}from"react/jsx-runtime";var wt=fr({});function Tt({children:e}){let[t,r]=hr(),o=i=>r(i),n=i=>{let s=t===i;return s&&r(void 0),s};return xr(wt.Provider,{value:{sendMessage:o,receiveMessage:n},children:e})}function j(){let e=gr(wt);if(Object.keys(e).length===0)throw new Error("useMessaging must be used within an MessagingProvider");return e}import{jsx as xe,jsxs as br}from"react/jsx-runtime";function ve(){let{setModal:e,toggle:t}=C(),[r,o]=Pt(),{width:n,sectionHeight:i}=g(),[s,a]=Pt(G[0]),{receiveMessage:l}=j();Mt(()=>{l("log-file")&&a(G[4]),l("blame-file")&&a(G[5])},[]);let{isLocked:c}=w(),{attempt:m}=H();yr((p,S)=>{p==="m"&&(e(xe(Z,{options:G,title:"Log Type",handleSubmit:x=>a(x),initialIndex:G.indexOf(s)})),t()),!c&&p==="c"&&r&&m(()=>P(`git checkout ${r}`))});let{setKeybinding:f,removeKeybinding:b}=M();return Mt(()=>(f("c","checkout"),f("m","mode"),()=>{b(["c","m"])}),[]),br(vr,{width:n,height:i,children:[xe(mt,{setSha:o,mode:s}),xe(Ze,{sha:r})]})}import{useEffect as Br}from"react";import{Box as Dt}from"ink";import{Box as ye,Text as Ct,useInput as Sr}from"ink";import{useEffect as wr}from"react";import{Fragment as Mr,jsx as N,jsxs as Tr}from"react/jsx-runtime";function Et(){let{activeSection:e,isLocked:t}=w(),{sectionHalfHeight:r}=g(),{value:o=[],refresh:n}=y(Ke),{value:i,refresh:s}=y(Fe),{setKeybinding:a,removeKeybinding:l}=M();wr(()=>{if(e==="Branches")return a("s","switch"),()=>{l("s")}},[e]);let{outList:c,selectedValue:m,scrollUp:f,scrollDown:b}=O(o,r-2),p=async v=>{await P(`git branch ${v}`),n()},S=async()=>{await P(`git branch -D ${m}`),n()},x=async()=>{await P(`git switch ${m}`),n(),s()},{setModal:u,open:d}=C(),{attempt:h}=H();return Sr((v,E)=>{e!=="Branches"||t||(E.upArrow?f():E.downArrow?b():v==="c"?(u(N(X,{title:"Name your new branch",handleSubmit:p})),d()):v==="d"?h(S):v==="s"&&h(x))}),N(Mr,{children:N(T,{width:"100%",title:"Branches",innerHeight:r-1,children:c.map(v=>Tr(ye,{flexDirection:"row",flexWrap:"nowrap",children:[N(ye,{minWidth:2,children:v===m?N(Ct,{children:"> "}):null}),N(ye,{children:N(Ct,{color:v===i?"magenta":void 0,children:v})})]},v))})})}import{Text as be}from"ink";import{Fragment as Pr}from"react";import{jsx as Se,jsxs as At}from"react/jsx-runtime";function Bt(){let{value:e}=y($e);return Se(T,{width:"50%",title:"Remotes",children:e?.map(({url:t,name:r,type:o})=>At(Pr,{children:[At(be,{wrap:"truncate-end",children:[r," (",o,")"]}),Se(be,{wrap:"truncate-end",children:t}),Se(be,{children:" "})]},`${r}-${o}`))})}import{Text as we}from"ink";import{Fragment as Cr}from"react";import{jsx as ee,jsxs as Ar}from"react/jsx-runtime";function kt(){let{sectionHalfHeight:e}=g(),{value:t}=y(Er);return ee(T,{width:"100%",title:"Worktrees",innerHeight:e-1,children:t?.map(({branch:r,detached:o,path:n,head:i})=>Ar(Cr,{children:[ee(we,{children:o?i:r}),ee(we,{children:n}),ee(we,{children:" "})]},n))})}async function Er(){let{stdout:e}=await P("git worktree list --porcelain"),t=e.trim().split(/\r?\n/),r=[],o=[];for(let n of t)n.trim()===""?o.length&&(r.push(o),o=[]):o.push(n);return o.length&&r.push(o),r.map(n=>{let i={detached:!1};for(let s of n)s.startsWith("worktree ")?i.path=s.slice(9):s.startsWith("HEAD ")?i.head=s.slice(5):s.startsWith("branch ")?i.branch=s.slice(7):s==="detached"&&(i.detached=!0);return i})}import{Fragment as kr,jsx as te,jsxs as Lt}from"react/jsx-runtime";function Rt(){let{width:e,sectionHeight:t}=g(),{setKeybinding:r,removeKeybinding:o}=M();return Br(()=>(r("c","create"),r("d","delete"),()=>{o(["c","d"])}),[]),te(kr,{children:Lt(Dt,{width:e,height:t,children:[Lt(Dt,{flexDirection:"column",width:"50%",height:t,children:[te(Et,{}),te(kt,{})]}),te(Bt,{})]})})}import{Component as Dr,useEffect as Lr}from"react";import{Text as Nt}from"ink";import{jsx as Te}from"react/jsx-runtime";function oe({title:e,message:t,width:r}){let{isOpen:o}=C(),{mode:n}=k();return o&&Te(K,{title:e,width:r,children:Array.isArray(t)?t.map(i=>Te(Nt,{wrap:n,children:i})):Te(Nt,{children:t})})}import{jsx as Ft}from"react/jsx-runtime";var re=class extends Dr{state={hasError:!1};constructor(t){super(t)}static getDerivedStateFromError(t){return{hasError:!0,message:t?.stderr??t?.message}}dismissError(){this.setState({hasError:!1})}componentDidCatch(t,r){let o=t?.stderr??t?.message;this.setState({hasError:!0,message:o})}render(){return this.state.hasError?Ft(Rr,{dismissError:this.dismissError.bind(this),message:this.state.message,children:this.props.children}):this.props.children}};function Rr({message:e,dismissError:t,children:r}){let{setModal:o,open:n}=C(),{modalWidth:i}=g();return Lr(()=>{if(e){let s=e.split(/\r?\n/).map(a=>a.trim());o(Ft(oe,{title:"Error",message:s,width:i}),{onClose:t}),n()}},[e]),r}import{Box as Ur,useInput as Yr}from"ink";import{useEffect as qr}from"react";import{Box as Me,Text as Kt}from"ink";import Pe from"node:path";import{memo as Nr,useEffect as Wt,useState as Fr}from"react";import{Fragment as Kr,jsx as D,jsxs as Ce}from"react/jsx-runtime";var Wr="\u2190",Ir="\u2191",$t="\u2192",Gt="\u2193",It=`${Wr}${Ir}${Gt}${$t}`;function Ht(){let{sectionHeight:e}=g(),{activeSection:t}=w(),{setKeybinding:r,removeKeybinding:o}=M();Wt(()=>{if(t==="Files")return r(It,"NAVIGATION_KEY"),()=>o(It)},[t]);let{tree:n,version:i}=B(),{value:s}=y(We),[,a]=Fr(0);return Wt(()=>{a(l=>l+1)},[i]),D(T,{title:"Files",innerHeight:e,width:"50%",children:s&&n&&D(Vt,{name:Pe.basename(s),contents:n,depth:0,fp:s})})}function Vt(e){let{contents:t,depth:r,fp:o,rp:n="."}=e,i=Object.keys(t).length===0,{selectedFile:s,visibleFiles:a,expandedFiles:l}=B(),c=n===s;if(!a.has(n))return null;let m=r+2;if(i)return D(Ot,{...e,depth:m,isSelected:c},o);let f=`${n}/`,b=Or(l,p=>p.startsWith(f))||r===0;return Ce(Kr,{children:[Ce(Me,{flexDirection:"row",flexWrap:"nowrap",children:[D(Me,{width:2,children:D(Kt,{children:b?Gt:$t})}),D(Me,{width:"100%",children:D(Ot,{...e,isSelected:c})})]}),b&&Object.entries(t).map(([p,S])=>{let x=Pe.join(n,p),u=Pe.join(o,p);return D(Vt,{name:p,contents:S,depth:m,rp:x,fp:u})})]})}var Ot=Nr(({name:e,depth:t,isSelected:r})=>Ce(Kt,{wrap:"truncate-end",color:r?"yellow":void 0,children:["\xA0".repeat(t),e]}),(e,t)=>e.isSelected===t.isSelected&&e.fp===t.fp);function Or(e,t){for(let r of e)if(t(r))return!0;return!1}import{Box as Ut,Text as F}from"ink";import{Box as $r,measureElement as Gr,Text as _t}from"ink";import{useMemo as Hr,useRef as Vr}from"react";import{jsx as Ee}from"react/jsx-runtime";function ne({text:e}){let t=Vr(null),r=Hr(()=>{if(!t.current)return 0;let{width:a}=Gr(t.current);return a-4},[t.current]),o=Math.max(0,r-e.length),n=Math.floor(o/2),i=o-n,s=`${"=".repeat(n)} ${e} ${"=".repeat(i)}`;return Ee($r,{width:"100%",ref:t,children:e.length>r?Ee(_t,{children:e}):Ee(_t,{children:s})})}import{jsx as Ae,jsxs as L}from"react/jsx-runtime";function Yt(){let{sectionHeight:e}=g(),{selectedFile:t}=B(),{value:r={}}=y(()=>Ge(t),[t]),{authorDate:o,authorEmail:n,authorName:i,shortHash:s}=r,{value:{added:a,deleted:l}={},resolved:c}=y(async()=>_r(s,t),[s,t]),{mode:m}=k();return Ae(Ut,{width:"50%",height:e,children:L(T,{width:"100%",title:"File Meta",innerHeight:e-1,children:[t&&Ae(ne,{text:t}),s&&L(F,{wrap:m,children:["Last Commit: ",s]}),i&&L(F,{wrap:m,children:["Edited By: ",i]}),o&&L(F,{wrap:m,children:["Edit On: ",o]}),n&&L(F,{wrap:m,children:["Contact: ",n]}),c&&(a||l)&&L(Ut,{flexDirection:"row",flexWrap:"nowrap",children:[Ae(F,{children:"Changes:\xA0"}),L(F,{color:"green",children:["+",a??0,"\xA0"]}),L(F,{color:"red",children:["-",l??0]})]})]})})}var _r=async(e,t)=>!e||!t?{}:(await Q(e)).find(({file:o})=>t===o)??{};import{jsx as Be,jsxs as Qr}from"react/jsx-runtime";function qt(){let{width:e,sectionHeight:t}=g(),{selectedFile:r,tree:o}=B(),{setKeybinding:n,removeKeybinding:i}=M();qr(()=>(n("l","log"),n("b","blame"),()=>{i(["l","b"])}),[]);let{setActiveGroup:s}=w(),{sendMessage:a}=j(),{setModal:l,open:c}=C();return Yr((m,f)=>{m==="l"?(a("log-file"),s("Log")):m==="b"&&(Object.keys(me(o??{},r)).length===0?(a("blame-file"),s("Log")):(l(Be(oe,{title:"Sorry",message:["Can't blame a folder."]})),c()))}),Qr(Ur,{width:e,height:t,children:[Be(Ht,{}),Be(Yt,{})]})}import{Box as on}from"ink";import{Box as Qt,Text as zt,useInput as zr}from"ink";import{useEffect as Jr}from"react";import{jsx as V,jsxs as Zr}from"react/jsx-runtime";function Jt({setStash:e}){let{sectionHeight:t}=g(),{mode:r}=k(),{attempt:o}=H(),{setModal:n,open:i}=C(),{activeSection:s,isLocked:a}=w(),{value:l=[],refresh:c}=y(Xr),{outList:m,selectedValue:f,selectedIndex:b,scrollUp:p,scrollDown:S}=O(l,t-2);Jr(()=>{e(`stash@{${b}}`)},[b]);let x=d=>async()=>{await P(`git stash ${d} stash@{${b}}`),c()},u=async()=>{let d=`stash@{${b}}`,h=await Oe(d);n(V(X,{title:`reword ${d}`,handleSubmit:async v=>{await P(`git stash drop ${d}`),await P(`git stash store ${h} -m "${v}"`),c()}})),i()};return zr((d,h)=>{a||(d==="s"?(n(V(Z,{title:"Stash",options:[{value:"git stash",label:"tracked only"},{value:"git stash -u",label:"tracked & untracked"}],handleSubmit:({value:v})=>o(async()=>{await P(v),c()})})),i()):d==="a"?o(x("apply")):d==="p"?o(x("pop")):d==="d"?o(x("drop")):d==="r"&&o(u),s==="Stashes"&&(h.upArrow?p():h.downArrow&&S()))}),V(T,{title:"Stashes",width:"50%",height:"100%",children:m.map(d=>Zr(Qt,{flexDirection:"row",flexWrap:"nowrap",children:[V(Qt,{minWidth:2,children:d===f?V(zt,{children:"> "}):null}),V(zt,{wrap:r,children:d})]},d))})}async function Xr(){return await De("git stash list")}import{Box as jr,Text as ke}from"ink";import{jsx as tn,jsxs as Y}from"react/jsx-runtime";function Xt({stash:e}){let{value:t=[]}=y(()=>en(e),[e]);return Y(T,{title:"Stash Details",width:"50%",height:"100%",children:[e&&tn(ne,{text:e}),t.map(({file:r,added:o,deleted:n,changeType:i})=>i!=="binary"&&Y(jr,{flexDirection:"row",flexWrap:"nowrap",children:[Y(ke,{children:[r,":\xA0"]}),Y(ke,{color:"green",children:["+",o??0,"\xA0"]}),Y(ke,{color:"red",children:["-",n??0]})]}))]})}async function en(e){if(e)return await Q(e)}import{useEffect as rn,useState as nn}from"react";import{jsx as Zt,jsxs as sn}from"react/jsx-runtime";function jt(){let{sectionHeight:e,width:t}=g(),[r,o]=nn(),{setKeybinding:n,removeKeybinding:i}=M();return rn(()=>(n("s","stash"),n("d","drop"),n("a","apply"),n("p","pop"),n("r","reword"),()=>i(["s","p","d","a","r"])),[]),sn(on,{width:t,height:e,children:[Zt(Jt,{setStash:o}),Zt(Xt,{stash:r})]})}import{jsx as A,jsxs as dn}from"react/jsx-runtime";function eo(){let{prevSection:e,nextSection:t,activeGroup:r,setActiveGroup:o}=w();return cn((n,i)=>{i.tab&&i.shift?e():i.tab?t():n==="1"?o("Files"):n==="2"?o("Status"):n==="3"?o("Log"):n==="4"?o("Branches"):n==="5"&&o("Stashes")}),A(re,{children:A(St,{children:A(Tt,{children:A(dt,{children:A(ln,{group:r})})})})})}function ln({group:e}){switch(e){case"Files":return A(qt,{});case"Status":return A(Je,{});case"Log":return A(ve,{});case"Branches":return A(Rt,{});case"Stashes":return A(jt,{});default:return dn(an,{children:['Error, unknown page "',e,'"']})}}import{jsx as ie,jsxs as fn}from"react/jsx-runtime";function oo(){let{isLocked:e,activeGroup:t}=w();pn((i,s)=>{e||i.toLowerCase()==="q"&&process.exit()});let r=g(),{keybindings:o,setKeybinding:n}=M();return mn(()=>n("q","quit"),[]),fn(to,{flexDirection:"column",...r,children:[ie(qe,{activeGroup:t}),ie(eo,{}),ie(to,{flexDirection:"row",children:Object.entries(o).map(([i,s])=>ie(un,{children:`[${i}]: ${s} `},s))})]})}import{jsx as W}from"react/jsx-runtime";function hn(){return W(gt,{children:W(Ue,{children:W(Ve,{children:W(it,{children:W(pt,{children:W(oo,{})})})})})})}var vl=()=>gn(W(hn,{}),{patchConsole:!0});export{vl as renderApp};