JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 3774949
  • Score
    100M100P100Q193163F
  • License MIT

Package Exports

  • giget

Readme

✨ giget

npm version npm downloads Github Actions Codecov

Easily download git repositories

Features

✔ Multi-provider support (GitHub, GitLab, and bitbucket)

✔ Super fast cloning using tarball gzip without depending on local git or tar commands.

✔ Works online and offline with fallback

✔ Support extracting with a subpath

Usage (CLI)

npx giget@latest <repo> [<dir>]

Arguments

  • repo: A URI describing provider, repository, subpath, and branch/ref. (format is [provider]:user/name[/path][#ref].)
  • dir: A relative or absolute path where to extract the repository. (if not provided, the name of the repo will be used as the directory name in the current working directory.)

Examples

# Clone the main branch of github.com/unjs/template to unjs-template directory
npx giget@latest unjs/template

# Clone to myProject directory
npx giget@latest unjs/template myProject

# Clone dev branch
npx giget@latest unjs/template#dev

# Clone /test directory from main branch
npx giget@latest unjs/template/test

# Clone from gitlab
npx giget@latest gitlab:unjs/template

# Clone from bitbucket
npx giget@latest butbucket:unjs/template

Usage (Programmatic)

Install package:

# npm
npm install giget

# yarn
yarn install giget

# pnpm
pnpm install giget

Import:

// ESM
import { downloadRepo } from 'giget'

// CommonJS
const { downloadRepo } = require('giget')

downloadRepo(source, dir, options?)

Example:

const { source, dir } = await downloadRepo('github:unjs/template')

Parameters:

  • source: (string) Input source in format of [provider]:user/name[/path][#ref].
  • dst: (string) Destination directory to clone to. If not provided, user-name will be used relative to the current directory.
  • options: (object) Options are usually inferred from the input string. You can customize them.
    • provider: (string) Either github, gitlab or bitbucket. The default is github.
    • repo: (string) Name of repository in format of {username}/{reponame}.
    • ref: (string) Git ref (branch or commit or tag). The default value is main.
    • subpathpath: (string) subpath of the repo to clone from. The default value is none.

Return value:

The return value is a promise that resolves to an object with the following properties:

  • dir: (string) Path to extracted dir.
  • source: (string) Normalized version of the input source. Useful for logging.

💻 Development

  • Clone this repository
  • Enable Corepack using corepack enable (use npm i -g corepack for Node.js < 16.10)
  • Install dependencies using pnpm install
  • Run interactive tests using pnpm dev

License

Made with 💛

Published under MIT License.