Skip to content

Commit

Permalink
📦NEW: create repo
Browse files Browse the repository at this point in the history
  • Loading branch information
msaaddev committed Apr 7, 2020
1 parent 4f28d92 commit c500160
Showing 1 changed file with 67 additions and 0 deletions.
67 changes: 67 additions & 0 deletions utils/createRepo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/**
*
* Author: Muhammad Saad
* GitHub: msaaddev
* Twitter: https://twitter.com/msaaddev
*/

const io = require("console-read-write");
const { cyan } = require("chalk");
const box = require("./box");
const axios = require("axios");
let { username, password } = require("./user");
const headers = require("./auth");

module.exports = async () => {
console.log(headers);

io.write("------------------------------------------");
// getting data from terminal
if (username === "" && password === "") {
io.write(cyan("> Enter GitHub Username"));
username = await io.read();
io.write("");
io.write(cyan("> Enter GitHub Password"));
password = await io.read();
io.write("");
}
io.write(cyan("> Enter Repo Title"));
const title = await io.read();
io.write("");
io.write(
cyan("> Enter Repo Description (You can leave it blank. Just Press Enter)")
);
const description = await io.read();
io.write("");
io.write(cyan("> Create Private Repo? (True/False)"));
const private = await io.read();
io.write("");
io.write(cyan("> Create empty README.MD file? (True/False)"));
const auto_init = await io.read();
io.write("");

/* const head = {
Authorization: `Basic ${username}:${password}`,
}; */

await axios
.post(`https://api.github.com/user/repos`, {
headers: headers,
name: title,
description,
private,
auto_init,
})
.then((res) => {
const name = "👌 DONE";
const msg = "Repo Successfully Created!!";
box(name, msg);
})
.catch((err) => {
console.log(err);

const name = "⚠️ WARNING";
const msg = "Repo Creation Failed!!";
box(name, msg);
});
};

0 comments on commit c500160

Please sign in to comment.