# https://github.com/jscutlery/semver for docs
$ yarn add -D @jscutlery/semver
$ yarn nx g @jscutlery/semver:install
✔ Would you want to enforce conventional commits? (Y/n) · true
✔ Which preset would you want to use? · conventional
? Which projects would you want to version independently?
# https://github.com/conventional-changelog/commitlint links to config-nx-scopes
$ yarn add -D @commitlint/config-nx-scopes
# https://commitlint.js.org/#/guides-use-prompt provides commitizen as an alternative, and
# @commitlint/cz-commitlint is used in other parts of the docs, so it's probably more mainained than @commitlint/prompt-cli
# https://www.npmjs.com/package/@commitlint/cz-commitlint for docs
$ yarn add -D @commitlint/cz-commitlint commitizen
$ touch .commitlintrc.js # and add the content from the gist
Last active
May 21, 2022 20:28
-
-
Save gioragutt/a091ba9be1d942a0e66588cdd07c29f2 to your computer and use it in GitHub Desktop.
setting up nx-pwm
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @type {import('@commitlint/types').UserConfig} | |
*/ | |
module.exports = { | |
extends: ['@commitlint/config-conventional', '@commitlint/config-nx-scopes'], | |
rules: { | |
// NOTE: uncomment this if you want to alter the scopes | |
// 'scope-enum': async (ctx) => { | |
// const projects = | |
// require('@commitlint/config-nx-scopes').utils.getProjects(ctx); | |
// return [2, 'always', projects]; | |
// }, | |
}, | |
prompt: { | |
settings: { | |
enableMultipleScopes: true, | |
}, | |
}, | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/.commitlintrc.js b/.commitlintrc.js | |
new file mode 100644 | |
index 0000000..52fecff | |
--- /dev/null | |
+++ b/.commitlintrc.js | |
@@ -0,0 +1,14 @@ | |
+/** | |
+ * @type {import('@commitlint/types').UserConfig} | |
+ */ | |
+module.exports = { | |
+ extends: ['@commitlint/config-conventional', '@commitlint/config-nx-scopes'], | |
+ rules: { | |
+ // NOTE: uncomment this if you want to alter the scopes | |
+ // 'scope-enum': async (ctx) => { | |
+ // const projects = | |
+ // require('@commitlint/config-nx-scopes').utils.getProjects(ctx); | |
+ // return [2, 'always', projects]; | |
+ // }, | |
+ prompt: { | |
+ settings: { | |
+ enableMultipleScopes: true, | |
+ }, | |
+ }, | |
+ }, | |
+}; | |
diff --git a/.husky/commit-msg b/.husky/commit-msg | |
new file mode 100755 | |
index 0000000..e8511ea | |
--- /dev/null | |
+++ b/.husky/commit-msg | |
@@ -0,0 +1,4 @@ | |
+#!/bin/sh | |
+. "$(dirname "$0")/_/husky.sh" | |
+ | |
+npx --no-install commitlint --edit $1 | |
diff --git a/package.json b/package.json | |
index 30f33e5..9f149c1 100644 | |
--- a/package.json | |
+++ b/package.json | |
@@ -2,16 +2,31 @@ | |
"name": "nx-pwm", | |
"version": "0.0.0", | |
"license": "MIT", | |
- "scripts": {}, | |
+ "scripts": { | |
+ "commit": "git-cz", | |
+ "prepare": "husky install" | |
+ }, | |
"private": true, | |
"dependencies": {}, | |
"devDependencies": { | |
+ "@commitlint/cli": "^17.0.0", | |
+ "@commitlint/config-conventional": "^17.0.0", | |
+ "@commitlint/config-nx-scopes": "^17.0.0", | |
+ "@commitlint/cz-commitlint": "^17.0.0", | |
+ "@jscutlery/semver": "^2.23.4", | |
"@nrwl/cli": "14.1.7", | |
"@nrwl/js": "14.1.7", | |
"@nrwl/nx-cloud": "latest", | |
"@nrwl/workspace": "14.1.7", | |
+ "commitizen": "^4.2.4", | |
+ "husky": "^7.0.4", | |
"nx": "14.1.7", | |
"prettier": "^2.5.1", | |
"typescript": "~4.6.2" | |
+ }, | |
+ "config": { | |
+ "commitizen": { | |
+ "path": "@commitlint/cz-commitlint" | |
+ } | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"scripts": { | |
"commit": "git-cz" | |
}, | |
"config": { | |
"commitizen": { | |
"path": "@commitlint/cz-commitlint" | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment