Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/nodesecure/gitlab

Download and extract gitlab repository
https://github.com/nodesecure/gitlab

archive download extract extractor git gitlab targz targz-extractor

Last synced: about 2 months ago
JSON representation

Download and extract gitlab repository

Awesome Lists containing this project

README

        

# Gitlab

![version](https://img.shields.io/badge/dynamic/json.svg?style=for-the-badge&url=https://raw.githubusercontent.com/NodeSecure/gitlab/master/package.json&query=$.version&label=Version)
[![Maintenance](https://img.shields.io/badge/Maintained%3F-yes-green.svg?style=for-the-badge)](https://github.com/NodeSecure/gitlab/graphs/commit-activity)
[![OpenSSF
Scorecard](https://api.securityscorecards.dev/projects/github.com/NodeSecure/gitlab/badge?style=for-the-badge)](https://api.securityscorecards.dev/projects/github.com/NodeSecure/gitlab)
![MIT](https://img.shields.io/github/license/NodeSecure/gitlab.svg?style=for-the-badge)
![build](https://img.shields.io/github/actions/workflow/status/NodeSecure/gitlab/node.js.yml?style=for-the-badge)

Download and (optionaly) extract gitlab repository archive.

## Requirements

- [Node.js](https://nodejs.org/en/) v18 or higher

## Getting Started

This package is available in the Node Package Repository and can be easily installed with [npm](https://docs.npmjs.com/getting-started/what-is-npm) or [yarn](https://yarnpkg.com).

```bash
$ npm i @nodesecure/gitlab
# or
$ yarn add @nodesecure/gitlab
```

## Usage example

```js
import * as gitlab from "@nodesecure/gitlab";

// Note: repository can be either namespace path or repository ID
const result = await gitlab.download(
"NodeSecure.utils"
);
console.log(result);
```

## API

Both `download` and `downloadAndExtract` functions use the same set of options.

```ts
interface DownloadOptions {
/**
* The destination (location) to extract the tar.gz
*
* @default process.cwd()
*/
dest?: string;
/**
* The default gitlab branch name (master, main ...).
* By default it fetch the "default" gitlab branch.
*
* @default null
*/
branch?: string | null;
/**
* Authentication token for private repositories
*
* @default process.env.GITLAB_TOKEN
*/
token?: string;
/**
* @default https://gitlab.com/api/v4/projects/
*/
gitlab?: string;
}
```

### download(repository: string, options?: DownloadOptions): Promise< DownloadResult >
Download the tar.gz archive of the GIT repository.

```ts
interface DownloadResult {
/** Archive or repository location on disk */
location: string;
/** Gitlab repository name */
repository: string;
/** Gitlab organization name */
organization: string;
/** Gitlab branch name */
branch: string;
}
```

### downloadAndExtract(repository: string, options?: DownloadExtractOptions): Promise< DownloadResult >
Use download but extract the tar.gz archive.

```ts
interface DownloadExtractOptions extends DownloadOptions {
/**
* Remove the tar.gz archive after a succesfull extraction
*
* @default true
*/
removeArchive?: boolean;
}
```

## Contributors ✨

[![All Contributors](https://img.shields.io/badge/all_contributors-5-orange.svg?style=flat-square)](#contributors-)

Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):



Gentilhomme
Gentilhomme

💻 📖 👀 🛡️ 🐛
Haze
Haze

💻
Alexandre Malaj
Alexandre Malaj

💻 📖
Kouadio Fabrice Nguessan
Kouadio Fabrice Nguessan

🚧
FredGuiou
FredGuiou

🚧

## License

MIT