@cenk1cenk2/cz-cc 2.3.3 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +34 -0
  2. package/dist/index.cjs +18 -2
  3. package/package.json +13 -11
package/README.md CHANGED
@@ -11,6 +11,8 @@
11
11
  - [Configuration](#configuration)
12
12
  - [package.json](#packagejson)
13
13
  - [Environment Variables](#environment-variables)
14
+ - [Breaking Changes](#breaking-changes)
15
+ - [Migration to v3](#migration-to-v3)
14
16
  - [Commitlint](#commitlint)
15
17
 
16
18
  <!-- tocstop -->
@@ -68,6 +70,7 @@ Like commitizen, you specify the configuration of cz-conventional-changelog thro
68
70
  "config": {
69
71
  "commitizen": {
70
72
  "path": "./node_modules/@cenk1cenk2/cz-cc",
73
+ "preset": "conventionalcommits",
71
74
  "maxHeaderWidth": 100,
72
75
  "maxLineWidth": 100,
73
76
  "defaultType": "",
@@ -89,10 +92,13 @@ Like commitizen, you specify the configuration of cz-conventional-changelog thro
89
92
  }
90
93
  ```
91
94
 
95
+ `preset` selects how breaking changes are prompted for and rendered, either `conventionalcommits` (default) or `angular`. See [Breaking Changes](#breaking-changes).
96
+
92
97
  ### Environment Variables
93
98
 
94
99
  The following environment varibles can be used to override any default configuration or package.json based configuration.
95
100
 
101
+ - CZ_PRESET = preset
96
102
  - CZ_TYPE = defaultType
97
103
  - CZ_SCOPE = defaultScope
98
104
  - CZ_SUBJECT = defaultSubject
@@ -100,6 +106,34 @@ The following environment varibles can be used to override any default configura
100
106
  - CZ_MAX_HEADER_WIDTH = maxHeaderWidth
101
107
  - CZ_MAX_LINE_WIDTH = maxLineWidth
102
108
 
109
+ ## Breaking Changes
110
+
111
+ Breaking changes are declared through the additional actions of the prompt, and the `preset` configuration decides which of the two mechanisms are offered there. It has to match the preset the release tooling analyzes commits with.
112
+
113
+ - `conventionalcommits` (**default**) offers both. `breaking-marker` appends the `!` marker after the type and the optional scope, as in `feat(api)!: drop the legacy token endpoint`, and `breaking-changes` appends a `BREAKING CHANGE` footer. The specification treats them as independent signals, so either one on its own marks the commit as breaking and selecting both is valid.
114
+ - `angular` offers `breaking-changes` alone, since the `!` marker is not part of its header pattern. This is the behaviour of every release before v3.
115
+
116
+ Selecting neither leaves the commit non-breaking, so an ordinary commit still skips the whole subject in one pass.
117
+
118
+ ### Migration to v3
119
+
120
+ `conventionalcommits` became the default in v3, so commits made through the adapter can now carry the `!` marker in the header once `breaking-marker` is selected. Two things to check:
121
+
122
+ - The release tooling has to analyze commits with the `conventionalcommits` preset, otherwise the `!` marker is not read as a major bump. `@semantic-release/commit-analyzer` and `commitlint` both take a `preset` of their own.
123
+ - `header-max-length` counts the extra character, and any tooling matching commit headers with a custom regular expression has to allow the `!` before the colon.
124
+
125
+ To keep the previous behaviour, pin the preset back:
126
+
127
+ ```json5
128
+ {
129
+ "config": {
130
+ "commitizen": {
131
+ "preset": "angular"
132
+ }
133
+ }
134
+ }
135
+ ```
136
+
103
137
  ## Commitlint
104
138
 
105
139
  If using the [commitlint](https://github.com/conventional-changelog/commitlint) js library, the "maxHeaderWidth" configuration property will default to the configuration of the "header-max-length" rule instead of the hard coded value of 100. This can be overwritten by setting the 'maxHeaderWidth' configuration in package.json or the CZ_MAX_HEADER_WIDTH environment variable.
package/dist/index.cjs CHANGED
@@ -38,6 +38,13 @@ let os = require("os");
38
38
  let path = require("path");
39
39
  let _inquirer_prompts = require("@inquirer/prompts");
40
40
 
41
+ //#region src/presets.js
42
+ const PRESETS = {
43
+ conventionalcommits: "conventionalcommits",
44
+ angular: "angular"
45
+ };
46
+
47
+ //#endregion
41
48
  //#region src/engine.js
42
49
  function engine_default(options) {
43
50
  return { prompter(cz, commit) {
@@ -90,10 +97,15 @@ function engine_default(options) {
90
97
  value: "issue",
91
98
  description: "Resolve Issues by additional comments."
92
99
  },
100
+ ...options.preset === PRESETS.conventionalcommits ? [{
101
+ name: "breaking-marker",
102
+ value: "breaking-marker",
103
+ description: "Mark the commit as breaking with the \"!\" marker in the header."
104
+ }] : [],
93
105
  {
94
106
  name: "breaking-changes",
95
107
  value: "breaking-changes",
96
- description: "Note breaking changes in the commit message."
108
+ description: "Describe the breaking changes in a footer of the commit message."
97
109
  },
98
110
  {
99
111
  name: "long-description",
@@ -152,7 +164,8 @@ function engine_default(options) {
152
164
  ctx: { prompts: {} }
153
165
  }).run().then((ctx) => {
154
166
  const scope = ctx.prompts.scope ? `(${ctx.prompts.scope})` : "";
155
- let head = ctx.prompts.type + scope + ": " + ctx.prompts.subject;
167
+ const breakingMarker = options.preset === PRESETS.conventionalcommits && ctx.prompts.additional.includes("breaking-marker") ? "!" : "";
168
+ let head = ctx.prompts.type + scope + breakingMarker + ": " + ctx.prompts.subject;
156
169
  if (ctx.prompts.additional.includes("skip-ci")) head = head + " [skip ci]";
157
170
  const body = ctx.prompts.body;
158
171
  const breaking = ctx.prompts.breaking ? "BREAKING CHANGE: " + ctx.prompts.breaking.trim().replace(/^BREAKING CHANGE: /, "") : false;
@@ -173,7 +186,10 @@ function engine_default(options) {
173
186
  //#region src/index.js
174
187
  function bootstrap() {
175
188
  const config = commitizen.configLoader.load() || {};
189
+ const preset = process.env.CZ_PRESET || config.preset || PRESETS.conventionalcommits;
190
+ if (!Object.hasOwn(PRESETS, preset)) throw new Error(`Unknown preset "${preset}", expected one of: ${Object.keys(PRESETS).join(", ")}.`);
176
191
  const options = {
192
+ preset,
177
193
  types: config.types || conventional_commit_types.default.types,
178
194
  defaultType: process.env.CZ_TYPE || config.defaultType || "fix",
179
195
  defaultScope: process.env.CZ_SCOPE || config.defaultScope,
package/package.json CHANGED
@@ -1,8 +1,11 @@
1
1
  {
2
2
  "name": "@cenk1cenk2/cz-cc",
3
- "version": "2.3.3",
3
+ "version": "3.0.0",
4
4
  "description": "Commitizen adapter following the conventional-changelog format.",
5
- "repository": "git@gitlab.kilic.dev:libraries/cz-cc.git",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "git@gitlab.kilic.dev:libraries/cz-cc.git"
8
+ },
6
9
  "author": "Cenk Kilic <cenk@kilic.dev>",
7
10
  "license": "MIT",
8
11
  "type": "commonjs",
@@ -10,12 +13,6 @@
10
13
  "publishConfig": {
11
14
  "access": "public"
12
15
  },
13
- "scripts": {
14
- "build": "tsdown src/index.js",
15
- "dev:start": "tsdown --watch src/index.js",
16
- "format": "prettier --log-level warn --write src/ && eslint --fix",
17
- "lint": "eslint"
18
- },
19
16
  "simple-git-hooks": {
20
17
  "pre-commit": "[ -n \"$SKIP_GIT_HOOKS\" ] && true || pnpm exec lint-staged",
21
18
  "prepare-commit-msg": "[ -t 1 ] && exec < /dev/tty && git cz --hook || true"
@@ -47,7 +44,7 @@
47
44
  "lint-staged": "^17.4.1",
48
45
  "prettier": "^3.9.6",
49
46
  "simple-git-hooks": "^2.14.0",
50
- "tsdown": "^0.22.14",
47
+ "tsdown": "^0.23.0",
51
48
  "typescript": "^6.0.3"
52
49
  },
53
50
  "config": {
@@ -55,5 +52,10 @@
55
52
  "path": "./dist/index.cjs"
56
53
  }
57
54
  },
58
- "packageManager": "pnpm@12.3.0"
59
- }
55
+ "scripts": {
56
+ "build": "tsdown src/index.js",
57
+ "dev:start": "tsdown --watch src/index.js",
58
+ "format": "prettier --log-level warn --write src/ && eslint --fix",
59
+ "lint": "eslint"
60
+ }
61
+ }