bisgit 0.4.0 → 0.6.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/dist/chunks/chunk-DLHREY2Q.js +2 -0
- package/dist/chunks/chunk-L4626BRA.js +2 -0
- package/dist/chunks/chunk-R7DNYVL6.js +2 -0
- package/dist/chunks/commands-XBKP3MSC.js +12 -0
- package/dist/chunks/pages-JELX53G4.js +2 -0
- package/dist/chunks/{wrapper-5X5SODCK.js → wrapper-PHXQ7CVF.js} +1 -1
- package/dist/main.js +1 -1
- package/package.json +4 -2
- package/dist/chunks/chunk-5WTQIRZS.js +0 -2
- package/dist/chunks/chunk-HCUVDNFV.js +0 -2
- package/dist/chunks/chunk-ZLDM3RDV.js +0 -2
- package/dist/chunks/commands-2Y6VXVCP.js +0 -12
- package/dist/chunks/pages-ALXMXO3T.js +0 -2
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{b as n,c as a,d as u}from"./chunk-R7DNYVL6.js";import l from"fs/promises";async function $(t){try{return await l.access(t),!0}catch{return!1}}async function f(){return await a("git ls-files")}async function p(){return await a("git ls-files --others --exclude-standard")}async function P(){let[t,r]=await Promise.all([f(),p()]),e=[...t,...r].sort(([o],[s])=>o.localeCompare(s)),i={};for(let o of e){let s=o.split("/"),c=i;for(let m of s)c[m]||(c[m]={}),c=c[m]}return i}function h(t,r=""){let e=[];for(let[i,o]of Object.entries(t)){let s=r?`${r}/${i}`:i;e.push(s),Object.keys(o).length>0&&e.push(...h(o,s))}return e}import{normalize as g}from"node:path";async function d(){let{stdout:t}=await n("git branch --show-current");return t.trim()}async function B(t){t??=await d();let{stdout:r}=await n(`git config --get branch.${t}.remote`);return r.trim()}async function D(t,r){try{let{stdout:e}=await n(`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 T(t,r){try{let{stdout:e}=await n(`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 E(t){let{stdout:r}=await n(`git rev-parse --git-path ${t}`);return g(r.trim())}async function R(){let{stdout:t}=await n("git rev-parse --git-dir");return g(t.trim())}async function N(){let{stdout:t}=await n("git rev-parse --show-toplevel");return g(t.trim())}async function S(t){let{code:r}=await u("git",["remote","get-url",t],{stdio:"ignore"});return r===0}async function G(){let{stdout:t}=await n("git rev-parse --abbrev-ref HEAD");return t.trim()==="HEAD"}async function I(t,r){let e="git fetch";t&&(e+=` ${t}`),r&&(e+=` ${r}`),await n(e)}async function M(){let{stdout:t}=await u("git",["status","--porcelain"]);return!t?.trim()}async function k(){return await a("git status --porcelain")}async function y(t,r){let{stdout:e}=await n(`git merge-base ${t} ${r}`);return e.trim()}async function z(t,r){let e=await y(t,r),{stdout:i}=await u("git",["merge-tree",e,r,t]);return!i?.split(/\r?\n/)?.includes("+=======")}async function A(t){let{stdout:r}=await n(`git rev-parse ${t}`);return r.trim()}async function F(t,r,e){return await a(`git rev-list ${e?"--reverse":""} ${t}..${r}`)}async function H(){return await a("git for-each-ref --format='%(refname:short)' refs/heads")}async function C(){let{stdout:t}=await n("git remote -v");return t.trim().split(/\r?\n/).map(e=>{let i=e.match(/^(\S+)\s+(\S+)\s+\((fetch|push)\)$/);if(!i)return null;let[,o,s,c]=i;return{name:o,url:s,type:c}}).filter(e=>e!==null)}async function O(t){try{let{stdout:r}=await n(`git log -1 --format='%an|%ae|%ad|%h' -- "${t}"`,{encoding:"utf8"}),[e,i,o,s]=r.trim().split("|");return{authorName:e,authorEmail:i,authorDate:o,shortHash:s}}catch{return{}}}export{$ as a,P as b,h as c,d,B as e,D as f,T as g,E as h,R as i,N as j,S as k,G as l,I as m,M as n,k as o,y as p,z as q,A as r,F as s,H as t,C as u,O as v};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{a as s,l as i,n}from"./chunk-DLHREY2Q.js";function u(){return process.argv[2]}function g(){return process.argv.slice(3)}async function p(){let[r,t]=g();return r||(console.error("Requires <branch> or <remote> <branch>"),process.exit(1)),t?{remote:r,branch:t}:{remote:"origin",branch:r}}import{spawnSync as a}from"node:child_process";function e(r,t,o){let{status:c}=a(r,t,{stdio:"ignore"});c!==0&&(o&&console.error(o),process.exit(1))}var h=()=>e("git",["rev-parse","--git-dir"],"Need to use command in a git repository."),x=()=>e("git",["rev-parse","HEAD"],"Need to create first commit."),q=(r="origin")=>e("git",["remote","get-url",r],`Need to add remote '${r}'.`),v=r=>e("git",["show-ref","--branches",r],`Branch '${r}' isn't tracked locally and may not exist.`),y=async()=>{await n()||(console.error("You should stash or commit your changes first."),process.exit(1))},b=async r=>{await s(r)||(console.error(`${r} must exist for this operation and it doesn't for some reason`),process.exit(1))},w=async()=>{await i()&&(console.error("Operation not allowed in a 'detached HEAD' state"),process.exit(1))},A=r=>e("git",["rev-parse","--abbrev-ref","--symbolic-full-name",`${r}@{u}`],`branch '${r}' has no upstream`);function C(r="Error: missing required argument"){if(process.argv[3])return process.argv[3];console.error(r),process.exit(1)}async function $(){let{status:r}=a("git",["diff","--staged","--quiet"],{stdio:"ignore"});r===0&&(console.error("You have no staged changes"),process.exit(1))}export{u as a,g as b,p as c,h as d,x as e,q as f,v as g,y as h,b as i,w as j,A as k,C as l,$ as m};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{exec as d,spawn as p}from"node:child_process";import{promisify as u}from"node:util";function w(n,s,t){let e=p(n,s,t??{});t?.silent||(e.stdout?.on("data",o=>{console.log(String(o))}),e.stderr?.on("data",o=>{console.error(String(o))})),e.on("close",o=>{t?.triggerExit&&process.exit(o)})}var g=u(d);async function x(n){let{stdout:s}=await g(n),t=s.trim();return t?t.split(/\r?\n/):[]}async function y(n,s,t={}){let{promise:e,resolve:o,reject:c}=Promise.withResolvers(),r=p(n,s,t),l="",a="";return r.stdout?.on("data",i=>l+=i),r.stderr?.on("data",i=>a+=i),r.on("close",i=>o({code:i,stdout:l,stderr:a})),r.on("error",i=>c(i)),e}async function h(n,s="inherit"){let{promise:t,resolve:e,reject:o}=Promise.withResolvers(),c=p("git",["-c","color.ui=always",...n],{stdio:s});return c.on("close",r=>{r===0?e({code:r}):o({code:r})}),c.on("error",o),t}export{w as a,g as b,x as c,y as d,h as e};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{b as g,c as K,d as rt,e as R,f as d,g as I,h as C,i as H,j as M,k as it,l as y,m as A}from"./chunk-L4626BRA.js";import{a as $,d as h,e as z,f as B,g as q,h as D,i as Z,j as Q,k as X,m as W,n as x,o as G,p as P,q as tt,r as et,s as F,t as ot}from"./chunk-DLHREY2Q.js";import{a as u,b as s,d as w,e as l}from"./chunk-R7DNYVL6.js";import S from"node:path";async function nt(){let t=await G(),e=/^(UU|DU|UD)/;return!!t?.some(o=>e.test(o))}async function N(){let t=await Z(),[e,o,i,r,n]=await Promise.all([await $(S.join(t,"MERGE_HEAD")),await $(S.join(t,"rebase-merge")),await $(S.join(t,"rebase-apply")),await $(S.join(t,"CHERRY_PICK_HEAD")),await $(S.join(t,"REVERT_HEAD"))]);return{merge:e,rebaseMerge:o,rebaseApply:i,cherryPick:r,revert:n}}async function st(){let{merge:t,rebaseMerge:e,rebaseApply:o,cherryPick:i,revert:r}=await N(),n="";if(t)n="merge";else if(e||o)n="rebase";else if(i)n="cherry-pick";else if(r)n="revert";else{let a=await nt()?"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 ${n}`),await l([n,"--abort"])}async function at(){await M(),await A(),u("git",["commit","--amend","--no-edit",...g()],{stdio:"inherit",silent:!0,triggerExit:!0})}import{render as Yt}from"ink";import{render as _t}from"ink";import{Suspense as Nt,use as Tt,useEffect as Lt}from"react";import{Text as ct,useApp as Ut}from"ink";import It from"ink-spinner";import{jsx as T,jsxs as jt}from"react/jsx-runtime";function c(t){let{msg:e}=t;return T(Nt,{fallback:jt(ct,{children:[T(It,{type:"dots"}),"\xA0",e]}),children:T(Ot,{...t})})}function Ot({msg:t,promise:e}){let o=Tt(e),{exit:i}=Ut();return Lt(()=>{i()},[o]),T(ct,{children:`\u2714 ${typeof o=="string"?o:t}`})}import{jsx as Vt}from"react/jsx-runtime";async function mt(){let t=process.argv[3],e=process.argv[4]??await h();if(I(t),I(e),t===e)return console.log(`No reason to merge '${t}' into '${e}'`);let o=await z(t);d(o),_t(Vt(c,{msg:"Updating target branch and merging",promise:(async()=>{try{await E(o,t)}catch{console.error(`Error when updating branch ${t} with remote ${o}. Fix divergent branches before merging into ${e}`);return}await h()!==e&&await s(`git switch ${e}`),u("git",["merge",t],{stdio:"inherit",silent:!0})})()}))}async function E(t,e){await W(t,e);let[o,i,r]=await Promise.all([B(t,e),q(t,e),h()]);if(i!==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 l(["merge",`${t}/${e}`],["ignore","ignore","inherit"])}}async function k(){R(),d();let{stdout:t,code:e}=await w("git",["rev-parse","--abbrev-ref","origin/HEAD"]);if(e===0)return lt(t.trim());await s("git remote set-head origin -a");let{stdout:o}=await s("git rev-parse --abbrev-ref origin/HEAD");return lt(o.trim())}async function ft(){let{remote:t,branch:e}=await k();console.log(`Remote default branch is '${t}/${e}'`)}async function lt(t){let e=t.split("/"),o=t.split("/").map((i,r)=>e.slice(0,r+1).join("/"));for(let i of o)if(await X(i)){let r=t.slice(i.length+1);return{remote:i,branch:r}}throw new Error("Failed to get default remote")}import{jsx as Kt}from"react/jsx-runtime";var Jt=["master","main","development","lingoport"];async function pt(){await C();let{branch:t,remote:e}=await k();await s(`git switch ${t}`);let o=(async()=>{await l(["fetch","--prune","--prune-tags"]),await E(e,t)})();Yt(Kt(c,{msg:"Fetching and pruning remote references",promise:o})),await o;let i=await ot();for(let r of i){if(r===t||Jt.includes(r))continue;let{code:n}=await w("git",["diff","--quiet",t,r]);if(n===0){O(r);continue}let{code:a}=await w("git",["merge-base","--is-ancestor",r,t]);if(a===0){O(r);continue}let m=await P(r,t),{stdout:f}=await w("git",["merge-tree",m,t,r]);f?.trim()||O(r)}}function O(t){l(["branch","-D",t])}import{spawn as zt}from"node:child_process";import{createInterface as Zt}from"node:readline/promises";async function gt(){R;let e=[...(await Qt()).entries()].sort(([,i],[,r])=>r-i).slice(0,25),o=e[0][1].toString().length;console.info(e.map(([i,r])=>`${String(r).padEnd(o)} ${i}:`).join(`
|
|
3
|
+
`))}async function Qt(){let{promise:t,resolve:e,reject:o}=Promise.withResolvers(),i=new Map,r=zt("git",["log","--all","-M","-C","--name-only","--format=format:"]),n=Zt({input:r.stdout,crlfDelay:1/0});return n.on("line",a=>{let m=a.trim();m&&i.set(m,(i.get(m)??0)+1)}),n.on("close",()=>e(i)),r.on("error",o),t}import{render as Xt}from"ink";import{jsx as ee}from"react/jsx-runtime";async function ut(){await A();let t=y("Error: missing github username argument"),e=(async()=>{let r=await te(t);return r.email||(console.error(`Couldn't find an email for ${t}`),process.exit(1)),r})();Xt(ee(c,{msg:"Fetching name and email",promise:e}));let{name:o,email:i}=await e;l(["commit","--edit","-m","<insert summary>","-m",`Co-authored-by: ${o} <${i}>`])}async function te(t){let{stdout:e}=await s(`gh api users/${t}`);return JSON.parse(e.trim())}import{render as j}from"ink";import{isDeepStrictEqual as oe}from"node:util";import{jsx as _}from"react/jsx-runtime";async function wt(){let t=y("Error: missing id of PR to checkout");await C();let e=(async()=>Promise.all([s(`gh co ${t}`),s(`gh pr view ${t} --json baseRefName -q .baseRefName`)]))();j(_(c,{msg:`Checking out pr #${t}`,promise:e}));let[,{stdout:o}]=await e,i=o.trim(),r=(async()=>{await s(`git switch ${i}`),await s("git pull"),await s("git switch -")})();j(_(c,{msg:`Updating ${i} branch merge destination`,promise:r})),await r;let n=(async()=>{let p=await P(i,"HEAD");return await s(`git reset ${p} --soft`),await re("HEAD")})();j(_(c,{msg:"Creating an editable, explorable, local PR experience",promise:n}));let[a,m]=await Promise.all([n,ie(t)]),{files:f,additions:b,deletions:U}=m;if(oe(a,m))return console.info(`Files: ${f}, +${b} -${U}`);console.info("The PR stat doesn't match the local stat."),console.info("LOCAL"),console.table(a),console.info("GITHUB"),console.table(m),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 re(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[,r,n,a]=i;return{files:parseInt(r,10),additions:n?parseInt(n,10):0,deletions:a?parseInt(a,10):0}}async function ie(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 ne}from"node:child_process";import{createInterface as se}from"node:readline/promises";import V from"chalk";async function ht(){let t=y("Error: missing target branch argument"),e=await P("HEAD",t),{promise:o,resolve:i,reject:r}=Promise.withResolvers(),n=ne("git",["merge-tree",e,"HEAD",t]),a=se({input:n.stdout,crlfDelay:1/0}),m=!1,f=0;a.on("line",p=>{p=p.trimEnd(),p==="+<<<<<<< .our"?(m=!0,console.info(V.red(p)),f+=1):p==="+>>>>>>> .their"?(m=!1,console.info(V.green(p))):p==="+======="?console.info(V.yellow(p)):m&&console.info(p)}),a.on("close",()=>i(f)),n.on("error",r);let b=await o,U=b?`\u274C ${b} conflicts would occur!`:"\u2705 No conflicts. Safe to merge.";console.info(U)}async function dt(){let{merge:t,rebaseMerge:e,rebaseApply:o,cherryPick:i,revert:r}=await N(),n="";if(t)n="merge";else if(e||o)n="rebase";else if(i)n="cherry-pick";else if(r)n="revert";else{console.log("Nothing to continue.");return}console.log(`Continuing the ${n}`),await l([n,"--continue"])}import{appendFileSync as ce}from"node:fs";import{readFile as ae}from"node:fs/promises";async function L(t){return(await ae(t,"utf-8")).split(/\r?\n/).map(o=>o.trim()).filter(o=>o&&!o.startsWith("#"))}async function yt(){let t=await D("info/exclude");await H(t);let e=await L(t);g().forEach(o=>{e.includes(o)?console.info(`Already Exists: '${o}'`):(ce(t,`${o}
|
|
4
|
+
`),console.info(`Added '${o}'`))}),console.info(`
|
|
5
|
+
See file at ${t}`)}function bt(){u("git",["show","--name-only","--pretty=format:",...g()],{stdio:"inherit",silent:!0,triggerExit:!0})}import{spawn as me}from"node:child_process";async function $t(){let t=y("Error: missing valid target ref argument");await A();let e=await et(t);await l(["commit",`--fixup=${e}`]);let i=(await F(`${e}^`,"HEAD",!0)).map(n=>le(n));(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 le(t){let{stdout:e}=await s(`git diff ${t}^ ${t}`),{promise:o,resolve:i,reject:r}=Promise.withResolvers(),n=me("git",["apply","--check","--3way","-q"],{stdio:["pipe","ignore","ignore"]});return n.on("close",a=>{i(a===0)}),n.on("error",r),n.stdin.write(e),n.stdin.end(),o}import{readFile as fe,writeFile as pe}from"node:fs/promises";async function xt(){let t=await D("info/exclude");await H(t);let e=await L(t),o=g();o.filter(a=>!e.includes(a)).forEach(a=>console.info(`No match: '${a}'`));let r=(await fe(t,"utf-8")).split(/\r?\n/).map(a=>a.trim()),n=r.filter(a=>!o.includes(a));await pe(t,n.join(`
|
|
6
|
+
`)),console.info(`
|
|
7
|
+
Removed ${r.length-n.length} entries from ${t}`)}import{render as ge}from"ink";import{jsx as de}from"react/jsx-runtime";async function Pt(){let t=(async()=>{let r=await ue();return await we(r)})();ge(de(c,{msg:"Fetching repo languages",promise:t}));let e=await t,o=Object.values(e).reduce((r,n)=>r+n,0),i=Object.entries(e).map(([r,n])=>`${r}: ${Math.round(n/o*100)}% - ${he(n)}`);console.log(i.join(`
|
|
8
|
+
`))}async function ue(){let{stdout:t}=await s("gh repo view --json nameWithOwner -q .nameWithOwner");return t.trim()}async function we(t){let{stdout:e}=await s(`gh api repos/${t}/languages`);return JSON.parse(e.trim())}function he(t,e=2){if(t===0)return"0 B";let o=1024,i=e<0?0:e,r=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],n=Math.floor(Math.log(t)/Math.log(o));return`${parseFloat((t/Math.pow(o,n)).toFixed(i))} ${r[n]}`}async function Rt(){let t=await Q();console.log(t)}import{render as At}from"ink";function Ct(){return new Date().toLocaleString("en-US",{year:"2-digit",month:"2-digit",day:"2-digit",hour:"numeric",minute:"2-digit",hour12:!0}).replace(",","")}async function v(){let t=Ct();await s("git add -A"),await l(["commit","-m",`"WIP ${t}"`])}import{nanoid as ye}from"nanoid";import be from"chalk";import{jsx as vt}from"react/jsx-runtime";async function Dt(){let{remote:t,branch:e}=await k(),o=process.argv[3]??e;await x()||await v(),await tt(o,"HEAD")||(console.warn("Conflicts would occur. Not safe to rebranch."),process.exit(1));let i=await h(),r=(async()=>{await E(t,o)})();At(vt(c,{msg:`Updating branch ${o}`,promise:r})),await r;let n=`${ye(8)}`,a=(async()=>{await s(`git switch ${i}`),await s(`git branch ${n}`),await s(`git switch ${o}`),await s(`git branch -D ${i}`),await s(`git switch -c ${i}`);let m=await F(o,n,!0);for(let f of m)try{await s(`git cherry-pick ${f}`)}catch{let b=be.yellow(`git branch -D ${i} && git branch -m ${n} ${i}`);throw new Error(`\u274C cherry pick failed at ${f}
|
|
9
|
+
Run this to restore backup branch
|
|
10
|
+
> ${b}`)}await s(`git branch -D ${n}`)})();At(vt(c,{msg:`Rewriting branch ${i}`,promise:a})),await a,console.info(`Successfully recreated branch ${i} from ${o}`)}import{execSync as $e}from"node:child_process";async function St(){R();let t=xe(process.argv[3]),{default:e}=await import("clipboardy");await e.write(t),console.log(`'${t}' copied to clipboard`)}function xe(t="HEAD"){return $e(`git rev-parse --short ${t}`,{encoding:"utf-8"}).trim()}import{render as Pe}from"ink";import{jsx as Re}from"react/jsx-runtime";async function Et(){let{remote:t,branch:e}=await K();d(t),await C();let o=W(t,e);Pe(Re(c,{msg:`Fetching branch ${e} from ${t}`,promise:o})),await o,await l(["switch","-c",e,"--track",`${t}/${e}`])}async function Y(){let{stdout:t}=await s("npm list -g bisgit --depth=0 --json");return JSON.parse(t.trim()).dependencies.bisgit.version}async function kt(){console.info(await Y())}async function Ce(){let{code:t}=await w("npm",["outdated","-g","bisgit"]);return t===0}async function Ae(){let{stdout:t}=await s("npm view bisgit version",{encoding:"utf8"});return t.trim()}async function Bt(){if(await Ce())return console.info("Already up to date");console.info(`Updating: ${await Y()} -> ${await Ae()}`),u("npm",["i","-g","bisgit@latest"])}async function qt(){let[t,e]=await Promise.allSettled([await De("user.name"),await ve()]);t.status==="fulfilled"&&console.info(`Git: ${t.value}`),e.status==="fulfilled"&&console.info(`Github: ${e.value}`)}async function ve(){let{stdout:t}=await s("gh api user --jq .login");return t.trim()}async function De(t){let{stdout:e}=await s(`git config ${t}`);return e.trim()}import{render as Ge}from"ink";import{Text as Se,useApp as Ee,useInput as ke}from"ink";import{useState as Be}from"react";import{Fragment as We,jsx as qe,jsxs as Wt}from"react/jsx-runtime";function Gt({prompt:t,msg:e,onConfirm:o}){let[i,r]=Be(""),{exit:n}=Ee();return ke((a,m)=>{if(i)return;let f=a.toLowerCase();f==="y"?r("Yes"):(f==="n"||m.return)&&(r("No"),n())}),Wt(We,{children:[Wt(Se,{children:[t," [y/N] ",i]}),i==="Yes"&&qe(c,{msg:e,promise:o()})]})}import{jsx as Fe}from"react/jsx-runtime";async function Ft(){if(rt(),await x())return console.log("Already a clean working tree");let t=await G();if(!t)throw new Error("git status cmd failed");let e=new J(t);e.displayReport(),Ge(Fe(Gt,{prompt:"Approve these changes?",msg:"Running git reset && git clean",onConfirm:async()=>(await s("git reset --hard"),await s("git clean -f"),`Altered ${e.willDelete.length+e.willRecreate.length+e.willRevert.length} files.`)}))}var J=class{willDelete=[];willRecreate=[];willRevert=[];constructor(e){e.forEach(o=>{if(o){let i=o.slice(0,2).trim(),r=o.slice(3);i.includes("?")||i.includes("A")?this.willDelete.push(r):i==="DU"||i==="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}
|
|
11
|
+
${o.map(i=>`- ${i}
|
|
12
|
+
`)}`)}};import{nanoid as He}from"nanoid";import{render as Me}from"ink";import{jsx as Ne}from"react/jsx-runtime";async function Ht(){await M();let t=process.argv[3]??"origin";d(t);let e=await h();it(e);let o="",r=(async()=>{let n=[s(`git fetch ${t} ${e} --force`)];await x()||n.push(v()),await Promise.all(n);let[a,m]=await Promise.all([B(t,e),q(t,e)]);if(!(a===0&&m===0)){if(a!==0){let f=`${e}-${He(8)}`;o=`Created branch ${f}`,await s(`git branch ${f}`)}await s(`git reset --hard ${t}/${e}`)}})();Me(Ne(c,{msg:`Force pull reseting ${e} -> ${t}`,promise:r})),await r,o&&console.info(o)}var Mt={abort:st,amend:at,autoprune:pt,backmerge:mt,churn:gt,coauthor:ut,"code-review":wt,conflict:ht,continue:dt,exclude:yt,files:bt,fixup:$t,include:xt,languages:Pt,pwd:Rt,rebranch:Dt,"remote-default":ft,savepoint:v,sha:St,track:Et,update:Bt,"--version":kt,whoami:qt,wipe:Ft,yank:Ht};async function zi(t){return await Mt[t]?.(),Object.hasOwn(Mt,t)}export{zi as runCommand};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{a as we,b as Se,c as Me,d as Pe,j as Ce,o as Ee,t as Ae,u as ke,v as Be}from"./chunk-DLHREY2Q.js";import{b as C}from"./chunk-R7DNYVL6.js";import{render as Gr}from"ink";import{createContext as Ht,useContext as Vt,useState as $t}from"react";import{jsx as _t}from"react/jsx-runtime";var Re=Ht(void 0),Le=({children:e})=>{let[t,o]=$t({}),r=(i,s)=>{o(c=>({...c,[i]:s}))},n=i=>{let s=Array.isArray(i)?i:[i];o(c=>{let l={...c};for(let a of s)delete l[a];return l})};return _t(Re.Provider,{value:{keybindings:t,setKeybinding:r,removeKeybinding:n},children:e})},M=()=>{let e=Vt(Re);if(!e)throw new Error("useKeybindings must be used within a KeybindingsProvider");return e};import{useEffect as Or}from"react";import{Text as Wr,Box as It,useInput as Ir}from"ink";import{useStdout as Ut}from"ink";function f(){let{stdout:e}=Ut(),t=e.rows-2,o=Math.floor(t/2),r=e.columns>100?96:e.columns-4;return{width:e.columns,height:e.rows,sectionHeight:t,sectionHalfHeight:o,modalWidth:r}}import{Box as Fe,Text as zt}from"ink";import{useState as ee,createContext as Yt,useContext as qt}from"react";import{jsx as Qt}from"react/jsx-runtime";var D={Files:"Files","File Meta":"Files",Status:"Status",Log:"Log","Commit Details":"Log",Branches:"Branches",Worktrees:"Branches",Remotes:"Branches"},H=Object.keys(D),Ne=Yt({});function De({children:e}){let[t,o]=ee(!1),r=()=>o(!0),n=()=>o(!1),[i,s]=ee("Status"),[c,l]=ee("Status"),a=u=>{t||(l(u),s(D[u]))},m=u=>{t||(s(u),l(u))},p=()=>{t||l(u=>{let v=H.at((H.indexOf(u)+1)%H.length);return s(D[v]),v})},b=()=>{t||l(u=>{let v=H.at(H.indexOf(u)-1);return s(D[v]),v})};return Qt(Ne.Provider,{value:{activeGroup:i,setActiveGroup:m,activeSection:c,setActiveSection:a,prevSection:b,nextSection:p,isLocked:t,lock:r,unlock:n},children:e})}function w(){let e=qt(Ne);if(Object.keys(e).length===0)throw new Error("useNavContext must be used within a NavProvider");return e}import{memo as Jt}from"react";import{jsx as te}from"react/jsx-runtime";var Xt=Array.from(new Set(Object.values(D))),Oe=Jt(({activeGroup:e})=>te(Fe,{width:"100%",flexDirection:"row",height:1,children:Xt.map((t,o)=>te(Fe,{borderStyle:"classic",borderLeft:!!o,borderRight:!1,borderTop:!1,borderBottom:!1,children:te(zt,{color:t===e?"cyan":"",children:` [${o+1}]: ${t} `})},t))}),(e,t)=>e.activeGroup===t.activeGroup);import{Text as Lr,useInput as Nr}from"ink";import{Box as no,Text as io}from"ink";import{Box as We,measureElement as Zt,Text as Ie}from"ink";import{useMemo as jt,useRef as eo}from"react";import{Fragment as to,jsx as $,jsxs as oo}from"react/jsx-runtime";function S(e){let{title:t,footer:o,children:r,width:n,height:i,innerHeight:s,isModal:c,backgroundColor:l}=e,{width:a}=f(),m=n??a,p=eo(null),b=jt(()=>{if(!p.current)return 0;let{width:h}=Zt(p.current);return h},[p.current]),u=b-8,v={...e,height:s,width:b},{activeSection:x}=w(),d=x===t||c?"cyan":"";return $(We,{ref:p,flexDirection:"column",height:i,width:m,backgroundColor:l,children:b!==0&&oo(to,{children:[t&&$(Ie,{color:d,wrap:"truncate-end",children:"\u256D\u2500\u2500\u2500\u2500 "+t+" "+"\u2500".repeat(u-t.length)+"\u256E"}),$(We,{flexDirection:"column",...v,borderStyle:"round",borderColor:d,borderTop:!t,borderBottom:!o,paddingLeft:1,children:r}),o&&$(Ie,{color:d,wrap:"truncate-end",children:"\u2570"+"\u2500".repeat(u-o.length)+" "+o+" \u2500\u2500\u2500\u2500\u256F"})]})})}import{useEffect as ro,useState as oe}from"react";function y(e,t=[]){let[o,r]=oe(void 0),[n,i]=oe(!1),[s,c]=oe(0),l=()=>c(a=>a+1);return ro(()=>{let a=!1;return i(!1),r(void 0),e().then(m=>{a||(r(m),i(!0))}).catch(()=>{a||i(!0)}),()=>{a=!0}},[s,...t]),{value:o,resolved:n,refresh:l}}import{jsx as re}from"react/jsx-runtime";function Ke(){let{width:e,sectionHeight:t}=f(),{value:o}=y(Ee);return re(no,{width:e,height:t,children:re(S,{title:"Status",innerHeight:t-1,children:o?.map(r=>re(io,{children:r},r))})})}import{useEffect as gt,useState as ht}from"react";import{Box as tr,useInput as or}from"ink";import{Text as so}from"ink";import{jsx as Ge}from"react/jsx-runtime";function He({sha:e}){let{resolved:t,value:o}=y(()=>co(e),[e]);return Ge(S,{title:"Commit Details",width:"50%",height:"100%",children:e&&t&&Ge(so,{children:o})})}async function co(e){if(!e)return;let{stdout:t}=await C(`git show ${e} --name-only`);return t.trim()}import{useCallback as To,useEffect as wo}from"react";import{Box as U,Text as se,useInput as So}from"ink";import{useEffect as Ve,useRef as ao,useState as ne}from"react";function _(e,t){let[o,r]=ne(0),[n,i]=ne(0),s=ao(void 0),[c,l]=ne(0),a=()=>l(d=>d+1);Ve(()=>{let d=0;if(s.current!==void 0){let g=e.findIndex(T=>T===s.current);g>=0&&(d=g)}i(d);let h=Math.min(Math.max(d-Math.floor(t/2),0),Math.max(0,e.length-t));r(h)},[e,t,c]),Ve(()=>{s.current=e[n]},[n,e]);let m=Math.max(0,e.length-t),p=e.length-1,b=()=>{i(d=>{let h=Math.min(d+1,p);return r(g=>h>=g+t?Math.min(g+1,m):g),h})},u=()=>{i(d=>{let h=Math.max(d-1,0);return r(g=>h<g?Math.max(g-1,0):g),h})},v=e.slice(o,o+t),x=e[n];return{scrollDown:b,scrollUp:u,outList:v,selectedIndex:n,selectedValue:x,refresh:a}}import{useInput as lo}from"ink";import{createContext as uo,useContext as mo}from"react";import{useEffect as Ye,useState as $e}from"react";import{jsx as po}from"react/jsx-runtime";var _e="\u2190",Ue="\u2192",qe=uo({});function Qe({children:e}){let[t,o]=$e("truncate-end"),[r,n]=$e(0),{removeKeybinding:i,setKeybinding:s}=M();return Ye(()=>(r&&(t==="truncate-start"?s(_e,"pan left"):s(Ue,"pan right")),()=>{i([Ue,_e])}),[t,r]),lo((c,l)=>{r&&(l.rightArrow?o("truncate-start"):l.leftArrow&&o("truncate-end"))}),po(qe.Provider,{value:{mode:t,_isToggleable:r,_setIsToggleable:n},children:e})}function F(){let e=mo(qe);if(Object.keys(e).length===0)throw new Error("useTruncationMode must be used within an TruncationModeProvider");let{mode:t,_setIsToggleable:o}=e;return Ye(()=>(o(r=>r+1),()=>o(r=>r-1)),[]),{mode:t}}import{createContext as fo,useContext as go,useEffect as ze,useMemo as ho,useRef as Je,useState as Xe}from"react";import{useInput as xo}from"ink";import{jsx as bo}from"react/jsx-runtime";var Ze=fo({});function je({children:e}){let{activeSection:t}=w(),{sectionHeight:o}=f(),r=o-3,{value:{tree:n,files:i}={},resolved:s}=y(vo),c=Je(new Set),l=Je(new Set(["."])),[a,m]=Xe();ze(()=>{n&&i&&(c.current=new Set(Object.keys(n)),m(i[0]))},[s]);let p=ho(()=>i?.filter(x=>c.current.has(x))??[],[c.current.size,s]),[b,u]=Xe(0),v=()=>u(x=>x+1);return xo((x,d)=>{if(t!=="Files"||!n||!a)return;if(d.upArrow){let g=Math.max(0,p.indexOf(a)-1);m(p[g]),v()}else if(d.downArrow){let g=Math.min(p.length-1,p.indexOf(a)+1);m(p[g]),v()}let h;if(d.leftArrow?h="collapse":d.rightArrow&&(h="expand"),h){let g=ie(n,a);if(!g)return;for(let T of Object.keys(g)){let E=`${a}/${T}`;h==="expand"?c.current.add(E):c.current.delete(E)}v()}}),ze(()=>{if(l.current.clear(),l.current.add("."),p.length<=r){p.forEach(G=>l.current.add(G));return}let x=a?yo(a):[],d=Math.max(1,r-x.length),h=p.filter(G=>!x.includes(G)),g=a?h.indexOf(a):0,T=Math.max(0,g-Math.floor(d/2)),E=T+d;E>h.length&&(E=h.length,T=Math.max(0,E-d));let Gt=h.slice(T,E);[...x,...Gt].forEach(G=>{l.current.add(G)})},[p.length,a,r]),bo(Ze.Provider,{value:{version:b,tree:n,visibleFiles:l.current,expandedFiles:c.current,selectedFile:a},children:e})}function A(){let e=go(Ze);if(Object.keys(e).length===0)throw new Error("useTreeNavigation must be used within an TreeNavigationProvider");return e}var ie=(e,t)=>{let o=t.split("/"),r=e;for(let n of o)r=r[n];return r},vo=async()=>{let e=await Se(),t=Me(e);return{tree:e,files:t}},yo=e=>{let t=e.split("/"),o=[];for(let r=1;r<t.length;r++)o.push(t.slice(0,r).join("/"));return o};import{jsx as R,jsxs as Mo}from"react/jsx-runtime";function et({setSha:e,mode:t}){let{label:o,value:r}=t,{sectionHeight:n}=f(),{activeSection:i,isLocked:s}=w(),{selectedFile:c}=A(),{mode:l}=F(),a=To(()=>r.length&&c?r(c):r(),[r,c]),{resolved:m,value:p=[]}=y(a,[o]),{scrollUp:b,scrollDown:u,outList:v,selectedValue:x}=_(p,n-2),d=x?.sha;return wo(()=>{e(d)},[d]),So((h,g)=>{i!=="Log"||s||(g.upArrow?b():g.downArrow&&u())}),R(S,{overflowY:"hidden",height:"100%",title:"Log",width:"50%",children:m&&v.map(({sha:h,message:g},T)=>Mo(U,{flexDirection:"row",flexWrap:"nowrap",children:[R(U,{minWidth:2,children:h===d?R(se,{children:"> "}):null}),R(U,{minWidth:8,children:R(se,{color:"yellow",children:h})}),R(U,{children:R(se,{wrap:l,children:g})})]},`${h}-${t.label}${t.label==="reflog"?T:""}`))})}import{useState as Go}from"react";import{useInput as Ho}from"ink";import Vo from"ink-text-input";import{useInput as Po}from"ink";import{createContext as Co,useContext as Eo,useEffect as Ao,useState as ce}from"react";import{Fragment as ko,jsx as Ro,jsxs as Bo}from"react/jsx-runtime";var tt=Co({});function P(){let e=Eo(tt);if(Object.keys(e).length===0)throw new Error("useKeybindings must be used within a KeybindingsProvider");return e}function ot({children:e}){let[t,o]=ce(null),{lock:r,unlock:n}=w(),[i,s]=ce(!1),[c,l]=ce(),a=()=>{n(),s(!1),c?.(),o(null)},m=()=>{r(),s(!0)},p=()=>{i?a():m()},b=(x,d)=>{a(),l(d?.onClose),o(x)};Po((x,d)=>{d.escape&&a()});let{setKeybinding:u,removeKeybinding:v}=M();return Ao(()=>{if(i)return u("esc","close"),()=>{v("esc")}},[i]),Ro(tt.Provider,{value:{setModal:b,open:m,close:a,toggle:p,isOpen:i},children:Bo(ko,{children:[e,t]})})}import{Box as st}from"ink";import ae from"node:path";import le from"node:os";import Lo from"node:fs/promises";import{createContext as No,useContext as Do}from"react";import{jsx as Io}from"react/jsx-runtime";var rt=No({});function nt({children:e}){let{value:t}=y(Fo);return Io(rt.Provider,{value:{bgColor:t},children:e})}var it=()=>{let e=Do(rt);if(Object.keys(e).length===0)throw new Error("useKeybindings must be used within a KeybindingsProvider");return e};async function Fo(){if(!(!process.stdin.isTTY||!process.stdout.isTTY))return process.env.TERM_PROGRAM==="vscode"?await Wo():new Promise(e=>{let t="\x1B]11;?\x07",o="",r,n=s=>{clearTimeout(r),process.stdin.off("data",i);try{process.stdin.setRawMode(!1),process.stdin.pause()}catch{}e(s)},i=s=>{o+=s.toString("ascii");let c=o.match(/\x1b]11;rgb:([0-9a-fA-F]{1,4})\/([0-9a-fA-F]{1,4})\/([0-9a-fA-F]{1,4})\x07/);if(c){let l=Oo(c[1],c[2],c[3]);n(l)}};try{process.stdin.setRawMode(!0),process.stdin.resume(),process.stdin.on("data",i),r=setTimeout(()=>n(void 0),150),process.stdout.write(t)}catch{n(void 0)}})}function Oo(e,t,o){return"#"+[e,t,o].map(r=>Math.round(parseInt(r,16)*255/((1<<4*r.length)-1)).toString(16).padStart(2,"0")).join("")}async function Wo(){let e="Code";process.env.TERM_PROGRAM_VERSION?.includes("insider")&&(e="Code - Insiders");let t;switch(process.platform){case"win32":t=ae.join(le.homedir(),"AppData","Roaming",e,"User","settings.json");break;case"linux":t=ae.join(le.homedir(),".config",e,"User","settings.json");break;case"darwin":t=ae.join(le.homedir(),"Library","Application Support",e,"User","settings.json");break;default:return}if(!await we(t))return;let o=await Lo.readFile(t,{encoding:"utf-8"}),{default:r}=await import("strip-json-comments"),n=r(o).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 de}from"react/jsx-runtime";var Ko=36;function O({children:e,title:t,width:o=Ko}){let r=f(),{width:n}=r,i=Math.floor((n-o)/2),{bgColor:s}=it();return de(st,{...r,position:"absolute",children:de(st,{alignSelf:"center",marginLeft:i,marginRight:i,children:de(S,{title:t,width:o,isModal:!0,backgroundColor:s,children:e})})})}import{jsx as ct}from"react/jsx-runtime";function at({title:e,handleSubmit:t}){let[o,r]=Go(""),{isOpen:n,close:i}=P();return Ho((s,c)=>{c.return&&n&&(t(o),r(""),i())}),n&&ct(O,{title:e,children:ct(Vo,{value:o,onChange:r})})}import{useInput as $o}from"ink";import _o from"ink-select-input";import{jsx as lt}from"react/jsx-runtime";function dt({title:e,handleSubmit:t,options:o,initialIndex:r,width:n}){let{isOpen:i,close:s}=P();return $o((c,l)=>{l.return&&i&&s()}),i&<(O,{title:e,width:n,children:lt(_o,{items:o,onSelect:t,initialIndex:r})})}var I=[{value:()=>W("git log --oneline -n 400"),label:"log"},{value:()=>W("git log --oneline --tags --no-walk --decorate"),label:"tags"},{value:()=>W("git reflog"),label:"reflog"},{value:()=>W('git log --oneline --author="$(git config user.name)"'),label:"my commits"},{value:e=>W(`git log --oneline "${e}"`),label:"file"},{value:e=>W(`git blame --follow "${e}"`),label:"blame"}];async function W(e){let{stdout:t}=await C(e);return t.trim().split(/\r?\n/).map(Uo)}function Uo(e){let t=e.indexOf(" ");return{sha:e.slice(0,t),message:e.slice(t+1)}}import{createContext as Yo,useContext as qo,useEffect as Qo,useState as zo}from"react";import{jsx as Jo}from"react/jsx-runtime";var ut=Yo({});function mt({children:e}){let[t,o]=zo(),r=(n,...i)=>{n(...i).catch(s=>o(s.stderr??s.message))};return Qo(()=>{if(t)throw new Error(t)},[t]),Jo(ut.Provider,{value:{attempt:r,err:t},children:e})}function Y(){let e=qo(ut);if(Object.keys(e).length===0)throw new Error("useErrorCatcher must be used within an ErrorCatcherProvider");return e}import{createContext as Xo,useContext as Zo,useState as jo}from"react";import{jsx as er}from"react/jsx-runtime";var pt=Xo({});function ft({children:e}){let[t,o]=jo(),r=i=>o(i),n=i=>{let s=t===i;return s&&o(void 0),s};return er(pt.Provider,{value:{sendMessage:r,receiveMessage:n},children:e})}function q(){let e=Zo(pt);if(Object.keys(e).length===0)throw new Error("useMessaging must be used within an MessagingProvider");return e}import{jsx as ue,jsxs as rr}from"react/jsx-runtime";function me(){let{setModal:e,toggle:t}=P(),[o,r]=ht(),{width:n,sectionHeight:i}=f(),[s,c]=ht(I[0]),{receiveMessage:l}=q();gt(()=>{l("log-file")&&c(I[4]),l("blame-file")&&c(I[5])},[]);let{isLocked:a}=w(),{attempt:m}=Y();or((u,v)=>{u==="m"&&(e(ue(dt,{options:I,title:"Log Type",handleSubmit:x=>c(x),initialIndex:I.indexOf(s)})),t()),!a&&u==="c"&&o&&m(()=>C(`git checkout ${o}`))});let{setKeybinding:p,removeKeybinding:b}=M();return gt(()=>(p("c","checkout"),p("m","mode"),()=>{b(["c","m"])}),[]),rr(tr,{width:n,height:i,children:[ue(et,{setSha:r,mode:s}),ue(He,{sha:o})]})}import{useEffect as mr}from"react";import{Box as wt}from"ink";import{Box as pe,Text as xt,useInput as nr}from"ink";import{useEffect as ir}from"react";import{Fragment as cr,jsx as L,jsxs as sr}from"react/jsx-runtime";function vt(){let{activeSection:e,isLocked:t}=w(),{sectionHalfHeight:o}=f(),{value:r=[],refresh:n}=y(Ae),{value:i,refresh:s}=y(Pe),{setKeybinding:c,removeKeybinding:l}=M();ir(()=>{if(e==="Branches")return c("s","switch"),()=>{l("s")}},[e]);let{outList:a,selectedValue:m,scrollUp:p,scrollDown:b}=_(r,o-2),u=async T=>{await C(`git branch ${T}`),n()},v=async()=>{await C(`git branch -D ${m}`),n()},x=async()=>{await C(`git switch ${m}`),n(),s()},{setModal:d,open:h}=P(),{attempt:g}=Y();return nr((T,E)=>{e!=="Branches"||t||(E.upArrow?p():E.downArrow?b():T==="c"?(d(L(at,{title:"Name your new branch",handleSubmit:u})),h()):T==="d"?g(v):T==="s"&&g(x))}),L(cr,{children:L(S,{width:"100%",title:"Branches",innerHeight:o-1,children:a.map(T=>sr(pe,{flexDirection:"row",flexWrap:"nowrap",children:[L(pe,{minWidth:2,children:T===m?L(xt,{children:"> "}):null}),L(pe,{minWidth:8,children:L(xt,{color:T===i?"magenta":void 0,children:T})})]},T))})})}import{Text as fe}from"ink";import{Fragment as ar}from"react";import{jsx as ge,jsxs as yt}from"react/jsx-runtime";function bt(){let{value:e}=y(ke);return ge(S,{width:"50%",title:"Remotes",children:e?.map(({url:t,name:o,type:r})=>yt(ar,{children:[yt(fe,{wrap:"truncate-end",children:[o," (",r,")"]}),ge(fe,{wrap:"truncate-end",children:t}),ge(fe,{children:" "})]},`${o}-${r}`))})}import{Text as he}from"ink";import{Fragment as lr}from"react";import{jsx as Q,jsxs as ur}from"react/jsx-runtime";function Tt(){let{sectionHalfHeight:e}=f(),{value:t}=y(dr);return Q(S,{width:"100%",title:"Worktrees",innerHeight:e-1,children:t?.map(({branch:o,detached:r,path:n,head:i})=>ur(lr,{children:[Q(he,{children:r?i:o}),Q(he,{children:n}),Q(he,{children:" "})]},n))})}async function dr(){let{stdout:e}=await C("git worktree list --porcelain"),t=e.trim().split(/\r?\n/),o=[],r=[];for(let n of t)n.trim()===""?r.length&&(o.push(r),r=[]):r.push(n);return r.length&&o.push(r),o.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 pr,jsx as z,jsxs as St}from"react/jsx-runtime";function Mt(){let{width:e,sectionHeight:t}=f(),{setKeybinding:o,removeKeybinding:r}=M();return mr(()=>(o("c","create"),o("d","delete"),()=>{r(["c","d"])}),[]),z(pr,{children:St(wt,{width:e,height:t,children:[St(wt,{flexDirection:"column",width:"50%",height:t,children:[z(vt,{}),z(Tt,{})]}),z(bt,{})]})})}import{Component as fr,useEffect as gr}from"react";import{Text as Pt}from"ink";import{jsx as xe}from"react/jsx-runtime";function J({title:e,message:t,width:o}){let{isOpen:r}=P(),{mode:n}=F();return r&&xe(O,{title:e,width:o,children:Array.isArray(t)?t.map(i=>xe(Pt,{wrap:n,children:i})):xe(Pt,{children:t})})}import{jsx as Ct}from"react/jsx-runtime";var X=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,o){let r=t?.stderr??t?.message;this.setState({hasError:!0,message:r})}render(){return this.state.hasError?Ct(hr,{dismissError:this.dismissError.bind(this),message:this.state.message,children:this.props.children}):this.props.children}};function hr({message:e,dismissError:t,children:o}){let{setModal:r,open:n}=P(),{modalWidth:i}=f();return gr(()=>{if(e){let s=e.split(/\r?\n/).map(c=>c.trim());r(Ct(J,{title:"Error",message:s,width:i}),{onClose:t}),n()}},[e]),o}import{Box as Ar,useInput as kr}from"ink";import{useEffect as Br}from"react";import{Box as ve,Text as Bt}from"ink";import ye from"node:path";import{memo as xr,useEffect as Et,useState as vr}from"react";import{Fragment as wr,jsx as B,jsxs as be}from"react/jsx-runtime";var yr="\u2190",br="\u2191",Rt="\u2192",Lt="\u2193",At=`${yr}${br}${Lt}${Rt}`;function Nt(){let{sectionHeight:e}=f(),{activeSection:t}=w(),{setKeybinding:o,removeKeybinding:r}=M();Et(()=>{if(t==="Files")return o(At,"NAVIGATION_KEY"),()=>r(At)},[t]);let{tree:n,version:i}=A(),{value:s}=y(Ce),[,c]=vr(0);return Et(()=>{c(l=>l+1)},[i]),B(S,{title:"Files",innerHeight:e,width:"50%",children:s&&n&&B(Dt,{name:ye.basename(s),contents:n,depth:0,fp:s})})}function Dt(e){let{contents:t,depth:o,fp:r,rp:n="."}=e,i=Object.keys(t).length===0,{selectedFile:s,visibleFiles:c,expandedFiles:l}=A(),a=n===s;if(!c.has(n))return null;let m=o+2;if(i)return B(kt,{...e,depth:m,isSelected:a},r);let p=`${n}/`,b=Tr(l,u=>u.startsWith(p))||o===0;return be(wr,{children:[be(ve,{flexDirection:"row",flexWrap:"nowrap",children:[B(ve,{width:2,children:B(Bt,{children:b?Lt:Rt})}),B(ve,{width:"100%",children:B(kt,{...e,isSelected:a})})]}),b&&Object.entries(t).map(([u,v])=>{let x=ye.join(n,u),d=ye.join(r,u);return B(Dt,{name:u,contents:v,depth:m,rp:x,fp:d})})]})}var kt=xr(({name:e,depth:t,isSelected:o})=>be(Bt,{wrap:"truncate-end",color:o?"yellow":void 0,children:["\xA0".repeat(t),e]}),(e,t)=>e.isSelected===t.isSelected&&e.fp===t.fp);function Tr(e,t){for(let o of e)if(t(o))return!0;return!1}import{Box as Sr,measureElement as Mr,Text as K}from"ink";import{useMemo as Pr,useRef as Cr}from"react";import{jsx as Z,jsxs as V}from"react/jsx-runtime";function Ft(){let{sectionHeight:e}=f(),{selectedFile:t}=A(),o=Cr(null),r=Pr(()=>{if(!o.current)return 0;let{width:m}=Mr(o.current);return m-4},[o.current]),{value:n={}}=y(()=>Be(t),[t]),{authorDate:i,authorEmail:s,authorName:c,shortHash:l}=n,{mode:a}=F();return Z(Sr,{width:"50%",height:e,ref:o,children:V(S,{width:"100%",title:"File Meta",innerHeight:e-1,children:[t&&Z(Er,{width:r,text:t}),l&&V(K,{wrap:a,children:["Last Commit: ",l]}),c&&V(K,{wrap:a,children:["Edited By: ",c]}),i&&V(K,{wrap:a,children:["Edit On: ",i]}),s&&V(K,{wrap:a,children:["Contact: ",s]})]})})}function Er({width:e,text:t}){if(t.length>e)return Z(K,{children:t});let o=Math.max(0,e-t.length-2),r=Math.floor(o/2),n=o-r,i=`${"=".repeat(r)} ${t} ${"=".repeat(n)}`;return Z(K,{children:i})}import{jsx as Te,jsxs as Rr}from"react/jsx-runtime";function Ot(){let{width:e,sectionHeight:t}=f(),{selectedFile:o,tree:r}=A(),{setKeybinding:n,removeKeybinding:i}=M();Br(()=>(n("l","log"),n("b","blame"),()=>{i(["l","b"])}),[]);let{setActiveGroup:s}=w(),{sendMessage:c}=q(),{setModal:l,open:a}=P();return kr((m,p)=>{m==="l"?(c("log-file"),s("Log")):m==="b"&&(Object.keys(ie(r??{},o)).length===0?(c("blame-file"),s("Log")):(l(Te(J,{title:"Sorry",message:["Can't blame a folder."]})),a()))}),Rr(Ar,{width:e,height:t,children:[Te(Nt,{}),Te(Ft,{})]})}import{jsx as k,jsxs as Fr}from"react/jsx-runtime";function Wt(){let{prevSection:e,nextSection:t,activeGroup:o,setActiveGroup:r}=w();return Nr((n,i)=>{i.tab&&i.shift?e():i.tab?t():n==="1"?r("Files"):n==="2"?r("Status"):n==="3"?r("Log"):n==="4"&&r("Branches")}),k(X,{children:k(mt,{children:k(ft,{children:k(je,{children:k(Dr,{group:o})})})})})}function Dr({group:e}){switch(e){case"Files":return k(Ot,{});case"Status":return k(Ke,{});case"Log":return k(me,{});case"Branches":return k(Mt,{});default:return Fr(Lr,{children:['Error, unknown page "',e,'"']})}}import{jsx as j,jsxs as Kr}from"react/jsx-runtime";function Kt(){let{isLocked:e,activeGroup:t}=w();Ir((i,s)=>{e||i.toLowerCase()==="q"&&process.exit()});let o=f(),{keybindings:r,setKeybinding:n}=M();return Or(()=>n("q","quit"),[]),Kr(It,{flexDirection:"column",...o,children:[j(Oe,{activeGroup:t}),j(Wt,{}),j(It,{flexDirection:"row",children:Object.entries(r).map(([i,s])=>j(Wr,{children:`[${i}]: ${s} `},s))})]})}import{jsx as N}from"react/jsx-runtime";function Hr(){return N(nt,{children:N(De,{children:N(Le,{children:N(Qe,{children:N(ot,{children:N(Kt,{})})})})})})}var da=()=>Gr(N(Hr,{}),{patchConsole:!0});export{da as renderApp};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as r}from"./chunk-
|
|
2
|
+
import{a as r}from"./chunk-R7DNYVL6.js";var i=["init","clone","add","status","diff","commit","restore","reset","branch","checkout","switch","merge","log","stash","tag","worktree","fetch","pull","push","remote","submodule","show","apply","cherry-pick","rebase","revert","bisect","blame","grep","clean","fsck","reflog","bundle","daemon","cat-file","check-ignore","checkout-index","commit-tree","count-objects","diff-index","for-each-ref","hash-object","ls-files","ls-tree","merge-base","read-tree","rev-list","rev-parse","show-ref","symbolic-ref","update-index","update-ref","verify-pack","write-tree","column"];function t(e){return i.includes(e)}var n=["auth","browse","codespace","gist","issue","org","pr","project","release","repo","cache","run","workflow","agent-task","alias","api","attestation","completion","config","extension","gpg-key","label","preview","ruleset","search","secret","ssh-key","status","variable"];function s(e){return n.includes(e)}var o=e=>{r(e,process.argv.slice(2),{stdio:"inherit",silent:!0})};async function f(e){return t(e)?(o("git"),!0):s(e)?(o("gh"),!0):!1}export{f as runWrapper};
|
package/dist/main.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{a as
|
|
2
|
+
import{a as o,d as t}from"./chunks/chunk-L4626BRA.js";import"./chunks/chunk-DLHREY2Q.js";import"./chunks/chunk-R7DNYVL6.js";async function a(){let r=o();if(!r){t();let{renderApp:i}=await import("./chunks/pages-JELX53G4.js");return i()}let{runCommand:n}=await import("./chunks/commands-XBKP3MSC.js");if(await n(r))return;let{runWrapper:e}=await import("./chunks/wrapper-PHXQ7CVF.js");await e(r)||(console.error("unknown command"),process.exit(1))}a().catch(r=>{console.error(`An error occurred: ${r.stderr??r.message}`),process.exit(1)});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bisgit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.6.0",
|
|
4
4
|
"description": "Git CLI tool to simplify common advanced git workflows",
|
|
5
5
|
"main": "dist/main.js",
|
|
6
6
|
"bin": {
|
|
@@ -60,9 +60,11 @@
|
|
|
60
60
|
"chalk": "^5.6.2",
|
|
61
61
|
"clipboardy": "^5.0.2",
|
|
62
62
|
"ink": "^6.6.0",
|
|
63
|
+
"ink-select-input": "^6.2.0",
|
|
63
64
|
"ink-spinner": "^5.0.0",
|
|
64
65
|
"ink-text-input": "^6.0.0",
|
|
65
66
|
"nanoid": "^5.1.6",
|
|
66
|
-
"react": "^19.2.3"
|
|
67
|
+
"react": "^19.2.3",
|
|
68
|
+
"strip-json-comments": "^5.0.3"
|
|
67
69
|
}
|
|
68
70
|
}
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
function t(){return process.argv[2]}function n(){return process.argv.slice(3)}async function o(){let[r,e]=n();return r||(console.error("Requires <branch> or <remote> <branch>"),process.exit(1)),e?{remote:r,branch:e}:{remote:"origin",branch:r}}export{t as a,n as b,o as c};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{exec as d,spawn as l}from"node:child_process";import{promisify as g}from"node:util";function f(e,i,r){let n=l(e,i,r??{});r?.silent||(n.stdout?.on("data",o=>{console.log(String(o))}),n.stderr?.on("data",o=>{console.error(String(o))})),n.on("close",o=>{r?.triggerExit&&process.exit(o)})}var w=g(d);async function x(e,i,r={}){let{promise:n,resolve:o,reject:c}=Promise.withResolvers(),t=l(e,i,r),p="",a="";return t.stdout?.on("data",s=>p+=s),t.stderr?.on("data",s=>a+=s),t.on("close",s=>o({code:s,stdout:p,stderr:a})),t.on("error",s=>c(s)),n}async function h(e,i="inherit"){let{promise:r,resolve:n,reject:o}=Promise.withResolvers(),c=l("git",["-c","color.ui=always",...e],{stdio:i});return c.on("close",t=>{t===0?n({code:t}):o({code:t})}),c.on("error",o),r}export{f as a,w as b,x as c,h as d};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{b as n,c as s}from"./chunk-HCUVDNFV.js";import{normalize as a}from"node:path";async function g(){let{stdout:t}=await n("git branch --show-current");return t.trim()}async function l(t){t??=await g();let{stdout:r}=await n(`git config --get branch.${t}.remote`);return r.trim()}async function d(t,r){try{let{stdout:e}=await n(`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 y(t,r){try{let{stdout:e}=await n(`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 h(t){let{stdout:r}=await n(`git rev-parse --git-path ${t}`);return a(r.trim())}async function w(){let{stdout:t}=await n("git rev-parse --git-dir");return a(t.trim())}async function x(t){let{code:r}=await s("git",["remote","get-url",t],{stdio:"ignore"});return r===0}async function $(){let{stdout:t}=await n("git rev-parse --abbrev-ref HEAD");return t.trim()==="HEAD"}async function v(t,r){let e="git fetch";t&&(e+=` ${t}`),r&&(e+=` ${r}`),await n(e)}async function P(){let{stdout:t}=await s("git",["status","--porcelain"]);return!t?.trim()}async function b(){let{stdout:t}=await s("git",["status","--porcelain"]);return t?.trim()?.split(/\r?\n/)}async function m(t,r){let{stdout:e}=await n(`git merge-base ${t} ${r}`);return e.trim()}async function D(t,r){let e=await m(t,r),{stdout:i}=await s("git",["merge-tree",e,r,t]);return!i?.split(/\r?\n/)?.includes("+=======")}async function R(t){let{stdout:r}=await n(`git rev-parse ${t}`);return r.trim()}async function A(t,r,e){let{stdout:i}=await n(`git rev-list ${e?"--reverse":""} ${t}..${r}`);return i.trim().split(/\r?\n/)}async function B(){let{stdout:t}=await n("git for-each-ref --format='%(refname:short)' refs/heads");return t.trim().split(/\r?\n/)}async function G(){let{stdout:t}=await n("git remote -v");return t.trim().split(/\r?\n/).map(e=>{let i=e.match(/^(\S+)\s+(\S+)\s+\((fetch|push)\)$/);if(!i)return null;let[,o,c,u]=i;return{name:o,url:c,type:u}}).filter(e=>e!==null)}export{g as a,l as b,d as c,y as d,h as e,w as f,x as g,$ as h,v as i,P as j,b as k,m as l,D as m,R as n,A as o,B as p,G as q};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{b as g,c as K}from"./chunk-5WTQIRZS.js";import{a as u,b as V,c as k,d as B,e as v,f as z,g as J,h as Z,i as H,j as h,k as W,l as x,m as Q,n as X,o as G,p as tt}from"./chunk-ZLDM3RDV.js";import{a as $,b as s,c as q,d as l}from"./chunk-HCUVDNFV.js";import A from"node:path";import Ft from"fs/promises";async function w(t){try{return await Ft.access(t),!0}catch{return!1}}async function et(){let t=await W(),e=/^(UU|DU|UD)/;return!!t?.some(o=>e.test(o))}async function F(){let t=await z(),[e,o,r,i,n]=await Promise.all([await w(A.join(t,"MERGE_HEAD")),await w(A.join(t,"rebase-merge")),await w(A.join(t,"rebase-apply")),await w(A.join(t,"CHERRY_PICK_HEAD")),await w(A.join(t,"REVERT_HEAD"))]);return{merge:e,rebaseMerge:o,rebaseApply:r,cherryPick:i,revert:n}}async function ot(){let{merge:t,rebaseMerge:e,rebaseApply:o,cherryPick:r,revert:i}=await F(),n="";if(t)n="merge";else if(e||o)n="rebase";else if(r)n="cherry-pick";else if(i)n="revert";else{let a=await et()?"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 ${n}`),await l([n,"--abort"])}function rt(){$("git",["commit","--amend","--no-edit",...g()],{stdio:"inherit",silent:!0,triggerExit:!0})}import{render as Yt}from"ink";import{spawnSync as it}from"node:child_process";function D(t,e,o){let{status:r}=it(t,e,{stdio:"ignore"});r!==0&&(o&&console.error(o),process.exit(1))}var nt=()=>D("git",["rev-parse","--git-dir"],"Need to use command in a git repository."),R=()=>D("git",["rev-parse","HEAD"],"Need to create first commit."),d=(t="origin")=>D("git",["remote","get-url",t],`Need to add remote '${t}'.`),U=t=>D("git",["show-ref","--branches",t],`Branch '${t}' isn't tracked locally and may not exist.`),P=async()=>{await h()||(console.error("You should stash or commit your changes first."),process.exit(1))},M=async t=>{await w(t)||(console.error(`${t} must exist for this operation and it doesn't for some reason`),process.exit(1))},st=async()=>{await Z()&&(console.error("Operation not allowed in a 'detached HEAD' state"),process.exit(1))},at=t=>D("git",["rev-parse","--abbrev-ref","--symbolic-full-name",`${t}@{u}`],`branch '${t}' has no upstream`);function y(t="Error: missing required argument"){if(process.argv[3])return process.argv[3];console.error(t),process.exit(1)}async function N(){let{status:t}=it("git",["diff","--staged","--quiet"],{stdio:"ignore"});t===0&&(console.error("You have no staged changes"),process.exit(1))}import{render as jt}from"ink";import{Suspense as Mt,use as Nt,useEffect as Tt}from"react";import{Text as ct,useApp as Lt}from"ink";import It from"ink-spinner";import{jsx as T,jsxs as Ot}from"react/jsx-runtime";function c(t){let{msg:e}=t;return T(Mt,{fallback:Ot(ct,{children:[T(It,{type:"dots"}),"\xA0",e]}),children:T(Ut,{...t})})}function Ut({msg:t,promise:e}){let o=Nt(e),{exit:r}=Lt();return Tt(()=>{r()},[o]),T(ct,{children:`\u2714 ${typeof o=="string"?o:t}`})}import{jsx as _t}from"react/jsx-runtime";async function mt(){let t=process.argv[3],e=process.argv[4]??await u();if(U(t),U(e),t===e)return console.log(`No reason to merge '${t}' into '${e}'`);let o=await V(t);d(o),jt(_t(c,{msg:"Updating target branch and merging",promise:(async()=>{try{await S(o,t)}catch{console.error(`Error when updating branch ${t} with remote ${o}. Fix divergent branches before merging into ${e}`);return}await u()!==e&&await s(`git switch ${e}`),$("git",["merge",t],{stdio:"inherit",silent:!0})})()}))}async function S(t,e){await H(t,e);let[o,r,i]=await Promise.all([k(t,e),B(t,e),u()]);if(r!==0){if(o===0&&i!==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 l(["merge",`${t}/${e}`],["ignore","ignore","inherit"])}}async function E(){R(),d();let{stdout:t,code:e}=await q("git",["rev-parse","--abbrev-ref","origin/HEAD"]);if(e===0)return lt(t.trim());await s("git remote set-head origin -a");let{stdout:o}=await s("git rev-parse --abbrev-ref origin/HEAD");return lt(o.trim())}async function ft(){let{remote:t,branch:e}=await E();console.log(`Remote default branch is '${t}/${e}'`)}async function lt(t){let e=t.split("/"),o=t.split("/").map((r,i)=>e.slice(0,i+1).join("/"));for(let r of o)if(await J(r)){let i=t.slice(r.length+1);return{remote:r,branch:i}}throw new Error("Failed to get default remote")}import{jsx as Vt}from"react/jsx-runtime";var Kt=["master","main","development","lingoport"];async function pt(){await P();let{branch:t,remote:e}=await E();await s(`git switch ${t}`);let o=(async()=>{await l(["fetch","--prune","--prune-tags"]),await S(e,t)})();Yt(Vt(c,{msg:"Fetching and pruning remote references",promise:o})),await o;let r=await tt();for(let i of r){if(i===t||Kt.includes(i))continue;let n=await x(i,t),{code:a}=await q("git",["diff","--quiet",n,i]);a===0&&await l(["branch","-D",i])}}import{spawn as zt}from"node:child_process";import{createInterface as Jt}from"node:readline/promises";async function gt(){R;let e=[...(await Zt()).entries()].sort(([,r],[,i])=>i-r).slice(0,25),o=e[0][1].toString().length;console.info(e.map(([r,i])=>`${String(i).padEnd(o)} ${r}:`).join(`
|
|
3
|
-
`))}async function Zt(){let{promise:t,resolve:e,reject:o}=Promise.withResolvers(),r=new Map,i=zt("git",["log","--all","-M","-C","--name-only","--format=format:"]),n=Jt({input:i.stdout,crlfDelay:1/0});return n.on("line",a=>{let m=a.trim();m&&r.set(m,(r.get(m)??0)+1)}),n.on("close",()=>e(r)),i.on("error",o),t}import{render as Qt}from"ink";import{jsx as te}from"react/jsx-runtime";async function ut(){await N();let t=y("Error: missing github username argument"),e=(async()=>{let i=await Xt(t);return i.email||(console.error(`Couldn't find an email for ${t}`),process.exit(1)),i})();Qt(te(c,{msg:"Fetching name and email",promise:e}));let{name:o,email:r}=await e;l(["commit","--edit","-m","<insert summary>","-m",`Co-authored-by: ${o} <${r}>`])}async function Xt(t){let{stdout:e}=await s(`gh api users/${t}`);return JSON.parse(e.trim())}import{render as O}from"ink";import{isDeepStrictEqual as ee}from"node:util";import{jsx as j}from"react/jsx-runtime";async function ht(){let t=y("Error: missing id of PR to checkout");await P();let e=(async()=>Promise.all([s(`gh co ${t}`),s(`gh pr view ${t} --json baseRefName -q .baseRefName`)]))();O(j(c,{msg:`Checking out pr #${t}`,promise:e}));let[,{stdout:o}]=await e,r=o.trim(),i=(async()=>{await s(`git switch ${r}`),await s("git pull"),await s("git switch -")})();O(j(c,{msg:`Updating ${r} branch merge destination`,promise:i})),await i;let n=(async()=>{let p=await x(r,"HEAD");return await s(`git reset ${p} --soft`),await oe("HEAD")})();O(j(c,{msg:"Creating an editable, explorable, local PR experience",promise:n}));let[a,m]=await Promise.all([n,re(t)]),{files:f,additions:b,deletions:I}=m;if(ee(a,m))return console.info(`Files: ${f}, +${b} -${I}`);console.info("The PR stat doesn't match the local stat."),console.info("LOCAL"),console.table(a),console.info("GITHUB"),console.table(m),console.info("One option to fix (there'll likely be conflicts):"),console.info("1. git stash -u"),console.info(`2. git merge ${r}`),console.info("3. git stash pop")}async function oe(t){let{stdout:e}=await s(`git diff --shortstat ${t}`),o=/(\d+)\s+files? changed(?:, (\d+) insertions?\(\+\))?(?:, (\d+) deletions?\(-\))?/,r=e.trim().match(o);if(!r)throw new Error(`Couldn't generate short stat for ref(s): ${t}`);let[,i,n,a]=r;return{files:parseInt(i,10),additions:n?parseInt(n,10):0,deletions:a?parseInt(a,10):0}}async function re(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 ie}from"node:child_process";import{createInterface as ne}from"node:readline/promises";import _ from"chalk";async function wt(){let t=y("Error: missing target branch argument"),e=await x("HEAD",t),{promise:o,resolve:r,reject:i}=Promise.withResolvers(),n=ie("git",["merge-tree",e,"HEAD",t]),a=ne({input:n.stdout,crlfDelay:1/0}),m=!1,f=0;a.on("line",p=>{p=p.trimEnd(),p==="+<<<<<<< .our"?(m=!0,console.info(_.red(p)),f+=1):p==="+>>>>>>> .their"?(m=!1,console.info(_.green(p))):p==="+======="?console.info(_.yellow(p)):m&&console.info(p)}),a.on("close",()=>r(f)),n.on("error",i);let b=await o,I=b?`\u274C ${b} conflicts would occur!`:"\u2705 No conflicts. Safe to merge.";console.info(I)}async function dt(){let{merge:t,rebaseMerge:e,rebaseApply:o,cherryPick:r,revert:i}=await F(),n="";if(t)n="merge";else if(e||o)n="rebase";else if(r)n="cherry-pick";else if(i)n="revert";else{console.log("Nothing to continue.");return}console.log(`Continuing the ${n}`),await l([n,"--continue"])}import{appendFileSync as ae}from"node:fs";import{readFile as se}from"node:fs/promises";async function L(t){return(await se(t,"utf-8")).split(/\r?\n/).map(o=>o.trim()).filter(o=>o&&!o.startsWith("#"))}async function yt(){let t=await v("info/exclude");await M(t);let e=await L(t);g().forEach(o=>{e.includes(o)?console.info(`Already Exists: '${o}'`):(ae(t,`${o}
|
|
4
|
-
`),console.info(`Added '${o}'`))}),console.info(`
|
|
5
|
-
See file at ${t}`)}function bt(){$("git",["show","--name-only","--pretty=format:",...g()],{stdio:"inherit",silent:!0,triggerExit:!0})}import{spawn as ce}from"node:child_process";async function $t(){let t=y("Error: missing valid target ref argument");await N();let e=await X(t);await l(["commit",`--fixup=${e}`]);let r=(await G(`${e}^`,"HEAD",!0)).map(n=>me(n));(await Promise.all(r)).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 me(t){let{stdout:e}=await s(`git diff ${t}^ ${t}`),{promise:o,resolve:r,reject:i}=Promise.withResolvers(),n=ce("git",["apply","--check","--3way","-q"],{stdio:["pipe","ignore","ignore"]});return n.on("close",a=>{r(a===0)}),n.on("error",i),n.stdin.write(e),n.stdin.end(),o}import{readFile as le,writeFile as fe}from"node:fs/promises";async function xt(){let t=await v("info/exclude");await M(t);let e=await L(t),o=g();o.filter(a=>!e.includes(a)).forEach(a=>console.info(`No match: '${a}'`));let i=(await le(t,"utf-8")).split(/\r?\n/).map(a=>a.trim()),n=i.filter(a=>!o.includes(a));await fe(t,n.join(`
|
|
6
|
-
`)),console.info(`
|
|
7
|
-
Removed ${i.length-n.length} entries from ${t}`)}import{render as pe}from"ink";import{jsx as we}from"react/jsx-runtime";async function Rt(){let t=(async()=>{let i=await ge();return await ue(i)})();pe(we(c,{msg:"Fetching repo languages",promise:t}));let e=await t,o=Object.values(e).reduce((i,n)=>i+n,0),r=Object.entries(e).map(([i,n])=>`${i}: ${Math.round(n/o*100)}% - ${he(n)}`);console.log(r.join(`
|
|
8
|
-
`))}async function ge(){let{stdout:t}=await s("gh repo view --json nameWithOwner -q .nameWithOwner");return t.trim()}async function ue(t){let{stdout:e}=await s(`gh api repos/${t}/languages`);return JSON.parse(e.trim())}function he(t,e=2){if(t===0)return"0 B";let o=1024,r=e<0?0:e,i=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],n=Math.floor(Math.log(t)/Math.log(o));return`${parseFloat((t/Math.pow(o,n)).toFixed(r))} ${i[n]}`}import{execSync as de}from"node:child_process";function ye(){return de("git rev-parse --show-toplevel",{encoding:"utf-8"}).trim()}function Pt(){let t=ye();console.log(t)}import{render as vt}from"ink";function Ct(){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 C(){let t=Ct();await s("git add -A"),await l(["commit","-m",`"WIP ${t}"`])}import{nanoid as be}from"nanoid";import $e from"chalk";import{jsx as At}from"react/jsx-runtime";async function Dt(){let{remote:t,branch:e}=await E(),o=process.argv[3]??e;await h()||await C(),await Q(o,"HEAD")||(console.warn("Conflicts would occur. Not safe to rebranch."),process.exit(1));let r=await u(),i=(async()=>{await S(t,o)})();vt(At(c,{msg:`Updating branch ${o}`,promise:i})),await i;let n=`${be(8)}`,a=(async()=>{await s(`git switch ${r}`),await s(`git branch ${n}`),await s(`git switch ${o}`),await s(`git branch -D ${r}`),await s(`git switch -c ${r}`);let m=await G(o,n,!0);for(let f of m)try{await s(`git cherry-pick ${f}`)}catch{let b=$e.yellow(`git branch -D ${r} && git branch -m ${n} ${r}`);throw new Error(`\u274C cherry pick failed at ${f}
|
|
9
|
-
Run this to restore backup branch
|
|
10
|
-
> ${b}`)}await s(`git branch -D ${n}`)})();vt(At(c,{msg:`Rewriting branch ${r}`,promise:a})),await a,console.info(`Successfully recreated branch ${r} from ${o}`)}import{execSync as xe}from"node:child_process";async function St(){R();let t=Re(process.argv[3]),{default:e}=await import("clipboardy");await e.write(t),console.log(`'${t}' copied to clipboard`)}function Re(t="HEAD"){return xe(`git rev-parse --short ${t}`,{encoding:"utf-8"}).trim()}import{render as Pe}from"ink";import{jsx as Ce}from"react/jsx-runtime";async function Et(){let{remote:t,branch:e}=await K();d(t),await P();let o=H(t,e);Pe(Ce(c,{msg:`Fetching branch ${e} from ${t}`,promise:o})),await o,await l(["switch","-c",e,"--track",`${t}/${e}`])}async function qt(){let[t,e]=await Promise.allSettled([await Ae("user.name"),await ve()]);t.status==="fulfilled"&&console.info(`Git: ${t.value}`),e.status==="fulfilled"&&console.info(`Github: ${e.value}`)}async function ve(){let{stdout:t}=await s("gh api user --jq .login");return t.trim()}async function Ae(t){let{stdout:e}=await s(`git config ${t}`);return e.trim()}import{render as He}from"ink";import{Text as De,useApp as Se,useInput as Ee}from"ink";import{useState as qe}from"react";import{Fragment as Be,jsx as ke,jsxs as kt}from"react/jsx-runtime";function Bt({prompt:t,msg:e,onConfirm:o}){let[r,i]=qe(""),{exit:n}=Se();return Ee((a,m)=>{if(r)return;let f=a.toLowerCase();f==="y"?i("Yes"):(f==="n"||m.return)&&(i("No"),n())}),kt(Be,{children:[kt(De,{children:[t," [y/N] ",r]}),r==="Yes"&&ke(c,{msg:e,promise:o()})]})}import{jsx as We}from"react/jsx-runtime";async function Ht(){if(nt(),await h())return console.log("Already a clean working tree");let t=await W();if(!t)throw new Error("git status cmd failed");let e=new Y(t);e.displayReport(),He(We(Bt,{prompt:"Approve these changes?",msg:"Running git reset && git clean",onConfirm:async()=>(await s("git reset --hard"),await s("git clean -f"),`Altered ${e.willDelete.length+e.willRecreate.length+e.willRevert.length} files.`)}))}var Y=class{willDelete=[];willRecreate=[];willRevert=[];constructor(e){e.forEach(o=>{if(o){let r=o.slice(0,2).trim(),i=o.slice(3);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}
|
|
11
|
-
${o.map(r=>`- ${r}
|
|
12
|
-
`)}`)}};import{nanoid as Ge}from"nanoid";import{render as Fe}from"ink";import{jsx as Me}from"react/jsx-runtime";async function Wt(){await st();let t=process.argv[3]??"origin";d(t);let e=await u();at(e);let o="",i=(async()=>{let n=[s(`git fetch ${t} ${e} --force`)];await h()||n.push(C()),await Promise.all(n);let[a,m]=await Promise.all([k(t,e),B(t,e)]);if(!(a===0&&m===0)){if(a!==0){let f=`${e}-${Ge(8)}`;o=`Created branch ${f}`,await s(`git branch ${f}`)}await s(`git reset --hard ${t}/${e}`)}})();Fe(Me(c,{msg:`Force pull reseting ${e} -> ${t}`,promise:i})),await i,o&&console.info(o)}var Gt={abort:ot,amend:rt,autoprune:pt,backmerge:mt,churn:gt,coauthor:ut,"code-review":ht,conflict:wt,continue:dt,exclude:yt,files:bt,fixup:$t,include:xt,languages:Rt,pwd:Pt,rebranch:Dt,"remote-default":ft,savepoint:C,sha:St,track:Et,whoami:qt,wipe:Ht,yank:Wt};async function Ki(t){return await Gt[t]?.(),Object.hasOwn(Gt,t)}export{Ki as runCommand};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
import{a as J,k as Q,p as X,q as Z}from"./chunk-ZLDM3RDV.js";import{b as w}from"./chunk-HCUVDNFV.js";import{render as yt}from"ink";import{createContext as Ke,useContext as Le,useState as De}from"react";import{jsx as Ne}from"react/jsx-runtime";var j=Ke(void 0),ee=({children:e})=>{let[t,o]=De({}),n=(r,s)=>{o(c=>({...c,[r]:s}))},i=r=>{let s=Array.isArray(r)?r:[r];o(c=>{let l={...c};for(let a of s)delete l[a];return l})};return Ne(j.Provider,{value:{keybindings:t,setKeybinding:n,removeKeybinding:i},children:e})},b=()=>{let e=Le(j);if(!e)throw new Error("useKeybindings must be used within a KeybindingsProvider");return e};import{useEffect as ht}from"react";import{Text as gt,Box as ke,useInput as xt}from"ink";import{useStdout as Pe}from"ink";function h(){let{stdout:e}=Pe(),t=e.rows-2,o=Math.floor(t/2);return{width:e.columns,height:e.rows,sectionHeight:t,sectionHalfHeight:o}}import{Box as ne,Text as Me}from"ink";import{useState as I,createContext as Re,useContext as We}from"react";import{jsx as Ae}from"react/jsx-runtime";var B={Status:"Status",Log:"Log","Commit Details":"Log",Branches:"Branches",Worktrees:"Branches",Remotes:"Branches"},C=Object.keys(B),te=Re({});function oe({children:e}){let[t,o]=I(!1),n=()=>o(!0),i=()=>o(!1),[r,s]=I("Status"),[c,l]=I("Status"),a=u=>{t||(l(u),s(B[u]))},m=u=>{t||(s(u),l(u))},f=()=>{t||l(u=>{let d=C.at((C.indexOf(u)+1)%C.length);return s(B[d]),d})},p=()=>{t||l(u=>{let d=C.at(C.indexOf(u)-1);return s(B[d]),d})};return Ae(te.Provider,{value:{activeGroup:r,setActiveGroup:m,activeSection:c,setActiveSection:a,prevSection:p,nextSection:f,isLocked:t,lock:n,unlock:i},children:e})}function g(){let e=We(te);if(!e)throw new Error("useNavContext must be used within a NavProvider");return e}import{jsx as G}from"react/jsx-runtime";var He=Array.from(new Set(Object.values(B)));function re(){let{activeGroup:e}=g();return G(ne,{width:"100%",flexDirection:"row",children:He.map((t,o)=>G(ne,{borderStyle:"classic",borderLeft:!!o,borderRight:!1,borderTop:!1,borderBottom:!1,children:G(Me,{color:t===e?"cyan":"",children:` [${o+1}]: ${t} `})},t))})}import{Text as ft,useInput as dt}from"ink";import{Box as ie,measureElement as Ie,Text as se}from"ink";import{useMemo as Ge,useRef as Ee}from"react";import{Fragment as Oe,jsx as D,jsxs as Ve}from"react/jsx-runtime";function v(e){let{title:t,footer:o,children:n,width:i,height:r,innerHeight:s,isModal:c}=e,{width:l}=h(),a=i??l,m=Ee(null),f=Ge(()=>{if(!m.current)return 0;let{width:L}=Ie(m.current);return L},[m.current]),p=f-8,u={...e,height:s,width:f},{activeSection:d}=g(),k=d===t||c?"cyan":"";return D(ie,{ref:m,flexDirection:"column",height:r,width:a,children:f!==0&&Ve(Oe,{children:[t&&D(se,{color:k,wrap:"truncate-end",children:"\u256D\u2500\u2500\u2500\u2500 "+t+" "+"\u2500".repeat(p-t.length)+"\u256E"}),D(ie,{flexDirection:"column",...u,borderStyle:"round",borderColor:k,borderTop:!t,borderBottom:!o,paddingLeft:1,children:n}),o&&D(se,{color:k,wrap:"truncate-end",children:"\u2570"+"\u2500".repeat(p-o.length)+" "+o+" \u2500\u2500\u2500\u2500\u256F"})]})})}import{Text as Fe}from"ink";import{useEffect as $e,useState as E}from"react";function y(e,t=[]){let[o,n]=E(void 0),[i,r]=E(!1),[s,c]=E(0),l=()=>c(a=>a+1);return $e(()=>{let a=!1;return r(!1),n(void 0),e().then(m=>{a||(n(m),r(!0))}).catch(()=>{a||r(!0)}),()=>{a=!0}},[s,...t]),{value:o,resolved:i,refresh:l}}import{jsx as ce}from"react/jsx-runtime";function O(){let{value:e,resolved:t}=y(Q);return ce(v,{flexDirection:"column",title:"Bisgit",width:"100%",children:t&&e?.map((o,n)=>ce(Fe,{children:o},n))})}import{useEffect as _e}from"react";import{Box as K,Text as P,useInput as qe}from"ink";import{useEffect as Ue,useState as ae}from"react";function N(e,t){let[o,n]=ae(0),[i,r]=ae(0);Ue(()=>{n(0),r(0)},[e]);let s=Math.max(0,e.length-t),c=e.length-1,l=()=>{r(p=>{let u=Math.min(p+1,c);return n(d=>u>=d+t?Math.min(d+1,s):d),u})},a=()=>{r(p=>{let u=Math.max(p-1,0);return n(d=>u<d?Math.max(d-1,0):d),u})},m=e.slice(o,o+t),f=e[i];return{scrollDown:l,scrollUp:a,outList:m,selectedIndex:i,selectedValue:f}}import me from"ink-spinner";import{Fragment as ue,jsx as x,jsxs as le}from"react/jsx-runtime";async function Ye(){let{stdout:e}=await w("git log --oneline -n 30");return e.trim().split(/\r?\n/).map(Qe)}async function ze(e){if(!e)return;let{stdout:t}=await w(`git show ${e} --name-only`);return t.trim()}function V(){let{width:e,sectionHeight:t}=h(),{resolved:o,value:n=[]}=y(Ye),{scrollUp:i,scrollDown:r,outList:s,selectedValue:c}=N(n,t-2);qe((f,p)=>{p.upArrow&&i(),p.downArrow&&r(),f==="c"&&w(`git checkout ${c.sha}`)});let{activeSection:l}=g(),{setKeybinding:a,removeKeybinding:m}=b();return _e(()=>{if(l==="Log")return a("c","checkout"),()=>{m("c")}},[l]),x(ue,{children:le(K,{width:e,children:[x(v,{overflowY:"hidden",height:t,title:"Log",width:"50%",children:o?x(ue,{children:s.map(({sha:f,message:p})=>le(K,{flexDirection:"row",flexWrap:"nowrap",children:[x(K,{minWidth:2,children:f===c.sha?x(P,{children:"> "}):null}),x(K,{minWidth:8,children:x(P,{color:"yellow",children:f})}),x(K,{children:x(P,{wrap:"truncate-end",children:p})})]},f))}):x(me,{})}),x(Je,{sha:c?.sha})]})})}function Je({sha:e}){let{resolved:t,value:o}=y(()=>ze(e),[e]);return x(v,{title:"Commit Details",width:"50%",height:"100%",children:e&&t?x(P,{children:o}):x(me,{})})}function Qe(e){let t=e.indexOf(" ");return{sha:e.slice(0,t),message:e.slice(t+1)}}import{useEffect as ut}from"react";import{Box as we}from"ink";import{Box as $,Text as ge,useInput as nt}from"ink";import{useState as Xe}from"react";import{Box as fe,useInput as Ze}from"ink";import je from"ink-text-input";import{jsx as R}from"react/jsx-runtime";var de=36;function pe({title:e,handleSubmit:t,modalControls:o}){let[n,i]=Xe(""),{isOpen:r,close:s}=o,c=h(),{width:l}=c,a=Math.floor((l-de)/2);return Ze((m,f)=>{f.return&&r&&(t(n),i(""),s())}),r&&R(fe,{...c,position:"absolute",children:R(fe,{alignSelf:"center",marginLeft:a,marginRight:a,children:R(v,{title:e,width:de,isModal:!0,children:R(je,{value:n,onChange:i})})})})}import{useInput as et}from"ink";import{useEffect as tt,useState as ot}from"react";function he(){let{lock:e,unlock:t}=g(),[o,n]=ot(!1),i=()=>{t(),n(!1)},r=()=>{e(),n(!0)};et((l,a)=>{a.escape&&i()});let{setKeybinding:s,removeKeybinding:c}=b();return tt(()=>{if(o)return s("esc","close"),()=>{c("esc")}},[o]),{isOpen:o,close:i,open:r}}import{useEffect as rt}from"react";import{Fragment as it,jsx as T,jsxs as xe}from"react/jsx-runtime";function F(){let{activeSection:e,isLocked:t}=g(),{sectionHalfHeight:o}=h(),{value:n=[],refresh:i}=y(X),{value:r,refresh:s}=y(J),{setKeybinding:c,removeKeybinding:l}=b();rt(()=>{if(e==="Branches")return c("s","switch"),()=>{l("s")}},[e]);let{outList:a,selectedValue:m,scrollUp:f,scrollDown:p}=N(n,o-2),u=async S=>{await w(`git branch ${S}`),i()},d=async()=>{await w(`git branch -D ${m}`),i()},k=async()=>{await w(`git switch ${m}`),i(),s()},L=he();return nt((S,z)=>{e!=="Branches"||t||(z.upArrow?f():z.downArrow?p():S==="c"?L.open():S==="d"?d():S==="s"&&k())}),xe(it,{children:[T(v,{width:"100%",title:"Branches",innerHeight:o-1,children:a.map(S=>xe($,{flexDirection:"row",flexWrap:"nowrap",children:[T($,{minWidth:2,children:S===m?T(ge,{children:"> "}):null}),T($,{minWidth:8,children:T(ge,{color:S===r?"magenta":void 0,children:S})})]},S))}),T(pe,{title:"Name your new branch",handleSubmit:u,modalControls:L})]})}import{Text as U}from"ink";import{Fragment as st}from"react";import{jsx as _,jsxs as ve}from"react/jsx-runtime";function ye(){let{value:e}=y(Z);return _(v,{width:"50%",title:"Remotes",children:e?.map(({url:t,name:o,type:n})=>ve(st,{children:[ve(U,{wrap:"truncate-end",children:[o," (",n,")"]}),_(U,{wrap:"truncate-end",children:t}),_(U,{children:" "})]},`${o}-${n}`))})}import{Text as q}from"ink";import{Fragment as ct}from"react";import{jsx as W,jsxs as lt}from"react/jsx-runtime";function Se(){let{sectionHalfHeight:e}=h(),{value:t}=y(at);return W(v,{width:"100%",title:"Worktrees",innerHeight:e-1,children:t?.map(({branch:o,detached:n,path:i,head:r})=>lt(ct,{children:[W(q,{children:n?r:o}),W(q,{children:i}),W(q,{children:" "})]},i))})}async function at(){let{stdout:e}=await w("git worktree list --porcelain"),t=e.trim().split(/\r?\n/),o=[],n=[];for(let i of t)i.trim()===""?n.length&&(o.push(n),n=[]):n.push(i);return n.length&&o.push(n),o.map(i=>{let r={detached:!1};for(let s of i)s.startsWith("worktree ")?r.path=s.slice(9):s.startsWith("HEAD ")?r.head=s.slice(5):s.startsWith("branch ")?r.branch=s.slice(7):s==="detached"&&(r.detached=!0);return r})}import{Fragment as mt,jsx as A,jsxs as be}from"react/jsx-runtime";function Be(){let{width:e,sectionHeight:t}=h(),{setKeybinding:o,removeKeybinding:n}=b();return ut(()=>(o("c","create"),o("d","delete"),()=>{n(["c","d"])}),[]),A(mt,{children:be(we,{width:e,height:t,children:[be(we,{flexDirection:"column",width:"50%",height:t,children:[A(F,{}),A(Se,{})]}),A(ye,{})]})})}import{jsx as Y,jsxs as pt}from"react/jsx-runtime";function Te(){let{prevSection:e,nextSection:t,activeGroup:o,setActiveGroup:n}=g();switch(dt((i,r)=>{r.tab&&r.shift?e():r.tab?t():i==="1"?n("Status"):i==="2"?n("Log"):i==="3"&&n("Branches")}),o){case"Status":return Y(O,{});case"Log":return Y(V,{});case"Branches":return Y(Be,{});default:return pt(ft,{children:["Error, unknown page ",o]})}}import{jsx as M,jsxs as vt}from"react/jsx-runtime";function Ce(){let{isLocked:e}=g();xt((i,r)=>{e||i.toLowerCase()==="q"&&process.exit()});let t=h(),{keybindings:o,setKeybinding:n}=b();return ht(()=>n("q","quit"),[]),vt(ke,{flexDirection:"column",...t,children:[M(re,{}),M(Te,{}),M(ke,{flexDirection:"row",children:Object.entries(o).map(([i,r])=>M(gt,{children:`[${i}]: ${r} `},r))})]})}import{jsx as H}from"react/jsx-runtime";function St(){return H(oe,{children:H(ee,{children:H(Ce,{})})})}var Nn=()=>yt(H(St,{}),{patchConsole:!0});export{Nn as renderApp};
|