bisgit 0.10.0 → 0.11.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 +1 -0
- package/dist/chunks/commands-EDHHPHMO.js +13 -0
- package/dist/main.js +1 -1
- package/package.json +8 -8
- package/dist/chunks/commands-YR3ZU55X.js +0 -13
package/README.md
CHANGED
|
@@ -36,6 +36,7 @@ Each of these commands work with `gi` or `bisgit`. Just found out gi isn't going
|
|
|
36
36
|
- `gi whoami` shows github username.
|
|
37
37
|
- `gi languages` prints the percentages of languages for this repo.
|
|
38
38
|
- `gi coauthor <username?>` commits with a co-authorship description.
|
|
39
|
+
- `gi syncfork` syncs main with upstream main (use `git pull` after).
|
|
39
40
|
|
|
40
41
|
### Utility
|
|
41
42
|
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import{b as u,c as tt}from"./chunk-5WTQIRZS.js";import{a as U,b as mt}from"./chunk-6JGIBU7E.js";import{a as pt}from"./chunk-NHXDQYDU.js";import{A as L,B as h,C as Y,D as R,E as H,F as I,G as ct,H as y,I as S,a as C,e as w,f as et,g as q,h as T,i as E,j as ot,k as rt,m as W,n as x,o as P,p as it,q as nt,r as N,s as st,v as F,w as G,x as M,z as at}from"./chunk-5AP2OORN.js";import{a as b,b as s,c as D,d,e as l}from"./chunk-OSOEWQKA.js";import k from"node:path";async function lt(){let t=await M(),e=/^(UU|DU|UD)/;return!!t?.some(o=>e.test(o))}async function O(){let t=await ot(),[e,o,i,n,r]=await Promise.all([await C(k.join(t,"MERGE_HEAD")),await C(k.join(t,"rebase-merge")),await C(k.join(t,"rebase-apply")),await C(k.join(t,"CHERRY_PICK_HEAD")),await C(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 l([r,"--abort"])}async function gt(){await I(),await S(),b("git",["commit","--amend","--no-edit",...u()],{stdio:"inherit",silent:!0,triggerExit:!0})}import{render as ne}from"ink";import{render as re}from"ink";import{Suspense as Kt,use as Zt,useEffect as Qt}from"react";import{Text as ut,useApp as Xt}from"ink";import te from"ink-spinner";import{jsx as j,jsxs as oe}from"react/jsx-runtime";function m(t){let{msg:e}=t;return j(Kt,{fallback:oe(ut,{children:[j(te,{type:"dots"}),"\xA0",e]}),children:j(ee,{...t})})}function ee({msg:t,promise:e}){let o=Zt(e),{exit:i}=Xt();return Qt(()=>{i()},[o]),j(ut,{children:`\u2714 ${typeof o=="string"?o:t}`})}import{jsx as ie}from"react/jsx-runtime";async function dt(){let t=process.argv[3],e=process.argv[4]??await w();if(Y(t),Y(e),t===e)return console.log(`No reason to merge '${t}' into '${e}'`);let o=await et(t);h(o),re(ie(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}`),b("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 l(["merge",`${t}/${e}`],["ignore","ignore","inherit"])}}import{jsx as ae}from"react/jsx-runtime";var se=["master","main","development","lingoport"];async function wt(){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()}})();ne(ae(m,{msg:"Fetching and pruning remote references",promise:o}));let{prunedRefs:i}=await o;i&&console.log(i);let n=await st();for(let r of n){if(r===t||se.includes(r))continue;let{code:a}=await d("git",["diff","--quiet",t,r]);if(a===0){J(r);continue}let{code:c}=await d("git",["merge-base","--is-ancestor",r,t]);if(c===0){J(r);continue}let p=await P(r,t),{stdout:f}=await d("git",["merge-tree",p,t,r]);f?.trim()||J(r)}}function J(t){l(["branch","-D",t])}import{spawn as ce}from"node:child_process";import{createInterface as me}from"node:readline/promises";async function ht(){L;let e=[...(await pe()).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 pe(){let{promise:t,resolve:e,reject:o}=Promise.withResolvers(),i=new Map,n=ce("git",["log","--all","-M","-C","--name-only","--format=format:"]),r=me({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 yt}from"ink";import{jsx as bt}from"react/jsx-runtime";async function Ct(){await S();let t=u()[0];if(!t){let r=(await fe()).map(c=>({value:c,label:`${c.name} ${c.email} (${c.commits})`}));yt(bt(pt,{items:r,prompt:"Who assisted in this commit?",onSelect:async({value:{name:c,email:p}})=>{await $t(c,p.slice(1,-1))}}));return}let e=(async()=>{let n=await le(t);return n.email||(console.error(`Couldn't find an email for ${t}`),process.exit(1)),n})();yt(bt(m,{msg:"Fetching name and email",promise:e}));let{name:o,email:i}=await e;$t(o,i)}async function le(t){let{stdout:e}=await s(`gh api users/${t}`);return JSON.parse(e.trim())}async function fe(){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 $t(t,e){l(["commit","--edit","-m","<insert summary>","-m",`Co-authored-by: ${t} <${e}>`])}import{render as z}from"ink";import{isDeepStrictEqual as ge}from"node:util";import{jsx as K}from"react/jsx-runtime";async function xt(){let t=y("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(K(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(K(m,{msg:`Updating ${i} branch merge destination`,promise:n})),await n;let r=(async()=>{let g=await P(i,"HEAD");return await s(`git reset ${g} --soft`),await ue("HEAD")})();z(K(m,{msg:"Creating an editable, explorable, local PR experience",promise:r}));let[a,c]=await Promise.all([r,de(t)]),{files:p,additions:f,deletions:v}=c;if(ge(a,c))return console.info(`Files: ${p}, +${f} -${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 ue(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 de(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 we}from"node:child_process";import{createInterface as he}from"node:readline/promises";import Z from"chalk";async function Pt(){let t=y("Error: missing target branch argument"),e=await P("HEAD",t),{promise:o,resolve:i,reject:n}=Promise.withResolvers(),r=we("git",["merge-tree",e,"HEAD",t]),a=he({input:r.stdout,crlfDelay:1/0}),c=!1,p=0;a.on("line",g=>{g=g.trimEnd(),g==="+<<<<<<< .our"?(c=!0,console.info(Z.red(g)),p+=1):g==="+>>>>>>> .their"?(c=!1,console.info(Z.green(g))):g==="+======="?console.info(Z.yellow(g)):c&&console.info(g)}),a.on("close",()=>i(p)),r.on("error",n);let f=await o,v=f?`\u274C ${f} conflicts would occur!`:"\u2705 No conflicts. Safe to merge.";console.info(v)}async function Rt(){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 l([r,"--continue"])}import{appendFileSync as $e}from"node:fs";import{readFile as ye}from"node:fs/promises";async function _(t){return(await ye(t,"utf-8")).split(/\r?\n/).map(o=>o.trim()).filter(o=>o&&!o.startsWith("#"))}async function St(){let t=await E("info/exclude");await H(t);let e=await _(t);u().forEach(o=>{e.includes(o)?console.info(`Already Exists: '${o}'`):($e(t,`${o}
|
|
4
|
+
`),console.info(`Added '${o}'`))}),console.info(`
|
|
5
|
+
See file at ${t}`)}async function At(){let t=u();if(t[0]){let e=await be(t[0]);console.info(e.join(`
|
|
6
|
+
`))}else l(["status","--short"])}async function be(t){return G(t)?await D(`git stash show -p --include-untracked --name-only ${t}`):await D(`git show --name-only --pretty=format:"" ${t}`)}import{spawn as Ce}from"node:child_process";async function vt(){let t=y("Error: missing valid target ref argument");await S();let e=await nt(t);await l(["commit",`--fixup=${e}`]);let i=(await N(`${e}^`,"HEAD",!0)).map(r=>xe(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 xe(t){let{stdout:e}=await s(`git diff ${t}^ ${t}`),{promise:o,resolve:i,reject:n}=Promise.withResolvers(),r=Ce("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 Pe,writeFile as Re}from"node:fs/promises";async function Dt(){let t=await E("info/exclude");await H(t);let e=await _(t),o=u();o.filter(a=>!e.includes(a)).forEach(a=>console.info(`No match: '${a}'`));let n=(await Pe(t,"utf-8")).split(/\r?\n/).map(a=>a.trim()),r=n.filter(a=>!o.includes(a));await Re(t,r.join(`
|
|
7
|
+
`)),console.info(`
|
|
8
|
+
Removed ${n.length-r.length} entries from ${t}`)}import{render as Se}from"ink";async function V(){let{stdout:t}=await s("gh repo view --json nameWithOwner --jq .nameWithOwner"),e=t.trim(),[o,i]=e.split("/");return{owner:o,repo:i}}async function Et(){let{stdout:t}=await s("gh repo view --json parent"),e=JSON.parse(t);return{repo:e.parent?.name,owner:e.parent?.owner?.login}}import{jsx as De}from"react/jsx-runtime";async function kt(){let t=(async()=>{let{repo:n,owner:r}=await V();return await Ae(`${r}/${n}`)})();Se(De(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)}% - ${ve(r)}`);console.info(i.join(`
|
|
9
|
+
`))}async function Ae(t){let{stdout:e}=await s(`gh api repos/${t}/languages`);return JSON.parse(e.trim())}function ve(t,e=2){if(t===0)return"0 B";let o=1024,i=e<0?0:e,n=["B","KB","MB","GB","TB","PB","EB","ZB","YB"],r=Math.floor(Math.log(t)/Math.log(o));return`${parseFloat((t/Math.pow(o,r)).toFixed(i))} ${n[r]}`}import $ from"chalk";async function Bt(){y();let t=u(),[e,o]=t.filter(n=>n!=="-v"),i=[];if(G(e)?(i.push(...await F(`${e}^3`)),i.push(...await F(`${e}^2`))):i.push(...await F(e,o)),t.includes("-v")){let n={added:"A",modified:"M",deleted:"D",binary:"B"};i.forEach(r=>{let c=`${Ee(r.changeType)(n[r.changeType])} ${r.file} |`;r.added&&(c+=$.green(` +${r.added}`)),r.deleted&&(c+=$.red(` -${r.deleted}`)),console.info(c)})}else{let n=new Set(i.map(({file:f})=>f)).size,[r,a]=i.reduce((f,{added:v,deleted:g})=>[f[0]+(v??0),f[1]+(g??0)],[0,0]),c=$.green(`+${r}`),p=$.red(`-${a}`);console.info(`${n} files: ${c} ${p}`)}}var Ee=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 rt();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 A(){let t=Tt();await s("git add -A"),await l(["commit","-m",`WIP ${t}`])}import{nanoid as ke}from"nanoid";import Be from"chalk";import{jsx as Nt}from"react/jsx-runtime";async function Ft(){let{remote:t,branch:e}=await U(),o=process.argv[3]??e;await x()||await A(),await it(o,"HEAD")||(console.warn("Conflicts would occur. Not safe to rebranch."),process.exit(1));let i=await w(),n=(async()=>{await B(t,o)})();Wt(Nt(m,{msg:`Updating branch ${o}`,promise:n})),await n;let r=`${ke(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 N(o,r,!0);for(let p of c)try{await s(`git cherry-pick ${p}`)}catch{let f=Be.yellow(`git branch -D ${i} && git branch -m ${r} ${i}`);throw new Error(`\u274C cherry pick failed at ${p}
|
|
10
|
+
Run this to restore backup branch
|
|
11
|
+
> ${f}`)}await s(`git branch -D ${r}`)})();Wt(Nt(m,{msg:`Rewriting branch ${i}`,promise:a})),await a,console.info(`Successfully recreated branch ${i} from ${o}`)}import{execSync as qe}from"node:child_process";async function Gt(){L();let t=Te(process.argv[3]),{default:e}=await import("clipboardy");await e.write(t),console.log(`'${t}' copied to clipboard`)}function Te(t="HEAD"){return qe(`git rev-parse --short ${t}`,{encoding:"utf-8"}).trim()}import{render as Mt}from"ink";import{jsx as Lt}from"react/jsx-runtime";async function Ht(){h();let t=Promise.all([V(),Et()]);Mt(Lt(m,{promise:t,msg:"Getting fork details"}));let[e,o]=await t;o.owner||(console.error("This is not a fork"),process.exit(1));let i=s(`gh repo sync ${e.owner}/${e.repo} --source ${o.owner}/${o.repo}`);Mt(Lt(m,{promise:i,msg:`Syncing fork ${e.repo} with upstream ${o.owner}/${o.repo}`}))}import{render as We}from"ink";import{jsx as Ne}from"react/jsx-runtime";async function It(){let{remote:t,branch:e}=await tt();h(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);We(Ne(m,{msg:`Fetching branch ${e} from ${t}`,promise:i})),await i,await l(["switch","-c",e,"--track",`${t}/${e}`])}async function Q(){let{stdout:t}=await s("npm list -g bisgit --depth=0 --json");return JSON.parse(t.trim()).dependencies.bisgit.version}async function Ut(){console.info(await Q())}async function Fe(){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 Ot(){if(await Fe())return console.info("Already up to date");console.info(`Updating: ${await Q()} -> ${await Ge()}`),b("npm",["i","-g","bisgit@latest"])}async function jt(){let[t,e]=await Promise.allSettled([await Le("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 Le(t){let{stdout:e}=await s(`git config ${t}`);return e.trim()}import{render as Ve}from"ink";import{Text as He,useApp as Ie,useInput as Ue}from"ink";import{useState as Oe}from"react";import{Fragment as _e,jsx as je,jsxs as _t}from"react/jsx-runtime";function Vt({prompt:t,msg:e,onConfirm:o,requireConfirmation:i}){let[n,r]=Oe(""),{exit:a}=Ie();return Ue((c,p)=>{if(n)return;let f=c.toLowerCase();f==="y"||p.return&&!i?r("Yes"):(f==="n"||p.return&&i)&&(r("No"),a())}),_t(_e,{children:[_t(He,{children:[t," [",i?"y/N":"Y/n","] ",n]}),n==="Yes"&&je(m,{msg:e,promise:o()})]})}import{jsx as Ye}from"react/jsx-runtime";async function Yt(){if(at(),await x())return console.log("Already a clean working tree");let t=await M();if(!t)throw new Error("git status cmd failed");let e=new X(t);e.displayReport(),Ve(Ye(Vt,{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 X=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 ze}from"ink";import{jsx as Ke}from"react/jsx-runtime";async function Jt(){await I();let t=process.argv[3]??"origin";h(t);let e=await w();ct(e);let o="",n=(async()=>{let r=[s(`git fetch ${t} ${e} --force`)];await x()||r.push(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 p=`${e}-${Je(8)}`;o=`Created branch ${p}`,await s(`git branch ${p}`)}await s(`git reset --hard ${t}/${e}`)}})();ze(Ke(m,{msg:`Force pull reseting ${e} -> ${t}`,promise:n})),await n,o&&console.info(o)}var zt={abort:ft,amend:gt,autoprune:wt,backmerge:dt,churn:ht,coauthor:Ct,"code-review":xt,conflict:Pt,continue:Rt,exclude:St,files:At,fixup:vt,include:Dt,languages:kt,lines:Bt,pwd:qt,rebranch:Ft,"remote-default":mt,savepoint:A,sha:Gt,syncfork:Ht,track:It,update:Ot,"--version":Ut,whoami:jt,wipe:Yt,yank:Jt};async function Sn(t){return await zt[t]?.(),Object.hasOwn(zt,t)}export{Sn as runCommand};
|
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{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-
|
|
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-EDHHPHMO.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.11.0",
|
|
4
4
|
"description": "Git CLI tool to simplify common advanced git workflows",
|
|
5
5
|
"main": "dist/main.js",
|
|
6
6
|
"bin": {
|
|
@@ -41,17 +41,17 @@
|
|
|
41
41
|
"prepare": "husky"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@types/node": "^24.
|
|
44
|
+
"@types/node": "^24.12.0",
|
|
45
45
|
"@types/react": "^19.2.14",
|
|
46
|
-
"@typescript-eslint/eslint-plugin": "^8.
|
|
47
|
-
"@typescript-eslint/parser": "^8.
|
|
48
|
-
"esbuild": "^0.27.
|
|
46
|
+
"@typescript-eslint/eslint-plugin": "^8.57.2",
|
|
47
|
+
"@typescript-eslint/parser": "^8.57.2",
|
|
48
|
+
"esbuild": "^0.27.4",
|
|
49
49
|
"esbuild-lazy-analyzer": "^1.4.0",
|
|
50
50
|
"esbuild-visualizer": "^0.7.0",
|
|
51
|
-
"eslint": "^9.39.
|
|
51
|
+
"eslint": "^9.39.4",
|
|
52
52
|
"eslint-plugin-import": "^2.32.0",
|
|
53
53
|
"husky": "^9.1.7",
|
|
54
|
-
"lint-staged": "^16.
|
|
54
|
+
"lint-staged": "^16.4.0",
|
|
55
55
|
"npm-run-all": "^4.1.5",
|
|
56
56
|
"prettier": "^3.8.1",
|
|
57
57
|
"react-devtools-core": "^7.0.1"
|
|
@@ -63,7 +63,7 @@
|
|
|
63
63
|
"ink-select-input": "^6.2.0",
|
|
64
64
|
"ink-spinner": "^5.0.0",
|
|
65
65
|
"ink-text-input": "^6.0.0",
|
|
66
|
-
"nanoid": "^5.1.
|
|
66
|
+
"nanoid": "^5.1.7",
|
|
67
67
|
"react": "^19.2.4",
|
|
68
68
|
"strip-json-comments": "^5.0.3"
|
|
69
69
|
}
|
|
@@ -1,13 +0,0 @@
|
|
|
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};
|