gitpick 3.26.0-canary.2 → 3.26.0

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 +1 -1
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
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
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.25.2",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.")}
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.")}
5
5
 
6
6
  \u{1F680} More awesome tools at ${s.cyan("https://github.com/nrjdalal")}
7
7
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gitpick",
3
- "version": "3.26.0-canary.2",
3
+ "version": "3.26.0",
4
4
  "description": "With gitpick, you can clone precisely what you need.",
5
5
  "keywords": [
6
6
  "clone",