Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@begit/core

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@begit/core - npm Package Compare versions

Comparing version 0.0.14 to 0.0.15

2

dist/index.js

@@ -1,2 +0,2 @@

import{join as g}from"path";import{createWriteStream as x}from"fs";import{mkdir as b}from"fs/promises";import{Readable as u}from"stream";import{finished as A}from"stream/promises";import{homedir as L,tmpdir as E}from"os";import{dirname as R,join as m}from"path";var $=()=>{let a=process.env.XDG_CACHE_HOME??E();return m(a,".begit")},p=()=>m($(),"cache"),l=async(a,r,t)=>{t=t??"HEAD";let e=await fetch(`https://github.com/${a}/${r}/tarball/${t}`);return{body:e.body,name:e.url.split("/").pop()}},h=async(a,r)=>{await b(R(a.toString()),{recursive:!0});let t=x(a);await A(u.fromWeb(r.body).pipe(t))},d=async(a,r)=>(await(await fetch(`https://api.github.com/repos/${a}/${r}/commits?per_page=1`)).json())[0].sha;import{existsSync as C}from"fs";import{extract as D,list as S}from"tar";import{mkdir as T,unlink as w}from"fs/promises";var k=async a=>{let{owner:r,name:t,branch:e}=a,n=await d(r,t),o=g(p(),`${r}-${t}-${n}.tar.gz`);if(C(o))return o;let i=await l(r,t,e);return await h(o,i),o},F=async a=>{let r=[];return await S({file:a,onentry:t=>r.push(t.path)}),r},O=async(a,r,t=null,e=!1)=>{t&&(t=t?.startsWith("/")?t:`/${t}`,t=t?.endsWith("/")?t:`${t}/`),await T(r,{recursive:!0});let o=(await F(a)).find(s=>t?s.includes(t):!1);if(t&&!o)throw new Error("Subdirectory not found");let i=o?o.split("/").length-1:1;await new Promise((s,y)=>D({file:a.toString(),strip:i,C:r,k:!e},o?[o]:void 0,c=>{c&&y(c),s()}))},f=async({repo:a,dest:r,cwd:t,opts:e={cache:!0}})=>{let n=e.cache;t=t??process.cwd(),r=r??a.name;let o=await k(a);await O(o,g(t,r),a.subdir),n||await w(o)},B=async a=>{try{await f(a)}catch(r){if(r.tarCode!=="TAR_ABORT")throw r;let t=r.file;await w(t),await f(a)}};export{f as downloadAndExtract,B as downloadRepo,k as downloadToFile,O as extractFile};
import{join as d}from"path";import{createWriteStream as y}from"fs";import{mkdir as w}from"fs/promises";import{Readable as x}from"stream";import{finished as b}from"stream/promises";import{homedir as v,tmpdir as u}from"os";import{dirname as A,join as s}from"path";var E=()=>{let a=process.env.XDG_CACHE_HOME??u();return s(a,".begit")},c=()=>s(E(),"cache"),m=async(a,r,t)=>{t=t??"HEAD";let e=await fetch(`https://github.com/${a}/${r}/tarball/${t}`);return{body:e.body,name:e.url.split("/").pop()}},p=async(a,r)=>{await w(A(a.toString()),{recursive:!0});let t=y(a);await b(x.fromWeb(r.body).pipe(t))},l=async(a,r)=>(await(await fetch(`https://api.github.com/repos/${a}/${r}/commits?per_page=1`)).json())[0].sha;import{existsSync as R}from"fs";import{extract as $}from"tar/extract";import{list as C}from"tar/list";import{mkdir as D,unlink as f}from"fs/promises";var S=async a=>{let{owner:r,name:t,branch:e}=a,n=await l(r,t),o=d(c(),`${r}-${t}-${n}.tar.gz`);if(R(o))return o;let i=await m(r,t,e);return await p(o,i),o},T=async a=>{let r=[];return await C({file:a,onentry:t=>r.push(t.path)}),r},k=async(a,r,t=null,e=!1)=>{t&&(t=t?.startsWith("/")?t:`/${t}`,t=t?.endsWith("/")?t:`${t}/`),await D(r,{recursive:!0});let o=(await T(a)).find(g=>t?g.includes(t):!1);if(t&&!o)throw new Error("Subdirectory not found");let i=o?o.split("/").length-1:1;await $({file:a.toString(),strip:i,C:r,k:!e},o?[o]:void 0)},h=async({repo:a,dest:r,cwd:t,opts:e={cache:!0}})=>{let n=e.cache;t=t??process.cwd(),r=r??a.name;let o=await S(a);await k(o,d(t,r),a.subdir),n||await f(o)},z=async a=>{try{await h(a)}catch(r){if(r.tarCode!=="TAR_ABORT")throw r;let t=r.file;await f(t),await h(a)}};export{h as downloadAndExtract,z as downloadRepo,S as downloadToFile,k as extractFile};
//# sourceMappingURL=index.js.map
{
"name": "@begit/core",
"version": "0.0.14",
"version": "0.0.15",
"description": "Blazingly fast tool for cloning git repositories, with no reliance on local `git`, or `tar` installs",

@@ -20,16 +20,20 @@ "author": "Thomas Beer",

"types": "./types/index.d.ts",
"default": "./dist/index.js",
"import": "./dist/index.js"
"import": "./dist/index.js",
"default": "./dist/index.js"
}
},
"keywords": [],
"keywords": [
"git",
"template",
"scaffolding"
],
"devDependencies": {
"@types/node": "^20.12.6",
"@types/node": "^20.12.7",
"@types/tar": "^6.1.12",
"tsup": "^8.0.2",
"typescript": "^5.4.4",
"typescript": "^5.4.5",
"vitest": "^1.4.0"
},
"dependencies": {
"tar": "^6.2.1"
"tar": "^7.0.0"
},

@@ -36,0 +40,0 @@ "publishConfig": {

@@ -6,4 +6,4 @@ # Begit

```ts
import { downloadAndExtract } from "@begit/core";
await downloadAndExtract({
import { downloadRepo } from "@begit/core";
await downloadRepo({
repo: {

@@ -18,1 +18,5 @@ owner: "Tommypop2",

```
The code above downloads this repository into a folder named `cool_project`.
Alternatively, `downloadAndExtract` could be used in place of `downloadRepo` to opt out of automatically attempting to handle errors

@@ -10,2 +10,9 @@ export type Repository = {

export declare const downloadToFile: (repo: Repository) => Promise<string>;
/**
* Extracts a tarball to a given path
* @param tarPath Path to the tarfile to be extracted
* @param dest Destination folder, into which the contents of the tarball will be extracted
* @param subdir Folder within the tarball to extract
* @param overwrite Whether or not to overwrite existing files in the target directory
*/
export declare const extractFile: (tarPath: string, dest: string, subdir?: string | null, overwrite?: boolean) => Promise<void>;

@@ -21,3 +28,9 @@ export type Options = {

};
/**
* Downloads given repository to a folder.
*/
export declare const downloadAndExtract: ({ repo, dest, cwd, opts, }: DownloadAndExtract) => Promise<void>;
/**
* Wrapper around `downloadAndExtract`, which automatically attempts to re-download the tarball if extraction fails
*/
export declare const downloadRepo: (opts: DownloadAndExtract) => Promise<void>;

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc