From aec62bbeac03e484861f0388f7fc58455bc2bb21 Mon Sep 17 00:00:00 2001 From: Yesha Mavani Date: Wed, 6 Mar 2024 11:27:59 +0530 Subject: [PATCH] feat(sandbox): user tenant example MIGRATION CHANGE: migration-20230905130235- migration gh-1954 --- .../user-tenant-service-example/.cz-config.js | 61 - .../user-tenant-service-example/.gitignore | 3 - .../.husky/commit-msg | 18 - .../.husky/pre-commit | 18 - .../.husky/prepare-commit-msg | 18 - .../user-tenant-service-example/DEVELOPING.md | 492 - sandbox/user-tenant-service-example/README.md | 135 - .../commitlint.config.js | 14 - .../user-tenant-service-example/lerna.json | 19 - .../package-lock.json | 17948 ---------------- .../user-tenant-service-example/package.json | 39 - .../packages/migrations/.env.example | 5 - .../packages/migrations/.gitignore | 2 - .../packages/migrations/package.json | 28 - .../user-tenant-service/database.json | 22 - .../migrations/20230905130235-init.js | 53 - .../sqls/20230905130235-init-down.sql | 2 - .../sqls/20230905130235-init-up.sql | 393 - .../user-tenant-service/.dockerignore | 5 - .../user-tenant-service/.env.defaults | 16 - .../services/user-tenant-service/.env.example | 16 - .../user-tenant-service/.eslintignore | 4 - .../services/user-tenant-service/.eslintrc.js | 12 - .../services/user-tenant-service/.gitignore | 64 - .../user-tenant-service/.mocharc.json | 5 - .../services/user-tenant-service/.nycrc | 5 - .../user-tenant-service/.prettierignore | 3 - .../services/user-tenant-service/.prettierrc | 7 - .../user-tenant-service/.vscode/launch.json | 38 - .../user-tenant-service/.vscode/settings.json | 32 - .../user-tenant-service/.vscode/tasks.json | 29 - .../services/user-tenant-service/.yo-rc.json | 6 - .../user-tenant-service/DEVELOPING.md | 36 - .../services/user-tenant-service/Dockerfile | 88 - .../services/user-tenant-service/README.md | 75 - .../services/user-tenant-service/package.json | 97 - .../user-tenant-service/public/index.html | 103 - .../src/__tests__/README.md | 3 - .../acceptance/home-page.acceptance.ts | 31 - .../acceptance/ping.controller.acceptance.ts | 21 - .../src/__tests__/acceptance/test-helper.ts | 43 - .../user-tenant-service/src/application.ts | 127 - .../src/controllers/README.md | 9 - .../src/controllers/home-page.controller.ts | 42 - .../src/controllers/index.ts | 2 - .../src/controllers/ping.controller.ts | 60 - .../src/datasources/README.md | 3 - .../src/datasources/index.ts | 0 .../services/user-tenant-service/src/index.ts | 41 - .../user-tenant-service/src/models/README.md | 3 - .../user-tenant-service/src/openapi-spec.ts | 31 - .../user-tenant-service/src/openapi.json | 4755 ---- .../src/opentelemetry-registry.ts | 35 - .../user-tenant-service/tsconfig.json | 9 - .../user-tenant-service-example/tsconfig.json | 0 55 files changed, 25126 deletions(-) delete mode 100644 sandbox/user-tenant-service-example/.cz-config.js delete mode 100644 sandbox/user-tenant-service-example/.gitignore delete mode 100755 sandbox/user-tenant-service-example/.husky/commit-msg delete mode 100755 sandbox/user-tenant-service-example/.husky/pre-commit delete mode 100755 sandbox/user-tenant-service-example/.husky/prepare-commit-msg delete mode 100644 sandbox/user-tenant-service-example/DEVELOPING.md delete mode 100644 sandbox/user-tenant-service-example/README.md delete mode 100644 sandbox/user-tenant-service-example/commitlint.config.js delete mode 100644 sandbox/user-tenant-service-example/lerna.json delete mode 100644 sandbox/user-tenant-service-example/package-lock.json delete mode 100644 sandbox/user-tenant-service-example/package.json delete mode 100644 sandbox/user-tenant-service-example/packages/migrations/.env.example delete mode 100644 sandbox/user-tenant-service-example/packages/migrations/.gitignore delete mode 100644 sandbox/user-tenant-service-example/packages/migrations/package.json delete mode 100644 sandbox/user-tenant-service-example/packages/migrations/user-tenant-service/database.json delete mode 100644 sandbox/user-tenant-service-example/packages/migrations/user-tenant-service/migrations/20230905130235-init.js delete mode 100644 sandbox/user-tenant-service-example/packages/migrations/user-tenant-service/migrations/sqls/20230905130235-init-down.sql delete mode 100644 sandbox/user-tenant-service-example/packages/migrations/user-tenant-service/migrations/sqls/20230905130235-init-up.sql delete mode 100644 sandbox/user-tenant-service-example/services/user-tenant-service/.dockerignore delete mode 100644 sandbox/user-tenant-service-example/services/user-tenant-service/.env.defaults delete mode 100644 sandbox/user-tenant-service-example/services/user-tenant-service/.env.example delete mode 100644 sandbox/user-tenant-service-example/services/user-tenant-service/.eslintignore delete mode 100644 sandbox/user-tenant-service-example/services/user-tenant-service/.eslintrc.js delete mode 100644 sandbox/user-tenant-service-example/services/user-tenant-service/.gitignore delete mode 100644 sandbox/user-tenant-service-example/services/user-tenant-service/.mocharc.json delete mode 100644 sandbox/user-tenant-service-example/services/user-tenant-service/.nycrc delete mode 100644 sandbox/user-tenant-service-example/services/user-tenant-service/.prettierignore delete mode 100644 sandbox/user-tenant-service-example/services/user-tenant-service/.prettierrc delete mode 100644 sandbox/user-tenant-service-example/services/user-tenant-service/.vscode/launch.json delete mode 100644 sandbox/user-tenant-service-example/services/user-tenant-service/.vscode/settings.json delete mode 100644 sandbox/user-tenant-service-example/services/user-tenant-service/.vscode/tasks.json delete mode 100644 sandbox/user-tenant-service-example/services/user-tenant-service/.yo-rc.json delete mode 100644 sandbox/user-tenant-service-example/services/user-tenant-service/DEVELOPING.md delete mode 100644 sandbox/user-tenant-service-example/services/user-tenant-service/Dockerfile delete mode 100644 sandbox/user-tenant-service-example/services/user-tenant-service/README.md delete mode 100644 sandbox/user-tenant-service-example/services/user-tenant-service/package.json delete mode 100644 sandbox/user-tenant-service-example/services/user-tenant-service/public/index.html delete mode 100644 sandbox/user-tenant-service-example/services/user-tenant-service/src/__tests__/README.md delete mode 100644 sandbox/user-tenant-service-example/services/user-tenant-service/src/__tests__/acceptance/home-page.acceptance.ts delete mode 100644 sandbox/user-tenant-service-example/services/user-tenant-service/src/__tests__/acceptance/ping.controller.acceptance.ts delete mode 100644 sandbox/user-tenant-service-example/services/user-tenant-service/src/__tests__/acceptance/test-helper.ts delete mode 100644 sandbox/user-tenant-service-example/services/user-tenant-service/src/application.ts delete mode 100644 sandbox/user-tenant-service-example/services/user-tenant-service/src/controllers/README.md delete mode 100644 sandbox/user-tenant-service-example/services/user-tenant-service/src/controllers/home-page.controller.ts delete mode 100644 sandbox/user-tenant-service-example/services/user-tenant-service/src/controllers/index.ts delete mode 100644 sandbox/user-tenant-service-example/services/user-tenant-service/src/controllers/ping.controller.ts delete mode 100644 sandbox/user-tenant-service-example/services/user-tenant-service/src/datasources/README.md delete mode 100644 sandbox/user-tenant-service-example/services/user-tenant-service/src/datasources/index.ts delete mode 100644 sandbox/user-tenant-service-example/services/user-tenant-service/src/index.ts delete mode 100644 sandbox/user-tenant-service-example/services/user-tenant-service/src/models/README.md delete mode 100644 sandbox/user-tenant-service-example/services/user-tenant-service/src/openapi-spec.ts delete mode 100644 sandbox/user-tenant-service-example/services/user-tenant-service/src/openapi.json delete mode 100644 sandbox/user-tenant-service-example/services/user-tenant-service/src/opentelemetry-registry.ts delete mode 100644 sandbox/user-tenant-service-example/services/user-tenant-service/tsconfig.json delete mode 100644 sandbox/user-tenant-service-example/tsconfig.json diff --git a/sandbox/user-tenant-service-example/.cz-config.js b/sandbox/user-tenant-service-example/.cz-config.js deleted file mode 100644 index 0bf3b08c8c..0000000000 --- a/sandbox/user-tenant-service-example/.cz-config.js +++ /dev/null @@ -1,61 +0,0 @@ -module.exports = { - types: [ - {value: 'feat', name: 'feat: A new feature'}, - {value: 'fix', name: 'fix: A bug fix'}, - {value: 'docs', name: 'docs: Documentation only changes'}, - { - value: 'style', - name: 'style: Changes that do not affect the meaning of the code\n (white-space, formatting, missing semi-colons, etc)', - }, - { - value: 'refactor', - name: 'refactor: A code change that neither fixes a bug nor adds a feature', - }, - { - value: 'perf', - name: 'perf: A code change that improves performance', - }, - {value: 'test', name: 'test: Adding missing tests'}, - { - value: 'chore', - name: 'chore: Changes to the build process or auxiliary tools\n and libraries such as documentation generation', - }, - {value: 'revert', name: 'revert: Revert to a commit'}, - {value: 'WIP', name: 'WIP: Work in progress'}, - ], - - scopes: [ -{name: 'user-tenant-service-service'}, - {name: 'ci-cd'}, - {name: 'deps'}, - {name: 'migrations'}, - ], - - appendBranchNameToCommitMessage: false, - allowTicketNumber: false, - isTicketNumberRequired: false, - ticketNumberPrefix: 'Fixes - ', - - // override the messages, defaults are as follows - messages: { - type: "Select the type of change that you're committing:", - scope: 'Denote the SCOPE of this change:', - // used if allowCustomScopes is true - customScope: 'Denote the SCOPE of this change:', - subject: 'Write a SHORT, IMPERATIVE tense description of the change:\n', - body: 'Provide a LONGER description of the change (optional). Use "|" to break new line:\n', - breaking: 'List any BREAKING CHANGES (optional):\n', - footer: - 'List any ISSUES CLOSED by this change (optional). E.g.: -31, -34:\n', - confirmCommit: 'Are you sure you want to proceed with the commit above?', - }, - - allowCustomScopes: false, - allowBreakingChanges: ['feat', 'fix'], - - // limit subject length - subjectLimit: 100, - breaklineChar: '|', // It is supported for fields body and footer. - footerPrefix: '', - askForBreakingChangeFirst: true, // default is false -}; diff --git a/sandbox/user-tenant-service-example/.gitignore b/sandbox/user-tenant-service-example/.gitignore deleted file mode 100644 index 5b2ab7f46e..0000000000 --- a/sandbox/user-tenant-service-example/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -node_modules -lerna-debug.log -.env \ No newline at end of file diff --git a/sandbox/user-tenant-service-example/.husky/commit-msg b/sandbox/user-tenant-service-example/.husky/commit-msg deleted file mode 100755 index f27bc42683..0000000000 --- a/sandbox/user-tenant-service-example/.husky/commit-msg +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh -. "$(dirname "$0")/_/husky.sh" - -npx --no-install commitlint --edit $1 - -# Section for git-secrets -if ! command -v git-secrets &> /dev/null 2>&1 -then - echo "git-secrets is not installed. Please run 'brew install git-secrets' or visit https://github.com/awslabs/git-secrets#installing-git-secrets" - exit 1 -fi - -# Initialise git-secrets configuration -git-secrets --register-aws > /dev/null - -echo "Running git-secrets..." -# Scans the commit message. -git-secrets --commit_msg_hook -- "$@" \ No newline at end of file diff --git a/sandbox/user-tenant-service-example/.husky/pre-commit b/sandbox/user-tenant-service-example/.husky/pre-commit deleted file mode 100755 index b02183d543..0000000000 --- a/sandbox/user-tenant-service-example/.husky/pre-commit +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh -. "$(dirname "$0")/_/husky.sh" - -# Section for git-secrets -if ! command -v git-secrets &> /dev/null 2>&1 -then - echo "git-secrets is not installed. Please run 'brew install git-secrets' or visit https://github.com/awslabs/git-secrets#installing-git-secrets" - exit 1 -fi - -# Initialise git-secrets configuration -git-secrets --register-aws > /dev/null - -echo "Running git-secrets..." -# Scans all files that are about to be committed. -git-secrets --pre_commit_hook -- "$@" - -npm test \ No newline at end of file diff --git a/sandbox/user-tenant-service-example/.husky/prepare-commit-msg b/sandbox/user-tenant-service-example/.husky/prepare-commit-msg deleted file mode 100755 index 2b72373426..0000000000 --- a/sandbox/user-tenant-service-example/.husky/prepare-commit-msg +++ /dev/null @@ -1,18 +0,0 @@ -#!/bin/sh -. "$(dirname "$0")/_/husky.sh" - -exec < /dev/tty && npx cz --hook || true - -# Section for git-secrets -if ! command -v git-secrets &> /dev/null 2>&1 -then - echo "git-secrets is not installed. Please run 'brew install git-secrets' or visit https://github.com/awslabs/git-secrets#installing-git-secrets" - exit 1 -fi - -# Initialise git-secrets configuration -git-secrets --register-aws > /dev/null - -echo "Running git-secrets..." -# Determines if merging in a commit will introduce tainted history. -git-secrets --prepare_commit_msg_hook -- "$@" \ No newline at end of file diff --git a/sandbox/user-tenant-service-example/DEVELOPING.md b/sandbox/user-tenant-service-example/DEVELOPING.md deleted file mode 100644 index a2913afa1d..0000000000 --- a/sandbox/user-tenant-service-example/DEVELOPING.md +++ /dev/null @@ -1,492 +0,0 @@ -# Developing Microservices - -This document describes how to develop microservices living in loopback4-microservice-catalog monorepo. - -- [Setting up development environment](#setting-up-development-environment) -- [Setup Codebase](#setup-codebase) -- [Building the project](#building-the-project) -- [File naming convention](#file-naming-convention) -- [Develop a new microservice](#develop-a-new-microservice) -- [How to upgrade to new LB4 dependencies](#how-to-upgrade-to-new-lb4-dependencies) -- [Sonar Setup in VS Code](#sonar-setup-in-vs-code) -- [Commit message guidelines](#commit-message-guidelines) -- [Husky setup for commit hooks](#husky-setup-for-commit-hooks) - -## Setting up development environment - -We recommend our contributors to use -[VisualStudio Code](https://code.visualstudio.com/) with the following -extensions installed: - -- [Prettier - Code Formatter](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) - for automatic formatting of source files on save. -- [ESLint](https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint) - to highlight and auto-fix linting problems directly in the editor. -- [SonarLint for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=SonarSource.sonarlint-vscode) -- [TypeScript Hero](https://marketplace.visualstudio.com/items?itemName=rbbit.typescript-hero) - -Our monorepo comes with few preconfigured -[VSCode Tasks](https://code.visualstudio.com/docs/editor/tasks): - -- The build task is configured to run the TypeScript compiler -- The test task is configured to run `npm test` (which runs the build before - running any tests). - -## Setup Codebase - -1. Open root folder of this repo in VS Code. -2. Install lerna globally `npm i -g lerna` -3. Run `lerna bootstrap` -4. Run `npm i` -5. Create .env files for all the micro service packages. -6. Run DB migrations using `lerna run db:migrate`. -7. Build all microservices in one go - `lerna run build`. -8. Run `lerna run start` to start all the micro services in one go. - -## Building the project - -Whenever you pull updates from GitHub or switch between feature branches, make -sure to updated installed dependencies in all monorepo packages. The following -command will install npm dependencies for all packages and create symbolic links -for intra-dependencies: - -```sh -lerna bootstrap -``` - -As part of `lerna bootstrap`, TypeScript project references are automatically -updated for each package with in the monorepo. - -The next step is to compile all packages from TypeScript to JavaScript: - -```sh -lerna run build -``` - -To force a clean build: - -```sh -lerna clean && lerna run build -``` - -Please note that `npm run clean` removes `dist`, `*.tsbuildinfo`, and other -generated files from each package to clean the state for builds. - -To build an individual package: - -```sh -cd // For example, cd `packages/core`. -npm run build -``` - - - -### Linting and formatting - -We use two tools to keep our codebase healthy: - -- [ESLint](https://typescript-eslint.io/) to statically analyse our source code - and detect common problems. -- [Prettier](https://prettier.io/) to keep our code always formatted the same - way, avoid style discussions in code reviews, and save everybody's time an - energy. - -You can run both linters via the following npm script, just keep in mind that -`lerna run test` is already running them for you. - -```sh -lerna run lint -``` - -Many problems (especially formatting) can be automatically fixed by running the -npm script `lint:fix`. - -```sh -lerna run lint:fix -``` - -### Adding dependencies - -Use the following command to add or update dependency `dep` in a package `name`: - -```sh -$ npx lerna add --scope ${name} ${dep} -``` - -For example: - -```sh -$ npx lerna add --scope @loopback/rest debug -``` - -See [lerna add](https://github.com/lerna/lerna/blob/master/commands/add#readme) -for more details. - -## File naming convention - -For consistency, we follow -[Angular's file naming convention](https://angular.io/guide/styleguide#separate-file-names-with-dots-and-dashes). -It helps to derive the usage of files by inspecting the names. Besides the -LoopBack 4 codebase, we also follow this naming convention in our generated -artifacts from the CLI tooling: `{name}`.`{artifact-type}`.ts - -Examples are: - -``` -src/decorators/authenticate.decorator.ts -src/boot.component.ts -``` - -In addition, files under `test` folder are categorized according to the type of -tests (unit, acceptance and integration), with the convention -`{name}.{test-type}.ts`. - -Examples are: - -``` -src/__tests__/acceptance/application.acceptance.ts -src/__tests__/integration/user.controller.integration.ts -src/__tests__/unit/application.unit.ts -``` - -## Develop a new microservice - -1. **lb4 ** - Generate a new loopback-next application under the required folder, either facades or services. -2. **.dockerignore** - Replace node_modules with coverage -3. **.prettierignore** - Add coverage -4. **.eslintrc.js** - Just copy below as is - - ```json - module.exports = { - extends: '@loopback/eslint-config', - rules: { - 'no-extra-boolean-cast': 'off', - '@typescript-eslint/interface-name-prefix': 'off', - 'no-prototype-builtins': 'off', - }, - parserOptions: { - project: './tsconfig.json', - tsconfigRootDir: __dirname, - }, - }; - ``` - -5. **Necessary deps** - Add symlink-resolver package to devDependencies - - ```sh - lerna add -D symlink-resolver --scope={service name} - ``` - - then add these two in scripts of package.json - - ```json - "symlink-resolver": "symlink-resolver", - "resolve-links": "npm run symlink-resolver build ./node_modules", - ``` - -6. **Dotenv** - Add dotenv packages for environment keys handling. Run below - - ```sh - lerna add dotenv --scope={service name} - lerna add dotenv-extended --scope={service name} - lerna add -D @types/dotenv --scope={service name} - ``` - -7. **Env files** - Add .env.defaults and .env.example and specify required keys -8. **Load .env** - Add below code to the top of `application.ts` before super call. - - ```ts - const port = 3000; - dotenv.config(); - dotenvExt.load({ - schema: '.env.example', - errorOnMissing: true, - includeProcessEnv: true, - }); - options.rest = options.rest || {}; - options.rest.port = +(process.env.PORT || port); - options.rest.host = process.env.HOST; - ``` - - Import dotenv related packages - - ```ts - import * as dotenv from 'dotenv'; - import * as dotenvExt from 'dotenv-extended'; - ``` - -9. **Add Sourceloop core** - Add @sourceloop/core as dependency to the module - - ```sh - lerna add @sourceloop/core --scope={service name} - ``` - -In application.ts, - -```ts -import {CoreComponent, ServiceSequence} from '@sourceloop/core'; - -this.component(CoreComponent); - -// Set up the custom sequence -this.sequence(ServiceSequence); -``` - -10. **Bearer Verifier** - Add bearer verifier to your service - -```sh -lerna add loopback4-authentication --scope={service name} -lerna add loopback4-authorization --scope={service name} -``` - -Add below to application.ts - -```ts - ... - import {AuthenticationComponent} from 'loopback4-authentication'; - import { - AuthorizationBindings, - AuthorizationComponent, - } from 'loopback4-authorization'; - import { - BearerVerifierBindings, - BearerVerifierComponent, - BearerVerifierConfig, - BearerVerifierType, - } from '@sourceloop/core'; - ... - // Add authentication component - this.component(AuthenticationComponent); - - // Add bearer verifier component - this.bind(BearerVerifierBindings.Config).to({ - authServiceUrl: '', - type: BearerVerifierType.service, - } as BearerVerifierConfig); - this.component(BearerVerifierComponent); - - // Add authorization component - this.bind(AuthorizationBindings.CONFIG).to({ - allowAlwaysPaths: ['/explorer'], - }); - this.component(AuthorizationComponent); -``` - -Use BearerVerifierType.facade for facades. - -11. **Setup project for test coverage** - - - Create a file named .nycrc and copy this data in it - - ```json - { - "extends": "@istanbuljs/nyc-config-typescript", - "all": true, - "reporter": ["html", "text-summary"] - } - ``` - - Install nyc for coverage reporting - - ```sh - lerna add -D @istanbuljs/nyc-config-typescript --scope={service name} - lerna add -D nyc --scope={service name} - ``` - - then add these in scripts of package.json - - ```json - "coverage": "nyc npm run test", - ``` - -12. **Setup sequence** - Remove auto-generated sequence.ts and change to ServiceSequence in application.ts. -13. **Fix api explorer** - Update base path in index.html for facades. - -```html - -
-

auth-facade

-

Version 1.0.0

- -

OpenAPI spec: /openapi.json

-

API Explorer: /explorer

-
- - - -``` - -14. **Update home-page.controller.ts** - Update the home-page.controller.ts with base path related changes, only in facades. - -```ts -this.html = fs.readFileSync( - path.join(__dirname, '../../public/index.html'), - 'utf-8', -); -// Replace base path placeholder from env -this.html = this.html.replace(/\$\{basePath\}/g, process.env.BASE_PATH ?? ''); -``` - -Create home-page.controller.ts if not already there. - -## How to upgrade to new LB4 dependencies - -1. Upgrade LB4 CLI version first. Use `npm i -g @loopback/cli@latest`. -2. Run `npm i` at project root. This step is mandatory if node.js or npm version support is also needed to upgrade. -3. Upgrade any deps, if needed, at project root. Verify it in the package.json at root. If not needed, skip this step. -4. Navigate to core package. `cd packages/core`. -5. Run `lb4 update`. It will prompt you to confirm the deps upgrade. Verify it carefully and confirm. Let it overwrite package.json. -6. There may be some errors in previous step if there are any breaking changes coming in. If that's so, then, delete package-lock.json and run `npm i` again. -7. Upgrade any other package related, like, loopback4 extensions - loopback4-authentication, etc. In order to ensure upgrade works, all the extensions should support the upgraded LB4 version. For example, `npm i loopback4-authentication@latest loopback4-authorization@latest loopback4-soft-delete@latest tslib@latest loopback-connector-postgresql@latest`. -8. Run `npm audit fix`, if needed. -9. Run `npm run test` to validate upgrade. -10. Now, navigate to individual services. `cd ../../services/audit-service`. -11. Re-execute steps 5-8 again. -12. Before doing test, we need to update the `@sourceloop/core` with local symlinked package. Run `lerna bootstrap --force-local --scope=@sourceloop/audit-service`. -13. Now run `npm run test` to validate upgrade. -14. Repeat steps 10-13 for each service. - -After all the steps above done for all services and core package, all your deps are upgraded and tested. You can commit and push them to be released. Make sure to mention any breaking changes if any of the deps upgrade had breaking change. - -## Sonar Setup in VS Code - -1. Go to [Sonar Cloud](https://sonarcloud.io/) -2. Login with your SF Github ID -3. Go to `My Account` from top-right user profile menu. -4. Move to `Security` tab. -5. Add a recognizable token name and click on `Generate token` -6. Install Sonarlint extension in VS Code IDE -7. Open Settings in VS Code IDE -8. Search for `sonarlint` using search box at the top -9. Look for `Sonarlint › Connected Mode: Servers` -10. Click on `Edit in settings.json`. settings.json under system user directory will open. -11. Add the below configuration - -```json - "sonarlint.connectedMode.servers": [ - { - "serverId": "sf_sonar", // Connection identifier - "serverUrl": "https://sonarcloud.io/", // SonarQube/SonarCloud URL - https//sonarcloud.io for SonarCloud - "token": "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", - "organizationKey": "sourcefuse-cloud" - } - ], -``` - -Replace value of token with your own user token generated in step 5 from sonar cloud. - -**Note** - Sonarlint requires latest java runtime. Please install if not done already. - -Close and reopen VS Code. - -## Commit message guidelines - -A good commit message should describe what changed and why. - -Our commit messages are formatted according to -[Conventional Commits](https://conventionalcommits.org/), we use -[commitlint](https://github.com/marionebl/commitlint) to verify and enforce this -convention. These rules lead to more readable messages that are easy to follow -when looking through the project history. But also, we use the git commit -messages to generate change logs when publishing new versions. - -### Commit Message Format - -Each commit message consists of a **header**, a **body** and a **footer**. The -header has a special format that includes a **type**, an optional **scope** and -a **subject**: - -```text -(): - - - -