From e651ea539398c5de403b250c1a36ec3a28edbc72 Mon Sep 17 00:00:00 2001 From: Preet Shah Date: Wed, 25 Nov 2020 18:18:16 +0530 Subject: [PATCH 01/11] cli: calling labels to recommend issue type --- .gitgo | 15 +- lib/funcs/commit-gen.js | 8 +- lib/funcs/rec-iss-type.js | 20 +++ lib/inquirer.js | 315 +++++++++++++++++++++----------------- lib/issue.js | 11 +- 5 files changed, 212 insertions(+), 157 deletions(-) create mode 100644 lib/funcs/rec-iss-type.js diff --git a/.gitgo b/.gitgo index 0699c21..c805329 100644 --- a/.gitgo +++ b/.gitgo @@ -1,17 +1,18 @@ { "current_issue": { - "number": "39", + "number": "22", "labels": [ - "cli" + "cli", + "enhancement" ], - "title": "Create commands for checking out and committing" + "title": "Emoji top 3 recommendations" }, "commit_guidelines": [ "cli:", "general:" ], "custom_guidelines": true, - "selected_commit_type": "✨ Adding a new user-facing feature", + "selected_commit_type": "🎨 Improving UI", "emojis": { "initial_commit": "tada", "feature": "sparkles", @@ -30,12 +31,14 @@ "wip": "construction" }, "existing_branches": [ + "commands", + "issuetype-rec", "main", "readme" ], "current_branch": [ - "commands" + "cli-commands" ], - "current_commit_message": "✨ cli: Create commands for checking out and committing", + "current_commit_message": "✨ cli: Add cli commands for config and startup", "use_emojis": true } \ No newline at end of file diff --git a/lib/funcs/commit-gen.js b/lib/funcs/commit-gen.js index 8a55629..006ecb4 100644 --- a/lib/funcs/commit-gen.js +++ b/lib/funcs/commit-gen.js @@ -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) - }) + }) }); } } diff --git a/lib/funcs/rec-iss-type.js b/lib/funcs/rec-iss-type.js new file mode 100644 index 0000000..ac5c2d2 --- /dev/null +++ b/lib/funcs/rec-iss-type.js @@ -0,0 +1,20 @@ +var inquirer = require('inquirer'); +const emoji = require('node-emoji'); +const issue = require('../issue'); +const reader = require('./jsonReader'); + + + recIssueType = () => { + reader.jsonReader('../../.gitgo', (err,conf) => { + if (err) { + console.log(err) + return + } + + var issue_labels = conf.current_issue.labels; + console.log(issue_labels) + }) + } + + +recIssueType() \ No newline at end of file diff --git a/lib/inquirer.js b/lib/inquirer.js index fe811e6..1503c90 100644 --- a/lib/inquirer.js +++ b/lib/inquirer.js @@ -1,59 +1,86 @@ 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'); 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 => { + // jsonReader('./.gitgo', (err, conf) => { + // if (err) { + // console.log('Error reading file:', err) + // return + // } + // // conf.selected_commit_type = issue['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 + const _issueNumber = answer1['issue']; + getIssue(_issueNumber) + 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) + }) + }) + .then(() => { + // 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 => { + 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) + } + ) + }) .catch(error => { if (error.isTtyError) { // Prompt couldn't render in the current environment @@ -66,105 +93,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) + 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 + } + 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([ - { + 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; - } - jsonReader('./.gitgo', (err, conf) => { - if (err) { - console.log('Error reading file:', err) - return + 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) + 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 + } + 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([ - { + 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; - } - jsonReader('./.gitgo', (err, conf) => { - if (err) { - console.log('Error reading file:', err) - return + 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 @@ -175,7 +202,7 @@ module.exports = { }, displaySuggestions: async () => { - jsonReader('./.gitgo', (err, conf) => { + reader.jsonReader('./.gitgo', (err, conf) => { if (err) { console.log('Error reading file:', err) return @@ -185,22 +212,26 @@ module.exports = { suggestedBranch = "Suggested branch name(press enter to continue or type an alternate): " + branch + "\n"; suggestedCommitMsg = "Suggested commit message(press enter to continue or \"e\" to type an alternate): " + 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']); @@ -226,4 +257,4 @@ module.exports = { }); }) }, -}; +}; \ No newline at end of file diff --git a/lib/issue.js b/lib/issue.js index 2260138..12870d7 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) @@ -55,10 +55,11 @@ module.exports = { if (err) console.log('Error writing file:', err) }) }) - setTimeout(function () { - suggestCommitMsg(); - branchName(); - }, 1000); + // setTimeout(function () { + // suggestCommitMsg(); + // branchName(); + // }, 1000); + return (emoji.get(':smiley_cat:'), chalk.bold('Github Issue Title:'), titleOfIssue) }); } }; From 6012e306ef4451db3b163302112c8c2b3802a77f Mon Sep 17 00:00:00 2001 From: Preet Shah Date: Wed, 25 Nov 2020 21:51:50 +0530 Subject: [PATCH 02/11] cli: recommendations of issue types available for each label now --- .gitgo | 6 +- lib/funcs/rec-iss-type.js | 284 ++++++++++++++++++++++++++++++++++++-- package-lock.json | 209 ++++++++++++++++++++++++++++ 3 files changed, 484 insertions(+), 15 deletions(-) diff --git a/.gitgo b/.gitgo index c805329..697a81e 100644 --- a/.gitgo +++ b/.gitgo @@ -12,7 +12,7 @@ "general:" ], "custom_guidelines": true, - "selected_commit_type": "🎨 Improving UI", + "selected_commit_type": "✨ Adding a new user-facing feature", "emojis": { "initial_commit": "tada", "feature": "sparkles", @@ -37,8 +37,8 @@ "readme" ], "current_branch": [ - "cli-commands" + "Emoji-recommendations" ], - "current_commit_message": "✨ cli: Add cli commands for config and startup", + "current_commit_message": "✨ cli: Emoji top 3 recommendations", "use_emojis": true } \ No newline at end of file diff --git a/lib/funcs/rec-iss-type.js b/lib/funcs/rec-iss-type.js index ac5c2d2..62f9a33 100644 --- a/lib/funcs/rec-iss-type.js +++ b/lib/funcs/rec-iss-type.js @@ -1,20 +1,280 @@ var inquirer = require('inquirer'); const emoji = require('node-emoji'); -const issue = require('../issue'); const reader = require('./jsonReader'); +recIssueType = () => { + reader.jsonReader('../../.gitgo', (err, conf) => { + if (err) { + console.log(err) + return + } - recIssueType = () => { - reader.jsonReader('../../.gitgo', (err,conf) => { - if (err) { - console.log(err) - return - } - - var issue_labels = conf.current_issue.labels; - console.log(issue_labels) - }) - } + var issue_labels = conf.current_issue.labels; + console.log(issue_labels) + for (let i=0; i Date: Wed, 25 Nov 2020 22:34:07 +0530 Subject: [PATCH 03/11] :sparkles: cli: recommendations connected but optimization needed --- .gitgo | 9 +- lib/funcs/commit-gen.js | 2 +- lib/funcs/rec-iss-type.js | 534 +++++++++++++++++++------------------- lib/inquirer.js | 54 ++-- lib/issue.js | 2 +- 5 files changed, 297 insertions(+), 304 deletions(-) diff --git a/.gitgo b/.gitgo index 697a81e..a90938c 100644 --- a/.gitgo +++ b/.gitgo @@ -1,11 +1,11 @@ { "current_issue": { - "number": "22", + "number": "23", "labels": [ - "cli", - "enhancement" + "bug", + "cli" ], - "title": "Emoji top 3 recommendations" + "title": "Fix dependencies issue" }, "commit_guidelines": [ "cli:", @@ -32,6 +32,7 @@ }, "existing_branches": [ "commands", + "fix-commit", "issuetype-rec", "main", "readme" diff --git a/lib/funcs/commit-gen.js b/lib/funcs/commit-gen.js index 006ecb4..a4f7765 100644 --- a/lib/funcs/commit-gen.js +++ b/lib/funcs/commit-gen.js @@ -5,7 +5,7 @@ const reader = require('./jsonReader'); stopwords = ['a', 'the']; module.exports = { - suggestCommitMsg:() => { + suggestCommitMsg: () => { reader.jsonReader('./.gitgo', (err, conf) => { if (err) { console.log(err) diff --git a/lib/funcs/rec-iss-type.js b/lib/funcs/rec-iss-type.js index 62f9a33..26c4eda 100644 --- a/lib/funcs/rec-iss-type.js +++ b/lib/funcs/rec-iss-type.js @@ -2,279 +2,271 @@ var inquirer = require('inquirer'); const emoji = require('node-emoji'); const reader = require('./jsonReader'); -recIssueType = () => { - reader.jsonReader('../../.gitgo', (err, conf) => { - if (err) { - console.log(err) - return - } +module.exports = { + recIssueType: () => { + reader.jsonReader('./.gitgo', (err, conf) => { + if (err) { + console.log(err) + return + } - var issue_labels = conf.current_issue.labels; - console.log(issue_labels) + var issue_labels = conf.current_issue.labels; - for (let i=0; i { @@ -41,30 +40,31 @@ module.exports = { }) }) .then(() => { - // 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( + // 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`, + // ] + // }]) + recIssueType() + .then( ans => { reader.jsonReader('./.gitgo', (err, conf) => { if (err) { diff --git a/lib/issue.js b/lib/issue.js index 12870d7..f1cb146 100644 --- a/lib/issue.js +++ b/lib/issue.js @@ -59,7 +59,7 @@ module.exports = { // suggestCommitMsg(); // branchName(); // }, 1000); - return (emoji.get(':smiley_cat:'), chalk.bold('Github Issue Title:'), titleOfIssue) + // return (emoji.get(':smiley_cat:'), chalk.bold('Github Issue Title:'), titleOfIssue) }); } }; From f7887297b1c8b4550c8e7e7d9702de2a9d7b638f Mon Sep 17 00:00:00 2001 From: Preet Shah Date: Wed, 25 Nov 2020 23:49:32 +0530 Subject: [PATCH 04/11] cli: updates happen once .gitgo is loaded --- .gitgo | 8 ++-- lib/funcs/rec-iss-type.js | 2 +- lib/inquirer.js | 98 +++++++++++++++++++++------------------ 3 files changed, 58 insertions(+), 50 deletions(-) diff --git a/.gitgo b/.gitgo index a90938c..81002da 100644 --- a/.gitgo +++ b/.gitgo @@ -1,11 +1,11 @@ { "current_issue": { - "number": "23", + "number": "22", "labels": [ - "bug", - "cli" + "cli", + "enhancement" ], - "title": "Fix dependencies issue" + "title": "Emoji top 3 recommendations" }, "commit_guidelines": [ "cli:", diff --git a/lib/funcs/rec-iss-type.js b/lib/funcs/rec-iss-type.js index 26c4eda..1ea22f0 100644 --- a/lib/funcs/rec-iss-type.js +++ b/lib/funcs/rec-iss-type.js @@ -238,7 +238,7 @@ module.exports = { ] }]) return; - } else { + } else if (issue_labels[i]) { inquirer.prompt([{ // displays emoji based MCQ type: 'list', diff --git a/lib/inquirer.js b/lib/inquirer.js index f348674..2e37f99 100644 --- a/lib/inquirer.js +++ b/lib/inquirer.js @@ -1,10 +1,14 @@ var inquirer = require('inquirer'); var emoji = require('node-emoji'); const fs = require('fs'); -const { getIssue } = require('./issue.js'); +const { + getIssue +} = require('./issue.js'); const reader = require('./funcs/jsonReader.js'); const chalk = require('chalk'); -const { recIssueType } = require('./funcs/rec-iss-type'); +const { + recIssueType +} = require('./funcs/rec-iss-type'); module.exports = { getQuestions: async () => { @@ -30,7 +34,8 @@ module.exports = { // passes issue number to the function which fetches the issue title const _issueNumber = answer1['issue']; getIssue(_issueNumber) - reader.jsonReader('./.gitgo', (err, conf) => { + setTimeout(function () { + reader.jsonReader('./.gitgo', (err, conf) => { if (err) { console.log('Error reading file:', err) return @@ -38,49 +43,52 @@ module.exports = { var title = conf.current_issue.title console.log(emoji.get(':smiley_cat:'), chalk.bold('Github Issue Title:'), title) }) - }) - .then(() => { - // 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`, - // ] - // }]) - recIssueType() - .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) - } - ) + }, 2000) }) + .then(() => { + // 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`, + // ] + // }]) + setTimeout(function () { + recIssueType() + }, 3000) + .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) + } + ) + }) .catch(error => { if (error.isTtyError) { // Prompt couldn't render in the current environment From f6fe4313ce7e7a06b74297091edd5179bb199acf Mon Sep 17 00:00:00 2001 From: Preet Shah Date: Thu, 26 Nov 2020 02:07:06 +0530 Subject: [PATCH 05/11] cli: writes issuetype to .gitgo and recommends well --- .gitgo | 7 +- lib/funcs/rec-iss-type.js | 168 +++++++++++++++++++++++++++++++++++++- lib/inquirer.js | 48 ++--------- 3 files changed, 174 insertions(+), 49 deletions(-) diff --git a/.gitgo b/.gitgo index 81002da..fbe03f0 100644 --- a/.gitgo +++ b/.gitgo @@ -1,16 +1,17 @@ { "current_issue": { - "number": "22", + "number": "37", "labels": [ "cli", + "command", "enhancement" ], - "title": "Emoji top 3 recommendations" + "title": "Store the branch name and commit message in gitgo" }, "commit_guidelines": [ "cli:", "general:" - ], + ],23 "custom_guidelines": true, "selected_commit_type": "✨ Adding a new user-facing feature", "emojis": { diff --git a/lib/funcs/rec-iss-type.js b/lib/funcs/rec-iss-type.js index 1ea22f0..6a24377 100644 --- a/lib/funcs/rec-iss-type.js +++ b/lib/funcs/rec-iss-type.js @@ -1,9 +1,10 @@ var inquirer = require('inquirer'); const emoji = require('node-emoji'); +const fs = require('fs'); const reader = require('./jsonReader'); module.exports = { - recIssueType: () => { + recIssueType : () => { reader.jsonReader('./.gitgo', (err, conf) => { if (err) { console.log(err) @@ -20,8 +21,8 @@ module.exports = { message: 'What is the type of issue?', name: 'issueType', choices: [ - `${emoji.get(':sparkles:')} Adding a new user-facing feature`, `${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`, @@ -37,6 +38,22 @@ module.exports = { `${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([{ @@ -62,6 +79,22 @@ module.exports = { `${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([{ @@ -87,6 +120,22 @@ module.exports = { `${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([{ @@ -112,6 +161,22 @@ module.exports = { `${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([{ @@ -137,6 +202,22 @@ module.exports = { `${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([{ @@ -162,6 +243,22 @@ module.exports = { `${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([{ @@ -187,6 +284,22 @@ module.exports = { `${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([{ @@ -212,6 +325,22 @@ module.exports = { `${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([{ @@ -237,8 +366,25 @@ module.exports = { `${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]) { + } + 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', @@ -262,6 +408,22 @@ module.exports = { `${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; } } diff --git a/lib/inquirer.js b/lib/inquirer.js index 2e37f99..35b0f21 100644 --- a/lib/inquirer.js +++ b/lib/inquirer.js @@ -7,7 +7,8 @@ const { const reader = require('./funcs/jsonReader.js'); const chalk = require('chalk'); const { - recIssueType + recIssueType, + issueType } = require('./funcs/rec-iss-type'); module.exports = { @@ -43,51 +44,12 @@ module.exports = { var title = conf.current_issue.title console.log(emoji.get(':smiley_cat:'), chalk.bold('Github Issue Title:'), title) }) - }, 2000) + }, 3000) }) .then(() => { - // 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`, - // ] - // }]) setTimeout(function () { - recIssueType() - }, 3000) - .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) - } - ) + recIssueType() + }, 4000) }) .catch(error => { if (error.isTtyError) { From e55e36f8486bc7c4e774c0ec0616db9dc1501d5f Mon Sep 17 00:00:00 2001 From: Preet Shah Date: Thu, 26 Nov 2020 09:49:49 +0530 Subject: [PATCH 06/11] cli: jsonReader bug removed --- .gitgo | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.gitgo b/.gitgo index fbe03f0..3264d7b 100644 --- a/.gitgo +++ b/.gitgo @@ -1,19 +1,18 @@ { "current_issue": { - "number": "37", + "number": "22", "labels": [ "cli", - "command", "enhancement" ], - "title": "Store the branch name and commit message in gitgo" + "title": "Emoji top 3 recommendations" }, "commit_guidelines": [ "cli:", "general:" - ],23 + ], "custom_guidelines": true, - "selected_commit_type": "✨ Adding a new user-facing feature", + "selected_commit_type": "🎨 Improving UI", "emojis": { "initial_commit": "tada", "feature": "sparkles", From f46bd55245c0c99f9f3d7d8f2da3f0020ae232e9 Mon Sep 17 00:00:00 2001 From: Preet Shah Date: Thu, 26 Nov 2020 10:35:43 +0530 Subject: [PATCH 07/11] cli: time increased --- .gitgo | 2 +- lib/inquirer.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.gitgo b/.gitgo index 3264d7b..ccae0cc 100644 --- a/.gitgo +++ b/.gitgo @@ -12,7 +12,7 @@ "general:" ], "custom_guidelines": true, - "selected_commit_type": "🎨 Improving UI", + "selected_commit_type": "💥 Fixing a crash", "emojis": { "initial_commit": "tada", "feature": "sparkles", diff --git a/lib/inquirer.js b/lib/inquirer.js index 35b0f21..3ded011 100644 --- a/lib/inquirer.js +++ b/lib/inquirer.js @@ -44,12 +44,12 @@ module.exports = { var title = conf.current_issue.title console.log(emoji.get(':smiley_cat:'), chalk.bold('Github Issue Title:'), title) }) - }, 3000) + }, 4000) }) .then(() => { setTimeout(function () { recIssueType() - }, 4000) + }, 5000) }) .catch(error => { if (error.isTtyError) { From e9ab2ee831a3ccc10fb5fdf578fdd75973cf1d7b Mon Sep 17 00:00:00 2001 From: Preet Shah Date: Thu, 26 Nov 2020 14:36:55 +0530 Subject: [PATCH 08/11] cli: commit suggestions update after issuetype --- .gitgo | 22 +++++++++++++--------- lib/funcs/commit-gen.js | 6 +++--- lib/issue.js | 8 ++++---- 3 files changed, 20 insertions(+), 16 deletions(-) diff --git a/.gitgo b/.gitgo index ccae0cc..5f63fa7 100644 --- a/.gitgo +++ b/.gitgo @@ -1,18 +1,20 @@ { "current_issue": { - "number": "22", + "number": "21", "labels": [ "cli", + "command", "enhancement" ], - "title": "Emoji top 3 recommendations" + "title": "Add cli commands for config and startup" }, "commit_guidelines": [ - "cli:", - "general:" + "fix:", + " feat:", + " chore:" ], - "custom_guidelines": true, - "selected_commit_type": "💥 Fixing a crash", + "custom_guidelines": false, + "selected_commit_type": "🎨 Improving UI", "emojis": { "initial_commit": "tada", "feature": "sparkles", @@ -31,15 +33,17 @@ "wip": "construction" }, "existing_branches": [ + "capitalizing-default-value", "commands", "fix-commit", "issuetype-rec", "main", - "readme" + "readme", + "recommendation-text-color" ], "current_branch": [ - "Emoji-recommendations" + "cli-commands" ], - "current_commit_message": "✨ cli: Emoji top 3 recommendations", + "current_commit_message": "🎨 feat: Add cli commands for config and startup", "use_emojis": true } \ No newline at end of file diff --git a/lib/funcs/commit-gen.js b/lib/funcs/commit-gen.js index a4f7765..68323b3 100644 --- a/lib/funcs/commit-gen.js +++ b/lib/funcs/commit-gen.js @@ -5,8 +5,8 @@ const reader = require('./jsonReader'); stopwords = ['a', 'the']; module.exports = { - suggestCommitMsg: () => { - reader.jsonReader('./.gitgo', (err, conf) => { + suggestCommitMsg:() => { + setTimeout(()=>{reader.jsonReader('./.gitgo', (err, conf) => { if (err) { console.log(err) return @@ -204,6 +204,6 @@ module.exports = { fs.writeFile('./.gitgo', JSON.stringify(conf, null, 2), (err) => { if (err) console.log('Error writing file:', err) }) - }); + });},6000) } } diff --git a/lib/issue.js b/lib/issue.js index f1cb146..f4d3940 100644 --- a/lib/issue.js +++ b/lib/issue.js @@ -55,10 +55,10 @@ module.exports = { if (err) console.log('Error writing file:', err) }) }) - // setTimeout(function () { - // suggestCommitMsg(); - // branchName(); - // }, 1000); + setTimeout(function () { + suggestCommitMsg(); + branchName(); + }, 3000); // return (emoji.get(':smiley_cat:'), chalk.bold('Github Issue Title:'), titleOfIssue) }); } From 07eb61a0a0fbdf1b2bcb05830c13b1212c8f6089 Mon Sep 17 00:00:00 2001 From: agg-shambhavi Date: Thu, 26 Nov 2020 17:45:38 +0530 Subject: [PATCH 09/11] =?UTF-8?q?=F0=9F=90=9B=20cli:=20fix=20length=20of?= =?UTF-8?q?=20issue=20label=20array?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitgo | 24 +++++++----------------- lib/funcs/rec-iss-type.js | 35 ++++++++++++++++++++++++++++++++++- 2 files changed, 41 insertions(+), 18 deletions(-) diff --git a/.gitgo b/.gitgo index 5f63fa7..cac35df 100644 --- a/.gitgo +++ b/.gitgo @@ -1,12 +1,10 @@ { "current_issue": { - "number": "21", + "number": "41", "labels": [ - "cli", - "command", - "enhancement" + "bug" ], - "title": "Add cli commands for config and startup" + "title": "Fix commit message suggestion for standard template" }, "commit_guidelines": [ "fix:", @@ -14,7 +12,7 @@ " chore:" ], "custom_guidelines": false, - "selected_commit_type": "🎨 Improving UI", + "selected_commit_type": "🐎 Improving performance", "emojis": { "initial_commit": "tada", "feature": "sparkles", @@ -32,18 +30,10 @@ "cleanup": "fire", "wip": "construction" }, - "existing_branches": [ - "capitalizing-default-value", - "commands", - "fix-commit", - "issuetype-rec", - "main", - "readme", - "recommendation-text-color" - ], + "existing_branches": [], "current_branch": [ - "cli-commands" + "message-suggestion" ], - "current_commit_message": "🎨 feat: Add cli commands for config and startup", + "current_commit_message": "🐎 chore: Fix commit message suggestion for standard template", "use_emojis": true } \ No newline at end of file diff --git a/lib/funcs/rec-iss-type.js b/lib/funcs/rec-iss-type.js index 6a24377..0dd2852 100644 --- a/lib/funcs/rec-iss-type.js +++ b/lib/funcs/rec-iss-type.js @@ -11,7 +11,40 @@ module.exports = { return } - var issue_labels = conf.current_issue.labels; + var issue_labels_raw = conf.current_issue.labels; + if(issue_labels_raw.length > 1){ + console.log('inside if'); + var element = issue_labels_raw[issue_labels_raw.length - 1]; + while(issue_labels_raw.length > 1){ + console.log('inside while loop',issue_labels_raw); + 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]; + console.log('before break',issue_labels); + break; + } + else{ + issue_labels_raw.pop(element); + console.log('after popping',issue_labels_raw); + element = issue_labels_raw[issue_labels_raw.length - 1]; + } + } + if (issue_labels_raw.length == 1){ + var issue_labels = issue_labels_raw; + console.log('inside last if',issue_labels); + } + } + else{ + var issue_labels = issue_labels_raw; + console.log('inside else',issue_labels); + } for (let i = 0; i < issue_labels.length; i++) { if (issue_labels[i] === 'enhancement') { From 95728dfa3c4eb9d676241f6b7342207687bc8e2d Mon Sep 17 00:00:00 2001 From: Preet Shah Date: Thu, 26 Nov 2020 17:50:21 +0530 Subject: [PATCH 10/11] cli: removed excess console.logs --- .gitgo | 20 +++++++++++++------- lib/funcs/rec-iss-type.js | 6 ------ 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/.gitgo b/.gitgo index cac35df..1f64f94 100644 --- a/.gitgo +++ b/.gitgo @@ -1,10 +1,11 @@ { "current_issue": { - "number": "41", + "number": "22", "labels": [ - "bug" + "cli", + "enhancement" ], - "title": "Fix commit message suggestion for standard template" + "title": "Emoji top 3 recommendations" }, "commit_guidelines": [ "fix:", @@ -12,7 +13,7 @@ " chore:" ], "custom_guidelines": false, - "selected_commit_type": "🐎 Improving performance", + "selected_commit_type": "✨ Adding a new user-facing feature", "emojis": { "initial_commit": "tada", "feature": "sparkles", @@ -30,10 +31,15 @@ "cleanup": "fire", "wip": "construction" }, - "existing_branches": [], + "existing_branches": [ + "issuetype-rec", + "main", + "notice", + "readme" + ], "current_branch": [ - "message-suggestion" + "Emoji-recommendations" ], - "current_commit_message": "🐎 chore: Fix commit message suggestion for standard template", + "current_commit_message": "✨ feat: Emoji top 3 recommendations", "use_emojis": true } \ No newline at end of file diff --git a/lib/funcs/rec-iss-type.js b/lib/funcs/rec-iss-type.js index 0dd2852..d869867 100644 --- a/lib/funcs/rec-iss-type.js +++ b/lib/funcs/rec-iss-type.js @@ -13,10 +13,8 @@ module.exports = { var issue_labels_raw = conf.current_issue.labels; if(issue_labels_raw.length > 1){ - console.log('inside if'); var element = issue_labels_raw[issue_labels_raw.length - 1]; while(issue_labels_raw.length > 1){ - console.log('inside while loop',issue_labels_raw); if (element == 'bug' || element == 'enhancement' || element == 'help wanted' || @@ -27,23 +25,19 @@ module.exports = { element == 'documentation' || element == 'wontfix' ){ var issue_labels = [element]; - console.log('before break',issue_labels); break; } else{ issue_labels_raw.pop(element); - console.log('after popping',issue_labels_raw); element = issue_labels_raw[issue_labels_raw.length - 1]; } } if (issue_labels_raw.length == 1){ var issue_labels = issue_labels_raw; - console.log('inside last if',issue_labels); } } else{ var issue_labels = issue_labels_raw; - console.log('inside else',issue_labels); } for (let i = 0; i < issue_labels.length; i++) { From ad7c4d7293ee1bb33e8cfa85708fc1cc585b4719 Mon Sep 17 00:00:00 2001 From: Preet Shah Date: Thu, 26 Nov 2020 17:52:45 +0530 Subject: [PATCH 11/11] :sparkles: cli: testing code --- .gitgo | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.gitgo b/.gitgo index 1f64f94..2673d96 100644 --- a/.gitgo +++ b/.gitgo @@ -1,11 +1,11 @@ { "current_issue": { - "number": "22", + "number": "20", "labels": [ "cli", "enhancement" ], - "title": "Emoji top 3 recommendations" + "title": "Add branch name & commit message suggestions " }, "commit_guidelines": [ "fix:", @@ -13,7 +13,7 @@ " chore:" ], "custom_guidelines": false, - "selected_commit_type": "✨ Adding a new user-facing feature", + "selected_commit_type": "🐎 Improving performance", "emojis": { "initial_commit": "tada", "feature": "sparkles", @@ -38,8 +38,10 @@ "readme" ], "current_branch": [ - "Emoji-recommendations" + "branch-name", + "branch-name", + "message-suggestions" ], - "current_commit_message": "✨ feat: Emoji top 3 recommendations", + "current_commit_message": "🐎 chore: Add branch name & commit message suggestions ", "use_emojis": true } \ No newline at end of file