Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zyj1022/git-get-repo
Download and extract a git repository (GitHub, GitLab, Bitbucket, Gitee) from node
https://github.com/zyj1022/git-get-repo
bitbucket git github gitlab
Last synced: 23 days ago
JSON representation
Download and extract a git repository (GitHub, GitLab, Bitbucket, Gitee) from node
- Host: GitHub
- URL: https://github.com/zyj1022/git-get-repo
- Owner: zyj1022
- License: mit
- Created: 2022-04-08T02:45:36.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-04-08T02:47:26.000Z (over 2 years ago)
- Last Synced: 2024-10-21T18:19:32.950Z (2 months ago)
- Topics: bitbucket, git, github, gitlab
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/git-get-repo
- Size: 27.3 KB
- Stars: 1
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# git-get-repo
- Download and extract a git repository (GitHub, GitLab, Bitbucket, Gitee) from node.
- [TSDX](https://tsdx.io/) development, add Gitee support
- Fork by [download-git-repo](https://gitlab.com/flippidippi/download-git-repo)## Installation
```
npm install git-get-repo
```## API
### download(repository, destination, options, callback)
Download a git `repository` to a `destination` folder with `options`, and `callback`.
#### repository
The shorthand repository string to download the repository from:- **GitHub** - `github:owner/name` or simply `owner/name`
- **GitLab** - `gitlab:owner/name`
- **Bitbucket** - `bitbucket:owner/name`
- **Gitee** - `gitee:owner/name`The `repository` parameter defaults to the `master` branch, but you can specify a branch or tag as a URL fragment like `owner/name#my-branch`.
In addition to specifying the type of where to download, you can also specify a custom origin like `gitlab:custom.com:owner/name`.
Custom origin will default to `https` or `git@` for http and clone downloads respectively, unless protocol is specified.
Feel free to submit an issue or pull request for additional origin options.In addition to having the shorthand for supported git hosts, you can also hit a repository directly with:
- **Direct** - `direct:url`
This will bypass the shorthand normalizer and pass `url` directly.
If using `direct` without clone, you must pass the full url to the zip file, including paths to branches if needed.
If using `direct` with clone, you must pass the full url to the git repo and you can specify a branch like `direct:url#my-branch`.#### destination
The file path to download the repository to.#### options
An optional options object parameter with download options. Options include:- `clone` - boolean default `false` - If true use `git clone` instead of an http download. While this can be a bit slower, it does allow private repositories to be used if the appropriate SSH keys are setup.
- All other options (`proxy`, `headers`, `filter`, etc.) will be passed down accordingly and may override defaults
- Additional download options: https://github.com/kevva/download#options
- Additional clone options: https://github.com/jaz303/git-clone#clonerepo-targetpath-options-cb#### callback
The callback function as `function (err)`.## Examples
### Shorthand
Using http download from Github repository at master.
```javascript
download('owner/git-get-repo-fixture', 'test/tmp', function (err) {
console.log(err ? 'Error' : 'Success')
})
```Using git clone from Bitbucket repository at my-branch.
```javascript
download('bitbucket:owner/git-get-repo-fixture#my-branch', 'test/tmp', { clone: true }, function (err) {
console.log(err ? 'Error' : 'Success')
})
```Using http download from GitLab repository with custom origin and token.
```javascript
download('gitlab:mygitlab.com:owner/git-get-repo-fixture#my-branch', 'test/tmp', { headers: { 'PRIVATE-TOKEN': '1234' } } function (err) {
console.log(err ? 'Error' : 'Success')
})
```Using git clone from GitLab repository with custom origin and protocol.
Note that the repository type (`github`, `gitlab` etc.) is not required if cloning from a custom origin.```javascript
download('https://mygitlab.com:owner/git-get-repo-fixture#my-branch', 'test/tmp', { clone: true }, function (err) {
console.log(err ? 'Error' : 'Success')
})
```Using git clone from Gitee repository with custom origin and protocol.
```javascript
download('https://gitee.com:owner/git-get-repo-fixture#my-branch', 'test/tmp', { clone: true }, function (err) {
console.log(err ? 'Error' : 'Success')
})
```
### DirectUsing http download from direct url.
```javascript
download('direct:https://gitlab.com/owner/git-get-repo-fixture/repository/archive.zip', 'test/tmp', function (err) {
console.log(err ? 'Error' : 'Success')
})
```Using git clone from direct url at master.
```javascript
download('direct:https://gitlab.com/owner/git-get-repo-fixture.git', 'test/tmp', { clone: true }, function (err) {
console.log(err ? 'Error' : 'Success')
})
```Using git clone from direct url at my-branch.
```javascript
download('direct:https://gitlab.com/owner/git-get-repo-fixture.git#my-branch', 'test/tmp', { clone: true }, function (err) {
console.log(err ? 'Error' : 'Success')
})
```## License
MIT