From 5a5889ab5861720136fc57912a330910fc362e49 Mon Sep 17 00:00:00 2001 From: instinxt Date: Mon, 5 May 2025 21:59:59 +0530 Subject: [PATCH 1/4] chore: update .gitignore to exclude lock file --- .gitignore | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.gitignore b/.gitignore index 02bce81a..506cdb4c 100644 --- a/.gitignore +++ b/.gitignore @@ -58,3 +58,6 @@ command_output.log # Properties src/main/environment/common_local.properties + +# Exclude pack-lock.json +package-lock.json From 99eb57018688b7c1fde86215e86934ef51d461e4 Mon Sep 17 00:00:00 2001 From: instinxt Date: Mon, 5 May 2025 22:00:38 +0530 Subject: [PATCH 2/4] feat: add commit linting configuration with Husky and Commitlint --- .github/workflows/commit-lint.yml | 18 ++++++++++++++++ .husky/commit-msg | 4 ++++ commitlint.config.js | 36 +++++++++++++++++++++++++++++++ package.json | 22 +++++++++++++++++++ 4 files changed, 80 insertions(+) create mode 100644 .github/workflows/commit-lint.yml create mode 100755 .husky/commit-msg create mode 100644 commitlint.config.js create mode 100644 package.json diff --git a/.github/workflows/commit-lint.yml b/.github/workflows/commit-lint.yml new file mode 100644 index 00000000..bac7e032 --- /dev/null +++ b/.github/workflows/commit-lint.yml @@ -0,0 +1,18 @@ +name: Lint Commit Messages +on: [pull_request] + +jobs: + commitlint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - uses: actions/setup-node@v3 + with: + node-version: "16" + cache: 'npm' + - name: Install dependencies + run: npm install + - name: Validate all commits from PR + run: npx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose \ No newline at end of file diff --git a/.husky/commit-msg b/.husky/commit-msg new file mode 100755 index 00000000..e8105222 --- /dev/null +++ b/.husky/commit-msg @@ -0,0 +1,4 @@ +#!/usr/bin/env sh +. "$(dirname -- "$0")/_/husky.sh" + +npx --no -- commitlint --edit $1 diff --git a/commitlint.config.js b/commitlint.config.js new file mode 100644 index 00000000..fe3163ff --- /dev/null +++ b/commitlint.config.js @@ -0,0 +1,36 @@ +module.exports = { + extends: ["@commitlint/config-conventional"], + rules: { + "body-leading-blank": [1, "always"], + "body-max-line-length": [2, "always", 100], + "footer-leading-blank": [1, "always"], + "footer-max-line-length": [2, "always", 100], + "header-max-length": [2, "always", 100], + "subject-case": [ + 2, + "never", + ["sentence-case", "start-case", "pascal-case", "upper-case"], + ], + "subject-empty": [2, "never"], + "subject-full-stop": [2, "never", "."], + "type-case": [2, "always", "lower-case"], + "type-empty": [2, "never"], + "type-enum": [ + 2, + "always", + [ + "build", + "chore", + "ci", + "docs", + "feat", + "fix", + "perf", + "refactor", + "revert", + "style", + "test", + ], + ], + }, +}; diff --git a/package.json b/package.json new file mode 100644 index 00000000..606b247d --- /dev/null +++ b/package.json @@ -0,0 +1,22 @@ +{ + "name": "tm-api", + "version": "1.0.0", + "description": "TM-API commit linting configuration", + "private": true, + "scripts": { + "prepare": "husky install", + "commit": "git-cz" + }, + "devDependencies": { + "@commitlint/cli": "^17.6.7", + "@commitlint/config-conventional": "^17.6.7", + "commitizen": "^4.3.0", + "cz-conventional-changelog": "^3.3.0", + "husky": "^8.0.3" + }, + "config": { + "commitizen": { + "path": "./node_modules/cz-conventional-changelog" + } + } +} From 455a5b7a2d51de9a00761ec03824f6f5a66bb300 Mon Sep 17 00:00:00 2001 From: instinxt Date: Mon, 5 May 2025 22:01:06 +0530 Subject: [PATCH 3/4] chore: update Readme for linting setup --- README.md | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 58 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 0872010e..fbd7fde4 100644 --- a/README.md +++ b/README.md @@ -25,13 +25,13 @@ Telemedicine is integral to HWCs, enhancing accessibility and efficiency in heal Telemedicine strengthens HWCs by bridging geographical gaps, optimizing resources, and ensuring timely medical intervention. - ## Building From Source This microservice is built using Java and the Spring Boot framework, with MySQL as the underlying database. Before building the TM module, ensure you have the following prerequisites: For step-by-step guide, follow this [guide] (https://piramal-swasthya.gitbook.io/amrit/developer-guide/development-environment-setup) . ## Prerequisites + - JDK 17 (LTS) - Maven - Redis @@ -42,12 +42,15 @@ To build the TM module from source, follow these steps: 1. Clone the repository to your local machine. 2. Install the required dependencies and build the module using the following command: + - Execute the following command: ``` mvn clean install ``` + 3. You can copy `common_example.properties` to `common_local.properties` and edit the file accordingly. The file is under `src/main/environment` folder. -4. Run the development server by following these steps: +4. Run the development server by following these steps: + - Start the Redis server. - Execute the following command: ``` @@ -63,10 +66,61 @@ With the TM module, you can efficiently manage all aspects of your telemedicine ## Filing Issues -If you encounter any issues, bugs, or have feature requests, please file them in the [main AMRIT repository](https://github.com/PSMRI/AMRIT/issues). Centralizing all feedback helps us streamline improvements and address concerns efficiently. +If you encounter any issues, bugs, or have feature requests, please file them in the [main AMRIT repository](https://github.com/PSMRI/AMRIT/issues). Centralizing all feedback helps us streamline improvements and address concerns efficiently. ## Join Our Community We’d love to have you join our community discussions and get real-time support! -Join our [Discord server](https://discord.gg/FVQWsf5ENS) to connect with contributors, ask questions, and stay updated. +Join our [Discord server](https://discord.gg/FVQWsf5ENS) to connect with contributors, ask questions, and stay updated. + +## Setting Up Commit Hooks + +This project uses Git hooks to enforce consistent code quality and commit message standards. Even though this is a Java project, the hooks are powered by Node.js. Follow these steps to set up the hooks locally: + +### Prerequisites + +- Node.js (v14 or later) +- npm (comes with Node.js) + +### Setup Steps + +1. **Install Node.js and npm** + - Download and install from [nodejs.org](https://nodejs.org/) + - Verify installation with: + ``` + node --version + npm --version + ``` +2. **Install dependencies** + - From the project root directory, run: + ``` + npm ci + ``` + - This will install all required dependencies including Husky and commitlint +3. **Verify hooks installation** + - The hooks should be automatically installed by Husky + - You can verify by checking if the `.husky` directory contains executable hooks + +### Commit Message Convention + +This project follows a specific commit message format: + +- Format: `type(scope): subject` +- Example: `feat(login): add remember me functionality` + Types include: +- `feat`: A new feature +- `fix`: A bug fix +- `docs`: Documentation changes +- `style`: Code style changes (formatting, etc.) +- `refactor`: Code changes that neither fix bugs nor add features +- `perf`: Performance improvements +- `test`: Adding or fixing tests +- `build`: Changes to build process or tools +- `ci`: Changes to CI configuration +- `chore`: Other changes (e.g., maintenance tasks, dependencies) + Your commit messages will be automatically validated when you commit, ensuring project consistency. + +## Usage +OVER-CODER marked this conversation as resolved. +All the features of the TM module have been exposed as REST endpoints. For detailed information on how to use the service, refer to the SWAGGER API specification. From 5255ac8c991247753d717ed96eb2ec38a0213c88 Mon Sep 17 00:00:00 2001 From: instinxt Date: Mon, 5 May 2025 22:33:31 +0530 Subject: [PATCH 4/4] fix: commitlint flags --- .husky/commit-msg | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.husky/commit-msg b/.husky/commit-msg index e8105222..80416c7b 100755 --- a/.husky/commit-msg +++ b/.husky/commit-msg @@ -1,4 +1,4 @@ #!/usr/bin/env sh . "$(dirname -- "$0")/_/husky.sh" -npx --no -- commitlint --edit $1 +npx --no-install commitlint --edit "$1"