Skip to content

Commit 2ec8bf0

Browse files
chore: #250 setup conventional commits (#251)
1 parent f96c9f6 commit 2ec8bf0

10 files changed

Lines changed: 1423 additions & 7 deletions

File tree

.cz.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"path": "./cz-config.js"
3+
}

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,6 @@ jobs:
3434
- name: Build Project
3535
run: |
3636
npm run build
37+
- name: Commitlint Check
38+
if: github.event_name == 'push'
39+
run: npm run commit:lint

.husky/commit-msg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
npm run commit:edit

.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

.ls-lint.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ ignore:
2323
- public
2424
- reports
2525
- storybook-static
26+
- .cz.json

CONTRIBUTING.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,3 +315,22 @@ See the [Greenwood Storybook docs](/guides/ecosystem/storybook/#content-as-data)
315315
This project is hosted on Netlify and automatically deploys on each merge into main. Release branches will be curated over the course of a Greenwood release cycle and then merged at the time the new Greenwood release is published to NPM.
316316
317317
For links to `/discord/`, a redirect is configured in _netlify.toml_ to redirect these requests to the project's Discord server.
318+
319+
## Pull Requests
320+
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_.
322+
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:
324+
325+
```sh
326+
$ npm run commit
327+
```
328+
329+
The following will be required:
330+
331+
- **type**
332+
- **issue reference** (can technically be empty)
333+
334+
## Continuous Integration
335+
336+
To test the CI build scripts locally, run the yarn commands mentioned in the _Workflows_ section of the README. (basically just make sure linting, formatting, and test tasks are all passing).

commitlint.config.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// https://commitlint.js.org/reference/rules.html
2+
export default {
3+
rules: {
4+
"type-case": [2, "always", "lower-case"],
5+
"type-enum": [
6+
2,
7+
"always",
8+
["feat", "enhancement", "fix", "chore", "content", "docs", "revert"],
9+
],
10+
"type-empty": [2, "never"],
11+
"subject-case": [2, "always", "lower-case"],
12+
"body-case": [2, "always", "lower-case"],
13+
"header-case": [2, "always", "lower-case"],
14+
},
15+
};

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)