commitlint-config-spellbookx 0.7.2 → 0.8.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.
@@ -1,7 +1,7 @@
1
1
 
2
- > commitlint-config-spellbookx@0.7.2 build /home/runner/work/spellbookx/spellbookx/packages/commitlint-config-spellbookx
2
+ > commitlint-config-spellbookx@0.8.0 build /home/runner/work/spellbookx/spellbookx/packages/commitlint-config-spellbookx
3
3
  > rolldown -c && tsc
4
4
 
5
- [log] <DIR>/index.js chunk │ size: 272.41 kB
5
+ [log] <DIR>/index.js chunk │ size: 272.66 kB
6
6
  [log]
7
- [success] rolldown v1.0.0-rc.1 Finished in 50.37 ms
7
+ [success] rolldown v1.0.0-rc.1 Finished in 56.45 ms
package/README.md CHANGED
@@ -1,165 +1,77 @@
1
1
  # commitlint-config-spellbookx
2
2
 
3
- Shared Commitlint configuration - standardizing commit message formatting across JS/TS projects.
4
- Conventional commits, interactive prompts, and multi-scope support included.
5
- Clean. Opinionated. Always consistent.
6
-
7
- ---
8
-
9
- ## Table of Content
10
-
11
- - [Features](#features)
12
- - [Install](#installation)
13
- - [Usage](#usage)
14
- - [With CLI](#with-cli)
15
- - [With Lefthook](#with-lefthook)
16
- - [Resources](#resources)
17
- - [License](#license)
18
-
19
- ---
20
-
21
- ## Features
22
-
23
- - **Base Rules**
24
- - Enforces [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) style.
25
- - Supported commit types:
26
- - `feat` -> A new feature
27
- - `fix` -> A bug fix
28
- - `docs` -> Documentation only changes
29
- - `style` -> Code style changes without functional impact
30
- - `refactor` -> Code refactoring (no feature or fix)
31
- - `perf` -> Performance improvements
32
- - `test` -> Adding or correcting tests
33
- - `build` -> Changes affecting the build system or dependencies
34
- - `ci` -> Changes to CI configuration
35
- - `chore` -> Miscellaneous chores
36
- - `revert` -> Reverts a previous commit
37
- - `feat` -> A new feature
38
- - `fix` -> A bug fix
39
- - `docs` -> Documentation only changes
40
- - `style` -> Code style changes without functional impact
41
- - `refactor` -> Code refactoring (no feature or fix)
42
- - `perf` -> Performance improvements
43
- - `test` -> Adding or correcting tests
44
- - `build` -> Changes affecting the build system or dependencies
45
- - `ci` -> Changes to CI configuration
46
- - `chore` -> Miscellaneous chores
47
- - `revert` -> Reverts a previous commit
48
- - Enforces:
49
- - Scope case: `kebab-case`
50
- - Subject cannot be empty
51
- - Subject case: `sentence-case`
52
- - No full stop at the end of subject
53
- - Header max length: 72
54
- - Body and footer max line length: 100
55
-
56
- - **Interactive Prompt**
57
- - Multi-scope support enabled
58
- - Scope separator: `,`
59
- - Guided questions for type, scope, subject, body, breaking changes, and issues affected
60
- - Emoji and title per commit type
61
- - Uses `cz` for interactive commits (`npx cz`)
62
-
63
- - **Parser Preset**
64
- - Uses `conventional-changelog-conventionalcommits`
65
- - Supports multi-scope commit messages:
66
- ```bash
67
- type(scope1,scope2): subject
68
- ```
69
-
70
- ---
3
+ Shared [Commitlint](https://commitlint.js.org/) configuration for the Spellbookx project. This package ensures that all commits adhere to the [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/) specification.
4
+
5
+ ## Description
6
+
7
+ This package provides a base commitlint configuration that:
8
+
9
+ - Extends the widely-used `@commitlint/config-conventional`.
10
+ - Dynamically generates commit scopes based on the packages present in the `@spellbookx` monorepo.
11
+ - Includes pre-defined commit types with emojis for better readability.
12
+ - Offers a customized `commitizen` prompt for an enhanced commit experience.
13
+
14
+ ## Why use this?
15
+
16
+ Using this package ensures consistent and readable commit messages across the entire project. This helps in:
17
+
18
+ - Automatically generating changelogs.
19
+ - Simplifying the release process.
20
+ - Improving the readability of the project's history.
71
21
 
72
22
  ## Installation
73
23
 
24
+ Install the package using your favorite package manager:
25
+
26
+ **npm**
27
+
74
28
  ```bash
75
- npm install -g commitizen cz-git
76
- npm install -D commitizen cz-git conventional-changelog-conventionalcommits @commitlint/cli @commitlint/config-conventional commitlint-config-spellbookx
29
+ npm install --save-dev commitlint-config-spellbookx @commitlint/cli
77
30
  ```
78
31
 
79
- or
32
+ **pnpm**
80
33
 
81
34
  ```bash
82
- pnpm add -g commitizen cz-git
83
- pnpm add -D commitizen cz-git conventional-changelog-conventionalcommits @commitlint/cli @commitlint/config-conventional commitlint-config-spellbookx
35
+ pnpm add -D commitlint-config-spellbookx @commitlint/cli
84
36
  ```
85
37
 
86
- or
38
+ **yarn**
87
39
 
88
40
  ```bash
89
- yarn global add commitizen cz-git
90
- yarn add -D commitizen cz-git conventional-changelog-conventionalcommits @commitlint/cli @commitlint/config-conventional commitlint-config-spellbookx
41
+ yarn add -D commitlint-config-spellbookx @commitlint/cli
91
42
  ```
92
43
 
93
- or
44
+ **bun**
94
45
 
95
46
  ```bash
96
- bun add -g commitizen cz-git
97
- bun add -D commitizen cz-git conventional-changelog-conventionalcommits @commitlint/cli @commitlint/config-conventional commitlint-config-spellbookx
47
+ bun add -d commitlint-config-spellbookx @commitlint/cli
98
48
  ```
99
49
 
100
- ---
101
-
102
50
  ## Usage
103
51
 
104
- Create a `commitlint.config.mjs` file at your project root:
105
-
106
- ```ts
107
- export default {
108
- extends: ['spellbookx'],
109
- };
110
- ```
52
+ To use this configuration, create a `commitlint.config.mjs` file in your project's root and extend this package:
111
53
 
112
- Create a `.czrc` file at your project root:
54
+ ```javascript
55
+ import config from 'commitlint-config-spellbookx';
113
56
 
114
- ```json
115
- {
116
- "path": "cz-git"
117
- }
57
+ export default config;
118
58
  ```
119
59
 
120
- Add these properties to your root `package.json`:
60
+ For an interactive commit experience, you can use `commitizen` with `cz-git`. Update your `package.json` with the following configuration:
121
61
 
122
62
  ```json
123
63
  {
64
+ "scripts": {
65
+ "commit": "cz"
66
+ },
124
67
  "config": {
125
68
  "commitizen": {
126
- "path": "git-cz"
69
+ "path": "cz-git"
127
70
  }
128
71
  }
129
72
  }
130
73
  ```
131
74
 
132
- ### With CLI
133
-
134
- Interactive commits using Commitizen:
135
-
136
- ```bash
137
- npx cz
138
- ```
139
-
140
- ### With Lefthook
141
-
142
- Configure a `lefthook.yml` in your project root:
143
-
144
- ```yaml
145
- commit-msg:
146
- commands:
147
- lint-commit-msg:
148
- run: npx commitlint --verbose --edit {1}
149
- ```
150
-
151
- > Commitlint will automatically validate commit messages on each commit. Use `cz` to create commits interactively.
152
-
153
- ---
154
-
155
- ## Resources
156
-
157
- - [Commitlint Documentation](https://commitlint.js.org/)
158
- - [Conventional Commits](https://www.conventionalcommits.org/)
159
- - [Commitizen](https://github.com/commitizen/cz-cli)
160
-
161
- ---
162
-
163
75
  ## License
164
76
 
165
77
  This project is licensed under the MIT License.
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,WAAW,EAAoD;IAC1E,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC1C,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,GAAG,MAAM,EACvB,QAAQ,GAAE,MAAqB,GAC9B,MAAM,EAAE,CA0BV;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,IAAI,MAAM,EAAE,CA+CpC"}
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,WAAW,EAAoD;IAC1E,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAC1C,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAClC,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,GAAG,MAAM,EACvB,QAAQ,GAAE,MAAqB,GAC9B,MAAM,EAAE,CA0BV;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,IAAI,MAAM,EAAE,CA6DpC"}
package/dist/index.js CHANGED
@@ -7697,18 +7697,22 @@ function getScopes() {
7697
7697
  rawWorkspaces.push(...getWorkspacesRawPath(pnpmWorkspaceYmlPath, "yaml", "packages"));
7698
7698
  const lernaJsonPath = path.join(cwd, "lerna.json");
7699
7699
  rawWorkspaces.push(...getWorkspacesRawPath(lernaJsonPath, "json", "packages"));
7700
- const workspaces = [];
7700
+ const workspaces = /* @__PURE__ */ new Set();
7701
+ if (existsSync(path.join(cwd, "package.json")) && !rawWorkspaces.includes(".")) rawWorkspaces.push(".");
7701
7702
  for (const pattern of rawWorkspaces) {
7702
7703
  const entries = import_out.default.sync(pattern, {
7703
7704
  onlyDirectories: true,
7704
7705
  absolute: true
7705
7706
  });
7706
7707
  for (const dirPath of entries) {
7707
- const dirName = dirPath.split(path.sep).at(-1);
7708
- if (typeof dirName === "string") workspaces.push(dirName);
7708
+ const packageJsonPath = path.join(dirPath, "package.json");
7709
+ if (existsSync(packageJsonPath)) try {
7710
+ const pkg = JSON.parse(readFileSync(packageJsonPath, "utf8"));
7711
+ if (pkg.name) workspaces.add(pkg.name);
7712
+ } catch {}
7709
7713
  }
7710
7714
  }
7711
- return workspaces;
7715
+ return [...workspaces];
7712
7716
  }
7713
7717
 
7714
7718
  //#endregion
package/package.json CHANGED
@@ -1,12 +1,15 @@
1
1
  {
2
2
  "name": "commitlint-config-spellbookx",
3
- "version": "0.7.2",
3
+ "version": "0.8.0",
4
4
  "private": false,
5
- "description": "Shared Commitlint configuration and commit convention tooling for Spellbookx",
5
+ "description": "A shareable Commitlint configuration for enforcing conventional commits.",
6
6
  "keywords": [
7
+ "commit-config",
8
+ "commitizen",
7
9
  "commitlint",
10
+ "commitlint-config",
8
11
  "conventional-commits",
9
- "commit-config",
12
+ "cz-git",
10
13
  "spellbookx"
11
14
  ],
12
15
  "homepage": "https://github.com/spellbookx/spellbookx#readme",
@@ -42,11 +45,11 @@
42
45
  },
43
46
  "devDependencies": {
44
47
  "@commitlint/types": "^20.3.1",
48
+ "@dcdavidev/tsconfig": "^0.1.0",
45
49
  "@types/js-yaml": "^4.0.9",
46
50
  "@types/node": "^25.0.10",
47
51
  "rolldown": "1.0.0-rc.1",
48
- "typescript": "5.9.2",
49
- "@spellbookx/typescript-config": "0.7.2"
52
+ "typescript": "5.9.2"
50
53
  },
51
54
  "publishConfig": {
52
55
  "access": "public"
package/src/helpers.ts CHANGED
@@ -90,20 +90,34 @@ export function getScopes(): string[] {
90
90
  ...getWorkspacesRawPath(lernaJsonPath, 'json', 'packages')
91
91
  );
92
92
 
93
- const workspaces: string[] = [];
93
+ const workspaces = new Set<string>();
94
+
95
+ const rootPackageJsonPath = path.join(cwd, 'package.json');
96
+ if (existsSync(rootPackageJsonPath) && !rawWorkspaces.includes('.')) {
97
+ rawWorkspaces.push('.');
98
+ }
94
99
 
95
100
  for (const pattern of rawWorkspaces) {
96
101
  const entries = fg.sync(pattern, { onlyDirectories: true, absolute: true });
97
102
 
98
103
  for (const dirPath of entries) {
99
- const dirArray = dirPath.split(path.sep);
100
- const dirName = dirArray.at(-1);
101
-
102
- if (typeof dirName === 'string') {
103
- workspaces.push(dirName);
104
+ const packageJsonPath = path.join(dirPath, 'package.json');
105
+
106
+ if (existsSync(packageJsonPath)) {
107
+ try {
108
+ const pkg = JSON.parse(readFileSync(packageJsonPath, 'utf8')) as {
109
+ name?: string;
110
+ };
111
+
112
+ if (pkg.name) {
113
+ workspaces.add(pkg.name);
114
+ }
115
+ } catch {
116
+ // ignore invalid package.json files
117
+ }
104
118
  }
105
119
  }
106
120
  }
107
121
 
108
- return workspaces;
122
+ return [...workspaces];
109
123
  }
package/tsconfig.json CHANGED
@@ -1,9 +1,12 @@
1
1
  {
2
- "extends": "@spellbookx/typescript-config/base.json",
2
+ "extends": "@dcdavidev/tsconfig/base.json",
3
3
  "compilerOptions": {
4
4
  "outDir": "./dist",
5
5
  "rootDir": "./src",
6
- "tsBuildInfoFile": "./dist/.tsbuildinfo"
6
+ "tsBuildInfoFile": "./dist/.tsbuildinfo",
7
+ "declaration": true,
8
+ "declarationMap": true,
9
+ "emitDeclarationOnly": true
7
10
  },
8
11
  "include": ["src/**/*"],
9
12
  "exclude": ["node_modules", "**/*.test.ts"]