gitpick 4.15.0-canary.4 → 4.15.0-canary.6

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 CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  **Clone exactly what you need aka straightforward project scaffolding!**
6
6
 
7
- 📦 `Zero dependencies` / `Un/packed (<27/11kb)` / `Faster and more features` yet drop-in replacement for `degit`
7
+ 📦 `Zero dependencies` / `Un/packed (19/8kb)` / `Faster and more features` yet drop-in replacement for `degit`
8
8
 
9
9
  [![Twitter](https://img.shields.io/twitter/follow/nrjdalal_dev?label=%40nrjdalal_dev)](https://twitter.com/nrjdalal_dev)
10
10
  [![npm](https://img.shields.io/npm/v/gitpick?color=red&logo=npm)](https://www.npmjs.com/package/gitpick)
@@ -122,9 +122,16 @@ Create a `.gitpick.json` or `.gitpick.jsonc` in your project to pick multiple fi
122
122
  ```jsonc
123
123
  // .gitpick.jsonc
124
124
  [
125
- "owner/repo/tree/main/src",
126
- "owner/repo/blob/main/README.md docs",
127
- "other/repo/tree/main/configs my-configs",
125
+ // blob pick
126
+ "owner/repo/blob/main/path/to/file target-dir",
127
+ // repository picks
128
+ "owner/repo target-dir",
129
+ "https://github.com/owner/repo target-dir",
130
+ // tree picks
131
+ "owner/repo/tree/main/src target-dir",
132
+ "https://github.com/owner/repo/tree/main/src target-dir",
133
+ // tree picks with branch override
134
+ "owner/repo/tree/master/src -b main target-dir",
128
135
  ]
129
136
  ```
130
137
 
package/dist/index.mjs CHANGED
@@ -5,7 +5,7 @@ import e from"node:fs";import t from"node:path";import{parseArgs as n,stripVTCon
5
5
  `)};return{start(e){return i=e,u=!0,o&&d(`\x1B[?25l`),m(),o&&(n=setInterval(m,80)),this},success(e){return u?(u=!1,n&&=(clearInterval(n),void 0),f(),o&&d(`\x1B[?25h`),d(`${M} ${e??i}\n`),this):this}}},F=async(n,r,a)=>{process.platform===`win32`&&await S(`git`,[`config`,`--global`,`core.longpaths`,`true`]);let o=`https://${n.token?n.token+`@`:n.token}github.com/${n.owner}/${n.repository}.git`,s=t.resolve(i.tmpdir(),`${n.repository}-${Date.now()}${Math.random().toString(16).slice(2,6)}`),c=P(),l=performance.now();r.watch||c.start(`Picking ${n.type}${n.type===`repository`?` without .git`:` from repository`}...`);try{await S(`git`,[`clone`,o,s,`--branch`,n.branch,`--depth`,`1`,`--single-branch`,...r.recursive?[`--recursive`]:[]])}catch{await S(`git`,[`clone`,o,s,...r.recursive?[`--recursive`]:[]]),await S(`git`,[`checkout`,n.branch],{cwd:s})}let u=t.resolve(s,n.path);(await e.promises.stat(u)).isDirectory()?(await e.promises.mkdir(a,{recursive:!0}),await d(u,a)):(await e.promises.mkdir(a.split(`/`).slice(0,-1).join(`/`),{recursive:!0}),await e.promises.copyFile(u,a)),r.watch?console.log(`- Synced at `+new Date().toLocaleTimeString()):c.success(`Picked ${n.type}${n.type===`repository`?` without .git`:` from repository`} in ${((performance.now()-l)/1e3).toFixed(2)} seconds.`),await e.promises.rm(s,{recursive:!0,force:!0})};function I(e){if(typeof e==`number`||/^\d+$/.test(e))return typeof e==`number`?e:parseInt(e,10);let t=/(\d+)([hms])/g,n=0,r;for(;(r=t.exec(e))!==null;){let e=parseInt(r[1],10);switch(r[2]){case`h`:n+=e*36e5;break;case`m`:n+=e*6e4;break;case`s`:n+=e*1e3;break}}return n}const L=async e=>{let t=(await S(`git`,[`ls-remote`,e])).stdout,n=t.match(/(.+)\s+HEAD/)?.[1],r=t.match(RegExp(`${n}\\s+refs/heads/(.+)`))?.[1];if(!r)throw Error(`Could not determine default branch!`);return r};async function R(e,{branch:t,target:n}){let r=/^https:\/\/([^@]+)@github\.com/,i=e.match(r),a=``;i&&(a=i[1],e=e.replace(r,`https://github.com`));for(let t of[`git@github.com:`,`https://github.com/`,`https://raw.githubusercontent.com/`])if(e.startsWith(t)){e=e.replace(t,``);break}let o=e.split(`/`),s=o[0],c=o[1].endsWith(`.git`)?o[1].slice(0,-4):o[1],l=o[2]===`blob`?`blob`:o[2]===`tree`?`tree`:o[2]+o[3]===`refsheads`?`raw`:`repository`,u=t||(l===`repository`?await L(`https://${a&&a+`@`}github.com/${s}/${c}`):l===`raw`?o[4]:o[3]),d=l?l===`raw`?o.slice(5).join(`/`):o.slice(4).join(`/`):o.slice(2).join(`/`)||`/`,f=n||(l===`blob`?`.`:d.split(`/`).pop()||c);return{token:a,owner:s,repository:c,type:l,branch:u,path:d,target:f}}const z=Symbol(`singleComment`),B=Symbol(`multiComment`),V=(e,t,n)=>e.slice(t,n).replace(/[^ \t\r\n]/g,` `),H=(e,t)=>{let n=t-1,r=0;for(;e[n]===`\\`;)--n,r+=1;return!!(r%2)};function U(e){if(typeof e!=`string`)throw TypeError(`Expected argument \`jsonString\` to be a \`string\`, got \`${typeof e}\``);let t=!1,n=!1,r=0,i=``,a=``,o=-1;for(let s=0;s<e.length;s++){let c=e[s],l=e[s+1];if(!n&&c===`"`&&(H(e,s)||(t=!t)),!t)if(!n&&c+l===`//`)i+=e.slice(r,s),r=s,n=z,s++;else if(n===z&&c+l===`\r
6
6
  `){s++,n=!1,i+=V(e,r,s),r=s;continue}else if(n===z&&c===`
7
7
  `)n=!1,i+=V(e,r,s),r=s;else if(!n&&c+l===`/*`){i+=e.slice(r,s),r=s,n=B,s++;continue}else if(n===B&&c+l===`*/`){s++,n=!1,i+=V(e,r,s+1),r=s+1;continue}else n||(o===-1?c===`,`&&(a+=i+e.slice(r,s),i=``,r=s,o=s):c===`}`||c===`]`?(i+=e.slice(r,s),a+=V(i,0,1)+i.slice(1),i=``,r=s,o=-1):c!==` `&&c!==` `&&c!==`\r`&&c!==`
8
- `&&(i+=e.slice(r,s),r=s,o=-1))}let s=n===z?V(e,r):e.slice(r);return a+i+s}const W=[`.gitpick.json`,`.gitpick.jsonc`],G=async()=>{let n;for(let r of W){let i=t.resolve(r);if(e.existsSync(i)){n=i;break}}if(!n)return!1;let r=await e.promises.readFile(n,`utf-8`),i=JSON.parse(U(r));if(!Array.isArray(i)||!i.every(e=>typeof e==`string`))throw Error(`${t.basename(n)} must be an array of strings`);for(let e of i)await S(process.argv[0],[...process.argv.slice(1),...e.split(/\s+/),`-o`],{stdio:`inherit`});return!0};var K=`gitpick`,q=`4.15.0-canary.4`;const J=(e,t)=>`\x1b]8;;${t}\x07${e}\x1b]8;;\x07`,Y=`
8
+ `&&(i+=e.slice(r,s),r=s,o=-1))}let s=n===z?V(e,r):e.slice(r);return a+i+s}const W=[`.gitpick.json`,`.gitpick.jsonc`],G=async()=>{let n;for(let r of W){let i=t.resolve(r);if(e.existsSync(i)){n=i;break}}if(!n)return!1;let r=await e.promises.readFile(n,`utf-8`),i=JSON.parse(U(r));if(!Array.isArray(i)||!i.every(e=>typeof e==`string`))throw Error(`${t.basename(n)} must be an array of strings`);for(let e of i)await S(process.argv[0],[...process.argv.slice(1),...e.split(/\s+/),`-o`],{stdio:`inherit`});return!0};var K=`gitpick`,q=`4.15.0-canary.6`;const J=(e,t)=>`\x1b]8;;${t}\x07${e}\x1b]8;;\x07`,Y=`
9
9
  With ${T(`${J(`GitPick`,`https://github.com/nrjdalal/gitpick`)}`)} clone specific directories or files from GitHub!
10
10
 
11
11
  $ gitpick ${O(`<url>`)} ${D(`[target]`)} ${k(`[options]`)}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gitpick",
3
- "version": "4.15.0-canary.4",
3
+ "version": "4.15.0-canary.6",
4
4
  "description": "Clone exactly what you need aka straightforward project scaffolding!",
5
5
  "keywords": [
6
6
  "clone",