Skip to content

Commit c500160

Browse files
committed
📦NEW: create repo
1 parent 4f28d92 commit c500160

1 file changed

Lines changed: 67 additions & 0 deletions

File tree

utils/createRepo.js

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/**
2+
*
3+
* Author: Muhammad Saad
4+
* GitHub: msaaddev
5+
* Twitter: https://twitter.com/msaaddev
6+
*/
7+
8+
const io = require("console-read-write");
9+
const { cyan } = require("chalk");
10+
const box = require("./box");
11+
const axios = require("axios");
12+
let { username, password } = require("./user");
13+
const headers = require("./auth");
14+
15+
module.exports = async () => {
16+
console.log(headers);
17+
18+
io.write("------------------------------------------");
19+
// getting data from terminal
20+
if (username === "" && password === "") {
21+
io.write(cyan("> Enter GitHub Username"));
22+
username = await io.read();
23+
io.write("");
24+
io.write(cyan("> Enter GitHub Password"));
25+
password = await io.read();
26+
io.write("");
27+
}
28+
io.write(cyan("> Enter Repo Title"));
29+
const title = await io.read();
30+
io.write("");
31+
io.write(
32+
cyan("> Enter Repo Description (You can leave it blank. Just Press Enter)")
33+
);
34+
const description = await io.read();
35+
io.write("");
36+
io.write(cyan("> Create Private Repo? (True/False)"));
37+
const private = await io.read();
38+
io.write("");
39+
io.write(cyan("> Create empty README.MD file? (True/False)"));
40+
const auto_init = await io.read();
41+
io.write("");
42+
43+
/* const head = {
44+
Authorization: `Basic ${username}:${password}`,
45+
}; */
46+
47+
await axios
48+
.post(`https://api.github.com/user/repos`, {
49+
headers: headers,
50+
name: title,
51+
description,
52+
private,
53+
auto_init,
54+
})
55+
.then((res) => {
56+
const name = "👌 DONE";
57+
const msg = "Repo Successfully Created!!";
58+
box(name, msg);
59+
})
60+
.catch((err) => {
61+
console.log(err);
62+
63+
const name = "⚠️ WARNING";
64+
const msg = "Repo Creation Failed!!";
65+
box(name, msg);
66+
});
67+
};

0 commit comments

Comments
 (0)