当前位置: 首页 > Web前端 > vue.js

提交规格

时间:2023-03-31 22:38:48 vue.js

提交规范说明使用inquirer选择配置的提交类型,配合commitlint实现commit检查npmiinquirershelljs@commitlint/{cli,config-conventional}-D添加package.json脚本"commitlint":"commitlint-e","commit":"nodecommit/git-commit.js"创建commit/git-commit.js文件constshell=require('shelljs')constinquirer=require('inquirer')constprompsConfig={ciType:[{type:'list',name:'type',message:'请选择提交类型:',choices:[{name:'引入新功能',value:'feat',},{name:'改进代码结构格式/样式',value:'style',},{name:'fixbug',value:'fix',},{name:'improveperformance',value:'perf',},{name:'删除代码或文件',value:'delete',},{name:'其他修改,例如更改构建过程,或添加依赖库、工具等',value:'chore',},{name:'重构',value:'重构',},{name:'写文档',value:'docs',},{name:'添加测试',value:'test',},{name:'更新包文件',value:'build',},{name:'初次提交',value:'init',},{name:'release/versionlabel',value:'release',},{name:'deploymentfeature',value:'deploy',},{name:'coderollback',value:'revert',},{name:'CI持续集成修改',value:'ci',},],},],ciMsg:{type:'input',name:'msg',message:'请输入提交文本:',validate:function(value){if(value){returntrue}return'Textmustbeentered!'},},}asyncfunctiongitCommit(){let{type}=awaitinquirer.prompt(prompsConfig.ciType)let{msg}=awaitinquirer.prompt(prompsConfig.ciMsg)shell.exec(`gitcommit-m"${type}:${msg}"`,function(){控制台.log(`\n提交脚本:gitcommit-m"${type}:${msg}"`)})}gitCommit()配置commitlint类型,创建commitlint.config.js文件module.exports={extends:['@commitlint/config-conventional'],rules:{'type-enum':[2,'always',['build','chore','ci','feat','docs','fix','perf','revert','refactor','style','测试','初始化','构建','发布','删除']],}};