From 943ce37623a794bcd70ea5355d7e7ab64b20b2a9 Mon Sep 17 00:00:00 2001
From: MikeWallaceDev <mike@wallacehub.com>
Date: Mon, 25 Jul 2022 10:48:24 -0400
Subject: [PATCH 1/6] feat: remove commitlint and node.js dependency

---
 commitlint.config.js                    | 24 ---------------
 frontend/Makefile.toml                  |  1 -
 frontend/scripts/makefile/githooks.toml | 39 -------------------------
 package.json                            |  6 ----
 4 files changed, 70 deletions(-)
 delete mode 100644 commitlint.config.js
 delete mode 100644 frontend/scripts/makefile/githooks.toml
 delete mode 100644 package.json

diff --git a/commitlint.config.js b/commitlint.config.js
deleted file mode 100644
index c59a378e48..0000000000
--- a/commitlint.config.js
+++ /dev/null
@@ -1,24 +0,0 @@
-// module.exports = {extends: ['@commitlint/config-conventional']}
-module.exports = {
-    rules: {
-        'header-max-length': [2, 'always', 100],
-
-        'type-enum': [2, 'always', ['build', 'chore', 'ci', 'docs', 'feat', 'feature', 'fix', 'refactor', 'style', 'test']],
-        'type-empty': [2, 'never'],
-        'type-case': [2, 'always', 'lower-case'],
-
-        'subject-empty': [2, 'never'],
-        'subject-case': [
-            0,
-            'never',
-            ['sentence-case', 'start-case', 'pascal-case', 'upper-case'],
-        ],
-
-        'body-leading-blank': [2, 'always'],
-        'body-max-line-length': [2, 'always', 200],
-        'body-case': [0, 'never', []],
-
-        'footer-leading-blank': [1, 'always'],
-        'footer-max-line-length': [2, 'always', 100]
-    },
-};
diff --git a/frontend/Makefile.toml b/frontend/Makefile.toml
index 7449bfeef3..337b9efd76 100644
--- a/frontend/Makefile.toml
+++ b/frontend/Makefile.toml
@@ -8,7 +8,6 @@ extend = [
     { path = "scripts/makefile/env.toml" },
     { path = "scripts/makefile/flutter.toml" },
     { path = "scripts/makefile/tool.toml" },
-    { path = "scripts/makefile/githooks.toml" },
 ]
 
 [config]
diff --git a/frontend/scripts/makefile/githooks.toml b/frontend/scripts/makefile/githooks.toml
deleted file mode 100644
index f6b066ec49..0000000000
--- a/frontend/scripts/makefile/githooks.toml
+++ /dev/null
@@ -1,39 +0,0 @@
-[tasks.install-commitlint.mac]
-script = [
-    """
-    brew install npm
-    npm install @commitlint/cli @commitlint/config-conventional --save-dev
-
-    git config core.hooksPath .githooks
-    """,
-]
-script_runner = "@shell"
-
-[tasks.install-commitlint.windows]
-script = [
-    """
-    echo "WIP"
-
-    git config core.hooksPath .githooks
-    """,
-]
-script_runner = "@duckscript"
-
-[tasks.install-commitlint.linux]
-script = [
-    """
-    if command -v apt &> /dev/null
-    then
-      echo "Installing node.js (sudo apt install nodejs)"
-      sudo apt install nodejs
-    else
-    echo "Installing node.js (sudo pacman -S nodejs)"
-      sudo pacman -S nodejs
-    fi
-
-    npm install @commitlint/cli @commitlint/config-conventional --save-dev
-
-    git config core.hooksPath .githooks
-    """,
-]
-script_runner = "@shell"
diff --git a/package.json b/package.json
deleted file mode 100644
index 0f6a7fcafe..0000000000
--- a/package.json
+++ /dev/null
@@ -1,6 +0,0 @@
-{
-  "devDependencies": {
-    "@commitlint/cli": "^16.1.0",
-    "@commitlint/config-conventional": "^16.0.0"
-  }
-}

From f993e1d076b05f0bed3bc5231eca4aede9e73019 Mon Sep 17 00:00:00 2001
From: MikeWallaceDev <mike@wallacehub.com>
Date: Mon, 25 Jul 2022 12:02:33 -0400
Subject: [PATCH 2/6] feat: add gitlint dependency

---
 .githooks/commit-msg                              |  9 ++++++++-
 .gitignore                                        |  3 +++
 frontend/scripts/install_dev_env/install_linux.sh | 12 ++++++++++--
 frontend/scripts/install_dev_env/install_macos.sh | 11 +++++++----
 4 files changed, 28 insertions(+), 7 deletions(-)

diff --git a/.githooks/commit-msg b/.githooks/commit-msg
index 24cd55c6b6..cf50d88f35 100755
--- a/.githooks/commit-msg
+++ b/.githooks/commit-msg
@@ -16,7 +16,14 @@ test "" = "$(grep '^Signed-off-by: ' "$1" |
 	exit 1
 }
 
-npx --no -- commitlint --edit $1
+.githooks/gitlint \
+	 --msg-file=$1 \
+	 --subject-regex="^([bB]uild|[cC]hore|[cC]i|[dD]ocs|[fF]eat|[fF]eature|[fF]ix|[pP]erf|[rR]efactor|[rR]evert|[sS]tyle|[tT]est)(.*)?\s?:\s?.*" \
+    --subject-maxlen=100 \
+    --subject-minlen=10 \
+    --body-regex=".*" \
+    --body-maxlen=200 \
+    --max-parents=1
 
 if [ $? -ne 0 ]
 then
diff --git a/.gitignore b/.gitignore
index c956a0ad13..b4bd54c6be 100644
--- a/.gitignore
+++ b/.gitignore
@@ -32,3 +32,6 @@ frontend/.vscode/*
 # Commit the highest level pubspec.lock, but ignore the others
 pubspec.lock
 !frontend/app_flowy/pubspec.lock
+
+# ignore tool used for commit linting
+.githooks/gitlint
diff --git a/frontend/scripts/install_dev_env/install_linux.sh b/frontend/scripts/install_dev_env/install_linux.sh
index a580c22b19..eafc15ae98 100755
--- a/frontend/scripts/install_dev_env/install_linux.sh
+++ b/frontend/scripts/install_dev_env/install_linux.sh
@@ -50,6 +50,13 @@ flutter doctor
 printMessage "Setting up githooks."
 git config core.hooksPath .githooks
 
+# Install go-gitlint 
+printMessage "Installing go-gitlint."
+GOLINT_FILENAME="go-gitlint_1.1.0_linux_x86_64.tar.gz"
+wget https://github.com/llorllale/go-gitlint/releases/download/1.1.0/${GOLINT_FILENAME}
+tar -zxv --directory .githooks/. -f ${GOLINT_FILENAME} gitlint 
+rm ${GOLINT_FILENAME}
+
 # Change to the frontend directory
 cd frontend
 
@@ -62,8 +69,9 @@ printMessage "Installing duckscript."
 cargo install --force duckscript_cli
 
 # Install CommitLint
-printMessage "Installing CommitLint."
-npm install @commitlint/cli @commitlint/config-conventional --save-dev
+printMessage "Installing go-gitlint."
+wget https://github.com/llorllale/go-gitlint/releases/download/1.1.0/go-gitlint_1.1.0_linux_x86_64.tar.gz
+tar -xf go-gitlint_1.1.0_linux_x86_64.tar.gz - C
 
 # Check prerequisites
 printMessage "Checking prerequisites."
diff --git a/frontend/scripts/install_dev_env/install_macos.sh b/frontend/scripts/install_dev_env/install_macos.sh
index edc0c40b26..26a2e5da02 100755
--- a/frontend/scripts/install_dev_env/install_macos.sh
+++ b/frontend/scripts/install_dev_env/install_macos.sh
@@ -50,6 +50,13 @@ flutter doctor
 printMessage "Setting up githooks."
 git config core.hooksPath .githooks
 
+# Install go-gitlint 
+printMessage "Installing go-gitlint."
+GOLINT_FILENAME="go-gitlint_1.1.0_osx_x86_64.tar.gz"
+wget https://github.com/llorllale/go-gitlint/releases/download/1.1.0/${GOLINT_FILENAME}
+tar -zxv --directory .githooks/. -f ${GOLINT_FILENAME} gitlint 
+rm ${GOLINT_FILENAME}
+
 # Change to the frontend directory
 cd frontend
 
@@ -61,10 +68,6 @@ cargo install --force cargo-make
 printMessage "Installing duckscript."
 cargo install --force duckscript_cli
 
-# Install CommitLint
-printMessagae "Installing CommitLint."
-npm install @commitlint/cli @commitlint/config-conventional --save-dev
-
 # Check prerequisites
 printMessage "Checking prerequisites."
 cargo make flowy_dev

From c45e4515bb975fdcc18c2c706c337930dacd2296 Mon Sep 17 00:00:00 2001
From: MikeWallaceDev <mike@wallacehub.com>
Date: Mon, 25 Jul 2022 12:20:55 -0400
Subject: [PATCH 3/6] feat: Improved commit githooks messages

---
 .githooks/commit-msg | 22 ++++++++++++++++++++--
 .githooks/pre-commit | 19 ++++++++++++++++++-
 .githooks/pre-push   | 30 ++++++++++++++++++++++++------
 3 files changed, 62 insertions(+), 9 deletions(-)

diff --git a/.githooks/commit-msg b/.githooks/commit-msg
index cf50d88f35..c2cd09aecf 100755
--- a/.githooks/commit-msg
+++ b/.githooks/commit-msg
@@ -6,7 +6,24 @@
 # status after issuing an appropriate message if it wants to stop the
 # commit.  The hook is allowed to edit the commit message file.
 
-echo "Running the AppFlowy commit-msg hook."
+YELLOW="\e[93m"
+GREEN="\e[32m"
+RED="\e[31m"
+ENDCOLOR="\e[0m"
+
+printMessage() {
+   printf "${YELLOW}AppFlowy : $1${ENDCOLOR}\n"
+}
+
+printSuccess() {
+   printf "${GREEN}AppFlowy : $1${ENDCOLOR}\n"
+}
+
+printError() {
+   printf "${RED}AppFlowy : $1${ENDCOLOR}\n"
+}
+
+printMessage "Running the AppFlowy commit-msg hook."
 
 # This example catches duplicate Signed-off-by lines.
 
@@ -27,7 +44,8 @@ test "" = "$(grep '^Signed-off-by: ' "$1" |
 
 if [ $? -ne 0 ]
 then
-    echo "Please fix your commit message to match AppFlowy coding standards"
+    printError "Please fix your commit message to match AppFlowy coding standards"
+    printError "https://appflowy.gitbook.io/docs/essential-documentation/contribute-to-appflowy/software-contributions/submitting-code/style-guides"
     exit 1
 fi
 
diff --git a/.githooks/pre-commit b/.githooks/pre-commit
index d27345fe71..be42c93834 100755
--- a/.githooks/pre-commit
+++ b/.githooks/pre-commit
@@ -1,6 +1,23 @@
 #!/usr/bin/env bash
 
-echo "Running local AppFlowy pre-commit hook."
+YELLOW="\e[93m"
+GREEN="\e[32m"
+RED="\e[31m"
+ENDCOLOR="\e[0m"
+
+printMessage() {
+   printf "${YELLOW}AppFlowy : $1${ENDCOLOR}\n"
+}
+
+printSuccess() {
+   printf "${GREEN}AppFlowy : $1${ENDCOLOR}\n"
+}
+
+printError() {
+   printf "${RED}AppFlowy : $1${ENDCOLOR}\n"
+}
+
+printMessage "Running local AppFlowy pre-commit hook."
 
 #flutter format .
 ##https://gist.github.com/benmccallum/28e4f216d9d72f5965133e6c43aaff6e
diff --git a/.githooks/pre-push b/.githooks/pre-push
index ad7d19a16e..7b6eeb8bc1 100755
--- a/.githooks/pre-push
+++ b/.githooks/pre-push
@@ -1,23 +1,41 @@
 #!/usr/bin/env bash
 
-echo "Running local AppFlowy pre-push hook."
+YELLOW="\e[93m"
+GREEN="\e[32m"
+RED="\e[31m"
+ENDCOLOR="\e[0m"
+
+printMessage() {
+   printf "${YELLOW}AppFlowy : $1${ENDCOLOR}\n"
+}
+
+printSuccess() {
+   printf "${GREEN}AppFlowy : $1${ENDCOLOR}\n"
+}
+
+printError() {
+   printf "${RED}AppFlowy : $1${ENDCOLOR}\n"
+}
+
+printMessage "Running local AppFlowy pre-push hook."
 
 if [[ `git status --porcelain` ]]; then
-  printf "\e[31;1m%s\e[0m\n" 'This script needs to run against committed code only. Please commit or stash you changes.'
+  printError "This script needs to run against committed code only. Please commit or stash you changes."
   exit 1
 fi
 
-printf "\e[33;1m%s\e[0m\n" 'Running the Flutter analyzer'
+printMessage "Running the Flutter analyzer"
 flutter analyze
 
 if [ $? -ne 0 ]; then
-  printf "\e[31;1m%s\e[0m\n" 'Flutter analyzer error'
+  printError "Flutter analyzer error"
   exit 1
 fi
 
-printf "\e[33;1m%s\e[0m\n" 'Finished running the Flutter analyzer'
-printf "\e[33;1m%s\e[0m\n" 'Running unit tests'
+printMessage "Finished running the Flutter analyzer"
 
+
+#printMessage "Running unit tests"
 #flutter test
 #if [ $? -ne 0 ]; then
 #  printf "\e[31;1m%s\e[0m\n" 'Unit tests error'

From db2a27384505e5f9f414f98f38ab70d07e0a0352 Mon Sep 17 00:00:00 2001
From: MikeWallaceDev <mike@wallacehub.com>
Date: Mon, 25 Jul 2022 12:44:54 -0400
Subject: [PATCH 4/6] fix: put back commintlint config because the server will
 need it

---
 commitlint.config.js | 25 +++++++++++++++++++++++++
 1 file changed, 25 insertions(+)
 create mode 100644 commitlint.config.js

diff --git a/commitlint.config.js b/commitlint.config.js
new file mode 100644
index 0000000000..1e1af55752
--- /dev/null
+++ b/commitlint.config.js
@@ -0,0 +1,25 @@
+// module.exports = {extends: ['@commitlint/config-conventional']}
+module.exports = {
+    rules: {
+        'header-max-length': [2, 'always', 100],
+
+        'type-enum': [2, 'always', ['build', 'chore', 'ci', 'docs', 'feat', 'feature', 'fix', 'refactor', 'style', 'test']],
+        'type-empty': [2, 'never'],
+        'type-case': [2, 'always', 'lower-case'],
+
+        'subject-empty': [2, 'never'],
+        'subject-case': [
+            0,
+            'never',
+            ['sentence-case', 'start-case', 'pascal-case', 'upper-case'],
+        ],
+
+        'body-leading-blank': [2, 'always'],
+        'body-max-line-length': [2, 'always', 200],
+        'body-case': [0, 'never', []],
+
+        'footer-leading-blank': [1, 'always'],
+        'footer-max-line-length': [2, 'always', 100]
+    },
+};
+

From 30db03f3dfb4942218f9b695e01170bfc3e28feb Mon Sep 17 00:00:00 2001
From: MikeWallaceDev <mike@wallacehub.com>
Date: Mon, 25 Jul 2022 12:48:51 -0400
Subject: [PATCH 5/6] fix: made the regex match commitlint more closely

---
 .githooks/commit-msg | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/.githooks/commit-msg b/.githooks/commit-msg
index c2cd09aecf..48a347456b 100755
--- a/.githooks/commit-msg
+++ b/.githooks/commit-msg
@@ -35,7 +35,7 @@ test "" = "$(grep '^Signed-off-by: ' "$1" |
 
 .githooks/gitlint \
 	 --msg-file=$1 \
-	 --subject-regex="^([bB]uild|[cC]hore|[cC]i|[dD]ocs|[fF]eat|[fF]eature|[fF]ix|[pP]erf|[rR]efactor|[rR]evert|[sS]tyle|[tT]est)(.*)?\s?:\s?.*" \
+	 --subject-regex="^(build|chore|ci|docs|feat|feature|fix|perf|refactor|revert|style|test)(.*)?:\s?.*" \
     --subject-maxlen=100 \
     --subject-minlen=10 \
     --body-regex=".*" \

From 244549b1672f6642d9f6cf6095a3d4d86c0830cd Mon Sep 17 00:00:00 2001
From: MikeWallaceDev <mike@wallacehub.com>
Date: Mon, 25 Jul 2022 13:37:58 -0400
Subject: [PATCH 6/6] fix: bah! removing duplicate code.

---
 frontend/scripts/install_dev_env/install_linux.sh | 5 -----
 1 file changed, 5 deletions(-)

diff --git a/frontend/scripts/install_dev_env/install_linux.sh b/frontend/scripts/install_dev_env/install_linux.sh
index eafc15ae98..396a66cd63 100755
--- a/frontend/scripts/install_dev_env/install_linux.sh
+++ b/frontend/scripts/install_dev_env/install_linux.sh
@@ -68,11 +68,6 @@ cargo install --force cargo-make
 printMessage "Installing duckscript."
 cargo install --force duckscript_cli
 
-# Install CommitLint
-printMessage "Installing go-gitlint."
-wget https://github.com/llorllale/go-gitlint/releases/download/1.1.0/go-gitlint_1.1.0_linux_x86_64.tar.gz
-tar -xf go-gitlint_1.1.0_linux_x86_64.tar.gz - C
-
 # Check prerequisites
 printMessage "Checking prerequisites."
 cargo make flowy_dev