@begit/core
Advanced tools
Comparing version 0.0.9 to 0.0.10
@@ -1,2 +0,2 @@ | ||
import{join as f}from"path";import{createWriteStream as g}from"fs";import{mkdir as y}from"fs/promises";import{Readable as w}from"stream";import{finished as b}from"stream/promises";import{homedir as O,tmpdir as x}from"os";import{dirname as u,join as m}from"path";var $=()=>{let r=process.env.XDG_CACHE_HOME??x();return m(r,".begit")},p=()=>m($(),"cache"),l=async(r,o,t)=>{t=t??"HEAD";let e=await fetch(`https://github.com/${r}/${o}/tarball/${t}`);return{body:e.body,name:e.url.split("/").pop()}},h=async(r,o)=>{await y(u(r.toString()),{recursive:!0});let t=g(r);await b(w.fromWeb(o.body).pipe(t))},d=async(r,o)=>(await(await fetch(`https://api.github.com/repos/${r}/${o}/commits?per_page=1`)).json())[0].sha;import{existsSync as E}from"fs";import{extract as S,list as A}from"tar";import{mkdir as P}from"fs/promises";var R=async(r,o={cache:!0})=>{let{owner:t,name:e,branch:a}=r,i=await d(t,e),n=f(p(),`${t}-${e}-${i}.tar.gz`);if(E(n))return n;let s=await l(t,e,a);return await h(n,s),n},C=async r=>{let o=[];return await A({file:r,onentry:t=>o.push(t.path)}),o},D=async(r,o,t=null)=>{t&&(t=t?.startsWith("/")?t:`/${t}`,t=t?.endsWith("/")?t:`${t}/`),await P(o,{recursive:!0});let a=(await C(r)).find(n=>t?n.includes(t):!1);if(t&&!a)throw new Error("Subdirectory not found");let i=a?a.split("/").length-1:1;await new Promise((n,s)=>S({file:r.toString(),strip:i,C:o},a?[a]:void 0,c=>{c&&s(c),n()}))},z=async({repo:r,dest:o,cwd:t})=>{t=t??process.cwd(),o=o??r.name;let e=await R(r);await D(e,f(t,o),r.subdir)};export{z as downloadAndExtract,R as downloadToFile,D as extractFile}; | ||
import{join as f}from"path";import{createWriteStream as d}from"fs";import{mkdir as y}from"fs/promises";import{Readable as w}from"stream";import{finished as x}from"stream/promises";import{homedir as H,tmpdir as b}from"os";import{dirname as u,join as c}from"path";var $=()=>{let r=process.env.XDG_CACHE_HOME??b();return c(r,".begit")},m=()=>c($(),"cache"),p=async(r,o,t)=>{t=t??"HEAD";let n=await fetch(`https://github.com/${r}/${o}/tarball/${t}`);return{body:n.body,name:n.url.split("/").pop()}},l=async(r,o)=>{await y(u(r.toString()),{recursive:!0});let t=d(r);await x(w.fromWeb(o.body).pipe(t))},h=async(r,o)=>(await(await fetch(`https://api.github.com/repos/${r}/${o}/commits?per_page=1`)).json())[0].sha;import{existsSync as E}from"fs";import{extract as C,list as D}from"tar";import{mkdir as S,unlink as A}from"fs/promises";var R=async r=>{let{owner:o,name:t,branch:n}=r,e=await h(o,t),a=f(m(),`${o}-${t}-${e}.tar.gz`);if(E(a))return a;let i=await p(o,t,n);return await l(a,i),a},F=async r=>{let o=[];return await D({file:r,onentry:t=>o.push(t.path)}),o},T=async(r,o,t=null)=>{t&&(t=t?.startsWith("/")?t:`/${t}`,t=t?.endsWith("/")?t:`${t}/`),await S(o,{recursive:!0});let e=(await F(r)).find(i=>t?i.includes(t):!1);if(t&&!e)throw new Error("Subdirectory not found");let a=e?e.split("/").length-1:1;await new Promise((i,g)=>C({file:r.toString(),strip:a,C:o},e?[e]:void 0,s=>{s&&g(s),i()}))},z=async({repo:r,dest:o,cwd:t,opts:n={cache:!0}})=>{let e=n.cache;t=t??process.cwd(),o=o??r.name;let a=await R(r);await T(a,f(t,o),r.subdir),e||await A(a)};export{z as downloadAndExtract,R as downloadToFile,T as extractFile}; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@begit/core", | ||
"version": "0.0.9", | ||
"version": "0.0.10", | ||
"description": "Blazingly fast tool for cloning git repositories, with no reliance on local `git`, or `tar` installs", | ||
@@ -5,0 +5,0 @@ "author": "", |
@@ -9,13 +9,13 @@ export type Repository = { | ||
}; | ||
type Options = { | ||
export declare const downloadToFile: (repo: Repository) => Promise<string>; | ||
export declare const extractFile: (tarPath: string, dest: string, subdir?: string | null) => Promise<void>; | ||
export type Options = { | ||
cache: boolean; | ||
}; | ||
export declare const downloadToFile: (repo: Repository, options?: Options) => Promise<string>; | ||
export declare const extractFile: (tarPath: string, dest: string, subdir?: string | null) => Promise<void>; | ||
type DownloadAndExtract = { | ||
export type DownloadAndExtract = { | ||
repo: Installable; | ||
dest?: string; | ||
cwd?: string; | ||
opts?: Options; | ||
}; | ||
export declare const downloadAndExtract: ({ repo, dest, cwd, }: DownloadAndExtract) => Promise<void>; | ||
export {}; | ||
export declare const downloadAndExtract: ({ repo, dest, cwd, opts, }: DownloadAndExtract) => Promise<void>; |
@@ -13,2 +13,5 @@ /// <reference types="node" /> | ||
export declare const toFile: (path: PathLike, tarball: Tarball) => Promise<void>; | ||
export type CommitData = { | ||
sha: string; | ||
}; | ||
export declare const fetchLatestCommit: (owner: string, repo: string) => Promise<string>; |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
11370
43