Skip to content
This repository was archived by the owner on Sep 4, 2024. It is now read-only.

Commit c879812

Browse files
authored
fix(ci-cd): add commitlint and husky (#8)
* fix(ci-cd): add commitlint and husky GH-0 * refactor(ci-cd): remove prettier check GH-0 * fix(core): manually run prettier fix GH-0 * fix(ci-cd): add prettier check back GH-0
1 parent 3ce2938 commit c879812

20 files changed

+1774
-226
lines changed

.cz-config.js

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
module.exports = {
2+
types: [
3+
{value: 'feat', name: 'feat: A new feature'},
4+
{value: 'fix', name: 'fix: A bug fix'},
5+
{value: 'docs', name: 'docs: Documentation only changes'},
6+
{
7+
value: 'style',
8+
name: 'style: Changes that do not affect the meaning of the code\n (white-space, formatting, missing semi-colons, etc)',
9+
},
10+
{
11+
value: 'refactor',
12+
name: 'refactor: A code change that neither fixes a bug nor adds a feature',
13+
},
14+
{
15+
value: 'perf',
16+
name: 'perf: A code change that improves performance',
17+
},
18+
{value: 'test', name: 'test: Adding missing tests'},
19+
{
20+
value: 'chore',
21+
name: 'chore: Changes to the build process or auxiliary tools\n and libraries such as documentation generation',
22+
},
23+
{value: 'revert', name: 'revert: Reverting a commit'},
24+
{value: 'WIP', name: 'WIP: Work in progress'},
25+
],
26+
27+
scopes: [
28+
{name: 'deps'},
29+
{name: 'ci-cd'},
30+
{name: 'component'},
31+
{name: 'providers'},
32+
{name: 'services'},
33+
{name: 'decorators'},
34+
{name: 'core'},
35+
{name: 'repository'},
36+
{name: 'datasource'},
37+
],
38+
39+
appendBranchNameToCommitMessage: true,
40+
appendIssueFromBranchName: true,
41+
allowTicketNumber: false,
42+
isTicketNumberRequired: false,
43+
44+
// override the messages, defaults are as follows
45+
messages: {
46+
type: "Select the type of change that you're committing:",
47+
scope: 'Denote the SCOPE of this change:',
48+
// used if allowCustomScopes is true
49+
customScope: 'Denote the SCOPE of this change:',
50+
subject: 'Write a SHORT, IMPERATIVE tense description of the change:\n',
51+
body: 'Provide a LONGER description of the change (optional). Use "|" to break new line:\n',
52+
breaking: 'List any BREAKING CHANGES (optional):\n',
53+
footer: 'List any ISSUES CLOSED by this change (optional). E.g.: GH-144:\n',
54+
confirmCommit: 'Are you sure you want to proceed with the commit above?',
55+
},
56+
57+
allowCustomScopes: false,
58+
allowBreakingChanges: ['feat', 'fix'],
59+
60+
// limit subject length
61+
subjectLimit: 100,
62+
breaklineChar: '|', // It is supported for fields body and footer.
63+
footerPrefix: '',
64+
askForBreakingChangeFirst: true, // default is false
65+
};

.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ node_modules/
22
dist/
33
coverage/
44
.eslintrc.js
5+
.cz-config.js
6+
commitlint.config.js

.eslintrc.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,12 @@
11
module.exports = {
22
extends: '@loopback/eslint-config',
3+
rules: {
4+
'no-extra-boolean-cast': 'off',
5+
'@typescript-eslint/interface-name-prefix': 'off',
6+
'no-prototype-builtins': 'off',
7+
},
8+
parserOptions: {
9+
project: './tsconfig.json',
10+
tsconfigRootDir: __dirname,
11+
},
312
};

.husky/commit-msg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
npx --no-install commitlint --edit

.husky/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
npm test

.husky/prepare-commit-msg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
exec < /dev/tty && npx cz --hook || true

commitlint.config.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
module.exports = {
2+
extends: ['@commitlint/config-conventional'],
3+
rules: {
4+
'header-max-length': [2, 'always', 100],
5+
'body-leading-blank': [2, 'always'],
6+
'footer-leading-blank': [0, 'always'],
7+
'references-empty': [2, 'never'],
8+
},
9+
parserPreset: {
10+
parserOpts: {
11+
issuePrefixes: ['GH-'],
12+
},
13+
},
14+
};

0 commit comments

Comments
 (0)