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

github-superclone

v1.1.2

Published

Clone all repositories from a GitHub organization

Downloads

5

Readme

github-superclone

npm version

Overview

Clones or pulls most or all of the repositories of a GitHub user or set of GitHub organizations. If authentication information is specified, private repositories are included.

Installation

npm install -g github-superclone

Usage

Command-line

Usage: superclone [options]

Options:

  -V, --version              output the version number
  -o, --orgs <orgs>          GitHub organizations
  -u, --user <user>          GitHub user name
  -p, --password <password>  GitHub password or token
  -2, --2fa <code>           two-factor authentication code
  -d, --dir <dir>            target directory (default: .)
  -i, --ignore-forks         ignored forked repositories
  -a, --archived             include archived repositories
  -f, --force-pull           pull repositories regardless of local mtime
  -n, --dry-run              don't actually run git
  -h, --help                 output usage information

API

This package can also be used as a library, which exports the following functions.

fetchRepos

Fetches all of the repositories for a given organization or user and calls the given asynchronous callback for each one.

function fetchRepos(
  kind: String, // 'org' or 'user'
  name: String,
  callback: function(repo, options): Promise<Void>,
  options: {
    user: String,
    password: String,
    otp: String,
    userAgent: String = path.basename(process.argv[1], '.js'),
    pageSize: Number = 100,
    hooks: {
      fetchingUrl: function(url: String): Void,
      fetchFailed: function(url: String, err: Error): Void
    } = {}
  } = {}
): Promise<Void>

cloneRepo

Clones or pulls the given repository.

function cloneRepo(
  repo: {
    name: String, // required
    fork: Boolean = false,
    archived: Boolean = false,
    pushed_at: Date,
    clone_url: String // required
  },
  options: {
    dir: String = '.',
    gitCommand: String = 'git',
    user: String,
    password: String,
    ignoreForks: Boolean = false,
    ignoreArchived: Boolean = false,
    forcePull: Boolean = false,
    touchPull: Boolean = false,
    dryRun: Boolean = false,
    shellOptions = {},
    hooks: {
      ignoreFork: function(repo, dirExists: Boolean): Void,
      ignoreArchived: function(repo, dirExists: Boolean): Void,
      skipUpToDate: function(repo): Void,
      runningCommand: function(repo, cmd: String, cwd: String): Void,
      pullSucceeded: function(repo): Void,
      cloneSucceeded: function(repo): Void,
      cloneFailed: function(repo): Void
    } = {}
  } = {}
): Promise<Void>

shell

Executes the given command in a subshell and returns the accumulated stdout/stderr strings. By default, stdout/stderr of the child process are piped to stdout/stderr of the parent process. See child_process.spawn for the definition of spawnOptions.

function shell(
  cmd: String,
  options: {
    spawnOptions = {},
    stdoutEncoding: String = 'utf8',
    stderrEncoding: String = 'utf8',
    stdoutWrite: function(s: String): Void = process.stdout.write.bind(process.stdout),
    stderrWrite: function(s: String): Void = process.stderr.write.bind(process.stderr)
  } = {}
): Promise<{
  stdout: String,
  stderr: String
}>

FAQ

Why would I want to do this?

You probably don't. I wanted to clone hundreds of repositories from an organization so I could perform static analysis.

Hasn't this been done before?

You wouldn't believe how many times. This is my version. There are many like it, but this one is mine.

Okay, so how is this one different?

If you insist, because it does/has all of these things:

  • Supports an unlimited number of repositories (using GitHub pagination)
  • Supports either a user or a set of organizations as repository owners
  • Clones or pulls, depending on whether the directory exists
  • Supports private repositories if authentication information is provided
  • Optionally ignores forks
  • Ignores archived repositories (or optionally includes them)
  • Compares GitHub pushed-at time with local timestamp to avoid unnecessary pulls
  • Optional dry-run mode to see what would be cloned
  • Pretty colors and progress messages in the output
  • Decent error handling
  • CLI and library
  • Readable modern JavaScript source code

I'm having trouble authenticating -- what should I do?

Create a personal access token with repo access and use that instead of a password and two-factor. If your organization uses Single Sign-on (SSO), be sure to click the little "SSO" button next to your newly created token to authorize it for access.

License

github-superclone is available under the ISC license.