gitpick 3.27.0-canary.2 → 3.27.0-canary.21

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 +28 -23
  2. package/package.json +2 -34
package/dist/index.js CHANGED
@@ -1,34 +1,39 @@
1
1
  #!/usr/bin/env node
2
- import l from"fs";import S from"os";import u from"path";function w(e){if(typeof e=="number"||/^\d+$/.test(e))return typeof e=="number"?e:parseInt(e,10);let n=/(\d+)([hms])/g,t=0,r;for(;(r=n.exec(e))!==null;){let o=parseInt(r[1],10);switch(r[2]){case"h":t+=o*36e5;break;case"m":t+=o*6e4;break;case"s":t+=o*1e3;break}}return t}import C from"simple-git";var v=async e=>{var o,i;let n=await C().listRemote([e]),t=(o=n.match(/(.+)\s+HEAD/))==null?void 0:o[1],r=(i=n.match(new RegExp(`${t}\\s+refs/heads/(.+)`)))==null?void 0:i[1];if(!r)throw new Error("Could not determine default branch!");return r};async function $(e,{branch:n,target:t}){let r=/^https:\/\/([^@]+)@github\.com/,o=e.match(r),i="";o&&(i=o[1],e=e.replace(r,"https://github.com"));let m=["git@github.com:","https://github.com/","https://raw.githubusercontent.com/"];for(let y of m)if(e.startsWith(y)){e=e.replace(y,"");break}let a=e.split("/"),h=a[0],f=a[1].endsWith(".git")?a[1].slice(0,-4):a[1],g=a[2]==="blob"?"blob":a[2]==="tree"?"tree":a[2]+a[3]==="refsheads"?"raw":"repository",D=n||(g==="repository"?await v(`https://${i&&i+"@"}github.com/${h}/${f}`):g==="raw"?a[4]:a[3]),b=g?g==="raw"?a.slice(5).join("/"):a.slice(4).join("/"):a.slice(2).join("/")||"/",T=t||(g==="blob"?".":b.split("/").pop()||f);return{token:i,owner:h,repository:f,type:g,branch:D,path:b,target:T}}import{cancel as G,confirm as H,intro as I,isCancel as W,log as p,spinner as A}from"@clack/prompts";import{Command as U}from"commander";import F from"simple-git";import d from"yoctocolors";import{z as c}from"zod";import{fromError as L}from"zod-validation-error";var R=c.object({url:c.string(),target:c.string().optional(),branch:c.string().optional(),overwrite:c.boolean().optional(),force:c.boolean().optional(),watch:c.union([c.string(),c.number(),c.boolean()]).optional()}),x=new U().name("clone").argument("<url>","GitHub URL with path to file/folder").argument("[target]","Directory to clone into (optional)").option("-b, --branch <branch>","Branch to clone").option("-o, --overwrite","Skip overwrite prompt").option("-f, --force","Alias for --overwrite").option("-w, --watch [time]",`Watch the repository and sync every [time]
3
- (e.g. 1h, 30m, 15s) default: 1m`).action(async(e,n,t)=>{R.parse({url:e,target:n,branch:t.branch,overwrite:t.overwrite,force:t.force,watch:t.watch}),t.overwrite=t.overwrite||t.force,t.watch&&(typeof t.watch=="boolean"&&(t.watch="1m"),console.log(`\u{1F440} Watching every ${w(t.watch)/1e3+"s"}
4
- `));let r=await $(e,{branch:t.branch,target:n});I(`${d.bold(r.owner)}/${d.bold(r.repository)} ${d.green(`<${r.type}:${r.branch}>`)} ${r.type==="repository"?`> ${d.cyan(r.target)}`:`${d.yellow(r.path)} > ${d.cyan(`${r.target}${r.type==="blob"?`/${r.path.split("/").pop()}`:""}`)}`}`);try{let o=u.resolve(r.target);if(t.watch&&(t.overwrite=!0),l.existsSync(o+(r.type==="blob"?"/"+r.path.split("/").pop():""))&&(await l.promises.readdir(o)).length&&!t.overwrite){let i=r.type==="tree"?"The target directory is not empty. Do you want to overwrite the files?":"The target file already exists. Do you want to overwrite the file?",m=await H({message:i});W(m)&&(G("Operation cancelled."),process.exit(0)),m||(p.info("Chose not to overwrite files."),process.exit(0)),p.info("You can use -o | --overwrite or -f | --force flag to skip this prompt next time.")}if(await k(r,t,o),t.watch){let i=w(t.watch);setInterval(async()=>await k(r,t,o),i)}}catch(o){if(p.error("Level 1: An error occurred"),o instanceof c.ZodError){let i=L(o);p.error("Validation Error: "+i.toString())}else o instanceof Error?p.error("Error: "+o.message):p.error("Unexpected Error: "+JSON.stringify(o,null,2));process.exit(1)}});async function j(e,n){let t=await l.promises.readdir(e,{withFileTypes:!0});await l.promises.mkdir(n,{recursive:!0});for(let r of t){if(r.name===".git")continue;let o=u.join(e,r.name),i=u.join(n,r.name);r.isDirectory()?await j(o,i):await l.promises.copyFile(o,i)}}var k=async(e,n,t)=>{let r=A();try{let o=F();process.platform==="win32"&&await o.raw(["config","--global","core.longpaths","true"]);let i=`https://${e.token?e.token+"@":e.token}github.com/${e.owner}/${e.repository}.git`,m=u.join(S.tmpdir(),`${e.repository}-${Date.now()}${Math.random().toString(16).slice(2,6)}`);n.watch||r.start(`Picking ${e.type}${e.type==="repository"?" without .git":" from repository"}`);let a=performance.now();await o.clone(i,m,["--depth","1","--single-branch","--branch",e.branch]);let h=u.join(m,e.path);(await l.promises.stat(h)).isDirectory()?(await l.promises.mkdir(t,{recursive:!0}),await j(h,t)):(await l.promises.mkdir(t,{recursive:!0}),await l.promises.copyFile(h,t+"/"+e.path.split("/").pop())),n.watch?p.success("Synced at "+new Date().toLocaleTimeString()):r.stop(`Picked ${e.type}${e.type==="repository"?" without .git":" from repository"} in ${((performance.now()-a)/1e3).toFixed(2)} seconds!`),await l.promises.rm(m,{recursive:!0,force:!0})}catch(o){r.stop("Level 2: An error occurred while cloning!"),o instanceof Error?p.error("Error: "+o.message):p.error("Unexpected Error: "+JSON.stringify(o,null,2)),process.exit(1)}};import{Command as M}from"commander";import z from"terminal-link";import s from"yoctocolors";var E={name:"gitpick",version:"3.26.0",description:"With gitpick, you can clone precisely what you need.",keywords:["clone","degit","directory","file","folder","git","github","scaffolding","template","url"],homepage:"https://github.com/nrjdalal/gitpick#readme",bugs:"https://github.com/nrjdalal/gitpick/issues",repository:"nrjdalal/gitpick",funding:"https://github.com/sponsors/nrjdalal",license:"MIT",author:{name:"Neeraj Dalal",email:"admin@nrjdalal.com",url:"https://nrjdalal.com"},type:"module",bin:{degit:"./dist/index.js",gitpick:"./dist/index.js"},files:["dist"],scripts:{build:"tsup",dev:"tsup --watch",prepare:"npx simple-git-hooks",test:"bun run build && node dist/index.js",tests:"bash tests.sh"},"simple-git-hooks":{"pre-commit":"npx lint-staged","commit-msg":"npx commitlint --edit $1"},dependencies:{"@clack/prompts":"^0.10.0",commander:"^13.1.0","simple-git":"^3.27.0","terminal-link":"^4.0.0",yoctocolors:"^2.1.1",zod:"^3.24.2","zod-validation-error":"^3.4.0"},devDependencies:{"@commitlint/cli":"^19.8.0","@commitlint/config-conventional":"^19.8.0","@ianvs/prettier-plugin-sort-imports":"^4.4.1","@types/node":"^22.13.13","lint-staged":"^15.5.0",prettier:"^3.5.3","simple-git-hooks":"^2.12.1","sort-package-json":"^2.15.1",tsup:"^8.4.0",typescript:"^5.8.2"}};process.on("SIGINT",()=>process.exit(0));process.on("SIGTERM",()=>process.exit(0));async function N(){let e=new M().name("gitpick").description("With gitpick, you can clone precisely what you need.").version(E.version||"1.0.0","-v, --version","display the version number"),n=process.argv.slice(2),t=["-v","--version","-h","--help","help","clone"];n.length&&!t.includes(n[0])&&process.argv.splice(2,0,"clone"),e.addCommand(x),e.configureHelp({formatHelp:()=>`${s.bold("With gitpick, you can clone precisely what you need.")}
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 v=(t,e)=>(e=Symbol[t])?e:Symbol.for("Symbol."+t),jt=t=>{throw TypeError(t)};var A=(t,e,o)=>e in t?vt(t,e,{enumerable:!0,configurable:!0,writable:!0,value:o}):t[e]=o,f=(t,e)=>{for(var o in e||(e={}))_.call(e,o)&&A(t,o,e[o]);if(S)for(var o of S(e))J.call(e,o)&&A(t,o,e[o]);return t},b=(t,e)=>kt(t,Et(e));var T=(t,e)=>{var o={};for(var r in t)_.call(t,r)&&e.indexOf(r)<0&&(o[r]=t[r]);if(t!=null&&S)for(var r of S(t))e.indexOf(r)<0&&J.call(t,r)&&(o[r]=t[r]);return o};var V=(t,e,o)=>A(t,typeof e!="symbol"?e+"":e,o);var y=function(t,e){this[0]=t,this[1]=e},D=(t,e,o)=>{var r=(i,a,c,p)=>{try{var l=o[i](a),u=(a=l.value)instanceof y,w=l.done;Promise.resolve(u?a[0]:a).then(m=>u?r(i==="return"?i:"next",a[1]?{done:m.done,value:m.value}:m,c,p):c({value:m,done:w})).catch(m=>r("throw",m,c,p))}catch(m){p(m)}},s=i=>n[i]=a=>new Promise((c,p)=>r(i,a,c,p)),n={};return o=o.apply(t,e),n[v("asyncIterator")]=()=>n,s("next"),s("throw"),s("return"),n},q=t=>{var e=t[v("asyncIterator")],o=!1,r,s={};return e==null?(e=t[v("iterator")](),r=n=>s[n]=i=>e[n](i)):(e=e.call(t),r=n=>s[n]=i=>{if(o){if(o=!1,n==="throw")throw i;return i}return o=!0,{done:!1,value:new y(new Promise(a=>{var c=e[n](i);c instanceof Object||jt("Object expected"),a(c)}),1)}}),s[v("iterator")]=()=>s,r("next"),"throw"in e?r("throw"):s.throw=n=>{throw n},"return"in e&&r("return"),s},C=(t,e,o)=>(e=t[v("asyncIterator")])?e.call(t):(t=t[v("iterator")](),e={},o=(r,s)=>(s=t[r])&&(e[r]=n=>new Promise((i,a,c)=>(n=s.call(t,n),c=n.done,Promise.resolve(n.value).then(p=>i({value:p,done:c}),a)))),o("next"),o("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 F from"node:fs";import z from"node:path";var O=async(t,e)=>{let o=await F.promises.readdir(t,{withFileTypes:!0});await F.promises.mkdir(e,{recursive:!0});for(let r of o){if(r.name===".git")continue;let s=z.join(t,r.name),n=z.join(e,r.name);r.isDirectory()?await O(s,n):await F.promises.copyFile(s,n)}};import Pt from"node:process";import{stripVTControlCharacters as St}from"node:util";var K=t=>({start:Pt.hrtime.bigint(),command:t.map(e=>Ct(St(e))).join(" "),state:{stdout:"",stderr:"",output:""}}),Ct=t=>/[^\w./-]/.test(t)?`'${t.replaceAll("'","'\\''")}'`:t;var W=function(r,s,n){return D(this,arguments,function*(t,{state:e},o){if(e.isIterating===!1)throw new Error(`The subprocess must be iterated right away, for example:
3
+ for await (const line of spawn(...)) { ... }`);e.isIterating=!0;try{let{[o]:l}=yield new y(t.nodeChildProcess);if(!l)return;let u="";try{for(var i=C(l.iterator({destroyOnReturn:!1})),a,c,p;a=!(c=yield new y(i.next())).done;a=!1){let w=c.value;let m=`${u}${w}`.split(/\r?\n/);u=m.pop(),yield*q(m)}}catch(c){p=[c]}finally{try{a&&(c=i.return)&&(yield new y(c.call(i)))}finally{if(p)throw p[0]}}u&&(yield u)}finally{yield new y(t)}})},Q=function(...t){return D(this,null,function*(){try{let e=[];for(;t.length>0;){e=t.map((i,a)=>{var c;return(c=e[a])!=null?c:It(i)});let[{value:o,done:r},s]=yield new y(Promise.race(e.map((i,a)=>Promise.all([i,a])))),[n]=t.splice(s,1);e.splice(s,1),r||(t.push(n),yield o)}}finally{yield new y(Promise.all(t.map(e=>e.return())))}})},It=async t=>{try{return await t.next()}catch(e){await t.throw(e)}};import k from"node:path";import Y from"node:process";import{fileURLToPath as Rt}from"node:url";var Z=c=>{var p=c,{stdin:t,stdout:e,stderr:o,stdio:r=[t,e,o],env:s,preferLocal:n,cwd:i="."}=p,a=T(p,["stdin","stdout","stderr","stdio","env","preferLocal","cwd"]);var m;let l=i instanceof URL?Rt(i):k.resolve(i),u=s?f(f({},Y.env),s):void 0,w=(m=r[0])==null?void 0:m.string;return b(f({},a),{input:w,stdio:w===void 0?r:["pipe",...r.slice(1)],env:n?At(u!=null?u:Y.env,l):u,cwd:l})},At=(s,r)=>{var n=s,{Path:t="",PATH:e=t}=n,o=T(n,["Path","PATH"]);let i=e.split(k.delimiter),a=X([],k.resolve(r)).map(c=>k.join(c,"node_modules/.bin")).filter(c=>!i.includes(c));return b(f({},o),{PATH:[...a,e].filter(Boolean).join(k.delimiter)})},X=(t,e)=>t.at(-1)===e?t:X([...t,e],k.resolve(e,".."));import{pipeline as Tt}from"node:stream/promises";var tt=async t=>{var r;let[[e,o]]=await Promise.all([Promise.allSettled(t),Dt(t)]);if(o.reason)throw o.reason.pipedFrom=(r=e.reason)!=null?r:e.value,o.reason;if(e.reason)throw e.reason;return b(f({},o.value),{pipedFrom:e.value})},Dt=async t=>{try{let[{stdout:e},{stdin:o}]=await Promise.all(t.map(({nodeChildProcess:r})=>r));if(o===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.');Tt(e,o).catch(()=>{})}catch(e){throw await Promise.allSettled(t.map(({nodeChildProcess:o})=>Ft(o))),e}},Ft=async t=>{let{stdin:e}=await t;e.end()};import{on as Ot,once as Wt}from"node:events";import Bt from"node:process";var et=async(t,{input:e},o)=>{let r=await t;e!==void 0&&r.stdin.end(e);let s=Wt(r,"close");try{return await Promise.race([s,...r.stdio.filter(Boolean).map(n=>Lt(n))]),Ut(o,ot(r)),rt(o)}catch(n){throw await Promise.allSettled([s]),L(n,r,o)}},Lt=async t=>{try{for(var e=C(Ot(t,"error")),o,r,s;o=!(r=await e.next()).done;o=!1){let[n]=r.value;if(!["ERR_STREAM_PREMATURE_CLOSE","EPIPE"].includes(n==null?void 0:n.code))throw n}}catch(r){s=[r]}finally{try{o&&(r=e.return)&&await r.call(e)}finally{if(s)throw s[0]}}},Ut=({command:t},{exitCode:e,signalName:o})=>{if(o!==void 0)throw new $(`Command was terminated with ${o}: ${t}`);if(e!==void 0)throw new $(`Command failed with exit code ${e}: ${t}`)},L=(t,e,o)=>Object.assign(Mt(t,o),ot(e),rt(o)),Mt=(t,{command:e})=>t instanceof $?t:new $(`Command failed: ${e}`,{cause:t}),$=class extends Error{constructor(){super(...arguments);V(this,"name","SubprocessError")}},ot=({exitCode:t,signalCode:e})=>f(f({},t<1?{}:{exitCode:t}),e===null?{}:{signalName:e}),rt=({state:{stdout:t,stderr:e,output:o},command:r,start:s})=>({stdout:B(t),stderr:B(e),output:B(o),command:r,durationMs:Number(Bt.hrtime.bigint()-s)/1e6}),B=t=>t.at(-1)===`
4
+ `?t.slice(0,t.at(-2)==="\r"?-2:-1):t;import{spawn as Vt}from"node:child_process";import{once as qt}from"node:events";import ct from"node:process";import{stat as Gt}from"node:fs/promises";import st from"node:path";import nt from"node:process";var it=async(t,e,o)=>await Ht(t,o)?[M(t),e.map(r=>Jt(r)),b(f({},o),{shell:!0})]:[t,e,o],Ht=async(t,{shell:e,cwd:o,env:r=nt.env})=>nt.platform==="win32"&&!e&&!await Nt(t,o,r),Nt=async(t,e,{Path:o="",PATH:r=o})=>{var s,n;return at.some(i=>t.toLowerCase().endsWith(i))||((n=U[s=`${t}\0${e}\0${r}`])!=null?n:U[s]=await _t(t,e,r))},U={},_t=async(t,e,o)=>{let r=o.split(st.delimiter).filter(Boolean).map(s=>s.replace(/^"(.*)"$/,"$1"));try{await Promise.all(at.flatMap(s=>[e,...r].map(n=>`${st.resolve(n,t)}${s}`)).map(async s=>{try{await Gt(s)}catch(n){return}throw 0}))}catch(s){return!0}return!1},at=[".exe",".com"],Jt=t=>M(M(`"${t.replaceAll(/(\\*)"/g,'$1$1\\"').replace(/(\\*)$/,"$1$1")}"`)),M=t=>t.replaceAll(/([()\][%!^"`<>&|;, *?])/g,"^$1");var lt=async(t,e,o,r)=>{try{[t,e]=["node","node.exe"].includes(t.toLowerCase())?[ct.execPath,[...ct.execArgv.filter(n=>!n.startsWith("--inspect")),...e]]:[t,e];let s=Vt(...await it(t,e,o));return pt(s.stdout,r,"stdout"),pt(s.stderr,r,"stderr"),s.once("error",()=>{}),await qt(s,"spawn"),s}catch(s){throw L(s,{},r)}},pt=(t,{state:e},o)=>{t&&(t.setEncoding("utf8"),e.isIterating||(e.isIterating=!1,t.on("data",r=>{e[o]+=r,e.output+=r})))};function x(t,e,o,r){let[s=[],n={}]=Array.isArray(e)?[e,o]:[[],e],i=K([t,...s]),a=Z(n),c=lt(t,s,a,i),p=et(c,a,i);Object.assign(p,{nodeChildProcess:c}),p=r?tt([r,p]):p;let l=W(p,i,"stdout"),u=W(p,i,"stderr");return Object.assign(p,{nodeChildProcess:c,stdout:l,stderr:u,[Symbol.asyncIterator]:()=>Q(l,u),pipe:(w,m,P)=>x(w,m,P,p)})}var G=async(t,e,o)=>{process.platform==="win32"&&await x("git",["config","--global","core.longpaths","true"]);let r=`https://${t.token?t.token+"@":t.token}github.com/${t.owner}/${t.repository}.git`,s=mt.join(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 n=performance.now();await x("git",["clone",r,s,"--branch",t.branch,"--depth","1","--single-branch"]);let i=mt.join(s,t.path);(await E.promises.stat(i)).isDirectory()?(await E.promises.mkdir(o,{recursive:!0}),await O(i,o)):(await E.promises.mkdir(o,{recursive:!0}),await E.promises.copyFile(i,o+"/"+t.path.split("/").pop())),e.watch?console.log("- Synced at "+new Date().toLocaleTimeString()):console.log(`
6
+ \u{1F389} Picked ${t.type}${t.type==="repository"?" without .git":" from repository"} in ${((performance.now()-n)/1e3).toFixed(2)} seconds!`),await E.promises.rm(s,{recursive:!0,force:!0})};import Kt from"node:tty";var ht,ut,I,dt,ft,Qt=(ft=(dt=(I=(ut=(ht=Kt)==null?void 0:ht.WriteStream)==null?void 0:ut.prototype)==null?void 0:I.hasColors)==null?void 0:dt.call(I))!=null?ft:!1,h=(t,e)=>{if(!Qt)return s=>s;let o=`\x1B[${t}m`,r=`\x1B[${e}m`;return s=>{let n=s+"",i=n.indexOf(r);if(i===-1)return o+n+r;let a=o,c=0;for(;i!==-1;)a+=n.slice(c,i)+o,c=i+r.length,i=n.indexOf(r,c);return a+=n.slice(c)+r,a}},Ke=h(0,0),d=h(1,22),Qe=h(2,22),Ye=h(3,23),Ze=h(4,24),Xe=h(53,55),to=h(7,27),eo=h(8,28),oo=h(9,29),ro=h(30,39),H=h(31,39),R=h(32,39),j=h(33,39),so=h(34,39),no=h(35,39),g=h(36,39),io=h(37,39),ao=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,o=0,r;for(;(r=e.exec(t))!==null;){let s=parseInt(r[1],10);switch(r[2]){case"h":o+=s*36e5;break;case"m":o+=s*6e4;break;case"s":o+=s*1e3;break}}return o}var gt=async t=>{var s,n;let e=(await x("git",["ls-remote",t])).stdout,o=(s=e.match(/(.+)\s+HEAD/))==null?void 0:s[1],r=(n=e.match(new RegExp(`${o}\\s+refs/heads/(.+)`)))==null?void 0:n[1];if(!r)throw new Error("Could not determine default branch!");return r};async function wt(t,{branch:e,target:o}){let r=/^https:\/\/([^@]+)@github\.com/,s=t.match(r),n="";s&&(n=s[1],t=t.replace(r,"https://github.com"));let i=["git@github.com:","https://github.com/","https://raw.githubusercontent.com/"];for(let P of i)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://${n&&n+"@"}github.com/${c}/${p}`):l==="raw"?a[4]:a[3]),w=l?l==="raw"?a.slice(5).join("/"):a.slice(4).join("/"):a.slice(2).join("/")||"/",m=o||(l==="blob"?".":w.split("/").pop()||p);return{token:n,owner:c,repository:p,type:l,branch:u,path:w,target:m}}var bt="gitpick",$t="3.27.0-canary.21";var Xt=`
7
+ ${d("With GitPick, you can clone precisely what you need.")}
5
8
 
6
- \u{1F680} More awesome tools at ${s.cyan("https://github.com/nrjdalal")}
9
+ ${d("gitpick")} ${j("<url>")} ${R("[target]")} ${g("[options]")}
7
10
 
8
- -------------------------------------
9
- ${s.cyan("gitpick <url>")} ${s.green("[target]")} ${s.blue("[options]")}
10
- -------------------------------------
11
+ ${d("Hint:")} Target is optional, and follows default git clone behavior.
11
12
 
12
- ${s.bold("Hint:")} Target is optional, and follows default git clone behavior.
13
+ ${d("Arguments:")}
14
+ ${j("url")} GitHub URL with path to file/folder/repository
15
+ ${R("target")} Directory to clone into (optional)
13
16
 
14
- ${s.bold("Arguments:")}
15
- ${s.cyan("url")} GitHub URL with path to file/folder
16
- ${s.green("target")} Directory to clone into (optional)
17
+ ${d("Options:")}
18
+ ${g("-b, --branch ")} Branch to clone
19
+ ${g("-o, --overwrite")} Skip overwrite prompt
20
+ ${g("-w, --watch [time]")} Watch the repository and sync every [time]
21
+ (e.g. 1h, 30m, 15s) default: 1m
22
+ ${g("-h, --help")} display help for command
23
+ ${g("-v, --version")} display the version number
17
24
 
18
- ${s.bold("Options:")}
19
- ${s.blue("-b, --branch ")} Branch to clone
20
- ${s.blue("-o, --overwrite")} Skip overwrite prompt
21
- ${s.blue("-w, --watch [time]")} Watch the repository and sync every [time]
22
- (e.g. 1h, 30m, 15s) default: 1m
23
- ${s.blue("-h, --help")} display help for command
24
- ${s.blue("-v, --version")} display the version number
25
-
26
- ${s.bold("Examples:")}
25
+ ${d("Examples:")}
27
26
  $ gitpick <url>
28
27
  $ gitpick <url> [target]
29
28
  $ gitpick <url> [target] -b [branch]
30
29
  $ gitpick <url> [target] -w [time]
31
30
  $ gitpick <url> [target] -b [branch] -w [time]
32
- `}),console.log(s.dim(`
33
- ${z("GitPick \u2197\uFE0F ","https://github.com/nrjdalal/gitpick")} - Clone specific directories or files from GitHub!
34
- `)),e.parse()}N();
31
+
32
+ \u{1F680} More awesome tools at ${g("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"},overwrite:{type:"boolean",short:"o"},force:{type:"boolean",short:"f"},watch:{type:"string",short:"w"},help:{type:"boolean",short:"h"},version:{type:"boolean",short:"v"}}});t.length||(e.version&&(console.log(`
33
+ ${bt}@${$t}`),process.exit(0)),console.log(Xt),process.exit(0)),t[0]==="clone"&&t.shift();let[o,r]=t,s={branch:e.branch,overwrite:e.overwrite,force:e.force,watch:e.watch};console.log(`
34
+ ${d("GitPick")} - Clone specific directories or files from GitHub!`),s.overwrite=s.overwrite||s.force,s.watch&&(typeof s.watch=="boolean"&&(s.watch="1m"),console.log(`
35
+ \u{1F440} Watching every ${N(s.watch)/1e3+"s"}`));let n=await wt(o,{branch:s.branch,target:r});console.info(`
36
+ ${d(n.owner)}/${d(n.repository)} ${R(`<${n.type}:${n.branch}>`)} ${n.type==="repository"?`> ${g(n.target)}`:`${j(n.path)} > ${g(`${n.target}${n.type==="blob"?`/${n.path.split("/").pop()}`:""}`)}`}`);let i=Zt.resolve(n.target);if(s.watch&&(s.overwrite=!0),xt.existsSync(i+(n.type==="blob"?"/"+n.path.split("/").pop():""))&&(await xt.promises.readdir(i)).length&&!s.overwrite&&(console.log(d(`${j(`
37
+ Warning: The target directory is not empty. Use ${g("-f")} | ${g("-o")} to overwrite.`)}`)),process.exit(0)),await G(n,s,i),s.watch){let a=N(s.watch);setInterval(async()=>await G(n,s,i),a)}else process.exit(0)}catch(t){t instanceof Error?console.log(d(`
38
+ ${H("Error: ")}`)+t.message):console.log(d(`${H(`
39
+ 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": "3.27.0-canary.2",
3
+ "version": "3.27.0-canary.21",
4
4
  "description": "With gitpick, you can clone precisely what you need.",
5
5
  "keywords": [
6
6
  "clone",
@@ -31,37 +31,5 @@
31
31
  },
32
32
  "files": [
33
33
  "dist"
34
- ],
35
- "scripts": {
36
- "build": "tsup",
37
- "dev": "tsup --watch",
38
- "prepare": "npx simple-git-hooks",
39
- "test": "bun run build && node dist/index.js",
40
- "tests": "bash tests.sh"
41
- },
42
- "simple-git-hooks": {
43
- "pre-commit": "npx lint-staged",
44
- "commit-msg": "npx commitlint --edit $1"
45
- },
46
- "dependencies": {
47
- "@clack/prompts": "^0.10.0",
48
- "commander": "^13.1.0",
49
- "simple-git": "^3.27.0",
50
- "terminal-link": "^4.0.0",
51
- "yoctocolors": "^2.1.1",
52
- "zod": "^3.24.2",
53
- "zod-validation-error": "^3.4.0"
54
- },
55
- "devDependencies": {
56
- "@commitlint/cli": "^19.8.0",
57
- "@commitlint/config-conventional": "^19.8.0",
58
- "@ianvs/prettier-plugin-sort-imports": "^4.4.1",
59
- "@types/node": "^22.13.13",
60
- "lint-staged": "^15.5.0",
61
- "prettier": "^3.5.3",
62
- "simple-git-hooks": "^2.12.1",
63
- "sort-package-json": "^2.15.1",
64
- "tsup": "^8.4.0",
65
- "typescript": "^5.8.2"
66
- }
34
+ ]
67
35
  }