Download and extract gitlab repository
npm install @nodesecure/gitlab
Download and (optionaly) extract GitLab repository archive.
- Node.js v20 or higher
This package is available in the Node Package Repository and can be easily installed with npm or yarn.
``bash`
$ npm i @nodesecure/gitlabor
$ yarn add @nodesecure/gitlab
`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);
`
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;
}
`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;
}
`ts``
interface DownloadExtractOptions extends DownloadOptions {
/**
* Remove the tar.gz archive after a succesfull extraction
*
* @default true
*/
removeArchive?: boolean;
}
MIT