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

glitter

v3.1.1

Published

git abstraction

Downloads

25

Readme

glitter

NPM version Build status Test coverage Dependency Status License Downloads Gittip

A utility to interact with remote repositories seamlessly. Supports fetching remotes, getting references/tags/branches from either the remote or the local copy, and copying files.

Adding Custom Remotes

By default, this library supports GitHub and BitBucket git remotes. Adding remotes is pretty trivial since all it really needs is a URL.

First you need to create a custom remote object. View lib/remotes/github.js for an example. All it needs is a .name and a .url( user, repo => URL) function.

Then you need to set this remote to glitter.remotes[name]=. See lib/remotes/index.js. For example:

var local = {
  name: 'local',
  url: function (user, repo) {
    // ignores the `user` field,
    // though you could optionally just use the `user` field
    // as the repo.
    return 'https://localhost:8080/' + repo;
  }
};

Glitter.remotes.local =
Glitter.remotes.someAlias = local;

var glitter = Glitter('local', null, 'module');

And you're set!

API

Glitter.folder

Where the repositories are cloned to.

var glitter = new Glitter(remote, user, repo)

Create a new instance. Currently supported remotes are:

  • github - set your optional GitHub credentials as the GLITTER_GITHUB environmental variable

glitter.install().then( => )

git clone

Clone the remote repository locally. Does not check whether the repository has already been cloned.

glitter.isInstall().then( !!installed => )

Checks whether a repository is installed.

glitter.update().then( !!updated => )

git fetch -f --all

Update all the branches and references of the local copy. updated is whether any references were updated.

glitter.show(reference, remote).then( hash'' => )

git show

Lookup a commit sha from a reference. If remote is true, will .update() from the origin if no references are found. This requires a local copy of the repository to be installed.

glitter.copy(reference, folder).then( => )

git archive <reference> | tar -x -C <folder>

Copy the repository at reference to folder. Requires a local copy.

glitter.getReferences(remote).then( [refs] => )

git ls-remote and git show-ref

Gets all HEAD and tag references, References is an array of references of the form [<name>, <commit sha>]. If remote is true, gets the references directly from the remote.

glitter.getHeads(remote).then( [refs] => )

.getReferences(remote), but only HEAD references are returned.

glitter.getTags(remote).then( [refs] => )

.getReferences(remote), but only tags are returned.

glitter.getVersions(remote).then( [versions] => )

.getTags(remote), except only valid semantic versions are returned. It returns an array of [<tag>, <sha>].

glitter.getMaxSatisfying(range, remote).then( version => )

Same like .getVersions(), but you pass a semver range, and it will return the max satisfying range. It returns a single [<tag>, <sha>] unless null.