-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathcz-config.js
More file actions
115 lines (105 loc) · 2.9 KB
/
Copy pathcz-config.js
File metadata and controls
115 lines (105 loc) · 2.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
// NOTE: need to keep types and scope consistent with commitlint.config.js
// https://commitizen.github.io/cz-cli/
const types = [
{ value: "feature", name: "feature: ✨ A new feature" },
{
value: "enhancement",
name: "enhancement: 💪 A code change that neither fixes a bug nor adds a feature",
},
{ value: "fix", name: "fix: 🐛 A bug fix" },
{ value: "chore", name: "chore: 🛠 Other changes that don't modify src files" },
{ value: "docs", name: "docs: 📚 Documentation only changes" },
{ value: "revert", name: "revert: 🗑 Reverts a previous commit" },
];
const scopes = [
{
value: "cli",
name: "cli: ♻️ Changes to the core CLI",
},
{
value: "init",
name: "init: ⚡ Changes to the init CLI",
},
{
value: "plugins",
name: "plugins: 🔌 Changes to any plugins",
},
{
value: "adapters",
name: "adapters: 🔋 Changes to any adapters",
},
{
value: "runtimes",
name: "runtimes: ❄️ Changes related to supporting runtimes",
},
{
value: "types",
name: "types: 🤓 Type or TypeScript specific changes",
},
{
value: "deps",
name: "deps: 📦 Updating dependencies (for renovate)",
},
{
value: "workspace",
name: "workspace: 🏗️ Changes to the monorepo or CI",
},
];
export default {
prompter: async (cz, commit) => {
const { type } = await cz.prompt([
{
type: "list",
name: "type",
message: "Select the type of the change",
choices: types,
},
]);
const { scope } = await cz.prompt([
{
type: "list",
name: "scope",
message: "Select the scope of the change",
choices: scopes,
},
]);
const { subject } = await cz.prompt([
{
type: "input",
name: "subject",
message: "Write a short, imperative description of the change",
validate: (input) => {
if (input.length === 0) {
return "Subject is required";
}
return true;
},
},
]);
const { breaking } = await cz.prompt([
{
type: "list",
name: "breaking",
message: "Is this a breaking change?",
choices: ["No", "Yes"],
},
]);
const { issue } = await cz.prompt([
{
type: "input",
name: "issue",
message: "Enter the issue associated with this change (e.g. 123)",
validate: (input) => {
if (input.startsWith("#")) {
return "Please do not include the #";
}
return true;
},
},
]);
const issueFormat = issue === "" ? "" : `#${issue} `;
const breakingFormat = breaking === "Yes" ? "!" : "";
const message = `${type}(${scope})${breakingFormat}: ${issueFormat}${subject}`;
commit(message);
},
};