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

remove-github-forks

v2.1.1

Published

Delete all forks that have no commits that are not in the main repository

Downloads

126

Readme

Clean your useless GitHub forks

npm npm Build Status

If you contribute to many projects on GitHub, your profile is full of temporary forks that are only useful while the pull request is open. After that there is no reason to keep the fork. This tool will delete all such forks. And if there’s any commits in the fork that have not yet been merged upstream, the fork will be kept, of course. For the extra peace of mind, the tool will ask you to confirm the forks it plans to delete.

GitHub now suggests to delete the fork after deleting a PR branch, so this software is now less necessary. Still, depending on your workflow, you may benefit from mass-pruning of forks.

Usage

To allow the library access to a GitHub account, one needs an OAuth token. Create a new token with permissions public_repo, delete_repo. (include repo as well if you want to allow access to private repositories), and pass it to the library.

Install

$ [sudo] npm install --global remove-github-forks

(Or run with Docker)

Run

$ remove-github-forks token
? Will delete: user/repo, user/repo2 <yes|no>: yes
Done!

Warning! Your shell will likely store your command history in a plain-text file such as .bash_history. As a quick workaround, consider adding a space in front of your command for it to not be stored:

$ <space>remove-github-forks token

If you want to do this often and are happy with saving the token in plain-text, add an alias to your .bashrc:

alias clean-github='remove-github-forks YOUR-TOKEN'

Options

  • --debug will output extended details in case of errors.
  • --user <userOrOrganization> will only clean repositories for the user or organization provided, without touching repositories for organizations you are in.
  • -y, --yes will not ask for confirmation before deleting repositories. Useful for cron jobs!

API

Main usage to delete useless forks:

var clean = require("remove-github-forks");
clean(token, function (err) {});
clean(
  token,
  {
    // If user is given, only forks belonging to this username
    // (or organization) will be deleted.
    user: "my-username",
  },
  function (err) {}
);

Advanced usage:

// Get a list of repositories that are useless
// repos is a list of {user, repo, url} objects
clean.get(token, {
  // Trigger when we can estimate the amount of work done
  // info has fields:
  //   countInspected: number of inspected forks
  //   lastInspected: name of last inspected fork, can be empty at the start
  //   totalToInspect: total count of forks to inspect
  progress: function(info){}

  // If user is given, only forks belonging to this username
  // (or organization) will be returned.
  user: 'my-username',

  // If something in the process goes a little bit wrong in a non-destructive
  // way, we will skip the problematic item and continue. Use this callback
  // to know about such cases.
  warnings: function(msg, err){}
}, function(err, repos){});

// Delete repositories
// repos is a list of {user, repo} objects
clean.remove(token, repos, function(err){});

Alternatives

I am not aware of many alternatives to this tool.

One is github-clean-forks by caub.

Credits

Thanks for everyone who has contributed, and in particular @fregante for reinvigorating a paused project.