From eb038a34a75fd005c31cd5339bae2c410bc2dcf0 Mon Sep 17 00:00:00 2001 From: Arsalan Khattak Date: Tue, 18 Apr 2023 15:50:02 +0500 Subject: [PATCH 1/5] =?UTF-8?q?=F0=9F=90=9B=20fix:=20github=20action=20-?= =?UTF-8?q?=20lint?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/lint.yml | 9 ++++----- package.json | 3 ++- src/cli.js | 20 ++++++++++---------- src/commands.js | 10 +++++----- src/helper.js | 2 +- 5 files changed, 22 insertions(+), 22 deletions(-) diff --git a/.github/lint.yml b/.github/lint.yml index db4d586..48f9fa7 100644 --- a/.github/lint.yml +++ b/.github/lint.yml @@ -1,11 +1,10 @@ +name: linter on: - push: - branches: - - master - - main pull_request: branches: - - "*" + - main + - master + jobs: build: runs-on: ubuntu-latest diff --git a/package.json b/package.json index d7610c1..d7a5e16 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,8 @@ "description": "A minimalist approach toward git commits to keep things simple.", "main": "./bin/index.js", "scripts": { - "lint": "eslint ." + "lint": "eslint .", + "fix": "eslint . --fix" }, "bin": { "mct": "bin/index.js" diff --git a/src/cli.js b/src/cli.js index 7390c32..93af4f3 100644 --- a/src/cli.js +++ b/src/cli.js @@ -6,17 +6,17 @@ import { getStagedFiles, checkIfRepoisGit, getUnstagedFiles, - stageFiles, + stageFiles } from "./commands.js"; -function logOption(title, description) { +function logOption (title, description) { return chalk.bgWhite(title) + " - " + description; } -async function cli() { +async function cli () { const [isGit, stagedFiles] = await Promise.all([ checkIfRepoisGit(), - getStagedFiles(), + getStagedFiles() ]); if (isGit && !stagedFiles) { await promptToCommit(); @@ -68,8 +68,8 @@ const promptToCommit = async () => { message: "Select the files you want to add with, and use (CTRL + D to exit)", type: "checkbox", - choices: styledList, - }, + choices: styledList + } ]) .then((answer) => { if (answer.list.length < 1) { @@ -118,14 +118,14 @@ const addCommit = async () => { "📝 docs", "🎨 style", "🛠 config", - "📦 misc", - ], + "📦 misc" + ] }, { name: "message", message: "Write a commit message ✍️ : ", - type: "input", - }, + type: "input" + } ]) .then((answer) => { const message = `${answer.type}: ${answer.message}`; diff --git a/src/commands.js b/src/commands.js index 2af3c58..9f07b91 100644 --- a/src/commands.js +++ b/src/commands.js @@ -2,7 +2,7 @@ import { exec } from "child_process"; import chalk from "chalk"; import { logExec } from "./helper.js"; -export function checkIfRepoisGit() { +export function checkIfRepoisGit () { return new Promise((resolve, reject) => { exec("git rev-parse --is-inside-work-tree", (err, stdout, stderr) => { if (stdout == "true\n") resolve(stdout); @@ -31,7 +31,7 @@ export function checkIfRepoisGit() { }); } -export async function getStagedFiles() { +export async function getStagedFiles () { return new Promise((resolve, reject) => { exec("git diff --cached --name-only", (err, stdout, stderr) => { if (err) { @@ -53,7 +53,7 @@ export async function getStagedFiles() { }); } -export function commitFiles(message) { +export function commitFiles (message) { exec(`git commit -m "${message}"`, (err, stdout, stderr) => { if (err) { logExec(err); @@ -67,7 +67,7 @@ export function commitFiles(message) { }); } -export async function getUnstagedFiles() { +export async function getUnstagedFiles () { return new Promise((resolve, reject) => { exec("git status --porcelain", (err, stdout, stderr) => { if (err) { @@ -84,7 +84,7 @@ export async function getUnstagedFiles() { }); } -export async function stageFiles(files) { +export async function stageFiles (files) { return new Promise((resolve, reject) => { exec(`git add ${files}`, (err, stdout, stderr) => { if (err) { diff --git a/src/helper.js b/src/helper.js index bc94cd2..90ed07e 100644 --- a/src/helper.js +++ b/src/helper.js @@ -1,6 +1,6 @@ import chalk from "chalk"; -export function logExec(message) { +export function logExec (message) { console.log("\n\n"); console.log(chalk.bgRed("⛔️ Whops! Something went wrong. Try again!")); console.log(message); From 3a413f67032b425b55e9600707e745f4ac677a14 Mon Sep 17 00:00:00 2001 From: Arsalan Khattak Date: Tue, 18 Apr 2023 15:50:19 +0500 Subject: [PATCH 2/5] Test --- .github/{ => workflows}/lint.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/{ => workflows}/lint.yml (100%) diff --git a/.github/lint.yml b/.github/workflows/lint.yml similarity index 100% rename from .github/lint.yml rename to .github/workflows/lint.yml From 15755c109608de33aeb9df2b3a2e6c06f64f2a13 Mon Sep 17 00:00:00 2001 From: Arsalan Khattak Date: Tue, 18 Apr 2023 15:58:28 +0500 Subject: [PATCH 3/5] add runs --- .github/workflows/lint.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 48f9fa7..4cea961 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -9,6 +9,8 @@ jobs: build: runs-on: ubuntu-latest + runs: + using: "node16" steps: - uses: actions/checkout@v2 From bf10e7cfe9643ba01c48d009d37b64fa747dcb3f Mon Sep 17 00:00:00 2001 From: Arsalan Khattak Date: Tue, 18 Apr 2023 15:59:12 +0500 Subject: [PATCH 4/5] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d0d1f9c..e1db517 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ > _A minimalist approach toward `git commit` to keep commits simple._ -## What is Minimal Commit? +## What is Minimal Commit?? Minimal commit is a Node.js based CLI (command line interface) tool that helps you and your team mates to stay consistent with the `git commit` messages. To commit files using **Minimal Commit**, you have a list of options to choose from, this list consist type of work you did. This makes things simple and less confusing by choosing an option from a list. From f02af3176aad3d4e0f60cdd56718ad17d662ddf2 Mon Sep 17 00:00:00 2001 From: Arsalan Khattak Date: Tue, 18 Apr 2023 16:03:34 +0500 Subject: [PATCH 5/5] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e1db517..09b397f 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,7 @@ Minimal commit is a Node.js based CLI (command line interface) tool that helps y The list of options is limited to only **nine types**. This is done on purpose to keep the list as short as possible to avoid confusion. The more options you have, the more confusing it will be. ## Types -Following are the nine types of commits. +Following are the nine types of commits.ss - `✨ feat` to be used for a new feature - `🐛 fix` to be used for bug fixes - `💥 break` to be used for breaking changes