diff --git a/.cz-config.js b/.cz-config.js new file mode 100644 index 0000000000..22e7ba5209 --- /dev/null +++ b/.cz-config.js @@ -0,0 +1,41 @@ +const commitLintConfig = require("./commitlint.config"); +const generateScopes = () => { + let rules = []; + for (rule of commitLintConfig.rules["scope-enum"][2]) { + rules.push({ name: rule }); + } + return rules; +}; + +module.exports = { + //See here for options details https://github.com/leonardoanalista/cz-customizable#options + 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 or correcting existing tests" }, + { + value: "build", + name: + "build: Changes that affect the build system or external dependencies\n (example scopes: gulp, broccoli, npm)" + }, + { + value: "ci", + name: + "ci: Changes to our CI configuration files and scripts\n (example scopes: Travis, Circle, BrowserStack, SauceLabs)" + }, + { + value: "chore", + name: "chore: Changes to the build process or auxiliary tools\n and libraries such as documentation generation" + }, + { value: "revert", name: "revert: Reverts a previous commit" } + ], + scopes: generateScopes() +}; diff --git a/commitlint.config.js b/commitlint.config.js new file mode 100644 index 0000000000..81c045d9f9 --- /dev/null +++ b/commitlint.config.js @@ -0,0 +1,32 @@ +module.exports = { + extends: ["@commitlint/config-conventional"], + + //See here for the rules definition : https://github.com/marionebl/commitlint/blob/master/docs/reference-rules.md + rules: { + "header-max-length": [1, "always", 100], + "scope-enum": [ + 2, + "always", + [ + "core", + "ui", + "test", + "build", + "accessibility", + "build-main", + "developer-guide", + "docs", + "qa", + "stark-all", + "stark-build", + "stark-core", + "stark-demo", + "stark-starter", + "stark-rbac", + "stark-ui", + "testing" + ] + ], + "scope-case": [2, "always", "lowerCase"] + } +}; diff --git a/package.json b/package.json index 82caf11937..be8fb5d062 100644 --- a/package.json +++ b/package.json @@ -19,11 +19,16 @@ "npm": ">=5.3.0" }, "devDependencies": { - "@angular/core": "5.2.10", "@angular/compiler": "5.2.10", "@angular/compiler-cli": "5.2.10", + "@angular/core": "5.2.10", + "@commitlint/cli": "6.1.3", + "@commitlint/config-conventional": "6.1.3", "codelyzer": "4.3.0", "conventional-changelog-cli": "1.3.22", + "commitizen": "2.9.6", + "cz-conventional-changelog": "2.1.0", + "cz-customizable": "^5.2.0", "husky": "0.14.3", "lint-staged": "7.0.4", "prettier": "1.12.1", @@ -57,6 +62,8 @@ "clean:modules:stark-core": "cd packages/stark-core && npm run clean:modules && cd ../..", "clean:modules:stark-testing": "cd packages/stark-testing && npm run clean:modules dist && cd ../..", "clean:modules:starter": "cd starter && npm run clean:modules dist && cd ..", + "commit": "./node_modules/.bin/git-cz", + "commitmsg": "commitlint -e $GIT_PARAMS", "generate:changelog": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0", "generate:changelog-recent": "conventional-changelog -p angular | tail -n +3", "preupdate:starter": "npm run clean:starter", @@ -98,5 +105,10 @@ "prettier --write", "git add" ] + }, + "config": { + "commitizen": { + "path": "node_modules/cz-customizable" + } } }