npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@dking/dgit

v0.0.12

Published

@dking/hasaki-cli init application

Downloads

14

Readme

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 Git repository author name
      • --repo-name Git repo name
      • --ref Git repo branch,commit hash or tagname
      • --relative-path Specifies the relative location of the directory or file that git needs to download. default: '.'
      • -d, --dest Specify the file output directory, either absolute path or relative path of the current terminal execution path
      • -l, --parallel-limit, Specify the number of concurrent downloads,default: 10.
      • -u, --username, Specify git account name, configuration parameters required when downloading private repo.
      • -p --password, Specify the git account password, which is used with username, and the configuration parameters required when downloading the private repo.
      • -t --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