@commitlint/cz-commitlint 13.2.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.
- package/CHANGELOG.md +43 -0
- package/README.md +61 -0
- package/lib/Process.d.ts +4 -0
- package/lib/Process.d.ts.map +1 -0
- package/lib/Process.js +23 -0
- package/lib/Process.js.map +1 -0
- package/lib/Question.d.ts +42 -0
- package/lib/Question.d.ts.map +1 -0
- package/lib/Question.js +134 -0
- package/lib/Question.js.map +1 -0
- package/lib/SectionBody.d.ts +4 -0
- package/lib/SectionBody.d.ts.map +1 -0
- package/lib/SectionBody.js +42 -0
- package/lib/SectionBody.js.map +1 -0
- package/lib/SectionFooter.d.ts +12 -0
- package/lib/SectionFooter.d.ts.map +1 -0
- package/lib/SectionFooter.js +138 -0
- package/lib/SectionFooter.js.map +1 -0
- package/lib/SectionHeader.d.ts +12 -0
- package/lib/SectionHeader.d.ts.map +1 -0
- package/lib/SectionHeader.js +51 -0
- package/lib/SectionHeader.js.map +1 -0
- package/lib/index.d.ts +11 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +21 -0
- package/lib/index.js.map +1 -0
- package/lib/services/getRuleQuestionConfig.d.ts +4 -0
- package/lib/services/getRuleQuestionConfig.d.ts.map +1 -0
- package/lib/services/getRuleQuestionConfig.js +63 -0
- package/lib/services/getRuleQuestionConfig.js.map +1 -0
- package/lib/store/defaultPromptConfigs.d.ts +29 -0
- package/lib/store/defaultPromptConfigs.d.ts.map +1 -0
- package/lib/store/defaultPromptConfigs.js +30 -0
- package/lib/store/defaultPromptConfigs.js.map +1 -0
- package/lib/store/prompts.d.ts +5 -0
- package/lib/store/prompts.d.ts.map +1 -0
- package/lib/store/prompts.js +39 -0
- package/lib/store/prompts.js.map +1 -0
- package/lib/store/rules.d.ts +7 -0
- package/lib/store/rules.d.ts.map +1 -0
- package/lib/store/rules.js +19 -0
- package/lib/store/rules.js.map +1 -0
- package/lib/types.d.ts +3 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +3 -0
- package/lib/types.js.map +1 -0
- package/lib/utils/case-fn.d.ts +9 -0
- package/lib/utils/case-fn.d.ts.map +1 -0
- package/lib/utils/case-fn.js +52 -0
- package/lib/utils/case-fn.js.map +1 -0
- package/lib/utils/full-stop-fn-test.d.ts +2 -0
- package/lib/utils/full-stop-fn-test.d.ts.map +1 -0
- package/lib/utils/full-stop-fn-test.js +63 -0
- package/lib/utils/full-stop-fn-test.js.map +1 -0
- package/lib/utils/full-stop-fn.d.ts +9 -0
- package/lib/utils/full-stop-fn.d.ts.map +1 -0
- package/lib/utils/full-stop-fn.js +32 -0
- package/lib/utils/full-stop-fn.js.map +1 -0
- package/lib/utils/leading-blank-fn-test.d.ts +2 -0
- package/lib/utils/leading-blank-fn-test.d.ts.map +1 -0
- package/lib/utils/leading-blank-fn-test.js +39 -0
- package/lib/utils/leading-blank-fn-test.js.map +1 -0
- package/lib/utils/leading-blank-fn.d.ts +8 -0
- package/lib/utils/leading-blank-fn.d.ts.map +1 -0
- package/lib/utils/leading-blank-fn.js +27 -0
- package/lib/utils/leading-blank-fn.js.map +1 -0
- package/lib/utils/rules.d.ts +30 -0
- package/lib/utils/rules.d.ts.map +1 -0
- package/lib/utils/rules.js +79 -0
- package/lib/utils/rules.js.map +1 -0
- package/license.md +19 -0
- package/package.json +53 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Change Log
|
|
2
|
+
|
|
3
|
+
All notable changes to this project will be documented in this file.
|
|
4
|
+
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
|
+
|
|
6
|
+
# [13.2.0](https://github.com/conventional-changelog/commitlint/compare/v13.1.0...v13.2.0) (2021-09-28)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @commitlint/cz-commitlint
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# [13.1.0](https://github.com/conventional-changelog/commitlint/compare/v13.0.0...v13.1.0) (2021-07-24)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Bug Fixes
|
|
18
|
+
|
|
19
|
+
* **cz-commitlint:** fix minor formatting issues ([99d8881](https://github.com/conventional-changelog/commitlint/commit/99d8881d0d951deded6d9e31bbb279d04101549b))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
# [13.0.0](https://github.com/conventional-changelog/commitlint/compare/v12.1.4...v13.0.0) (2021-05-24)
|
|
26
|
+
|
|
27
|
+
**Note:** Version bump only for package @commitlint/cz-commitlint
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
## [12.1.3](https://github.com/conventional-changelog/commitlint/compare/v12.1.2...v12.1.3) (2021-05-12)
|
|
34
|
+
|
|
35
|
+
**Note:** Version bump only for package @commitlint/cz-commitlint
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
## [12.1.2](https://github.com/conventional-changelog/commitlint/compare/v12.1.1...v12.1.2) (2021-04-29)
|
|
42
|
+
|
|
43
|
+
**Note:** Version bump only for package @commitlint/cz-commitlint
|
package/README.md
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
> Commitizen adapter using the commitlint.config.js
|
|
2
|
+
|
|
3
|
+
# @commitlint/cz-commitlint
|
|
4
|
+
|
|
5
|
+
This is a commitizen adapter, using this adapter, commitizen works based on commitlint.config.js.
|
|
6
|
+
|
|
7
|
+
Submit by commitizen, lint by commitlint, just need maintain one configuration file, Consistent and Scalable.
|
|
8
|
+
|
|
9
|
+
The interactive process is inspired by [cz-conventional-changelog](https://github.com/commitizen/cz-conventional-changelog).
|
|
10
|
+
|
|
11
|
+
## Getting started
|
|
12
|
+
|
|
13
|
+
### Configure commitizen adapter
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install --save-dev @commitlint/cz-commitlint commitizen
|
|
17
|
+
# or yarn
|
|
18
|
+
yarn add -D @commitlint/cz-commitlint commitizen
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
In package.json
|
|
22
|
+
|
|
23
|
+
```json
|
|
24
|
+
{
|
|
25
|
+
"scripts": {
|
|
26
|
+
"commit": "git-cz"
|
|
27
|
+
},
|
|
28
|
+
"config": {
|
|
29
|
+
"commitizen": {
|
|
30
|
+
"path": "@commitlint/cz-commitlint"
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Configure commitlint
|
|
37
|
+
|
|
38
|
+
**⚠️ Important: The required version of commitlint and shared configuration is above 12.1.2, update them if already existed in project**
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
# Install commitlint cli and conventional config
|
|
42
|
+
npm install --save-dev @commitlint/config-conventional @commitlint/cli
|
|
43
|
+
# or yarn
|
|
44
|
+
yarn add @commitlint/config-conventional @commitlint/cli -D
|
|
45
|
+
|
|
46
|
+
# Simple: config with conventional
|
|
47
|
+
echo "module.exports = {extends: ['@commitlint/config-conventional']};" > commitlint.config.js
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### Try it out
|
|
51
|
+
|
|
52
|
+
```bash
|
|
53
|
+
git add .
|
|
54
|
+
npm run commit
|
|
55
|
+
# or yarn
|
|
56
|
+
yarn commit
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
## Related
|
|
60
|
+
|
|
61
|
+
- [Commitlint Reference Prompt](https://commitlint.js.org/#/reference-prompt) - How to customize prompt information by setting commitlint.config.js
|
package/lib/Process.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Process.d.ts","sourceRoot":"","sources":["../src/Process.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAE,gBAAgB,EAAC,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAC,QAAQ,EAAC,MAAM,UAAU,CAAC;AAgBlC,yBACC,KAAK,EAAE,cAAc,EACrB,OAAO,EAAE,gBAAgB,EACzB,QAAQ,EAAE,QAAQ,GAChB,OAAO,CAAC,MAAM,CAAC,CAcjB"}
|
package/lib/Process.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const SectionBody_1 = require("./SectionBody");
|
|
4
|
+
const SectionFooter_1 = require("./SectionFooter");
|
|
5
|
+
const SectionHeader_1 = require("./SectionHeader");
|
|
6
|
+
const prompts_1 = require("./store/prompts");
|
|
7
|
+
const rules_1 = require("./store/rules");
|
|
8
|
+
async function default_1(rules, prompts, inquirer) {
|
|
9
|
+
(0, rules_1.setRules)(rules);
|
|
10
|
+
(0, prompts_1.setPromptConfig)(prompts);
|
|
11
|
+
const questions = [
|
|
12
|
+
...(0, SectionHeader_1.getQuestions)(),
|
|
13
|
+
...(0, SectionBody_1.getQuestions)(),
|
|
14
|
+
...(0, SectionFooter_1.getQuestions)(),
|
|
15
|
+
];
|
|
16
|
+
const answers = await inquirer.prompt(questions);
|
|
17
|
+
const header = (0, SectionHeader_1.combineCommitMessage)(answers);
|
|
18
|
+
const body = (0, SectionBody_1.combineCommitMessage)(answers);
|
|
19
|
+
const footer = (0, SectionFooter_1.combineCommitMessage)(answers);
|
|
20
|
+
return [header, body, footer].filter(Boolean).join('\n');
|
|
21
|
+
}
|
|
22
|
+
exports.default = default_1;
|
|
23
|
+
//# sourceMappingURL=Process.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Process.js","sourceRoot":"","sources":["../src/Process.ts"],"names":[],"mappings":";;AAEA,+CAGuB;AACvB,mDAGyB;AACzB,mDAGyB;AACzB,6CAAgD;AAChD,yCAAuC;AAExB,KAAK,oBACnB,KAAqB,EACrB,OAAyB,EACzB,QAAkB;IAElB,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC;IAChB,IAAA,yBAAe,EAAC,OAAO,CAAC,CAAC;IACzB,MAAM,SAAS,GAAG;QACjB,GAAG,IAAA,4BAAkB,GAAE;QACvB,GAAG,IAAA,0BAAgB,GAAE;QACrB,GAAG,IAAA,4BAAkB,GAAE;KACvB,CAAC;IACF,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC;IACjD,MAAM,MAAM,GAAG,IAAA,oCAAa,EAAC,OAAO,CAAC,CAAC;IACtC,MAAM,IAAI,GAAG,IAAA,kCAAW,EAAC,OAAO,CAAC,CAAC;IAClC,MAAM,MAAM,GAAG,IAAA,oCAAa,EAAC,OAAO,CAAC,CAAC;IAEtC,OAAO,CAAC,MAAM,EAAE,IAAI,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1D,CAAC;AAlBD,4BAkBC"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { PromptMessages, PromptName } from '@commitlint/types';
|
|
2
|
+
import { Answers, ChoiceCollection, DistinctQuestion } from 'inquirer';
|
|
3
|
+
import { CaseFn } from './utils/case-fn';
|
|
4
|
+
import { FullStopFn } from './utils/full-stop-fn';
|
|
5
|
+
export declare type QuestionConfig = {
|
|
6
|
+
title: string;
|
|
7
|
+
messages: PromptMessages;
|
|
8
|
+
maxLength?: number;
|
|
9
|
+
minLength?: number;
|
|
10
|
+
defaultValue?: string;
|
|
11
|
+
when?: DistinctQuestion['when'];
|
|
12
|
+
skip?: boolean;
|
|
13
|
+
enumList?: ChoiceCollection<{
|
|
14
|
+
name: string;
|
|
15
|
+
value: string;
|
|
16
|
+
}> | null;
|
|
17
|
+
fullStopFn?: FullStopFn;
|
|
18
|
+
caseFn?: CaseFn;
|
|
19
|
+
};
|
|
20
|
+
export default class Question {
|
|
21
|
+
private _question;
|
|
22
|
+
private messages;
|
|
23
|
+
private skip;
|
|
24
|
+
private _maxLength;
|
|
25
|
+
private _minLength;
|
|
26
|
+
private title;
|
|
27
|
+
private caseFn;
|
|
28
|
+
private fullStopFn;
|
|
29
|
+
constructor(name: PromptName, { title, enumList, messages, defaultValue, when, skip, fullStopFn, caseFn, maxLength, minLength, }: QuestionConfig);
|
|
30
|
+
getMessage(key: string): string;
|
|
31
|
+
get question(): Readonly<DistinctQuestion>;
|
|
32
|
+
get maxLength(): number;
|
|
33
|
+
set maxLength(maxLength: number);
|
|
34
|
+
get minLength(): number;
|
|
35
|
+
set minLength(minLength: number);
|
|
36
|
+
protected beforeQuestionStart(_answers: Answers): void;
|
|
37
|
+
protected validate(input: string): boolean | string;
|
|
38
|
+
protected filter(input: string): string;
|
|
39
|
+
protected transformer(input: string, _answers: Answers): string;
|
|
40
|
+
protected decorateMessage(_answers: Answers): string;
|
|
41
|
+
}
|
|
42
|
+
//# sourceMappingURL=Question.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Question.d.ts","sourceRoot":"","sources":["../src/Question.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,cAAc,EAAE,UAAU,EAAC,MAAM,mBAAmB,CAAC;AAE7D,OAAiB,EAAC,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAC,MAAM,UAAU,CAAC;AAC/E,OAAO,EAAC,MAAM,EAAC,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAC,UAAU,EAAC,MAAM,sBAAsB,CAAC;AAEhD,oBAAY,cAAc,GAAG;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,cAAc,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,IAAI,CAAC,EAAE,gBAAgB,CAAC,MAAM,CAAC,CAAC;IAChC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,QAAQ,CAAC,EAAE,gBAAgB,CAA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E,OAAO,GAAG,MAAM;CAgCpD"}
|
package/lib/Question.js
ADDED
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
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
|
+
const chalk_1 = __importDefault(require("chalk"));
|
|
7
|
+
const inquirer_1 = __importDefault(require("inquirer"));
|
|
8
|
+
class Question {
|
|
9
|
+
constructor(name, { title, enumList, messages, defaultValue, when, skip, fullStopFn, caseFn, maxLength, minLength, }) {
|
|
10
|
+
if (!name || typeof name !== 'string')
|
|
11
|
+
throw new Error('Question: name is required');
|
|
12
|
+
this._maxLength = maxLength !== null && maxLength !== void 0 ? maxLength : Infinity;
|
|
13
|
+
this._minLength = minLength !== null && minLength !== void 0 ? minLength : 0;
|
|
14
|
+
this.messages = messages;
|
|
15
|
+
this.title = title !== null && title !== void 0 ? title : '';
|
|
16
|
+
this.skip = skip !== null && skip !== void 0 ? skip : false;
|
|
17
|
+
this.fullStopFn = fullStopFn !== null && fullStopFn !== void 0 ? fullStopFn : ((_) => _);
|
|
18
|
+
this.caseFn = caseFn !== null && caseFn !== void 0 ? caseFn : ((_) => _);
|
|
19
|
+
if (enumList && Array.isArray(enumList)) {
|
|
20
|
+
this._question = {
|
|
21
|
+
type: 'list',
|
|
22
|
+
choices: skip
|
|
23
|
+
? [
|
|
24
|
+
...enumList,
|
|
25
|
+
new inquirer_1.default.Separator(),
|
|
26
|
+
{
|
|
27
|
+
name: 'empty',
|
|
28
|
+
value: '',
|
|
29
|
+
},
|
|
30
|
+
]
|
|
31
|
+
: [...enumList],
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
else if (/^is[A-Z]/.test(name)) {
|
|
35
|
+
this._question = {
|
|
36
|
+
type: 'confirm',
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
this._question = {
|
|
41
|
+
type: 'input',
|
|
42
|
+
transformer: this.transformer.bind(this),
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
Object.assign(this._question, {
|
|
46
|
+
name,
|
|
47
|
+
default: defaultValue,
|
|
48
|
+
when,
|
|
49
|
+
validate: this.validate.bind(this),
|
|
50
|
+
filter: this.filter.bind(this),
|
|
51
|
+
message: this.decorateMessage.bind(this),
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
getMessage(key) {
|
|
55
|
+
var _a;
|
|
56
|
+
return (_a = this.messages[key]) !== null && _a !== void 0 ? _a : '';
|
|
57
|
+
}
|
|
58
|
+
get question() {
|
|
59
|
+
return this._question;
|
|
60
|
+
}
|
|
61
|
+
get maxLength() {
|
|
62
|
+
return this._maxLength;
|
|
63
|
+
}
|
|
64
|
+
set maxLength(maxLength) {
|
|
65
|
+
this._maxLength = maxLength;
|
|
66
|
+
}
|
|
67
|
+
get minLength() {
|
|
68
|
+
return this._minLength;
|
|
69
|
+
}
|
|
70
|
+
set minLength(minLength) {
|
|
71
|
+
this._minLength = minLength;
|
|
72
|
+
}
|
|
73
|
+
beforeQuestionStart(_answers) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
validate(input) {
|
|
77
|
+
var _a;
|
|
78
|
+
const output = this.filter(input);
|
|
79
|
+
const questionName = (_a = this.question.name) !== null && _a !== void 0 ? _a : '';
|
|
80
|
+
if (!this.skip && output.length === 0) {
|
|
81
|
+
return this.getMessage('emptyWarning').replace(/%s/g, questionName);
|
|
82
|
+
}
|
|
83
|
+
if (output.length > this.maxLength) {
|
|
84
|
+
return this.getMessage('upperLimitWarning')
|
|
85
|
+
.replace(/%s/g, questionName)
|
|
86
|
+
.replace(/%d/g, `${output.length - this.maxLength}`);
|
|
87
|
+
}
|
|
88
|
+
if (output.length < this.minLength) {
|
|
89
|
+
return this.getMessage('lowerLimitWarning')
|
|
90
|
+
.replace(/%s/g, questionName)
|
|
91
|
+
.replace(/%d/g, `${this.minLength - output.length}`);
|
|
92
|
+
}
|
|
93
|
+
return true;
|
|
94
|
+
}
|
|
95
|
+
filter(input) {
|
|
96
|
+
return this.caseFn(this.fullStopFn(input));
|
|
97
|
+
}
|
|
98
|
+
transformer(input, _answers) {
|
|
99
|
+
const output = this.filter(input);
|
|
100
|
+
if (this.maxLength === Infinity && this.minLength === 0) {
|
|
101
|
+
return output;
|
|
102
|
+
}
|
|
103
|
+
const color = output.length <= this.maxLength && output.length >= this.minLength
|
|
104
|
+
? chalk_1.default.green
|
|
105
|
+
: chalk_1.default.red;
|
|
106
|
+
return color('(' + output.length + ') ' + input);
|
|
107
|
+
}
|
|
108
|
+
decorateMessage(_answers) {
|
|
109
|
+
this.beforeQuestionStart && this.beforeQuestionStart(_answers);
|
|
110
|
+
if (this.question.type === 'input') {
|
|
111
|
+
const countLimitMessage = (() => {
|
|
112
|
+
const messages = [];
|
|
113
|
+
if (this.minLength > 0 && this.getMessage('min')) {
|
|
114
|
+
messages.push(this.getMessage('min').replace(/%d/g, this.minLength + ''));
|
|
115
|
+
}
|
|
116
|
+
if (this.maxLength < Infinity && this.getMessage('max')) {
|
|
117
|
+
messages.push(this.getMessage('max').replace(/%d/g, this.maxLength + ''));
|
|
118
|
+
}
|
|
119
|
+
return messages.join(', ');
|
|
120
|
+
})();
|
|
121
|
+
const skipMessage = this.skip && this.getMessage('skip');
|
|
122
|
+
return (this.title +
|
|
123
|
+
(skipMessage ? ` ${skipMessage}` : '') +
|
|
124
|
+
':' +
|
|
125
|
+
(countLimitMessage ? ` ${countLimitMessage}` : '') +
|
|
126
|
+
'\n');
|
|
127
|
+
}
|
|
128
|
+
else {
|
|
129
|
+
return `${this.title}:`;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
exports.default = Question;
|
|
134
|
+
//# sourceMappingURL=Question.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Question.js","sourceRoot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C,WAAW,CAAC,CAAC,CAAC,IAAI,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBACtC,GAAG;gBACH,CAAC,iBAAiB,CAAC,CAAC,CAAC,IAAI,iBAAiB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;gBAClD,IAAI,CACJ,CAAC;SACF;aAAM;YACN,OAAO,GAAG,IAAI,CAAC,KAAK,GAAG,CAAC;SACxB;IACF,CAAC;CACD;AAzKD,2BAyKC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SectionBody.d.ts","sourceRoot":"","sources":["../src/SectionBody.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAE,gBAAgB,EAAC,MAAM,UAAU,CAAC;AAQnD,wBAAgB,YAAY,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAMtD;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAoB7D"}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
"use strict";
|
|
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.combineCommitMessage = exports.getQuestions = void 0;
|
|
7
|
+
const word_wrap_1 = __importDefault(require("word-wrap"));
|
|
8
|
+
const Question_1 = __importDefault(require("./Question"));
|
|
9
|
+
const getRuleQuestionConfig_1 = __importDefault(require("./services/getRuleQuestionConfig"));
|
|
10
|
+
const rules_1 = require("./store/rules");
|
|
11
|
+
const leading_blank_fn_1 = __importDefault(require("./utils/leading-blank-fn"));
|
|
12
|
+
const rules_2 = require("./utils/rules");
|
|
13
|
+
function getQuestions() {
|
|
14
|
+
// body
|
|
15
|
+
const questionConfig = (0, getRuleQuestionConfig_1.default)('body');
|
|
16
|
+
if (!questionConfig)
|
|
17
|
+
return [];
|
|
18
|
+
else
|
|
19
|
+
return [new Question_1.default('body', questionConfig).question];
|
|
20
|
+
}
|
|
21
|
+
exports.getQuestions = getQuestions;
|
|
22
|
+
function combineCommitMessage(answers) {
|
|
23
|
+
var _a, _b;
|
|
24
|
+
const maxLineLength = (0, rules_2.getMaxLength)((0, rules_1.getRule)('body', 'max-line-length'));
|
|
25
|
+
const leadingBlankFn = (0, leading_blank_fn_1.default)((0, rules_1.getRule)('body', 'leading-blank'));
|
|
26
|
+
const { body, breakingBody, issuesBody } = answers;
|
|
27
|
+
const commitBody = (_b = (_a = body !== null && body !== void 0 ? body : breakingBody) !== null && _a !== void 0 ? _a : issuesBody) !== null && _b !== void 0 ? _b : '-';
|
|
28
|
+
if (commitBody) {
|
|
29
|
+
return leadingBlankFn(maxLineLength < Infinity
|
|
30
|
+
? (0, word_wrap_1.default)(commitBody, {
|
|
31
|
+
width: maxLineLength,
|
|
32
|
+
trim: true,
|
|
33
|
+
indent: '',
|
|
34
|
+
})
|
|
35
|
+
: commitBody.trim());
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
return '';
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
exports.combineCommitMessage = combineCommitMessage;
|
|
42
|
+
//# sourceMappingURL=SectionBody.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SectionBody.js","sourceRoot":"","sources":["../src/SectionBody.ts"],"names":[],"mappings":";;;;;;AACA,0DAA6B;AAC7B,0DAAkC;AAClC,6FAAqE;AACrE,yCAAsC;AACtC,gFAAyD;AACzD,yCAA2C;AAE3C,SAAgB,YAAY;IAC3B,OAAO;IACP,MAAM,cAAc,GAAG,IAAA,+BAAqB,EAAC,MAAM,CAAC,CAAC;IAErD,IAAI,CAAC,cAAc;QAAE,OAAO,EAAE,CAAC;;QAC1B,OAAO,CAAC,IAAI,kBAAQ,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC,QAAQ,CAAC,CAAC;AAC7D,CAAC;AAND,oCAMC;AAED,SAAgB,oBAAoB,CAAC,OAAgB;;IACpD,MAAM,aAAa,GAAG,IAAA,oBAAY,EAAC,IAAA,eAAO,EAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC,CAAC;IACvE,MAAM,cAAc,GAAG,IAAA,0BAAiB,EAAC,IAAA,eAAO,EAAC,MAAM,EAAE,eAAe,CAAC,CAAC,CAAC;IAC3E,MAAM,EAAC,IAAI,EAAE,YAAY,EAAE,UAAU,EAAC,GAAG,OAAO,CAAC;IAEjD,MAAM,UAAU,GAAG,MAAA,MAAA,IAAI,aAAJ,IAAI,cAAJ,IAAI,GAAI,YAAY,mCAAI,UAAU,mCAAI,GAAG,CAAC;IAE7D,IAAI,UAAU,EAAE;QACf,OAAO,cAAc,CACpB,aAAa,GAAG,QAAQ;YACvB,CAAC,CAAC,IAAA,mBAAI,EAAC,UAAU,EAAE;gBACjB,KAAK,EAAE,aAAa;gBACpB,IAAI,EAAE,IAAI;gBACV,MAAM,EAAE,EAAE;aACT,CAAC;YACJ,CAAC,CAAC,UAAU,CAAC,IAAI,EAAE,CACpB,CAAC;KACF;SAAM;QACN,OAAO,EAAE,CAAC;KACV;AACF,CAAC;AApBD,oDAoBC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { PromptName } from '@commitlint/types';
|
|
2
|
+
import { Answers, DistinctQuestion } from 'inquirer';
|
|
3
|
+
import Question, { QuestionConfig } from './Question';
|
|
4
|
+
export declare class FooterQuestion extends Question {
|
|
5
|
+
footerMaxLength: number;
|
|
6
|
+
footerMinLength: number;
|
|
7
|
+
constructor(name: PromptName, questionConfig: QuestionConfig, footerMaxLength?: number, footerMinLength?: number);
|
|
8
|
+
beforeQuestionStart(answers: Answers): void;
|
|
9
|
+
}
|
|
10
|
+
export declare function getQuestions(): Array<DistinctQuestion>;
|
|
11
|
+
export declare function combineCommitMessage(answers: Answers): string;
|
|
12
|
+
//# sourceMappingURL=SectionFooter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SectionFooter.d.ts","sourceRoot":"","sources":["../src/SectionFooter.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAC,OAAO,EAAE,gBAAgB,EAAC,MAAM,UAAU,CAAC;AAEnD,OAAO,QAAQ,EAAE,EAAC,cAAc,EAAC,MAAM,YAAY,CAAC;AAOpD,qBAAa,cAAe,SAAQ,QAAQ;IAC3C,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;gBAEvB,IAAI,EAAE,UAAU,EAChB,cAAc,EAAE,cAAc,EAC9B,eAAe,CAAC,EAAE,MAAM,EACxB,eAAe,CAAC,EAAE,MAAM;IAMzB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;CAM3C;AAED,wBAAgB,YAAY,IAAI,KAAK,CAAC,gBAAgB,CAAC,CA2FtD;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAiD7D"}
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
"use strict";
|
|
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.combineCommitMessage = exports.getQuestions = exports.FooterQuestion = void 0;
|
|
7
|
+
const word_wrap_1 = __importDefault(require("word-wrap"));
|
|
8
|
+
const Question_1 = __importDefault(require("./Question"));
|
|
9
|
+
const getRuleQuestionConfig_1 = __importDefault(require("./services/getRuleQuestionConfig"));
|
|
10
|
+
const prompts_1 = require("./store/prompts");
|
|
11
|
+
const rules_1 = require("./store/rules");
|
|
12
|
+
const leading_blank_fn_1 = __importDefault(require("./utils/leading-blank-fn"));
|
|
13
|
+
const rules_2 = require("./utils/rules");
|
|
14
|
+
class FooterQuestion extends Question_1.default {
|
|
15
|
+
constructor(name, questionConfig, footerMaxLength, footerMinLength) {
|
|
16
|
+
super(name, questionConfig);
|
|
17
|
+
this.footerMaxLength = footerMaxLength !== null && footerMaxLength !== void 0 ? footerMaxLength : Infinity;
|
|
18
|
+
this.footerMinLength = footerMinLength !== null && footerMinLength !== void 0 ? footerMinLength : 0;
|
|
19
|
+
}
|
|
20
|
+
beforeQuestionStart(answers) {
|
|
21
|
+
const footerRemainLength = this.footerMaxLength - combineCommitMessage(answers).length - '\n'.length;
|
|
22
|
+
this.maxLength = Math.min(this.maxLength, footerRemainLength);
|
|
23
|
+
this.minLength = Math.min(this.minLength, this.footerMinLength);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
exports.FooterQuestion = FooterQuestion;
|
|
27
|
+
function getQuestions() {
|
|
28
|
+
const footerQuestionConfig = (0, getRuleQuestionConfig_1.default)('footer');
|
|
29
|
+
if (!footerQuestionConfig)
|
|
30
|
+
return [];
|
|
31
|
+
const footerMaxLength = footerQuestionConfig.maxLength;
|
|
32
|
+
const footerMinLength = footerQuestionConfig.minLength;
|
|
33
|
+
const fields = [
|
|
34
|
+
'isBreaking',
|
|
35
|
+
'breakingBody',
|
|
36
|
+
'breaking',
|
|
37
|
+
'isIssueAffected',
|
|
38
|
+
'issuesBody',
|
|
39
|
+
'issues',
|
|
40
|
+
'footer',
|
|
41
|
+
];
|
|
42
|
+
return fields
|
|
43
|
+
.filter((name) => name in (0, prompts_1.getPromptQuestions)())
|
|
44
|
+
.map((name) => {
|
|
45
|
+
var _a, _b;
|
|
46
|
+
const questions = (0, prompts_1.getPromptQuestions)();
|
|
47
|
+
const questionConfigs = {
|
|
48
|
+
title: (_b = (_a = questions[name]) === null || _a === void 0 ? void 0 : _a.description) !== null && _b !== void 0 ? _b : '',
|
|
49
|
+
messages: (0, prompts_1.getPromptMessages)(),
|
|
50
|
+
footerMaxLength,
|
|
51
|
+
footerMinLength,
|
|
52
|
+
};
|
|
53
|
+
if (name === 'isBreaking') {
|
|
54
|
+
Object.assign(questionConfigs, {
|
|
55
|
+
defaultValue: false,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
if (name === 'breakingBody') {
|
|
59
|
+
Object.assign(questionConfigs, {
|
|
60
|
+
when: (answers) => {
|
|
61
|
+
return answers.isBreaking && !answers.body;
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
if (name === 'breaking') {
|
|
66
|
+
Object.assign(questionConfigs, {
|
|
67
|
+
when: (answers) => {
|
|
68
|
+
return answers.isBreaking;
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
if (name === 'isIssueAffected') {
|
|
73
|
+
Object.assign(questionConfigs, {
|
|
74
|
+
defaultValue: false,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
if (name === 'issuesBody') {
|
|
78
|
+
Object.assign(questionConfigs, {
|
|
79
|
+
when: (answers) => {
|
|
80
|
+
return (answers.isIssueAffected && !answers.body && !answers.breakingBody);
|
|
81
|
+
},
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
if (name === 'issues') {
|
|
85
|
+
Object.assign(questionConfigs, {
|
|
86
|
+
when: (answers) => {
|
|
87
|
+
return answers.isIssueAffected;
|
|
88
|
+
},
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
if (name === 'footer') {
|
|
92
|
+
Object.assign(questionConfigs, Object.assign({}, footerQuestionConfig));
|
|
93
|
+
}
|
|
94
|
+
const instance = new FooterQuestion(name, questionConfigs, footerMaxLength, footerMinLength);
|
|
95
|
+
return instance.question;
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
exports.getQuestions = getQuestions;
|
|
99
|
+
function combineCommitMessage(answers) {
|
|
100
|
+
// TODO references-empty
|
|
101
|
+
// TODO signed-off-by
|
|
102
|
+
const maxLineLength = (0, rules_2.getMaxLength)((0, rules_1.getRule)('footer', 'max-line-length'));
|
|
103
|
+
const leadingBlankFn = (0, leading_blank_fn_1.default)((0, rules_1.getRule)('footer', 'leading-blank'));
|
|
104
|
+
const { footer, breaking, issues } = answers;
|
|
105
|
+
const footerNotes = [];
|
|
106
|
+
if (breaking) {
|
|
107
|
+
const BREAKING_CHANGE = 'BREAKING CHANGE: ';
|
|
108
|
+
const message = BREAKING_CHANGE + breaking.replace(new RegExp(`^${BREAKING_CHANGE}`), '');
|
|
109
|
+
footerNotes.push(maxLineLength < Infinity
|
|
110
|
+
? (0, word_wrap_1.default)(message, {
|
|
111
|
+
width: maxLineLength,
|
|
112
|
+
trim: true,
|
|
113
|
+
indent: '',
|
|
114
|
+
})
|
|
115
|
+
: message.trim());
|
|
116
|
+
}
|
|
117
|
+
if (issues) {
|
|
118
|
+
footerNotes.push(maxLineLength < Infinity
|
|
119
|
+
? (0, word_wrap_1.default)(issues, {
|
|
120
|
+
width: maxLineLength,
|
|
121
|
+
trim: true,
|
|
122
|
+
indent: '',
|
|
123
|
+
})
|
|
124
|
+
: issues.trim());
|
|
125
|
+
}
|
|
126
|
+
if (footer) {
|
|
127
|
+
footerNotes.push(maxLineLength < Infinity
|
|
128
|
+
? (0, word_wrap_1.default)(footer, {
|
|
129
|
+
width: maxLineLength,
|
|
130
|
+
trim: true,
|
|
131
|
+
indent: '',
|
|
132
|
+
})
|
|
133
|
+
: footer);
|
|
134
|
+
}
|
|
135
|
+
return leadingBlankFn(footerNotes.join('\n'));
|
|
136
|
+
}
|
|
137
|
+
exports.combineCommitMessage = combineCommitMessage;
|
|
138
|
+
//# sourceMappingURL=SectionFooter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SectionFooter.js","sourceRoot":"","sources":["../src/SectionFooter.ts"],"names":[],"mappings":";;;;;;AAEA,0DAA6B;AAC7B,0DAAoD;AACpD,6FAAqE;AACrE,6CAAsE;AACtE,yCAAsC;AACtC,gFAAyD;AACzD,yCAA2C;AAE3C,MAAa,cAAe,SAAQ,kBAAQ;IAG3C,YACC,IAAgB,EAChB,cAA8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vB,CAAC,CAAC,IAAA,mBAAI,EAAC,MAAM,EAAE;gBACb,KAAK,EAAE,aAAa;gBACpB,IAAI,EAAE,IAAI;gBACV,MAAM,EAAE,EAAE;aACT,CAAC;YACJ,CAAC,CAAC,MAAM,CAAC,IAAI,EAAE,CAChB,CAAC;KACF;IAED,IAAI,MAAM,EAAE;QACX,WAAW,CAAC,IAAI,CACf,aAAa,GAAG,QAAQ;YACvB,CAAC,CAAC,IAAA,mBAAI,EAAC,MAAM,EAAE;gBACb,KAAK,EAAE,aAAa;gBACpB,IAAI,EAAE,IAAI;gBACV,MAAM,EAAE,EAAE;aACT,CAAC;YACJ,CAAC,CAAC,MAAM,CACT,CAAC;KACF;IAED,OAAO,cAAc,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC;AAC/C,CAAC;AAjDD,oDAiDC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { PromptName } from '@commitlint/types';
|
|
2
|
+
import { Answers, DistinctQuestion } from 'inquirer';
|
|
3
|
+
import Question, { QuestionConfig } from './Question';
|
|
4
|
+
export declare class HeaderQuestion extends Question {
|
|
5
|
+
headerMaxLength: number;
|
|
6
|
+
headerMinLength: number;
|
|
7
|
+
constructor(name: PromptName, questionConfig: QuestionConfig, headerMaxLength?: number, headerMinLength?: number);
|
|
8
|
+
beforeQuestionStart(answers: Answers): void;
|
|
9
|
+
}
|
|
10
|
+
export declare function combineCommitMessage(answers: Answers): string;
|
|
11
|
+
export declare function getQuestions(): Array<DistinctQuestion>;
|
|
12
|
+
//# sourceMappingURL=SectionHeader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SectionHeader.d.ts","sourceRoot":"","sources":["../src/SectionHeader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,UAAU,EAAY,MAAM,mBAAmB,CAAC;AACxD,OAAO,EAAC,OAAO,EAAE,gBAAgB,EAAC,MAAM,UAAU,CAAC;AACnD,OAAO,QAAQ,EAAE,EAAC,cAAc,EAAC,MAAM,YAAY,CAAC;AAGpD,qBAAa,cAAe,SAAQ,QAAQ;IAC3C,eAAe,EAAE,MAAM,CAAC;IACxB,eAAe,EAAE,MAAM,CAAC;gBAEvB,IAAI,EAAE,UAAU,EAChB,cAAc,EAAE,cAAc,EAC9B,eAAe,CAAC,EAAE,MAAM,EACxB,eAAe,CAAC,EAAE,MAAM;IAMzB,mBAAmB,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;CAM3C;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,OAAO,GAAG,MAAM,CAS7D;AAED,wBAAgB,YAAY,IAAI,KAAK,CAAC,gBAAgB,CAAC,CAwBtD"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
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.getQuestions = exports.combineCommitMessage = exports.HeaderQuestion = void 0;
|
|
7
|
+
const Question_1 = __importDefault(require("./Question"));
|
|
8
|
+
const getRuleQuestionConfig_1 = __importDefault(require("./services/getRuleQuestionConfig"));
|
|
9
|
+
class HeaderQuestion extends Question_1.default {
|
|
10
|
+
constructor(name, questionConfig, headerMaxLength, headerMinLength) {
|
|
11
|
+
super(name, questionConfig);
|
|
12
|
+
this.headerMaxLength = headerMaxLength !== null && headerMaxLength !== void 0 ? headerMaxLength : Infinity;
|
|
13
|
+
this.headerMinLength = headerMinLength !== null && headerMinLength !== void 0 ? headerMinLength : 0;
|
|
14
|
+
}
|
|
15
|
+
beforeQuestionStart(answers) {
|
|
16
|
+
const headerRemainLength = this.headerMaxLength - combineCommitMessage(answers).length;
|
|
17
|
+
this.maxLength = Math.min(this.maxLength, headerRemainLength);
|
|
18
|
+
this.minLength = Math.min(this.minLength, this.headerMinLength);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
exports.HeaderQuestion = HeaderQuestion;
|
|
22
|
+
function combineCommitMessage(answers) {
|
|
23
|
+
const { type = '', scope = '', subject = '' } = answers;
|
|
24
|
+
const prefix = `${type}${scope ? `(${scope})` : ''}`;
|
|
25
|
+
if (subject) {
|
|
26
|
+
return ((prefix ? prefix + ': ' : '') + subject).trim();
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
return prefix.trim();
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.combineCommitMessage = combineCommitMessage;
|
|
33
|
+
function getQuestions() {
|
|
34
|
+
// header: type, scope, subject
|
|
35
|
+
const questions = [];
|
|
36
|
+
const headerRuleFields = ['type', 'scope', 'subject'];
|
|
37
|
+
const headerRuleQuestionConfig = (0, getRuleQuestionConfig_1.default)('header');
|
|
38
|
+
if (!headerRuleQuestionConfig) {
|
|
39
|
+
return [];
|
|
40
|
+
}
|
|
41
|
+
headerRuleFields.forEach((name) => {
|
|
42
|
+
const questionConfig = (0, getRuleQuestionConfig_1.default)(name);
|
|
43
|
+
if (questionConfig) {
|
|
44
|
+
const instance = new HeaderQuestion(name, questionConfig, headerRuleQuestionConfig.maxLength, headerRuleQuestionConfig.minLength);
|
|
45
|
+
questions.push(instance.question);
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
return questions;
|
|
49
|
+
}
|
|
50
|
+
exports.getQuestions = getQuestions;
|
|
51
|
+
//# sourceMappingURL=SectionHeader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SectionHeader.js","sourceRoot":"","sources":["../src/SectionHeader.ts"],"names":[],"mappings":";;;;;;AAEA,0DAAoD;AACpD,6FAAqE;AAErE,MAAa,cAAe,SAAQ,kBAAQ;IAG3C,YACC,IAAgB,EAChB,cAA8B,EAC9B,eAAwB,EACxB,eAAwB;QAExB,KAAK,CAAC,IAAI,EAAE,cAAc,CAAC,CAAC;QAC5B,IAAI,CAAC,eA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C;IAEjE,IAAI,CAAC,wBAAwB,EAAE;QAC9B,OAAO,EAAE,CAAC;KACV;IAED,gBAAgB,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE;QACjC,MAAM,cAAc,GAAG,IAAA,+BAAqB,EAAC,IAAI,CAAC,CAAC;QACnD,IAAI,cAAc,EAAE;YACnB,MAAM,QAAQ,GAAG,IAAI,cAAc,CAClC,IAAI,EACJ,cAAc,EACd,wBAAwB,CAAC,SAAS,EAClC,wBAAwB,CAAC,SAAS,CAClC,CAAC;YACF,SAAS,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;SAClC;IACF,CAAC,CAAC,CAAC;IACH,OAAO,SAAS,CAAC;AAClB,CAAC;AAxBD,oCAwBC"}
|
package/lib/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Inquirer } from 'inquirer';
|
|
2
|
+
declare type Commit = (message: string) => void;
|
|
3
|
+
/**
|
|
4
|
+
* Entry point for commitizen
|
|
5
|
+
* @param inquirer instance passed by commitizen, unused
|
|
6
|
+
* @param commit callback to execute with complete commit message
|
|
7
|
+
* @return {void}
|
|
8
|
+
*/
|
|
9
|
+
export declare function prompter(inquirer: Inquirer, commit: Commit): void;
|
|
10
|
+
export {};
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAC,QAAQ,EAAC,MAAM,UAAU,CAAC;AAGlC,aAAK,MAAM,GAAG,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;AACxC;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,QAAQ,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAIjE"}
|