@cenk1cenk2/cz-cc 1.4.11 → 1.5.2
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 +31 -0
- package/README.md +3 -5
- package/dist/index.js +11 -49
- package/package.json +22 -20
- package/dist/engine.js +0 -208
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,34 @@
|
|
|
1
|
+
## [1.5.2](https://github.com/cenk1cenk2/cz-cc/compare/v1.5.1...v1.5.2) (2022-03-09)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
- **deps:** update dependency listr2 to ^4.0.5 ([6113cbd](https://github.com/cenk1cenk2/cz-cc/commit/6113cbd437e2d02ac7455fa5e8cc1ce3edba0835))
|
|
6
|
+
|
|
7
|
+
## [1.5.1](https://github.com/cenk1cenk2/cz-cc/compare/v1.5.0...v1.5.1) (2022-02-10)
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
- import bug ([f5fcadc](https://github.com/cenk1cenk2/cz-cc/commit/f5fcadc87a5da33c6696af93cd9f6f90bc79ccb8))
|
|
12
|
+
- retry ([4c47e3f](https://github.com/cenk1cenk2/cz-cc/commit/4c47e3fd8f62aa8905b73a6ccf334ffc1b4a2655))
|
|
13
|
+
- test ([95ad68f](https://github.com/cenk1cenk2/cz-cc/commit/95ad68f3faeef20974647f9e2d7bd22ea46d1d36))
|
|
14
|
+
- test ([2b393a2](https://github.com/cenk1cenk2/cz-cc/commit/2b393a28a4505a8bead184e54932f747f08fb60b))
|
|
15
|
+
- update ([5426b0d](https://github.com/cenk1cenk2/cz-cc/commit/5426b0d4fc9dec9513c13fc34b8b15f7d32ad7c2))
|
|
16
|
+
- update edit ([7a3ef6b](https://github.com/cenk1cenk2/cz-cc/commit/7a3ef6b523868eb9d30a59ca1b02ba7f4cede4af))
|
|
17
|
+
- update import ([131c202](https://github.com/cenk1cenk2/cz-cc/commit/131c2028e9c871a417e2d5860b6e639bb5013455))
|
|
18
|
+
|
|
19
|
+
# [1.5.0](https://github.com/cenk1cenk2/cz-cc/compare/v1.4.11...v1.5.0) (2022-02-10)
|
|
20
|
+
|
|
21
|
+
### Bug Fixes
|
|
22
|
+
|
|
23
|
+
- go back to the non esm lint-staged ([999f4e9](https://github.com/cenk1cenk2/cz-cc/commit/999f4e9406b04a424e87302c7b01740eb246fbd6))
|
|
24
|
+
- update the hint ([6275ec5](https://github.com/cenk1cenk2/cz-cc/commit/6275ec5be0ce539cc4a32f7024c581b549ff95f2))
|
|
25
|
+
- **deps:** update dependency listr2 to ^3.13.5 ([240435e](https://github.com/cenk1cenk2/cz-cc/commit/240435efbfdfb1cb5035b0f840a96fa06362368c))
|
|
26
|
+
- **deps:** update dependency listr2 to ^3.14.0 ([95decf1](https://github.com/cenk1cenk2/cz-cc/commit/95decf1acb681f279f172c8bda36ca5bf0fe9a22))
|
|
27
|
+
|
|
28
|
+
### Features
|
|
29
|
+
|
|
30
|
+
- update build method ([20cb37a](https://github.com/cenk1cenk2/cz-cc/commit/20cb37a9bf6b2874a3cde3cc83a7952ee6f34329))
|
|
31
|
+
|
|
1
32
|
## [1.4.11](https://github.com/cenk1cenk2/cz-cc/compare/v1.4.10...v1.4.11) (2021-11-17)
|
|
2
33
|
|
|
3
34
|
### Bug Fixes
|
package/README.md
CHANGED
|
@@ -40,14 +40,12 @@ commitizen init @cenk1cenk2/cz-cc --yarn --dev
|
|
|
40
40
|
commitizen init @cenk1cenk2/cz-cc --dev
|
|
41
41
|
```
|
|
42
42
|
|
|
43
|
-
- Add
|
|
43
|
+
- Add git-hooks.
|
|
44
44
|
|
|
45
45
|
```json
|
|
46
46
|
{
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"prepare-commit-msg": "exec < /dev/tty && git cz --hook || true"
|
|
50
|
-
}
|
|
47
|
+
"simple-git-hooks": {
|
|
48
|
+
"prepare-commit-msg": "[ -t 1 ] && exec < /dev/tty && git cz --hook || true"
|
|
51
49
|
}
|
|
52
50
|
}
|
|
53
51
|
```
|
package/dist/index.js
CHANGED
|
@@ -1,49 +1,11 @@
|
|
|
1
|
-
"
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
})
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
var _engine = _interopRequireDefault(require("./engine"));
|
|
13
|
-
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
16
|
-
function bootstrap() {
|
|
17
|
-
const config = _commitizen.configLoader.load() || {};
|
|
18
|
-
const options = {
|
|
19
|
-
types: config.types || _conventionalCommitTypes.default.types,
|
|
20
|
-
defaultType: process.env.CZ_TYPE || config.defaultType || 'fix',
|
|
21
|
-
defaultScope: process.env.CZ_SCOPE || config.defaultScope,
|
|
22
|
-
defaultSubject: process.env.CZ_SUBJECT || config.defaultSubject,
|
|
23
|
-
defaultBody: process.env.CZ_BODY || config.defaultBody,
|
|
24
|
-
defaultIssues: process.env.CZ_ISSUES || config.defaultIssues,
|
|
25
|
-
disableScopeLowerCase: process.env.DISABLE_SCOPE_LOWERCASE || config.disableScopeLowerCase,
|
|
26
|
-
maxHeaderWidth: process.env.CZ_MAX_HEADER_WIDTH && parseInt(process.env.CZ_MAX_HEADER_WIDTH, 10) || config.maxHeaderWidth || 100,
|
|
27
|
-
maxLineWidth: process.env.CZ_MAX_LINE_WIDTH && parseInt(process.env.CZ_MAX_LINE_WIDTH, 10) || config.maxLineWidth || 100
|
|
28
|
-
};
|
|
29
|
-
|
|
30
|
-
try {
|
|
31
|
-
const commitlint = require('@commitlint/load');
|
|
32
|
-
|
|
33
|
-
commitlint.default().then(function (clConfig) {
|
|
34
|
-
if (clConfig.rules) {
|
|
35
|
-
const maxHeaderLengthRule = clConfig.rules['header-max-length'];
|
|
36
|
-
|
|
37
|
-
if (typeof maxHeaderLengthRule === 'object' && maxHeaderLengthRule.length >= 3 && !process.env.CZ_MAX_HEADER_WIDTH && !config.maxHeaderWidth) {
|
|
38
|
-
options.maxHeaderWidth = maxHeaderLengthRule[2];
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
}); // eslint-disable-next-line no-empty
|
|
42
|
-
} catch (err) {}
|
|
43
|
-
|
|
44
|
-
return (0, _engine.default)(options);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
var _default = bootstrap();
|
|
48
|
-
|
|
49
|
-
exports.default = _default;
|
|
1
|
+
var M=Object.create;var l=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var Z=Object.getOwnPropertyNames;var B=Object.getPrototypeOf,P=Object.prototype.hasOwnProperty;var g=e=>l(e,"__esModule",{value:!0});var O=(e,t)=>{for(var i in t)l(e,i,{get:t[i],enumerable:!0})},y=(e,t,i,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of Z(t))!P.call(e,o)&&(i||o!=="default")&&l(e,o,{get:()=>t[o],enumerable:!(n=R(t,o))||n.enumerable});return e},m=(e,t)=>y(g(l(e!=null?M(B(e)):{},"default",!t&&e&&e.__esModule?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e),G=(e=>(t,i)=>e&&e.get(t)||(i=y(g({}),t,1),e&&e.set(t,i),i))(typeof WeakMap!="undefined"?new WeakMap:0);var $={};O($,{default:()=>X});var H=require("commitizen"),W=m(require("conventional-commit-types"));var E=m(require("colorette")),b=m(require("enquirer")),x=m(require("find-git-root")),_=m(require("fs")),I=require("listr2"),L=m(require("lodash.map")),A=require("path"),u=m(require("word-wrap"));var w=require("enquirer"),S=require("external-editor"),h=class extends w.Prompt{constructor(t={}){super(t);this.value=this.state.initial||""}async suffix(t=""){let i=this.state.cancelled?" \u2014 Aborted":this.state.submitted?" \u2014 Received":" \u2014 Press <Enter> to launch "+t;return this.styles.dim(i)}async submit(){return this.value=(0,S.edit)(this.value),super.submit()}async render(){let t=await this.prefix()+" ",i=await this.message(),n=await this.error(),o=n?await this.suffix("the editor again"):await this.suffix("an editor");this.clear(this.state.size),this.cursorHide(),this.write(this.style.bold(t)+i+o),n&&this.write(`
|
|
2
|
+
`+n.split(`
|
|
3
|
+
`).join(""))}};function N(e){return e.type.length+2+(e.scope?e.scope.length+2:0)}function k(e,t){return e.maxHeaderWidth-N(t)}function C(e){for(e=e.trim(),e.charAt(0).toLowerCase()!==e.charAt(0)&&(e=e.charAt(0).toLowerCase()+e.slice(1,e.length));e.endsWith(".");)e=e.slice(0,e.length-1);return e}function v(e){let t=e.types,i=(0,L.default)(t,function(o,c){return{name:c,hint:o.description,value:c}}),n=new b.default;return n=n.register("editor",h),{prompter(o,c){new I.Listr([{enabled:()=>{let r=(0,x.default)(process.cwd()),p=(0,A.join)(r,"COMMIT_EDITMSG");if(r)try{let s=_.default.readFileSync(p,"utf-8");if(new RegExp(/^Merge branch/).test(s))return!0}catch{}},task:async(r,p)=>{if(await p.prompt({type:"Toggle",message:"Last commit was found as merge commit do you want to skip?",initial:!0}))throw new Error("Skipping because of merge commit.")}},{task:async(r,p)=>r.prompts=await p.prompt([{type:"AutoComplete",name:"type",message:"Type of commit:",choices:i,initial:i.findIndex(s=>s.value===e.defaultType)},{type:"Input",name:"subject",message:s=>`Write a short description (max ${k(e,s)} chars):
|
|
4
|
+
`,initial:e.defaultSubject,required:!0,validate:s=>{let a=C(s);return a.length<=e.maxHeaderWidth&&a.length>0?!0:`Subject length must be less than or equal to ${e.maxHeaderWidth} characters. Current length is ${a.length} characters.`}},{type:"MultiSelect",name:"additional",message:"Please select additional actions.",choices:[{name:"scope",message:"add a scope"},{name:"issue",message:"resolves issues"},{name:"breaking-changes",message:"introduces breaking changes"},{name:"long-description",message:"add a long description"},{name:"skip-ci",message:"skip ci/cd setups"}]}])},{task:(r,p)=>p.newListr([{skip:s=>!s.prompts.additional.includes("scope"),task:async(s,a)=>{s.prompts.scope=await a.prompt({type:"Input",message:`Please state the scope of the change:
|
|
5
|
+
`,initial:e.defaultScope,format:d=>e.disableScopeLowerCase?d.trim():d.trim().toLowerCase()})}},{skip:s=>!s.prompts.additional.some(a=>["long-description"].includes(a)),task:async(s,a)=>{s.prompts.body=await a.prompt([{type:"editor",name:"default",message:`Please give a long description:
|
|
6
|
+
`,initial:e.defaultBody}])}},{skip:s=>!s.prompts.additional.includes("issue"),task:async(s,a)=>{s.prompts.issues=await a.prompt({type:"Input",message:`Add issue references:
|
|
7
|
+
`,hint:"fix #123, re #124",initial:e.defaultIssues})}},{skip:s=>!s.prompts.additional.includes("breaking-changes"),task:async(s,a)=>{s.prompts.breaking=await a.prompt({type:"editor",message:`Describe the breaking changes:
|
|
8
|
+
`})}}])}],{rendererOptions:{collapse:!1},rendererFallback:!1,injectWrapper:{enquirer:n}}).run().then(r=>{let p={trim:!0,cut:!1,newline:`
|
|
9
|
+
`,indent:"",width:e.maxLineWidth},s=r.prompts.scope?`(${r.prompts.scope})`:"",a=r.prompts.type+s+": "+r.prompts.subject;r.prompts.additional.includes("skip-ci")&&(a=a+" [skip ci]");let d=r.prompts.body?(0,u.default)(r.prompts.body,p):!1,T=r.prompts.breaking?(0,u.default)("BREAKING CHANGE: "+r.prompts.breaking.trim().replace(/^BREAKING CHANGE: /,""),p):!1,D=r.prompts.issues?(0,u.default)(r.prompts.issues,p):!1;c([a,d,T,D].filter(Boolean).join(`
|
|
10
|
+
|
|
11
|
+
`))}).catch(()=>{console.log(E.default.yellow("Cancelled. Skipping..."))})}}}function q(){let e=H.configLoader.load()||{},t={types:e.types||W.default.types,defaultType:process.env.CZ_TYPE||e.defaultType||"fix",defaultScope:process.env.CZ_SCOPE||e.defaultScope,defaultSubject:process.env.CZ_SUBJECT||e.defaultSubject,defaultBody:process.env.CZ_BODY||e.defaultBody,defaultIssues:process.env.CZ_ISSUES||e.defaultIssues,disableScopeLowerCase:process.env.DISABLE_SCOPE_LOWERCASE||e.disableScopeLowerCase,maxHeaderWidth:process.env.CZ_MAX_HEADER_WIDTH&&parseInt(process.env.CZ_MAX_HEADER_WIDTH,10)||e.maxHeaderWidth||100,maxLineWidth:process.env.CZ_MAX_LINE_WIDTH&&parseInt(process.env.CZ_MAX_LINE_WIDTH,10)||e.maxLineWidth||100};try{require("@commitlint/load").default().then(function(n){if(n.rules){let o=n.rules["header-max-length"];typeof o=="object"&&o.length>=3&&!process.env.CZ_MAX_HEADER_WIDTH&&!e.maxHeaderWidth&&(t.maxHeaderWidth=o[2])}})}catch{}return v(t)}var X=q();module.exports=G($);0&&(module.exports={});
|
package/package.json
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cenk1cenk2/cz-cc",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.2",
|
|
4
4
|
"description": "Commitizen adapter following the conventional-changelog format.",
|
|
5
|
-
"main": "./dist/index.js",
|
|
6
5
|
"repository": "https://github.com/cenk1cenk2/cz-cc",
|
|
7
|
-
"author": "Cenk Kilic <cenk@kilic.dev>
|
|
6
|
+
"author": "Cenk Kilic <cenk@kilic.dev>",
|
|
8
7
|
"license": "MIT",
|
|
8
|
+
"type": "commonjs",
|
|
9
|
+
"main": "./dist/index.js",
|
|
9
10
|
"publishConfig": {
|
|
10
11
|
"access": "public"
|
|
11
12
|
},
|
|
12
13
|
"scripts": {
|
|
13
|
-
"build": "
|
|
14
|
+
"build": "tsup-node",
|
|
15
|
+
"dev:start": "tsup-node --watch",
|
|
14
16
|
"lint": "prettier --write src/ && eslint --ext .ts,.js,.tsx,.jsx --fix src/",
|
|
15
17
|
"lint:check": "eslint --ext .ts,.js,.tsx,.jsx src/"
|
|
16
18
|
},
|
|
@@ -19,42 +21,42 @@
|
|
|
19
21
|
"prepare-commit-msg": "[ -t 1 ] && exec < /dev/tty && git cz --hook || true"
|
|
20
22
|
},
|
|
21
23
|
"lint-staged": {
|
|
22
|
-
"
|
|
24
|
+
"*.{ts,js,tsx,jsx}": [
|
|
23
25
|
"prettier --write",
|
|
24
26
|
"eslint --fix"
|
|
25
27
|
],
|
|
26
|
-
"
|
|
28
|
+
"*.{json,md}": [
|
|
27
29
|
"prettier --write"
|
|
28
30
|
]
|
|
29
31
|
},
|
|
30
|
-
"engineStrict": true,
|
|
31
32
|
"engines": {
|
|
32
|
-
"node": ">=
|
|
33
|
+
"node": ">= 16"
|
|
33
34
|
},
|
|
34
35
|
"dependencies": {
|
|
35
|
-
"colorette": "^
|
|
36
|
+
"colorette": "^2.0.16",
|
|
36
37
|
"commitizen": "^4.2.4",
|
|
37
38
|
"conventional-commit-types": "^3.0.0",
|
|
38
39
|
"enquirer": "^2.3.6",
|
|
39
40
|
"enquirer-editor": "^1.0.0",
|
|
40
|
-
"enquirer-prompt-editor": "^2.0.1",
|
|
41
41
|
"find-git-root": "^1.0.4",
|
|
42
|
-
"listr2": "^
|
|
42
|
+
"listr2": "^4.0.5",
|
|
43
43
|
"lodash.map": "^4.6.0",
|
|
44
44
|
"word-wrap": "^1.2.3"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
|
-
"@babel/cli": "^7.
|
|
48
|
-
"@babel/core": "^7.
|
|
49
|
-
"@babel/preset-env": "^7.16.
|
|
50
|
-
"@cenk1cenk2/eslint-config": "^
|
|
51
|
-
"eslint": "^8.
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
47
|
+
"@babel/cli": "^7.17.6",
|
|
48
|
+
"@babel/core": "^7.17.5",
|
|
49
|
+
"@babel/preset-env": "^7.16.11",
|
|
50
|
+
"@cenk1cenk2/eslint-config": "^2.5.7",
|
|
51
|
+
"eslint": "^8.9.0",
|
|
52
|
+
"external-editor": "^3.1.0",
|
|
53
|
+
"lint-staged": "^11",
|
|
54
|
+
"prettier": "^2.5.1",
|
|
55
|
+
"simple-git-hooks": "^2.7.0",
|
|
56
|
+
"tsup": "^5.12.0"
|
|
55
57
|
},
|
|
56
58
|
"optionalDependencies": {
|
|
57
|
-
"@commitlint/load": "^
|
|
59
|
+
"@commitlint/load": "^16.1.0"
|
|
58
60
|
},
|
|
59
61
|
"config": {
|
|
60
62
|
"commitizen": {
|
package/dist/engine.js
DELETED
|
@@ -1,208 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = _default;
|
|
7
|
-
|
|
8
|
-
var _colorette = _interopRequireDefault(require("colorette"));
|
|
9
|
-
|
|
10
|
-
var _enquirer = _interopRequireDefault(require("enquirer"));
|
|
11
|
-
|
|
12
|
-
var _enquirerEditor = _interopRequireDefault(require("enquirer-editor"));
|
|
13
|
-
|
|
14
|
-
var _findGitRoot = _interopRequireDefault(require("find-git-root"));
|
|
15
|
-
|
|
16
|
-
var _fs = _interopRequireDefault(require("fs"));
|
|
17
|
-
|
|
18
|
-
var _listr = require("listr2");
|
|
19
|
-
|
|
20
|
-
var _lodash = _interopRequireDefault(require("lodash.map"));
|
|
21
|
-
|
|
22
|
-
var _path = require("path");
|
|
23
|
-
|
|
24
|
-
var _wordWrap = _interopRequireDefault(require("word-wrap"));
|
|
25
|
-
|
|
26
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
27
|
-
|
|
28
|
-
function headerLength(answers) {
|
|
29
|
-
return answers.type.length + 2 + (answers.scope ? answers.scope.length + 2 : 0);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
function maxSummaryLength(options, answers) {
|
|
33
|
-
return options.maxHeaderWidth - headerLength(answers);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function filterSubject(subject) {
|
|
37
|
-
subject = subject.trim();
|
|
38
|
-
|
|
39
|
-
if (subject.charAt(0).toLowerCase() !== subject.charAt(0)) {
|
|
40
|
-
subject = subject.charAt(0).toLowerCase() + subject.slice(1, subject.length);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
while (subject.endsWith('.')) {
|
|
44
|
-
subject = subject.slice(0, subject.length - 1);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
return subject;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
function _default(options) {
|
|
51
|
-
const types = options.types;
|
|
52
|
-
const choices = (0, _lodash.default)(types, function (type, key) {
|
|
53
|
-
return {
|
|
54
|
-
name: key,
|
|
55
|
-
hint: type.description,
|
|
56
|
-
value: key
|
|
57
|
-
};
|
|
58
|
-
});
|
|
59
|
-
let enquirer = new _enquirer.default();
|
|
60
|
-
enquirer = enquirer.register('editor', _enquirerEditor.default);
|
|
61
|
-
return {
|
|
62
|
-
prompter(cz, commit) {
|
|
63
|
-
new _listr.Listr([{
|
|
64
|
-
enabled: () => {
|
|
65
|
-
// try for merge message
|
|
66
|
-
const gitRoot = (0, _findGitRoot.default)(process.cwd());
|
|
67
|
-
const commitMsg = (0, _path.join)(gitRoot, 'COMMIT_EDITMSG');
|
|
68
|
-
|
|
69
|
-
if (gitRoot) {
|
|
70
|
-
try {
|
|
71
|
-
const lastCommit = _fs.default.readFileSync(commitMsg, 'utf-8');
|
|
72
|
-
|
|
73
|
-
if (new RegExp(/^Merge branch/).test(lastCommit)) {
|
|
74
|
-
return true;
|
|
75
|
-
} // eslint-disable-next-line no-empty
|
|
76
|
-
|
|
77
|
-
} catch {}
|
|
78
|
-
}
|
|
79
|
-
},
|
|
80
|
-
task: async (ctx, task) => {
|
|
81
|
-
if (await task.prompt({
|
|
82
|
-
type: 'Toggle',
|
|
83
|
-
message: 'Last commit was found as merge commit do you want to skip?',
|
|
84
|
-
initial: true
|
|
85
|
-
})) {
|
|
86
|
-
throw new Error('Skipping because of merge commit.');
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}, {
|
|
90
|
-
task: async (ctx, task) => ctx.prompts = await task.prompt([{
|
|
91
|
-
type: 'AutoComplete',
|
|
92
|
-
name: 'type',
|
|
93
|
-
message: 'Type of commit:',
|
|
94
|
-
choices,
|
|
95
|
-
initial: choices.findIndex(val => val.value === options.defaultType)
|
|
96
|
-
}, {
|
|
97
|
-
type: 'Input',
|
|
98
|
-
name: 'subject',
|
|
99
|
-
message: answers => {
|
|
100
|
-
return `Write a short description (max ${maxSummaryLength(options, answers)} chars):\n`;
|
|
101
|
-
},
|
|
102
|
-
initial: options.defaultSubject,
|
|
103
|
-
required: true,
|
|
104
|
-
validate: value => {
|
|
105
|
-
const filteredSubject = filterSubject(value);
|
|
106
|
-
return filteredSubject.length <= options.maxHeaderWidth && filteredSubject.length > 0 ? true : `Subject length must be less than or equal to ${options.maxHeaderWidth} characters. Current length is ${filteredSubject.length} characters.`;
|
|
107
|
-
}
|
|
108
|
-
}, {
|
|
109
|
-
type: 'MultiSelect',
|
|
110
|
-
name: 'additional',
|
|
111
|
-
message: 'Please select additional actions.',
|
|
112
|
-
choices: [{
|
|
113
|
-
name: 'scope',
|
|
114
|
-
message: 'add a scope'
|
|
115
|
-
}, {
|
|
116
|
-
name: 'issue',
|
|
117
|
-
message: 'resolves issues'
|
|
118
|
-
}, {
|
|
119
|
-
name: 'breaking-changes',
|
|
120
|
-
message: 'introduces breaking changes'
|
|
121
|
-
}, {
|
|
122
|
-
name: 'long-description',
|
|
123
|
-
message: 'add a long description'
|
|
124
|
-
}, {
|
|
125
|
-
name: 'skip-ci',
|
|
126
|
-
message: 'skip ci/cd setups'
|
|
127
|
-
}]
|
|
128
|
-
}])
|
|
129
|
-
}, {
|
|
130
|
-
task: (ctx, task) => task.newListr([{
|
|
131
|
-
skip: ctx => !ctx.prompts.additional.includes('scope'),
|
|
132
|
-
task: async (ctx, task) => {
|
|
133
|
-
ctx.prompts.scope = await task.prompt({
|
|
134
|
-
type: 'Input',
|
|
135
|
-
message: 'Please state the scope of the change:\n',
|
|
136
|
-
initial: options.defaultScope,
|
|
137
|
-
format: value => {
|
|
138
|
-
return options.disableScopeLowerCase ? value.trim() : value.trim().toLowerCase();
|
|
139
|
-
}
|
|
140
|
-
});
|
|
141
|
-
}
|
|
142
|
-
}, {
|
|
143
|
-
skip: ctx => !ctx.prompts.additional.some(property => ['long-description'].includes(property)),
|
|
144
|
-
task: async (ctx, task) => {
|
|
145
|
-
ctx.prompts.body = await task.prompt([{
|
|
146
|
-
type: 'editor',
|
|
147
|
-
name: 'default',
|
|
148
|
-
message: 'Please give a long description:\n',
|
|
149
|
-
initial: options.defaultBody
|
|
150
|
-
}]);
|
|
151
|
-
}
|
|
152
|
-
}, {
|
|
153
|
-
skip: ctx => !ctx.prompts.additional.includes('issue'),
|
|
154
|
-
task: async (ctx, task) => {
|
|
155
|
-
ctx.prompts.issues = await task.prompt({
|
|
156
|
-
type: 'Input',
|
|
157
|
-
message: 'Add issue references (e.g. "fix #123, re #124".):\n',
|
|
158
|
-
initial: options.defaultIssues
|
|
159
|
-
});
|
|
160
|
-
}
|
|
161
|
-
}, {
|
|
162
|
-
skip: ctx => !ctx.prompts.additional.includes('breaking-changes'),
|
|
163
|
-
task: async (ctx, task) => {
|
|
164
|
-
ctx.prompts.breaking = await task.prompt({
|
|
165
|
-
type: 'editor',
|
|
166
|
-
message: 'Describe the breaking changes:\n'
|
|
167
|
-
});
|
|
168
|
-
}
|
|
169
|
-
}])
|
|
170
|
-
}], {
|
|
171
|
-
rendererOptions: {
|
|
172
|
-
collapse: false
|
|
173
|
-
},
|
|
174
|
-
rendererFallback: false,
|
|
175
|
-
injectWrapper: {
|
|
176
|
-
enquirer
|
|
177
|
-
}
|
|
178
|
-
}).run().then(ctx => {
|
|
179
|
-
const wrapOptions = {
|
|
180
|
-
trim: true,
|
|
181
|
-
cut: false,
|
|
182
|
-
newline: '\n',
|
|
183
|
-
indent: '',
|
|
184
|
-
width: options.maxLineWidth
|
|
185
|
-
}; // parentheses are only needed when a scope is present
|
|
186
|
-
|
|
187
|
-
const scope = ctx.prompts.scope ? `(${ctx.prompts.scope})` : ''; // Hard limit this line in the validate
|
|
188
|
-
|
|
189
|
-
let head = ctx.prompts.type + scope + ': ' + ctx.prompts.subject;
|
|
190
|
-
|
|
191
|
-
if (ctx.prompts.additional.includes('skip-ci')) {
|
|
192
|
-
head = head + ' [skip ci]';
|
|
193
|
-
} // Wrap these lines at options.maxLineWidth characters
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
const body = ctx.prompts.body ? (0, _wordWrap.default)(ctx.prompts.body, wrapOptions) : false; // Apply breaking change prefix, removing it if already present
|
|
197
|
-
|
|
198
|
-
const breaking = ctx.prompts.breaking ? (0, _wordWrap.default)('BREAKING CHANGE: ' + ctx.prompts.breaking.trim().replace(/^BREAKING CHANGE: /, ''), wrapOptions) : false;
|
|
199
|
-
const issues = ctx.prompts.issues ? (0, _wordWrap.default)(ctx.prompts.issues, wrapOptions) : false;
|
|
200
|
-
commit([head, body, breaking, issues].filter(Boolean).join('\n\n'));
|
|
201
|
-
}).catch(() => {
|
|
202
|
-
// eslint-disable-next-line no-console
|
|
203
|
-
console.log(_colorette.default.yellow('Cancelled. Skipping...'));
|
|
204
|
-
});
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
};
|
|
208
|
-
}
|