commitlint-config-spellbookx 1.1.2 → 1.3.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 (46) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/README.md +91 -60
  3. package/__tests__/index.test.ts +3 -29
  4. package/dist/{get-scopes-D9bIfVqN.js → git-C5S_9pJT.js} +2166 -276
  5. package/dist/index.d.ts +2 -4
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +2 -7
  8. package/dist/lib/index.d.ts +1 -5
  9. package/dist/lib/index.d.ts.map +1 -1
  10. package/dist/lib/index.js +1 -5
  11. package/dist/prompt.js +8 -10
  12. package/dist/rules.d.ts.map +1 -1
  13. package/dist/rules.js +1 -4
  14. package/package.json +3 -15
  15. package/rolldown.config.ts +0 -6
  16. package/src/index.ts +2 -9
  17. package/src/lib/index.ts +1 -5
  18. package/src/prompt.ts +8 -8
  19. package/src/rules.ts +1 -2
  20. package/__tests__/scopes.test.ts +0 -42
  21. package/__tests__/workspaces.test.ts +0 -137
  22. package/dist/constants/commit-types.d.ts +0 -13
  23. package/dist/constants/commit-types.d.ts.map +0 -1
  24. package/dist/constants/commit-types.js +0 -24
  25. package/dist/get-workspaces-raw-path-Cg196xaD.js +0 -2043
  26. package/dist/lib/find-git-root.d.ts +0 -16
  27. package/dist/lib/find-git-root.d.ts.map +0 -1
  28. package/dist/lib/find-git-root.js +0 -30
  29. package/dist/lib/get-scope-description.d.ts +0 -21
  30. package/dist/lib/get-scope-description.d.ts.map +0 -1
  31. package/dist/lib/get-scope-description.js +0 -35
  32. package/dist/lib/get-scopes.d.ts +0 -16
  33. package/dist/lib/get-scopes.d.ts.map +0 -1
  34. package/dist/lib/get-scopes.js +0 -4
  35. package/dist/lib/get-workspaces-raw-path.d.ts +0 -19
  36. package/dist/lib/get-workspaces-raw-path.d.ts.map +0 -1
  37. package/dist/lib/get-workspaces-raw-path.js +0 -3
  38. package/dist/scopes.d.ts +0 -23
  39. package/dist/scopes.d.ts.map +0 -1
  40. package/dist/scopes.js +0 -38
  41. package/src/constants/commit-types.ts +0 -26
  42. package/src/lib/find-git-root.ts +0 -31
  43. package/src/lib/get-scope-description.ts +0 -38
  44. package/src/lib/get-scopes.ts +0 -89
  45. package/src/lib/get-workspaces-raw-path.ts +0 -53
  46. package/src/scopes.ts +0 -40
package/CHANGELOG.md CHANGED
@@ -1,5 +1,20 @@
1
1
  # commitlint-config-spellbookx
2
2
 
3
+ ## 1.3.0
4
+
5
+ ### Minor Changes
6
+
7
+ - chore(release): automated minor release bump
8
+
9
+ ### Patch Changes
10
+
11
+ - Updated dependencies []:
12
+ - @spellbookx/recipes@1.3.0
13
+
14
+ ## 1.2.0
15
+
16
+ No changes in this release.
17
+
3
18
  ## 1.1.2
4
19
 
5
20
  ### Patch Changes
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # commitlint-config-spellbookx
2
2
 
3
- A modern, highly modular, and opinionated [Commitlint](https://commitlint.js.org/) configuration for the Spellbookx ecosystem. It enforces the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) specification, automatically discovers monorepo package scopes, and provides an interactive [cz-git](https://cz-git.qbenben.com/) Commitizen prompt with emojis.
3
+ A modern, highly modular, and opinionated [Commitlint](https://commitlint.js.org/) configuration for the Spellbookx ecosystem. It enforces the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) specification, automatically discovers monorepo package scopes, and provides an interactive [cz-git](https://cz-git.qbb.sh/) prompt with emojis.
4
4
 
5
5
  ---
6
6
 
@@ -12,7 +12,7 @@ A modern, highly modular, and opinionated [Commitlint](https://commitlint.js.org
12
12
  | **Dynamic Monorepo Scopes** | Automatically discovers workspace packages from `pnpm-workspace.yaml`, `package.json`, and `lerna.json`. |
13
13
  | **Standard Special Scopes** | Built-in support for `workspace` (root/infra changes) and `release` (versioning commits). |
14
14
  | **Interactive cz-git Prompt** | Out-of-the-box support for `commitizen` with rich emojis, descriptions, and multi-scope selection. |
15
- | **Modular Architecture** | Import individual building blocks (`rules`, `prompt`, `scopes`, `COMMIT_TYPES`) or atomic functions (`lib/`). |
15
+ | **Modular Architecture** | Import individual building blocks (`config`, `rules`, `prompt`) and combine with `@spellbookx/recipes/git`. |
16
16
 
17
17
  ---
18
18
 
@@ -22,15 +22,15 @@ A modern, highly modular, and opinionated [Commitlint](https://commitlint.js.org
22
22
  | :------------- | :---: | :---------------------- | :-------------------------------------------------------------------------------- |
23
23
  | **`feat`** | ✨ | Features | A new feature for the user or codebase |
24
24
  | **`fix`** | 🐛 | Bug Fixes | A bug fix |
25
- | **`docs`** | 📚 | Documentation | Documentation only changes |
26
- | **`style`** | 💎 | Styles | Changes that do not affect the meaning of the code (whitespace, formatting, etc.) |
27
- | **`refactor`** | 📦 | Code Refactoring | A code change that neither fixes a bug nor adds a feature |
25
+ | **`docs`** | 📖 | Documentation | Documentation only changes |
26
+ | **`style`** | 🎨 | Styles | Changes that do not affect the meaning of the code (whitespace, formatting, etc.) |
27
+ | **`refactor`** | 🧹 | Code Refactoring | A code change that neither fixes a bug nor adds a feature |
28
28
  | **`perf`** | 🚀 | Performance | A code change that improves performance |
29
- | **`test`** | 🚨 | Tests | Adding missing tests or correcting existing tests |
30
- | **`build`** | 🛠 | Builds | Changes that affect the build system or external dependencies |
31
- | **`ci`** | ⚙️ | Continuous Integrations | Changes to CI configuration files and scripts |
29
+ | **`test`** | 🧪 | Tests | Adding missing tests or correcting existing tests |
30
+ | **`build`** | 📦 | Builds | Changes that affect the build system or external dependencies |
31
+ | **`ci`** | 🤖 | Continuous Integrations | Changes to CI configuration files and scripts |
32
32
  | **`chore`** | ♻️ | Chores | Other changes that don't modify src or test files |
33
- | **`revert`** | 🗑 | Reverts | Reverts a previous commit |
33
+ | **`revert`** | 🔙 | Reverts | Reverts a previous commit |
34
34
 
35
35
  ---
36
36
 
@@ -46,11 +46,20 @@ npm install --save-dev commitlint-config-spellbookx @commitlint/cli
46
46
 
47
47
  ## Usage
48
48
 
49
- Commitlint loads configuration from standard config files in your repository root. You can use this package in multiple ways depending on your project needs:
49
+ Commitlint loads configuration from standard config files in your repository root. Because the package is named `commitlint-config-spellbookx`, Commitlint's [Shareable Configuration](https://commitlint.js.org/reference/configuration.html#shareable-configuration) resolution allows you to simply specify `'spellbookx'` in the `extends` array.
50
50
 
51
- ### 1. Default Export (Recommended)
51
+ ### 1. Shareable Configuration (Recommended)
52
52
 
53
- The simplest way to use this preset:
53
+ Extend `'spellbookx'` in your Commitlint configuration:
54
+
55
+ ```javascript
56
+ // commitlint.config.mjs
57
+ export default {
58
+ extends: ['spellbookx'],
59
+ };
60
+ ```
61
+
62
+ Alternatively, you can re-export the default configuration object directly:
54
63
 
55
64
  ```javascript
56
65
  // commitlint.config.mjs
@@ -59,16 +68,13 @@ export { default } from 'commitlint-config-spellbookx';
59
68
 
60
69
  ### 2. Customizing Rules
61
70
 
62
- Extend and customize specific commitlint rules while keeping the shared defaults:
71
+ Extend `'spellbookx'` and override specific Commitlint rules:
63
72
 
64
73
  ```javascript
65
74
  // commitlint.config.mjs
66
- import { config, rules } from 'commitlint-config-spellbookx';
67
-
68
75
  export default {
69
- ...config,
76
+ extends: ['spellbookx'],
70
77
  rules: {
71
- ...rules,
72
78
  'header-max-length': [2, 'always', 100],
73
79
  },
74
80
  };
@@ -76,16 +82,15 @@ export default {
76
82
 
77
83
  ### 3. Adding Custom Scopes
78
84
 
79
- You can extend the dynamically discovered monorepo scopes with custom scopes:
85
+ You can extend the dynamically discovered monorepo scopes from `@spellbookx/recipes/git` with custom scopes:
80
86
 
81
87
  ```javascript
82
88
  // commitlint.config.mjs
83
- import { config, rules, scopesArray } from 'commitlint-config-spellbookx';
89
+ import { scopesArray } from '@spellbookx/recipes/git';
84
90
 
85
91
  export default {
86
- ...config,
92
+ extends: ['spellbookx'],
87
93
  rules: {
88
- ...rules,
89
94
  'scope-enum': [2, 'always', [...scopesArray, 'custom-scope', 'analytics']],
90
95
  },
91
96
  };
@@ -97,13 +102,7 @@ Assemble your configuration from modular pieces:
97
102
 
98
103
  ```javascript
99
104
  // commitlint.config.mjs
100
- import {
101
- rules,
102
- prompt,
103
- scopesArray,
104
- scopesEnum,
105
- COMMIT_TYPES,
106
- } from 'commitlint-config-spellbookx';
105
+ import { rules, prompt } from 'commitlint-config-spellbookx';
107
106
 
108
107
  export default {
109
108
  extends: ['@commitlint/config-conventional'],
@@ -118,56 +117,38 @@ Available building blocks:
118
117
  - `config`: Complete, ready-to-use commitlint configuration object.
119
118
  - `rules`: Strict Conventional Commit rules (`type-enum`, `scope-enum`, `header-max-length`, etc.).
120
119
  - `prompt`: Commitizen / `cz-git` interactive questionnaire configuration with emojis and multi-scope support.
121
- - `scopesArray`: Array of discovered workspace package names plus `'workspace'` and `'release'`.
122
- - `scopesEnum`: Record of scopes with human-readable descriptions for interactive CLI prompts.
123
- - `COMMIT_TYPES`: Array of all 11 allowed commit type strings.
124
- - `SCOPE_WORKSPACE`: Constant `'workspace'`.
125
- - `SCOPE_RELEASE`: Constant `'release'`.
126
-
127
- ### 5. Atomic Utility Functions (`lib`)
128
-
129
- Every helper and utility function is implemented atomically under `lib/` and can be imported either from the package root or from `commitlint-config-spellbookx/lib`:
130
120
 
131
- ```javascript
132
- import {
133
- findGitRoot,
134
- getScopes,
135
- getScopeDescription,
136
- getWorkspacesRawPath,
137
- } from 'commitlint-config-spellbookx/lib';
138
- ```
139
-
140
- - `getScopes(cwd?)`: Scans the monorepo configuration files and returns all workspace package names.
141
- - `findGitRoot(startDir?)`: Traverses upwards to locate the root of the current git repository.
142
- - `getScopeDescription(scope)`: Generates a human-friendly description string for a given scope identifier.
143
- - `getWorkspacesRawPath(configPath, parser, property?)`: Parses JSON or YAML configuration files to extract workspace glob patterns.
121
+ Shared git constants (`COMMIT_TYPES`, `SCOPE_WORKSPACE`, `SCOPE_RELEASE`, `scopesArray`, `scopesEnum`) and workspace discovery utilities (`findGitRoot`, `getScopes`, `getScopeDescription`, `getWorkspacesRawPath`) are provided by [`@spellbookx/recipes/git`](../recipes/README.md).
144
122
 
145
123
  ---
146
124
 
147
125
  ## Configuration File Formats
148
126
 
149
- According to the [Commitlint Configuration Documentation](https://commitlint.js.org/#/reference-configuration), you can define your configuration in any of the following formats:
127
+ According to the [Commitlint Shareable Configuration Documentation](https://commitlint.js.org/reference/configuration.html#shareable-configuration), you can define your configuration in any of the following formats:
150
128
 
151
129
  ### In `commitlint.config.mjs` (ES Modules)
152
130
 
153
131
  ```javascript
154
- export { default } from 'commitlint-config-spellbookx';
132
+ export default {
133
+ extends: ['spellbookx'],
134
+ };
155
135
  ```
156
136
 
157
137
  ### In `commitlint.config.cjs` (CommonJS)
158
138
 
159
139
  ```javascript
160
- module.exports = require('commitlint-config-spellbookx').default;
140
+ module.exports = {
141
+ extends: ['spellbookx'],
142
+ };
161
143
  ```
162
144
 
163
145
  ### In `commitlint.config.ts` (TypeScript)
164
146
 
165
147
  ```typescript
166
148
  import type { UserConfig } from '@commitlint/types';
167
- import config from 'commitlint-config-spellbookx';
168
149
 
169
150
  const userConfig: UserConfig = {
170
- ...config,
151
+ extends: ['spellbookx'],
171
152
  };
172
153
 
173
154
  export default userConfig;
@@ -177,7 +158,7 @@ export default userConfig;
177
158
 
178
159
  ```json
179
160
  {
180
- "extends": ["commitlint-config-spellbookx"]
161
+ "extends": ["spellbookx"]
181
162
  }
182
163
  ```
183
164
 
@@ -185,7 +166,7 @@ export default userConfig;
185
166
 
186
167
  ```yaml
187
168
  extends:
188
- - commitlint-config-spellbookx
169
+ - spellbookx
189
170
  ```
190
171
 
191
172
  ### In `package.json`
@@ -194,7 +175,7 @@ extends:
194
175
  {
195
176
  "name": "my-project",
196
177
  "commitlint": {
197
- "extends": ["commitlint-config-spellbookx"]
178
+ "extends": ["spellbookx"]
198
179
  }
199
180
  }
200
181
  ```
@@ -226,9 +207,13 @@ npx husky add .husky/commit-msg 'npx --no -- commitlint --edit "$1"'
226
207
 
227
208
  ---
228
209
 
229
- ## Interactive Commits with Commitizen
210
+ ## Interactive Commits (`cz-git` / `czg` / Commitizen)
211
+
212
+ `commitlint-config-spellbookx` ships with a preconfigured [`cz-git`](https://cz-git.qbb.sh/config/) prompt. You can use it either with **Commitizen** (`cz`) or standalone with **`czg`** / **`cz-git`** without Commitizen.
213
+
214
+ ### Option 1: Using Commitizen (`cz`)
230
215
 
231
- For a guided, interactive commit experience with `cz-git`, configure Commitizen in your `package.json`:
216
+ Configure Commitizen to use the `cz-git` adapter in your `package.json`:
232
217
 
233
218
  ```json
234
219
  {
@@ -249,6 +234,52 @@ Then run:
249
234
  npm run commit
250
235
  ```
251
236
 
237
+ ### Option 2: Using `czg` or `cz-git` Without Commitizen
238
+
239
+ If you use [`czg`](https://cz-git.qbb.sh/cli/) or `cz-git` without Commitizen, create a `cz.config.(js|cjs|mjs|ts)` file in your project root (see the [cz-git Configuration Documentation](https://cz-git.qbb.sh/config/)):
240
+
241
+ #### In `cz.config.mjs` (ES Modules)
242
+
243
+ ```javascript
244
+ import { definePrompt } from 'cz-git';
245
+ import { prompt } from 'commitlint-config-spellbookx';
246
+
247
+ export default definePrompt({
248
+ ...prompt,
249
+ });
250
+ ```
251
+
252
+ Or re-export `prompt` directly:
253
+
254
+ ```javascript
255
+ export { prompt as default } from 'commitlint-config-spellbookx';
256
+ ```
257
+
258
+ #### In `cz.config.cjs` (CommonJS)
259
+
260
+ ```javascript
261
+ const { definePrompt } = require('cz-git');
262
+ const { prompt } = require('commitlint-config-spellbookx');
263
+
264
+ module.exports = definePrompt({
265
+ ...prompt,
266
+ });
267
+ ```
268
+
269
+ Then add a script in `package.json` or run `czg` directly:
270
+
271
+ ```json
272
+ {
273
+ "scripts": {
274
+ "commit": "czg"
275
+ }
276
+ }
277
+ ```
278
+
279
+ ```bash
280
+ npx czg
281
+ ```
282
+
252
283
  ---
253
284
 
254
285
  ## License
@@ -1,16 +1,13 @@
1
1
  import { describe, expect, it } from 'vitest';
2
2
 
3
+ import { COMMIT_TYPES, scopesEnum } from '@spellbookx/recipes/git';
4
+
3
5
  import defaultExport, {
4
- COMMIT_TYPES,
5
6
  config,
7
+ packageJson,
6
8
  prompt,
7
9
  rules,
8
- SCOPE_RELEASE,
9
- SCOPE_WORKSPACE,
10
- scopesArray,
11
- scopesEnum,
12
10
  } from '../src/index.js';
13
- import { packageJson } from '../src/lib/package-json.js';
14
11
 
15
12
  describe('commitlint-config-spellbookx (entrypoint)', () => {
16
13
  it('exports a valid commitlint UserConfig object as default and named export', () => {
@@ -29,22 +26,6 @@ describe('commitlint-config-spellbookx (entrypoint)', () => {
29
26
  expect(packageJson.version).toMatch(/^\d+\.\d+\.\d+/);
30
27
  });
31
28
 
32
- it('exports all 11 standard conventional commit types', () => {
33
- expect(COMMIT_TYPES).toEqual([
34
- 'feat',
35
- 'fix',
36
- 'docs',
37
- 'style',
38
- 'refactor',
39
- 'perf',
40
- 'test',
41
- 'chore',
42
- 'ci',
43
- 'build',
44
- 'revert',
45
- ]);
46
- });
47
-
48
29
  it('configures cz-git interactive prompt questions and settings', () => {
49
30
  expect(prompt?.settings?.enableMultipleScopes).toBe(true);
50
31
  expect(prompt?.settings?.scopeEnumSeparator).toBe(',');
@@ -54,11 +35,4 @@ describe('commitlint-config-spellbookx (entrypoint)', () => {
54
35
  expect(prompt?.questions?.type?.enum?.[type]).toBeDefined();
55
36
  }
56
37
  });
57
-
58
- it('exports special scope constants and dynamically discovered scopes', () => {
59
- expect(SCOPE_WORKSPACE).toBe('workspace');
60
- expect(SCOPE_RELEASE).toBe('release');
61
- expect(Array.isArray(scopesArray)).toBe(true);
62
- expect(scopesEnum).toBeTypeOf('object');
63
- });
64
38
  });