Skip to content

Commit

Permalink
chore(cb2-8121): update husky scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
shivangidas committed Sep 20, 2023
1 parent 990203d commit 492c471
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 10 deletions.
4 changes: 4 additions & 0 deletions .husky/commit-msg
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run commit-msg
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run precommit
4 changes: 4 additions & 0 deletions .husky/pre-push
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run prepush
55 changes: 54 additions & 1 deletion commitlint.config.js
Original file line number Diff line number Diff line change
@@ -1 +1,54 @@
module.exports = { extends: ["@commitlint/config-conventional"] };
// https://github.com/conventional-changelog/commitlint/blob/master/@commitlint/config-conventional/index.js
// https://github.com/conventional-changelog/commitlint/blob/master/docs/reference-rules.md
module.exports = {
extends: ["@commitlint/config-conventional"],
plugins: ["commitlint-plugin-function-rules"],
rules: {
"type-enum": [
2,
"always",
// in addtition to angular defaults, we add additional type for commits, breaking, breaking_change will force a major release with semantic-release
// any body of commit containing BREAKING_CHANGE, BREAKING, etc.. will do too, please refer to the .releaserc.json file
[
"revert",
"feat",
"test",
"perf",
"fix",
"chore",
"ci",
"docs",
"breaking_change",
"breaking",
"refactor",
],
],
"subject-case": [1, "always", "lower-case"],
// disable it to allow release notes from semantic-release to happen when releasing
"footer-max-line-length": [0],
"body-max-line-length": [0],
// level: disabled to use our own rule with commitlint-plugin-function-rules plugin
"scope-case": [0],
"function-rules/scope-empty": [
2,
"always",
(parsed) => {
const ticketNumberFormat = /^[a-z0-9]+-\d+$/;
// type(scope?): subject
// we want to ticket number to appear in the commit msg as well as scope when we release
if (
parsed &&
((parsed.scope && parsed.scope.match(ticketNumberFormat) !== null) ||
parsed.scope === "release")
) {
return [true];
} else {
return [
false,
`scope must follow the format defined in the commitlint config. The current format is ${ticketNumberFormat}`,
];
}
},
],
},
};
14 changes: 5 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,6 @@
"node": "18.*",
"npm": "9.*"
},
"husky": {
"hooks": {
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
"pre-commit": "npm run security-checks && npm run audit && npm run lint:fix && npm run format",
"pre-push": "npm run test && npm run build && npm run test-i"
}
},
"devDependencies": {
"@commitlint/cli": "17.7.1",
"@commitlint/config-conventional": "17.7.0",
Expand Down Expand Up @@ -82,9 +75,12 @@
"test:integration": "npm run compile && jasmine build/spec/logs-service.spec.js",
"compile-no-emit": "tsc --noEmit -p .",
"sonar-scanner": "sonar-scanner",
"audit": "npm audit --prod",
"audit": "npm audit --omit=dev",
"package": "mkdir ${ZIP_NAME} && cp package.json package-lock.json ${ZIP_NAME}/ && cp -r .build/src/* ${ZIP_NAME}/ && cd ${ZIP_NAME} && npm ci --production && rm package.json package-lock.json && zip -qr ../${ZIP_NAME}.zip .",
"tools-setup": "echo 'Nothing to do'"
"tools-setup": "echo 'Nothing to do'",
"precommit": "npm run security-checks && npm run audit && npm run lint && npm run format",
"commit-msg": "commitlint --edit $1",
"prepush": "npm run test && npm run build && npm run test-i"
},
"nyc": {
"require": [
Expand Down

0 comments on commit 492c471

Please sign in to comment.