gitpick 4.18.0-canary.3 → 4.18.0-canary.4

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
@@ -61,14 +61,14 @@ npx gitpick owner/repo --dry-run
61
61
  ## ✨ Features
62
62
 
63
63
  - 🔍 Clone individual files or folders from GitHub, GitLab and Bitbucket
64
- - ⚙️ Auto-detects branches and target directory (if not specified) like `git clone`
65
64
  - 🧠 Use shorthands `TanStack/router` or full URL's `https://github.com/TanStack/router`
66
- - 🗑️ Overwrite or replace existing files without a prompt using `-o` | `--overwrite`
67
- - 📦 Can easily clone all submodules with `-r` | `--recursive`
68
- - 🔁 Sync changes remotely with `--watch` using intervals (e.g., `15s`, `1m`, `1h`)
65
+ - ⚙️ Auto-detects branches and target directory (if not specified) like `git clone`
69
66
  - 🔐 Seamlessly works with both public and private repositories using a PAT
67
+ - 📦 Can easily clone all submodules with `-r` | `--recursive`
70
68
  - 🔎 Preview what would be cloned with `--dry-run` before cloning
71
69
  - 🌳 View cloned file structure as a colored tree with `--tree`
70
+ - 🗑️ Overwrite or replace existing files without a prompt using `-o` | `--overwrite`
71
+ - 🔁 Sync changes remotely with `--watch` using intervals (e.g., `15s`, `1m`, `1h`)
72
72
  - 🔇 Silent mode with `--quiet` for CI pipelines, debug mode with `--verbose`
73
73
  - 📋 Config file support (`.gitpick.json` / `.gitpick.jsonc`) for multi-path picks
74
74
 
package/dist/index.mjs CHANGED
@@ -5,7 +5,7 @@ import e from"node:fs";import t from"node:os";import n from"node:path";import{pa
5
5
  `)};return{start(e){return r=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??r}\n`),this):this}}},F=async(t,r,i)=>{let a=i??r,o=await e.promises.readdir(t,{withFileTypes:!0});await e.promises.mkdir(r,{recursive:!0});let s=[];for(let i of o){if(i.name===`.git`)continue;let o=n.join(t,i.name),c=n.join(r,i.name);if(i.isDirectory())s.push(...await F(o,c,a));else if(i.isSymbolicLink()){let t=await e.promises.readlink(o);await e.promises.symlink(t,c),s.push(n.relative(a,c))}else await e.promises.copyFile(o,c),s.push(n.relative(a,c))}return s},I=async(r,i,a)=>{let o=i.tree||i.quiet,s=i.verbose&&!o;process.platform===`win32`&&await k(`git`,[`config`,`--global`,`core.longpaths`,`true`]);let c=`https://${r.token?r.token+`@`:r.token}${r.host}/${r.owner}/${r.repository}.git`,l=`https://${r.host}/${r.owner}/${r.repository}.git`,u=n.resolve(t.tmpdir(),`${r.repository}-${Date.now()}${Math.random().toString(16).slice(2,6)}`),d=P(),f=performance.now();!i.watch&&!o&&d.start(`Picking ${r.type}${r.type===`repository`?` without .git`:` from repository`}...`);let p=`shallow`;try{await k(`git`,[`clone`,c,u,`--branch`,r.branch,`--depth`,`1`,`--single-branch`,...i.recursive?[`--recursive`]:[]])}catch{p=`full`,await k(`git`,[`clone`,c,u,...i.recursive?[`--recursive`]:[]]),await k(`git`,[`checkout`,r.branch],{cwd:u})}let h=n.resolve(u,r.path),g=await e.promises.stat(h),_=[];g.isDirectory()?(await e.promises.mkdir(a,{recursive:!0}),_=await F(h,a)):(await e.promises.mkdir(n.dirname(a),{recursive:!0}),await e.promises.copyFile(h,a),_=[n.basename(a)]);let y=Number(((performance.now()-f)/1e3).toFixed(2));return o||(i.watch?console.log(`- Synced at `+new Date().toLocaleTimeString()):d.success(`Picked ${r.type}${r.type===`repository`?` without .git`:` from repository`} in ${y} seconds.`)),s&&(console.log(m(` clone: ${p} (depth=${p===`shallow`?`1`:`full`})`)),console.log(m(` from: ${l} @ ${v(r.branch)}`)),console.log(m(` to: ${a}`)),console.log(m(` files: ${_.length}`)),console.log(m(` duration: ${y}s`))),await e.promises.rm(u,{recursive:!0,force:!0}),{files:_,duration:y}};function L(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 R=async e=>{let t=(await k(`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},z=[{prefix:`git@github.com:`,host:`github.com`},{prefix:`https://github.com/`,host:`github.com`},{prefix:`https://raw.githubusercontent.com/`,host:`github.com`},{prefix:`git@gitlab.com:`,host:`gitlab.com`},{prefix:`https://gitlab.com/`,host:`gitlab.com`},{prefix:`git@bitbucket.org:`,host:`bitbucket.org`},{prefix:`https://bitbucket.org/`,host:`bitbucket.org`}];async function B(e,{branch:t,target:n}){let r=e.match(/^https:\/\/([^@]+)@(github\.com|gitlab\.com|bitbucket\.org)/),i=``;r&&(i=r[1],e=e.replace(`${r[1]}@`,``));let a=`github.com`;for(let{prefix:t,host:n}of z)if(e.startsWith(t)){a=n,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=`https://${i&&i+`@`}${a}/${s}/${c}`,u,d,f;a===`github.com`?o[2]===`refs`&&[`heads`,`tags`].includes(o[3])?(u=`raw`,d=t||o[4],f=o.slice(5).join(`/`)):o[2]===`refs`&&o[3]===`remotes`?(u=`raw`,d=t||`${o[4]}/${o[5]}`,f=o.slice(6).join(`/`)):o[2]===`blob`?(u=`blob`,d=t||o[3],f=o.slice(4).join(`/`)):o[2]===`tree`?(u=`tree`,d=t||o[3],f=o.slice(4).join(`/`)):o[2]===`commit`?(u=`repository`,d=t||o[3],f=``):(u=`repository`,d=t||await R(l),f=``):a===`gitlab.com`?o[2]===`-`&&o[3]===`blob`?(u=`blob`,d=t||o[4],f=o.slice(5).join(`/`)):o[2]===`-`&&o[3]===`tree`?(u=`tree`,d=t||o[4],f=o.slice(5).join(`/`)):(u=`repository`,d=t||await R(l),f=``):o[2]===`src`?(u=`tree`,d=t||o[3],f=o.slice(4).join(`/`)):(u=`repository`,d=t||await R(l),f=``);let p=n||(u===`blob`?`.`:f.split(`/`).pop()||c);return{token:i,host:a,owner:s,repository:c,type:u,branch:d,path:f,target:p}}const V=Symbol(`singleComment`),H=Symbol(`multiComment`),U=(e,t,n)=>e.slice(t,n).replace(/[^ \t\r\n]/g,` `),W=(e,t)=>{let n=t-1,r=0;for(;e[n]===`\\`;)--n,r+=1;return!!(r%2)};function G(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===`"`&&(W(e,s)||(t=!t)),!t)if(!n&&c+l===`//`)i+=e.slice(r,s),r=s,n=V,s++;else if(n===V&&c+l===`\r
6
6
  `){s++,n=!1,i+=U(e,r,s),r=s;continue}else if(n===V&&c===`
7
7
  `)n=!1,i+=U(e,r,s),r=s;else if(!n&&c+l===`/*`){i+=e.slice(r,s),r=s,n=H,s++;continue}else if(n===H&&c+l===`*/`){s++,n=!1,i+=U(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+=U(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===V?U(e,r):e.slice(r);return a+i+s}const K=[`.gitpick.json`,`.gitpick.jsonc`],q=async()=>{let t;for(let r of K){let i=n.resolve(r);if(e.existsSync(i)){t=i;break}}if(!t)return!1;let r=await e.promises.readFile(t,`utf-8`),i=JSON.parse(G(r));if(!Array.isArray(i)||!i.every(e=>typeof e==`string`))throw Error(`${n.basename(t)} must be an array of strings`);for(let e of i)await k(process.argv[0],[...process.argv.slice(1),...e.split(/\s+/),`-o`],{stdio:`inherit`});return!0};var J=`gitpick`,Y=`4.18.0-canary.3`;const X=(e,t)=>`\x1b]8;;${t}\x07${e}\x1b]8;;\x07`,Z=`
8
+ `&&(i+=e.slice(r,s),r=s,o=-1))}let s=n===V?U(e,r):e.slice(r);return a+i+s}const K=[`.gitpick.json`,`.gitpick.jsonc`],q=async()=>{let t;for(let r of K){let i=n.resolve(r);if(e.existsSync(i)){t=i;break}}if(!t)return!1;let r=await e.promises.readFile(t,`utf-8`),i=JSON.parse(G(r));if(!Array.isArray(i)||!i.every(e=>typeof e==`string`))throw Error(`${n.basename(t)} must be an array of strings`);for(let e of i)await k(process.argv[0],[...process.argv.slice(1),...e.split(/\s+/),`-o`],{stdio:`inherit`});return!0};var J=`gitpick`,Y=`4.18.0-canary.4`;const X=(e,t)=>`\x1b]8;;${t}\x07${e}\x1b]8;;\x07`,Z=`
9
9
  With ${p(`${X(`GitPick`,`https://github.com/nrjdalal/gitpick`)}`)} clone specific directories or files from GitHub, GitLab and Bitbucket!
10
10
 
11
11
  $ gitpick ${_(`<url>`)} ${g(`[target]`)} ${v(`[options]`)}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gitpick",
3
- "version": "4.18.0-canary.3",
3
+ "version": "4.18.0-canary.4",
4
4
  "description": "Clone exactly what you need aka straightforward project scaffolding!",
5
5
  "keywords": [
6
6
  "clone",