File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 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+ const headers = require ( "./auth" ) ;
13+
14+ module . exports = async ( ) => {
15+ io . write ( "------------------------------------------" ) ;
16+ // getting data from terminal
17+
18+ io . write ( cyan ( "> Enter GitHub Username where the repo exists" ) ) ;
19+ username = await io . read ( ) ;
20+ io . write ( "" ) ;
21+
22+ io . write ( cyan ( "> Enter the repo name" ) ) ;
23+ repo = await io . read ( ) ;
24+ io . write ( "" ) ;
25+
26+ io . write ( cyan ( "> Enter Issue Title" ) ) ;
27+ const title = await io . read ( ) ;
28+ io . write ( "" ) ;
29+ io . write ( cyan ( "> Enter Issue Description" ) ) ;
30+ const description = await io . read ( ) ;
31+ io . write ( "" ) ;
32+
33+ const payLoad = {
34+ title : title ,
35+ body : description ,
36+ } ;
37+
38+ const options = {
39+ method : "POST" ,
40+ headers : headers ,
41+ data : JSON . stringify ( payLoad ) ,
42+ url : `https://api.github.com/repos/${ username } /${ repo } /issues` ,
43+ } ;
44+
45+ await axios ( options )
46+ . then ( ( res ) => {
47+ const name = "👌 DONE" ;
48+ const msg = "Issue Successfully Created!!" ;
49+ box ( name , msg ) ;
50+ } )
51+ . catch ( ( err ) => {
52+ console . log ( err . response . config . headers ) ;
53+ console . log ( err . response . data ) ;
54+
55+ const name = "⚠️ WARNING" ;
56+ const msg = "Issue Creation Failed!!" ;
57+ box ( name , msg ) ;
58+ } ) ;
59+ } ;
You can’t perform that action at this time.
0 commit comments