@nodesecure/gitlab

Download and extract gitlab repository

Usage no npm install needed!

<script type="module">
  import nodesecureGitlab from 'https://cdn.skypack.dev/@nodesecure/gitlab';
</script>

README

Gitlab

version Maintenance MIT size known vulnerabilities build

Download and (optionaly) extract gitlab repository archive.

Requirements

Getting Started

This package is available in the Node Package Repository and can be easily installed with npm or yarn.

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

Usage example

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

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

API

export 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;
}

export type ExtractOptions = DownloadOptions & {
  /**
   * Remove the tar.gz archive after a succesfull extraction
   *
   * @default true
   */
  removeArchive?: boolean;
}

export 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;
}

export function download(repo: string, options?: DownloadOptions): Promise<DownloadResult>;
export function downloadAndExtract(repo: string, options?: ExtractOptions): Promise<DownloadResult>;
export function setToken(gitlabToken: string): void;
export function setUrl(gitlabUrl: string | URL): void;

Private repositories

To work with private repositories you can either setup a GITLAB_TOKEN system variable or use setToken method:

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

gitlab.setToken("...");

Custom gitlab URL

To work with a custom gitlab instance you can either setup a GITLAB_URL system variable or use setUrl method:

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

gitlab.setUrl("...");

Contributors ✨

All Contributors

Thanks goes to these wonderful people (emoji key):


Gentilhomme

💻 📖 👀 🛡️ 🐛

License

MIT