gitpick 4.3.2 → 4.4.0-canary.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/index.js +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
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
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
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.
|
|
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=`
|
|
6
6
|
${w("With GitPick, you can clone precisely what you need.")}
|
|
7
7
|
|
|
8
8
|
${w("gitpick")} ${j("<url>")} ${A("[target]")} ${f("[options]")}
|