diff --git a/.gitgo b/.gitgo index 72408ed..2673d96 100644 --- a/.gitgo +++ b/.gitgo @@ -1,14 +1,19 @@ { "current_issue": { - "number": "43", + "number": "20", "labels": [ - "cli" + "cli", + "enhancement" ], - "title": "Change suggested text color to green" + "title": "Add branch name & commit message suggestions " }, - "commit_guidelines": [], + "commit_guidelines": [ + "fix:", + " feat:", + " chore:" + ], "custom_guidelines": false, - "selected_commit_type": "🎨 Improving UI", + "selected_commit_type": "🐎 Improving performance", "emojis": { "initial_commit": "tada", "feature": "sparkles", @@ -27,14 +32,16 @@ "wip": "construction" }, "existing_branches": [ - "commands", - "fix-commit", "issuetype-rec", "main", - "readme", - "recommendation-text-color" + "notice", + "readme" + ], + "current_branch": [ + "branch-name", + "branch-name", + "message-suggestions" ], - "current_branch": "capitalizing-default-value", - "current_commit_message": ":pencil: cli: Capitalizing default value on pressing enter", + "current_commit_message": "🐎 chore: Add branch name & commit message suggestions ", "use_emojis": true } \ No newline at end of file diff --git a/lib/funcs/commit-gen.js b/lib/funcs/commit-gen.js index 41d42e8..2659498 100644 --- a/lib/funcs/commit-gen.js +++ b/lib/funcs/commit-gen.js @@ -6,7 +6,7 @@ stopwords = ['a', 'the']; module.exports = { suggestCommitMsg:() => { - reader.jsonReader('./.gitgo', (err, conf) => { + setTimeout(()=>{reader.jsonReader('./.gitgo', (err, conf) => { if (err) { console.log(err) return @@ -16,7 +16,7 @@ module.exports = { var issue_title = conf.current_issue.title; var issue_number = conf.current_issue.number; var commitGuidelines = conf.commit_guidelines; - var customBoolean = conf. custom_guidelines; + var customBoolean = conf.custom_guidelines; var commitTypeContent = String(conf.selected_commit_type.match(/([A-Za-z\s\-]+)\w+/g)).trim(); var commitTypeEmoji; var emojiBool = conf.use_emojis; @@ -119,7 +119,7 @@ module.exports = { // { // commitTypeEmoji = conf.emojis.feature; // } - + } commitTypeEmoji = emoji.get(':'+commitTypeEmoji+':'); @@ -199,11 +199,11 @@ module.exports = { commitMsg = `${prefix} ${issue_title}`; conf.current_commit_message = commitMsg; } - + } fs.writeFile('./.gitgo', JSON.stringify(conf, null, 2), (err) => { if (err) console.log('Error writing file:', err) - }) - }); + }) + });},6000) } } diff --git a/lib/funcs/rec-iss-type.js b/lib/funcs/rec-iss-type.js new file mode 100644 index 0000000..d869867 --- /dev/null +++ b/lib/funcs/rec-iss-type.js @@ -0,0 +1,461 @@ +var inquirer = require('inquirer'); +const emoji = require('node-emoji'); +const fs = require('fs'); +const reader = require('./jsonReader'); + +module.exports = { + recIssueType : () => { + reader.jsonReader('./.gitgo', (err, conf) => { + if (err) { + console.log(err) + return + } + + var issue_labels_raw = conf.current_issue.labels; + if(issue_labels_raw.length > 1){ + var element = issue_labels_raw[issue_labels_raw.length - 1]; + while(issue_labels_raw.length > 1){ + if (element == 'bug' || + element == 'enhancement' || + element == 'help wanted' || + element == 'question' || + element == 'invalid' || + element == 'duplicate' || + element == 'good first issue' || + element == 'documentation' || + element == 'wontfix' ){ + var issue_labels = [element]; + break; + } + else{ + issue_labels_raw.pop(element); + element = issue_labels_raw[issue_labels_raw.length - 1]; + } + } + if (issue_labels_raw.length == 1){ + var issue_labels = issue_labels_raw; + } + } + else{ + var issue_labels = issue_labels_raw; + } + + for (let i = 0; i < issue_labels.length; i++) { + if (issue_labels[i] === 'enhancement') { + inquirer.prompt([{ + // displays emoji based MCQ + type: 'list', + message: 'What is the type of issue?', + name: 'issueType', + choices: [ + `${emoji.get(':art:')} Improving UI`, + `${emoji.get(':sparkles:')} Adding a new user-facing feature`, + `${emoji.get(':racehorse:')} Improving performance`, + `${emoji.get(':lock:')} Improving security`, + `${emoji.get(':wheelchair:')} Improving accessibility`, + `${emoji.get(':tada:')} Initial commit`, + `${emoji.get(':package:')} Refactoring or improving code`, + `${emoji.get(':wrench:')} Updating configs`, + `${emoji.get(':rocket:')} Improving dev tools`, + `${emoji.get(':pencil:')} Writing docs`, + `${emoji.get(':gem:')} New release`, + `${emoji.get(':bug:')} Fixing a bug`, + `${emoji.get(':boom:')} Fixing a crash`, + `${emoji.get(':fire:')} Removing code/files`, + `${emoji.get(':construction:')} WIP`, + ] + }]) + .then( + (ans) => { + reader.jsonReader('./.gitgo', (err, conf) => { + if (err) { + console.log('Error reading file:', err) + return + } + conf.selected_commit_type = ans['issueType']; + fs.writeFile('./.gitgo', JSON.stringify(conf, null, 2), (err) => { + if (err) console.log('Error writing file:', err) + }) + }); + // passes issue number to the function which fetches the issue title + // getIssue(_issueNumber) + } + ) + return; + } else if (issue_labels[i] === 'bug') { + inquirer.prompt([{ + // displays emoji based MCQ + type: 'list', + message: 'What is the type of issue?', + name: 'issueType', + choices: [ + `${emoji.get(':bug:')} Fixing a bug`, + `${emoji.get(':boom:')} Fixing a crash`, + `${emoji.get(':construction:')} WIP`, + `${emoji.get(':tada:')} Initial commit`, + `${emoji.get(':sparkles:')} Adding a new user-facing feature`, + `${emoji.get(':art:')} Improving UI`, + `${emoji.get(':package:')} Refactoring or improving code`, + `${emoji.get(':racehorse:')} Improving performance`, + `${emoji.get(':lock:')} Improving security`, + `${emoji.get(':wrench:')} Updating configs`, + `${emoji.get(':wheelchair:')} Improving accessibility`, + `${emoji.get(':rocket:')} Improving dev tools`, + `${emoji.get(':pencil:')} Writing docs`, + `${emoji.get(':gem:')} New release`, + `${emoji.get(':fire:')} Removing code/files`, + ] + }]) + .then( + (ans) => { + reader.jsonReader('./.gitgo', (err, conf) => { + if (err) { + console.log('Error reading file:', err) + return + } + conf.selected_commit_type = ans['issueType']; + fs.writeFile('./.gitgo', JSON.stringify(conf, null, 2), (err) => { + if (err) console.log('Error writing file:', err) + }) + }); + // passes issue number to the function which fetches the issue title + // getIssue(_issueNumber) + } + ) + return; + } else if (issue_labels[i] === 'documentation') { + inquirer.prompt([{ + // displays emoji based MCQ + type: 'list', + message: 'What is the type of issue?', + name: 'issueType', + choices: [ + `${emoji.get(':pencil:')} Writing docs`, + `${emoji.get(':construction:')} WIP`, + `${emoji.get(':tada:')} Initial commit`, + `${emoji.get(':sparkles:')} Adding a new user-facing feature`, + `${emoji.get(':art:')} Improving UI`, + `${emoji.get(':package:')} Refactoring or improving code`, + `${emoji.get(':racehorse:')} Improving performance`, + `${emoji.get(':lock:')} Improving security`, + `${emoji.get(':wrench:')} Updating configs`, + `${emoji.get(':wheelchair:')} Improving accessibility`, + `${emoji.get(':rocket:')} Improving dev tools`, + `${emoji.get(':gem:')} New release`, + `${emoji.get(':bug:')} Fixing a bug`, + `${emoji.get(':boom:')} Fixing a crash`, + `${emoji.get(':fire:')} Removing code/files`, + ] + }]) + .then( + (ans) => { + reader.jsonReader('./.gitgo', (err, conf) => { + if (err) { + console.log('Error reading file:', err) + return + } + conf.selected_commit_type = ans['issueType']; + fs.writeFile('./.gitgo', JSON.stringify(conf, null, 2), (err) => { + if (err) console.log('Error writing file:', err) + }) + }); + // passes issue number to the function which fetches the issue title + // getIssue(_issueNumber) + } + ) + return; + } else if (issue_labels[i] === 'duplicate') { + inquirer.prompt([{ + // displays emoji based MCQ + type: 'list', + message: 'What is the type of issue?', + name: 'issueType', + choices: [ + `${emoji.get(':construction:')} WIP`, + `${emoji.get(':tada:')} Initial commit`, + `${emoji.get(':sparkles:')} Adding a new user-facing feature`, + `${emoji.get(':art:')} Improving UI`, + `${emoji.get(':package:')} Refactoring or improving code`, + `${emoji.get(':racehorse:')} Improving performance`, + `${emoji.get(':lock:')} Improving security`, + `${emoji.get(':wrench:')} Updating configs`, + `${emoji.get(':wheelchair:')} Improving accessibility`, + `${emoji.get(':rocket:')} Improving dev tools`, + `${emoji.get(':pencil:')} Writing docs`, + `${emoji.get(':gem:')} New release`, + `${emoji.get(':bug:')} Fixing a bug`, + `${emoji.get(':boom:')} Fixing a crash`, + `${emoji.get(':fire:')} Removing code/files`, + ] + }]) + .then( + (ans) => { + reader.jsonReader('./.gitgo', (err, conf) => { + if (err) { + console.log('Error reading file:', err) + return + } + conf.selected_commit_type = ans['issueType']; + fs.writeFile('./.gitgo', JSON.stringify(conf, null, 2), (err) => { + if (err) console.log('Error writing file:', err) + }) + }); + // passes issue number to the function which fetches the issue title + // getIssue(_issueNumber) + } + ) + return; + } else if (issue_labels[i] === 'good first issue') { + inquirer.prompt([{ + // displays emoji based MCQ + type: 'list', + message: 'What is the type of issue?', + name: 'issueType', + choices: [ + `${emoji.get(':gem:')} New release`, + `${emoji.get(':construction:')} WIP`, + `${emoji.get(':tada:')} Initial commit`, + `${emoji.get(':sparkles:')} Adding a new user-facing feature`, + `${emoji.get(':art:')} Improving UI`, + `${emoji.get(':package:')} Refactoring or improving code`, + `${emoji.get(':racehorse:')} Improving performance`, + `${emoji.get(':lock:')} Improving security`, + `${emoji.get(':wrench:')} Updating configs`, + `${emoji.get(':wheelchair:')} Improving accessibility`, + `${emoji.get(':rocket:')} Improving dev tools`, + `${emoji.get(':pencil:')} Writing docs`, + `${emoji.get(':bug:')} Fixing a bug`, + `${emoji.get(':boom:')} Fixing a crash`, + `${emoji.get(':fire:')} Removing code/files`, + ] + }]) + .then( + (ans) => { + reader.jsonReader('./.gitgo', (err, conf) => { + if (err) { + console.log('Error reading file:', err) + return + } + conf.selected_commit_type = ans['issueType']; + fs.writeFile('./.gitgo', JSON.stringify(conf, null, 2), (err) => { + if (err) console.log('Error writing file:', err) + }) + }); + // passes issue number to the function which fetches the issue title + // getIssue(_issueNumber) + } + ) + return; + } else if (issue_labels[i] === 'help wanted') { + inquirer.prompt([{ + // displays emoji based MCQ + type: 'list', + message: 'What is the type of issue?', + name: 'issueType', + choices: [ + `${emoji.get(':bug:')} Fixing a bug`, + `${emoji.get(':boom:')} Fixing a crash`, + `${emoji.get(':construction:')} WIP`, + `${emoji.get(':tada:')} Initial commit`, + `${emoji.get(':sparkles:')} Adding a new user-facing feature`, + `${emoji.get(':art:')} Improving UI`, + `${emoji.get(':package:')} Refactoring or improving code`, + `${emoji.get(':racehorse:')} Improving performance`, + `${emoji.get(':lock:')} Improving security`, + `${emoji.get(':wrench:')} Updating configs`, + `${emoji.get(':wheelchair:')} Improving accessibility`, + `${emoji.get(':rocket:')} Improving dev tools`, + `${emoji.get(':pencil:')} Writing docs`, + `${emoji.get(':gem:')} New release`, + `${emoji.get(':fire:')} Removing code/files`, + ] + }]) + .then( + (ans) => { + reader.jsonReader('./.gitgo', (err, conf) => { + if (err) { + console.log('Error reading file:', err) + return + } + conf.selected_commit_type = ans['issueType']; + fs.writeFile('./.gitgo', JSON.stringify(conf, null, 2), (err) => { + if (err) console.log('Error writing file:', err) + }) + }); + // passes issue number to the function which fetches the issue title + // getIssue(_issueNumber) + } + ) + return; + } else if (issue_labels[i] === 'invalid') { + inquirer.prompt([{ + // displays emoji based MCQ + type: 'list', + message: 'What is the type of issue?', + name: 'issueType', + choices: [ + `${emoji.get(':package:')} Refactoring or improving code`, + `${emoji.get(':bug:')} Fixing a bug`, + `${emoji.get(':boom:')} Fixing a crash`, + `${emoji.get(':fire:')} Removing code/files`, + `${emoji.get(':construction:')} WIP`, + `${emoji.get(':tada:')} Initial commit`, + `${emoji.get(':sparkles:')} Adding a new user-facing feature`, + `${emoji.get(':art:')} Improving UI`, + `${emoji.get(':racehorse:')} Improving performance`, + `${emoji.get(':lock:')} Improving security`, + `${emoji.get(':wrench:')} Updating configs`, + `${emoji.get(':wheelchair:')} Improving accessibility`, + `${emoji.get(':rocket:')} Improving dev tools`, + `${emoji.get(':pencil:')} Writing docs`, + `${emoji.get(':gem:')} New release`, + ] + }]) + .then( + (ans) => { + reader.jsonReader('./.gitgo', (err, conf) => { + if (err) { + console.log('Error reading file:', err) + return + } + conf.selected_commit_type = ans['issueType']; + fs.writeFile('./.gitgo', JSON.stringify(conf, null, 2), (err) => { + if (err) console.log('Error writing file:', err) + }) + }); + // passes issue number to the function which fetches the issue title + // getIssue(_issueNumber) + } + ) + return; + } else if (issue_labels[i] === 'question') { + inquirer.prompt([{ + // displays emoji based MCQ + type: 'list', + message: 'What is the type of issue?', + name: 'issueType', + choices: [ + `${emoji.get(':construction:')} WIP`, + `${emoji.get(':tada:')} Initial commit`, + `${emoji.get(':sparkles:')} Adding a new user-facing feature`, + `${emoji.get(':art:')} Improving UI`, + `${emoji.get(':package:')} Refactoring or improving code`, + `${emoji.get(':racehorse:')} Improving performance`, + `${emoji.get(':lock:')} Improving security`, + `${emoji.get(':wrench:')} Updating configs`, + `${emoji.get(':wheelchair:')} Improving accessibility`, + `${emoji.get(':rocket:')} Improving dev tools`, + `${emoji.get(':pencil:')} Writing docs`, + `${emoji.get(':gem:')} New release`, + `${emoji.get(':bug:')} Fixing a bug`, + `${emoji.get(':boom:')} Fixing a crash`, + `${emoji.get(':fire:')} Removing code/files`, + ] + }]) + .then( + (ans) => { + reader.jsonReader('./.gitgo', (err, conf) => { + if (err) { + console.log('Error reading file:', err) + return + } + conf.selected_commit_type = ans['issueType']; + fs.writeFile('./.gitgo', JSON.stringify(conf, null, 2), (err) => { + if (err) console.log('Error writing file:', err) + }) + }); + // passes issue number to the function which fetches the issue title + // getIssue(_issueNumber) + } + ) + return; + } else if (issue_labels[i] === 'wontfix') { + inquirer.prompt([{ + // displays emoji based MCQ + type: 'list', + message: 'What is the type of issue?', + name: 'issueType', + choices: [ + `${emoji.get(':tada:')} Initial commit`, + `${emoji.get(':sparkles:')} Adding a new user-facing feature`, + `${emoji.get(':art:')} Improving UI`, + `${emoji.get(':package:')} Refactoring or improving code`, + `${emoji.get(':racehorse:')} Improving performance`, + `${emoji.get(':lock:')} Improving security`, + `${emoji.get(':wrench:')} Updating configs`, + `${emoji.get(':wheelchair:')} Improving accessibility`, + `${emoji.get(':rocket:')} Improving dev tools`, + `${emoji.get(':pencil:')} Writing docs`, + `${emoji.get(':gem:')} New release`, + `${emoji.get(':bug:')} Fixing a bug`, + `${emoji.get(':boom:')} Fixing a crash`, + `${emoji.get(':fire:')} Removing code/files`, + `${emoji.get(':construction:')} WIP`, + ] + }]) + .then( + (ans) => { + reader.jsonReader('./.gitgo', (err, conf) => { + if (err) { + console.log('Error reading file:', err) + return + } + conf.selected_commit_type = ans['issueType']; + fs.writeFile('./.gitgo', JSON.stringify(conf, null, 2), (err) => { + if (err) console.log('Error writing file:', err) + }) + }); + // passes issue number to the function which fetches the issue title + // getIssue(_issueNumber) + } + ) + return; + } + else if (issue_labels[i] !== 'bug' && issue_labels[i] !== 'enhancement' && issue_labels[i] !== 'help wanted' && issue_labels[i] !== 'question' && issue_labels[i] !== 'invalid' && issue_labels[i] !== 'duplicate' && issue_labels[i] !== 'good first issue' && issue_labels[i] !== 'documentation' && issue_labels[i] !== 'wontfix') { + inquirer.prompt([{ + // displays emoji based MCQ + type: 'list', + message: 'What is the type of issue?', + name: 'issueType', + choices: [ + `${emoji.get(':tada:')} Initial commit`, + `${emoji.get(':sparkles:')} Adding a new user-facing feature`, + `${emoji.get(':art:')} Improving UI`, + `${emoji.get(':package:')} Refactoring or improving code`, + `${emoji.get(':racehorse:')} Improving performance`, + `${emoji.get(':lock:')} Improving security`, + `${emoji.get(':wrench:')} Updating configs`, + `${emoji.get(':wheelchair:')} Improving accessibility`, + `${emoji.get(':rocket:')} Improving dev tools`, + `${emoji.get(':pencil:')} Writing docs`, + `${emoji.get(':gem:')} New release`, + `${emoji.get(':bug:')} Fixing a bug`, + `${emoji.get(':boom:')} Fixing a crash`, + `${emoji.get(':fire:')} Removing code/files`, + `${emoji.get(':construction:')} WIP`, + ] + }]) + .then( + (ans) => { + reader.jsonReader('./.gitgo', (err, conf) => { + if (err) { + console.log('Error reading file:', err) + return + } + conf.selected_commit_type = ans['issueType']; + fs.writeFile('./.gitgo', JSON.stringify(conf, null, 2), (err) => { + if (err) console.log('Error writing file:', err) + }) + }); + // passes issue number to the function which fetches the issue title + // getIssue(_issueNumber) + } + ) + return; + } + } + }) + } +} + +// recIssueType() \ No newline at end of file diff --git a/lib/inquirer.js b/lib/inquirer.js index c3bf2fc..a43f2c7 100644 --- a/lib/inquirer.js +++ b/lib/inquirer.js @@ -1,59 +1,44 @@ var inquirer = require('inquirer'); var emoji = require('node-emoji'); const fs = require('fs'); -const { getIssue } = require('./issue.js'); -const { jsonReader } = require('./funcs/jsonReader.js'); +const { + getIssue +} = require('./issue.js'); +const reader = require('./funcs/jsonReader.js'); const chalk = require('chalk'); +const { + recIssueType, + issueType +} = require('./funcs/rec-iss-type'); module.exports = { getQuestions: async () => { - inquirer.prompt([ - { + inquirer.prompt([{ // expects issue number as response - type: 'string', message: 'Which issue are you working on today?', name: 'issue' - } - ]) - .then(answers => { - const _issueNumber = answers['issue']; - inquirer.prompt([{ - // displays emoji based MCQ - type: 'list', - message: 'What is the type of issue?', - name: 'issueType', - choices: [ - `${emoji.get(':tada:')} Initial commit`, - `${emoji.get(':sparkles:')} Adding a new user-facing feature`, - `${emoji.get(':art:')} Improving UI`, - `${emoji.get(':package:')} Refactoring or improving code`, - `${emoji.get(':racehorse:')} Improving performance`, - `${emoji.get(':lock:')} Improving security`, - `${emoji.get(':wrench:')} Updating configs`, - `${emoji.get(':wheelchair:')} Improving accessibility`, - `${emoji.get(':rocket:')} Improving dev tools`, - `${emoji.get(':pencil:')} Writing docs`, - `${emoji.get(':gem:')} New release`, - `${emoji.get(':bug:')} Fixing a bug`, - `${emoji.get(':boom:')} Fixing a crash`, - `${emoji.get(':fire:')} Removing code/files`, - `${emoji.get(':construction:')} WIP`, - ] - }]).then( - ans => { - jsonReader('./.gitgo', (err, conf) => { + type: 'string', + message: 'Which issue are you working on today?', + name: 'issue' + }]) + .then( + answer1 => { + const _issueNumber = answer1['issue']; + getIssue(_issueNumber) + setTimeout(function () { + reader.jsonReader('./.gitgo', (err, conf) => { if (err) { console.log('Error reading file:', err) return } - conf.selected_commit_type = ans['issueType']; - fs.writeFile('./.gitgo', JSON.stringify(conf, null, 2), (err) => { - if (err) console.log('Error writing file:', err) - }) - }); - // passes issue number to the function which fetches the issue title - getIssue(_issueNumber) - } - ) + var title = conf.current_issue.title + console.log(emoji.get(':smiley_cat:'), chalk.bold('Github Issue Title:'), title) + }) + }, 4000) + }) + .then(() => { + setTimeout(function () { + recIssueType() + }, 5000) }) .catch(error => { if (error.isTtyError) { @@ -67,105 +52,105 @@ module.exports = { getConfigQuestions: async () => { inquirer.prompt([{ - type: 'list', - message: 'What commit guidelines do you follow?', - name: 'guidelines', - choices: [ - `fix:, feat:, chore:`, - `fix #`, - `...(fix #)`, - `Type your own, if multiple, separate with commas`, - ] - }]).then( - ans => { - if (ans['guidelines'] === "Type your own, if multiple, separate with commas") { - inquirer.prompt([ - { + type: 'list', + message: 'What commit guidelines do you follow?', + name: 'guidelines', + choices: [ + `fix:, feat:, chore:`, + `fix #`, + `...(fix #)`, + `Type your own, if multiple, separate with commas`, + ] + }]).then( + ans => { + if (ans['guidelines'] === "Type your own, if multiple, separate with commas") { + inquirer.prompt([{ // expects issue number as response - type: 'string', message: 'Type your own guidelines, if multiple, separate with commas\n', name: 'commit' - } - ]).then( - ans1 => { - jsonReader('./.gitgo', (err, conf) => { - if (err) { - console.log('Error reading file:', err) - return - } - conf.commit_guidelines = ans1['commit'].split(','); - conf.custom_guidelines = true; - fs.writeFile('./.gitgo', JSON.stringify(conf, null, 2), (err) => { - if (err) console.log('Error writing file:', err) - }) - }) - inquirer.prompt([ - { - // expects yes and no as response - type: 'string', message: 'Would you be using emojis in your commit messages?(y/N)', name: 'emojis' - } - ]).then( - ans2 => { - var emo = true; - if (ans2['emojis'] === "y") { - console.log("\nWe have an awesome set of emojis in the .gitgo file which will be suggested to you in the commit messages.\n") - } else { - emo = false; + type: 'string', + message: 'Type your own guidelines, if multiple, separate with commas\n', + name: 'commit' + }]).then( + ans1 => { + reader.jsonReader('./.gitgo', (err, conf) => { + if (err) { + console.log('Error reading file:', err) + return } - jsonReader('./.gitgo', (err, conf) => { - if (err) { - console.log('Error reading file:', err) - return + conf.commit_guidelines = ans1['commit'].split(','); + conf.custom_guidelines = true; + fs.writeFile('./.gitgo', JSON.stringify(conf, null, 2), (err) => { + if (err) console.log('Error writing file:', err) + }) + }) + inquirer.prompt([{ + // expects issue number as response + type: 'string', + message: 'Would you be using emojis in your commit messages?(y/n)', + name: 'emojis' + }]).then( + ans2 => { + var emo = true; + if (ans2['emojis'] === "y") { + console.log("\nWe have an awesome set of emojis in the .gitgo file which will be suggested to you in the commit messages.\n") + } else { + emo = false; } - conf.use_emojis = emo; - fs.writeFile('./.gitgo', JSON.stringify(conf, null, 2), (err) => { - if (err) console.log('Error writing file:', err) + reader.jsonReader('./.gitgo', (err, conf) => { + if (err) { + console.log('Error reading file:', err) + return + } + conf.use_emojis = emo; + fs.writeFile('./.gitgo', JSON.stringify(conf, null, 2), (err) => { + if (err) console.log('Error writing file:', err) + }) }) - }) - console.log("\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") - } - ) - } - ) - } else { - jsonReader('./.gitgo', (err, conf) => { - if (err) { - console.log('Error reading file:', err) - return - } - conf.commit_guidelines = ans['guidelines'].split(','); - conf.custom_guidelines = false; - fs.writeFile('./.gitgo', JSON.stringify(conf, null, 2), (err) => { - if (err) console.log('Error writing file:', err) - }) - }) - inquirer.prompt([ - { - // expects yes and no as response - type: 'string', message: 'Would you be using emojis in your commit messages?(y/N)', name: 'emojis' - } - ]).then( - ans2 => { - var emo = true; - if (ans2['emojis'] === "y") { - console.log("\nWe have an awesome set of emojis in the .gitgo file which will be suggested to you in the commit messages.\n") - } else { - emo = false; + console.log("\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") + } + ) + } + ) + } else { + reader.jsonReader('./.gitgo', (err, conf) => { + if (err) { + console.log('Error reading file:', err) + return } - jsonReader('./.gitgo', (err, conf) => { - if (err) { - console.log('Error reading file:', err) - return + conf.commit_guidelines = ans['guidelines'].split(','); + conf.custom_guidelines = false; + fs.writeFile('./.gitgo', JSON.stringify(conf, null, 2), (err) => { + if (err) console.log('Error writing file:', err) + }) + }) + inquirer.prompt([{ + // expects issue number as response + type: 'string', + message: 'Would you be using emojis in your commit messages?(y/n)', + name: 'emojis' + }]).then( + ans2 => { + var emo = true; + if (ans2['emojis'] === "y") { + console.log("\nWe have an awesome set of emojis in the .gitgo file which will be suggested to you in the commit messages.\n") + } else { + emo = false; } - conf.use_emojis = emo; - fs.writeFile('./.gitgo', JSON.stringify(conf, null, 2), (err) => { - if (err) console.log('Error writing file:', err) + reader.jsonReader('./.gitgo', (err, conf) => { + if (err) { + console.log('Error reading file:', err) + return + } + conf.use_emojis = emo; + fs.writeFile('./.gitgo', JSON.stringify(conf, null, 2), (err) => { + if (err) console.log('Error writing file:', err) + }) }) - }) - console.log("\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") - } - ) + console.log("\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") + } + ) + } } - } - ) + ) .catch(error => { if (error.isTtyError) { // Prompt couldn't render in the current environment @@ -176,7 +161,7 @@ module.exports = { }, displaySuggestions: async () => { - jsonReader('./.gitgo', (err, conf) => { + reader.jsonReader('./.gitgo', (err, conf) => { if (err) { console.log('Error reading file:', err) return @@ -186,22 +171,26 @@ module.exports = { suggestedBranch = "Suggested branch name(press enter to continue or type an alternate): " + chalk.green(branch) + "\n"; suggestedCommitMsg = "Suggested commit message(press enter to continue or \"e\" to type an alternate): " + chalk.green(commitMsg) + "\n"; - inquirer.prompt([ - { - type: 'string', message: suggestedBranch, name: 'branch' - } - ]) + inquirer.prompt([{ + type: 'string', + message: suggestedBranch, + name: 'branch' + }]) .then(answers => { if (answers['branch'] != "") { conf.current_branch = answers['branch']; } inquirer.prompt([{ - type: 'string', message: suggestedCommitMsg, name: 'commit' + type: 'string', + message: suggestedCommitMsg, + name: 'commit' }]).then( ans => { if (ans['commit'] === "e") { inquirer.prompt([{ - type: 'editor', message: commitMsg + "\n", name: 'commitCustom' + type: 'editor', + message: commitMsg + "\n", + name: 'commitCustom' }]).then( ans2 => { console.log(ans2['commitCustom']); @@ -227,4 +216,4 @@ module.exports = { }); }) }, -}; +}; \ No newline at end of file diff --git a/lib/issue.js b/lib/issue.js index 2260138..f4d3940 100644 --- a/lib/issue.js +++ b/lib/issue.js @@ -41,7 +41,7 @@ module.exports = { (res.data['labels']).forEach(element => { labelsOfIssue.push(element['name']); }); - console.log(emoji.get(':smiley_cat:'), chalk.bold('Github Issue Title:'), titleOfIssue); + // console.log(emoji.get(':smiley_cat:'), chalk.bold('Github Issue Title:'), titleOfIssue); reader.jsonReader('./.gitgo', (err, conf) => { if (err) { console.log('Error reading file:', err) @@ -58,7 +58,8 @@ module.exports = { setTimeout(function () { suggestCommitMsg(); branchName(); - }, 1000); + }, 3000); + // return (emoji.get(':smiley_cat:'), chalk.bold('Github Issue Title:'), titleOfIssue) }); } }; diff --git a/package-lock.json b/package-lock.json index 6972ef5..bbca6d4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -17,6 +17,11 @@ "resolved": "https://registry.npmjs.org/@kwsites/promise-deferred/-/promise-deferred-1.1.1.tgz", "integrity": "sha512-GaHYm+c0O9MjZRu0ongGBRbinu8gVAMd2UZjji6jVmqKtZluZnptXGWhz1E8j8D2HJ3f/yMxKAUC0b+57wncIw==" }, + "@types/unist": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/@types/unist/-/unist-2.0.3.tgz", + "integrity": "sha512-FvUupuM3rlRsRtCN+fDudtmytGO6iHJuuRKS1Ss0pG5z8oX0diNEw94UEL7hgDbpN94rgaK5R7sWm6RrSkZuAQ==" + }, "ansi-escapes": { "version": "4.3.1", "resolved": "https://registry.npmjs.org/ansi-escapes/-/ansi-escapes-4.3.1.tgz", @@ -38,6 +43,11 @@ "color-convert": "^2.0.1" } }, + "array-iterate": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/array-iterate/-/array-iterate-1.1.4.tgz", + "integrity": "sha512-sNRaPGh9nnmdC8Zf+pT3UqP8rnWj5Hf9wiFGsX3wUQ2yVSIhO2ShFwCoceIPpB41QF6i2OEmrHmCo36xronCVA==" + }, "axios": { "version": "0.21.0", "resolved": "https://registry.npmjs.org/axios/-/axios-0.21.0.tgz", @@ -46,6 +56,11 @@ "follow-redirects": "^1.10.0" } }, + "bail": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/bail/-/bail-1.0.5.tgz", + "integrity": "sha512-xFbRxM1tahm08yHBP16MMjVUAvDaBMD38zsM9EMAUN61omwLmKlOpB/Zku5QkjZ8TZ4vn53pj+t518cH0S03RQ==" + }, "chalk": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.0.tgz", @@ -154,6 +169,11 @@ "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" }, + "extend": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", + "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==" + }, "external-editor": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/external-editor/-/external-editor-3.1.0.tgz", @@ -246,11 +266,21 @@ "through": "^2.3.6" } }, + "is-buffer": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.5.tgz", + "integrity": "sha512-i2R6zNFDwgEHJyQUtJEk0XFi1i0dPFn/oqjK3/vPCcDeJvW5NQ83V8QbicfF1SupOaB0h8ntgBC2YiE7dfyctQ==" + }, "is-fullwidth-code-point": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==" }, + "is-plain-obj": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz", + "integrity": "sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==" + }, "lodash": { "version": "4.17.20", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.20.tgz", @@ -276,6 +306,11 @@ "resolved": "https://registry.npmjs.org/mute-stream/-/mute-stream-0.0.8.tgz", "integrity": "sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==" }, + "nlcst-to-string": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/nlcst-to-string/-/nlcst-to-string-2.0.4.tgz", + "integrity": "sha512-3x3jwTd6UPG7vi5k4GEzvxJ5rDA7hVUIRNHPblKuMVP9Z3xmlsd9cgLcpAMkc5uPOBna82EeshROFhsPkbnTZg==" + }, "node-emoji": { "version": "1.10.0", "resolved": "https://registry.npmjs.org/node-emoji/-/node-emoji-1.10.0.tgz", @@ -313,6 +348,16 @@ "resolved": "https://registry.npmjs.org/os-tmpdir/-/os-tmpdir-1.0.2.tgz", "integrity": "sha1-u+Z0BseaqFxc/sdm/lc0VV36EnQ=" }, + "parse-latin": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/parse-latin/-/parse-latin-4.3.0.tgz", + "integrity": "sha512-TYKL+K98dcAWoCw/Ac1yrPviU8Trk+/gmjQVaoWEFDZmVD4KRg6c/80xKqNNFQObo2mTONgF8trzAf2UTwKafw==", + "requires": { + "nlcst-to-string": "^2.0.0", + "unist-util-modify-children": "^2.0.0", + "unist-util-visit-children": "^1.0.0" + } + }, "path": { "version": "0.12.7", "resolved": "https://registry.npmjs.org/path/-/path-0.12.7.tgz", @@ -322,11 +367,21 @@ "util": "^0.10.3" } }, + "pos": { + "version": "0.4.2", + "resolved": "https://registry.npmjs.org/pos/-/pos-0.4.2.tgz", + "integrity": "sha1-IOnHf77tzDVoI86mPHWFys6Tvio=" + }, "process": { "version": "0.11.10", "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz", "integrity": "sha1-czIwDoQBYb2j5podHZGn1LwW8YI=" }, + "replace-ext": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/replace-ext/-/replace-ext-1.0.0.tgz", + "integrity": "sha1-3mMSg3P8v3w8z6TeWkgMRaZ5WOs=" + }, "restore-cursor": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/restore-cursor/-/restore-cursor-3.1.0.tgz", @@ -336,6 +391,53 @@ "signal-exit": "^3.0.2" } }, + "retext": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/retext/-/retext-7.0.1.tgz", + "integrity": "sha512-N0IaEDkvUjqyfn3/gwxVfI51IxfGzOiVXqPLWnKeCDbiQdxSg0zebzHPxXWnL7TeplAJ+RE4uqrXyYN//s9HjQ==", + "requires": { + "retext-latin": "^2.0.0", + "retext-stringify": "^2.0.0", + "unified": "^8.0.0" + } + }, + "retext-keywords": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/retext-keywords/-/retext-keywords-6.0.0.tgz", + "integrity": "sha512-jDdindZTevx7uvDPcLG86qsfr6++szKXgGtQ5PjkkCxpEPpnyBeGovlTR7BCfyRatEoLX66iiTmpsY/hhAjbzA==", + "requires": { + "nlcst-to-string": "^2.0.0", + "stemmer": "^1.0.0", + "unist-util-visit": "^2.0.0" + } + }, + "retext-latin": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/retext-latin/-/retext-latin-2.0.4.tgz", + "integrity": "sha512-fOoSSoQgDZ+l/uS81oxI3alBghDUPja0JEl0TpQxI6MN+dhM6fLFumPJwMZ4PJTyL5FFAgjlsdv8IX+6IRuwMw==", + "requires": { + "parse-latin": "^4.0.0", + "unherit": "^1.0.4" + } + }, + "retext-pos": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/retext-pos/-/retext-pos-3.0.0.tgz", + "integrity": "sha512-OQ6WtYodx7ONuPBbX3cOC8+U9DzJEF365NbBy0LSuf28b3Nf6AK+lSnF7S23zhYrpbh1DVU0rdMTRh0ggYXnEg==", + "requires": { + "nlcst-to-string": "^2.0.0", + "pos": "^0.4.2", + "unist-util-visit": "^2.0.0" + } + }, + "retext-stringify": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/retext-stringify/-/retext-stringify-2.0.4.tgz", + "integrity": "sha512-xOtx5mFJBoT3j7PBtiY2I+mEGERNniofWktI1cKXvjMEJPOuqve0dghLHO1+gz/gScLn4zqspDGv4kk2wS5kSA==", + "requires": { + "nlcst-to-string": "^2.0.0" + } + }, "run-async": { "version": "2.4.1", "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.4.1.tgz", @@ -354,6 +456,11 @@ "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, + "sentence-engine": { + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/sentence-engine/-/sentence-engine-0.7.0.tgz", + "integrity": "sha512-UGK85TcnCLD2eR6TYGJnSt2mvnKqVZ3q2AaGiiuZiOqRIS43NEP/cKYLl9znuwU+Xa20C2DfF0Suc7gPTQRElw==" + }, "signal-exit": { "version": "3.0.3", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.3.tgz", @@ -369,6 +476,11 @@ "debug": "^4.3.1" } }, + "stemmer": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/stemmer/-/stemmer-1.0.5.tgz", + "integrity": "sha512-SLq7annzSKRDStasOJJoftCSCzBCKmBmH38jC4fDtCunAqOzpTpIm9zmaHmwNJiZ8gLe9qpVdBVbEG2DC5dE2A==" + }, "string-width": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.0.tgz", @@ -413,6 +525,11 @@ "os-tmpdir": "~1.0.2" } }, + "trough": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/trough/-/trough-1.0.5.tgz", + "integrity": "sha512-rvuRbTarPXmMb79SmzEp8aqXNKcK+y0XaB298IXueQ8I2PsrATcPBCSPyK/dDNa2iWOhKlfNnOjdAOTBU/nkFA==" + }, "tslib": { "version": "1.14.1", "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", @@ -423,6 +540,72 @@ "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.11.0.tgz", "integrity": "sha512-OdjXJxnCN1AvyLSzeKIgXTXxV+99ZuXl3Hpo9XpJAv9MBcHrrJOQ5kV7ypXOuQie+AmWG25hLbiKdwYTifzcfQ==" }, + "unherit": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/unherit/-/unherit-1.1.3.tgz", + "integrity": "sha512-Ft16BJcnapDKp0+J/rqFC3Rrk6Y/Ng4nzsC028k2jdDII/rdZ7Wd3pPT/6+vIIxRagwRc9K0IUX0Ra4fKvw+WQ==", + "requires": { + "inherits": "^2.0.0", + "xtend": "^4.0.0" + } + }, + "unified": { + "version": "8.4.2", + "resolved": "https://registry.npmjs.org/unified/-/unified-8.4.2.tgz", + "integrity": "sha512-JCrmN13jI4+h9UAyKEoGcDZV+i1E7BLFuG7OsaDvTXI5P0qhHX+vZO/kOhz9jn8HGENDKbwSeB0nVOg4gVStGA==", + "requires": { + "bail": "^1.0.0", + "extend": "^3.0.0", + "is-plain-obj": "^2.0.0", + "trough": "^1.0.0", + "vfile": "^4.0.0" + } + }, + "unist-util-is": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/unist-util-is/-/unist-util-is-4.0.3.tgz", + "integrity": "sha512-bTofCFVx0iQM8Jqb1TBDVRIQW03YkD3p66JOd/aCWuqzlLyUtx1ZAGw/u+Zw+SttKvSVcvTiKYbfrtLoLefykw==" + }, + "unist-util-modify-children": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/unist-util-modify-children/-/unist-util-modify-children-2.0.0.tgz", + "integrity": "sha512-HGrj7JQo9DwZt8XFsX8UD4gGqOsIlCih9opG6Y+N11XqkBGKzHo8cvDi+MfQQgiZ7zXRUiQREYHhjOBHERTMdg==", + "requires": { + "array-iterate": "^1.0.0" + } + }, + "unist-util-stringify-position": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/unist-util-stringify-position/-/unist-util-stringify-position-2.0.3.tgz", + "integrity": "sha512-3faScn5I+hy9VleOq/qNbAd6pAx7iH5jYBMS9I1HgQVijz/4mv5Bvw5iw1sC/90CODiKo81G/ps8AJrISn687g==", + "requires": { + "@types/unist": "^2.0.2" + } + }, + "unist-util-visit": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/unist-util-visit/-/unist-util-visit-2.0.3.tgz", + "integrity": "sha512-iJ4/RczbJMkD0712mGktuGpm/U4By4FfDonL7N/9tATGIF4imikjOuagyMY53tnZq3NP6BcmlrHhEKAfGWjh7Q==", + "requires": { + "@types/unist": "^2.0.0", + "unist-util-is": "^4.0.0", + "unist-util-visit-parents": "^3.0.0" + } + }, + "unist-util-visit-children": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/unist-util-visit-children/-/unist-util-visit-children-1.1.4.tgz", + "integrity": "sha512-sA/nXwYRCQVRwZU2/tQWUqJ9JSFM1X3x7JIOsIgSzrFHcfVt6NkzDtKzyxg2cZWkCwGF9CO8x4QNZRJRMK8FeQ==" + }, + "unist-util-visit-parents": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/unist-util-visit-parents/-/unist-util-visit-parents-3.1.1.tgz", + "integrity": "sha512-1KROIZWo6bcMrZEwiH2UrXDyalAa0uqzWCxCJj6lPOvTve2WkfgCytoDTPaMnodXh1WrXOq0haVYHj99ynJlsg==", + "requires": { + "@types/unist": "^2.0.0", + "unist-util-is": "^4.0.0" + } + }, "util": { "version": "0.10.4", "resolved": "https://registry.npmjs.org/util/-/util-0.10.4.tgz", @@ -431,10 +614,36 @@ "inherits": "2.0.3" } }, + "vfile": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/vfile/-/vfile-4.2.0.tgz", + "integrity": "sha512-a/alcwCvtuc8OX92rqqo7PflxiCgXRFjdyoGVuYV+qbgCb0GgZJRvIgCD4+U/Kl1yhaRsaTwksF88xbPyGsgpw==", + "requires": { + "@types/unist": "^2.0.0", + "is-buffer": "^2.0.0", + "replace-ext": "1.0.0", + "unist-util-stringify-position": "^2.0.0", + "vfile-message": "^2.0.0" + } + }, + "vfile-message": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/vfile-message/-/vfile-message-2.0.4.tgz", + "integrity": "sha512-DjssxRGkMvifUOJre00juHoP9DPWuzjxKuMDrhNbk2TdaYYBNMStsNhEOt3idrtI12VQYM/1+iM0KOzXi4pxwQ==", + "requires": { + "@types/unist": "^2.0.0", + "unist-util-stringify-position": "^2.0.0" + } + }, "wordwrap": { "version": "0.0.3", "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-0.0.3.tgz", "integrity": "sha1-o9XabNXAvAAI03I0u68b7WMFkQc=" + }, + "xtend": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/xtend/-/xtend-4.0.2.tgz", + "integrity": "sha512-LKYU1iAXJXUgAXn9URjiu+MWhyUXHsvfp7mcuYm9dSUKK0/CjtrUwFAxD82/mCWbtLsGjFIad0wIsod4zrTAEQ==" } } }