Skip to content

Commit 9b5cf19

Browse files
chore: #250 refresh and refactor commit wizard workflow
1 parent fa86f74 commit 9b5cf19

8 files changed

Lines changed: 70 additions & 354 deletions

File tree

.cz.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"path": "@commitlint/cz-commitlint"
2+
"path": "./cz-config.js"
33
}

.github/workflows/ci.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,4 +36,4 @@ jobs:
3636
npm run build
3737
- name: Commitlint Check
3838
if: github.event_name == 'push'
39-
run: npm run commit:lint --last --verbose
39+
run: npm run commit:lint

.husky/pre-commit

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

CONTRIBUTING.md

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -318,15 +318,18 @@ For links to `/discord/`, a redirect is configured in _netlify.toml_ to redirect
318318
319319
## Pull Requests
320320
321-
To best help facilitate contributions to the project, we have Conventional Commits configured for the project to walk you through preparing commits in the format of `<type>(<scope>): <summary of change>`, e.g. _bug(cli): fixed bug with the thing_. This workflow will also run your files through Prettier.
321+
To best help facilitate contributions to the project, we have Conventional Commits configured for the project to walk you through preparing commits in the format of `<type>: #<issue> <summary-of-change>`, e.g. _bug: #123 fixed bug with the thing_.
322322
323-
After staging the files you ready to commit with git add, you can initiate the commit "wizard" by running:
323+
Make sure you have run `npm run lint`, `npm run format` and `npm run test` to prepare your commit. Then, after staging your files with `git add`, you can initiate the commit "wizard" by running:
324324
325325
```sh
326326
$ npm run commit
327327
```
328328
329-
The PR title should match the conventional commits format as well. If you make the PR after one commit, GitHub will automatically use the first commit as the.
329+
The following will be required:
330+
331+
- **type**
332+
- **issue reference** (can technically be empty)
330333
331334
## Continuous Integration
332335

commitlint.config.js

Lines changed: 0 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -8,68 +8,8 @@ export default {
88
["feat", "enhancement", "fix", "chore", "content", "docs", "revert"],
99
],
1010
"type-empty": [2, "never"],
11-
"scope-empty": [2, "always"],
1211
"subject-case": [2, "always", "lower-case"],
1312
"body-case": [2, "always", "lower-case"],
1413
"header-case": [2, "always", "lower-case"],
1514
},
16-
// emojis don't actually work
17-
// https://github.com/conventional-changelog/commitlint/issues/4534
18-
prompt: {
19-
settings: {
20-
enableMultipleScopes: false,
21-
scopeEnumSeparator: ",",
22-
},
23-
questions: {
24-
type: {
25-
description: "Select the type of change that you're committing:",
26-
enum: {
27-
feat: {
28-
description: "A new feature",
29-
title: "Features",
30-
emoji: "✨",
31-
},
32-
enhancement: {
33-
description: "A code change that neither fixes a bug nor adds a feature",
34-
title: "Code Refactoring",
35-
emoji: "💪",
36-
},
37-
fix: {
38-
description: "A bug fix",
39-
title: "Bug Fixes",
40-
emoji: "🐛",
41-
},
42-
chore: {
43-
description: "Other changes that don't modify src files",
44-
title: "Chores",
45-
emoji: "🛠",
46-
},
47-
docs: {
48-
description: "Docs or guide changes",
49-
title: "Documentation",
50-
emoji: "📚",
51-
},
52-
content: {
53-
description: "Copy only changes or blog posts",
54-
title: "Content",
55-
emoji: "📝",
56-
},
57-
revert: {
58-
description: "Reverts a previous commit",
59-
title: "Reverts",
60-
emoji: "🗑",
61-
},
62-
},
63-
},
64-
subject: {
65-
description: "Write a short, imperative tense description of the change",
66-
},
67-
isIssueAffected: {
68-
description: "Does this change affect any open issues?",
69-
},
70-
issues: {
71-
description: 'Add issue references (e.g. "#123")',
72-
},
73-
},
74-
},
7515
};

cz-config.js

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// NOTE: need to keep types and scope consistent with commitlint.config.js
2+
// https://commitizen.github.io/cz-cli/
3+
const types = [
4+
{ value: "feature", name: "feature: ✨ A new feature" },
5+
{
6+
value: "enhancement",
7+
name: "enhancement: 💪 A code change that neither fixes a bug nor adds a feature",
8+
},
9+
{ value: "fix", name: "fix: 🐛 A bug fix" },
10+
{ value: "docs", name: "docs: 📚 Docs or guides content changes" },
11+
{ value: "content", name: "content: 📝 Copy only changes or blog posts" },
12+
{ value: "chore", name: "chore: 🛠 Other changes that don't modify src files" },
13+
{ value: "revert", name: "revert: 🗑 Reverts a previous commit" },
14+
];
15+
16+
export default {
17+
prompter: async (cz, commit) => {
18+
const { type } = await cz.prompt([
19+
{
20+
type: "list",
21+
name: "type",
22+
message: "Select the type of the change",
23+
choices: types,
24+
},
25+
]);
26+
27+
const { subject } = await cz.prompt([
28+
{
29+
type: "input",
30+
name: "subject",
31+
message: "Write a short, imperative description of the change",
32+
validate: (input) => {
33+
if (input.length === 0) {
34+
return "Subject is required";
35+
}
36+
37+
return true;
38+
},
39+
},
40+
]);
41+
42+
const { issue } = await cz.prompt([
43+
{
44+
type: "input",
45+
name: "issue",
46+
message: "Enter the issue associated with this change (e.g. 123)",
47+
validate: (input) => {
48+
if (input.startsWith("#")) {
49+
return "Please do not include the #";
50+
}
51+
52+
return true;
53+
},
54+
},
55+
]);
56+
57+
const issueFormat = issue === "" ? "" : `#${issue} `;
58+
const message = `${type}: ${issueFormat}${subject}`;
59+
60+
commit(message);
61+
},
62+
};

0 commit comments

Comments
 (0)