@dking/dgit
@dking/hasaki-cli init application
Last updated 12 days ago by johnapache .
MIT · Original npm · Tarball · package.json
$ cnpm install @dking/dgit 
SYNC missed versions from official npm registry.

Dgit

Dgit is a portable tool for downloading the specified directory or file of GitHub Repo. It can be used as a command line for global installation on the terminal, or as a node module. This tool does not rely on the local git, can directly download the specified directory file, reduce the traffic consumption, and is very suitable for scenarios where you want to download large projects, and can directly download the content you need.

Install

  • Global Installation
$ npm install @dking/dgit -g
  • Local Installation
$ npm install @dking/dgit --save
$ yarn add @dking/dgit

Usage

  • Global installation, using as command line
$ dgit d https://github.com/JohnApache/hasaki-cli/tree/master/src -d ./abc
  • Local installation as module
import dgit from '@dking/dgit';

(async () => {
    await dgit(
        {
            owner: 'JohnApache',
            repoName: 'hasaki-cli',
            ref: 'master',
            relativePath: 'src',
        },
        './aaa',
    );
    console.log('download succeed');
})()

Configuration

  • Global installation, used as command line, configurable parameters

    • Commands:
      • download|d [options] [githubLink] Download the specified files of the specified repo or all files under the specified directory
    • Options:
      • --owner <ownerName> Git repository author name
      • --repo-name <repoName> Git repo name
      • --ref <refName> Git repo branch,commit hash or tagname
      • --relative-path <relativePath> Specifies the relative location of the directory or file that git needs to download. default: '.'
      • -d, --dest <destPath> Specify the file output directory, either absolute path or relative path of the current terminal execution path
      • -l, --parallel-limit, <number> Specify the number of concurrent downloads,default: 10.
      • -u, --username, <username> Specify git account name, configuration parameters required when downloading private repo.
      • -p --password, <password> Specify the git account password, which is used with username, and the configuration parameters required when downloading the private repo.
      • -t --token, <token> Git token is another configurable parameter of login mode, which is used to download private repo.
      • -e --exclude, <relativePath,...,relativePath> Specifies the collection of files or directory paths that need to be excluded for the current download directory.
      • -i --include, <relativePath,...,relativePath> Specifies the collection of files or directories that need to be included again in the currently excluded file path collection.
      • -h, --help Output usage information
  • Local installation, configurable parameters when used as a module

    import dgit from '@dking/dgit';
    import path from 'path';
    const repoOption = {
        owner: 'JohnApache'; // Git repository author name
        repoName: 'hasaki-cli'; // Git repo name
        ref: 'master'; // Git repo branch,commit hash or tagname,
        relativePath: '.'; // Specifies the relative location of the directory or file that git needs to download
        username: ''; // Specify git account name.
        password: ''; // Specify the git account password.
        token: ''; // Git token is another configurable parameter of login mode.
    }
    
    const githubLinkOption = {
        githubLink: 'https://github.com/JohnApache/hasaki-cli/blob/master/PLAN.txt',
        // You can also directly specify the download path address of gitHub
    }
    
    const destPath = path.resolve(__dirname, './aaa'); // Specify the file output directory
    
    const dgitOptions = {
        maxRetryCount: 3, // The maximum number of attempts to download again when the download fails due to network problems
        parallelLimit: 10, // Number of parallel downloads
        log: false, // Open internal log
        logSuffix: '', // Log output prefix
        exclude: [], // excluded paths,
        include: [], // include paths
    }
    
    const hooks = {
        onSuccess: () => void,
        onError: (err) => err,
        onProgress: (status, node) => void,
        onResolved: (status) => void,
    }
    
    
    (async () => {
        await dgit(
            repoOption,
            destPath,
            dgitOptions,
            hooks,
        );
        console.log('repoOption download succeed.');
    
        await dgit(
            githubLinkOption,
            destPath,
            dgitOptions,
            hooks,
        );
        console.log('githubLinkOption download succeed.');
    })()
    

TIPS

When downloading the private repo, you need to provide download permission. At this time, you need to pass in additional parameters in two ways

  • Basic authentication

    Download permission is provided by passing in user name and password. When passing in user name, password can not be provided explicitly. When password is not provided, password input option will appear password prompt;

    $ dgit d https://github.com/JohnApache/hasaki-cli/tree/master/src -d ./abc -u JohnApache
    
  • OAuth2 token

    Token is another way of authority authentication provided by GitHub.

    Set the token method, which is located in Github Settings -> Developer settings -> Personal access tokens

    $ dgit d https://github.com/JohnApache/hasaki-cli/tree/master/src -d ./abc -t OAUTH-TOKEN
    

Questions

Please open an issue here.

License

MIT

Current Tags

  • 0.0.11                                ...           latest (12 days ago)

11 Versions

  • 0.0.11                                ...           12 days ago
  • 0.0.10                                ...           4 months ago
  • 0.0.9                                ...           5 months ago
  • 0.0.8                                ...           6 months ago
  • 0.0.7                                ...           6 months ago
  • 0.0.6                                ...           7 months ago
  • 0.0.5                                ...           7 months ago
  • 0.0.4                                ...           7 months ago
  • 0.0.3                                ...           7 months ago
  • 0.0.2                                ...           7 months ago
  • 0.0.1                                ...           7 months ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 11
Last Month 21
Dependencies (13)
Dev Dependencies (18)
Dependents (2)

Copyright 2014 - 2016 © taobao.org |