From a65d4257a5419fc6d99bfc43c269dcab656bc9f3 Mon Sep 17 00:00:00 2001 From: Mihajlo Date: Tue, 10 May 2022 12:32:05 +0200 Subject: [PATCH 1/6] chore: running lint as pre-commit hook --- .git-hooks/pre-commit | 5 +++++ package.json | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100755 .git-hooks/pre-commit diff --git a/.git-hooks/pre-commit b/.git-hooks/pre-commit new file mode 100755 index 0000000..8f1c776 --- /dev/null +++ b/.git-hooks/pre-commit @@ -0,0 +1,5 @@ +#!/bin/sh + +npm run --silent lint:fix + +exit 0 \ No newline at end of file diff --git a/package.json b/package.json index 2be4b9a..02f528b 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "build": "rimraf build && rimraf node && mkdir node && copyfiles -u 1 \"./src/**/*\" ./node && webpack && rimraf build/src && rimraf node", "package:lib": "npm run build && copyfiles ./package.json ./checkNodeVersion.js build && cd build && npm version \"5.0.0\" && npm pack", "publish:lib": "npm run build && cd build && npm publish", - "lint:fix": "npx prettier --write \"src/**/*.{ts,tsx,js,jsx,html,css,sass,less,json,yml,md,graphql}\" && npx prettier --write \"sasjs-tests/src/**/*.{ts,tsx,js,jsx,html,css,sass,less,json,yml,md,graphql}\"", + "lint:fix": "npx prettier --loglevel silent --write \"src/**/*.{ts,tsx,js,jsx,html,css,sass,less,json,yml,md,graphql}\" && npx prettier --loglevel silent --write \"sasjs-tests/src/**/*.{ts,tsx,js,jsx,html,css,sass,less,json,yml,md,graphql}\"", "lint": "npx prettier --check \"src/**/*.{ts,tsx,js,jsx,html,css,sass,less,json,yml,md,graphql}\" && npx prettier --check \"sasjs-tests/src/**/*.{ts,tsx,js,jsx,html,css,sass,less,json,yml,md,graphql}\"", "test": "jest --silent --coverage", "prepublishOnly": "cp -r ./build/* . && rm -rf ./build", From 8f309143e9ebffc768d7a342ac722c95f1deeb6b Mon Sep 17 00:00:00 2001 From: Mihajlo Date: Tue, 10 May 2022 12:37:50 +0200 Subject: [PATCH 2/6] chore: comment --- .git-hooks/pre-commit | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.git-hooks/pre-commit b/.git-hooks/pre-commit index 8f1c776..01016fa 100755 --- a/.git-hooks/pre-commit +++ b/.git-hooks/pre-commit @@ -1,5 +1,7 @@ #!/bin/sh +# We make this command run without printing to console, because if it does, it prevents `commit-msg` error to be shown when commiting +# trough VS Code npm run --silent lint:fix exit 0 \ No newline at end of file From 59e3edf4b3be5185ddf4e96df038e61560608bd0 Mon Sep 17 00:00:00 2001 From: Allan Bowe <4420615+allanbowe@users.noreply.github.com> Date: Tue, 10 May 2022 11:42:35 +0100 Subject: [PATCH 3/6] Update pre-commit --- .git-hooks/pre-commit | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.git-hooks/pre-commit b/.git-hooks/pre-commit index 01016fa..a7262ae 100755 --- a/.git-hooks/pre-commit +++ b/.git-hooks/pre-commit @@ -1,7 +1,6 @@ #!/bin/sh -# We make this command run without printing to console, because if it does, it prevents `commit-msg` error to be shown when commiting -# trough VS Code +# Silent mode prevents `commit-msg` err in log window npm run --silent lint:fix -exit 0 \ No newline at end of file +exit 0 From aebf4ea8d867652a728dcdc6a5643e1ff8d24a80 Mon Sep 17 00:00:00 2001 From: Allan Bowe <4420615+allanbowe@users.noreply.github.com> Date: Tue, 10 May 2022 12:22:40 +0100 Subject: [PATCH 4/6] Update pre-commit --- .git-hooks/pre-commit | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.git-hooks/pre-commit b/.git-hooks/pre-commit index a7262ae..ddec82b 100755 --- a/.git-hooks/pre-commit +++ b/.git-hooks/pre-commit @@ -1,6 +1,8 @@ #!/bin/sh -# Silent mode prevents `commit-msg` err in log window +# Using `--silent` helps for showing any errs in the first line of the response +# The first line is picked up by the VS Code GIT UI popup when rc is not 0 + npm run --silent lint:fix exit 0 From 63328163ab746efc23d7803be8fc7280ea5387b4 Mon Sep 17 00:00:00 2001 From: Mihajlo Date: Tue, 10 May 2022 14:09:41 +0200 Subject: [PATCH 5/6] chore: pre-push run lint --- .git-hooks/{pre-commit => pre-push} | 9 ++++++--- package.json | 3 ++- src/auth/AuthManager.ts | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) rename .git-hooks/{pre-commit => pre-push} (56%) diff --git a/.git-hooks/pre-commit b/.git-hooks/pre-push similarity index 56% rename from .git-hooks/pre-commit rename to .git-hooks/pre-push index ddec82b..6e79d5f 100755 --- a/.git-hooks/pre-commit +++ b/.git-hooks/pre-push @@ -3,6 +3,9 @@ # Using `--silent` helps for showing any errs in the first line of the response # The first line is picked up by the VS Code GIT UI popup when rc is not 0 -npm run --silent lint:fix - -exit 0 +if npm run --silent lint:silent ; then + exit 0 +else + echo "❌ Prettier check failed! Please run lint:fix." + exit 1 +fi diff --git a/package.json b/package.json index 02f528b..a88e5e1 100644 --- a/package.json +++ b/package.json @@ -8,8 +8,9 @@ "build": "rimraf build && rimraf node && mkdir node && copyfiles -u 1 \"./src/**/*\" ./node && webpack && rimraf build/src && rimraf node", "package:lib": "npm run build && copyfiles ./package.json ./checkNodeVersion.js build && cd build && npm version \"5.0.0\" && npm pack", "publish:lib": "npm run build && cd build && npm publish", - "lint:fix": "npx prettier --loglevel silent --write \"src/**/*.{ts,tsx,js,jsx,html,css,sass,less,json,yml,md,graphql}\" && npx prettier --loglevel silent --write \"sasjs-tests/src/**/*.{ts,tsx,js,jsx,html,css,sass,less,json,yml,md,graphql}\"", + "lint:fix": "npx prettier --write \"src/**/*.{ts,tsx,js,jsx,html,css,sass,less,json,yml,md,graphql}\" && npx prettier --loglevel silent --write \"sasjs-tests/src/**/*.{ts,tsx,js,jsx,html,css,sass,less,json,yml,md,graphql}\"", "lint": "npx prettier --check \"src/**/*.{ts,tsx,js,jsx,html,css,sass,less,json,yml,md,graphql}\" && npx prettier --check \"sasjs-tests/src/**/*.{ts,tsx,js,jsx,html,css,sass,less,json,yml,md,graphql}\"", + "lint:silent": "npx prettier --loglevel silent --check \"src/**/*.{ts,tsx,js,jsx,html,css,sass,less,json,yml,md,graphql}\" && npx prettier --check \"sasjs-tests/src/**/*.{ts,tsx,js,jsx,html,css,sass,less,json,yml,md,graphql}\"", "test": "jest --silent --coverage", "prepublishOnly": "cp -r ./build/* . && rm -rf ./build", "postpublish": "git clean -fd", diff --git a/src/auth/AuthManager.ts b/src/auth/AuthManager.ts index 5d69c94..e442291 100644 --- a/src/auth/AuthManager.ts +++ b/src/auth/AuthManager.ts @@ -171,7 +171,7 @@ export class AuthManager { if (isLoggedIn) { if (this.serverType === ServerType.Sas9) { - await this.performCASSecurityCheck() + await this.performCASSecurityCheck(); } this.loginCallback() From 29a65052dcc91c58a8c374ba3f127ef31f0cbcd3 Mon Sep 17 00:00:00 2001 From: Mihajlo Date: Tue, 10 May 2022 14:54:34 +0200 Subject: [PATCH 6/6] chore: pre commit hook --- .git-hooks/{pre-push => pre-commit} | 3 ++- package.json | 4 ++-- src/auth/AuthManager.ts | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) rename .git-hooks/{pre-push => pre-commit} (66%) diff --git a/.git-hooks/pre-push b/.git-hooks/pre-commit similarity index 66% rename from .git-hooks/pre-push rename to .git-hooks/pre-commit index 6e79d5f..0232fdd 100755 --- a/.git-hooks/pre-push +++ b/.git-hooks/pre-commit @@ -6,6 +6,7 @@ if npm run --silent lint:silent ; then exit 0 else - echo "❌ Prettier check failed! Please run lint:fix." + npm run --silent lint:fix + echo "❌ Prettier check failed! We ran lint:fix for you. Please add & commit again." exit 1 fi diff --git a/package.json b/package.json index a88e5e1..0edb94d 100644 --- a/package.json +++ b/package.json @@ -8,9 +8,9 @@ "build": "rimraf build && rimraf node && mkdir node && copyfiles -u 1 \"./src/**/*\" ./node && webpack && rimraf build/src && rimraf node", "package:lib": "npm run build && copyfiles ./package.json ./checkNodeVersion.js build && cd build && npm version \"5.0.0\" && npm pack", "publish:lib": "npm run build && cd build && npm publish", - "lint:fix": "npx prettier --write \"src/**/*.{ts,tsx,js,jsx,html,css,sass,less,json,yml,md,graphql}\" && npx prettier --loglevel silent --write \"sasjs-tests/src/**/*.{ts,tsx,js,jsx,html,css,sass,less,json,yml,md,graphql}\"", + "lint:fix": "npx prettier --loglevel silent --write \"src/**/*.{ts,tsx,js,jsx,html,css,sass,less,json,yml,md,graphql}\" && npx prettier --loglevel silent --write \"sasjs-tests/src/**/*.{ts,tsx,js,jsx,html,css,sass,less,json,yml,md,graphql}\"", "lint": "npx prettier --check \"src/**/*.{ts,tsx,js,jsx,html,css,sass,less,json,yml,md,graphql}\" && npx prettier --check \"sasjs-tests/src/**/*.{ts,tsx,js,jsx,html,css,sass,less,json,yml,md,graphql}\"", - "lint:silent": "npx prettier --loglevel silent --check \"src/**/*.{ts,tsx,js,jsx,html,css,sass,less,json,yml,md,graphql}\" && npx prettier --check \"sasjs-tests/src/**/*.{ts,tsx,js,jsx,html,css,sass,less,json,yml,md,graphql}\"", + "lint:silent": "npx prettier --loglevel silent --check \"src/**/*.{ts,tsx,js,jsx,html,css,sass,less,json,yml,md,graphql}\" && npx prettier --loglevel silent --check \"sasjs-tests/src/**/*.{ts,tsx,js,jsx,html,css,sass,less,json,yml,md,graphql}\"", "test": "jest --silent --coverage", "prepublishOnly": "cp -r ./build/* . && rm -rf ./build", "postpublish": "git clean -fd", diff --git a/src/auth/AuthManager.ts b/src/auth/AuthManager.ts index e442291..5d69c94 100644 --- a/src/auth/AuthManager.ts +++ b/src/auth/AuthManager.ts @@ -171,7 +171,7 @@ export class AuthManager { if (isLoggedIn) { if (this.serverType === ServerType.Sas9) { - await this.performCASSecurityCheck(); + await this.performCASSecurityCheck() } this.loginCallback()