bisgit 0.9.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
- package/dist/chunks/chunk-5AP2OORN.js +2 -0
- package/dist/chunks/chunk-6JGIBU7E.js +2 -0
- package/dist/chunks/commands-YR3ZU55X.js +13 -0
- package/dist/chunks/overloads-3UYKGKZT.js +2 -0
- package/dist/chunks/pages-CVHDGNIL.js +2 -0
- package/dist/main.js +1 -1
- package/package.json +11 -11
- package/dist/chunks/chunk-5MVENPOO.js +0 -2
- package/dist/chunks/chunk-NYHXXPP7.js +0 -2
- package/dist/chunks/commands-SLPEOXTP.js +0 -13
- package/dist/chunks/overloads-JPXCKAYN.js +0 -2
- package/dist/chunks/pages-7NIOV6QQ.js +0 -2
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)
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{b as s,c as a,d as m}from"./chunk-OSOEWQKA.js";import{spawnSync as w}from"node:child_process";import $ from"fs/promises";async function h(t){try{return await $.access(t),!0}catch{return!1}}async function b(){return await a("git ls-files")}async function P(){return await a("git ls-files --others --exclude-standard")}async function R(){let[t,r]=await Promise.all([b(),P()]),e=[...t,...r].sort(([i],[o])=>i.localeCompare(o)),n={};for(let i of e){let o=i.split("/"),c=n;for(let u of o)c[u]||(c[u]={}),c=c[u]}return n}function T(t,r=""){let e=[];for(let[n,i]of Object.entries(t)){let o=r?`${r}/${n}`:n;e.push(o),Object.keys(i).length>0&&e.push(...T(i,o))}return e}async function E(){let[t,r]=await Promise.all([await a("git config --list --global"),await a("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),o=e.slice(n+1);return[i,o]})}import{normalize as d}from"node:path";async function v(){let{stdout:t}=await s("git branch --show-current");return t.trim()}async function H(t){t??=await v();let{stdout:r}=await s(`git config --get branch.${t}.remote`);return r.trim()}async function G(t,r){try{let{stdout:e}=await s(`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 I(t,r){try{let{stdout:e}=await s(`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 M(t){let{stdout:r}=await s(`git rev-parse --git-path ${t}`);return d(r.trim())}async function z(){let{stdout:t}=await s("git rev-parse --git-dir");return d(t.trim())}async function O(){let{stdout:t}=await s("git rev-parse --show-toplevel");return d(t.trim())}async function j(t){let{code:r}=await m("git",["remote","get-url",t],{stdio:"ignore"});return r===0}async function y(){let{stdout:t}=await s("git rev-parse --abbrev-ref HEAD");return t.trim()==="HEAD"}async function U(t,r){let e="git fetch";t&&(e+=` ${t}`),r&&(e+=` ${r}`),await s(e)}async function x(){let{stdout:t}=await m("git",["status","--porcelain"]);return!t?.trim()}async function C(t,r){let{stdout:e}=await s(`git merge-base ${t} ${r}`);return e.trim()}async function Y(t,r){let e=await C(t,r),{stdout:n}=await m("git",["merge-tree",e,r,t]);return!n?.split(/\r?\n/)?.includes("+=======")}async function V(t){let{stdout:r}=await s(`git rev-parse ${t}`);return r.trim()}async function W(t,r,e){return await a(`git rev-list ${e?"--reverse":""} ${t}..${r}`)}async function Z(){return await a("git for-each-ref --format='%(refname:short)' refs/heads")}async function J(){let{stdout:t}=await s("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,o,c]=n;return{name:i,url:o,type:c}}).filter(e=>e!==null)}async function K(t){try{let{stdout:r}=await s(`git log -1 --format='%an|%ae|%ad|%h' -- "${t}"`,{encoding:"utf8"}),[e,n,i,o]=r.trim().split("|");return{authorName:e,authorEmail:n,authorDate:i,shortHash:o}}catch{return{}}}async function Q(t,r){let e=r?`git diff --numstat ${t} ${r}`:S(t)?`git stash show --numstat --format="" --include-untracked ${t}`:`git show --numstat --format="" ${t}`;return(await a(e)).map(i=>{let[o,c,u]=i.split(" ");if(o==="-"&&c==="-")return{file:u,added:null,deleted:null,changeType:"binary"};let l=Number(o),p=Number(c),f="modified";return l>0&&p===0?f="added":l===0&&p>0&&(f="deleted"),{file:u,added:l,deleted:p,changeType:f}})}function S(t){return/^stash@\{\d+\}$/.test(t)}async function B(){return await a("git status --porcelain")}async function tt(){let t=await B(),r=[];for(let e of t){let n=e[0],i=e[1],o=e.slice(3);n!==" "&&r.push({staged:!0,changeType:n,name:o}),i!==" "&&r.push({staged:!1,changeType:i,name:o})}return r}function g(t,r,e){let{status:n}=w(t,r,{stdio:"ignore"});n!==0&&(e&&console.error(e),process.exit(1))}var ut=()=>g("git",["rev-parse","--git-dir"],"Need to use command in a git repository."),gt=()=>g("git",["rev-parse","HEAD"],"Need to create first commit."),mt=(t="origin")=>g("git",["remote","get-url",t],`Need to add remote '${t}'.`),lt=t=>g("git",["show-ref","--branches",t],`Branch '${t}' isn't tracked locally and may not exist.`),pt=async()=>{await x()||(console.error("You should stash or commit your changes first."),process.exit(1))},ft=async t=>{await h(t)||(console.error(`${t} must exist for this operation and it doesn't for some reason`),process.exit(1))},dt=async()=>{await y()&&(console.error("Operation not allowed in a 'detached HEAD' state"),process.exit(1))},ht=t=>g("git",["rev-parse","--abbrev-ref","--symbolic-full-name",`${t}@{u}`],`branch '${t}' has no upstream`);function yt(t="Error: missing required argument"){if(process.argv[3])return process.argv[3];console.error(t),process.exit(1)}async function xt(){let{status:t}=w("git",["diff","--staged","--quiet"],{stdio:"ignore"});t===0&&(console.error("You have no staged changes"),process.exit(1))}export{h as a,R as b,T as c,E as d,v as e,H as f,G as g,I as h,M as i,z as j,O as k,j as l,U as m,x as n,C as o,Y as p,V as q,W as r,Z as s,J as t,K as u,Q as v,S as w,B as x,tt as y,ut as z,gt as A,mt as B,lt as C,pt as D,ft as E,dt as F,ht as G,yt as H,xt as I};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{A as m,B as c,l as s}from"./chunk-5AP2OORN.js";import{b as n,d as a}from"./chunk-OSOEWQKA.js";async function l(){m(),c();let{stdout:e,code:t}=await a("git",["rev-parse","--abbrev-ref","origin/HEAD"]);if(t===0)return f(e.trim());await n("git remote set-head origin -a");let{stdout:r}=await n("git rev-parse --abbrev-ref origin/HEAD");return f(r.trim())}async function R(){let{remote:e,branch:t}=await l();console.log(`Remote default branch is '${e}/${t}'`)}async function f(e){let t=e.split("/"),r=e.split("/").map((o,i)=>t.slice(0,i+1).join("/"));for(let o of r)if(await s(o)){let i=e.slice(o.length+1);return{remote:o,branch:i}}throw new Error("Failed to get default remote")}export{l as a,R as b};
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{b as u,c as X}from"./chunk-5WTQIRZS.js";import{a as U,b as ct}from"./chunk-6JGIBU7E.js";import{a as mt}from"./chunk-NHXDQYDU.js";import{A as H,B as P,C as V,D as R,E as I,F as N,G as at,H as h,I as S,a as b,e as w,f as tt,g as q,h as T,i as E,j as et,k as ot,m as W,n as C,o as x,p as rt,q as it,r as G,s as nt,v as M,w as F,x as L,z as st}from"./chunk-5AP2OORN.js";import{a as $,b as s,c as D,d,e as f}from"./chunk-OSOEWQKA.js";import k from"node:path";async function lt(){let t=await L(),e=/^(UU|DU|UD)/;return!!t?.some(o=>e.test(o))}async function O(){let t=await et(),[e,o,i,n,r]=await Promise.all([await b(k.join(t,"MERGE_HEAD")),await b(k.join(t,"rebase-merge")),await b(k.join(t,"rebase-apply")),await b(k.join(t,"CHERRY_PICK_HEAD")),await b(k.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 O(),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 N(),await S(),$("git",["commit","--amend","--no-edit",...u()],{stdio:"inherit",silent:!0,triggerExit:!0})}import{render as te}from"ink";import{render as Qt}from"ink";import{Suspense as _t,use as Vt,useEffect as Yt}from"react";import{Text as gt,useApp as zt}from"ink";import Jt from"ink-spinner";import{jsx as j,jsxs as Zt}from"react/jsx-runtime";function m(t){let{msg:e}=t;return j(_t,{fallback:Zt(gt,{children:[j(Jt,{type:"dots"}),"\xA0",e]}),children:j(Kt,{...t})})}function Kt({msg:t,promise:e}){let o=Vt(e),{exit:i}=zt();return Yt(()=>{i()},[o]),j(gt,{children:`\u2714 ${typeof o=="string"?o:t}`})}import{jsx as Xt}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);P(o),Qt(Xt(m,{msg:"Updating target branch and merging",promise:(async()=>{try{await B(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}`),$("git",["merge",t],{stdio:"inherit",silent:!0})})()}))}async function B(t,e){await W(t,e);let[o,i,n]=await Promise.all([q(t,e),T(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"])}}import{jsx as oe}from"react/jsx-runtime";var ee=["master","main","development","lingoport"];async function dt(){await R();let{branch:t,remote:e}=await U();await s(`git switch ${t}`);let o=(async()=>{let{stdout:r}=await s("git fetch --prune --prune-tags");return await B(e,t),{prunedRefs:r.trim()}})();te(oe(m,{msg:"Fetching and pruning remote references",promise:o}));let{prunedRefs:i}=await o;i&&console.log(i);let n=await nt();for(let r of n){if(r===t||ee.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 x(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 re}from"node:child_process";import{createInterface as ie}from"node:readline/promises";async function wt(){H;let e=[...(await ne()).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 ne(){let{promise:t,resolve:e,reject:o}=Promise.withResolvers(),i=new Map,n=re("git",["log","--all","-M","-C","--name-only","--format=format:"]),r=ie({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 ht}from"ink";import{jsx as $t}from"react/jsx-runtime";async function bt(){await S();let t=u()[0];if(!t){let r=(await ae()).map(c=>({value:c,label:`${c.name} ${c.email} (${c.commits})`}));ht($t(mt,{items:r,prompt:"Who assisted in this commit?",onSelect:async({value:{name:c,email:l}})=>{await yt(c,l.slice(1,-1))}}));return}let e=(async()=>{let n=await se(t);return n.email||(console.error(`Couldn't find an email for ${t}`),process.exit(1)),n})();ht($t(m,{msg:"Fetching name and email",promise:e}));let{name:o,email:i}=await e;yt(o,i)}async function se(t){let{stdout:e}=await s(`gh api users/${t}`);return JSON.parse(e.trim())}async function ae(){let t=await D('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 yt(t,e){f(["commit","--edit","-m","<insert summary>","-m",`Co-authored-by: ${t} <${e}>`])}import{render as z}from"ink";import{isDeepStrictEqual as ce}from"node:util";import{jsx as J}from"react/jsx-runtime";async function Ct(){let t=h("Error: missing id of PR to checkout");await R();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 x(i,"HEAD");return await s(`git reset ${g} --soft`),await me("HEAD")})();z(J(m,{msg:"Creating an editable, explorable, local PR experience",promise:r}));let[a,c]=await Promise.all([r,le(t)]),{files:l,additions:p,deletions:v}=c;if(ce(a,c))return console.info(`Files: ${l}, +${p} -${v}`);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 me(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 le(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 fe}from"node:child_process";import{createInterface as pe}from"node:readline/promises";import K from"chalk";async function xt(){let t=h("Error: missing target branch argument"),e=await x("HEAD",t),{promise:o,resolve:i,reject:n}=Promise.withResolvers(),r=fe("git",["merge-tree",e,"HEAD",t]),a=pe({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,v=p?`\u274C ${p} conflicts would occur!`:"\u2705 No conflicts. Safe to merge.";console.info(v)}async function Pt(){let{merge:t,rebaseMerge:e,rebaseApply:o,cherryPick:i,revert:n}=await O(),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 ue}from"node:fs";import{readFile as ge}from"node:fs/promises";async function _(t){return(await ge(t,"utf-8")).split(/\r?\n/).map(o=>o.trim()).filter(o=>o&&!o.startsWith("#"))}async function Rt(){let t=await E("info/exclude");await I(t);let e=await _(t);u().forEach(o=>{e.includes(o)?console.info(`Already Exists: '${o}'`):(ue(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 de(t[0]);console.info(e.join(`
|
|
6
|
+
`))}else f(["status","--short"])}async function de(t){return F(t)?await D(`git stash show -p --include-untracked --name-only ${t}`):await D(`git show --name-only --pretty=format:"" ${t}`)}import{spawn as we}from"node:child_process";async function At(){let t=h("Error: missing valid target ref argument");await S();let e=await it(t);await f(["commit",`--fixup=${e}`]);let i=(await G(`${e}^`,"HEAD",!0)).map(r=>he(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 he(t){let{stdout:e}=await s(`git diff ${t}^ ${t}`),{promise:o,resolve:i,reject:n}=Promise.withResolvers(),r=we("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 ye,writeFile as $e}from"node:fs/promises";async function vt(){let t=await E("info/exclude");await I(t);let e=await _(t),o=u();o.filter(a=>!e.includes(a)).forEach(a=>console.info(`No match: '${a}'`));let n=(await ye(t,"utf-8")).split(/\r?\n/).map(a=>a.trim()),r=n.filter(a=>!o.includes(a));await $e(t,r.join(`
|
|
7
|
+
`)),console.info(`
|
|
8
|
+
Removed ${n.length-r.length} entries from ${t}`)}import{render as be}from"ink";import{jsx as Re}from"react/jsx-runtime";async function Dt(){let t=(async()=>{let n=await Ce();return await xe(n)})();be(Re(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)}% - ${Pe(r)}`);console.log(i.join(`
|
|
9
|
+
`))}async function Ce(){let{stdout:t}=await s("gh repo view --json nameWithOwner -q .nameWithOwner");return t.trim()}async function xe(t){let{stdout:e}=await s(`gh api repos/${t}/languages`);return JSON.parse(e.trim())}function Pe(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 y from"chalk";async function Et(){h();let t=u(),[e,o]=t.filter(n=>n!=="-v"),i=[];if(F(e)?(i.push(...await M(`${e}^3`)),i.push(...await M(`${e}^2`))):i.push(...await M(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+=y.green(` +${r.added}`)),r.deleted&&(c+=y.red(` -${r.deleted}`)),console.info(c)})}else{let n=new Set(i.map(({file:p})=>p)).size,[r,a]=i.reduce((p,{added:v,deleted:g})=>[p[0]+(v??0),p[1]+(g??0)],[0,0]),c=y.green(`+${r}`),l=y.red(`-${a}`);console.info(`${n} files: ${c} ${l}`)}}var Se=t=>{switch(t){case"modified":return y.yellow;case"added":return y.green;case"deleted":return y.red;default:return e=>e}};async function kt(){let t=await ot();console.log(t)}import{render as qt}from"ink";function Bt(){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 A(){let t=Bt();await s("git add -A"),await f(["commit","-m",`"WIP ${t}"`])}import{nanoid as Ae}from"nanoid";import ve from"chalk";import{jsx as Tt}from"react/jsx-runtime";async function Wt(){let{remote:t,branch:e}=await U(),o=process.argv[3]??e;await C()||await A(),await rt(o,"HEAD")||(console.warn("Conflicts would occur. Not safe to rebranch."),process.exit(1));let i=await w(),n=(async()=>{await B(t,o)})();qt(Tt(m,{msg:`Updating branch ${o}`,promise:n})),await n;let r=`${Ae(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 G(o,r,!0);for(let l of c)try{await s(`git cherry-pick ${l}`)}catch{let p=ve.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}`)})();qt(Tt(m,{msg:`Rewriting branch ${i}`,promise:a})),await a,console.info(`Successfully recreated branch ${i} from ${o}`)}import{execSync as De}from"node:child_process";async function Gt(){H();let t=Ee(process.argv[3]),{default:e}=await import("clipboardy");await e.write(t),console.log(`'${t}' copied to clipboard`)}function Ee(t="HEAD"){return De(`git rev-parse --short ${t}`,{encoding:"utf-8"}).trim()}import{render as ke}from"ink";import{jsx as Be}from"react/jsx-runtime";async function Mt(){let{remote:t,branch:e}=await X();P(t);let{code:o}=await d("git",["show-ref","--branches",e]);o||(console.warn(`Branch '${e}' already exists.`),process.exit(1)),await R();let i=W(t,e);ke(Be(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 Ft(){console.info(await Z())}async function qe(){let{code:t}=await d("npm",["outdated","-g","bisgit"]);return t===0}async function Te(){let{stdout:t}=await s("npm view bisgit version",{encoding:"utf8"});return t.trim()}async function Lt(){if(await qe())return console.info("Already up to date");console.info(`Updating: ${await Z()} -> ${await Te()}`),$("npm",["i","-g","bisgit@latest"])}async function Ht(){let[t,e]=await Promise.allSettled([await Ge("user.name"),await We()]);t.status==="fulfilled"&&console.info(`Git: ${t.value}`),e.status==="fulfilled"&&console.info(`Github: ${e.value}`)}async function We(){let{stdout:t}=await s("gh api user --jq .login");return t.trim()}async function Ge(t){let{stdout:e}=await s(`git config ${t}`);return e.trim()}import{render as Ue}from"ink";import{Text as Me,useApp as Fe,useInput as Le}from"ink";import{useState as He}from"react";import{Fragment as Ne,jsx as Ie,jsxs as It}from"react/jsx-runtime";function Nt({prompt:t,msg:e,onConfirm:o,requireConfirmation:i}){let[n,r]=He(""),{exit:a}=Fe();return Le((c,l)=>{if(n)return;let p=c.toLowerCase();p==="y"||l.return&&!i?r("Yes"):(p==="n"||l.return&&i)&&(r("No"),a())}),It(Ne,{children:[It(Me,{children:[t," [",i?"y/N":"Y/n","] ",n]}),n==="Yes"&&Ie(m,{msg:e,promise:o()})]})}import{jsx as Oe}from"react/jsx-runtime";async function Ut(){if(st(),await C())return console.log("Already a clean working tree");let t=await L();if(!t)throw new Error("git status cmd failed");let e=new Q(t);e.displayReport(),Ue(Oe(Nt,{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 je}from"nanoid";import{render as _e}from"ink";import{jsx as Ve}from"react/jsx-runtime";async function Ot(){await N();let t=process.argv[3]??"origin";P(t);let e=await w();at(e);let o="",n=(async()=>{let r=[s(`git fetch ${t} ${e} --force`)];await C()||r.push(A()),await Promise.all(r);let[a,c]=await Promise.all([q(t,e),T(t,e)]);if(!(a===0&&c===0)){if(a!==0){let l=`${e}-${je(8)}`;o=`Created branch ${l}`,await s(`git branch ${l}`)}await s(`git reset --hard ${t}/${e}`)}})();_e(Ve(m,{msg:`Force pull reseting ${e} -> ${t}`,promise:n})),await n,o&&console.info(o)}var jt={abort:ft,amend:pt,autoprune:dt,backmerge:ut,churn:wt,coauthor:bt,"code-review":Ct,conflict:xt,continue:Pt,exclude:Rt,files:St,fixup:At,include:vt,languages:Dt,lines:Et,pwd:kt,rebranch:Wt,"remote-default":ct,savepoint:A,sha:Gt,track:Mt,update:Lt,"--version":Ft,whoami:Ht,wipe:Ut,yank:Ot};async function ln(t){return await jt[t]?.(),Object.hasOwn(jt,t)}export{ln as runCommand};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{a as m}from"./chunk-NHXDQYDU.js";import{D as s,d as e,s as c}from"./chunk-5AP2OORN.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 ze}from"./chunk-6JGIBU7E.js";import{a as Ie,b as Ke,c as He,e as X,g as $e,h as Ve,k as Ge,q as Ue,s as _e,t as qe,u as Ye,v as Z,y as Qe}from"./chunk-5AP2OORN.js";import{b as C,c as Oe}from"./chunk-OSOEWQKA.js";import{render as ii}from"ink";import{createContext as Co,useContext as Po,useState as Eo}from"react";import{jsx as Ao}from"react/jsx-runtime";var Je=Co(void 0),Xe=({children:e})=>{let[t,r]=Eo({}),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 Ao(Je.Provider,{value:{keybindings:t,setKeybinding:o,removeKeybinding:n},children:e})},T=()=>{let e=Po(Je);if(!e)throw new Error("useKeybindings must be used within a KeybindingsProvider");return e};import{useEffect as ti}from"react";import{Text as oi,Box as To,useInput as ri}from"ink";import{useStdout as Do}from"ink";import{useMemo as Bo}from"react";var Ro=64;function h(){let{stdout:e}=Do(),{keybindings:t}=T(),r=Bo(()=>{let s=Object.entries(t).map(([a,c])=>`[${a}]: ${c}`).join(" ").length;return Math.ceil(s/e.columns)+Math.ceil(Ro/e.columns)},[Object.keys(t).join(",")]),o=e.rows-r,n=Math.floor(o/2),i=e.columns>100?96:e.columns-4;return{width:e.columns,height:e.rows,sectionHeight:o,sectionHalfHeight:n,modalWidth:i}}import{Box as et,Text as No}from"ink";import{useState as ue,createContext as ko,useContext as Lo}from"react";import{jsx as Fo}from"react/jsx-runtime";var $={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"},Q=Object.keys($),Ze=ko({});function je({children:e}){let[t,r]=ue(!1),o=()=>r(!0),n=()=>r(!1),[i,s]=ue("Status"),[a,c]=ue("Staged"),l=f=>{t||(c(f),s($[f]))},m=f=>{t||(s(f),c(f))},d=()=>{t||c(f=>{let b=Q.at((Q.indexOf(f)+1)%Q.length);return s($[b]),b})},v=()=>{t||c(f=>{let b=Q.at(Q.indexOf(f)-1);return s($[b]),b})};return Fo(Ze.Provider,{value:{activeGroup:i,setActiveGroup:m,activeSection:a,setActiveSection:l,prevSection:v,nextSection:d,isLocked:t,lock:o,unlock:n},children:e})}function y(){let e=Lo(Ze);if(Object.keys(e).length===0)throw new Error("useNavContext must be used within a NavProvider");return e}import{memo as Wo}from"react";import{jsx as de}from"react/jsx-runtime";var Oo=Array.from(new Set(Object.values($))),tt=Wo(({activeGroup:e})=>de(et,{width:"100%",flexDirection:"row",flexWrap:"wrap",children:Oo.map((t,r)=>de(et,{borderStyle:"classic",borderLeft:!!r,borderRight:!1,borderTop:!1,borderBottom:!1,children:de(No,{color:t===e?"cyan":"",children:` [${r+1}]: ${t} `})},t))}),(e,t)=>e.activeGroup===t.activeGroup);import{Text as Xn,useInput as Zn}from"ink";import{Box as Hr,useInput as $r}from"ink";import{Box as te,Text as xt,useInput as mr}from"ink";import{createContext as Ko,useContext as Ho}from"react";import{useEffect as Io,useState as pe}from"react";function w(e,t=[]){let[r,o]=pe(void 0),[n,i]=pe(!1),[s,a]=pe(0),c=()=>a(l=>l+1);return Io(()=>{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 $o}from"react/jsx-runtime";var ot=Ko({});function rt({children:e}){let{value:t=[],refresh:r}=w(Qe);return $o(ot.Provider,{value:{status:t,refresh:r},children:e})}function O(){let e=Ho(ot);if(Object.keys(e).length===0)throw new Error("useStatus must be used within an StatusProvider");return e}import{useEffect as ur,useMemo as St}from"react";import{useEffect as zo,useRef as Jo,useState as Xo}from"react";import{Box as Zo,measureElement as jo}from"ink";function nt(e){let{activeSection:t}=y();return{calcSectionHeight:o=>e.includes(t)?t===o?Vo(e.length):Go(e.length):`${100/e.length}%`}}var Vo=e=>{switch(e){case 2:return"75%";case 3:case 4:return"50%";default:throw new Error(`Variable Section Height not configured for ${e}`)}},Go=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{Box as it,measureElement as Uo,Text as st}from"ink";import{useMemo as _o,useRef as qo}from"react";import{Fragment as Yo,jsx as j,jsxs as Qo}from"react/jsx-runtime";function M(e){let{title:t,footer:r,children:o,width:n,height:i,innerHeight:s,isModal:a,backgroundColor:c}=e,{width:l}=h(),m=n??l,d=qo(null),v=_o(()=>{if(!d.current)return 0;let{width:u}=Uo(d.current);return u},[d.current]),f=v-8,b={...e,height:s,width:v},{activeSection:x}=y(),p=x===t||a?"cyan":"";return j(it,{ref:d,flexDirection:"column",height:i,width:m,backgroundColor:c,children:v!==0&&Qo(Yo,{children:[t&&j(st,{color:p,wrap:"truncate-end",children:"\u256D\u2500\u2500\u2500\u2500 "+t+" "+"\u2500".repeat(f-t.length)+"\u256E"}),j(it,{flexDirection:"column",...b,borderStyle:"round",borderColor:p,borderTop:!t,borderBottom:!r,paddingLeft:1,children:o}),r&&j(st,{color:p,wrap:"truncate-end",children:"\u2570"+"\u2500".repeat(f-r.length)+" "+r+" \u2500\u2500\u2500\u2500\u256F"})]})})}import{jsx as at}from"react/jsx-runtime";function ee({title:e,sections:t,children:r}){let o=Jo(null),{activeSection:n}=y(),[i,s]=Xo(0);zo(()=>{if(o.current){let{height:c}=jo(o.current);s(c-1)}},[o.current,n]);let{calcSectionHeight:a}=nt(t);return at(Zo,{ref:o,height:a(e),children:at(M,{title:e,innerHeight:i,children:r(i)})})}import{useEffect as ct,useRef as er,useState as fe}from"react";function L(e,t){let[r,o]=fe(0),[n,i]=fe(0),s=er(void 0),[a,c]=fe(0),l=()=>c(p=>p+1);ct(()=>{let p=0;if(s.current!==void 0){let g=e.findIndex(S=>S===s.current);g>=0&&(p=g)}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]),ct(()=>{s.current=e[n]},[n,e]);let m=Math.max(0,e.length-t),d=e.length-1,v=()=>{i(p=>{let u=Math.min(p+1,d);return o(g=>u>=g+t?Math.min(g+1,m):g),u})},f=()=>{i(p=>{let u=Math.max(p-1,0);return o(g=>u<g?Math.max(g-1,0):g),u})},b=e.slice(r,r+t),x=e[n];return{scrollDown:v,scrollUp:f,outList:b,selectedIndex:n,renderedIndex:n-r,selectedValue:x,refresh:l}}import{useInput as tr}from"ink";import{createContext as or,useContext as rr}from"react";import{useEffect as dt,useState as lt}from"react";import{jsx as nr}from"react/jsx-runtime";var mt="\u2190",ut="\u2192",pt=or({});function ft({children:e}){let[t,r]=lt("truncate-end"),[o,n]=lt(0),{removeKeybinding:i,setKeybinding:s}=T();return dt(()=>(o&&(t==="truncate-start"?s(mt,"pan left"):s(ut,"pan right")),()=>{i([ut,mt])}),[t,o]),tr((a,c)=>{o&&(c.rightArrow?r("truncate-start"):c.leftArrow&&r("truncate-end"))}),nr(pt.Provider,{value:{mode:t,_isToggleable:o,_setIsToggleable:n},children:e})}function D(){let e=rr(pt);if(Object.keys(e).length===0)throw new Error("useTruncationMode must be used within an TruncationModeProvider");let{mode:t,_setIsToggleable:r}=e;return dt(()=>(r(o=>o+1),()=>r(o=>o-1)),[]),{mode:t}}import{createContext as ir,useContext as sr,useEffect as ar,useState as cr}from"react";import{jsx as lr}from"react/jsx-runtime";var gt=ir({});function ht({children:e}){let[t,r]=cr(),o=(n,...i)=>{n(...i).catch(s=>r(s.stderr??s.message))};return ar(()=>{if(t)throw new Error(t)},[t]),lr(gt.Provider,{value:{attempt:o,err:t},children:e})}function B(){let e=sr(gt);if(Object.keys(e).length===0)throw new Error("useErrorCatcher must be used within an ErrorCatcherProvider");return e}import{Fragment as gr,jsx as A,jsxs as wt}from"react/jsx-runtime";var yt=e=>e.staged,vt=e=>e.changeType.includes("U"),dr=e=>!yt(e)&&!vt(e);function bt(){let{status:e}=O(),{sectionHeight:t}=h(),{sections:r,showMerged:o}=St(()=>{let n=e.some(({changeType:s})=>s==="U"),i=["Staged","Changes"];return n&&i.push("Unmerged"),{sections:i,showMerged:n}},[e]);return wt(te,{width:"50%",height:t,flexDirection:"column",children:[A(ee,{title:"Staged",sections:r,children:n=>A(ge,{sectionHeight:n,title:"Staged",filterCondition:yt})}),A(ee,{title:"Changes",sections:r,children:n=>A(ge,{sectionHeight:n,title:"Changes",filterCondition:dr})}),o&&A(ee,{title:"Unmerged",sections:r,children:n=>A(ge,{sectionHeight:n,title:"Unmerged",filterCondition:vt})})]})}function ge({sectionHeight:e,filterCondition:t,title:r}){let{isLocked:o,activeSection:n}=y(),{mode:i}=D(),{status:s,refresh:a}=O(),c=St(()=>s.filter(t),[s]),{selectedValue:l,outList:m,scrollDown:d,scrollUp:v}=L(c,e),{attempt:f}=B(),b=n==="Staged",x=n==="Changes"||n==="Unmerged",{setKeybinding:p,removeKeybinding:u}=T();return ur(()=>(b?p("a","unstage"):x&&p("a","stage"),()=>u("a")),[n]),mr((g,S)=>{n!==r||o||(S.upArrow?v():S.downArrow&&d(),l&&g==="a"&&(b?f(()=>fr(l.name)):x&&f(()=>pr(l.name)),a()))}),A(gr,{children:m.map(({name:g})=>wt(te,{flexDirection:"row",flexWrap:"nowrap",children:[A(te,{minWidth:2,children:g===l?.name?A(xt,{children:"> "}):null}),A(te,{minWidth:8,children:A(xt,{wrap:i,children:g})})]},g))})}async function pr(e){await C(`git add "${e}"`)}async function fr(e){await C(`git restore --staged "${e}"`)}import{jsx as yr}from"react/jsx-runtime";async function hr(){let[e,{remote:t}]=await Promise.all([X(),ze()]),[r,o]=await Promise.all([$e(t,e),Ve(t,e)]);return[r,o]}var xr="\u2191",Sr="\u2193";function Tt(){let{sectionHeight:e}=h(),{value:[t,r]=[]}=w(hr);return yr(M,{title:"Status",width:"50%",innerHeight:e-2,footer:`${r??0}${Sr} ${t??0}${xr}`,children:null})}import{useEffect as Lt}from"react";import{useState as Nr}from"react";import{useInput as Wr}from"ink";import Or from"ink-text-input";import{useInput as vr}from"ink";import{createContext as br,useContext as wr,useEffect as Tr,useState as he}from"react";import{Fragment as Mr,jsx as Pr,jsxs as Cr}from"react/jsx-runtime";var Mt=br({});function P(){let e=wr(Mt);if(Object.keys(e).length===0)throw new Error("useKeybindings must be used within a KeybindingsProvider");return e}function Ct({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)},d=()=>{i?l():m()},v=(x,p)=>{l(),c(p?.onClose),r(x)};vr((x,p)=>{p.escape&&l()});let{setKeybinding:f,removeKeybinding:b}=T();return Tr(()=>{if(i)return f("esc","close"),()=>{b("esc")}},[i]),Pr(Mt.Provider,{value:{setModal:v,open:m,close:l,toggle:d,isOpen:i},children:Cr(Mr,{children:[e,t]})})}import{Box as Bt}from"ink";import xe from"node:path";import Se from"node:os";import Er from"node:fs/promises";import{createContext as Ar,useContext as Dr}from"react";import{jsx as Lr}from"react/jsx-runtime";var Pt=Ar({});function Et({children:e,bgColor:t}){return Lr(Pt.Provider,{value:{bgColor:t},children:e})}var At=()=>{let e=Dr(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 kr();let e=Br();return(!process.stdin.isRaw||process.stdin.isPaused())&&(console.error("Error querying the terminal background color"),process.exit(1)),e}async function Br(){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(Rr(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 Rr(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 kr(){let e="Code";process.env.TERM_PROGRAM_VERSION?.includes("insider")&&(e="Code - Insiders");let t;switch(process.platform){case"win32":t=xe.join(Se.homedir(),"AppData","Roaming",e,"User","settings.json");break;case"linux":t=xe.join(Se.homedir(),".config",e,"User","settings.json");break;case"darwin":t=xe.join(Se.homedir(),"Library","Application Support",e,"User","settings.json");break;default:return}if(!await Ie(t))return;let r=await Er.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 Fr=36;function V({children:e,title:t,width:r=Fr}){let o=h(),{width:n}=o,{bgColor:i}=At(),s=n<r?n-2:r,a=n<r?1:Math.floor((n-r)/2);return ye(Bt,{...o,position:"absolute",children:ye(Bt,{alignSelf:"center",marginLeft:a,marginRight:a,children:ye(M,{title:t,width:s,isModal:!0,backgroundColor:i,children:e})})})}import{jsx as Rt}from"react/jsx-runtime";function G({title:e,handleSubmit:t,width:r}){let[o,n]=Nr(""),{isOpen:i,close:s}=P();return Wr((a,c)=>{c.return&&i&&(t(o),n(""),s())}),i&&Rt(V,{title:e,width:r,children:Rt(Or,{value:o,onChange:n})})}import{useInput as Ir}from"ink";import Kr from"ink-select-input";import{jsx as kt}from"react/jsx-runtime";function oe({title:e,handleSubmit:t,options:r,initialIndex:o,width:n}){let{isOpen:i,close:s}=P();return Ir((a,c)=>{c.return&&i&&s()}),i&&kt(V,{title:e,width:n,children:kt(Kr,{items:r,onSelect:t,initialIndex:o})})}import{jsx as ve,jsxs as Vr}from"react/jsx-runtime";function Ft(){let{width:e,sectionHeight:t}=h(),{status:r,refresh:o}=O();Lt(()=>{o()},[]);let{setKeybinding:n,removeKeybinding:i}=T();Lt(()=>(n("r","refresh"),n("c","commit"),()=>i(["r","c"])),[]);let{setModal:s,open:a}=P(),{attempt:c}=B(),l=m=>{m=m.trim(),m&&c(async()=>{if(!r.find(({staged:d})=>d))throw new Error("Nothing to commit");await C(`git commit -m "${m}"`),o()})};return $r((m,d)=>{m==="r"?o():m==="c"&&(s(ve(G,{title:"Commit Message",handleSubmit:l,width:54})),a())}),Vr(Hr,{width:e,height:t,flexDirection:"row",children:[ve(bt,{}),ve(Tt,{})]})}import{useEffect as _t,useState as qt}from"react";import{Box as ln,useInput as mn}from"ink";import{Text as Gr}from"ink";import{jsx as Nt}from"react/jsx-runtime";function Wt({sha:e}){let{resolved:t,value:r}=w(()=>Ur(e),[e]);return Nt(M,{title:"Commit Details",width:"50%",height:"100%",children:e&&t&&Nt(Gr,{children:r})})}async function Ur(e){if(!e)return;let{stdout:t}=await C(`git show ${e} --name-only`);return t.trim()}import{useCallback as Zr,useEffect as jr}from"react";import{Box as re,Text as we,useInput as en}from"ink";import{createContext as _r,useContext as qr,useEffect as Ot,useMemo as Yr,useRef as It,useState as Kt}from"react";import{useInput as Qr}from"ink";import{jsx as Xr}from"react/jsx-runtime";var Ht=_r({});function $t({children:e}){let{activeSection:t}=y(),{sectionHeight:r}=h(),o=r-3,{value:{tree:n,files:i}={},resolved:s}=w(zr),a=It(new Set),c=It(new Set(["."])),[l,m]=Kt();Ot(()=>{n&&i&&(a.current=new Set(Object.keys(n)),m(i[0]))},[s]);let d=Yr(()=>i?.filter(x=>a.current.has(x))??[],[a.current.size,s]),[v,f]=Kt(0),b=()=>f(x=>x+1);return Qr((x,p)=>{if(t!=="Files"||!n||!l)return;if(p.upArrow){let g=Math.max(0,d.indexOf(l)-1);m(d[g]),b()}else if(p.downArrow){let g=Math.min(d.length-1,d.indexOf(l)+1);m(d[g]),b()}let u;if(p.leftArrow?u="collapse":p.rightArrow&&(u="expand"),u){let g=be(n,l);if(!g)return;for(let S of Object.keys(g)){let E=`${l}/${S}`;u==="expand"?a.current.add(E):a.current.delete(E)}b()}}),Ot(()=>{if(c.current.clear(),c.current.add("."),d.length<=o){d.forEach(Y=>c.current.add(Y));return}let x=l?Jr(l):[],p=Math.max(1,o-x.length),u=d.filter(Y=>!x.includes(Y)),g=l?u.indexOf(l):0,S=Math.max(0,g-Math.floor(p/2)),E=S+p;E>u.length&&(E=u.length,S=Math.max(0,E-p));let J=u.slice(S,E);[...x,...J].forEach(Y=>{c.current.add(Y)})},[d.length,l,o]),Xr(Ht.Provider,{value:{version:v,tree:n,visibleFiles:c.current,expandedFiles:a.current,selectedFile:l},children:e})}function k(){let e=qr(Ht);if(Object.keys(e).length===0)throw new Error("useTreeNavigation must be used within an TreeNavigationProvider");return e}var be=(e,t)=>{let r=t.split("/"),o=e;for(let n of r)o=o[n];return o},zr=async()=>{let e=await Ke(),t=He(e);return{tree:e,files:t}},Jr=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 I,jsxs as on}from"react/jsx-runtime";function Vt({setSha:e,mode:t}){let{label:r,value:o}=t,{sectionHeight:n}=h(),{activeSection:i,isLocked:s}=y(),{selectedFile:a}=k(),{mode:c}=D(),l=Zr(()=>o.length&&a?o(a):o(),[o,a]),{resolved:m,value:d=[]}=w(l,[r]),{scrollUp:v,scrollDown:f,outList:b,selectedValue:x,renderedIndex:p}=L(d,n-2),u=x?.sha;jr(()=>{e(u)},[u]),en((S,E)=>{i!=="Log"||s||(E.upArrow?v():E.downArrow&&f())});let g=tn.includes(t.label);return I(M,{overflowY:"hidden",height:"100%",title:"Log",width:"50%",children:m&&b.map(({sha:S,message:E},J)=>on(re,{flexDirection:"row",flexWrap:"nowrap",children:[I(re,{minWidth:2,children:S===u?I(we,{color:g&&J===p?"magenta":void 0,children:"> "}):null}),I(re,{minWidth:8,children:I(we,{color:"yellow",children:S})}),I(re,{children:I(we,{wrap:c,children:E})})]},`${S}-${t.label}${g?J:""}`))})}var tn=["blame","reflog"];var _=[{value:()=>U("git log --oneline -n 400"),label:"log"},{value:()=>U("git log --oneline --tags --no-walk --decorate"),label:"tags"},{value:()=>U("git reflog"),label:"reflog"},{value:()=>U('git log --oneline --author="$(git config user.name)"'),label:"my commits"},{value:e=>U(`git log --oneline "${e}"`),label:"file"},{value:e=>U(`git blame --follow "${e}"`),label:"blame"}];async function U(e){let{stdout:t}=await C(e);return t.trim().split(/\r?\n/).map(rn)}function rn(e){let t=e.indexOf(" ");return{sha:e.slice(0,t),message:e.slice(t+1)}}import{createContext as nn,useContext as sn,useState as an}from"react";import{jsx as cn}from"react/jsx-runtime";var Gt=nn({});function Ut({children:e}){let[t,r]=an(),o=i=>r(i),n=i=>{let s=t===i;return s&&r(void 0),s};return cn(Gt.Provider,{value:{sendMessage:o,receiveMessage:n},children:e})}function ne(){let e=sn(Gt);if(Object.keys(e).length===0)throw new Error("useMessaging must be used within an MessagingProvider");return e}import{jsx as Te,jsxs as un}from"react/jsx-runtime";function Me(){let{setModal:e,toggle:t}=P(),[r,o]=qt(),{width:n,sectionHeight:i}=h(),[s,a]=qt(_[0]),{receiveMessage:c}=ne();_t(()=>{c("log-file")&&a(_[4]),c("blame-file")&&a(_[5])},[]);let{isLocked:l}=y(),{attempt:m}=B();mn((f,b)=>{f==="m"&&(e(Te(oe,{options:_,title:"Log Type",handleSubmit:x=>a(x),initialIndex:_.indexOf(s)})),t()),!l&&f==="c"&&r&&m(()=>C(`git checkout ${r}`))});let{setKeybinding:d,removeKeybinding:v}=T();return _t(()=>(d("c","checkout"),d("m","mode"),()=>{v(["c","m"])}),[]),un(ln,{width:n,height:i,children:[Te(Vt,{setSha:o,mode:s}),Te(Wt,{sha:r})]})}import{useEffect as vn}from"react";import{Box as Zt}from"ink";import{Box as Ce,Text as Yt,useInput as dn}from"ink";import{useEffect as pn}from"react";import{Fragment as gn,jsx as K,jsxs as fn}from"react/jsx-runtime";function Qt(){let{activeSection:e,isLocked:t}=y(),{sectionHalfHeight:r}=h(),{value:o=[],refresh:n}=w(_e),{value:i,refresh:s}=w(X),{setKeybinding:a,removeKeybinding:c}=T();pn(()=>{if(e==="Branches")return a("s","switch"),()=>{c("s")}},[e]);let{outList:l,selectedValue:m,scrollUp:d,scrollDown:v}=L(o,r-2),f=async S=>{await C(`git branch ${S}`),n()},b=async()=>{await C(`git branch -D ${m}`),n()},x=async()=>{await C(`git switch ${m}`),n(),s()},{setModal:p,open:u}=P(),{attempt:g}=B();return dn((S,E)=>{e!=="Branches"||t||(E.upArrow?d():E.downArrow?v():S==="c"?(p(K(G,{title:"Name your new branch",handleSubmit:f})),u()):S==="d"?g(b):S==="s"&&g(x))}),K(gn,{children:K(M,{width:"100%",title:"Branches",innerHeight:r-1,children:l.map(S=>fn(Ce,{flexDirection:"row",flexWrap:"nowrap",children:[K(Ce,{minWidth:2,children:S===m?K(Yt,{children:"> "}):null}),K(Ce,{children:K(Yt,{color:S===i?"magenta":void 0,children:S})})]},S))})})}import{Text as Pe}from"ink";import{Fragment as hn}from"react";import{jsx as Ee,jsxs as zt}from"react/jsx-runtime";function Jt(){let{value:e}=w(qe);return Ee(M,{width:"50%",title:"Remotes",children:e?.map(({url:t,name:r,type:o})=>zt(hn,{children:[zt(Pe,{wrap:"truncate-end",children:[r," (",o,")"]}),Ee(Pe,{wrap:"truncate-end",children:t}),Ee(Pe,{children:" "})]},`${r}-${o}`))})}import{Text as Ae}from"ink";import{Fragment as xn}from"react";import{jsx as ie,jsxs as yn}from"react/jsx-runtime";function Xt(){let{sectionHalfHeight:e}=h(),{value:t}=w(Sn);return ie(M,{width:"100%",title:"Worktrees",innerHeight:e-1,children:t?.map(({branch:r,detached:o,path:n,head:i})=>yn(xn,{children:[ie(Ae,{children:o?i:r}),ie(Ae,{children:n}),ie(Ae,{children:" "})]},n))})}async function Sn(){let{stdout:e}=await C("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 bn,jsx as se,jsxs as jt}from"react/jsx-runtime";function eo(){let{width:e,sectionHeight:t}=h(),{setKeybinding:r,removeKeybinding:o}=T();return vn(()=>(r("c","create"),r("d","delete"),()=>{o(["c","d"])}),[]),se(bn,{children:jt(Zt,{width:e,height:t,children:[jt(Zt,{flexDirection:"column",width:"50%",height:t,children:[se(Qt,{}),se(Xt,{})]}),se(Jt,{})]})})}import{Component as wn,useEffect as Tn}from"react";import{Text as to}from"ink";import{jsx as De}from"react/jsx-runtime";function ae({title:e,message:t,width:r}){let{isOpen:o}=P(),{mode:n}=D();return o&&De(V,{title:e,width:r,children:Array.isArray(t)?t.map(i=>De(to,{wrap:n,children:i})):De(to,{children:t})})}import{jsx as oo}from"react/jsx-runtime";var ce=class extends wn{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?oo(Mn,{dismissError:this.dismissError.bind(this),message:this.state.message,children:this.props.children}):this.props.children}};function Mn({message:e,dismissError:t,children:r}){let{setModal:o,open:n}=P(),{modalWidth:i}=h();return Tn(()=>{if(e){let s=e.split(/\r?\n/).map(a=>a.trim());o(oo(ae,{title:"Error",message:s,width:i}),{onClose:t}),n()}},[e]),r}import{Box as Wn,useInput as On}from"ink";import{useEffect as In}from"react";import{Box as Be,Text as so}from"ink";import Re from"node:path";import{memo as Cn,useEffect as ro,useState as Pn}from"react";import{Fragment as Bn,jsx as F,jsxs as ke}from"react/jsx-runtime";var En="\u2190",An="\u2191",ao="\u2192",co="\u2193",no=`${En}${An}${co}${ao}`;function lo(){let{sectionHeight:e}=h(),{activeSection:t}=y(),{setKeybinding:r,removeKeybinding:o}=T();ro(()=>{if(t==="Files")return r(no,"navigate"),()=>o(no)},[t]);let{tree:n,version:i}=k(),{value:s}=w(Ge),[,a]=Pn(0);return ro(()=>{a(c=>c+1)},[i]),F(M,{title:"Files",innerHeight:e,width:"50%",children:s&&n&&F(mo,{name:Re.basename(s),contents:n,depth:0,fp:s})})}function mo(e){let{contents:t,depth:r,fp:o,rp:n="."}=e,i=Object.keys(t).length===0,{selectedFile:s,visibleFiles:a,expandedFiles:c}=k(),l=n===s;if(!a.has(n))return null;let m=r+2;if(i)return F(io,{...e,depth:m,isSelected:l},o);let d=`${n}/`,v=Dn(c,f=>f.startsWith(d))||r===0;return ke(Bn,{children:[ke(Be,{flexDirection:"row",flexWrap:"nowrap",children:[F(Be,{width:2,children:F(so,{children:v?co:ao})}),F(Be,{width:"100%",children:F(io,{...e,isSelected:l})})]}),v&&Object.entries(t).map(([f,b])=>{let x=Re.join(n,f),p=Re.join(o,f);return F(mo,{name:f,contents:b,depth:m,rp:x,fp:p})})]})}var io=Cn(({name:e,depth:t,isSelected:r})=>ke(so,{wrap:"truncate-end",color:r?"yellow":void 0,children:["\xA0".repeat(t),e]}),(e,t)=>e.isSelected===t.isSelected&&e.fp===t.fp);function Dn(e,t){for(let r of e)if(t(r))return!0;return!1}import{Box as po,Text as H}from"ink";import{Box as Rn,measureElement as kn,Text as uo}from"ink";import{useMemo as Ln,useRef as Fn}from"react";import{jsx as Le}from"react/jsx-runtime";function le({text:e}){let t=Fn(null),r=Ln(()=>{if(!t.current)return 0;let{width:a}=kn(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 Le(Rn,{width:"100%",ref:t,children:e.length>r?Le(uo,{children:e}):Le(uo,{children:s})})}import{jsx as Fe,jsxs as N}from"react/jsx-runtime";function fo(){let{sectionHeight:e}=h(),{selectedFile:t}=k(),{value:r={}}=w(()=>Ye(t),[t]),{authorDate:o,authorEmail:n,authorName:i,shortHash:s}=r,{value:{added:a,deleted:c}={},resolved:l}=w(async()=>Nn(s,t),[s,t]),{mode:m}=D();return Fe(po,{width:"50%",height:e,children:N(M,{width:"100%",title:"File Meta",innerHeight:e-1,children:[t&&Fe(le,{text:t}),s&&N(H,{wrap:m,children:["Last Commit: ",s]}),i&&N(H,{wrap:m,children:["Edited By: ",i]}),o&&N(H,{wrap:m,children:["Edit On: ",o]}),n&&N(H,{wrap:m,children:["Contact: ",n]}),l&&(a||c)&&N(po,{flexDirection:"row",flexWrap:"nowrap",children:[Fe(H,{children:"Changes:\xA0"}),N(H,{color:"green",children:["+",a??0,"\xA0"]}),N(H,{color:"red",children:["-",c??0]})]})]})})}var Nn=async(e,t)=>!e||!t?{}:(await Z(e)).find(({file:o})=>t===o)??{};import{jsx as Ne,jsxs as Kn}from"react/jsx-runtime";function go(){let{width:e,sectionHeight:t}=h(),{selectedFile:r,tree:o}=k(),{setKeybinding:n,removeKeybinding:i}=T();In(()=>(n("l","log"),n("b","blame"),()=>{i(["l","b"])}),[]);let{setActiveGroup:s}=y(),{sendMessage:a}=ne(),{setModal:c,open:l}=P();return On((m,d)=>{m==="l"?(a("log-file"),s("Log")):m==="b"&&(Object.keys(be(o??{},r)).length===0?(a("blame-file"),s("Log")):(c(Ne(ae,{title:"Sorry",message:["Can't blame a folder."]})),l()))}),Kn(Wn,{width:e,height:t,children:[Ne(lo,{}),Ne(fo,{})]})}import{Box as Yn}from"ink";import{Box as ho,Text as xo,useInput as Hn}from"ink";import{useEffect as $n}from"react";import{jsx as q,jsxs as Gn}from"react/jsx-runtime";function So({setStash:e}){let{sectionHeight:t}=h(),{mode:r}=D(),{attempt:o}=B(),{setModal:n,open:i}=P(),{activeSection:s,isLocked:a}=y(),{value:c=[],refresh:l}=w(Vn),{outList:m,selectedValue:d,selectedIndex:v,scrollUp:f,scrollDown:b}=L(c,t-2);$n(()=>{e(`stash@{${v}}`)},[v]);let x=u=>async()=>{await C(`git stash ${u} stash@{${v}}`),l()},p=async()=>{let u=`stash@{${v}}`,g=await Ue(u);n(q(G,{title:`reword ${u}`,handleSubmit:async S=>{await C(`git stash drop ${u}`),await C(`git stash store ${g} -m "${S}"`),l()}})),i()};return Hn((u,g)=>{a||(u==="s"?(n(q(oe,{title:"Stash",options:[{value:"git stash",label:"tracked only"},{value:"git stash -u",label:"tracked & untracked"}],handleSubmit:({value:S})=>o(async()=>{await C(S),l()})})),i()):u==="a"?o(x("apply")):u==="p"?o(x("pop")):u==="d"?o(x("drop")):u==="r"&&o(p),s==="Stashes"&&(g.upArrow?f():g.downArrow&&b()))}),q(M,{title:"Stashes",width:"50%",height:"100%",children:m.map(u=>Gn(ho,{flexDirection:"row",flexWrap:"nowrap",children:[q(ho,{minWidth:2,children:u===d?q(xo,{children:"> "}):null}),q(xo,{wrap:r,children:u})]},u))})}async function Vn(){return await Oe("git stash list")}import{Box as Un,Text as We}from"ink";import{jsx as qn,jsxs as z}from"react/jsx-runtime";function yo({stash:e}){let{value:t=[]}=w(()=>_n(e),[e]);return z(M,{title:"Stash Details",width:"50%",height:"100%",children:[e&&qn(le,{text:e}),t.map(({file:r,added:o,deleted:n,changeType:i})=>i!=="binary"&&z(Un,{flexDirection:"row",flexWrap:"nowrap",children:[z(We,{children:[r,":\xA0"]}),z(We,{color:"green",children:["+",o??0,"\xA0"]}),z(We,{color:"red",children:["-",n??0]})]}))]})}async function _n(e){if(e)return await Z(e)}import{useEffect as Qn,useState as zn}from"react";import{jsx as vo,jsxs as Jn}from"react/jsx-runtime";function bo(){let{sectionHeight:e,width:t}=h(),[r,o]=zn(),{setKeybinding:n,removeKeybinding:i}=T();return Qn(()=>(n("s","stash"),n("d","drop"),n("a","apply"),n("p","pop"),n("r","reword"),()=>i(["s","p","d","a","r"])),[]),Jn(Yn,{width:t,height:e,children:[vo(So,{setStash:o}),vo(yo,{stash:r})]})}import{jsx as R,jsxs as ei}from"react/jsx-runtime";function wo(){let{prevSection:e,nextSection:t,activeGroup:r,setActiveGroup:o,setActiveSection:n,activeSection:i}=y(),{status:s}=O(),a=s.some(({changeType:c})=>c==="U");return Zn((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")}),R(ce,{children:R(ht,{children:R(Ut,{children:R($t,{children:R(jn,{group:r})})})})})}function jn({group:e}){switch(e){case"Files":return R(go,{});case"Status":return R(Ft,{});case"Log":return R(Me,{});case"Branches":return R(eo,{});case"Stashes":return R(bo,{});default:return ei(Xn,{children:['Error, unknown page "',e,'"']})}}import{jsx as me,jsxs as ni}from"react/jsx-runtime";function Mo(){let{isLocked:e,activeGroup:t}=y();ri((i,s)=>{e||i.toLowerCase()==="q"&&process.exit()});let r=h(),{keybindings:o,setKeybinding:n}=T();return ti(()=>n("q","quit"),[]),ni(To,{flexDirection:"column",...r,children:[me(tt,{activeGroup:t}),me(wo,{}),me(To,{flexDirection:"row",children:Object.entries(o).map(([i,s])=>me(oi,{children:`[${i}]: ${s} `},s))})]})}import{jsx as W}from"react/jsx-runtime";function si(){return W(je,{children:W(Xe,{children:W(ft,{children:W(Ct,{children:W(rt,{children:W(Mo,{})})})})})})}var Jm=async()=>{let e=await Dt();ii(W(Et,{bgColor:e,children:W(si,{})}),{patchConsole:!0,incrementalRendering:!0})};export{Jm as renderApp};
|
package/dist/main.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as o,b as n}from"./chunks/chunk-5WTQIRZS.js";import{
|
|
2
|
+
import{a as o,b as n}from"./chunks/chunk-5WTQIRZS.js";import{z as e}from"./chunks/chunk-5AP2OORN.js";import"./chunks/chunk-OSOEWQKA.js";async function c(){let r=o();if(!r){e();let{renderApp:t}=await import("./chunks/pages-CVHDGNIL.js");return t()}if(n().length===0){let{runOverload:t}=await import("./chunks/overloads-3UYKGKZT.js");if(await t(r))return}let{runCommand:i}=await import("./chunks/commands-YR3ZU55X.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.
|
|
3
|
+
"version": "0.10.0",
|
|
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": "^
|
|
45
|
-
"@types/react": "^19.2.
|
|
46
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
47
|
-
"@typescript-eslint/parser": "^8.
|
|
48
|
-
"esbuild": "^0.27.
|
|
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.
|
|
51
|
+
"eslint": "^9.39.3",
|
|
52
52
|
"eslint-plugin-import": "^2.32.0",
|
|
53
53
|
"husky": "^9.1.7",
|
|
54
|
-
"lint-staged": "^16.2
|
|
54
|
+
"lint-staged": "^16.3.2",
|
|
55
55
|
"npm-run-all": "^4.1.5",
|
|
56
56
|
"prettier": "^3.8.1",
|
|
57
|
-
"react-devtools-core": "^
|
|
57
|
+
"react-devtools-core": "^7.0.1"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
60
|
"chalk": "^5.6.2",
|
|
61
|
-
"clipboardy": "^5.1
|
|
62
|
-
"ink": "^6.
|
|
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{a as o,l as s,n as i}from"./chunk-NYHXXPP7.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};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{b as n,c,d as m}from"./chunk-OSOEWQKA.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,13 +0,0 @@
|
|
|
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 R,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-5MVENPOO.js";import{a as C,d as w,e as tt,f as W,g as G,h as k,i as et,j as ot,k as rt,m as M,n as x,o as F,p as P,q as it,r as nt,s as H,t as st,w as L,x as I}from"./chunk-NYHXXPP7.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 F(),e=/^(UU|DU|UD)/;return!!t?.some(o=>e.test(o))}async function j(){let t=await et(),[e,o,n,r,i]=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:n,cherryPick:r,revert:i}}async function ft(){let{merge:t,rebaseMerge:e,rebaseApply:o,cherryPick:n,revert:r}=await j(),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 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 ${i}`),await f([i,"--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:n}=Kt();return Jt(()=>{n()},[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,n,r]=await Promise.all([W(t,e),G(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 T(){R(),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((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 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()=>{await f(["fetch","--prune","--prune-tags"]),await q(e,t)})();oe(ie(m,{msg:"Fetching and pruning remote references",promise:o})),await o;let n=await st();for(let r of n){if(r===t||re.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 ne}from"node:child_process";import{createInterface as se}from"node:readline/promises";async function yt(){R;let e=[...(await ae()).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 ae(){let{promise:t,resolve:e,reject:o}=Promise.withResolvers(),n=new Map,r=ne("git",["log","--all","-M","-C","--name-only","--format=format:"]),i=se({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 $t}from"ink";import{jsx as Ct}from"react/jsx-runtime";async function xt(){await v();let t=u()[0];if(!t){let i=(await me()).map(c=>({value:c,label:`${c.name} ${c.email} (${c.commits})`}));$t(Ct(mt,{items:i,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 r=await ce(t);return r.email||(console.error(`Couldn't find an email for ${t}`),process.exit(1)),r})();$t(Ct(m,{msg:"Fetching name and email",promise:e}));let{name:o,email:n}=await e;bt(o,n)}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[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 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 Pt(){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 fe("HEAD")})();z(J(m,{msg:"Creating an editable, explorable, local PR experience",promise:i}));let[a,c]=await Promise.all([i,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 ${n}`),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?\(-\))?/,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 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 Rt(){let t=y("Error: missing target branch argument"),e=await P("HEAD",t),{promise:o,resolve:n,reject:r}=Promise.withResolvers(),i=ge("git",["merge-tree",e,"HEAD",t]),a=ue({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 At(){let{merge:t,rebaseMerge:e,rebaseApply:o,cherryPick:n,revert:r}=await j(),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 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 I(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 n=(await H(`${e}^`,"HEAD",!0)).map(i=>$e(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 $e(t){let{stdout:e}=await s(`git diff ${t}^ ${t}`),{promise:o,resolve:n,reject:r}=Promise.withResolvers(),i=ye("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 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 r=(await be(t,"utf-8")).split(/\r?\n/).map(a=>a.trim()),i=r.filter(a=>!o.includes(a));await Ce(t,i.join(`
|
|
7
|
-
`)),console.info(`
|
|
8
|
-
Removed ${r.length-i.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 r=await Pe();return await Re(r)})();xe(ve(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)}% - ${Ae(i)}`);console.log(n.join(`
|
|
9
|
-
`))}async function Pe(){let{stdout:t}=await s("gh repo view --json nameWithOwner -q .nameWithOwner");return t.trim()}async function Re(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,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 Bt(){y();let t=u(),[e,o]=t.filter(r=>r!=="-v"),n=[];if(I(e)?(n.push(...await L(`${e}^3`)),n.push(...await L(`${e}^2`))):n.push(...await L(e,o)),t.includes("-v")){let r={added:"A",modified:"M",deleted:"D",binary:"B"};n.forEach(i=>{let c=`${Se(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 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 n=await w(),r=(async()=>{await q(t,o)})();Wt(Gt(m,{msg:`Updating branch ${o}`,promise:r})),await r;let i=`${De(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 H(o,i,!0);for(let l of c)try{await s(`git cherry-pick ${l}`)}catch{let p=Ee.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}`)})();Wt(Gt(m,{msg:`Rewriting branch ${n}`,promise:a})),await a,console.info(`Successfully recreated branch ${n} from ${o}`)}import{execSync as ke}from"node:child_process";async function Ft(){R();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),await A();let o=M(t,e);qe(Te(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 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:n}){let[r,i]=Ne(""),{exit:a}=Le();return Ie((c,l)=>{if(r)return;let p=c.toLowerCase();p==="y"||l.return&&!n?i("Yes"):(p==="n"||l.return&&n)&&(i("No"),a())}),Ut(je,{children:[Ut(He,{children:[t," [",n?"y/N":"Y/n","] ",r]}),r==="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 F();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 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 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="",r=(async()=>{let i=[s(`git fetch ${t} ${e} --force`)];await x()||i.push(S()),await Promise.all(i);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:r})),await r,o&&console.info(o)}var Vt={abort:ft,amend:pt,autoprune:ht,backmerge:ut,churn:yt,coauthor:xt,"code-review":Pt,conflict:Rt,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};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{a as s}from"./chunk-NHXDQYDU.js";import{e as c}from"./chunk-5MVENPOO.js";import{t as a}from"./chunk-NYHXXPP7.js";import{b as e,c as n}from"./chunk-OSOEWQKA.js";async function m(){let[i,r]=await Promise.all([await n("git config --list --global"),await n("git config --list --local")]);return[...i,...r].filter(Boolean).map(t=>t.trim()).filter(t=>!t.startsWith("alias")).map(t=>{let o=t.indexOf("=");if(o===-1)return[t,""];let g=t.slice(0,o),w=t.slice(o+1);return[g,w]})}import u from"chalk";async function l(){let i=await m();for(let[r,t]of i)console.info(`${u.yellow(r)} = ${t}`)}import{render as h}from"ink";import{jsx as d}from"react/jsx-runtime";async function f(){await c();let r=(await a()).map(o=>({value:o,label:o}));h(d(s,{prompt:"Which branch would you like to switch to?",items:r,onSelect:async({value:o})=>{await e(`git switch ${o}`)}}))}var p={switch:f,config:l};async function q(i){return await p[i]?.(),Object.hasOwn(p,i)}export{q as runOverload};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{a as Re,b as Ne,c as Fe,d as We,j as Oe,o as ae,r as Ie,t as Ke,u as $e,v as Ge,w as Q}from"./chunk-NYHXXPP7.js";import{b as P,c as Le}from"./chunk-OSOEWQKA.js";import{render as yn}from"ink";import{createContext as no,useContext as io,useState as so}from"react";import{jsx as ao}from"react/jsx-runtime";var He=no(void 0),Ve=({children:e})=>{let[t,r]=so({}),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 ao(He.Provider,{value:{keybindings:t,setKeybinding:o,removeKeybinding:n},children:e})},M=()=>{let e=io(He);if(!e)throw new Error("useKeybindings must be used within a KeybindingsProvider");return e};import{useEffect as gn}from"react";import{Text as hn,Box as oo,useInput as xn}from"ink";import{useStdout as co}from"ink";function g(){let{stdout:e}=co(),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 po}from"ink";import{useState as ce,createContext as lo,useContext as uo}from"react";import{jsx as mo}from"react/jsx-runtime";var O={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(O),_e=lo({});function Ue({children:e}){let[t,r]=ce(!1),o=()=>r(!0),n=()=>r(!1),[i,s]=ce("Status"),[a,l]=ce("Status"),c=p=>{t||(l(p),s(O[p]))},u=p=>{t||(s(p),l(p))},f=()=>{t||l(p=>{let b=U.at((U.indexOf(p)+1)%U.length);return s(O[b]),b})},S=()=>{t||l(p=>{let b=U.at(U.indexOf(p)-1);return s(O[b]),b})};return mo(_e.Provider,{value:{activeGroup:i,setActiveGroup:u,activeSection:a,setActiveSection:c,prevSection:S,nextSection:f,isLocked:t,lock:o,unlock:n},children:e})}function w(){let e=uo(_e);if(Object.keys(e).length===0)throw new Error("useNavContext must be used within a NavProvider");return e}import{memo as fo}from"react";import{jsx as le}from"react/jsx-runtime";var go=Array.from(new Set(Object.values(O))),qe=fo(({activeGroup:e})=>le(Ye,{width:"100%",flexDirection:"row",height:1,children:go.map((t,r)=>le(Ye,{borderStyle:"classic",borderLeft:!!r,borderRight:!1,borderTop:!1,borderBottom:!1,children:le(po,{color:t===e?"cyan":"",children:` [${r+1}]: ${t} `})},t))}),(e,t)=>e.activeGroup===t.activeGroup);import{Text as un,useInput as mn}from"ink";import{Box as Po,Text as Co}from"ink";import{Box as Qe,measureElement as ho,Text as ze}from"ink";import{useMemo as xo,useRef as vo}from"react";import{Fragment as yo,jsx as z,jsxs as So}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(),u=n??c,f=vo(null),S=xo(()=>{if(!f.current)return 0;let{width:d}=ho(f.current);return d},[f.current]),p=S-8,b={...e,height:s,width:S},{activeSection:x}=w(),m=x===t||a?"cyan":"";return z(Qe,{ref:f,flexDirection:"column",height:i,width:u,backgroundColor:l,children:S!==0&&So(yo,{children:[t&&z(ze,{color:m,wrap:"truncate-end",children:"\u256D\u2500\u2500\u2500\u2500 "+t+" "+"\u2500".repeat(p-t.length)+"\u256E"}),z(Qe,{flexDirection:"column",...b,borderStyle:"round",borderColor:m,borderTop:!t,borderBottom:!r,paddingLeft:1,children:o}),r&&z(ze,{color:m,wrap:"truncate-end",children:"\u2570"+"\u2500".repeat(p-r.length)+" "+r+" \u2500\u2500\u2500\u2500\u256F"})]})})}import{useEffect as bo,useState as de}from"react";function y(e,t=[]){let[r,o]=de(void 0),[n,i]=de(!1),[s,a]=de(0),l=()=>a(c=>c+1);return bo(()=>{let c=!1;return i(!1),o(void 0),e().then(u=>{c||(o(u),i(!0))}).catch(()=>{c||i(!0)}),()=>{c=!0}},[s,...t]),{value:r,resolved:n,refresh:l}}import{createContext as wo,useContext as Vn}from"react";import{jsx as Mo}from"react/jsx-runtime";var To=wo({});function Je({children:e}){return Mo(To.Provider,{value:{},children:e})}import{jsx as J}from"react/jsx-runtime";function Xe(){let{width:e,sectionHeight:t}=g(),{value:r}=y(ae);return J(Je,{children:J(Po,{width:e,height:t,children:J(T,{title:"Status",innerHeight:t-1,children:r?.map(o=>J(Co,{children:o},o))})})})}import{useEffect as Pt,useState as Ct}from"react";import{Box as wr,useInput as Tr}from"ink";import{Text as Eo}from"ink";import{jsx as Ze}from"react/jsx-runtime";function je({sha:e}){let{resolved:t,value:r}=y(()=>Ao(e),[e]);return Ze(T,{title:"Commit Details",width:"50%",height:"100%",children:e&&t&&Ze(Eo,{children:r})})}async function Ao(e){if(!e)return;let{stdout:t}=await P(`git show ${e} --name-only`);return t.trim()}import{useCallback as Go,useEffect as Ho}from"react";import{Box as X,Text as pe,useInput as Vo}from"ink";import{useEffect as et,useRef as Bo,useState as ue}from"react";function I(e,t){let[r,o]=ue(0),[n,i]=ue(0),s=Bo(void 0),[a,l]=ue(0),c=()=>l(m=>m+1);et(()=>{let m=0;if(s.current!==void 0){let h=e.findIndex(v=>v===s.current);h>=0&&(m=h)}i(m);let d=Math.min(Math.max(m-Math.floor(t/2),0),Math.max(0,e.length-t));o(d)},[e,t,a]),et(()=>{s.current=e[n]},[n,e]);let u=Math.max(0,e.length-t),f=e.length-1,S=()=>{i(m=>{let d=Math.min(m+1,f);return o(h=>d>=h+t?Math.min(h+1,u):h),d})},p=()=>{i(m=>{let d=Math.max(m-1,0);return o(h=>d<h?Math.max(h-1,0):h),d})},b=e.slice(r,r+t),x=e[n];return{scrollDown:S,scrollUp:p,outList:b,selectedIndex:n,renderedIndex:n-r,selectedValue:x,refresh:c}}import{useInput as ko}from"ink";import{createContext as Do,useContext as Lo}from"react";import{useEffect as nt,useState as tt}from"react";import{jsx as Ro}from"react/jsx-runtime";var ot="\u2190",rt="\u2192",it=Do({});function st({children:e}){let[t,r]=tt("truncate-end"),[o,n]=tt(0),{removeKeybinding:i,setKeybinding:s}=M();return nt(()=>(o&&(t==="truncate-start"?s(ot,"pan left"):s(rt,"pan right")),()=>{i([rt,ot])}),[t,o]),ko((a,l)=>{o&&(l.rightArrow?r("truncate-start"):l.leftArrow&&r("truncate-end"))}),Ro(it.Provider,{value:{mode:t,_isToggleable:o,_setIsToggleable:n},children:e})}function k(){let e=Lo(it);if(Object.keys(e).length===0)throw new Error("useTruncationMode must be used within an TruncationModeProvider");let{mode:t,_setIsToggleable:r}=e;return nt(()=>(r(o=>o+1),()=>r(o=>o-1)),[]),{mode:t}}import{createContext as No,useContext as Fo,useEffect as at,useMemo as Wo,useRef as ct,useState as lt}from"react";import{useInput as Oo}from"ink";import{jsx as $o}from"react/jsx-runtime";var dt=No({});function ut({children:e}){let{activeSection:t}=w(),{sectionHeight:r}=g(),o=r-3,{value:{tree:n,files:i}={},resolved:s}=y(Io),a=ct(new Set),l=ct(new Set(["."])),[c,u]=lt();at(()=>{n&&i&&(a.current=new Set(Object.keys(n)),u(i[0]))},[s]);let f=Wo(()=>i?.filter(x=>a.current.has(x))??[],[a.current.size,s]),[S,p]=lt(0),b=()=>p(x=>x+1);return Oo((x,m)=>{if(t!=="Files"||!n||!c)return;if(m.upArrow){let h=Math.max(0,f.indexOf(c)-1);u(f[h]),b()}else if(m.downArrow){let h=Math.min(f.length-1,f.indexOf(c)+1);u(f[h]),b()}let d;if(m.leftArrow?d="collapse":m.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)}b()}}),at(()=>{if(l.current.clear(),l.current.add("."),f.length<=o){f.forEach(_=>l.current.add(_));return}let x=c?Ko(c):[],m=Math.max(1,o-x.length),d=f.filter(_=>!x.includes(_)),h=c?d.indexOf(c):0,v=Math.max(0,h-Math.floor(m/2)),E=v+m;E>d.length&&(E=d.length,v=Math.max(0,E-m));let q=d.slice(v,E);[...x,...q].forEach(_=>{l.current.add(_)})},[f.length,c,o]),$o(dt.Provider,{value:{version:S,tree:n,visibleFiles:l.current,expandedFiles:a.current,selectedFile:c},children:e})}function B(){let e=Fo(dt);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},Io=async()=>{let e=await Ne(),t=Fe(e);return{tree:e,files:t}},Ko=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 Uo}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=Go(()=>o.length&&a?o(a):o(),[o,a]),{resolved:u,value:f=[]}=y(c,[r]),{scrollUp:S,scrollDown:p,outList:b,selectedValue:x,renderedIndex:m}=I(f,n-2),d=x?.sha;Ho(()=>{e(d)},[d]),Vo((v,E)=>{i!=="Log"||s||(E.upArrow?S():E.downArrow&&p())});let h=_o.includes(t.label);return R(T,{overflowY:"hidden",height:"100%",title:"Log",width:"50%",children:u&&b.map(({sha:v,message:E},q)=>Uo(X,{flexDirection:"row",flexWrap:"nowrap",children:[R(X,{minWidth:2,children:v===d?R(pe,{color:h&&q===m?"magenta":void 0,children:"> "}):null}),R(X,{minWidth:8,children:R(pe,{color:"yellow",children:v})}),R(X,{children:R(pe,{wrap:l,children:E})})]},`${v}-${t.label}${h?q:""}`))})}var _o=["blame","reflog"];import{useState as ar}from"react";import{useInput as cr}from"ink";import lr from"ink-text-input";import{useInput as Yo}from"ink";import{createContext as qo,useContext as Qo,useEffect as zo,useState as fe}from"react";import{Fragment as Jo,jsx as Zo,jsxs as Xo}from"react/jsx-runtime";var pt=qo({});function C(){let e=Qo(pt);if(Object.keys(e).length===0)throw new Error("useKeybindings must be used within a KeybindingsProvider");return e}function ft({children:e}){let[t,r]=fe(null),{lock:o,unlock:n}=w(),[i,s]=fe(!1),[a,l]=fe(),c=()=>{n(),s(!1),a?.(),r(null)},u=()=>{o(),s(!0)},f=()=>{i?c():u()},S=(x,m)=>{c(),l(m?.onClose),r(x)};Yo((x,m)=>{m.escape&&c()});let{setKeybinding:p,removeKeybinding:b}=M();return zo(()=>{if(i)return p("esc","close"),()=>{b("esc")}},[i]),Zo(pt.Provider,{value:{setModal:S,open:u,close:c,toggle:f,isOpen:i},children:Xo(Jo,{children:[e,t]})})}import{Box as vt}from"ink";import ge from"node:path";import he from"node:os";import jo from"node:fs/promises";import{createContext as er,useContext as tr}from"react";import{jsx as ir}from"react/jsx-runtime";var gt=er({});function ht({children:e}){let{value:t}=y(or);return ir(gt.Provider,{value:{bgColor:t},children:e})}var xt=()=>{let e=tr(gt);if(Object.keys(e).length===0)throw new Error("useKeybindings must be used within a KeybindingsProvider");return e};async function or(){if(!(!process.stdin.isTTY||!process.stdout.isTTY))return process.env.TERM_PROGRAM==="vscode"?await nr():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=rr(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 rr(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 nr(){let e="Code";process.env.TERM_PROGRAM_VERSION?.includes("insider")&&(e="Code - Insiders");let t;switch(process.platform){case"win32":t=ge.join(he.homedir(),"AppData","Roaming",e,"User","settings.json");break;case"linux":t=ge.join(he.homedir(),".config",e,"User","settings.json");break;case"darwin":t=ge.join(he.homedir(),"Library","Application Support",e,"User","settings.json");break;default:return}if(!await Re(t))return;let r=await jo.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 xe}from"react/jsx-runtime";var sr=36;function K({children:e,title:t,width:r=sr}){let o=g(),{width:n}=o,i=Math.floor((n-r)/2),{bgColor:s}=xt();return xe(vt,{...o,position:"absolute",children:xe(vt,{alignSelf:"center",marginLeft:i,marginRight:i,children:xe(T,{title:t,width:r,isModal:!0,backgroundColor:s,children:e})})})}import{jsx as yt}from"react/jsx-runtime";function Z({title:e,handleSubmit:t}){let[r,o]=ar(""),{isOpen:n,close:i}=C();return cr((s,a)=>{a.return&&n&&(t(r),o(""),i())}),n&&yt(K,{title:e,children:yt(lr,{value:r,onChange:o})})}import{useInput as dr}from"ink";import ur from"ink-select-input";import{jsx as St}from"react/jsx-runtime";function j({title:e,handleSubmit:t,options:r,initialIndex:o,width:n}){let{isOpen:i,close:s}=C();return dr((a,l)=>{l.return&&i&&s()}),i&&St(K,{title:e,width:n,children:St(ur,{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(mr)}function mr(e){let t=e.indexOf(" ");return{sha:e.slice(0,t),message:e.slice(t+1)}}import{createContext as pr,useContext as fr,useEffect as gr,useState as hr}from"react";import{jsx as xr}from"react/jsx-runtime";var bt=pr({});function wt({children:e}){let[t,r]=hr(),o=(n,...i)=>{n(...i).catch(s=>r(s.stderr??s.message))};return gr(()=>{if(t)throw new Error(t)},[t]),xr(bt.Provider,{value:{attempt:o,err:t},children:e})}function H(){let e=fr(bt);if(Object.keys(e).length===0)throw new Error("useErrorCatcher must be used within an ErrorCatcherProvider");return e}import{createContext as vr,useContext as yr,useState as Sr}from"react";import{jsx as br}from"react/jsx-runtime";var Tt=vr({});function Mt({children:e}){let[t,r]=Sr(),o=i=>r(i),n=i=>{let s=t===i;return s&&r(void 0),s};return br(Tt.Provider,{value:{sendMessage:o,receiveMessage:n},children:e})}function ee(){let e=yr(Tt);if(Object.keys(e).length===0)throw new Error("useMessaging must be used within an MessagingProvider");return e}import{jsx as ve,jsxs as Mr}from"react/jsx-runtime";function ye(){let{setModal:e,toggle:t}=C(),[r,o]=Ct(),{width:n,sectionHeight:i}=g(),[s,a]=Ct(G[0]),{receiveMessage:l}=ee();Pt(()=>{l("log-file")&&a(G[4]),l("blame-file")&&a(G[5])},[]);let{isLocked:c}=w(),{attempt:u}=H();Tr((p,b)=>{p==="m"&&(e(ve(j,{options:G,title:"Log Type",handleSubmit:x=>a(x),initialIndex:G.indexOf(s)})),t()),!c&&p==="c"&&r&&u(()=>P(`git checkout ${r}`))});let{setKeybinding:f,removeKeybinding:S}=M();return Pt(()=>(f("c","checkout"),f("m","mode"),()=>{S(["c","m"])}),[]),Mr(wr,{width:n,height:i,children:[ve(mt,{setSha:o,mode:s}),ve(je,{sha:r})]})}import{useEffect as Rr}from"react";import{Box as Lt}from"ink";import{Box as Se,Text as Et,useInput as Pr}from"ink";import{useEffect as Cr}from"react";import{Fragment as Ar,jsx as N,jsxs as Er}from"react/jsx-runtime";function At(){let{activeSection:e,isLocked:t}=w(),{sectionHalfHeight:r}=g(),{value:o=[],refresh:n}=y(Ke),{value:i,refresh:s}=y(We),{setKeybinding:a,removeKeybinding:l}=M();Cr(()=>{if(e==="Branches")return a("s","switch"),()=>{l("s")}},[e]);let{outList:c,selectedValue:u,scrollUp:f,scrollDown:S}=I(o,r-2),p=async v=>{await P(`git branch ${v}`),n()},b=async()=>{await P(`git branch -D ${u}`),n()},x=async()=>{await P(`git switch ${u}`),n(),s()},{setModal:m,open:d}=C(),{attempt:h}=H();return Pr((v,E)=>{e!=="Branches"||t||(E.upArrow?f():E.downArrow?S():v==="c"?(m(N(Z,{title:"Name your new branch",handleSubmit:p})),d()):v==="d"?h(b):v==="s"&&h(x))}),N(Ar,{children:N(T,{width:"100%",title:"Branches",innerHeight:r-1,children:c.map(v=>Er(Se,{flexDirection:"row",flexWrap:"nowrap",children:[N(Se,{minWidth:2,children:v===u?N(Et,{children:"> "}):null}),N(Se,{children:N(Et,{color:v===i?"magenta":void 0,children:v})})]},v))})})}import{Text as be}from"ink";import{Fragment as Br}from"react";import{jsx as we,jsxs as Bt}from"react/jsx-runtime";function kt(){let{value:e}=y($e);return we(T,{width:"50%",title:"Remotes",children:e?.map(({url:t,name:r,type:o})=>Bt(Br,{children:[Bt(be,{wrap:"truncate-end",children:[r," (",o,")"]}),we(be,{wrap:"truncate-end",children:t}),we(be,{children:" "})]},`${r}-${o}`))})}import{Text as Te}from"ink";import{Fragment as kr}from"react";import{jsx as te,jsxs as Lr}from"react/jsx-runtime";function Dt(){let{sectionHalfHeight:e}=g(),{value:t}=y(Dr);return te(T,{width:"100%",title:"Worktrees",innerHeight:e-1,children:t?.map(({branch:r,detached:o,path:n,head:i})=>Lr(kr,{children:[te(Te,{children:o?i:r}),te(Te,{children:n}),te(Te,{children:" "})]},n))})}async function Dr(){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 Nr,jsx as oe,jsxs as Rt}from"react/jsx-runtime";function Nt(){let{width:e,sectionHeight:t}=g(),{setKeybinding:r,removeKeybinding:o}=M();return Rr(()=>(r("c","create"),r("d","delete"),()=>{o(["c","d"])}),[]),oe(Nr,{children:Rt(Lt,{width:e,height:t,children:[Rt(Lt,{flexDirection:"column",width:"50%",height:t,children:[oe(At,{}),oe(Dt,{})]}),oe(kt,{})]})})}import{Component as Fr,useEffect as Wr}from"react";import{Text as Ft}from"ink";import{jsx as Me}from"react/jsx-runtime";function re({title:e,message:t,width:r}){let{isOpen:o}=C(),{mode:n}=k();return o&&Me(K,{title:e,width:r,children:Array.isArray(t)?t.map(i=>Me(Ft,{wrap:n,children:i})):Me(Ft,{children:t})})}import{jsx as Wt}from"react/jsx-runtime";var ne=class extends Fr{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?Wt(Or,{dismissError:this.dismissError.bind(this),message:this.state.message,children:this.props.children}):this.props.children}};function Or({message:e,dismissError:t,children:r}){let{setModal:o,open:n}=C(),{modalWidth:i}=g();return Wr(()=>{if(e){let s=e.split(/\r?\n/).map(a=>a.trim());o(Wt(re,{title:"Error",message:s,width:i}),{onClose:t}),n()}},[e]),r}import{Box as zr,useInput as Jr}from"ink";import{useEffect as Xr}from"react";import{Box as Pe,Text as $t}from"ink";import Ce from"node:path";import{memo as Ir,useEffect as Ot,useState as Kr}from"react";import{Fragment as Vr,jsx as D,jsxs as Ee}from"react/jsx-runtime";var $r="\u2190",Gr="\u2191",Gt="\u2192",Ht="\u2193",It=`${$r}${Gr}${Ht}${Gt}`;function Vt(){let{sectionHeight:e}=g(),{activeSection:t}=w(),{setKeybinding:r,removeKeybinding:o}=M();Ot(()=>{if(t==="Files")return r(It,"NAVIGATION_KEY"),()=>o(It)},[t]);let{tree:n,version:i}=B(),{value:s}=y(Oe),[,a]=Kr(0);return Ot(()=>{a(l=>l+1)},[i]),D(T,{title:"Files",innerHeight:e,width:"50%",children:s&&n&&D(_t,{name:Ce.basename(s),contents:n,depth:0,fp:s})})}function _t(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 u=r+2;if(i)return D(Kt,{...e,depth:u,isSelected:c},o);let f=`${n}/`,S=Hr(l,p=>p.startsWith(f))||r===0;return Ee(Vr,{children:[Ee(Pe,{flexDirection:"row",flexWrap:"nowrap",children:[D(Pe,{width:2,children:D($t,{children:S?Ht:Gt})}),D(Pe,{width:"100%",children:D(Kt,{...e,isSelected:c})})]}),S&&Object.entries(t).map(([p,b])=>{let x=Ce.join(n,p),m=Ce.join(o,p);return D(_t,{name:p,contents:b,depth:u,rp:x,fp:m})})]})}var Kt=Ir(({name:e,depth:t,isSelected:r})=>Ee($t,{wrap:"truncate-end",color:r?"yellow":void 0,children:["\xA0".repeat(t),e]}),(e,t)=>e.isSelected===t.isSelected&&e.fp===t.fp);function Hr(e,t){for(let r of e)if(t(r))return!0;return!1}import{Box as Yt,Text as F}from"ink";import{Box as _r,measureElement as Ur,Text as Ut}from"ink";import{useMemo as Yr,useRef as qr}from"react";import{jsx as Ae}from"react/jsx-runtime";function ie({text:e}){let t=qr(null),r=Yr(()=>{if(!t.current)return 0;let{width:a}=Ur(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 Ae(_r,{width:"100%",ref:t,children:e.length>r?Ae(Ut,{children:e}):Ae(Ut,{children:s})})}import{jsx as Be,jsxs as L}from"react/jsx-runtime";function qt(){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()=>Qr(s,t),[s,t]),{mode:u}=k();return Be(Yt,{width:"50%",height:e,children:L(T,{width:"100%",title:"File Meta",innerHeight:e-1,children:[t&&Be(ie,{text:t}),s&&L(F,{wrap:u,children:["Last Commit: ",s]}),i&&L(F,{wrap:u,children:["Edited By: ",i]}),o&&L(F,{wrap:u,children:["Edit On: ",o]}),n&&L(F,{wrap:u,children:["Contact: ",n]}),c&&(a||l)&&L(Yt,{flexDirection:"row",flexWrap:"nowrap",children:[Be(F,{children:"Changes:\xA0"}),L(F,{color:"green",children:["+",a??0,"\xA0"]}),L(F,{color:"red",children:["-",l??0]})]})]})})}var Qr=async(e,t)=>!e||!t?{}:(await Q(e)).find(({file:o})=>t===o)??{};import{jsx as ke,jsxs as Zr}from"react/jsx-runtime";function Qt(){let{width:e,sectionHeight:t}=g(),{selectedFile:r,tree:o}=B(),{setKeybinding:n,removeKeybinding:i}=M();Xr(()=>(n("l","log"),n("b","blame"),()=>{i(["l","b"])}),[]);let{setActiveGroup:s}=w(),{sendMessage:a}=ee(),{setModal:l,open:c}=C();return Jr((u,f)=>{u==="l"?(a("log-file"),s("Log")):u==="b"&&(Object.keys(me(o??{},r)).length===0?(a("blame-file"),s("Log")):(l(ke(re,{title:"Sorry",message:["Can't blame a folder."]})),c()))}),Zr(zr,{width:e,height:t,children:[ke(Vt,{}),ke(qt,{})]})}import{Box as an}from"ink";import{Box as zt,Text as Jt,useInput as jr}from"ink";import{useEffect as en}from"react";import{jsx as V,jsxs as on}from"react/jsx-runtime";function Xt({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(tn),{outList:u,selectedValue:f,selectedIndex:S,scrollUp:p,scrollDown:b}=I(l,t-2);en(()=>{e(`stash@{${S}}`)},[S]);let x=d=>async()=>{await P(`git stash ${d} stash@{${S}}`),c()},m=async()=>{let d=`stash@{${S}}`,h=await Ie(d);n(V(Z,{title:`reword ${d}`,handleSubmit:async v=>{await P(`git stash drop ${d}`),await P(`git stash store ${h} -m "${v}"`),c()}})),i()};return jr((d,h)=>{a||(d==="s"?(n(V(j,{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(m),s==="Stashes"&&(h.upArrow?p():h.downArrow&&b()))}),V(T,{title:"Stashes",width:"50%",height:"100%",children:u.map(d=>on(zt,{flexDirection:"row",flexWrap:"nowrap",children:[V(zt,{minWidth:2,children:d===f?V(Jt,{children:"> "}):null}),V(Jt,{wrap:r,children:d})]},d))})}async function tn(){return await Le("git stash list")}import{Box as rn,Text as De}from"ink";import{jsx as sn,jsxs as Y}from"react/jsx-runtime";function Zt({stash:e}){let{value:t=[]}=y(()=>nn(e),[e]);return Y(T,{title:"Stash Details",width:"50%",height:"100%",children:[e&&sn(ie,{text:e}),t.map(({file:r,added:o,deleted:n,changeType:i})=>i!=="binary"&&Y(rn,{flexDirection:"row",flexWrap:"nowrap",children:[Y(De,{children:[r,":\xA0"]}),Y(De,{color:"green",children:["+",o??0,"\xA0"]}),Y(De,{color:"red",children:["-",n??0]})]}))]})}async function nn(e){if(e)return await Q(e)}import{useEffect as cn,useState as ln}from"react";import{jsx as jt,jsxs as dn}from"react/jsx-runtime";function eo(){let{sectionHeight:e,width:t}=g(),[r,o]=ln(),{setKeybinding:n,removeKeybinding:i}=M();return cn(()=>(n("s","stash"),n("d","drop"),n("a","apply"),n("p","pop"),n("r","reword"),()=>i(["s","p","d","a","r"])),[]),dn(an,{width:t,height:e,children:[jt(Xt,{setStash:o}),jt(Zt,{stash:r})]})}import{jsx as A,jsxs as fn}from"react/jsx-runtime";function to(){let{prevSection:e,nextSection:t,activeGroup:r,setActiveGroup:o}=w();return mn((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(ne,{children:A(wt,{children:A(Mt,{children:A(ut,{children:A(pn,{group:r})})})})})}function pn({group:e}){switch(e){case"Files":return A(Qt,{});case"Status":return A(Xe,{});case"Log":return A(ye,{});case"Branches":return A(Nt,{});case"Stashes":return A(eo,{});default:return fn(un,{children:['Error, unknown page "',e,'"']})}}import{jsx as se,jsxs as vn}from"react/jsx-runtime";function ro(){let{isLocked:e,activeGroup:t}=w();xn((i,s)=>{e||i.toLowerCase()==="q"&&process.exit()});let r=g(),{keybindings:o,setKeybinding:n}=M();return gn(()=>n("q","quit"),[]),vn(oo,{flexDirection:"column",...r,children:[se(qe,{activeGroup:t}),se(to,{}),se(oo,{flexDirection:"row",children:Object.entries(o).map(([i,s])=>se(hn,{children:`[${i}]: ${s} `},s))})]})}import{jsx as W}from"react/jsx-runtime";function Sn(){return W(ht,{children:W(Ue,{children:W(Ve,{children:W(st,{children:W(ft,{children:W(ro,{})})})})})})}var Al=()=>yn(W(Sn,{}),{patchConsole:!0});export{Al as renderApp};
|