Skip to content

Commit 4c5389f

Browse files
rchtgptdotrachit
andauthored
🐛 cli: Add input check and fix whoami docs
* 📝 cli: add input check and fix whoami docs * 📝 cli: fix total command number * 🔧 general: Fix linting with prettier Co-authored-by: dotrachit <[email protected]>
1 parent 78fa3d4 commit 4c5389f

File tree

3 files changed

+51
-25
lines changed

3 files changed

+51
-25
lines changed

.gitgo

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,17 @@
11
{
22
"current_issue": {
3-
"number": "",
3+
"number": "62",
44
"labels": [
5-
""
5+
"bug"
66
],
7-
"title": ""
7+
"title": "Add (y/N) input checks"
88
},
99
"commit_guidelines": [
10-
"fix:",
11-
" feat:",
12-
" chore:"
10+
"cli: ",
11+
" general: "
1312
],
14-
"custom_guidelines": false,
15-
"selected_commit_type": "",
13+
"custom_guidelines": true,
14+
"selected_commit_type": "✨ Adding a new user-facing feature",
1615
"emojis": {
1716
"initial_commit": "tada",
1817
"feature": "sparkles",
@@ -31,12 +30,12 @@
3130
"wip": "construction"
3231
},
3332
"existing_branches": [
34-
""
33+
"main"
3534
],
3635
"current_branch": [
37-
""
36+
"input-checks"
3837
],
3938
"current_commit_message": "",
4039
"use_emojis": true,
41-
"commit_config": false
40+
"commit_config": true
4241
}

bin/index.js

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -282,30 +282,41 @@ program
282282
"\n"
283283
);
284284
console.log(
285-
"You just need to know 5 simple commands you and then you're " +
286-
chalk.bold.cyan("gtg") +
287-
": " +
288-
chalk.magenta("Good to Go")
285+
`You just need to know 7 simple commands you and then you're ${chalk.bold.cyan(
286+
"gtg"
287+
)} : ${chalk.magenta("Good to Go")}`
289288
);
290289
console.log(chalk.green("\ngtg config:\n"));
291290
console.log(
292-
"This command should be used to personalise your gitgo configuration. You can add your repository's commit and emoticon guidelines.\n"
291+
"Use this to set up your project's gitgo configuration. You will be asked certain questions regarding your commit and emoji preferences.\n"
293292
);
293+
console.log(chalk.green("\ngtg version:\n"));
294+
console.log(
295+
"Use this to check the version of your installed gitg0 package."
296+
);
297+
console.log(chalk.green("\ngtg whoami:\n"));
298+
console.log("I mean,,, you just used me.");
294299
console.log(chalk.green("\ngtg start:\n"));
295300
console.log(
296-
"Everytime you start working on a new issue, just run this command in order for the tool to know which issue you're working on. After this, the tool will suggest the branch names and commit messages automatically.\n"
301+
"Use this before you you start working on a new issue so that we can suggest the branch names and commit messages automatically.\n"
297302
);
298303
console.log(chalk.green("\ngtg display:\n"));
299304
console.log(
300-
"This command can be used to display the branch name and commit that the tool will be suggesting for a particular issue once bin start has been run.\n"
305+
`Use this to view the suggested branch name and commit title. You can also edit the suggested text based on your preference. This command should be run after ${chalk.yellow(
306+
"gg start"
307+
)}.\n`
301308
);
302309
console.log(chalk.green("\ngtg checkout:\n"));
303310
console.log(
304-
"This is a replacement for git checkout and will simply checkout with the suggested branch name.\n"
311+
`This is a replacement for ${chalk.yellow(
312+
"git checkout -b"
313+
)} and will simply checkout with gitgo's suggested branch name.\n`
305314
);
306315
console.log(chalk.green("\ngtg checkout:\n"));
307316
console.log(
308-
"This is a replacement for git commit and will commit your files once added with the suggested commit message.\n"
317+
`This is a replacement for ${chalk.yellow(
318+
"git checkout -m"
319+
)} and will commit your files once added with gitgo's suggested commit message.\n`
309320
);
310321
});
311322

lib/inquirer.js

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const { getIssue } = require("./issue.js");
55
const reader = require("./funcs/jsonReader.js");
66
const chalk = require("chalk");
77
const { recIssueType, issueType } = require("./funcs/rec-iss-type");
8+
const { exit } = require("process");
89

910
module.exports = {
1011
getQuestions: async () => {
@@ -101,18 +102,29 @@ module.exports = {
101102
// expects issue number as response
102103
type: "string",
103104
message:
104-
"Would you be using emojis in your commit messages?(y/n)",
105+
"Would you be using emojis in your commit messages?(y/N)",
105106
name: "emojis",
106107
},
107108
])
108109
.then((ans2) => {
109110
var emo = true;
110-
if (ans2["emojis"] === "y") {
111+
if (ans2["emojis"] === "y" || ans2["emojis"] === "Y") {
111112
console.log(
112113
"\nWe have an awesome set of emojis in the .gitgo file which will be suggested to you in the commit messages.\n"
113114
);
114-
} else {
115+
} else if (
116+
ans2["emojis"] === "n" ||
117+
ans2["emojis"] === "N" ||
118+
ans2["emojis"] === ""
119+
) {
115120
emo = false;
121+
} else {
122+
console.log(
123+
`We don't know what you mean by "${
124+
ans2["emojis"]
125+
}" ${emoji.get(":cry:")}`
126+
);
127+
exit();
116128
}
117129
reader.jsonReader("./.gitgo", (err, conf) => {
118130
if (err) {
@@ -130,7 +142,9 @@ module.exports = {
130142
);
131143
});
132144
console.log(
133-
"\nSettings for your repo have been stored. Run gg start before working on an issue to get the branch name and commit title automatically. If you would like to change any settings manually, please edit the .gitgo file.\n"
145+
`\nSettings for your repo have been stored. Run ${chalk.yellow(
146+
"gg start"
147+
)} before working on an issue to get the branch name and commit title automatically. If you would like to change any settings manually, please edit the .gitgo file.\n`
134148
);
135149
});
136150
});
@@ -181,7 +195,9 @@ module.exports = {
181195
);
182196
});
183197
console.log(
184-
"\nSettings for your repo have been stored. Run gg start before working on an issue to get the branch name and commit title automatically. If you would like to change any settings manually, please edit the .gitgo file.\n"
198+
`\nSettings for your repo have been stored. Run ${chalk.yellow(
199+
"gg start"
200+
)} before working on an issue to get the branch name and commit title automatically. If you would like to change any settings manually, please edit the .gitgo file.\n`
185201
);
186202
});
187203
}

0 commit comments

Comments
 (0)