From c573e143f7a25ea444b743ef0d389ba34ca09443 Mon Sep 17 00:00:00 2001 From: Mahmut Gundogdu Date: Thu, 24 Nov 2022 17:56:15 +0300 Subject: [PATCH] Add git hook for angular --- npm/ng-packs/README.md | 9 ++++++++- npm/ng-packs/package.json | 31 +++++++++++++++++++------------ npm/ng-packs/pre-commit | 2 ++ 3 files changed, 29 insertions(+), 13 deletions(-) create mode 100755 npm/ng-packs/pre-commit diff --git a/npm/ng-packs/README.md b/npm/ng-packs/README.md index 790a48fd0c..b58a8dc117 100644 --- a/npm/ng-packs/README.md +++ b/npm/ng-packs/README.md @@ -22,4 +22,11 @@ The `dev-app` project is the same as the Angular UI template project. `dev-app` For more information, see the [docs.abp.io](https://docs.abp.io) If would you like contribute, see the [contribution guideline](./CONTRIBUTING.md). - + +### Git Hooks + There is a pre-defined git hook for Angular project. This hook is `pre-commit`. The hook run prettier for staged files. If you want to use this hook. (This steps tested for linux and Mac os) + + - Go to `npm/ng-packs` + - Run `chmod +x ./pre-commit` + and now, when you create a git commit, git hook execute prettier for staged files. + \ No newline at end of file diff --git a/npm/ng-packs/package.json b/npm/ng-packs/package.json index b767614549..ba8ebea1f1 100644 --- a/npm/ng-packs/package.json +++ b/npm/ng-packs/package.json @@ -10,6 +10,7 @@ "build:all": "nx run-many --target=build --all --exclude=dev-app,schematics --prod && yarn build:schematics", "test": "ng test --detect-open-handles=true --run-in-band=true --watch-all=true", "test:all": "nx run-many --target=test --all", + "lint-staged": "lint-staged", "lint": "nx workspace-lint && ng lint", "lint:all": "nx run-many --target=lint --all", "e2e": "ng e2e", @@ -40,6 +41,17 @@ }, "private": true, "devDependencies": { + "@abp/ng.account": "~6.0.1", + "@abp/ng.account.core": "~6.0.1", + "@abp/ng.core": "~6.0.1", + "@abp/ng.feature-management": "~6.0.1", + "@abp/ng.identity": "~6.0.1", + "@abp/ng.permission-management": "~6.0.1", + "@abp/ng.schematics": "~6.0.1", + "@abp/ng.setting-management": "~6.0.1", + "@abp/ng.tenant-management": "~6.0.1", + "@abp/ng.theme.basic": "~6.0.1", + "@abp/ng.theme.shared": "~6.0.1", "@abp/utils": "~6.0.1", "@angular-devkit/build-angular": "14.2.1", "@angular-devkit/build-ng-packagr": "^0.1002.0", @@ -59,17 +71,6 @@ "@angular/platform-browser": "14.2.1", "@angular/platform-browser-dynamic": "14.2.1", "@angular/router": "14.2.1", - "@abp/ng.account": "~6.0.1", - "@abp/ng.account.core": "~6.0.1", - "@abp/ng.core": "~6.0.1", - "@abp/ng.feature-management": "~6.0.1", - "@abp/ng.identity": "~6.0.1", - "@abp/ng.permission-management": "~6.0.1", - "@abp/ng.schematics": "~6.0.1", - "@abp/ng.setting-management": "~6.0.1", - "@abp/ng.tenant-management": "~6.0.1", - "@abp/ng.theme.basic": "~6.0.1", - "@abp/ng.theme.shared": "~6.0.1", "@fortawesome/fontawesome-free": "^5.15.4", "@ng-bootstrap/ng-bootstrap": "~13.0.0", "@ngneat/spectator": "^10.0.0", @@ -105,6 +106,7 @@ "just-clone": "^3.2.1", "just-compare": "^1.4.0", "lerna": "^4.0.0", + "lint-staged": "^13.0.3", "ng-packagr": "14.2.1", "ng-zorro-antd": "^14.0.0", "nx": "14.7.5", @@ -125,5 +127,10 @@ "typescript": "4.7.4", "zone.js": "0.11.4" }, - "dependencies": {} + "dependencies": {}, + "lint-staged": { + "**/*.{js,jsx,ts,tsx}":[ + "npx prettier --write --config .prettierrc " + ] + } } diff --git a/npm/ng-packs/pre-commit b/npm/ng-packs/pre-commit new file mode 100755 index 0000000000..5000e1c00b --- /dev/null +++ b/npm/ng-packs/pre-commit @@ -0,0 +1,2 @@ +#!/usr/bin/env sh +cd npm/ng-packs && npm run lint-staged \ No newline at end of file