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-star

v5.0.2

Published

Star, unstar, or check if you starred a repository or the repositories associated with NPM, Bower, or Meteor package file dependencies on GitHub

Downloads

37

Readme

github-star

Star, unstar, or check if you starred a repository or the repositories associated with NPM, Bower, or Meteor package file dependencies on GitHub

CLI

Installation

npm i -g github-star

Usage

githubstar [options]

-h, --help            output usage information
-V, --version         output the version number
-s, --repostar        star a GitHub repository
-u, --repounstar      unstar a GitHub repository
-i, --repoisstarred   check if a GitHub repository is starred
-S, --depsstar        star dependencies in an NPM, Bower, or Meteor package file on GitHub
-U, --depsunstar      unstar dependencies in an NPM, Bower, or Meteor package file on GitHub
-A, --depsarestarred  check if dependencies in an NPM, Bower, or Meteor package file are starred on GitHub
-d, --skipdeps        skip dependencies (has no effect when --package is supplied, or when --depspath is supplied and it is a Meteor package file)
-D, --skipdevdeps     skip devDependencies (has no effect when --package is supplied, or when --depspath is supplied and it is a Meteor package file)
-z, --skipself        skip repos belonging to --username (or the GITHUB_USERNAME environment variable) when supplying --depsstar, --depsunstar, or --depsarestarred
-x, --skipauthor <x>  an author to skip when supplying --depsstar, --depsunstar, or --depsarestarred (repeatable)
-X, --skiprepo <X>    a repo to skip when supplying --depsstar, --depsunstar, or --depsarestarred (repeatable)
-P, --package <P>     an NPM, Bower, or Atmosphere dependency (repeatable; must be supplied when not using --depspath)
-n, --username <n>    a GitHub username (may be ommitted if the GITHUB_USERNAME environment variable is set)
-t, --token <t>       a GitHub personal access token or password belonging to --username (may be ommitted if GITHUB_TOKEN environment variable is set)
-p, --password <p>    a GitHub password or personal access token belonging to --username (may be ommitted if GITHUB_TOKEN environment variable is set)
-a, --author <a>      a GitHub author (must be supplied when providing --repostar, --repounstar, or --repoisstarred)
-r, --repo <r>        a repository belonging to --author (must be supplied when providing --repostar, --repounstar, or --repoisstarred)
-j, --depspath <j>    a path to an NPM, Bower, or Meteor package file (must be supplied when not providing --package)
-T, --type <T>        the package manager associated with --depspath or --package: NPM, Bower, or Atmosphere (case-insensitive; must be supplied for NPM or Bower dependencies when providing --package; must be supplied for Bower dependencies when providing --depspath, unless the file name is "bower.json")

Examples

Manually supply a username / password and star a single repo:

githubstar -u user -p password -s -a sindresorhus -r package-json

Authenticate using environment variables and star all of the dependencies in a package.json file, skipping repositories that belong to the specified author:

githubstar --depsstar --depspath package.json --skipauthor npm

Authenticate using environment variables and check if multiple Bower packages are starred:

githubstar --depsarestarred -P angular -P angular-material -T bower

API

gitHubStar.repository methods are supported in RequireJS, CommonJS, and global environments. gitHubStar.dependencies methods are only supported in CommonJS environments.

GitHubStar(username, tokenOrPassword)

Instantiate github-star

  • string [username] - A GitHub username (may be omitted if the GITHUB_USERNAME environment variable is set)
  • string [tokenOrPassword] - A GitHub personal access token (recommended) or password belonging to username (may be omitted if the GITHUB_TOKEN environment variable is set)

Example (CommonJS)

var GitHubStar = require('github-star'),
    gitHubStar = GitHubStar('username', 'token');

gitHubStar.repository.star(author, repo, cb)

Star a GitHub repository

  • string author - A GitHub author
  • string repo - A repository belonging to author
  • function(null | object err) cb - A function to be executed after the repository is starred

Example

gitHubStar.repository.star('mjhasbach', 'github-star', function(err){
    if (err) { console.error(err); }
});

gitHubStar.repository.unstar(author, repo, cb)

Unstar a GitHub repository

  • string author - A GitHub author
  • string repo - A repository belonging to author
  • function(null | object err) cb - A function to be executed after the repository is unstarred

Example

gitHubStar.repository.unstar('lodash', 'lodash', function(err){
    if (err) { console.error(err); }
});

gitHubStar.repository.isStarred(author, repo, cb)

Check if a GitHub repository is starred

  • string author - A GitHub author
  • string repo - A repository belonging to author
  • function(null | object err, boolean isStarred) cb - A function to be executed after the repository is checked

Example

gitHubStar.repository.isStarred('gulpjs', 'gulp', function(err, isStarred){
    if (err) { console.error(err); }
    
    console.log(isStarred);
});

gitHubStar.dependencies.star(opt, cb)

Star dependencies in an NPM, Bower, or Meteor package file on GitHub.

  • object opt - An options object
    • string [depsPath] - A path to an NPM, Bower, or Meteor package file. Must be supplied if depsList is not supplied.
    • array{string} [depsList] - An array containing NPM, Bower, or Meteor package names. Must be supplied if depsPath is not supplied.
    • boolean [dependencies] - If false, dependencies will not be starred. Has no effect when depsList is supplied, or when depsPath is supplied and it is a Meteor package file.
    • boolean [devDependencies] - If false, devDependencies will not be starred. Has no effect when depsList is supplied, or when depsPath is supplied and it is a Meteor package file.
    • string [type] - The package manager associated with depsPath or depsList: "NPM", "Bower", or "Atmosphere" (case-insensitive). Must be supplied for NPM or Bower dependencies when providing depsList. Must be supplied for Bower dependencies when providing depsPath, unless the file name is "bower.json".
    • boolean [skipSelf] - Skip repos belonging to username if true
    • array{string} [skippedAuthors] - Authors to skip
    • array{string} [skippedRepos] - Repos to skip
  • function(null | object err, object{boolean} wereStarred) cb - A function to be executed after the dependencies are starred. Errors for individual dependencies (e.g. not found on package manager) will be Error objects in the wereStarred object.

Example

// Using depsPath
gitHubStar.dependencies.star({
    depsPath: './some_file.json',
    dependencies: true,
    devDependencies: false,
    type: "Bower",
    skipSelf: true,
    skippedAuthors: ['angular', 'jquery'],
    skippedRepos: ['lodash', 'backbone']
}, function(err, wereStarred){
    if (err) {
        console.error(err);
    }

    _.each(wereStarred, function(wasStarred, dependency) {
        if (wasStarred instanceof Error) {
            console.error(wasStarred);
            return;
        }
        
        console.log(dependency + ' was ' + (wasStarred ? '' : 'not ') + 'starred');
    });
});

// Using depsList
gitHubStar.dependencies.star({
    depsList: [
        'flemay:less-autoprefixer',
        'stevezhu:lodash',
        'suxez:jquery-serialize-object'
    ],
    type: "Atmosphere",
    skippedAuthors: ['flemay'],
    skippedRepos: ['lodash']
}, function(err, wereStarred){
    if (err) {
        console.error(err);
    }

    _.each(wereStarred, function(wasStarred, dependency) {
        if (wasStarred instanceof Error) {
            console.error(wasStarred);
            return;
        }
        
        console.log(dependency + ' was ' + (wasStarred ? '' : 'not ') + 'starred');
    });
});

gitHubStar.dependencies.unstar(opt, cb)

Unstar dependencies in an NPM, Bower, or Meteor package file on GitHub.

  • object opt - An options object
    • string [depsPath] - A path to an NPM, Bower, or Meteor package file. Must be supplied if depsList is not supplied.
    • array{string} [depsList] - An array containing NPM, Bower, or Meteor package names. Must be supplied if depsPath is not supplied.
    • boolean [dependencies] - If false, dependencies will not be unstarred. Has no effect when depsList is supplied, or when depsPath is supplied and it is a Meteor package file.
    • boolean [devDependencies] - If false, devDependencies will not be unstarred. Has no effect when depsList is supplied, or when depsPath is supplied and it is a Meteor package file.
    • string [type] - The package manager associated with depsPath or depsList: "NPM", "Bower", or "Atmosphere" (case-insensitive). Must be supplied for NPM or Bower dependencies when providing depsList. Must be supplied for Bower dependencies when providing depsPath, unless the file name is "bower.json".
    • boolean [skipSelf] - Skip repos belonging to username if true
    • array{string} [skippedAuthors] - Authors to skip
    • array{string} [skippedRepos] - Repos to skip
  • function(null | object err, object{boolean} wereUnstarred) cb - A function to be executed after the dependencies are unstarred. Errors for individual dependencies (e.g. not found on package manager) will be Error objects in the wereUnstarred object.

Example

// Using depsPath

gitHubStar.dependencies.unstar({
    depsPath: './some_file.json',
    dependencies: true,
    devDependencies: false,
    type: "Bower",
    skipSelf: true,
    skippedAuthors: ['angular', 'jquery'],
    skippedRepos: ['lodash', 'backbone']
}, function(err, wereUnstarred){
    if (err) {
        console.error(err);
    }

    _.each(wereUnstarred, function(wasUnstarred, dependency) {
        if (wasUnstarred instanceof Error) {
            console.error(wasUnstarred);
            return;
        }
        
        console.log(dependency + ' was ' + (wasUnstarred ? '' : 'not ') + 'unstarred');
    });
});

// Using depsList
gitHubStar.dependencies.unstar({
    depsList: [
        'flemay:less-autoprefixer',
        'stevezhu:lodash',
        'suxez:jquery-serialize-object'
    ],
    type: "Atmosphere",
    skippedAuthors: ['flemay'],
    skippedRepos: ['lodash']
}, function(err, wereUnstarred){
    if (err) {
        console.error(err);
    }

    _.each(wereUnstarred, function(wasUnstarred, dependency) {
        if (wasUnstarred instanceof Error) {
            console.error(wasUnstarred);
            return;
        }
        
        console.log(dependency + ' was ' + (wasUnstarred ? '' : 'not ') + 'unstarred');
    });
});

gitHubStar.dependencies.areStarred(opt, cb)

Check if dependencies in an NPM, Bower, or Meteor package file are starred on GitHub.

  • object opt - An options object
    • string [depsPath] - A path to an NPM, Bower, or Meteor package file. Must be supplied if depsList is not supplied.
    • array{string} [depsList] - An array containing NPM, Bower, or Meteor package names. Must be supplied if depsPath is not supplied.
    • boolean [dependencies] - If false, dependencies will not be checked. Has no effect when depsList is supplied, or when depsPath is supplied and it is a Meteor package file.
    • boolean [devDependencies] - If false, devDependencies will not be checked. Has no effect when depsList is supplied, or when depsPath is supplied and it is a Meteor package file.
    • string [type] - The package manager associated with depsPath or depsList: "NPM", "Bower", or "Atmosphere" (case-insensitive). Must be supplied for NPM or Bower dependencies when providing depsList. Must be supplied for Bower dependencies when providing depsPath, unless the file name is "bower.json".
    • boolean [skipSelf] - Skip repos belonging to username if true
    • array{string} [skippedAuthors] - Authors to skip
    • array{string} [skippedRepos] - Repos to skip
  • function(null | object err, object{boolean} areStarred) cb - A function to be executed after the dependencies are checked. Errors for individual dependencies (e.g. not found on package manager) will be Error objects in the areStarred object.

Example

// Using depsPath
gitHubStar.dependencies.areStarred({
    depsPath: './some_file.json',
    dependencies: true,
    devDependencies: false,
    type: "Bower",
    skipSelf: true,
    skippedAuthors: ['angular', 'jquery'],
    skippedRepos: ['lodash', 'backbone']
}, function(err, areStarred){
    if (err) {
        console.error(err);
    }

    _.each(areStarred, function(isStarred, dependency) {
        if (isStarred instanceof Error) {
            console.error(isStarred);
            return;
        }
        
        console.log(dependency + ' is ' + (isStarred ? '' : 'not ') + 'starred');
    });
});

// Using depsList
gitHubStar.dependencies.areStarred({
    depsList: [
        'flemay:less-autoprefixer',
        'stevezhu:lodash',
        'suxez:jquery-serialize-object'
    ],
    type: "Atmosphere",
    skippedAuthors: ['flemay'],
    skippedRepos: ['lodash']
}, function(err, areStarred){
    if (err) {
        console.error(err);
    }

    _.each(areStarred, function(isStarred, dependency) {
        if (isStarred instanceof Error) {
            console.error(isStarred);
            return;
        }
        
        console.log(dependency + ' is ' + (isStarred ? '' : 'not ') + 'starred');
    });
});

Installation

Npm

npm i github-star

Bower

bower i github-star

Testing

npm test