@abelspithost/commitlint 0.0.1 → 0.0.3
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.
- package/LICENSE +14 -14
- package/README.md +9 -9
- package/bin/cli.spec.ts +199 -199
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +69 -69
package/LICENSE
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
ISC License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2026 Abel Spithost
|
|
4
|
-
|
|
5
|
-
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
-
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
-
copyright notice and this permission notice appear in all copies.
|
|
8
|
-
|
|
9
|
-
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
10
|
-
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
11
|
-
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
12
|
-
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
13
|
-
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
14
|
-
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
1
|
+
ISC License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Abel Spithost
|
|
4
|
+
|
|
5
|
+
Permission to use, copy, modify, and/or distribute this software for any
|
|
6
|
+
purpose with or without fee is hereby granted, provided that the above
|
|
7
|
+
copyright notice and this permission notice appear in all copies.
|
|
8
|
+
|
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
|
|
10
|
+
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
|
|
11
|
+
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
|
|
12
|
+
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
|
|
13
|
+
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
|
|
14
|
+
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
|
15
15
|
PERFORMANCE OF THIS SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
# @abelspithost/commitlint
|
|
2
2
|
|
|
3
|
-
A shared [commitlint](https://commitlint.js.org/) preset that extends `@commitlint/config-conventional` with stricter defaults, plus a CLI to set everything up
|
|
3
|
+
A shared [commitlint](https://commitlint.js.org/) preset that extends `@commitlint/config-conventional` with stricter defaults, plus a CLI to set everything up with one command.
|
|
4
4
|
|
|
5
5
|
## What's included
|
|
6
6
|
|
|
7
7
|
- Commitlint configuration that extends `@commitlint/config-conventional`
|
|
8
8
|
- Scope is optional by default
|
|
9
|
-
- A `createConfig` helper to customize allowed types and scopes (
|
|
9
|
+
- A `createConfig` helper to customize allowed types and scopes (when you provide scopes, they become mandatory)
|
|
10
10
|
- An `init` CLI that installs and configures commitlint + husky automatically
|
|
11
11
|
- Automatic package manager detection (npm, yarn, pnpm, bun)
|
|
12
12
|
|
|
@@ -18,17 +18,17 @@ Run the init command in your project root:
|
|
|
18
18
|
npx -p @abelspithost/commitlint init
|
|
19
19
|
```
|
|
20
20
|
|
|
21
|
-
The CLI
|
|
21
|
+
The CLI detects your package manager by looking for `bun.lockb`/`bun.lock`, `pnpm-lock.yaml`, `yarn.lock`, or falling back to npm. It will:
|
|
22
22
|
|
|
23
23
|
1. Install `husky`, `@commitlint/cli`, and `@abelspithost/commitlint` as dev dependencies
|
|
24
24
|
2. Initialize husky
|
|
25
|
-
3. Remove the default `pre-commit` hook
|
|
25
|
+
3. Remove the default `pre-commit` hook that husky creates
|
|
26
26
|
4. Create a `.husky/commit-msg` hook (using the correct runner for your package manager)
|
|
27
|
-
5. Generate a `commitlint.config.ts` that re-exports the preset (
|
|
27
|
+
5. Generate a `commitlint.config.ts` that re-exports the preset (skip if one already exists)
|
|
28
28
|
|
|
29
29
|
## Manual setup (npm)
|
|
30
30
|
|
|
31
|
-
Install the dependencies:
|
|
31
|
+
Install the required dependencies:
|
|
32
32
|
|
|
33
33
|
```sh
|
|
34
34
|
npm install --save-dev husky @commitlint/cli @abelspithost/commitlint
|
|
@@ -71,7 +71,7 @@ export default createConfig({
|
|
|
71
71
|
| `scopes` | `string[]` | — | Restrict commits to these scopes (makes scope mandatory) |
|
|
72
72
|
| `types` | `string[]` | `COMMIT_TYPES` | Override the allowed commit types |
|
|
73
73
|
|
|
74
|
-
When `scopes
|
|
74
|
+
When you omit `scopes`, scope is optional and you can use any value. When you provide `scopes`, scope becomes **required** and must match one of the listed values. When you omit `types`, it defaults to the built-in `COMMIT_TYPES`.
|
|
75
75
|
|
|
76
76
|
### Examples
|
|
77
77
|
|
|
@@ -113,11 +113,11 @@ const configuration: UserConfig = {
|
|
|
113
113
|
export default configuration;
|
|
114
114
|
```
|
|
115
115
|
|
|
116
|
-
`RuleConfigSeverity` and `UserConfig
|
|
116
|
+
This package re-exports `RuleConfigSeverity` and `UserConfig`, so you don't need to install `@commitlint/types` separately.
|
|
117
117
|
|
|
118
118
|
## Commit message format
|
|
119
119
|
|
|
120
|
-
|
|
120
|
+
Write your commits in the [Conventional Commits](https://www.conventionalcommits.org/) format:
|
|
121
121
|
|
|
122
122
|
```
|
|
123
123
|
type: description
|
package/bin/cli.spec.ts
CHANGED
|
@@ -1,199 +1,199 @@
|
|
|
1
|
-
import type { MockInstance } from 'vitest';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const mockExecSync = vi.fn();
|
|
5
|
-
const mockExistsSync = vi.fn<(path: string) => boolean>();
|
|
6
|
-
const mockUnlinkSync = vi.fn();
|
|
7
|
-
const mockWriteFileSync = vi.fn();
|
|
8
|
-
|
|
9
|
-
vi.mock('node:child_process', () => ({
|
|
10
|
-
execSync: mockExecSync,
|
|
11
|
-
}));
|
|
12
|
-
|
|
13
|
-
vi.mock('node:fs', () => ({
|
|
14
|
-
existsSync: mockExistsSync,
|
|
15
|
-
unlinkSync: mockUnlinkSync,
|
|
16
|
-
writeFileSync: mockWriteFileSync,
|
|
17
|
-
}));
|
|
18
|
-
|
|
19
|
-
async function runCli(): Promise<void> {
|
|
20
|
-
vi.resetModules();
|
|
21
|
-
// @ts-expect-error: CLI function in JavaScript
|
|
22
|
-
await import('./cli.mjs');
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
describe('cli.mjs', () => {
|
|
26
|
-
let exitSpy: MockInstance;
|
|
27
|
-
|
|
28
|
-
beforeEach(() => {
|
|
29
|
-
mockExecSync.mockReturnValue(Buffer.from(''));
|
|
30
|
-
mockExistsSync.mockReturnValue(false);
|
|
31
|
-
exitSpy = vi.spyOn(process, 'exit').mockImplementation(() => undefined as never);
|
|
32
|
-
vi.spyOn(console, 'log').mockReturnValue(undefined);
|
|
33
|
-
vi.spyOn(console, 'error').mockReturnValue(undefined);
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
afterEach(() => {
|
|
37
|
-
vi.restoreAllMocks();
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
describe('install command', () => {
|
|
41
|
-
it('runs npm install --save-dev for npm', async () => {
|
|
42
|
-
await runCli();
|
|
43
|
-
|
|
44
|
-
expect(mockExecSync).toHaveBeenCalledWith(
|
|
45
|
-
expect.stringContaining('npm install --save-dev'),
|
|
46
|
-
expect.anything(),
|
|
47
|
-
);
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it('runs pnpm add -D for pnpm', async () => {
|
|
51
|
-
mockExistsSync.mockImplementation((path: string) => path === 'pnpm-lock.yaml');
|
|
52
|
-
|
|
53
|
-
await runCli();
|
|
54
|
-
|
|
55
|
-
expect(mockExecSync).toHaveBeenCalledWith(
|
|
56
|
-
expect.stringContaining('pnpm add -D'),
|
|
57
|
-
expect.anything(),
|
|
58
|
-
);
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it('runs yarn add -D for yarn', async () => {
|
|
62
|
-
mockExistsSync.mockImplementation((path: string) => path === 'yarn.lock');
|
|
63
|
-
|
|
64
|
-
await runCli();
|
|
65
|
-
|
|
66
|
-
expect(mockExecSync).toHaveBeenCalledWith(
|
|
67
|
-
expect.stringContaining('yarn add -D'),
|
|
68
|
-
expect.anything(),
|
|
69
|
-
);
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
it('runs bun add -D for bun', async () => {
|
|
73
|
-
mockExistsSync.mockImplementation((path: string) => path === 'bun.lockb');
|
|
74
|
-
|
|
75
|
-
await runCli();
|
|
76
|
-
|
|
77
|
-
expect(mockExecSync).toHaveBeenCalledWith(
|
|
78
|
-
expect.stringContaining('bun add -D'),
|
|
79
|
-
expect.anything(),
|
|
80
|
-
);
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
describe('husky initialization', () => {
|
|
85
|
-
it('runs npx husky init for npm', async () => {
|
|
86
|
-
await runCli();
|
|
87
|
-
|
|
88
|
-
expect(mockExecSync).toHaveBeenCalledWith(
|
|
89
|
-
'npx husky init',
|
|
90
|
-
expect.anything(),
|
|
91
|
-
);
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
it('runs pnpm dlx husky init for pnpm', async () => {
|
|
95
|
-
mockExistsSync.mockImplementation((path: string) => path === 'pnpm-lock.yaml');
|
|
96
|
-
|
|
97
|
-
await runCli();
|
|
98
|
-
|
|
99
|
-
expect(mockExecSync).toHaveBeenCalledWith(
|
|
100
|
-
'pnpm exec husky init',
|
|
101
|
-
expect.anything(),
|
|
102
|
-
);
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
describe('pre-commit hook removal', () => {
|
|
107
|
-
it('removes the default pre-commit hook when it exists', async () => {
|
|
108
|
-
mockExistsSync.mockImplementation((path: string) => path === '.husky/pre-commit');
|
|
109
|
-
|
|
110
|
-
await runCli();
|
|
111
|
-
|
|
112
|
-
expect(mockUnlinkSync).toHaveBeenCalledWith('.husky/pre-commit');
|
|
113
|
-
});
|
|
114
|
-
|
|
115
|
-
it('skips removal when pre-commit hook does not exist', async () => {
|
|
116
|
-
await runCli();
|
|
117
|
-
|
|
118
|
-
expect(mockUnlinkSync).not.toHaveBeenCalled();
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
describe('commit-msg hook', () => {
|
|
123
|
-
it('writes hook with npx runner for npm', async () => {
|
|
124
|
-
await runCli();
|
|
125
|
-
|
|
126
|
-
expect(mockWriteFileSync).toHaveBeenCalledWith(
|
|
127
|
-
'.husky/commit-msg',
|
|
128
|
-
'npx --no -- commitlint --edit $1\n',
|
|
129
|
-
);
|
|
130
|
-
});
|
|
131
|
-
|
|
132
|
-
it('writes hook with pnpm exec runner for pnpm', async () => {
|
|
133
|
-
mockExistsSync.mockImplementation((path: string) => path === 'pnpm-lock.yaml');
|
|
134
|
-
|
|
135
|
-
await runCli();
|
|
136
|
-
|
|
137
|
-
expect(mockWriteFileSync).toHaveBeenCalledWith(
|
|
138
|
-
'.husky/commit-msg',
|
|
139
|
-
'pnpm exec commitlint --edit $1\n',
|
|
140
|
-
);
|
|
141
|
-
});
|
|
142
|
-
|
|
143
|
-
it('writes hook with yarn run runner for yarn', async () => {
|
|
144
|
-
mockExistsSync.mockImplementation((path: string) => path === 'yarn.lock');
|
|
145
|
-
|
|
146
|
-
await runCli();
|
|
147
|
-
|
|
148
|
-
expect(mockWriteFileSync).toHaveBeenCalledWith(
|
|
149
|
-
'.husky/commit-msg',
|
|
150
|
-
'yarn run commitlint --edit $1\n',
|
|
151
|
-
);
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
it('writes hook with bunx runner for bun', async () => {
|
|
155
|
-
mockExistsSync.mockImplementation((path: string) => path === 'bun.lockb');
|
|
156
|
-
|
|
157
|
-
await runCli();
|
|
158
|
-
|
|
159
|
-
expect(mockWriteFileSync).toHaveBeenCalledWith(
|
|
160
|
-
'.husky/commit-msg',
|
|
161
|
-
'bunx --bun commitlint --edit $1\n',
|
|
162
|
-
);
|
|
163
|
-
});
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
describe('commitlint config', () => {
|
|
167
|
-
it('creates commitlint.config.ts with the expected export', async () => {
|
|
168
|
-
await runCli();
|
|
169
|
-
|
|
170
|
-
expect(mockWriteFileSync).toHaveBeenCalledWith(
|
|
171
|
-
'commitlint.config.ts',
|
|
172
|
-
"export { default } from '@abelspithost/commitlint';\n",
|
|
173
|
-
);
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
it('skips commitlint.config.ts if it already exists', async () => {
|
|
177
|
-
mockExistsSync.mockImplementation((path: string) => path === 'commitlint.config.ts');
|
|
178
|
-
|
|
179
|
-
await runCli();
|
|
180
|
-
|
|
181
|
-
expect(mockWriteFileSync).not.toHaveBeenCalledWith(
|
|
182
|
-
'commitlint.config.ts',
|
|
183
|
-
expect.anything(),
|
|
184
|
-
);
|
|
185
|
-
});
|
|
186
|
-
});
|
|
187
|
-
|
|
188
|
-
describe('error handling', () => {
|
|
189
|
-
it('calls process.exit(1) when a step fails', async () => {
|
|
190
|
-
mockExecSync.mockImplementation(() => {
|
|
191
|
-
throw new Error('command failed');
|
|
192
|
-
});
|
|
193
|
-
|
|
194
|
-
await runCli();
|
|
195
|
-
|
|
196
|
-
expect(exitSpy).toHaveBeenCalledWith(1);
|
|
197
|
-
});
|
|
198
|
-
});
|
|
199
|
-
});
|
|
1
|
+
import type { MockInstance } from 'vitest';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
const mockExecSync = vi.fn();
|
|
5
|
+
const mockExistsSync = vi.fn<(path: string) => boolean>();
|
|
6
|
+
const mockUnlinkSync = vi.fn();
|
|
7
|
+
const mockWriteFileSync = vi.fn();
|
|
8
|
+
|
|
9
|
+
vi.mock('node:child_process', () => ({
|
|
10
|
+
execSync: mockExecSync,
|
|
11
|
+
}));
|
|
12
|
+
|
|
13
|
+
vi.mock('node:fs', () => ({
|
|
14
|
+
existsSync: mockExistsSync,
|
|
15
|
+
unlinkSync: mockUnlinkSync,
|
|
16
|
+
writeFileSync: mockWriteFileSync,
|
|
17
|
+
}));
|
|
18
|
+
|
|
19
|
+
async function runCli(): Promise<void> {
|
|
20
|
+
vi.resetModules();
|
|
21
|
+
// @ts-expect-error: CLI function in JavaScript
|
|
22
|
+
await import('./cli.mjs');
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
describe('cli.mjs', () => {
|
|
26
|
+
let exitSpy: MockInstance;
|
|
27
|
+
|
|
28
|
+
beforeEach(() => {
|
|
29
|
+
mockExecSync.mockReturnValue(Buffer.from(''));
|
|
30
|
+
mockExistsSync.mockReturnValue(false);
|
|
31
|
+
exitSpy = vi.spyOn(process, 'exit').mockImplementation(() => undefined as never);
|
|
32
|
+
vi.spyOn(console, 'log').mockReturnValue(undefined);
|
|
33
|
+
vi.spyOn(console, 'error').mockReturnValue(undefined);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
afterEach(() => {
|
|
37
|
+
vi.restoreAllMocks();
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
describe('install command', () => {
|
|
41
|
+
it('runs npm install --save-dev for npm', async () => {
|
|
42
|
+
await runCli();
|
|
43
|
+
|
|
44
|
+
expect(mockExecSync).toHaveBeenCalledWith(
|
|
45
|
+
expect.stringContaining('npm install --save-dev'),
|
|
46
|
+
expect.anything(),
|
|
47
|
+
);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('runs pnpm add -D for pnpm', async () => {
|
|
51
|
+
mockExistsSync.mockImplementation((path: string) => path === 'pnpm-lock.yaml');
|
|
52
|
+
|
|
53
|
+
await runCli();
|
|
54
|
+
|
|
55
|
+
expect(mockExecSync).toHaveBeenCalledWith(
|
|
56
|
+
expect.stringContaining('pnpm add -D'),
|
|
57
|
+
expect.anything(),
|
|
58
|
+
);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it('runs yarn add -D for yarn', async () => {
|
|
62
|
+
mockExistsSync.mockImplementation((path: string) => path === 'yarn.lock');
|
|
63
|
+
|
|
64
|
+
await runCli();
|
|
65
|
+
|
|
66
|
+
expect(mockExecSync).toHaveBeenCalledWith(
|
|
67
|
+
expect.stringContaining('yarn add -D'),
|
|
68
|
+
expect.anything(),
|
|
69
|
+
);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it('runs bun add -D for bun', async () => {
|
|
73
|
+
mockExistsSync.mockImplementation((path: string) => path === 'bun.lockb');
|
|
74
|
+
|
|
75
|
+
await runCli();
|
|
76
|
+
|
|
77
|
+
expect(mockExecSync).toHaveBeenCalledWith(
|
|
78
|
+
expect.stringContaining('bun add -D'),
|
|
79
|
+
expect.anything(),
|
|
80
|
+
);
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
describe('husky initialization', () => {
|
|
85
|
+
it('runs npx husky init for npm', async () => {
|
|
86
|
+
await runCli();
|
|
87
|
+
|
|
88
|
+
expect(mockExecSync).toHaveBeenCalledWith(
|
|
89
|
+
'npx husky init',
|
|
90
|
+
expect.anything(),
|
|
91
|
+
);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it('runs pnpm dlx husky init for pnpm', async () => {
|
|
95
|
+
mockExistsSync.mockImplementation((path: string) => path === 'pnpm-lock.yaml');
|
|
96
|
+
|
|
97
|
+
await runCli();
|
|
98
|
+
|
|
99
|
+
expect(mockExecSync).toHaveBeenCalledWith(
|
|
100
|
+
'pnpm exec husky init',
|
|
101
|
+
expect.anything(),
|
|
102
|
+
);
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
describe('pre-commit hook removal', () => {
|
|
107
|
+
it('removes the default pre-commit hook when it exists', async () => {
|
|
108
|
+
mockExistsSync.mockImplementation((path: string) => path === '.husky/pre-commit');
|
|
109
|
+
|
|
110
|
+
await runCli();
|
|
111
|
+
|
|
112
|
+
expect(mockUnlinkSync).toHaveBeenCalledWith('.husky/pre-commit');
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
it('skips removal when pre-commit hook does not exist', async () => {
|
|
116
|
+
await runCli();
|
|
117
|
+
|
|
118
|
+
expect(mockUnlinkSync).not.toHaveBeenCalled();
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
describe('commit-msg hook', () => {
|
|
123
|
+
it('writes hook with npx runner for npm', async () => {
|
|
124
|
+
await runCli();
|
|
125
|
+
|
|
126
|
+
expect(mockWriteFileSync).toHaveBeenCalledWith(
|
|
127
|
+
'.husky/commit-msg',
|
|
128
|
+
'npx --no -- commitlint --edit $1\n',
|
|
129
|
+
);
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
it('writes hook with pnpm exec runner for pnpm', async () => {
|
|
133
|
+
mockExistsSync.mockImplementation((path: string) => path === 'pnpm-lock.yaml');
|
|
134
|
+
|
|
135
|
+
await runCli();
|
|
136
|
+
|
|
137
|
+
expect(mockWriteFileSync).toHaveBeenCalledWith(
|
|
138
|
+
'.husky/commit-msg',
|
|
139
|
+
'pnpm exec commitlint --edit $1\n',
|
|
140
|
+
);
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
it('writes hook with yarn run runner for yarn', async () => {
|
|
144
|
+
mockExistsSync.mockImplementation((path: string) => path === 'yarn.lock');
|
|
145
|
+
|
|
146
|
+
await runCli();
|
|
147
|
+
|
|
148
|
+
expect(mockWriteFileSync).toHaveBeenCalledWith(
|
|
149
|
+
'.husky/commit-msg',
|
|
150
|
+
'yarn run commitlint --edit $1\n',
|
|
151
|
+
);
|
|
152
|
+
});
|
|
153
|
+
|
|
154
|
+
it('writes hook with bunx runner for bun', async () => {
|
|
155
|
+
mockExistsSync.mockImplementation((path: string) => path === 'bun.lockb');
|
|
156
|
+
|
|
157
|
+
await runCli();
|
|
158
|
+
|
|
159
|
+
expect(mockWriteFileSync).toHaveBeenCalledWith(
|
|
160
|
+
'.husky/commit-msg',
|
|
161
|
+
'bunx --bun commitlint --edit $1\n',
|
|
162
|
+
);
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
describe('commitlint config', () => {
|
|
167
|
+
it('creates commitlint.config.ts with the expected export', async () => {
|
|
168
|
+
await runCli();
|
|
169
|
+
|
|
170
|
+
expect(mockWriteFileSync).toHaveBeenCalledWith(
|
|
171
|
+
'commitlint.config.ts',
|
|
172
|
+
"export { default } from '@abelspithost/commitlint';\n",
|
|
173
|
+
);
|
|
174
|
+
});
|
|
175
|
+
|
|
176
|
+
it('skips commitlint.config.ts if it already exists', async () => {
|
|
177
|
+
mockExistsSync.mockImplementation((path: string) => path === 'commitlint.config.ts');
|
|
178
|
+
|
|
179
|
+
await runCli();
|
|
180
|
+
|
|
181
|
+
expect(mockWriteFileSync).not.toHaveBeenCalledWith(
|
|
182
|
+
'commitlint.config.ts',
|
|
183
|
+
expect.anything(),
|
|
184
|
+
);
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
describe('error handling', () => {
|
|
189
|
+
it('calls process.exit(1) when a step fails', async () => {
|
|
190
|
+
mockExecSync.mockImplementation(() => {
|
|
191
|
+
throw new Error('command failed');
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
await runCli();
|
|
195
|
+
|
|
196
|
+
expect(exitSpy).toHaveBeenCalledWith(1);
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
});
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { RuleConfigSeverity, type UserConfig } from '@commitlint/types';
|
|
2
|
-
export { COMMIT_TYPES } from './constants/commitTypes.js';
|
|
3
2
|
export { configuration, configuration as default, createConfig } from './config/config.js';
|
|
3
|
+
export { COMMIT_TYPES } from './constants/commitTypes.js';
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,KAAK,UAAU,EAAE,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,KAAK,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAExE,OAAO,EAAE,aAAa,EAAE,aAAa,IAAI,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC3F,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { RuleConfigSeverity } from '@commitlint/types';
|
|
2
|
-
export { COMMIT_TYPES } from './constants/commitTypes.js';
|
|
3
2
|
export { configuration, configuration as default, createConfig } from './config/config.js';
|
|
3
|
+
export { COMMIT_TYPES } from './constants/commitTypes.js';
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAmB,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAmB,MAAM,mBAAmB,CAAC;AAExE,OAAO,EAAE,aAAa,EAAE,aAAa,IAAI,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAC3F,OAAO,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,69 +1,69 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@abelspithost/commitlint",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "Shared commitlint preset extending @commitlint/config-conventional with stricter defaults",
|
|
5
|
-
"keywords": [
|
|
6
|
-
"commitlint",
|
|
7
|
-
"commitlint-config",
|
|
8
|
-
"conventional",
|
|
9
|
-
"commits",
|
|
10
|
-
"conventional-commits",
|
|
11
|
-
"husky",
|
|
12
|
-
"git-hooks"
|
|
13
|
-
],
|
|
14
|
-
"homepage": "https://github.com/aspithost/commitlint#readme",
|
|
15
|
-
"repository": {
|
|
16
|
-
"type": "git",
|
|
17
|
-
"url": "https://github.com/aspithost/commitlint.git"
|
|
18
|
-
},
|
|
19
|
-
"license": "ISC",
|
|
20
|
-
"author": {
|
|
21
|
-
"name": "Abel Spithost",
|
|
22
|
-
"url": "https://github.com/aspithost"
|
|
23
|
-
},
|
|
24
|
-
"engines": {
|
|
25
|
-
"node": ">=20"
|
|
26
|
-
},
|
|
27
|
-
"type": "module",
|
|
28
|
-
"exports": {
|
|
29
|
-
".": {
|
|
30
|
-
"types": "./dist/index.d.ts",
|
|
31
|
-
"import": "./dist/index.js"
|
|
32
|
-
}
|
|
33
|
-
},
|
|
34
|
-
"bin": {
|
|
35
|
-
"init": "./bin/cli.mjs"
|
|
36
|
-
},
|
|
37
|
-
"files": [
|
|
38
|
-
"bin",
|
|
39
|
-
"dist"
|
|
40
|
-
],
|
|
41
|
-
"scripts": {
|
|
42
|
-
"build": "npm run clean && tsc -p tsconfig.build.json",
|
|
43
|
-
"clean": "rimraf dist",
|
|
44
|
-
"lint": "eslint .",
|
|
45
|
-
"test:unit": "vitest",
|
|
46
|
-
"test:cov": "vitest run --coverage --coverage.reporter=text",
|
|
47
|
-
"typecheck": "tsc --noEmit",
|
|
48
|
-
"prepare": "husky"
|
|
49
|
-
},
|
|
50
|
-
"dependencies": {
|
|
51
|
-
"@commitlint/config-conventional": "^20.
|
|
52
|
-
"@commitlint/format": "^20.
|
|
53
|
-
"@commitlint/types": "^20.
|
|
54
|
-
},
|
|
55
|
-
"devDependencies": {
|
|
56
|
-
"@abelspithost/eslint-config-ts": "^0.
|
|
57
|
-
"@abelspithost/tsconfig-node": "^0.0.
|
|
58
|
-
"@commitlint/cli": "^20.
|
|
59
|
-
"@types/node": "^24.
|
|
60
|
-
"@vitest/coverage-v8": "^4.
|
|
61
|
-
"commitlint": "^20.
|
|
62
|
-
"eslint": "^
|
|
63
|
-
"husky": "^9.1.7",
|
|
64
|
-
"jiti": "^2.6.1",
|
|
65
|
-
"rimraf": "^6.1.
|
|
66
|
-
"typescript": "^
|
|
67
|
-
"vitest": "^4.
|
|
68
|
-
}
|
|
69
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@abelspithost/commitlint",
|
|
3
|
+
"version": "0.0.3",
|
|
4
|
+
"description": "Shared commitlint preset extending @commitlint/config-conventional with stricter defaults",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"commitlint",
|
|
7
|
+
"commitlint-config",
|
|
8
|
+
"conventional",
|
|
9
|
+
"commits",
|
|
10
|
+
"conventional-commits",
|
|
11
|
+
"husky",
|
|
12
|
+
"git-hooks"
|
|
13
|
+
],
|
|
14
|
+
"homepage": "https://github.com/aspithost/commitlint#readme",
|
|
15
|
+
"repository": {
|
|
16
|
+
"type": "git",
|
|
17
|
+
"url": "https://github.com/aspithost/commitlint.git"
|
|
18
|
+
},
|
|
19
|
+
"license": "ISC",
|
|
20
|
+
"author": {
|
|
21
|
+
"name": "Abel Spithost",
|
|
22
|
+
"url": "https://github.com/aspithost"
|
|
23
|
+
},
|
|
24
|
+
"engines": {
|
|
25
|
+
"node": ">=20"
|
|
26
|
+
},
|
|
27
|
+
"type": "module",
|
|
28
|
+
"exports": {
|
|
29
|
+
".": {
|
|
30
|
+
"types": "./dist/index.d.ts",
|
|
31
|
+
"import": "./dist/index.js"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"bin": {
|
|
35
|
+
"init": "./bin/cli.mjs"
|
|
36
|
+
},
|
|
37
|
+
"files": [
|
|
38
|
+
"bin",
|
|
39
|
+
"dist"
|
|
40
|
+
],
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "npm run clean && tsc -p tsconfig.build.json",
|
|
43
|
+
"clean": "rimraf dist",
|
|
44
|
+
"lint": "eslint .",
|
|
45
|
+
"test:unit": "vitest",
|
|
46
|
+
"test:cov": "vitest run --coverage --coverage.reporter=text",
|
|
47
|
+
"typecheck": "tsc --noEmit",
|
|
48
|
+
"prepare": "husky || true"
|
|
49
|
+
},
|
|
50
|
+
"dependencies": {
|
|
51
|
+
"@commitlint/config-conventional": "^20.5.0",
|
|
52
|
+
"@commitlint/format": "^20.5.0",
|
|
53
|
+
"@commitlint/types": "^20.5.0"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@abelspithost/eslint-config-ts": "^1.0.3",
|
|
57
|
+
"@abelspithost/tsconfig-node": "^0.0.5",
|
|
58
|
+
"@commitlint/cli": "^20.5.0",
|
|
59
|
+
"@types/node": "^24.12.2",
|
|
60
|
+
"@vitest/coverage-v8": "^4.1.4",
|
|
61
|
+
"commitlint": "^20.5.0",
|
|
62
|
+
"eslint": "^10.2.0",
|
|
63
|
+
"husky": "^9.1.7",
|
|
64
|
+
"jiti": "^2.6.1",
|
|
65
|
+
"rimraf": "^6.1.3",
|
|
66
|
+
"typescript": "^6.0.2",
|
|
67
|
+
"vitest": "^4.1.4"
|
|
68
|
+
}
|
|
69
|
+
}
|