-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
executable file
·88 lines (82 loc) · 2.59 KB
/
Copy pathindex.js
File metadata and controls
executable file
·88 lines (82 loc) · 2.59 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#!/usr/bin/env node
var path = require("path");
const exec = require("child_process").exec;
const fetch = require("node-fetch");
const { default: Axios } = require("axios");
var args = require("minimist")(process.argv.slice(2), {
boolean: ["help", "check"],
string: ["n", "path", "setup"],
});
const key = <Your_key />;
const BASEPATH = path.resolve(process.env.BASEPATH || __dirname);
if (args.help) {
printHelp();
} else if (args.n) {
if (args.path) {
var pathto = path.join(BASEPATH, args.path);
console.log("\x1b[32m", "work is in progress, please wait!");
exec(
`cd ${pathto} && mkdir ${args.n} && cd ${args.n} && create-react-app ./`,
(err, stdout, stderr) => {
if (err) {
console.error(`error: ${err.message}`);
return;
}
if (stderr) {
console.error(`stderr: ${stderr}`);
//return;
}
console.log("\x1b[32m", "Creating github repo!");
const payload = {
name: `${args.n}`,
description: "this is text",
homepage: "https://github.com",
private: false,
};
Axios.post("https://api.github.com/user/repos", payload, {
headers: {
"Content-Type": "application/json",
Authorization: `token ${key}`,
},
})
.then((res) => {
console.log(res.data);
exec(
`cd ${pathto}/${args.n} && git init && git remote add origin ${res.data.ssh_url} && git add . && git branch -M master && git push -u origin master `,
function (err, stdout, stderr) {
if (err) {
console.error(`error: ${err.message}`);
return;
}
if (stderr) {
console.error(`stderr: ${stderr}`);
}
console.log("");
console.log(`cd ${pathto}/${args.n}`);
console.log("yarn start");
console.log("Happy hacking");
}
);
})
.catch((e) => console.log("NetWork Error", e));
}
);
} else {
printHelp();
}
} else {
printHelp();
}
//************************************************
function printHelp() {
console.log("github usage:");
console.log("");
console.log(
"This package can be used while creating a react app and at the same time get synced with github"
);
console.log("");
console.log("--help Gives you help window");
console.log(
"--n ={fineName} --path ={path} File name of the project"
);
}