@commitlint/format 18.6.1 → 19.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/README.md +5 -55
- package/lib/format.js +10 -18
- package/lib/format.js.map +1 -1
- package/lib/index.d.ts +2 -2
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +2 -23
- package/lib/index.js.map +1 -1
- package/package.json +6 -5
package/README.md
CHANGED
|
@@ -1,65 +1,15 @@
|
|
|
1
|
-
> Format commitlint reports
|
|
2
|
-
|
|
3
1
|
# @commitlint/format
|
|
4
2
|
|
|
3
|
+
Format commitlint reports
|
|
4
|
+
|
|
5
5
|
## Getting started
|
|
6
6
|
|
|
7
7
|
```shell
|
|
8
8
|
npm install --save @commitlint/format
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
##
|
|
12
|
-
|
|
13
|
-
```js
|
|
14
|
-
const format = require('@commitlint/format').default;
|
|
11
|
+
## Documentation
|
|
15
12
|
|
|
16
|
-
|
|
17
|
-
{
|
|
18
|
-
valid: false,
|
|
19
|
-
errorCount: 1,
|
|
20
|
-
warningCount: 1,
|
|
21
|
-
results: [
|
|
22
|
-
{
|
|
23
|
-
valid: false,
|
|
24
|
-
input: 'some: commit message',
|
|
25
|
-
errors: [
|
|
26
|
-
{
|
|
27
|
-
valid: false,
|
|
28
|
-
level: 2,
|
|
29
|
-
name: 'some-error',
|
|
30
|
-
message: 'This will show up red as it has level 2',
|
|
31
|
-
},
|
|
32
|
-
],
|
|
33
|
-
warnings: [
|
|
34
|
-
{
|
|
35
|
-
valid: true,
|
|
36
|
-
level: 0,
|
|
37
|
-
name: 'some-hint',
|
|
38
|
-
message: 'This will not show up as it has level 0',
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
valid: false,
|
|
42
|
-
level: 1,
|
|
43
|
-
name: 'some-warning',
|
|
44
|
-
message: 'This will show up yellow as it has level 1',
|
|
45
|
-
},
|
|
46
|
-
],
|
|
47
|
-
},
|
|
48
|
-
],
|
|
49
|
-
},
|
|
50
|
-
{
|
|
51
|
-
color: false,
|
|
52
|
-
}
|
|
53
|
-
);
|
|
54
|
-
|
|
55
|
-
process.stdout.write(output);
|
|
56
|
-
|
|
57
|
-
/* => [
|
|
58
|
-
'✖ This will show up red as it has level 2 [some-error]',
|
|
59
|
-
' This will not show up as it has level 0 [some-hint]',
|
|
60
|
-
'⚠ This will show up yellow as it has level 1 [some-warning]',
|
|
61
|
-
'✖ found 1 problems, 2 warnings'
|
|
62
|
-
] */
|
|
63
|
-
```
|
|
13
|
+
Consult [API docs](https://commitlint.js.org/api/format) for comprehensive documentation.
|
|
64
14
|
|
|
65
|
-
|
|
15
|
+
Documentation generated from [`docs` folder](../../docs/api/format.md).
|
package/lib/format.js
CHANGED
|
@@ -1,13 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.formatResult = exports.format = void 0;
|
|
7
|
-
const chalk_1 = __importDefault(require("chalk"));
|
|
1
|
+
import chalk from 'chalk';
|
|
8
2
|
const DEFAULT_SIGNS = [' ', '⚠', '✖'];
|
|
9
3
|
const DEFAULT_COLORS = ['white', 'yellow', 'red'];
|
|
10
|
-
function format(report = {}, options = {}) {
|
|
4
|
+
export function format(report = {}, options = {}) {
|
|
11
5
|
const { results = [] } = report;
|
|
12
6
|
const fi = (result) => formatInput(result, options);
|
|
13
7
|
const fr = (result) => formatResult(result, options);
|
|
@@ -17,7 +11,6 @@ function format(report = {}, options = {}) {
|
|
|
17
11
|
.reduce((acc, item) => (Array.isArray(item) ? [...acc, ...item] : [...acc, item]), [])
|
|
18
12
|
.join('\n');
|
|
19
13
|
}
|
|
20
|
-
exports.format = format;
|
|
21
14
|
function formatInput(result, options = {}) {
|
|
22
15
|
const { color: enabled = true } = options;
|
|
23
16
|
const { errors = [], warnings = [], input = '' } = result;
|
|
@@ -25,36 +18,36 @@ function formatInput(result, options = {}) {
|
|
|
25
18
|
return [''];
|
|
26
19
|
}
|
|
27
20
|
const sign = '⧗';
|
|
28
|
-
const decoration = enabled ?
|
|
21
|
+
const decoration = enabled ? chalk.gray(sign) : sign;
|
|
29
22
|
const commitText = errors.length > 0 ? input : input.split('\n')[0];
|
|
30
|
-
const decoratedInput = enabled ?
|
|
23
|
+
const decoratedInput = enabled ? chalk.bold(commitText) : commitText;
|
|
31
24
|
const hasProblems = errors.length > 0 || warnings.length > 0;
|
|
32
25
|
return options.verbose || hasProblems
|
|
33
26
|
? [`${decoration} input: ${decoratedInput}`]
|
|
34
27
|
: [];
|
|
35
28
|
}
|
|
36
|
-
function formatResult(result = {}, options = {}) {
|
|
29
|
+
export function formatResult(result = {}, options = {}) {
|
|
37
30
|
const { signs = DEFAULT_SIGNS, colors = DEFAULT_COLORS, color: enabled = true, } = options;
|
|
38
31
|
const { errors = [], warnings = [] } = result;
|
|
39
32
|
const problems = [...errors, ...warnings].map((problem) => {
|
|
40
33
|
const sign = signs[problem.level] || '';
|
|
41
34
|
const color = colors[problem.level] || 'white';
|
|
42
|
-
const decoration = enabled ?
|
|
35
|
+
const decoration = enabled ? chalk[color](sign) : sign;
|
|
43
36
|
const name = enabled
|
|
44
|
-
?
|
|
37
|
+
? chalk.grey(`[${problem.name}]`)
|
|
45
38
|
: `[${problem.name}]`;
|
|
46
39
|
return `${decoration} ${problem.message} ${name}`;
|
|
47
40
|
});
|
|
48
41
|
const sign = selectSign(result);
|
|
49
42
|
const color = selectColor(result);
|
|
50
|
-
const deco = enabled ?
|
|
43
|
+
const deco = enabled ? chalk[color](sign) : sign;
|
|
51
44
|
const el = errors.length;
|
|
52
45
|
const wl = warnings.length;
|
|
53
46
|
const hasProblems = problems.length > 0;
|
|
54
47
|
const summary = options.verbose || hasProblems
|
|
55
48
|
? `${deco} found ${el} problems, ${wl} warnings`
|
|
56
49
|
: undefined;
|
|
57
|
-
const fmtSummary = enabled && typeof summary === 'string' ?
|
|
50
|
+
const fmtSummary = enabled && typeof summary === 'string' ? chalk.bold(summary) : summary;
|
|
58
51
|
const help = hasProblems && options.helpUrl
|
|
59
52
|
? `ⓘ Get help: ${options.helpUrl}`
|
|
60
53
|
: undefined;
|
|
@@ -66,8 +59,7 @@ function formatResult(result = {}, options = {}) {
|
|
|
66
59
|
hasProblems ? '' : undefined,
|
|
67
60
|
].filter((line) => typeof line === 'string');
|
|
68
61
|
}
|
|
69
|
-
|
|
70
|
-
exports.default = format;
|
|
62
|
+
export default format;
|
|
71
63
|
function selectSign(result) {
|
|
72
64
|
if ((result.errors || []).length > 0) {
|
|
73
65
|
return '✖';
|
package/lib/format.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.js","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"format.js","sourceRoot":"","sources":["../src/format.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAS1B,MAAM,aAAa,GAAG,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAU,CAAC;AAC/C,MAAM,cAAc,GAAG,CAAC,OAAO,EAAE,QAAQ,EAAE,KAAK,CAAU,CAAC;AAE3D,MAAM,UAAU,MAAM,CACrB,SAA4B,EAAE,EAC9B,UAAyB,EAAE;IAE3B,MAAM,EAAC,OAAO,GAAG,EAAE,EAAC,GAAG,MAAM,CAAC;IAC9B,MAAM,EAAE,GAAG,CAAC,MAAqC,EAAE,EAAE,CACpD,WAAW,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,MAAM,EAAE,GAAG,CAAC,MAAyB,EAAE,EAAE,CAAC,YAAY,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAExE,OAAO,OAAO;SACZ,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,O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O,CAAC,MAAM,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC;AACnD,CAAC;AAED,SAAS,WAAW,CAAC,MAAyB;IAC7C,IAAI,CAAC,MAAM,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACtC,OAAO,KAAK,CAAC;IACd,CAAC;IACD,OAAO,CAAC,MAAM,CAAC,QAAQ,IAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC;AAC5D,CAAC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { default } from './format';
|
|
2
|
-
export * from './format';
|
|
1
|
+
export { default } from './format.js';
|
|
2
|
+
export * from './format.js';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,aAAa,CAAC;AACpC,cAAc,aAAa,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -1,24 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
-
};
|
|
19
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.default = void 0;
|
|
21
|
-
var format_1 = require("./format");
|
|
22
|
-
Object.defineProperty(exports, "default", { enumerable: true, get: function () { return __importDefault(format_1).default; } });
|
|
23
|
-
__exportStar(require("./format"), exports);
|
|
1
|
+
export { default } from './format.js';
|
|
2
|
+
export * from './format.js';
|
|
24
3
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,aAAa,CAAC;AACpC,cAAc,aAAa,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@commitlint/format",
|
|
3
|
-
"
|
|
3
|
+
"type": "module",
|
|
4
|
+
"version": "19.0.3",
|
|
4
5
|
"description": "Format commitlint reports",
|
|
5
6
|
"main": "lib/index.js",
|
|
6
7
|
"types": "lib/index.d.ts",
|
|
@@ -35,11 +36,11 @@
|
|
|
35
36
|
},
|
|
36
37
|
"license": "MIT",
|
|
37
38
|
"devDependencies": {
|
|
38
|
-
"@commitlint/utils": "^
|
|
39
|
+
"@commitlint/utils": "^19.0.0"
|
|
39
40
|
},
|
|
40
41
|
"dependencies": {
|
|
41
|
-
"@commitlint/types": "^
|
|
42
|
-
"chalk": "^
|
|
42
|
+
"@commitlint/types": "^19.0.3",
|
|
43
|
+
"chalk": "^5.3.0"
|
|
43
44
|
},
|
|
44
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "9b4ac34069e06cd327760ce37adbde8d537d8e3e"
|
|
45
46
|
}
|