gitpick 4.4.0-canary.0 → 4.4.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.
Files changed (2) hide show
  1. package/dist/index.js +16 -17
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,26 +1,25 @@
1
1
  #!/usr/bin/env node
2
- var vt=Object.defineProperty,kt=Object.defineProperties;var Et=Object.getOwnPropertyDescriptors;var C=Object.getOwnPropertySymbols;var _=Object.prototype.hasOwnProperty,J=Object.prototype.propertyIsEnumerable;var v=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),jt=t=>{throw TypeError(t)};var T=(t,e,r)=>e in t?vt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,d=(t,e)=>{for(var r in e||(e={}))_.call(e,r)&&T(t,r,e[r]);if(C)for(var r of C(e))J.call(e,r)&&T(t,r,e[r]);return t},$=(t,e)=>kt(t,Et(e));var D=(t,e)=>{var r={};for(var o in t)_.call(t,o)&&e.indexOf(o)<0&&(r[o]=t[o]);if(t!=null&&C)for(var o of C(t))e.indexOf(o)<0&&J.call(t,o)&&(r[o]=t[o]);return r};var V=(t,e,r)=>T(t,typeof e!="symbol"?e+"":e,r);var y=function(t,e){this[0]=t,this[1]=e},F=(t,e,r)=>{var o=(n,a,c,p)=>{try{var l=r[n](a),u=(a=l.value)instanceof y,g=l.done;Promise.resolve(u?a[0]:a).then(m=>u?o(n==="return"?n:"next",a[1]?{done:m.done,value:m.value}:m,c,p):c({value:m,done:g})).catch(m=>o("throw",m,c,p))}catch(m){p(m)}},i=n=>s[n]=a=>new Promise((c,p)=>o(n,a,c,p)),s={};return r=r.apply(t,e),s[v("asyncIterator")]=()=>s,i("next"),i("throw"),i("return"),s},q=t=>{var e=t[v("asyncIterator")],r=!1,o,i={};return e==null?(e=t[v("iterator")](),o=s=>i[s]=n=>e[s](n)):(e=e.call(t),o=s=>i[s]=n=>{if(r){if(r=!1,s==="throw")throw n;return n}return r=!0,{done:!1,value:new y(new Promise(a=>{var c=e[s](n);c instanceof Object||jt("Object expected"),a(c)}),1)}}),i[v("iterator")]=()=>i,o("next"),"throw"in e?o("throw"):i.throw=s=>{throw s},"return"in e&&o("return"),i},S=(t,e,r)=>(e=t[v("asyncIterator")])?e.call(t):(t=t[v("iterator")](),e={},r=(o,i)=>(i=t[o])&&(e[o]=s=>new Promise((n,a,c)=>(s=i.call(t,s),c=s.done,Promise.resolve(s.value).then(p=>n({value:p,done:c}),a)))),r("next"),r("return"),e);import xt from"fs";import{parseArgs as Yt}from"node:util";import Zt from"path";import E from"node:fs";import zt from"node:os";import mt from"node:path";import O from"node:fs";import z from"node:path";var U=async(t,e)=>{let r=await O.promises.readdir(t,{withFileTypes:!0});await O.promises.mkdir(e,{recursive:!0});for(let o of r){if(o.name===".git")continue;let i=z.join(t,o.name),s=z.join(e,o.name);o.isDirectory()?await U(i,s):await O.promises.copyFile(i,s)}};import Pt from"node:process";import{stripVTControlCharacters as Ct}from"node:util";var K=t=>({start:Pt.hrtime.bigint(),command:t.map(e=>St(Ct(e))).join(" "),state:{stdout:"",stderr:"",output:""}}),St=t=>/[^\w./-]/.test(t)?`'${t.replaceAll("'","'\\''")}'`:t;import k from"node:path";import{fileURLToPath as It}from"node:url";import Q from"node:process";var Y=c=>{var p=c,{stdin:t,stdout:e,stderr:r,stdio:o=[t,e,r],env:i,preferLocal:s,cwd:n="."}=p,a=D(p,["stdin","stdout","stderr","stdio","env","preferLocal","cwd"]);var m;let l=n instanceof URL?It(n):k.resolve(n),u=i?d(d({},Q.env),i):void 0,g=(m=o[0])==null?void 0:m.string;return $(d({},a),{input:g,stdio:g===void 0?o:["pipe",...o.slice(1)],env:s?Rt(u!=null?u:Q.env,l):u,cwd:l})},Rt=(i,o)=>{var s=i,{Path:t="",PATH:e=t}=s,r=D(s,["Path","PATH"]);let n=e.split(k.delimiter),a=Z([],k.resolve(o)).map(c=>k.join(c,"node_modules/.bin")).filter(c=>!n.includes(c));return $(d({},r),{PATH:[...a,e].filter(Boolean).join(k.delimiter)})},Z=(t,e)=>t.at(-1)===e?t:Z([...t,e],k.resolve(e,".."));import{spawn as Ht}from"node:child_process";import{once as Nt}from"node:events";import nt from"node:process";import{stat as At}from"node:fs/promises";import X from"node:path";import tt from"node:process";var et=async(t,e,r)=>await Tt(t,r)?[L(t),e.map(o=>Ot(o)),$(d({},r),{shell:!0})]:[t,e,r],Tt=async(t,{shell:e,cwd:r,env:o=tt.env})=>tt.platform==="win32"&&!e&&!await Dt(t,r,o),Dt=async(t,e,{Path:r="",PATH:o=r})=>{var i,s;return rt.some(n=>t.toLowerCase().endsWith(n))||((s=B[i=`${t}\0${e}\0${o}`])!=null?s:B[i]=await Ft(t,e,o))},B={},Ft=async(t,e,r)=>{let o=r.split(X.delimiter).filter(Boolean).map(i=>i.replace(/^"(.*)"$/,"$1"));try{await Promise.all(rt.flatMap(i=>[e,...o].map(s=>`${X.resolve(s,t)}${i}`)).map(async i=>{try{await At(i)}catch(s){return}throw 0}))}catch(i){return!0}return!1},rt=[".exe",".com"],Ot=t=>L(L(`"${t.replaceAll(/(\\*)"/g,'$1$1\\"').replace(/(\\*)$/,"$1$1")}"`)),L=t=>t.replaceAll(/([()\][%!^"`<>&|;, *?])/g,"^$1");import{once as Ut,on as Bt}from"node:events";import Lt from"node:process";var ot=async(t,{input:e},r)=>{let o=await t;e!==void 0&&o.stdin.end(e);let i=Ut(o,"close");try{return await Promise.race([i,...o.stdio.filter(Boolean).map(s=>Wt(s))]),Mt(r,st(o)),it(r)}catch(s){throw await Promise.allSettled([i]),M(s,o,r)}},Wt=async t=>{try{for(var e=S(Bt(t,"error")),r,o,i;r=!(o=await e.next()).done;r=!1){let[s]=o.value;if(!["ERR_STREAM_PREMATURE_CLOSE","EPIPE"].includes(s==null?void 0:s.code))throw s}}catch(o){i=[o]}finally{try{r&&(o=e.return)&&await o.call(e)}finally{if(i)throw i[0]}}},Mt=({command:t},{exitCode:e,signalName:r})=>{if(r!==void 0)throw new x(`Command was terminated with ${r}: ${t}`);if(e!==void 0)throw new x(`Command failed with exit code ${e}: ${t}`)},M=(t,e,r)=>Object.assign(Gt(t,r),st(e),it(r)),Gt=(t,{command:e})=>t instanceof x?t:new x(`Command failed: ${e}`,{cause:t}),x=class extends Error{constructor(){super(...arguments);V(this,"name","SubprocessError")}},st=({exitCode:t,signalCode:e})=>d(d({},t<1?{}:{exitCode:t}),e===null?{}:{signalName:e}),it=({state:{stdout:t,stderr:e,output:r},command:o,start:i})=>({stdout:W(t),stderr:W(e),output:W(r),command:o,durationMs:Number(Lt.hrtime.bigint()-i)/1e6}),W=t=>t.at(-1)===`
3
- `?t.slice(0,t.at(-2)==="\r"?-2:-1):t;var ct=async(t,e,r,o)=>{try{[t,e]=["node","node.exe"].includes(t.toLowerCase())?[nt.execPath,[...nt.execArgv.filter(s=>!s.startsWith("--inspect")),...e]]:[t,e];let i=Ht(...await et(t,e,r));return at(i.stdout,o,"stdout"),at(i.stderr,o,"stderr"),i.once("error",()=>{}),await Nt(i,"spawn"),i}catch(i){throw M(i,{},o)}},at=(t,{state:e},r)=>{t&&(t.setEncoding("utf8"),e.isIterating||(e.isIterating=!1,t.on("data",o=>{e[r]+=o,e.output+=o})))};import{pipeline as _t}from"node:stream/promises";var pt=async t=>{var o;let[[e,r]]=await Promise.all([Promise.allSettled(t),Jt(t)]);if(r.reason)throw r.reason.pipedFrom=(o=e.reason)!=null?o:e.value,r.reason;if(e.reason)throw e.reason;return $(d({},r.value),{pipedFrom:e.value})},Jt=async t=>{try{let[{stdout:e},{stdin:r}]=await Promise.all(t.map(({nodeChildProcess:o})=>o));if(r===null)throw new Error('The "stdin" option must be set on the first "spawn()" call in the pipeline.');if(e===null)throw new Error('The "stdout" option must be set on the last "spawn()" call in the pipeline.');_t(e,r).catch(()=>{})}catch(e){throw await Promise.allSettled(t.map(({nodeChildProcess:r})=>Vt(r))),e}},Vt=async t=>{let{stdin:e}=await t;e.end()};var G=function(o,i,s){return F(this,arguments,function*(t,{state:e},r){if(e.isIterating===!1)throw new Error(`The subprocess must be iterated right away, for example:
4
- for await (const line of spawn(...)) { ... }`);e.isIterating=!0;try{let{[r]:l}=yield new y(t.nodeChildProcess);if(!l)return;let u="";try{for(var n=S(l.iterator({destroyOnReturn:!1})),a,c,p;a=!(c=yield new y(n.next())).done;a=!1){let g=c.value;let m=`${u}${g}`.split(/\r?\n/);u=m.pop(),yield*q(m)}}catch(c){p=[c]}finally{try{a&&(c=n.return)&&(yield new y(c.call(n)))}finally{if(p)throw p[0]}}u&&(yield u)}finally{yield new y(t)}})},lt=function(...t){return F(this,null,function*(){try{let e=[];for(;t.length>0;){e=t.map((n,a)=>{var c;return(c=e[a])!=null?c:qt(n)});let[{value:r,done:o},i]=yield new y(Promise.race(e.map((n,a)=>Promise.all([n,a])))),[s]=t.splice(i,1);e.splice(i,1),o||(t.push(s),yield r)}}finally{yield new y(Promise.all(t.map(e=>e.return())))}})},qt=async t=>{try{return await t.next()}catch(e){await t.throw(e)}};function b(t,e,r,o){let[i=[],s={}]=Array.isArray(e)?[e,r]:[[],e],n=K([t,...i]),a=Y(s),c=ct(t,i,a,n),p=ot(c,a,n);Object.assign(p,{nodeChildProcess:c}),p=o?pt([o,p]):p;let l=G(p,n,"stdout"),u=G(p,n,"stderr");return Object.assign(p,{nodeChildProcess:c,stdout:l,stderr:u,[Symbol.asyncIterator]:()=>lt(l,u),pipe:(g,m,P)=>b(g,m,P,p)})}var I=async(t,e,r)=>{process.platform==="win32"&&await b("git",["config","--global","core.longpaths","true"]);let o=`https://${t.token?t.token+"@":t.token}github.com/${t.owner}/${t.repository}.git`,i=mt.resolve(zt.tmpdir(),`${t.repository}-${Date.now()}${Math.random().toString(16).slice(2,6)}`);e.watch||console.log(`
5
- \u{1F50D} Picking ${t.type}${t.type==="repository"?" without .git":" from repository"}...`);let s=performance.now();try{await b("git",["clone",o,i,"--branch",t.branch,"--depth","1","--single-branch",...e.recursive?["--recursive"]:[]])}catch(c){console.log("\u{1F504} Using robust checkout process..."),await b("git",["clone",o,i,...e.recursive?["--recursive"]:[]]),await b("git",["checkout",t.branch],{cwd:i})}let n=mt.resolve(i,t.path);(await E.promises.stat(n)).isDirectory()?(await E.promises.mkdir(r,{recursive:!0}),await U(n,r)):(await E.promises.mkdir(r.split("/").slice(0,-1).join("/"),{recursive:!0}),await E.promises.copyFile(n,r)),e.watch?console.log("- Synced at "+new Date().toLocaleTimeString()):console.log(`\u{1F525} Picked ${t.type}${t.type==="repository"?" without .git":" from repository"} in ${((performance.now()-s)/1e3).toFixed(2)} seconds!`),await E.promises.rm(i,{recursive:!0,force:!0})};import Kt from"node:tty";var ht,ut,R,ft,dt,Qt=(dt=(ft=(R=(ut=(ht=Kt)==null?void 0:ht.WriteStream)==null?void 0:ut.prototype)==null?void 0:R.hasColors)==null?void 0:ft.call(R))!=null?dt:!1,h=(t,e)=>{if(!Qt)return i=>i;let r=`\x1B[${t}m`,o=`\x1B[${e}m`;return i=>{let s=i+"",n=s.indexOf(o);if(n===-1)return r+s+o;let a=r,c=0;for(;n!==-1;)a+=s.slice(c,n)+r,c=n+o.length,n=s.indexOf(o,c);return a+=s.slice(c)+o,a}},Ke=h(0,0),w=h(1,22),Qe=h(2,22),Ye=h(3,23),Ze=h(4,24),Xe=h(53,55),tr=h(7,27),er=h(8,28),rr=h(9,29),or=h(30,39),H=h(31,39),A=h(32,39),j=h(33,39),sr=h(34,39),ir=h(35,39),f=h(36,39),nr=h(37,39),ar=h(90,39);function N(t){if(typeof t=="number"||/^\d+$/.test(t))return typeof t=="number"?t:parseInt(t,10);let e=/(\d+)([hms])/g,r=0,o;for(;(o=e.exec(t))!==null;){let i=parseInt(o[1],10);switch(o[2]){case"h":r+=i*36e5;break;case"m":r+=i*6e4;break;case"s":r+=i*1e3;break}}return r}var gt=async t=>{var i,s;let e=(await b("git",["ls-remote",t])).stdout,r=(i=e.match(/(.+)\s+HEAD/))==null?void 0:i[1],o=(s=e.match(new RegExp(`${r}\\s+refs/heads/(.+)`)))==null?void 0:s[1];if(!o)throw new Error("Could not determine default branch!");return o};async function wt(t,{branch:e,target:r}){let o=/^https:\/\/([^@]+)@github\.com/,i=t.match(o),s="";i&&(s=i[1],t=t.replace(o,"https://github.com"));let n=["git@github.com:","https://github.com/","https://raw.githubusercontent.com/"];for(let P of n)if(t.startsWith(P)){t=t.replace(P,"");break}let a=t.split("/"),c=a[0],p=a[1].endsWith(".git")?a[1].slice(0,-4):a[1],l=a[2]==="blob"?"blob":a[2]==="tree"?"tree":a[2]+a[3]==="refsheads"?"raw":"repository",u=e||(l==="repository"?await gt(`https://${s&&s+"@"}github.com/${c}/${p}`):l==="raw"?a[4]:a[3]),g=l?l==="raw"?a.slice(5).join("/"):a.slice(4).join("/"):a.slice(2).join("/")||"/",m=r||(l==="blob"?".":g.split("/").pop()||p);return{token:s,owner:c,repository:p,type:l,branch:u,path:g,target:m}}var bt="gitpick",$t="4.4.0-canary.0";var Xt=`
2
+ var vt=Object.defineProperty,kt=Object.defineProperties;var Et=Object.getOwnPropertyDescriptors;var S=Object.getOwnPropertySymbols;var _=Object.prototype.hasOwnProperty,J=Object.prototype.propertyIsEnumerable;var k=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),jt=t=>{throw TypeError(t)};var T=(t,e,r)=>e in t?vt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r,f=(t,e)=>{for(var r in e||(e={}))_.call(e,r)&&T(t,r,e[r]);if(S)for(var r of S(e))J.call(e,r)&&T(t,r,e[r]);return t},x=(t,e)=>kt(t,Et(e));var D=(t,e)=>{var r={};for(var o in t)_.call(t,o)&&e.indexOf(o)<0&&(r[o]=t[o]);if(t!=null&&S)for(var o of S(t))e.indexOf(o)<0&&J.call(t,o)&&(r[o]=t[o]);return r};var V=(t,e,r)=>T(t,typeof e!="symbol"?e+"":e,r);var b=function(t,e){this[0]=t,this[1]=e},F=(t,e,r)=>{var o=(n,a,c,p)=>{try{var l=r[n](a),u=(a=l.value)instanceof b,g=l.done;Promise.resolve(u?a[0]:a).then(m=>u?o(n==="return"?n:"next",a[1]?{done:m.done,value:m.value}:m,c,p):c({value:m,done:g})).catch(m=>o("throw",m,c,p))}catch(m){p(m)}},i=n=>s[n]=a=>new Promise((c,p)=>o(n,a,c,p)),s={};return r=r.apply(t,e),s[k("asyncIterator")]=()=>s,i("next"),i("throw"),i("return"),s},q=t=>{var e=t[k("asyncIterator")],r=!1,o,i={};return e==null?(e=t[k("iterator")](),o=s=>i[s]=n=>e[s](n)):(e=e.call(t),o=s=>i[s]=n=>{if(r){if(r=!1,s==="throw")throw n;return n}return r=!0,{done:!1,value:new b(new Promise(a=>{var c=e[s](n);c instanceof Object||jt("Object expected"),a(c)}),1)}}),i[k("iterator")]=()=>i,o("next"),"throw"in e?o("throw"):i.throw=s=>{throw s},"return"in e&&o("return"),i},I=(t,e,r)=>(e=t[k("asyncIterator")])?e.call(t):(t=t[k("iterator")](),e={},r=(o,i)=>(i=t[o])&&(e[o]=s=>new Promise((n,a,c)=>(s=i.call(t,s),c=s.done,Promise.resolve(s.value).then(p=>n({value:p,done:c}),a)))),r("next"),r("return"),e);import xt from"fs";import{parseArgs as Yt}from"node:util";import Zt from"path";import P from"node:fs";import Qt from"node:os";import dt from"node:path";import Pt from"node:tty";var z,K,R,Q,Y,Ct=(Y=(Q=(R=(K=(z=Pt)==null?void 0:z.WriteStream)==null?void 0:K.prototype)==null?void 0:R.hasColors)==null?void 0:Q.call(R))!=null?Y:!1,h=(t,e)=>{if(!Ct)return i=>i;let r=`\x1B[${t}m`,o=`\x1B[${e}m`;return i=>{let s=i+"",n=s.indexOf(o);if(n===-1)return r+s+o;let a=r,c=0;for(;n!==-1;)a+=s.slice(c,n)+r,c=n+o.length,n=s.indexOf(o,c);return a+=s.slice(c)+o,a}},se=h(0,0),w=h(1,22),ie=h(2,22),ne=h(3,23),ae=h(4,24),ce=h(53,55),pe=h(7,27),le=h(8,28),me=h(9,29),he=h(30,39),O=h(31,39),y=h(32,39),j=h(33,39),ue=h(34,39),fe=h(35,39),d=h(36,39),de=h(37,39),ge=h(90,39);import U from"node:fs";import Z from"node:path";var B=async(t,e)=>{let r=await U.promises.readdir(t,{withFileTypes:!0});await U.promises.mkdir(e,{recursive:!0});for(let o of r){if(o.name===".git")continue;let i=Z.join(t,o.name),s=Z.join(e,o.name);o.isDirectory()?await B(i,s):await U.promises.copyFile(i,s)}};import St from"node:process";import{stripVTControlCharacters as It}from"node:util";var X=t=>({start:St.hrtime.bigint(),command:t.map(e=>Rt(It(e))).join(" "),state:{stdout:"",stderr:"",output:""}}),Rt=t=>/[^\w./-]/.test(t)?`'${t.replaceAll("'","'\\''")}'`:t;import E from"node:path";import{fileURLToPath as At}from"node:url";import tt from"node:process";var et=c=>{var p=c,{stdin:t,stdout:e,stderr:r,stdio:o=[t,e,r],env:i,preferLocal:s,cwd:n="."}=p,a=D(p,["stdin","stdout","stderr","stdio","env","preferLocal","cwd"]);var m;let l=n instanceof URL?At(n):E.resolve(n),u=i?f(f({},tt.env),i):void 0,g=(m=o[0])==null?void 0:m.string;return x(f({},a),{input:g,stdio:g===void 0?o:["pipe",...o.slice(1)],env:s?Tt(u!=null?u:tt.env,l):u,cwd:l})},Tt=(i,o)=>{var s=i,{Path:t="",PATH:e=t}=s,r=D(s,["Path","PATH"]);let n=e.split(E.delimiter),a=rt([],E.resolve(o)).map(c=>E.join(c,"node_modules/.bin")).filter(c=>!n.includes(c));return x(f({},r),{PATH:[...a,e].filter(Boolean).join(E.delimiter)})},rt=(t,e)=>t.at(-1)===e?t:rt([...t,e],E.resolve(e,".."));import{spawn as _t}from"node:child_process";import{once as Jt}from"node:events";import lt from"node:process";import{stat as Dt}from"node:fs/promises";import ot from"node:path";import st from"node:process";var it=async(t,e,r)=>await Ft(t,r)?[W(t),e.map(o=>Bt(o)),x(f({},r),{shell:!0})]:[t,e,r],Ft=async(t,{shell:e,cwd:r,env:o=st.env})=>st.platform==="win32"&&!e&&!await Ot(t,r,o),Ot=async(t,e,{Path:r="",PATH:o=r})=>{var i,s;return nt.some(n=>t.toLowerCase().endsWith(n))||((s=L[i=`${t}\0${e}\0${o}`])!=null?s:L[i]=await Ut(t,e,o))},L={},Ut=async(t,e,r)=>{let o=r.split(ot.delimiter).filter(Boolean).map(i=>i.replace(/^"(.*)"$/,"$1"));try{await Promise.all(nt.flatMap(i=>[e,...o].map(s=>`${ot.resolve(s,t)}${i}`)).map(async i=>{try{await Dt(i)}catch(s){return}throw 0}))}catch(i){return!0}return!1},nt=[".exe",".com"],Bt=t=>W(W(`"${t.replaceAll(/(\\*)"/g,'$1$1\\"').replace(/(\\*)$/,"$1$1")}"`)),W=t=>t.replaceAll(/([()\][%!^"`<>&|;, *?])/g,"^$1");import{once as Lt,on as Wt}from"node:events";import Mt from"node:process";var at=async(t,{input:e},r)=>{let o=await t;e!==void 0&&o.stdin.end(e);let i=Lt(o,"close");try{return await Promise.race([i,...o.stdio.filter(Boolean).map(s=>Gt(s))]),Ht(r,ct(o)),pt(r)}catch(s){throw await Promise.allSettled([i]),G(s,o,r)}},Gt=async t=>{try{for(var e=I(Wt(t,"error")),r,o,i;r=!(o=await e.next()).done;r=!1){let[s]=o.value;if(!["ERR_STREAM_PREMATURE_CLOSE","EPIPE"].includes(s==null?void 0:s.code))throw s}}catch(o){i=[o]}finally{try{r&&(o=e.return)&&await o.call(e)}finally{if(i)throw i[0]}}},Ht=({command:t},{exitCode:e,signalName:r})=>{if(r!==void 0)throw new v(`Command was terminated with ${r}: ${t}`);if(e!==void 0)throw new v(`Command failed with exit code ${e}: ${t}`)},G=(t,e,r)=>Object.assign(Nt(t,r),ct(e),pt(r)),Nt=(t,{command:e})=>t instanceof v?t:new v(`Command failed: ${e}`,{cause:t}),v=class extends Error{constructor(){super(...arguments);V(this,"name","SubprocessError")}},ct=({exitCode:t,signalCode:e})=>f(f({},t<1?{}:{exitCode:t}),e===null?{}:{signalName:e}),pt=({state:{stdout:t,stderr:e,output:r},command:o,start:i})=>({stdout:M(t),stderr:M(e),output:M(r),command:o,durationMs:Number(Mt.hrtime.bigint()-i)/1e6}),M=t=>t.at(-1)===`
3
+ `?t.slice(0,t.at(-2)==="\r"?-2:-1):t;var ht=async(t,e,r,o)=>{try{[t,e]=["node","node.exe"].includes(t.toLowerCase())?[lt.execPath,[...lt.execArgv.filter(s=>!s.startsWith("--inspect")),...e]]:[t,e];let i=_t(...await it(t,e,r));return mt(i.stdout,o,"stdout"),mt(i.stderr,o,"stderr"),i.once("error",()=>{}),await Jt(i,"spawn"),i}catch(i){throw G(i,{},o)}},mt=(t,{state:e},r)=>{t&&(t.setEncoding("utf8"),e.isIterating||(e.isIterating=!1,t.on("data",o=>{e[r]+=o,e.output+=o})))};import{pipeline as Vt}from"node:stream/promises";var ut=async t=>{var o;let[[e,r]]=await Promise.all([Promise.allSettled(t),qt(t)]);if(r.reason)throw r.reason.pipedFrom=(o=e.reason)!=null?o:e.value,r.reason;if(e.reason)throw e.reason;return x(f({},r.value),{pipedFrom:e.value})},qt=async t=>{try{let[{stdout:e},{stdin:r}]=await Promise.all(t.map(({nodeChildProcess:o})=>o));if(r===null)throw new Error('The "stdin" option must be set on the first "spawn()" call in the pipeline.');if(e===null)throw new Error('The "stdout" option must be set on the last "spawn()" call in the pipeline.');Vt(e,r).catch(()=>{})}catch(e){throw await Promise.allSettled(t.map(({nodeChildProcess:r})=>zt(r))),e}},zt=async t=>{let{stdin:e}=await t;e.end()};var H=function(o,i,s){return F(this,arguments,function*(t,{state:e},r){if(e.isIterating===!1)throw new Error(`The subprocess must be iterated right away, for example:
4
+ for await (const line of spawn(...)) { ... }`);e.isIterating=!0;try{let{[r]:l}=yield new b(t.nodeChildProcess);if(!l)return;let u="";try{for(var n=I(l.iterator({destroyOnReturn:!1})),a,c,p;a=!(c=yield new b(n.next())).done;a=!1){let g=c.value;let m=`${u}${g}`.split(/\r?\n/);u=m.pop(),yield*q(m)}}catch(c){p=[c]}finally{try{a&&(c=n.return)&&(yield new b(c.call(n)))}finally{if(p)throw p[0]}}u&&(yield u)}finally{yield new b(t)}})},ft=function(...t){return F(this,null,function*(){try{let e=[];for(;t.length>0;){e=t.map((n,a)=>{var c;return(c=e[a])!=null?c:Kt(n)});let[{value:r,done:o},i]=yield new b(Promise.race(e.map((n,a)=>Promise.all([n,a])))),[s]=t.splice(i,1);e.splice(i,1),o||(t.push(s),yield r)}}finally{yield new b(Promise.all(t.map(e=>e.return())))}})},Kt=async t=>{try{return await t.next()}catch(e){await t.throw(e)}};function $(t,e,r,o){let[i=[],s={}]=Array.isArray(e)?[e,r]:[[],e],n=X([t,...i]),a=et(s),c=ht(t,i,a,n),p=at(c,a,n);Object.assign(p,{nodeChildProcess:c}),p=o?ut([o,p]):p;let l=H(p,n,"stdout"),u=H(p,n,"stderr");return Object.assign(p,{nodeChildProcess:c,stdout:l,stderr:u,[Symbol.asyncIterator]:()=>ft(l,u),pipe:(g,m,C)=>$(g,m,C,p)})}var A=async(t,e,r)=>{process.platform==="win32"&&await $("git",["config","--global","core.longpaths","true"]);let o=`https://${t.token?t.token+"@":t.token}github.com/${t.owner}/${t.repository}.git`,i=dt.resolve(Qt.tmpdir(),`${t.repository}-${Date.now()}${Math.random().toString(16).slice(2,6)}`);e.watch||console.log(`${y("\u2714")} Picking ${t.type}${t.type==="repository"?" without .git":" from repository"}...`);let s=performance.now();try{await $("git",["clone",o,i,"--branch",t.branch,"--depth","1","--single-branch",...e.recursive?["--recursive"]:[]])}catch(c){console.log(`${y("\u2714")} Using robust checkout process...`),await $("git",["clone",o,i,...e.recursive?["--recursive"]:[]]),await $("git",["checkout",t.branch],{cwd:i})}let n=dt.resolve(i,t.path);(await P.promises.stat(n)).isDirectory()?(await P.promises.mkdir(r,{recursive:!0}),await B(n,r)):(await P.promises.mkdir(r.split("/").slice(0,-1).join("/"),{recursive:!0}),await P.promises.copyFile(n,r)),e.watch?console.log("- Synced at "+new Date().toLocaleTimeString()):console.log(`${y("\u2714")} Picked ${t.type}${t.type==="repository"?" without .git":" from repository"} in ${((performance.now()-s)/1e3).toFixed(2)} seconds!`),await P.promises.rm(i,{recursive:!0,force:!0})};function N(t){if(typeof t=="number"||/^\d+$/.test(t))return typeof t=="number"?t:parseInt(t,10);let e=/(\d+)([hms])/g,r=0,o;for(;(o=e.exec(t))!==null;){let i=parseInt(o[1],10);switch(o[2]){case"h":r+=i*36e5;break;case"m":r+=i*6e4;break;case"s":r+=i*1e3;break}}return r}var gt=async t=>{var i,s;let e=(await $("git",["ls-remote",t])).stdout,r=(i=e.match(/(.+)\s+HEAD/))==null?void 0:i[1],o=(s=e.match(new RegExp(`${r}\\s+refs/heads/(.+)`)))==null?void 0:s[1];if(!o)throw new Error("Could not determine default branch!");return o};async function wt(t,{branch:e,target:r}){let o=/^https:\/\/([^@]+)@github\.com/,i=t.match(o),s="";i&&(s=i[1],t=t.replace(o,"https://github.com"));let n=["git@github.com:","https://github.com/","https://raw.githubusercontent.com/"];for(let C of n)if(t.startsWith(C)){t=t.replace(C,"");break}let a=t.split("/"),c=a[0],p=a[1].endsWith(".git")?a[1].slice(0,-4):a[1],l=a[2]==="blob"?"blob":a[2]==="tree"?"tree":a[2]+a[3]==="refsheads"?"raw":"repository",u=e||(l==="repository"?await gt(`https://${s&&s+"@"}github.com/${c}/${p}`):l==="raw"?a[4]:a[3]),g=l?l==="raw"?a.slice(5).join("/"):a.slice(4).join("/"):a.slice(2).join("/")||"/",m=r||(l==="blob"?".":g.split("/").pop()||p);return{token:s,owner:c,repository:p,type:l,branch:u,path:g,target:m}}var bt="gitpick",$t="4.4.0";var Xt=`
6
5
  ${w("With GitPick, you can clone precisely what you need.")}
7
6
 
8
- ${w("gitpick")} ${j("<url>")} ${A("[target]")} ${f("[options]")}
7
+ ${w("gitpick")} ${j("<url>")} ${y("[target]")} ${d("[options]")}
9
8
 
10
9
  ${w("Hint:")} Target is optional, and follows default git clone behavior.
11
10
 
12
11
  ${w("Arguments:")}
13
12
  ${j("url")} GitHub URL with path to file/folder/repository
14
- ${A("target")} Directory to clone into (optional)
13
+ ${y("target")} Directory to clone into (optional)
15
14
 
16
15
  ${w("Options:")}
17
- ${f("-b, --branch ")} Branch to clone
18
- ${f("-o, --overwrite")} Skip overwrite prompt
19
- ${f("-r, --recursive")} Clone submodules
20
- ${f("-w, --watch [time]")} Watch the repository and sync every [time]
16
+ ${d("-b, --branch ")} Branch to clone
17
+ ${d("-o, --overwrite")} Skip overwrite prompt
18
+ ${d("-r, --recursive")} Clone submodules
19
+ ${d("-w, --watch [time]")} Watch the repository and sync every [time]
21
20
  (e.g. 1h, 30m, 15s)
22
- ${f("-h, --help")} display help for command
23
- ${f("-v, --version")} display the version number
21
+ ${d("-h, --help")} display help for command
22
+ ${d("-v, --version")} display the version number
24
23
 
25
24
  ${w("Examples:")}
26
25
  $ gitpick <url>
@@ -29,11 +28,11 @@ ${w("Examples:")}
29
28
  $ gitpick <url> [target] -w [time]
30
29
  $ gitpick <url> [target] -b [branch] -w [time]
31
30
 
32
- \u{1F680} More awesome tools at ${f("https://github.com/nrjdalal")}`,te=t=>{try{return Yt(t)}catch(e){throw new Error(`Error parsing arguments: ${e.message}`)}},ee=async()=>{try{let{positionals:t,values:e}=te({allowPositionals:!0,options:{branch:{type:"string",short:"b"},force:{type:"boolean",short:"f"},help:{type:"boolean",short:"h"},overwrite:{type:"boolean",short:"o"},recursive:{type:"boolean",short:"r"},version:{type:"boolean",short:"v"},watch:{type:"string",short:"w"}}});t.length||(e.version&&(console.log(`
31
+ \u{1F680} More awesome tools at ${d("https://github.com/nrjdalal")}`,te=t=>{try{return Yt(t)}catch(e){throw new Error(`Error parsing arguments: ${e.message}`)}},ee=async()=>{try{let{positionals:t,values:e}=te({allowPositionals:!0,options:{branch:{type:"string",short:"b"},force:{type:"boolean",short:"f"},help:{type:"boolean",short:"h"},overwrite:{type:"boolean",short:"o"},recursive:{type:"boolean",short:"r"},version:{type:"boolean",short:"v"},watch:{type:"string",short:"w"}}});t.length||(e.version&&(console.log(`
33
32
  ${bt}@${$t}`),process.exit(0)),console.log(Xt),process.exit(0)),t[0]==="clone"&&t.shift();let[r,o]=t,i={branch:e.branch,force:e.force,overwrite:e.overwrite,recursive:e.recursive,watch:e.watch};console.log(`${w("GitPick")} - Clone specific directories or files from GitHub!`);let s=await wt(r,{branch:i.branch,target:o});if(s.type==="blob"){let a=s.target.split("/").filter(p=>p!==""),c=a[a.length-1];c!=="."&&c!==".."&&c.includes(".")?a.pop():c=s.path.split("/").pop()||c,s.target=[...a,c].join("/")}console.info(`
34
- ${s.owner}/${s.repository} ${A(s.type+":"+s.branch)} ${s.type==="repository"?`> ${f(s.target)}`:`${s.path.length?j(s.path)+" >":">"} ${f(s.target)}`}`);let n=Zt.resolve(s.target);if(i.overwrite=i.overwrite||i.force,i.watch&&(i.overwrite=!0),xt.existsSync(n+(s.type==="blob"?"/"+s.path.split("/").pop():""))&&(await xt.promises.readdir(n)).length&&!i.overwrite&&(console.log(w(`${j(`
35
- Warning: The target directory is not empty. Use ${f("-f")} | ${f("-o")} to overwrite.`)}`)),process.exit(1)),i.watch){console.log(`
33
+ ${y("\u2714")} ${s.owner}/${s.repository} ${d(s.type+":"+s.branch)} ${s.type==="repository"?`> ${y(s.target)}`:`${s.path.length?j(s.path)+" >":">"} ${y(s.target)}`}`);let n=Zt.resolve(s.target);if(i.overwrite=i.overwrite||i.force,i.watch&&(i.overwrite=!0),xt.existsSync(n+(s.type==="blob"?"/"+s.path.split("/").pop():""))&&(await xt.promises.readdir(n)).length&&!i.overwrite&&(console.log(w(`${j(`
34
+ Warning: The target directory is not empty. Use ${d("-f")} | ${d("-o")} to overwrite.`)}`)),process.exit(1)),i.watch){console.log(`
36
35
  \u{1F440} Watching every ${N(i.watch)/1e3+"s"}
37
- `),await I(s,i,n);let a=N(i.watch);setInterval(async()=>await I(s,i,n),a)}else await I(s,i,n),process.exit(0)}catch(t){t instanceof Error?console.log(w(`
38
- ${H("Error: ")}`)+t.message):console.log(w(`${H(`
36
+ `),await A(s,i,n);let a=N(i.watch);setInterval(async()=>await A(s,i,n),a)}else await A(s,i,n),process.exit(0)}catch(t){t instanceof Error?console.log(w(`
37
+ ${O("Error: ")}`)+t.message):console.log(w(`${O(`
39
38
  Unexpected Error: `)}`)+JSON.stringify(t,null,2)),process.exit(1)}};ee();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gitpick",
3
- "version": "4.4.0-canary.0",
3
+ "version": "4.4.0",
4
4
  "description": "Clone exactly what you need aka straightforward project scaffolding",
5
5
  "keywords": [
6
6
  "clone",