Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/iwatakeshi/gitly
An API to download and/or extract git repositories
https://github.com/iwatakeshi/gitly
Last synced: 6 days ago
JSON representation
An API to download and/or extract git repositories
- Host: GitHub
- URL: https://github.com/iwatakeshi/gitly
- Owner: iwatakeshi
- License: mit
- Created: 2019-11-09T20:29:51.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2024-11-24T17:38:50.000Z (about 1 month ago)
- Last Synced: 2024-12-24T23:46:53.758Z (13 days ago)
- Language: TypeScript
- Size: 36.8 MB
- Stars: 26
- Watchers: 3
- Forks: 5
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# gitly
An API to download and/or extract git repositories.
[![Node CI](https://github.com/iwatakeshi/gitly/workflows/Node%20CI/badge.svg)](https://github.com/iwatakeshi/gitly/actions?query=workflow%3A%22Node+CI%22)
[![Version](https://img.shields.io/npm/v/gitly.svg)](https://www.npmjs.com/package/gitly)
[![codecov](https://codecov.io/gh/iwatakeshi/gitly/branch/master/graph/badge.svg)](https://codecov.io/gh/iwatakeshi/gitly)
[![Downloads/week](https://img.shields.io/npm/dw/gitly.svg)](https://www.npmjs.com/package/gitly)
[![License](https://img.shields.io/github/license/iwatakeshi/gitly)](https://github.com/iwatakeshi/gitly/blob/master/LICENSE.md)This project is the spiritual successor of [gittar](https://github.com/lukeed/gittar) written in TypeScript.
## Usage
Since v1.0+
```typescript
import { download, extract } from 'gitly'console.log(await download('iwatakeshi/gitly'))
// -> ~/.gitly/github/iwatakeshi/gitly/master.tar.gzconsole.log(await download('iwatakeshi/gitly#v1.0.0'))
// -> ~/.gitly/github/iwatakeshi/gitly/v1.0.0.tar.gzconsole.log(await download('https://github.com/iwatakeshi/gitly'))
// -> ~/.gitly/github/iwatakeshi/gitly/master.tar.gzconsole.log(await download('gitlab:Rich-Harris/buble#v0.15.2'))
// -> ~/.gitly/gitlab/Rich-Harris/buble/v0.15.2.tar.gzconsole.log(await download('Rich-Harris/buble', { host: 'gitlab' }))
// -> ~/.gitly/gitlab/Rich-Harris/buble/master.tar.gzconst source = 'path to downloaded zip file (can be obtained by download())'
const destination = '/path/to/foobar'await extract(source, destination)
// -> /path/to/foobar
```Since v2.0+
```typescript
import gitly from 'gitly'console.log(await gitly('iwatakeshi/gitly', '/path/to/extracted/folder/'))
// -> ['~/.gitly/github/iwatakeshi/gitly/master.tar.gz', '/path/to/extracted/folder/']
```## Options
````typescript
interface GitlyOptions {
/**
* Use cache only (default: undefined)
*/
cache?: boolean
/**
* Use both cache and local (default: undefined)
*/
force?: boolean
/**
* Throw an error when downloading (default: undefined)
*/
throw?: boolean
/**
* Set cache directory (default: '~/.gitly')
*/
temp?: string
/**
* Set the host name (default: undefined)
*/
host?: string
url?: {
/**
* Extend the url filtering method
* @param info The URLInfo object
*/
filter?(info: URLInfo): string
}
extract?: {
/**
* Extend the extract filtering method for the 'tar' library
*/
filter?(path: string, stat: FileStat): boolean
}
/**
* Set the request headers (default: undefined)
*/
headers?: RawAxiosRequestHeaders | AxiosHeaders
/**
* Set the backend (default: undefined)
*
* @example
* ```markdown
* 'axios' - default behavior
* 'git' - use local git installation to clone the repository (allows for cloning private
* repositories as long as the local git installation has access)
* ```
*/
backend?: 'axios' | 'git'
/**
* Set the git options (default: undefined)
*/
git?: {
/**
* Set the depth of the clone (default: 1)
*/
depth?: number
}
}
````## Interfaces
```typescript
interface URLInfo {
protocol: string
host: string
hostname: string
hash: string
href: string
path: string
repository: string
owner: string
type: string
}
```