gitpick 5.1.0 → 5.2.0-canary.1
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 +2 -36
- package/dist/index.mjs +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -158,43 +158,9 @@ npx gitpick https://github.com/owner/repo -i
|
|
|
158
158
|
npx gitpick https://gitlab.com/owner/repo -i
|
|
159
159
|
```
|
|
160
160
|
|
|
161
|
-
|
|
161
|
+
<img width="720" alt="Interactive Mode" src="https://github.com/user-attachments/assets/062e939e-b7c0-4678-ab7e-d392bac1d94a" />
|
|
162
162
|
|
|
163
|
-
|
|
164
|
-
2. An interactive file tree appears in your terminal
|
|
165
|
-
3. Navigate with arrow keys, select with space, expand/collapse folders with enter
|
|
166
|
-
4. Press `c` to confirm - only your selected files get copied
|
|
167
|
-
|
|
168
|
-
```
|
|
169
|
-
nrjdalal/gitpick repository:main > gitpick
|
|
170
|
-
|
|
171
|
-
> ● .
|
|
172
|
-
● ├── ▾ bin/
|
|
173
|
-
● │ ├── ▸ external/
|
|
174
|
-
● │ ├── ▸ utils/
|
|
175
|
-
○ │ └── index.ts
|
|
176
|
-
○ ├── ▸ tests/
|
|
177
|
-
○ ├── package.json
|
|
178
|
-
○ └── README.md
|
|
179
|
-
|
|
180
|
-
2 folders 3 files • 12.4 KB
|
|
181
|
-
|
|
182
|
-
↑↓:navigate enter:expand space:select c:confirm q:quit
|
|
183
|
-
```
|
|
184
|
-
|
|
185
|
-
**Controls:**
|
|
186
|
-
|
|
187
|
-
| Key | Action |
|
|
188
|
-
| ----------------- | -------------------------- |
|
|
189
|
-
| `↑` `↓` / `j` `k` | Navigate up/down |
|
|
190
|
-
| `←` `→` / `h` `l` | Collapse/expand folder |
|
|
191
|
-
| `Enter` | Toggle expand/collapse |
|
|
192
|
-
| `Space` | Toggle selection |
|
|
193
|
-
| `.` (first row) | Select/deselect all |
|
|
194
|
-
| `c` | Confirm and clone selected |
|
|
195
|
-
| `q` / `Ctrl+C` | Quit without cloning |
|
|
196
|
-
|
|
197
|
-
Works with GitHub, GitLab, Bitbucket, public and private repos.
|
|
163
|
+
Navigate with arrow keys, select with space, expand/collapse with enter, `.` to select all, `c` to confirm. Works with GitHub, GitLab, Bitbucket, public and private repos.
|
|
198
164
|
|
|
199
165
|
---
|
|
200
166
|
|
package/dist/index.mjs
CHANGED
|
@@ -5,12 +5,12 @@ import e from"node:fs";import t from"node:os";import n from"node:path";import{pa
|
|
|
5
5
|
`;for(let e=0;e<u.length;e++){let t=u[e],r=o+e+1===a,i=t.node.selected?O(`●`):E(`○`),s=t.node.type===`tree`?A(t.node.name+`/`):t.node.type===`symlink`?k(t.node.name)+E(` -> `)+(t.node.linkTarget.endsWith(`/`)?A(t.node.linkTarget):t.node.linkTarget):t.node.name,c=t.node.type===`tree`?t.node.expanded?E(`▾ `):E(`▸ `):` `,l=`${r?k(`>`):` `} ${i} ${E(t.prefix)}${E(t.connector)}${c}${s}`;if(r){let e=Math.max(0,n-R(l).length);l=`\x1B[48;5;236m${l}${` `.repeat(e)}\x1B[49m`}m+=l+`
|
|
6
6
|
`}for(let e=u.length;e<i;e++)m+=`
|
|
7
7
|
`;m+=`
|
|
8
|
-
`;let y=c.length>i?E(` • ${o+1}-${Math.min(o+i,c.length)}/${c.length}`):``,b;if(h)b=` all selected${y}`;else if(d+f>0){let e=[];f>0&&e.push(A(`${f} folder${f===1?``:`s`}`)),d>0&&e.push(`${d} file${d===1?``:`s`}`),b=` ${[e.join(` `),E(se(p))].join(E(` • `))}${y}`}else b=E(`
|
|
8
|
+
`;let y=c.length>i?E(` • ${o+1}-${Math.min(o+i,c.length)}/${c.length}`):``,b;if(h)b=` all selected${y}`;else if(d+f>0){let e=[];f>0&&e.push(A(`${f} folder${f===1?``:`s`}`)),d>0&&e.push(`${d} file${d===1?``:`s`}`),b=` ${[e.join(` `),E(se(p))].join(E(` • `))}${y}`}else b=E(` . to select all`)+y;m+=b+`
|
|
9
9
|
`,m+=`
|
|
10
10
|
`;let x=E(`↑↓:navigate enter:expand space:select c:confirm q:quit`);m+=` ${x}\n`,s.write(m)}function h(e){let t=ie(r),i=t.length+1,o=e.toString();if(o===``||o===`q`||o===`Q`){u(),process.removeListener(`exit`,d),process.removeListener(`SIGINT`,f),n([]);return}if(o===`c`||o===`C`){u(),process.removeListener(`exit`,d),process.removeListener(`SIGINT`,f),n(ae(r));return}if((o===`\x1B[A`||o===`k`)&&a>0&&a--,(o===`\x1B[B`||o===`j`)&&a<i-1&&a++,a===0&&(o===` `||o===`\r`)){let e=r.every(e=>e.selected);for(let t of r)z(t,!e)}if(o===` `&&a>0){let e=t[a-1];e&&z(e.node,!e.node.selected)}if(o===`\r`&&a>0){let e=t[a-1];e&&e.node.type===`tree`&&(e.node.expanded=!e.node.expanded)}if((o===`\x1B[C`||o===`l`)&&a>0){let e=t[a-1];e&&e.node.type===`tree`&&(e.node.expanded=!0)}if((o===`\x1B[D`||o===`h`)&&a>0){let e=t[a-1];e&&e.node.type===`tree`&&(e.node.expanded=!1)}m()}c.on(`data`,h),m()})}function B(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 V=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},H=[{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 le(e,{branch:t,target:n}){let r=e.match(/^https:\/\/([^@]+)@(github\.com|gitlab\.com|bitbucket\.org)/),i=``;if(r)i=r[1],e=e.replace(`${r[1]}@`,``);else{let t={"github.com":process.env.GITHUB_TOKEN||process.env.GH_TOKEN||``,"gitlab.com":process.env.GITLAB_TOKEN||``,"bitbucket.org":process.env.BITBUCKET_TOKEN||``};for(let{prefix:n,host:r}of H)if(e.startsWith(n)){i=t[r];break}!i&&!e.startsWith(`https://`)&&!e.startsWith(`git@`)&&(i=t[`github.com`])}let a=`github.com`;for(let{prefix:t,host:n}of H)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 V(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 V(l),f=``):o[2]===`src`?(u=`tree`,d=t||o[3],f=o.slice(4).join(`/`)):(u=`repository`,d=t||await V(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 U=n.join(t.homedir(),`.cache`,`gitpick`),W=n.join(U,`update-check.json`);function G(){try{return JSON.parse(e.readFileSync(W,`utf-8`))}catch{return null}}function ue(t){try{e.mkdirSync(U,{recursive:!0}),e.writeFileSync(W,JSON.stringify(t))}catch{}}function de(){return new Promise(e=>{let t=d.get(`https://registry.npmjs.org/gitpick/latest`,{headers:{Accept:`application/json`},timeout:3e3},t=>{if(t.statusCode!==200)return t.resume(),e(null);let n=``;t.on(`data`,e=>n+=e),t.on(`end`,()=>{try{e(JSON.parse(n).version||null)}catch{e(null)}})});t.on(`error`,()=>e(null)),t.on(`timeout`,()=>{t.destroy(),e(null)})})}function fe(e,t){let n=e.split(`.`).map(Number),r=t.split(`.`).map(Number);for(let e=0;e<3;e++){if((n[e]||0)>(r[e]||0))return!0;if((n[e]||0)<(r[e]||0))return!1}return!1}function K(e,t){if(t)return;let n=G();n&&fe(n.latestVersion,e)&&console.log(E(`\n Update available: ${k(e)} → ${A(T(n.latestVersion))}\n Run ${A(`npm i -g gitpick`)} to update\n`))}function pe(){let e=G();e&&Date.now()-e.lastCheck<864e5||setTimeout(async()=>{let e=await de();e&&ue({lastCheck:Date.now(),latestVersion:e})},0)}const q=Symbol(`singleComment`),J=Symbol(`multiComment`),Y=(e,t,n)=>e.slice(t,n).replace(/[^ \t\r\n]/g,` `),me=(e,t)=>{let n=t-1,r=0;for(;e[n]===`\\`;)--n,r+=1;return!!(r%2)};function he(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===`"`&&(me(e,s)||(t=!t)),!t)if(!n&&c+l===`//`)i+=e.slice(r,s),r=s,n=q,s++;else if(n===q&&c+l===`\r
|
|
11
11
|
`){s++,n=!1,i+=Y(e,r,s),r=s;continue}else if(n===q&&c===`
|
|
12
12
|
`)n=!1,i+=Y(e,r,s),r=s;else if(!n&&c+l===`/*`){i+=e.slice(r,s),r=s,n=J,s++;continue}else if(n===J&&c+l===`*/`){s++,n=!1,i+=Y(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+=Y(i,0,1)+i.slice(1),i=``,r=s,o=-1):c!==` `&&c!==` `&&c!==`\r`&&c!==`
|
|
13
|
-
`&&(i+=e.slice(r,s),r=s,o=-1))}let s=n===q?Y(e,r):e.slice(r);return a+i+s}const ge=[`.gitpick.json`,`.gitpick.jsonc`],_e=async()=>{let t;for(let r of ge){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(he(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 S(process.argv[0],[...process.argv.slice(1),...e.split(/\s+/),`-o`],{stdio:`inherit`});return!0};var ve=`gitpick`,X=`5.
|
|
13
|
+
`&&(i+=e.slice(r,s),r=s,o=-1))}let s=n===q?Y(e,r):e.slice(r);return a+i+s}const ge=[`.gitpick.json`,`.gitpick.jsonc`],_e=async()=>{let t;for(let r of ge){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(he(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 S(process.argv[0],[...process.argv.slice(1),...e.split(/\s+/),`-o`],{stdio:`inherit`});return!0};var ve=`gitpick`,X=`5.2.0-canary.1`;const Z=(e,t)=>`\x1b]8;;${t}\x07${e}\x1b]8;;\x07`,ye=`
|
|
14
14
|
With ${T(`${Z(`GitPick`,`https://github.com/nrjdalal/gitpick`)}`)} clone specific directories or files from GitHub, GitLab and Bitbucket!
|
|
15
15
|
|
|
16
16
|
$ gitpick ${k(`<url>`)} ${O(`[target]`)} ${A(`[options]`)}
|