gitpick 0.0.0-60fe370

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Neeraj Dalal
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,197 @@
1
+ # GitPick
2
+
3
+ <!-- -->
4
+
5
+ **Clone exactly what you need aka straightforward project scaffolding!**
6
+
7
+ šŸ“¦ `Zero dependencies` / `Un/packed (~19/8kb)` / `Faster and more features` yet drop-in replacement for `degit`
8
+
9
+ [![Twitter](https://img.shields.io/twitter/follow/nrjdalal_dev?label=%40nrjdalal_dev)](https://twitter.com/nrjdalal_dev)
10
+ [![npm](https://img.shields.io/npm/v/gitpick?color=red&logo=npm)](https://www.npmjs.com/package/gitpick)
11
+ [![downloads](https://img.shields.io/npm/dt/gitpick?color=red&logo=npm)](https://www.npmjs.com/package/gitpick)
12
+ [![stars](https://img.shields.io/github/stars/nrjdalal/gitpick?color=blue)](https://github.com/nrjdalal/gitpick)
13
+
14
+ > #### Just `copy-and-paste` any GitHub URL - no editing required (shorthands work too) - to clone individual files, folders, branches, commits, raw content or even entire repositories without the `.git` directory.
15
+
16
+ Unlike other tools that force you to tweak URLs or follow strict formats to clone files, folders, branches or commits GitPick works seamlessly with any URL.
17
+
18
+ <img width="400" alt="GitPick Meme" src="https://github.com/user-attachments/assets/180c3e5b-320c-48d7-aaf9-a7402e74c882" />
19
+
20
+ ---
21
+
22
+ ## šŸ“– Some Examples
23
+
24
+ ### See [Quick Usage](#-quick-usage) for to learn more.
25
+
26
+ ```sh
27
+ # clone a repo without .git
28
+ npx gitpick owner/repo
29
+ npx gitpick https://github.com/owner/repo
30
+ # clone a folder aka tree
31
+ npx gitpick owner/repo/tree/main/path/to/folder
32
+ npx gitpick https://github.com/owner/repo/tree/main/path/to/folder
33
+ # clone a file aka blob
34
+ npx gitpick owner/repo/blob/main/path/to/file
35
+ npx gitpick https://github.com/owner/repo/blob/main/path/to/file
36
+ # clone a branch
37
+ npx gitpick owner/repo -b canary
38
+ npx gitpick https://github.com/owner/repo -b canary
39
+ npx gitpick owner/repo/tree/canary
40
+ npx gitpick https://github.com/owner/repo/tree/canary
41
+ # clone a commit SHA
42
+ npx gitpick owner/repo -b cc8e93
43
+ npx gitpick https://github.com/owner/repo/commit/cc8e93
44
+ # clone submodules
45
+ npx gitpick owner/repo -r
46
+ npx gitpick https://github.com/owner/repo -r
47
+ # clone a private repo
48
+ npx gitpick https://<token>@github.com/owner/repo
49
+ ```
50
+
51
+ ---
52
+
53
+ ## ✨ Features
54
+
55
+ - šŸ” Clone individual files or folders from any GitHub repository
56
+ - āš™ļø Auto-detects branches and target directory (if not specified) like `git clone`
57
+ - 🧠 Use shorthands `TanStack/router` or full URL's `https://github.com/TanStack/router`
58
+ - šŸ—‘ļø Overwrite or replace existing files without a prompt using `-o` | `--overwrite`
59
+ - šŸ“¦ Can easily clone all submodules with `-r` | `--recursive`
60
+ - šŸ” Sync changes remotely with `--watch` using intervals (e.g., `15s`, `1m`, `1h`)
61
+ - šŸ” Seamlessly works with both public and private repositories using a PAT
62
+ - šŸ“‹ Config file support (`.gitpick.json` / `.gitpick.jsonc`) for multi-path picks
63
+
64
+ ---
65
+
66
+ ## šŸš€ Quick Usage
67
+
68
+ ```sh
69
+ npx gitpick <url/shorthand> [target] [options]
70
+ ```
71
+
72
+ - [target] and [options] are optional, if not specified, GitPick fallbacks to the default behavior of `git clone`
73
+
74
+ Examples:
75
+
76
+ ```sh
77
+ npx gitpick https://github.com/owner/repo # repo without .git
78
+ npx gitpick owner/repo/tree/main/path/to/folder # a folder aka tree
79
+ npx gitpick owner/repo/blob/main/path/to/file # a file aka blob
80
+
81
+ npx gitpick <url/shorthand> # default git behavior
82
+ npx gitpick <url/shorthand> [target] # with optional target
83
+ npx gitpick <url/shorthand> -b [branch/SHA] # branch or commit SHA
84
+ npx gitpick <url/shorthand> -o # overwrite if exists
85
+ npx gitpick <url/shorthand> -r # clone submodules
86
+ npx gitpick <url/shorthand> -w 30s # sync every 30 seconds
87
+ npx gitpick https://<token>@github.com/owner/repo # private repository
88
+ ```
89
+
90
+ <img width="720" alt="Image" src="https://github.com/user-attachments/assets/ddbc41b4-bfc6-4287-bb85-eb949d723591" />
91
+
92
+ ---
93
+
94
+ ## šŸ”§ Options
95
+
96
+ ```
97
+ -b, --branch Branch/SHA to clone
98
+ -o, --overwrite Skip overwrite prompt
99
+ -r, --recursive Clone submodules
100
+ -w, --watch [time] Watch the repository and sync every [time]
101
+ (e.g. 1h, 30m, 15s)
102
+ -h, --help display help for command
103
+ -v, --version display the version number
104
+ ```
105
+
106
+ ---
107
+
108
+ ## šŸ” Private Repos
109
+
110
+ Use a [GitHub personal access token](https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#about-personal-access-tokens) (create one šŸ‘‰ [here](https://github.com/settings/personal-access-tokens/new)) with `repo -> contents: read-only` permission:
111
+
112
+ ```sh
113
+ npx gitpick https://<token>@github.com/owner/repo
114
+ ```
115
+
116
+ ---
117
+
118
+ ## šŸ“‹ Config File
119
+
120
+ Create a `.gitpick.json` or `.gitpick.jsonc` in your project to pick multiple files/folders in one command:
121
+
122
+ ```jsonc
123
+ // .gitpick.jsonc
124
+ [
125
+ // clone a repo without .git
126
+ "owner/repo",
127
+ "https://github.com/owner/repo",
128
+ // clone a folder aka tree
129
+ "owner/repo/tree/main/path/to/folder",
130
+ "https://github.com/owner/repo/tree/main/path/to/folder",
131
+ // clone a file aka blob
132
+ "owner/repo/blob/main/path/to/file",
133
+ "https://github.com/owner/repo/blob/main/path/to/file",
134
+ // clone a branch
135
+ "owner/repo -b canary",
136
+ "https://github.com/owner/repo -b canary",
137
+ "owner/repo/tree/canary",
138
+ "https://github.com/owner/repo/tree/canary",
139
+ // clone a commit SHA
140
+ "owner/repo -b cc8e93",
141
+ "https://github.com/owner/repo/commit/cc8e93",
142
+ // clone submodules
143
+ "owner/repo -r",
144
+ "https://github.com/owner/repo -r",
145
+ // clone a private repo
146
+ "https://<token>@github.com/owner/repo",
147
+ ]
148
+ ```
149
+
150
+ Then just run:
151
+
152
+ ```sh
153
+ npx gitpick
154
+ ```
155
+
156
+ Each entry follows the same `<url> [target]` syntax as the CLI. All entries are cloned with `-o` (overwrite) by default.
157
+
158
+ ---
159
+
160
+ ## šŸ“¦ Install Globally (Optional)
161
+
162
+ ```sh
163
+ npm install -g gitpick
164
+ gitpick <url/shorthand> [target] [options]
165
+ ```
166
+
167
+ ---
168
+
169
+ ## šŸ›  More Tools
170
+
171
+ Check out more projects at [github.com/nrjdalal](https://github.com/nrjdalal)
172
+
173
+ ## šŸ”— Related Projects
174
+
175
+ - [tiged](https://github.com/tiged/tiged) - community driven fork of degit
176
+ - [giget](https://github.com/unjs/giget) - alternative approach
177
+
178
+ [![Star History Chart](https://api.star-history.com/svg?repos=nrjdalal/gitpick,tiged/tiged,unjs/giget&type=timeline&logscale&legend=top-left)](https://www.star-history.com/#nrjdalal/gitpick&tiged/tiged&unjs/giget&type=timeline&logscale&legend=top-left)
179
+
180
+ ## šŸ¤ Contributing
181
+
182
+ Contributions welcome — any help is appreciated!
183
+
184
+ - Fork the repo and create a branch (use descriptive names, e.g. feat/<name> or fix/<name>).
185
+ - Make your changes, add tests if applicable, and run the checks:
186
+ - bun install
187
+ - bun test
188
+ - Follow the existing code style and commit message conventions (use conventional commits: feat, fix, docs, chore).
189
+ - Open a PR describing the change, motivation, and any migration notes; link related issues.
190
+ - For breaking changes or large features, open an issue first to discuss the approach.
191
+ - By contributing you agree to the MIT license and the project's Code of Conduct.
192
+
193
+ Thank you for helping improve GitPick!
194
+
195
+ ## šŸ“„ License
196
+
197
+ MIT – [LICENSE](LICENSE)
package/dist/index.mjs ADDED
@@ -0,0 +1,39 @@
1
+ #!/usr/bin/env node
2
+ import e from"node:fs";import t from"node:path";import{parseArgs as n,stripVTControlCharacters as r}from"node:util";import i from"node:tty";import a from"node:os";import{spawn as o}from"node:child_process";import{once as s}from"node:events";import c from"node:fs/promises";import l from"node:process";import{fileURLToPath as u}from"node:url";const d=i?.WriteStream?.prototype?.hasColors?.()??!1,f=(e,t)=>{if(!d)return e=>e;let n=`\u001B[${e}m`,r=`\u001B[${t}m`;return e=>{let i=e+``,a=i.indexOf(r);if(a===-1)return n+i+r;let o=n,s=0,c=(t===22?r:``)+n;for(;a!==-1;)o+=i.slice(s,a)+c,s=a+r.length,a=i.indexOf(r,s);return o+=i.slice(s)+r,o}},p=f(1,22),m=f(31,39),h=f(32,39),g=f(33,39),_=f(36,39);var v=class extends Error{constructor(...e){super(...e),this.name=`SubprocessError`,this.stdout=``,this.stderr=``}};const y=[`.exe`,`.com`],b={},x=e=>(...t)=>b[t.join(`\0`)]??=e(...t),S=x(async(...e)=>{try{return await c.access(e[0]),!0}catch{return!1}}),C=x(async(e,n,r)=>{let i=r.split(t.delimiter).filter(Boolean).map(e=>e.replace(/^"(.*)"$/,`$1`));try{await Promise.any([n,...i].flatMap(n=>y.map(r=>S(`${t.resolve(n,e)}${r}`))))}catch{return!1}return!0}),w=async(e,t)=>l.platform===`win32`&&!t.shell&&!y.some(t=>e.toLowerCase().endsWith(t))&&!await C(e,t.cwd??`.`,(l.env.PATH||l.env.Path)??``),T=e=>e.replaceAll(/([()\][%!^"`<>&|;, *?])/g,`^$1`),E=e=>T(T(`"${e.replaceAll(/(\\*)"/g,`$1$1\\"`).replace(/(\\*)$/,`$1$1`)}"`)),D=e=>/[^\w./-]/.test(e)?`'${e.replaceAll(`'`,`'\\''`)}'`:e;async function O(e,n=[],i={}){let{stdin:a,stdout:c,stderr:d,stdio:f,cwd:p=`.`,env:m,...h}=i,g=p instanceof URL?u(p):t.resolve(p),_=m?{...l.env,...m}:void 0,y=f??[a,c,d],b=[e,...n].map(e=>D(r(e))).join(` `);[`node`,`node.exe`].includes(e.toLowerCase())&&(e=l.execPath,n=[...l.execArgv.filter(e=>!e.startsWith(`--inspect`)),...n]);let x={...h,stdio:y,env:_,cwd:g};await w(e,x)&&(n=n.map(e=>E(e)),e=T(e),x={...x,shell:!0}),x.shell&&n.length>0&&(e=[e,...n].join(` `),n=[]);let S=o(e,n,x),C=``,O=``;S.stdout&&(S.stdout.setEncoding(`utf8`),S.stdout.on(`data`,e=>C+=e)),S.stderr&&(S.stderr.setEncoding(`utf8`),S.stderr.on(`data`,e=>O+=e)),S.once(`error`,()=>{});try{await s(S,`spawn`)}catch(e){throw Object.assign(new v(`Command failed: ${b}`,{cause:e}),{stdout:C,stderr:O})}await s(S,`close`);let k=e=>e.at(-1)===`
3
+ `?e.slice(0,e.at(-2)===`\r`?-2:-1):e;if(S.exitCode&&S.exitCode>0)throw Object.assign(new v(`Command failed with exit code ${S.exitCode}: ${b}`),{stdout:k(C),stderr:k(O),exitCode:S.exitCode});if(S.signalCode)throw Object.assign(new v(`Command was terminated with ${S.signalCode}: ${b}`),{stdout:k(C),stderr:k(O)});return{stdout:k(C),stderr:k(O)}}const k=l.platform!==`win32`||!!l.env.WT_SESSION||l.env.TERM_PROGRAM===`vscode`,A=e=>!!(e.isTTY&&l.env.TERM!==`dumb`&&!(`CI`in l.env)),j=h(k?`āœ”`:`√`),M=k?[`ā ‹`,`ā ™`,`ā ¹`,`ā ø`,`ā ¼`,`ā “`,`ā ¦`,`ā §`,`ā ‡`,`ā `]:[`-`,`\\`,`|`,`/`],N=(e={})=>{let t=-1,n,i=e.text??``,a=e.stream??l.stderr,o=A(a),s=0,c=0,u=!1,d=e=>a.write(e),f=()=>{if(!(!o||s===0)){a.cursorTo(0);for(let e=0;e<s;e++)e>0&&a.moveCursor(0,-1),a.clearLine(1);s=0}},p=e=>{let t=a.columns??80,n=r(e).split(`
4
+ `),i=0;for(let e of n)i+=Math.max(1,Math.ceil(e.length/t));return i},m=()=>{let e=Date.now();(t===-1||e-c>=80)&&(t=++t%M.length,c=e);let n=M[t],r=`${_(n)} ${i}`;o?(f(),d(r),s=p(r)):d(r+`
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(`${j} ${e??i}\n`),this):this}}},P=async(n,r)=>{let i=await e.promises.readdir(n,{withFileTypes:!0});await e.promises.mkdir(r,{recursive:!0});for(let a of i){if(a.name===`.git`)continue;let i=t.join(n,a.name),o=t.join(r,a.name);if(a.isDirectory())await P(i,o);else if(a.isSymbolicLink()){let t=await e.promises.readlink(i);await e.promises.symlink(t,o)}else await e.promises.copyFile(i,o)}},F=async(n,r,i)=>{process.platform===`win32`&&await O(`git`,[`config`,`--global`,`core.longpaths`,`true`]);let o=`https://${n.token?n.token+`@`:n.token}${n.host}/${n.owner}/${n.repository}.git`,s=t.resolve(a.tmpdir(),`${n.repository}-${Date.now()}${Math.random().toString(16).slice(2,6)}`),c=N(),l=performance.now();r.watch||c.start(`Picking ${n.type}${n.type===`repository`?` without .git`:` from repository`}...`);try{await O(`git`,[`clone`,o,s,`--branch`,n.branch,`--depth`,`1`,`--single-branch`,...r.recursive?[`--recursive`]:[]])}catch{await O(`git`,[`clone`,o,s,...r.recursive?[`--recursive`]:[]]),await O(`git`,[`checkout`,n.branch],{cwd:s})}let u=t.resolve(s,n.path);(await e.promises.stat(u)).isDirectory()?(await e.promises.mkdir(i,{recursive:!0}),await P(u,i)):(await e.promises.mkdir(t.dirname(i),{recursive:!0}),await e.promises.copyFile(u,i)),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 O(`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},R=[{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 z(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 R)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 L(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 L(l),f=``):o[2]===`src`?(u=`tree`,d=t||o[3],f=o.slice(4).join(`/`)):(u=`repository`,d=t||await L(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 B=Symbol(`singleComment`),V=Symbol(`multiComment`),H=(e,t,n)=>e.slice(t,n).replace(/[^ \t\r\n]/g,` `),U=(e,t)=>{let n=t-1,r=0;for(;e[n]===`\\`;)--n,r+=1;return!!(r%2)};function W(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===`"`&&(U(e,s)||(t=!t)),!t)if(!n&&c+l===`//`)i+=e.slice(r,s),r=s,n=B,s++;else if(n===B&&c+l===`\r
6
+ `){s++,n=!1,i+=H(e,r,s),r=s;continue}else if(n===B&&c===`
7
+ `)n=!1,i+=H(e,r,s),r=s;else if(!n&&c+l===`/*`){i+=e.slice(r,s),r=s,n=V,s++;continue}else if(n===V&&c+l===`*/`){s++,n=!1,i+=H(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+=H(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===B?H(e,r):e.slice(r);return a+i+s}const G=[`.gitpick.json`,`.gitpick.jsonc`],K=async()=>{let n;for(let r of G){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(W(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 O(process.argv[0],[...process.argv.slice(1),...e.split(/\s+/),`-o`],{stdio:`inherit`});return!0};var q=`gitpick`,J=`0.0.0-60fe370`;const Y=(e,t)=>`\x1b]8;;${t}\x07${e}\x1b]8;;\x07`,X=`
9
+ With ${p(`${Y(`GitPick`,`https://github.com/nrjdalal/gitpick`)}`)} clone specific directories or files from GitHub, GitLab and Bitbucket!
10
+
11
+ $ gitpick ${g(`<url>`)} ${h(`[target]`)} ${_(`[options]`)}
12
+
13
+ ${p(`Hint:`)}
14
+ [target] and [options] are optional and if not specified,
15
+ GitPick fallbacks to the default behavior of \`git clone\`
16
+
17
+ ${p(`Arguments:`)}
18
+ ${g(`url`)} GitHub/GitLab/Bitbucket URL with path to file/folder/repository
19
+ ${h(`target`)} Directory to clone into (optional)
20
+
21
+ ${p(`Options:`)}
22
+ ${_(`-b, --branch `)} Branch/SHA to clone
23
+ ${_(`-n, --dry-run`)} Show what would be cloned without cloning
24
+ ${_(`-o, --overwrite`)} Skip overwrite prompt
25
+ ${_(`-r, --recursive`)} Clone submodules
26
+ ${_(`-w, --watch [time]`)} Watch the repository and sync every [time]
27
+ (e.g. 1h, 30m, 15s)
28
+ ${_(`-h, --help`)} display help for command
29
+ ${_(`-v, --version`)} display the version number
30
+
31
+ ${p(`Examples:`)}
32
+ $ gitpick <url>
33
+ $ gitpick <url> [target]
34
+ $ gitpick <url> [target] -b [branch/SHA]
35
+ $ gitpick <url> [target] -w [time]
36
+ $ gitpick <url> [target] -b [branch/SHA] -w [time]
37
+
38
+ šŸš€ More awesome tools at ${_(`https://github.com/nrjdalal`)}`,Z=e=>{try{return n(e)}catch(e){throw Error(`Error parsing arguments: ${e.message}`)}};(async()=>{try{let{positionals:n,values:r}=Z({allowPositionals:!0,options:{branch:{type:`string`,short:`b`},"dry-run":{type:`boolean`,short:`n`},force:{type:`boolean`,short:`f`},help:{type:`boolean`,short:`h`},overwrite:{type:`boolean`,short:`o`},recursive:{type:`boolean`,short:`r`},version:{type:`boolean`,short:`v`},watch:{type:`string`,short:`w`}}});n.length||(r.version&&(console.log(`\n${q}@${J}`),process.exit(0)),await K()&&process.exit(0),console.log(X),process.exit(0)),n[0]===`clone`&&n.shift();let[i,a]=n,o={branch:r.branch,dryRun:r[`dry-run`],force:r.force,overwrite:r.overwrite,recursive:r.recursive,watch:r.watch};console.log(`\nWith ${p(`${Y(`GitPick`,`https://github.com/nrjdalal/gitpick`)}`)} clone specific files, folders, branches, commits and more from GitHub, GitLab and Bitbucket!`);let s=await z(i,{branch:o.branch,target:a});if(s.type===`blob`){let e=s.target.split(/[/\\]/).filter(e=>e!==``),t=e[e.length-1];t!==`.`&&t!==`..`&&t.includes(`.`)?e.pop():t=s.path.split(`/`).pop()||t,s.target=[...e,t].join(`/`)}console.info(`\n${h(`āœ”`)} ${s.owner}/${s.repository} ${_(s.type+`:`+s.branch)} ${s.type===`repository`?`> ${h(s.target)}`:`${s.path.length?g(s.path)+` >`:`>`} ${h(s.target)}`}`),o.dryRun&&(console.log(),process.exit(0));let c=t.resolve(s.target);if(o.overwrite=o.overwrite||o.force,o.watch&&(o.overwrite=!0),e.existsSync(c)&&!o.overwrite&&(s.type===`blob`&&(console.log(`${g(`\nWarning: The target file exists at ${h(s.target)}. Use ${_(`-f`)} or ${_(`-o`)} to overwrite.`)}`),process.exit(1)),(await e.promises.readdir(c)).length&&(console.log(`${g(`\nWarning: The target directory exists at ${h(s.target)} and is not empty. Use ${_(`-f`)} or ${_(`-o`)} to overwrite.`)}`),process.exit(1))),o.watch){console.log(`\nšŸ‘€ Watching every ${I(o.watch)/1e3+`s`}\n`),await F(s,o,c);let e=I(o.watch);setInterval(async()=>await F(s,o,c),e)}else await F(s,o,c),process.exit(0)}catch(e){e instanceof Error?console.log(p(`\n${m(`Error: `)}`)+e.message):console.log(p(`${m(`
39
+ Unexpected Error: `)}`)+JSON.stringify(e,null,2)),process.exit(1)}})();export{};
package/package.json ADDED
@@ -0,0 +1,36 @@
1
+ {
2
+ "name": "gitpick",
3
+ "version": "0.0.0-60fe370",
4
+ "description": "Clone exactly what you need aka straightforward project scaffolding!",
5
+ "keywords": [
6
+ "clone",
7
+ "degit",
8
+ "directory",
9
+ "file",
10
+ "folder",
11
+ "git",
12
+ "github",
13
+ "repository",
14
+ "scaffolding",
15
+ "template",
16
+ "url"
17
+ ],
18
+ "homepage": "https://github.com/nrjdalal/gitpick#readme",
19
+ "bugs": "https://github.com/nrjdalal/gitpick/issues",
20
+ "license": "MIT",
21
+ "author": {
22
+ "name": "Neeraj Dalal",
23
+ "email": "admin@nrjdalal.com",
24
+ "url": "https://nrjdalal.com"
25
+ },
26
+ "repository": "nrjdalal/gitpick",
27
+ "funding": "https://github.com/sponsors/nrjdalal",
28
+ "bin": {
29
+ "degit": "./dist/index.mjs",
30
+ "gitpick": "./dist/index.mjs"
31
+ },
32
+ "files": [
33
+ "dist"
34
+ ],
35
+ "type": "module"
36
+ }