@vyriy/commit 0.1.9

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Vyriy contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,76 @@
1
+ # @vyriy/commit
2
+
3
+ Helper for validating commit message text in Vyriy projects.
4
+
5
+ ## Purpose
6
+
7
+ This package reads `.git/COMMIT_EDITMSG` and checks the commit message against a custom validation rule.
8
+
9
+ If the message is invalid, it:
10
+
11
+ - prints an error message
12
+ - prints additional usage guidance
13
+ - exits the process with code `1`
14
+
15
+ Merge commits and auto-merging messages are ignored.
16
+
17
+ ## Install
18
+
19
+ With npm:
20
+
21
+ ```bash
22
+ npm install @vyriy/commit
23
+ ```
24
+
25
+ With Yarn:
26
+
27
+ ```bash
28
+ yarn add @vyriy/commit
29
+ ```
30
+
31
+ ## Usage
32
+
33
+ Example `bin/commit.js`:
34
+
35
+ ```js
36
+ #!/usr/bin/env node
37
+
38
+ import { commit } from '@vyriy/commit';
39
+
40
+ commit({
41
+ rule: /[A-Z]{2,}-[0-9]+(,[A-Z]{2,}-[0-9]+)*/,
42
+ error: 'Wrong commit format!',
43
+ info: [
44
+ 'It must be a Jira ticket id or a sequence of Jira ticket ids separated by commas.',
45
+ 'For example -> fix(JT-123): fixing something',
46
+ ].join('\n'),
47
+ });
48
+ ```
49
+
50
+ This is useful in local git hooks, for example in `commit-msg`.
51
+
52
+ ## Husky
53
+
54
+ This package can be used together with Husky.
55
+
56
+ Example `.husky/commit-msg`:
57
+
58
+ ```sh
59
+ #!/bin/sh
60
+
61
+ node bin/commit.js
62
+ ```
63
+
64
+ ## API
65
+
66
+ `commit(params)`
67
+
68
+ - `params.rule`: regular expression used to validate the commit message
69
+ - `params.error`: message printed when validation fails
70
+ - `params.info`: additional instructions shown after the error message
71
+
72
+ ## Notes
73
+
74
+ - the package reads the message from `.git/COMMIT_EDITMSG`
75
+ - invalid messages terminate the current process with exit code `1`
76
+ - merge commit messages are allowed without custom validation
package/commit.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ import { Commit } from './types.js';
2
+ export declare const commit: Commit;
package/commit.js ADDED
@@ -0,0 +1,12 @@
1
+ import { readFileSync } from 'node:fs';
2
+ import { createLogger } from '@vyriy/logger';
3
+ import { path } from '@vyriy/path';
4
+ export const commit = ({ rule, error, info }) => {
5
+ const msg = readFileSync(path('.git/COMMIT_EDITMSG'), 'utf8');
6
+ if (!rule.test(msg) && !msg.startsWith('Merge') && !msg.startsWith('Auto-merging')) {
7
+ const logger = createLogger();
8
+ logger.error(error);
9
+ logger.info(info);
10
+ process.exit(1);
11
+ }
12
+ };
package/index.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from './commit.js';
2
+ export type * from './types.js';
package/index.js ADDED
@@ -0,0 +1 @@
1
+ export * from './commit.js';
package/package.json ADDED
@@ -0,0 +1,40 @@
1
+ {
2
+ "name": "@vyriy/commit",
3
+ "version": "0.1.9",
4
+ "description": "Shared commit package for Vyriy projects",
5
+ "type": "module",
6
+ "main": "./index.js",
7
+ "dependencies": {
8
+ "@vyriy/logger": "0.1.9",
9
+ "@vyriy/path": "0.1.9"
10
+ },
11
+ "license": "MIT",
12
+ "types": "./index.d.ts",
13
+ "exports": {
14
+ ".": {
15
+ "types": "./index.d.ts",
16
+ "import": "./index.js",
17
+ "default": "./index.js"
18
+ },
19
+ "./commit": {
20
+ "types": "./commit.d.ts",
21
+ "import": "./commit.js",
22
+ "default": "./commit.js"
23
+ },
24
+ "./commit.js": {
25
+ "types": "./commit.d.ts",
26
+ "import": "./commit.js",
27
+ "default": "./commit.js"
28
+ },
29
+ "./index": {
30
+ "types": "./index.d.ts",
31
+ "import": "./index.js",
32
+ "default": "./index.js"
33
+ },
34
+ "./index.js": {
35
+ "types": "./index.d.ts",
36
+ "import": "./index.js",
37
+ "default": "./index.js"
38
+ }
39
+ }
40
+ }
package/types.d.ts ADDED
@@ -0,0 +1,6 @@
1
+ export type CommitParams = {
2
+ rule: RegExp;
3
+ error: string;
4
+ info: string;
5
+ };
6
+ export type Commit = (params: CommitParams) => void;