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

gitman

v2.6.0

Published

A simple yet powerful opinionated tool for managing GitHub repositories.

Downloads

30

Readme

GitMan

A simple yet powerful opinionated tool for managing GitHub repositories.

Features

  • Simple: There's almost nothing to configure and very few commands are provided.
  • Powerful: It allows you to clone in bulk repositories easily and execute commands on them.
  • Tiny: The entire thing is ~40kb min+gzipped, and only dependencies I personally maintain are used.
  • Beautiful: All of its power derives from being opinioned about the folder structure where repositories are cloned.

Install

npm install -g gitman

Configuration

There are only two, optional, pieces of configuration:

  • GitHub token: a GitHub personal access token, possibly with the repo scope enabled, can be provided to avoid rate limits and being able to manage private repositories too. You can set a token by using either the GITMAN_GITHUB_TOKEN or GITHUB_TOKEN environment variables, or with the --github-token option.
  • Root path: the folder path where repositories are cloned. By default the first folder found matching the following is used ~/{GitHub,github,Git,git,Repositories,repositories,Repos,repos,Code,code,Projects,projects,Developer,developer,Dev,dev}, otherwise ~/Code is used. You can set a custom root path via the GITMAN_ROOT environment variable, or with the --root option.

The only other thing to remember is that repositories are saved according to the following schema: $ROOT/username/reponame, if you want GitMan to recognize manually-created repositories too you must follow that convention.

Usage

The following interface is provided:

gitman 2.0.0

USAGE

  gitman [command]

OPTIONS

  --help                  Display help for the command
  --version, -v           Display the version number
  --github-token <token>  GitHub personal access token
  --root <path>           The folder path where repositories are cloned

COMMANDS

  help [command]        Display help for the command
  backup <users...>     Backup all repositories of the provided users
  cd <repository>       CD into a local repository
  clone <repository>    Clone a remote repository
  ls                    List all known repositories
  publish <repository>  Publish a local repository to GitHub
  sh <command>          Execute a shell command in all known repositories
  sync <repository>     Synchronize all known repositories with GitHub (fetch, description, keywords)
  whoami                Output the user associated with the provided GitHub token, if any

The following filtering options are available for most commands:

--no-archived         Ignore archived repositories
--no-clean            Ignore clean repositories
--no-dirty            Ignore dirty repositories
--no-forks            Ignore forked repositories
--no-private          Ignore private repositories
--no-public           Ignore public repositories
--exclude, -e <glob>  Exclude repositories matching this glob
--include, -i <glob>  Include only repositories matching this glob

Examples

Clone a single repository:

gitman clone fabiospampinato/gitman

Clone all repositories from a user/org:

gitman clone 'fabiospampinato/*'

Clone all non-archived and non-forks repositories from a user/org:

gitman clone --no-archived --no-forks 'fabiospampinato/*'

Clone all my vscode-related repositories:

gitman clone -i '**/vscode-*' 'fabiospampinato/*'

CD into a repository (actually this spawn a sub-shell, which you can exit from to go back):

gitman cd fabiospampinato/gitman

List all locally cloned repositories, this provides some useful information about the dirty status and number of commits ahead/behind origin:

gitman ls

List all locally cloned repositories that have uncommitted changes:

gitman --no-clean

List all locally cloned repositories that don't have uncommitted changes:

gitman --no-dirty

List all locally cloned repositories as JSON, useful for third-party tools integrations:

gitman ls --json

List minimal data about all locally cloned repositories as JSON, this is much quicker but omits git-specific data:

gitman ls --json --minimal

List all remote repositories available on GitHub for a user/org:

gitman ls --user fabiospampinato

List all non-archived and non-forks repositories for a user/org:

gitman ls --no-archived --no-forks --user fabiospampinato

Execute a command on all locally cloned repositories:

gitman sh 'cat package.json | grep typescript'

Execute a command on a subset of locally cloned repositories:

gitman sh -i '**/vscode-*' 'git fetch && echo "Something"'

Execute a command and get the output as JSON:

gitman sh 'cat package.json | grep typescript' --json

Execute a command, listing the unpacked size of NPM dependencies, and get a sorted output:

gitman sh 'npm view --json | jq .dist.unpackedSize' --sort

Publish a repository:

gitman publish fabiospampinato/gitman

Publish all my vscode-related repositories:

gitman publish -i '**/vscode-*' 'fabiospampinato/*'

Sync a repository:

gitman sync fabiospampinato/gitman

Sync all repositories for a user/org:

gitman sync 'fabiospampinato/*'

Get the user handle associated with the provided GitHub token:

gitman whoami

Tips

  • The exclude and include globs are matched against the full repository identifier (e.g. username/reponame), therefor most of the times your glob should probably look something like this: **/foo-*.
  • GitMan will generally output nothing (except in --json mode) if there are no targeted repositories for your command (i.e. user with no repositories, no locally cloned repositories, using filters that exclude everything etc.).
  • GitMan works with any kind of git repository, but it's especially suited for NPM packages, since it's able to extract a description, keywords, and private status from them.

Related

  • GitMan for VSCode: The official companion extension for vscode, for switching to repositories quickly.
  • Projects+: A VSCode extension I wrote for switching quickly between projects, it requires some manual configuration though.

License

MIT © Fabio Spampinato