Skip to content

Instantly share code, notes, and snippets.

@felipe1181
Last active June 21, 2020 22:50
Show Gist options
  • Save felipe1181/5cf383281631ae90bdd9427d97d739fe to your computer and use it in GitHub Desktop.
Save felipe1181/5cf383281631ae90bdd9427d97d739fe to your computer and use it in GitHub Desktop.
Setting up the development environment for the commit
Node and NPM: https://nodejs.org/en/
YARN: https://yarnpkg.com/getting-started/install
*SE FOR COM NPM:
npm install @commitlint/cli @commitlint/config-conventional --save-dev
*SE FOR COM YARN:
yarn add @commitlint/cli @commitlint/config-conventional -D
- Criar arquivo chamado **commitlint.config.js** na raíz do projeto, nele terá o conteúdo:
module.exports = {extends: ['@commitlint/config-conventional']}
Refences: https://commitlint.js.org/#/
- ATENÇÃO NESSA PARTE, SÓ INSTALE O HUSKY SE TIVER UM REPOSITÓRIO GIT INICIALIZADO ANTES!
*SE FOR COM NPM:
npm install husky --save-dev
*SE FOR COM YARN:
yarn add husky -D
Adicionar trecho de código do package.json, ele irá fazer um hook nos commit's e chamar o commitlint para barrar commits mal feitos
"husky": {
"hooks": {
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
}
References: https://www.npmjs.com/package/husky
*SE FOR COM NPM:
npm install commitizen --save-dev
npm commitizen init cz-conventional-changelog --save-dev --save-exact
*SE FOR COM YARN:
yarn add commitizen -D
yarn commitizen init cz-conventional-changelog --yarn --dev --exact
Agora vamos criar um script pra inicializar o Commitizen ,Adicionar trecho de código do package.json
"scripts": {
"commit": "git-cz"
}
Ou se já tiver scripts:
"commit": "git-cz"
References: https://www.npmjs.com/package/commitizen
{
"name": "name-project",
"version": "0.1.0",
"private": true,
"scripts": {
"commit": "git-cz"
},
"husky": {
"hooks": {
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS"
}
},
"devDependencies": {
"@commitlint/config-conventional": "^8.3.4",
"commitizen": "^4.1.2",
"cz-conventional-changelog": "3.2.0",
"husky": "^4.2.5",
},
"config": {
"commitizen": {
"path": "./node_modules/cz-conventional-changelog"
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment