Skip to content

Commit

Permalink
chore: add conventional commit enforcement and conventional changelog…
Browse files Browse the repository at this point in the history
… generation
  • Loading branch information
ehrdi committed Aug 9, 2024
1 parent 7c96b0f commit f11b933
Show file tree
Hide file tree
Showing 6 changed files with 1,925 additions and 20 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## 0.0.1 (2024-08-09)

### Documentation

* docs: update readme ([f3adc58a9b39a4170f4c686dde07bfc1c5dcb6b0](https://github.com/PAYONE-GmbH/PCP-server-nodeJS-SDK/commit/f3adc58a9b39a4170f4c686dde07bfc1c5dcb6b0))
* docs: update readme ([4d596a66f3007e3d96e0ef39cacd3f278f507fdc](https://github.com/PAYONE-GmbH/PCP-server-nodeJS-SDK/commit/4d596a66f3007e3d96e0ef39cacd3f278f507fdc))

81 changes: 81 additions & 0 deletions changelog.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/* eslint-disable */
const fs = require('fs');

const customTransform = (commit, context) => {
const transformedCommit = { ...commit };

switch (transformedCommit.type) {
case 'feat':
transformedCommit.customGroup = 'Features';
break;
case 'feature':
transformedCommit.customGroup = 'Features';
break;
case 'fix':
transformedCommit.customGroup = 'Bug Fixes';
break;
case 'docs':
transformedCommit.customGroup = 'Documentation';
break;
default:
transformedCommit.customGroup = null;
}

return transformedCommit;
};

module.exports = {
writerOpts: {
transform: customTransform,
groupBy: 'customGroup',
commitGroupsSort: 'title',
commitsSort: ['scope', 'subject'],
mainTemplate: `{{> header}}
{{#each commitGroups}}
{{#if title}}
### {{title}}
{{#each commits}}
{{> commit root=@root}}
{{/each}}
{{/if}}
{{/each}}
{{> footer}}
`,
headerPartial: `{{#if isPatch~}}
##
{{~else~}}
#
{{~/if}} {{#if @root.linkCompare~}}
[{{version}}](
{{~#if @root.repository~}}
{{~#if @root.host}}
{{[email protected]}}/
{{~/if}}
{{~#if @root.owner}}
{{[email protected]}}/
{{~/if}}
{{[email protected]}}
{{~else}}
{{[email protected]}}
{{~/if~}}
/compare/{{previousTag}}...{{currentTag}})
{{~else}}
{{~version}}
{{~/if}}
{{~#if title}} "{{title}}"
{{~/if}}
{{~#if date}} ({{date}})
{{/if}}
`,
},
hooks: {
postbump: () => {
const path = 'CHANGELOG.md';
if (!fs.existsSync(path)) {
fs.writeFileSync(path, '', 'utf8');
}
},
},
};
1 change: 1 addition & 0 deletions commitlint.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export default { extends: ['@commitlint/config-conventional'] };
48 changes: 48 additions & 0 deletions lefthook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
# EXAMPLE USAGE:
#
# Refer for explanation to following link:
# https://github.com/evilmartians/lefthook/blob/master/docs/configuration.md
#
# pre-push:
# commands:
# packages-audit:
# tags: frontend security
# run: yarn audit
# gems-audit:
# tags: backend security
# run: bundle audit
#
# pre-commit:
# parallel: true
# commands:
# eslint:
# glob: "*.{js,ts,jsx,tsx}"
# run: yarn eslint {staged_files}
# rubocop:
# tags: backend style
# glob: "*.rb"
# exclude: '(^|/)(application|routes)\.rb$'
# run: bundle exec rubocop --force-exclusion {all_files}
# govet:
# tags: backend style
# files: git ls-files -m
# glob: "*.go"
# run: go vet {files}
# scripts:
# "hello.js":
# runner: node
# "any.go":
# runner: go run

pre-commit:
parallel: true
commands:
lint:
run: npm run lint
glob: "*.{js,ts}"

commit-msg:
parallel: true
commands:
commitlint:
run: npx commitlint --edit $1
Loading

0 comments on commit f11b933

Please sign in to comment.