-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcli.js
executable file
·146 lines (131 loc) · 3.68 KB
/
cli.js
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
#!/usr/bin/env node
// required modules
const fs = require("fs");
const path = require("path");
const inquirer = require("inquirer");
const genReadme = require("./utils/genReadme");
const codeCon = require("./utils/codeCon");
// array of questions for user -> #section of README each answer goes in
const questions = [
// project title -> title of README
{
name: "title",
type: "input",
message: "Enter title of project:",
default: path.basename(path.resolve()),
},
// github Repo Name -> badges
{
name: "repoName",
type: "input",
message: "Enter Github Repo Name:",
default: path.basename(path.resolve()),
},
// description -> #Description
{
name: "description",
type: "input",
message: "Enter a short description of the project:\n",
default: "```short description goes here```"
},
// installation instructions -> #Installation
{
name: "installation",
type: "input",
message: "Enter installation instructions:\n",
default: "```installation instructions go here```",
},
// usage information -> #Usage
{
name: "usage",
type: "input",
message: "Enter usage information:\n",
default: "```usage information goes here```",
},
// contributing code of conduct -> #Contributing
{
name: "codeOfConduct",
type: "confirm",
message:
"Add the Contributor Covenant? (This will overwrite any existing CODE_OF_CONDUCT.md)",
// https://www.contributor-covenant.org/
},
// contributing guidelines -> #contributing
{
name: "contributing",
type: "input",
message: "Add contributing guidelines:\n",
default:
"Your contribution is most welcome! Please refer to the contributing guidelines when making contributions to this project.",
},
// test instructions -> #Tests
{
name: "tests",
type: "input",
message: "Enter test instructions:\n",
default: "```test instructions go here```",
},
// github username -> #Questions
{
name: "github",
type: "input",
message: "Enter your github username:",
default: "thadkingcole",
},
// email address -> #Questions
// will also be used for code of conduct: npx covgen <your email address>
{
name: "email",
type: "input",
message: "Enter your email:",
default: "thadjcole@gmail.com",
},
// credits -> #Credits
{
name: "credits",
type: "input",
message: "Add any necessary credits:\n",
default: "I would like to thank the following people/projects/resources:",
},
// license
// list of options -> add badge of selected license to top of README
{
name: "license",
type: "rawlist",
message: "Choose a license:",
choices: [
"MIT",
"Apache-2.0",
"GPL-3.0",
// these are the three most popular licenses on github
// and easy to implement in any github project
],
},
];
// function to initialize program
function init() {
inquirer.prompt(questions).then((answers) => {
// Generate CODE_OF_CONDUCT.md using npx if desired by user
if (answers.codeOfConduct) {
codeCon.gen(answers);
}
// README.md may already exist, so alternate name will be used
fs.writeFile("READMEgen.md", genReadme(answers), (err) => {
if (err) {
console.log("ERROR!:", err);
return;
}
console.log("READMEgen.md successfully written!");
});
// CONTRIBUTING.md may already exist, so alternate name will be used
fs.writeFile("CONTRIBUTINGgen.md", codeCon.contributing(answers), (err) => {
if (err) {
console.log("ERROR!:", err);
return;
}
console.log("CONTRIBUTINGgen.md successfully written!");
});
});
}
// function call to initialize program
init();