开发流程与代码规范
开发流程与代码规范
开发流程
仓库
托管在码云私有仓库上, see: https://gitee.com/
分支管理
提交流程
参见教程: http://www.ruanyifeng.com/blog/2016/01/commit_message_change_log.html
git add YOUR_EDITED_FILES
git cz
git push
安装 commitizen
commitizen, 可以实现提交提示可视化, see: https://github.com/commitizen/cz-cli
提交内容主要分为以下几个方面
feat:新功能( feature )
fix:修补bug
docs:文档( documentation )
style: 格式( 不影响代码运行的变动 )
refactor:重构( 即不是新增功能,也不是修改bug的代码变动 )
test:增加测试
chore:构建过程或辅助工具的变动
npm install -g commitizen
commitizen init cz-conventional-changelog --save --save-exact
添加 .vcmrc
安装 standard-version
主要用于生成 changelog see: https://github.com/conventional-changelog/standard-version
npm i --save-dev standard-version
安装 commitlint
https://github.com/marionebl/commitlint
安装
# Install commitlint cli and conventional config
npm install --save-dev @commitlint/{config-angular,cli}
# For Windows:
npm install --save-dev @commitlint/config-angular @commitlint/cli
echo "module.exports = {extends: ['@commitlint/config-angular']};" > commitlint.config.js
本脚手架使用 angular 规则, 详情参见:
https://github.com/marionebl/commitlint/tree/master/@commitlint/config-angular
安装 validate-commit-msg( DEPRECATED 使用 commitlint 即可)
基于这个工具可以验证提交消息的格式是否规范, 阮博士教程中安装方式有点过时,具体使用可以 see: https://github.com/conventional-changelog-archived-repos/validate-commit-msg
npm install --save-dev validate-commit-msg
安装 conventional-changelog( DEPRECATED 使用 standard-version 即可)
基于这个工具可以自动生成 changelog , 前提是得按照标准的格式书写 commit message
see: https://github.com/conventional-changelog/conventional-changelog
npm install -g conventional-changelog
在本脚手架中,可以直接使用 npm 命令执行
npm run changelog
代码规范
业界参考
- JavaScript 代码规范, 参见业界公认的 airbnb 规范: https://github.com/airbnb/javascript
- Angular 规范,直接参考官网: https://angular.io/guide/styleguide , 默认已集成部分检测工具, 如
tslint-angular
,手动检测可以执行命令npm run lint
工具
这里囊括一些已经用到或者以后需要用到的一些工具
scsslint
https://sass-guidelin.es/#tools
codelyzer
see: https://github.com/mgechev/codelyzer
npm i tslint-angular
husky
usky can prevent bad git commit, git push and more
https://www.npmjs.com/package/husky
type doc
自动根据注释生成文档的工具,前提是你自己得写好注释 see: https://github.com/TypeStrong/typedoc/
better-npm-run
能够去除配置文件硬编码 see: https://github.com/benoror/better-npm-run
留言