-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinit.js
56 lines (48 loc) · 1.64 KB
/
init.js
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
"use strict";
async function loadInquirer() {
const inquirer = await import("inquirer");
return inquirer.default;
}
exports.prompter = async function (cz, commit) {
const inquirer = await loadInquirer();
const types = [
{ name: "feat", description: "A new feature" },
{ name: "fix", description: "A bug fix" },
{ name: "ui", description: "Work on the user interface" },
{ name: "logic", description: "Work on core logic" },
{
name: "refactor",
description: "A code change that neither fixes a bug nor adds a feature",
},
{
name: "chore",
description: "Changes to the build process or auxiliary tools",
},
{ name: "docs", description: "Documentation only changes" },
{ name: "WiP", description: "Still working on this" },
{name: "stash", description: "Not ready to commit, still committing anyways 🤡"},
];
// Calculate the maximum length of the type strings
const maxTypeLength = Math.max(...types.map((type) => type.name.length));
const questions = [
{
type: "list",
name: "type",
message: "Select the type of change you are committing:",
choices: types.map((type) => ({
name: `${type.name.padEnd(maxTypeLength)} ${type.description}`,
value: type.name,
})),
default: "feat",
},
{
type: "input",
name: "subject",
message: "Write a short, descriptive commit message:",
validate: (input) => !!input.trim() || "Commit message cannot be empty",
},
];
const answers = await inquirer.prompt(questions);
let commitMessage = `${answers.type}: ${answers.subject}`;
commit(commitMessage);
};