From 5aa53330a63251a3fe717f94a5503f6a292023ec Mon Sep 17 00:00:00 2001 From: Yash Khare Date: Fri, 27 Nov 2020 17:54:43 +0530 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=9A=80=20cli:=20Empty=20specific=20at?= =?UTF-8?q?tributes=20from=20.gitgo=20before=20pushing=20it=20on=20github?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 🚀 cli: Empty specific attributes from .gitgo before pushing it on github --- .gitgo | 18 ++++++++++-------- bin/index.js | 48 ++++++++++++++++++++++++++++++++++++++++++++++-- lib/inquirer.js | 2 ++ 3 files changed, 58 insertions(+), 10 deletions(-) diff --git a/.gitgo b/.gitgo index 4933d3a..ea16922 100644 --- a/.gitgo +++ b/.gitgo @@ -1,18 +1,18 @@ { "current_issue": { - "number": "51", + "number": "53", "labels": [ "cli", - "command", "enhancement" ], - "title": "Add a command to give summary of all instructions" + "title": "Empty specific attributes from .gitgo before pushing it on github" }, "commit_guidelines": [ - "cli:" + "cli:", + "general:" ], "custom_guidelines": true, - "selected_commit_type": "✨ Adding a new user-facing feature", + "selected_commit_type": "🚀 Improving dev tools", "emojis": { "initial_commit": "tada", "feature": "sparkles", @@ -31,11 +31,13 @@ "wip": "construction" }, "existing_branches": [ + "command-summary-instructions", "main" ], "current_branch": [ - "command-summary-instructions" + "Empty-attributes-github" ], - "current_commit_message": "✨ cli: Add a command to give summary of all instructions", - "use_emojis": true + "current_commit_message": "🚀 cli: Empty specific attributes from .gitgo before pushing it on github", + "use_emojis": true, + "commit_config": false } \ No newline at end of file diff --git a/bin/index.js b/bin/index.js index d863c7f..aaa51ce 100755 --- a/bin/index.js +++ b/bin/index.js @@ -15,6 +15,8 @@ const git = simpleGit(); const { jsonReader } = require("../lib/funcs/jsonReader.js"); const version = require("../package.json"); const chalk = require("chalk"); +const { exec } = require("child_process"); +const fs = require("fs"); clear(); @@ -151,8 +153,50 @@ program return; } cMsg = conf.current_commit_message; - git.commit(cMsg); - console.log("Files have be commited: " + cMsg); + if (conf.commit_config) { + conf.commit_config = false; + conf.current_commit_message = ""; + conf.current_branch = [""]; + conf.existing_branches = [""]; + conf.selected_commit_type = ""; + conf.current_issue.number = ""; + conf.current_issue.labels = [""]; + conf.current_issue.title = ""; + fs.writeFile( + "./.gitgo", + JSON.stringify(conf, null, 2), + (err) => { + if (err) console.log("Error writing file:", err); + } + ); + setTimeout(function () { + exec("git add ./.gitgo", (error, stdout, stderr) => { + if (error) { + console.log(`error: ${error.message}`); + return; + } + if (stderr) { + console.log(`stderr: ${stderr}`); + return; + } + }); + git.commit(cMsg); + console.log("Files have be commited: " + cMsg); + }, 1000); + } else { + exec("git reset -- ./.gitgo", (error, stdout, stderr) => { + if (error) { + console.log(`error: ${error.message}`); + return; + } + if (stderr) { + console.log(`stderr: ${stderr}`); + return; + } + }); + git.commit(cMsg); + console.log("Files have be commited: " + cMsg); + } }); } else { // checks if the directory is a git based repo or not diff --git a/lib/inquirer.js b/lib/inquirer.js index 692c1e3..d79cc45 100644 --- a/lib/inquirer.js +++ b/lib/inquirer.js @@ -120,6 +120,7 @@ module.exports = { return; } conf.use_emojis = emo; + conf.commit_config = true; fs.writeFile( "./.gitgo", JSON.stringify(conf, null, 2), @@ -170,6 +171,7 @@ module.exports = { return; } conf.use_emojis = emo; + conf.commit_config = true; fs.writeFile( "./.gitgo", JSON.stringify(conf, null, 2), From c46c986cd96c66acf43c01ada9ae0c24725ce439 Mon Sep 17 00:00:00 2001 From: yashk2000 Date: Fri, 27 Nov 2020 12:41:45 +0000 Subject: [PATCH 2/2] :wrench: general: Fix linting with prettier --- bin/index.js | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/bin/index.js b/bin/index.js index aaa51ce..1a92cbd 100755 --- a/bin/index.js +++ b/bin/index.js @@ -162,22 +162,18 @@ program conf.current_issue.number = ""; conf.current_issue.labels = [""]; conf.current_issue.title = ""; - fs.writeFile( - "./.gitgo", - JSON.stringify(conf, null, 2), - (err) => { - if (err) console.log("Error writing file:", err); - } - ); + fs.writeFile("./.gitgo", JSON.stringify(conf, null, 2), (err) => { + if (err) console.log("Error writing file:", err); + }); setTimeout(function () { exec("git add ./.gitgo", (error, stdout, stderr) => { if (error) { - console.log(`error: ${error.message}`); - return; + console.log(`error: ${error.message}`); + return; } if (stderr) { - console.log(`stderr: ${stderr}`); - return; + console.log(`stderr: ${stderr}`); + return; } }); git.commit(cMsg); @@ -186,12 +182,12 @@ program } else { exec("git reset -- ./.gitgo", (error, stdout, stderr) => { if (error) { - console.log(`error: ${error.message}`); - return; + console.log(`error: ${error.message}`); + return; } if (stderr) { - console.log(`stderr: ${stderr}`); - return; + console.log(`stderr: ${stderr}`); + return; } }); git.commit(cMsg);