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
32
Maintainers
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 tousername
(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 toauthor
- 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 toauthor
- 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 toauthor
- function(null | object
err
, booleanisStarred
)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 ifdepsList
is not supplied. - array{string} [
depsList
] - An array containing NPM, Bower, or Meteor package names. Must be supplied ifdepsPath
is not supplied. - boolean [
dependencies
] - If false, dependencies will not be starred. Has no effect whendepsList
is supplied, or whendepsPath
is supplied and it is a Meteor package file. - boolean [
devDependencies
] - If false, devDependencies will not be starred. Has no effect whendepsList
is supplied, or whendepsPath
is supplied and it is a Meteor package file. - string [
type
] - The package manager associated withdepsPath
ordepsList
: "NPM", "Bower", or "Atmosphere" (case-insensitive). Must be supplied for NPM or Bower dependencies when providingdepsList
. Must be supplied for Bower dependencies when providingdepsPath
, unless the file name is "bower.json". - boolean [
skipSelf
] - Skip repos belonging tousername
if true - array{string} [
skippedAuthors
] - Authors to skip - array{string} [
skippedRepos
] - Repos to skip
- string [
- 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 beError
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 ifdepsList
is not supplied. - array{string} [
depsList
] - An array containing NPM, Bower, or Meteor package names. Must be supplied ifdepsPath
is not supplied. - boolean [
dependencies
] - If false, dependencies will not be unstarred. Has no effect whendepsList
is supplied, or whendepsPath
is supplied and it is a Meteor package file. - boolean [
devDependencies
] - If false, devDependencies will not be unstarred. Has no effect whendepsList
is supplied, or whendepsPath
is supplied and it is a Meteor package file. - string [
type
] - The package manager associated withdepsPath
ordepsList
: "NPM", "Bower", or "Atmosphere" (case-insensitive). Must be supplied for NPM or Bower dependencies when providingdepsList
. Must be supplied for Bower dependencies when providingdepsPath
, unless the file name is "bower.json". - boolean [
skipSelf
] - Skip repos belonging tousername
if true - array{string} [
skippedAuthors
] - Authors to skip - array{string} [
skippedRepos
] - Repos to skip
- string [
- 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 beError
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 ifdepsList
is not supplied. - array{string} [
depsList
] - An array containing NPM, Bower, or Meteor package names. Must be supplied ifdepsPath
is not supplied. - boolean [
dependencies
] - If false, dependencies will not be checked. Has no effect whendepsList
is supplied, or whendepsPath
is supplied and it is a Meteor package file. - boolean [
devDependencies
] - If false, devDependencies will not be checked. Has no effect whendepsList
is supplied, or whendepsPath
is supplied and it is a Meteor package file. - string [
type
] - The package manager associated withdepsPath
ordepsList
: "NPM", "Bower", or "Atmosphere" (case-insensitive). Must be supplied for NPM or Bower dependencies when providingdepsList
. Must be supplied for Bower dependencies when providingdepsPath
, unless the file name is "bower.json". - boolean [
skipSelf
] - Skip repos belonging tousername
if true - array{string} [
skippedAuthors
] - Authors to skip - array{string} [
skippedRepos
] - Repos to skip
- string [
- 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 beError
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