🎩 You're Invited:Meet the Socket team at Black Hat in Las Vegas, August 3-6.RSVP
Sign In

github-repositories

Package Overview
Dependencies
Maintainers
2
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github-repositories - npm Package Compare versions

Comparing version
3.0.0
to
3.1.0
+19
-17
cli.js

@@ -5,3 +5,3 @@ #!/usr/bin/env node

const meow = require('meow');
const githubRepos = require('./');
const githubRepos = require('.');

@@ -14,7 +14,7 @@ const cli = meow(`

Options
-f, --forks Only list forks
-r, --repos Only display repository names
-s, --sources Only list sources
-t, --token GitHub authentication token
-u, --urls Only display URL
-f, --forks Only list forks
-r, --repos Only display repository names
-s, --sources Only list sources
-t, --token GitHub authentication token
-u, --urls Only display URL
`, {

@@ -31,2 +31,3 @@ boolean: [

alias: {
h: 'help',
f: 'forks',

@@ -36,3 +37,4 @@ r: 'repos',

t: 'token',
u: 'urls'
u: 'urls',
v: 'version'
}

@@ -46,18 +48,18 @@ });

githubRepos(cli.input[0], cli.flags).then(data => {
data.forEach(x => {
if (cli.flags.forks && !x.fork) {
githubRepos(cli.input[0], cli.flags).then(repositories => {
for (const repository of repositories) {
if (cli.flags.forks && !repository.fork) {
return;
}
if (cli.flags.sources && x.fork) {
if (cli.flags.sources && repository.fork) {
return;
}
if (!cli.flags.forks && !cli.flags.sources && x.fork) {
x.name += chalk.dim(' (fork)');
if (!cli.flags.forks && !cli.flags.sources && repository.fork) {
repository.name += chalk.dim(' (fork)');
}
if (cli.flags.repos) {
console.log(x.name);
console.log(repository.name);
return;

@@ -67,8 +69,8 @@ }

if (cli.flags.urls) {
console.log(x.html_url);
console.log(repository.html_url);
return;
}
console.log(`${x.name} ${chalk.dim(x.html_url)}`);
});
console.log(`${repository.name} ${chalk.dim(repository.html_url)}`);
}
});
+21
-16
'use strict';
const ghGot = require('gh-got');
const isGithubUserOrOrg = require('is-github-user-or-org');
module.exports = (user, opts) => {
opts = opts || {};
module.exports = (name, options) => {
options = options || {};
let page = 1;
let ret = [];
let returnValue = [];
if (typeof user !== 'string') {
return Promise.reject(new TypeError('Expected a string'));
if (typeof name !== 'string') {
return Promise.reject(new TypeError(`Expected \`name\` to be of type \`string\` but received type \`${typeof name}\``));
}
return (function loop() {
const url = `users/${user}/repos?&per_page=100&page=${page}`;
return isGithubUserOrOrg(name, options).then(userType => {
const type = (userType === 'User') ? 'users' : 'orgs';
return ghGot(url, opts).then(res => {
ret = ret.concat(res.body);
return (function loop() {
const url = `${type}/${name}/repos?&per_page=100&page=${page}`;
if (res.headers.link && res.headers.link.indexOf('next') !== -1) {
page++;
return loop();
}
return ghGot(url, options).then(response => {
returnValue = returnValue.concat(response.body);
return ret;
});
})();
if (response.headers.link && response.headers.link.includes('next')) {
page++;
return loop();
}
return returnValue;
});
})();
});
};
{
"name": "github-repositories",
"version": "3.0.0",
"description": "Get all Github repos from a user",
"license": "MIT",
"repository": "kevva/github-repositories",
"author": {
"name": "Kevin Mårtensson",
"email": "kevinmartensson@gmail.com",
"url": "github.com/kevva"
},
"engines": {
"node": ">=4"
},
"bin": "cli.js",
"scripts": {
"test": "xo && ava"
},
"files": [
"index.js",
"cli.js"
],
"keywords": [
"cli-app",
"cli",
"api",
"github",
"repo",
"repositories"
],
"dependencies": {
"chalk": "^1.0.0",
"gh-got": "^3.0.0",
"meow": "^3.3.0"
},
"devDependencies": {
"ava": "*",
"xo": "*"
},
"xo": {
"esnext": true
}
"name": "github-repositories",
"version": "3.1.0",
"description": "Get all Github repos from a user or an organization",
"license": "MIT",
"repository": "kevva/github-repositories",
"author": {
"name": "Kevin Mårtensson",
"email": "kevinmartensson@gmail.com",
"url": "github.com/kevva"
},
"bin": "cli.js",
"engines": {
"node": ">=4"
},
"scripts": {
"test": "xo && ava"
},
"files": [
"index.js",
"cli.js"
],
"keywords": [
"cli-app",
"cli",
"api",
"github",
"repo",
"repositories"
],
"dependencies": {
"chalk": "^1.0.0",
"gh-got": "^3.0.0",
"is-github-user-or-org": "^1.0.0",
"meow": "^3.3.0"
},
"devDependencies": {
"ava": "^0.25.0",
"xo": "^0.20.3"
}
}
+27
-22
# github-repositories [![Build Status](https://travis-ci.org/kevva/github-repositories.svg?branch=master)](https://travis-ci.org/kevva/github-repositories)
> Get all GitHub repos from a user
> Get all GitHub repos from a user or an organization

@@ -9,3 +9,3 @@

```
$ npm install --save github-repositories
$ npm install github-repositories
```

@@ -17,8 +17,8 @@

```js
const githubRepos = require('github-repositories');
const githubRepositories = require('github-repositories');
githubRepos('kevva').then(data => {
console.log(data);
//=> [{id: 29258368, name: 'animal-sounds', full_name: 'kevva/animal-sounds', ...}, ...]
});
(async () => {
console.log(await githubRepositories('kevva'));
//=> [{id: 29258368, name: 'animal-sounds', full_name: 'kevva/animal-sounds', …}, …]
})();
```

@@ -29,15 +29,16 @@

### githubRepos(user, [options])
### githubRepositories(name, options?)
Returns a promise for an array with the the repositories.
Returns a `Promise<object[]>` with the the repositories.
#### user
#### name
*Required*
Type: `string`
Username to fetch repos from.
Username or organization to fetch repos from.
#### options
Type: `object`
##### token

@@ -53,3 +54,12 @@

##### endpoint
Type: `string`<br>
Default: `https://api.github.com/`
To support [GitHub Enterprise](https://enterprise.github.com/).
Can be set globally with the `GITHUB_ENDPOINT` environment variable.
## CLI

@@ -69,12 +79,7 @@

Options
-f, --forks Only list forks
-r, --repos Only display repository names
-s, --sources Only list sources
-t, --token GitHub authentication token
-u, --urls Only display URLs
-f, --forks Only list forks
-r, --repos Only display repository names
-s, --sources Only list sources
-t, --token GitHub authentication token
-u, --urls Only display URLs
```
## License
MIT © [Kevin Mårtensson](https://github.com/kevva)

Sorry, the diff of this file is not supported yet