Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
## Project Title
### Get Repos
This is a node app that facilitates cloning all of the repositories of a given user's account on Github.

## Motivation
After a clean installation of my OS, I wanted an expedited way to retrieve a local copy of all of my projects stored in Github repositories.

<!-- ## View Live -->
<!-- [tglisson.com](https://www.tglisson.com) -->

## Screenshots
<!-- ![Screenshot of Portfolio Site](https://raw.githubusercontent.com/TylerGlisson/portfolio3/master/img/Portfolio%20Screen.png) -->

## Tech/framework used
<!-- [React](https://github.com/facebook/react), [Create React App](https://github.com/facebook/create-react-app), Javascript, HTML, CSS -->
[Node](https://nodejs.org/), [Node-Fetch](https://www.npmjs.com/package/node-fetch), [Node's File System module](https://nodejs.org/api/fs.html), [Git-Clone](https://www.npmjs.com/package/git-clone), [Prompts](https://www.npmjs.com/package/prompts)

## License
MIT © Tyler Glisson
70 changes: 52 additions & 18 deletions getRepos.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,55 @@
// Simple app to clone all repositories belonging to a github user

// node-fetch library
const fetch = require('node-fetch');

// Accept github username
let user = 'TylerGlisson';


const repos = fetch(`https://api.github.com/users/${user}/repos`)
.then(response => response.json())
// .then(resJson => console.log(resJson))
.catch(err => {console.log('There was an error ', err)});

repos.then(resJson => console.log(resJson))

// Loop through response array and create a
// new array of just repositories


// Map through new array and translate
const fs = require('fs');
const clone = require('git-clone');
const prompts = require('prompts');

const prompter = async () => {
const response = await prompts([
{
type: 'text',
name: 'username',
message: 'Please enter a Github username:',
},
{
type: 'text',
name: 'dir',
message: 'Please enter a local absolute path to clone the repositories into:'
}
]);
return response;
};

const fetcher = async (user) => {
return fetch(`https://api.github.com/users/${user}/repos`)
.then(data => data.json())
.catch(err => {console.log('There was an error ', err)});
};

const cloneURL_arr = (data) => data.map((val => val.clone_url));
const names_arr = (data) => data.map((val => val.name));

const main = async () => {
let userObj = await prompter();
let response = await fetcher(userObj.username);


// Loop through the response array and create an array of just the urls to clone each repository
const urls = cloneURL_arr(response);

// Loop through the response array and create an array of repository names to be used for creating directories
const names = names_arr(response);


// Loop through array of repository urls, mkdir for each associated reposotory name, then clone repo into new dir
urls.map((url, index) => {
let path = `${userObj.dir}/${names[index]}`

fs.mkdirSync(path);
clone(url, path);
});

};

main();
266 changes: 0 additions & 266 deletions node_modules/node-fetch/CHANGELOG.md

This file was deleted.

22 changes: 0 additions & 22 deletions node_modules/node-fetch/LICENSE.md

This file was deleted.

Loading