@4s1/conventional-commit-creator 3.6.0 → 3.8.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config.d.ts +5 -5
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +23 -23
- package/dist/config.js.map +1 -1
- package/dist/git.js +8 -8
- package/dist/git.js.map +1 -1
- package/dist/index.js +36 -36
- package/dist/index.js.map +1 -1
- package/dist/questions.d.ts +2 -2
- package/dist/questions.d.ts.map +1 -1
- package/dist/questions.js +42 -42
- package/dist/questions.js.map +1 -1
- package/package.json +25 -26
package/dist/config.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export
|
|
1
|
+
export interface ConfigTemplateType {
|
|
2
2
|
name: string;
|
|
3
3
|
regex: string;
|
|
4
4
|
pattern: string;
|
|
@@ -16,11 +16,11 @@ export type ConfigTemplateType = {
|
|
|
16
16
|
post_issue2?: string;
|
|
17
17
|
pre_issue3?: string;
|
|
18
18
|
post_issue3?: string;
|
|
19
|
-
}
|
|
20
|
-
export
|
|
21
|
-
$schema:
|
|
19
|
+
}
|
|
20
|
+
export interface ConfigType {
|
|
21
|
+
$schema: "https://www.4s1.de/conventional-commit-creator/schema.json";
|
|
22
22
|
version: number;
|
|
23
23
|
templates: ConfigTemplateType[];
|
|
24
|
-
}
|
|
24
|
+
}
|
|
25
25
|
export declare function loadConfig(): ConfigType;
|
|
26
26
|
//# sourceMappingURL=config.d.ts.map
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAIA,MAAM,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAEhB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,4DAA4D,CAAC;IACtE,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,kBAAkB,EAAE,CAAC;CACjC;AAED,wBAAgB,UAAU,IAAI,UAAU,CAsCvC"}
|
package/dist/config.js
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
import fs from
|
|
2
|
-
import os from
|
|
3
|
-
import path from
|
|
1
|
+
import fs from "node:fs";
|
|
2
|
+
import os from "node:os";
|
|
3
|
+
import path from "node:path";
|
|
4
4
|
export function loadConfig() {
|
|
5
5
|
const configFile = `${os.homedir()}/.config/conventional-commit-creator/config.json`;
|
|
6
6
|
if (fs.existsSync(configFile)) {
|
|
7
|
-
const config = fs.readFileSync(configFile, { encoding:
|
|
7
|
+
const config = fs.readFileSync(configFile, { encoding: "utf-8" });
|
|
8
8
|
return JSON.parse(config);
|
|
9
9
|
}
|
|
10
10
|
else {
|
|
11
11
|
const config = {
|
|
12
|
-
$schema:
|
|
12
|
+
$schema: "https://www.4s1.de/conventional-commit-creator/schema.json",
|
|
13
13
|
version: 1,
|
|
14
14
|
templates: [
|
|
15
15
|
{
|
|
16
|
-
name:
|
|
17
|
-
regex:
|
|
18
|
-
pattern:
|
|
19
|
-
pre_type:
|
|
20
|
-
post_type:
|
|
21
|
-
pre_scope:
|
|
22
|
-
post_scope:
|
|
23
|
-
pre_description:
|
|
24
|
-
post_description:
|
|
25
|
-
pre_body:
|
|
26
|
-
post_body:
|
|
27
|
-
pre_issue:
|
|
28
|
-
post_issue:
|
|
29
|
-
pre_issue2:
|
|
30
|
-
post_issue2:
|
|
31
|
-
pre_issue3:
|
|
32
|
-
post_issue3:
|
|
16
|
+
name: "Default",
|
|
17
|
+
regex: ".*",
|
|
18
|
+
pattern: "{type}{scope}: {description}{issue}{body}",
|
|
19
|
+
pre_type: "",
|
|
20
|
+
post_type: "",
|
|
21
|
+
pre_scope: "(",
|
|
22
|
+
post_scope: ")",
|
|
23
|
+
pre_description: "",
|
|
24
|
+
post_description: "",
|
|
25
|
+
pre_body: "\n\n",
|
|
26
|
+
post_body: "",
|
|
27
|
+
pre_issue: " (#",
|
|
28
|
+
post_issue: ")",
|
|
29
|
+
pre_issue2: "",
|
|
30
|
+
post_issue2: "",
|
|
31
|
+
pre_issue3: "",
|
|
32
|
+
post_issue3: "",
|
|
33
33
|
},
|
|
34
34
|
],
|
|
35
35
|
};
|
|
36
36
|
fs.mkdirSync(path.dirname(configFile), { recursive: true });
|
|
37
|
-
fs.writeFileSync(configFile, JSON.stringify(config, null, 2), { encoding:
|
|
37
|
+
fs.writeFileSync(configFile, JSON.stringify(config, null, 2), { encoding: "utf-8" });
|
|
38
38
|
return config;
|
|
39
39
|
}
|
|
40
40
|
}
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,IAAI,MAAM,WAAW,CAAC;AA8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AAE,OAAO,EAAE,CAAC,CAAC;QACrF,OAAO,MAAM,CAAC;KACf;AACH,CAAC","sourcesContent":["import fs from \"node:fs\";\nimport os from \"node:os\";\nimport path from \"node:path\";\n\nexport interface ConfigTemplateType {\n name: string;\n regex: string;\n pattern: string;\n\n pre_type?: string;\n post_type?: string;\n pre_scope?: string;\n post_scope?: string;\n pre_description?: string;\n post_description?: string;\n pre_body?: string;\n post_body?: string;\n\n pre_issue?: string;\n post_issue?: string;\n pre_issue2?: string;\n post_issue2?: string;\n pre_issue3?: string;\n post_issue3?: string;\n}\n\nexport interface ConfigType {\n $schema: \"https://www.4s1.de/conventional-commit-creator/schema.json\";\n version: number;\n templates: ConfigTemplateType[];\n}\n\nexport function loadConfig(): ConfigType {\n const configFile = `${os.homedir()}/.config/conventional-commit-creator/config.json`;\n\n if (fs.existsSync(configFile)) {\n const config = fs.readFileSync(configFile, { encoding: \"utf-8\" });\n return JSON.parse(config);\n } else {\n const config: ConfigType = {\n $schema: \"https://www.4s1.de/conventional-commit-creator/schema.json\",\n version: 1,\n templates: [\n {\n name: \"Default\",\n regex: \".*\",\n pattern: \"{type}{scope}: {description}{issue}{body}\",\n\n pre_type: \"\",\n post_type: \"\",\n pre_scope: \"(\",\n post_scope: \")\",\n pre_description: \"\",\n post_description: \"\",\n pre_body: \"\\n\\n\",\n post_body: \"\",\n\n pre_issue: \" (#\",\n post_issue: \")\",\n pre_issue2: \"\",\n post_issue2: \"\",\n pre_issue3: \"\",\n post_issue3: \"\",\n },\n ],\n };\n fs.mkdirSync(path.dirname(configFile), { recursive: true });\n fs.writeFileSync(configFile, JSON.stringify(config, null, 2), { encoding: \"utf-8\" });\n return config;\n }\n}\n"]}
|
package/dist/git.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { exec } from
|
|
1
|
+
import { exec } from "node:child_process";
|
|
2
2
|
export class Git {
|
|
3
3
|
async isCurrentDirUnderGitControl() {
|
|
4
4
|
try {
|
|
5
|
-
const result = await this.execute(
|
|
6
|
-
return result.trim() ===
|
|
5
|
+
const result = await this.execute("git rev-parse --is-inside-work-tree");
|
|
6
|
+
return result.trim() === "true";
|
|
7
7
|
}
|
|
8
8
|
catch (err) {
|
|
9
9
|
console.error(err);
|
|
@@ -12,20 +12,20 @@ export class Git {
|
|
|
12
12
|
}
|
|
13
13
|
async haveStagedChanges() {
|
|
14
14
|
try {
|
|
15
|
-
const staged = await this.execute(
|
|
16
|
-
return staged !==
|
|
15
|
+
const staged = await this.execute("git diff --cached | head -5");
|
|
16
|
+
return staged !== "";
|
|
17
17
|
}
|
|
18
18
|
catch (err) {
|
|
19
19
|
console.error(err);
|
|
20
|
-
console.log(
|
|
20
|
+
console.log("return false");
|
|
21
21
|
return false;
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
async getGitRemoteOriginUrl() {
|
|
25
|
-
return this.execute(
|
|
25
|
+
return this.execute("git remote get-url --push origin");
|
|
26
26
|
}
|
|
27
27
|
async commit(msg) {
|
|
28
|
-
console.info(
|
|
28
|
+
console.info("committing ...");
|
|
29
29
|
try {
|
|
30
30
|
await this.execute(`git commit -m "${this.encodeMessage(msg)}"`);
|
|
31
31
|
}
|
package/dist/git.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"git.js","sourceRoot":"","sources":["../src/git.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAE1C,MAAM,OAAO,GAAG;IACP,KAAK,CAAC,2BAA2B;QACtC,IAAI;YACF,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,qCAAqC,CAAC,CAAC;YACzE,OAAO,MAAM,CAAC,IAAI,EAAE,KAAK,MAAM,CAAC;SACjC;QAAC,OAAO,GAAG,EAAE;YACZ,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YACnB,OAAO,KAAK,CAAC;SACd;IACH,CAAC;IAEM,KAAK,CAAC,iBAAiB;QA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,CAAC;IAEO,OAAO,CAAC,GAAW;QACzB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,IAAI,CAAC,GAAG,EAAE,CAAC,GAAyB,EAAE,MAAc,EAAE,EAAE;gBACtD,IAAI,GAAG,EAAE;oBACP,MAAM,CAAC,GAAG,CAAC,CAAC;oBACZ,OAAO;iBACR;gBACD,OAAO,CAAC,MAAM,CAAC,CAAC;YAClB,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC;CACF","sourcesContent":["import type { ExecException } from \"node:child_process\";\nimport { exec } from \"node:child_process\";\n\nexport class Git {\n public async isCurrentDirUnderGitControl(): Promise<boolean> {\n try {\n const result = await this.execute(\"git rev-parse --is-inside-work-tree\");\n return result.trim() === \"true\";\n } catch (err) {\n console.error(err);\n return false;\n }\n }\n\n public async haveStagedChanges(): Promise<boolean> {\n try {\n const staged = await this.execute(\"git diff --cached | head -5\");\n return staged !== \"\";\n } catch (err) {\n console.error(err);\n console.log(\"return false\");\n return false;\n }\n }\n\n public async getGitRemoteOriginUrl(): Promise<string> {\n return this.execute(\"git remote get-url --push origin\");\n }\n\n public async commit(msg: string): Promise<void> {\n console.info(\"committing ...\");\n try {\n await this.execute(`git commit -m \"${this.encodeMessage(msg)}\"`);\n } catch (err) {\n console.error(err);\n process.exit(1);\n }\n }\n\n private encodeMessage(msg: string): string {\n return msg.replaceAll('\"', '\\\\\"');\n }\n\n private execute(cmd: string): Promise<string> {\n return new Promise((resolve, reject) => {\n exec(cmd, (err: ExecException | null, stdout: string) => {\n if (err) {\n reject(err);\n return;\n }\n resolve(stdout);\n });\n });\n }\n}\n"]}
|
package/dist/index.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { Git } from
|
|
3
|
-
import { loadConfig } from
|
|
4
|
-
import { AppError } from
|
|
5
|
-
import { askForBody, askForConfirmation, askForDescription, askForIssue, askForScope, askForType } from
|
|
2
|
+
import { Git } from "./git.js";
|
|
3
|
+
import { loadConfig } from "./config.js";
|
|
4
|
+
import { AppError } from "./app-error.js";
|
|
5
|
+
import { askForBody, askForConfirmation, askForDescription, askForIssue, askForScope, askForType, } from "./questions.js";
|
|
6
6
|
async function main() {
|
|
7
7
|
try {
|
|
8
8
|
const git = new Git();
|
|
9
9
|
if (!(await git.isCurrentDirUnderGitControl())) {
|
|
10
|
-
throw new AppError(
|
|
10
|
+
throw new AppError("Current directory is not a git repository.");
|
|
11
11
|
}
|
|
12
12
|
if (!(await git.haveStagedChanges())) {
|
|
13
|
-
throw new AppError(
|
|
13
|
+
throw new AppError("Nothing to commit");
|
|
14
14
|
}
|
|
15
15
|
const config = loadConfig();
|
|
16
16
|
const remoteOriginUrl = (await git.getGitRemoteOriginUrl()).trim();
|
|
@@ -24,10 +24,10 @@ async function main() {
|
|
|
24
24
|
issue: await askForIssue(),
|
|
25
25
|
};
|
|
26
26
|
const msg = await createMsg(answers, template);
|
|
27
|
-
console.info(`${
|
|
27
|
+
console.info(`${"-".repeat(42)}\n${msg}\n${"-".repeat(42)}`);
|
|
28
28
|
if (await askForConfirmation()) {
|
|
29
29
|
await git.commit(msg);
|
|
30
|
-
console.info(
|
|
30
|
+
console.info("done");
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
catch (err) {
|
|
@@ -56,58 +56,58 @@ function getMatchingTemplate(config, remoteOriginUrl) {
|
|
|
56
56
|
return template2;
|
|
57
57
|
}
|
|
58
58
|
async function createMsg(answers, template) {
|
|
59
|
-
const type = answers.type ? answers.type.trim() :
|
|
60
|
-
const scope = answers.scope ? answers.scope.trim() :
|
|
59
|
+
const type = answers.type ? answers.type.trim() : "";
|
|
60
|
+
const scope = answers.scope ? answers.scope.trim() : "";
|
|
61
61
|
const body = answers.body
|
|
62
62
|
? answers.body
|
|
63
|
-
.split(
|
|
63
|
+
.split("\\n")
|
|
64
64
|
.map((x) => x.trim())
|
|
65
|
-
.join(
|
|
65
|
+
.join("\n")
|
|
66
66
|
.trim()
|
|
67
|
-
:
|
|
68
|
-
const description = answers.description ? answers.description.trim() :
|
|
69
|
-
const issue = answers.issue ? answers.issue.trim() :
|
|
67
|
+
: "";
|
|
68
|
+
const description = answers.description ? answers.description.trim() : "";
|
|
69
|
+
const issue = answers.issue ? answers.issue.trim() : "";
|
|
70
70
|
let msg = template.pattern;
|
|
71
71
|
if (type) {
|
|
72
|
-
const typeText = `${template.pre_type ??
|
|
73
|
-
msg = msg.replace(
|
|
72
|
+
const typeText = `${template.pre_type ?? ""}${type}${template.post_type ?? ""}`;
|
|
73
|
+
msg = msg.replace("{type}", typeText);
|
|
74
74
|
}
|
|
75
75
|
else {
|
|
76
|
-
msg = msg.replace(
|
|
76
|
+
msg = msg.replace("{type}", "");
|
|
77
77
|
}
|
|
78
78
|
if (scope) {
|
|
79
|
-
const scopeText = `${template.pre_scope ??
|
|
80
|
-
msg = msg.replace(
|
|
79
|
+
const scopeText = `${template.pre_scope ?? ""}${scope}${template.post_scope ?? ""}`;
|
|
80
|
+
msg = msg.replace("{scope}", scopeText);
|
|
81
81
|
}
|
|
82
82
|
else {
|
|
83
|
-
msg = msg.replace(
|
|
83
|
+
msg = msg.replace("{scope}", "");
|
|
84
84
|
}
|
|
85
85
|
if (description) {
|
|
86
|
-
const descriptionText = `${template.pre_description ??
|
|
87
|
-
msg = msg.replace(
|
|
86
|
+
const descriptionText = `${template.pre_description ?? ""}${description}${template.post_description ?? ""}`;
|
|
87
|
+
msg = msg.replace("{description}", descriptionText);
|
|
88
88
|
}
|
|
89
89
|
else {
|
|
90
|
-
msg = msg.replace(
|
|
90
|
+
msg = msg.replace("{description}", "");
|
|
91
91
|
}
|
|
92
92
|
if (body) {
|
|
93
|
-
const bodyText = `${template.pre_body ??
|
|
94
|
-
msg = msg.replace(
|
|
93
|
+
const bodyText = `${template.pre_body ?? ""}${body}${template.post_body ?? ""}`;
|
|
94
|
+
msg = msg.replace("{body}", bodyText);
|
|
95
95
|
}
|
|
96
96
|
else {
|
|
97
|
-
msg = msg.replace(
|
|
97
|
+
msg = msg.replace("{body}", "");
|
|
98
98
|
}
|
|
99
99
|
if (issue) {
|
|
100
|
-
const issueText = `${template.pre_issue ??
|
|
101
|
-
msg = msg.replace(
|
|
102
|
-
const issue2Text = `${template.pre_issue2 ??
|
|
103
|
-
msg = msg.replace(
|
|
104
|
-
const issue3Text = `${template.pre_issue3 ??
|
|
105
|
-
msg = msg.replace(
|
|
100
|
+
const issueText = `${template.pre_issue ?? ""}${issue}${template.post_issue ?? ""}`;
|
|
101
|
+
msg = msg.replace("{issue}", issueText);
|
|
102
|
+
const issue2Text = `${template.pre_issue2 ?? ""}${issue}${template.post_issue2 ?? ""}`;
|
|
103
|
+
msg = msg.replace("{issue2}", issue2Text);
|
|
104
|
+
const issue3Text = `${template.pre_issue3 ?? ""}${issue}${template.post_issue3 ?? ""}`;
|
|
105
|
+
msg = msg.replace("{issue3}", issue3Text);
|
|
106
106
|
}
|
|
107
107
|
else {
|
|
108
|
-
msg = msg.replace(
|
|
109
|
-
msg = msg.replace(
|
|
110
|
-
msg = msg.replace(
|
|
108
|
+
msg = msg.replace("{issue}", "");
|
|
109
|
+
msg = msg.replace("{issue2}", "");
|
|
110
|
+
msg = msg.replace("{issue3}", "");
|
|
111
111
|
}
|
|
112
112
|
return msg;
|
|
113
113
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,UAAU,EAAmB,MAAM,aAAa,CAAC;AAE1D,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAEA,OAAO,EAAE,GAAG,EAAE,MAA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,GAAG,GAAG,CAAC,OAAO,CAAC,SAAS,EAAE,EAAE,CAAC,CAAC;QACjC,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;QAClC,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;KACnC;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC","sourcesContent":["#!/usr/bin/env node\n\nimport { Git } from \"./git.js\";\nimport { loadConfig, type ConfigType } from \"./config.js\";\nimport type { ConfigTemplateType } from \"./config.js\";\nimport { AppError } from \"./app-error.js\";\nimport {\n askForBody,\n askForConfirmation,\n askForDescription,\n askForIssue,\n askForScope,\n askForType,\n} from \"./questions.js\";\nimport type { AnswersType } from \"./questions.js\";\n\nasync function main(): Promise<void> {\n try {\n const git = new Git();\n\n if (!(await git.isCurrentDirUnderGitControl())) {\n throw new AppError(\"Current directory is not a git repository.\");\n }\n\n if (!(await git.haveStagedChanges())) {\n throw new AppError(\"Nothing to commit\");\n }\n\n const config = loadConfig();\n const remoteOriginUrl = (await git.getGitRemoteOriginUrl()).trim();\n const template = getMatchingTemplate(config, remoteOriginUrl);\n console.info(`Using template \"${template.name}\"\\n`);\n\n const answers: AnswersType = {\n type: await askForType(),\n scope: await askForScope(),\n description: await askForDescription(),\n body: await askForBody(),\n issue: await askForIssue(),\n };\n\n const msg = await createMsg(answers, template);\n console.info(`${\"-\".repeat(42)}\\n${msg}\\n${\"-\".repeat(42)}`);\n if (await askForConfirmation()) {\n await git.commit(msg);\n console.info(\"done\");\n }\n } catch (err) {\n if (err instanceof AppError) {\n console.error(err.message);\n process.exit(0);\n } else {\n console.error(err);\n process.exit(1);\n }\n }\n}\n\nfunction getMatchingTemplate(config: ConfigType, remoteOriginUrl: string): ConfigTemplateType {\n // ToDo: rename var\n let template2: ConfigTemplateType | undefined;\n\n for (const template of config.templates) {\n const regEx = new RegExp(template.regex);\n if (regEx.test(remoteOriginUrl)) {\n template2 = template;\n }\n }\n\n if (!template2) {\n throw new AppError(`No matching template found for \"${remoteOriginUrl}\"`);\n }\n\n return template2;\n}\n\nasync function createMsg(answers: AnswersType, template: ConfigTemplateType): Promise<string> {\n const type = answers.type ? answers.type.trim() : \"\";\n const scope = answers.scope ? answers.scope.trim() : \"\";\n const body = answers.body\n ? answers.body\n .split(\"\\\\n\")\n .map((x) => x.trim())\n .join(\"\\n\")\n .trim()\n : \"\";\n const description = answers.description ? answers.description.trim() : \"\";\n const issue = answers.issue ? answers.issue.trim() : \"\";\n\n let msg = template.pattern;\n\n if (type) {\n const typeText = `${template.pre_type ?? \"\"}${type}${template.post_type ?? \"\"}`;\n msg = msg.replace(\"{type}\", typeText);\n } else {\n msg = msg.replace(\"{type}\", \"\");\n }\n\n if (scope) {\n const scopeText = `${template.pre_scope ?? \"\"}${scope}${template.post_scope ?? \"\"}`;\n msg = msg.replace(\"{scope}\", scopeText);\n } else {\n msg = msg.replace(\"{scope}\", \"\");\n }\n\n if (description) {\n const descriptionText = `${template.pre_description ?? \"\"}${description}${\n template.post_description ?? \"\"\n }`;\n msg = msg.replace(\"{description}\", descriptionText);\n } else {\n msg = msg.replace(\"{description}\", \"\");\n }\n\n if (body) {\n const bodyText = `${template.pre_body ?? \"\"}${body}${template.post_body ?? \"\"}`;\n msg = msg.replace(\"{body}\", bodyText);\n } else {\n msg = msg.replace(\"{body}\", \"\");\n }\n\n if (issue) {\n const issueText = `${template.pre_issue ?? \"\"}${issue}${template.post_issue ?? \"\"}`;\n msg = msg.replace(\"{issue}\", issueText);\n const issue2Text = `${template.pre_issue2 ?? \"\"}${issue}${template.post_issue2 ?? \"\"}`;\n msg = msg.replace(\"{issue2}\", issue2Text);\n const issue3Text = `${template.pre_issue3 ?? \"\"}${issue}${template.post_issue3 ?? \"\"}`;\n msg = msg.replace(\"{issue3}\", issue3Text);\n } else {\n msg = msg.replace(\"{issue}\", \"\");\n msg = msg.replace(\"{issue2}\", \"\");\n msg = msg.replace(\"{issue3}\", \"\");\n }\n\n return msg;\n}\n\nmain().catch(console.error);\n"]}
|
package/dist/questions.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export
|
|
1
|
+
export interface AnswersType {
|
|
2
2
|
type: string;
|
|
3
3
|
scope: string;
|
|
4
4
|
description: string;
|
|
5
5
|
body: string;
|
|
6
6
|
issue: string;
|
|
7
|
-
}
|
|
7
|
+
}
|
|
8
8
|
export declare function askForType(): Promise<string>;
|
|
9
9
|
export declare function askForScope(): Promise<string>;
|
|
10
10
|
export declare function askForDescription(): Promise<string>;
|
package/dist/questions.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"questions.d.ts","sourceRoot":"","sources":["../src/questions.ts"],"names":[],"mappings":"AAIA,MAAM,
|
|
1
|
+
{"version":3,"file":"questions.d.ts","sourceRoot":"","sources":["../src/questions.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED,wBAAgB,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC,CA8D5C;AAED,wBAAgB,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC,CAW7C;AAED,wBAAgB,iBAAiB,IAAI,OAAO,CAAC,MAAM,CAAC,CAanD;AAED,wBAAgB,UAAU,IAAI,OAAO,CAAC,MAAM,CAAC,CAI5C;AAED,wBAAgB,WAAW,IAAI,OAAO,CAAC,MAAM,CAAC,CAY7C;AAED,wBAAgB,kBAAkB,IAAI,OAAO,CAAC,OAAO,CAAC,CAKrD"}
|
package/dist/questions.js
CHANGED
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
import select from
|
|
2
|
-
import input from
|
|
3
|
-
import confirm from
|
|
1
|
+
import select from "@inquirer/select";
|
|
2
|
+
import input from "@inquirer/input";
|
|
3
|
+
import confirm from "@inquirer/confirm";
|
|
4
4
|
export function askForType() {
|
|
5
5
|
return select({
|
|
6
|
-
message:
|
|
6
|
+
message: "type?",
|
|
7
7
|
pageSize: 99,
|
|
8
8
|
choices: [
|
|
9
9
|
{
|
|
10
|
-
name:
|
|
11
|
-
value:
|
|
12
|
-
description:
|
|
10
|
+
name: "fix",
|
|
11
|
+
value: "fix",
|
|
12
|
+
description: "A bugfix",
|
|
13
13
|
},
|
|
14
14
|
{
|
|
15
|
-
name:
|
|
16
|
-
value:
|
|
17
|
-
description:
|
|
15
|
+
name: "feat",
|
|
16
|
+
value: "feat",
|
|
17
|
+
description: "A new feature",
|
|
18
18
|
},
|
|
19
19
|
{
|
|
20
|
-
name:
|
|
21
|
-
value:
|
|
22
|
-
description:
|
|
20
|
+
name: "refactor",
|
|
21
|
+
value: "refactor",
|
|
22
|
+
description: "A code change that neither fixes a bug nor adds a feature",
|
|
23
23
|
},
|
|
24
24
|
{
|
|
25
|
-
name:
|
|
26
|
-
value:
|
|
27
|
-
description:
|
|
25
|
+
name: "perf",
|
|
26
|
+
value: "perf",
|
|
27
|
+
description: "A code change that improves performance",
|
|
28
28
|
},
|
|
29
29
|
{
|
|
30
|
-
name:
|
|
31
|
-
value:
|
|
32
|
-
description:
|
|
30
|
+
name: "docs",
|
|
31
|
+
value: "docs",
|
|
32
|
+
description: "Documentation only changes",
|
|
33
33
|
},
|
|
34
34
|
{
|
|
35
|
-
name:
|
|
36
|
-
value:
|
|
37
|
-
description:
|
|
35
|
+
name: "style",
|
|
36
|
+
value: "style",
|
|
37
|
+
description: "Code style (semicolon, indentation, white-space, formatting, ...)",
|
|
38
38
|
},
|
|
39
39
|
{
|
|
40
|
-
name:
|
|
41
|
-
value:
|
|
42
|
-
description:
|
|
40
|
+
name: "test",
|
|
41
|
+
value: "test",
|
|
42
|
+
description: "add/change/delete tests",
|
|
43
43
|
},
|
|
44
44
|
{
|
|
45
|
-
name:
|
|
46
|
-
value:
|
|
45
|
+
name: "chore",
|
|
46
|
+
value: "chore",
|
|
47
47
|
description: "Other changes that don't modify src or test files",
|
|
48
48
|
},
|
|
49
49
|
{
|
|
50
|
-
name:
|
|
51
|
-
value:
|
|
52
|
-
description:
|
|
50
|
+
name: "build",
|
|
51
|
+
value: "build",
|
|
52
|
+
description: "build system (npm, git, VSCode, tsconfig, angular.json, ...)",
|
|
53
53
|
},
|
|
54
54
|
{
|
|
55
|
-
name:
|
|
56
|
-
value:
|
|
57
|
-
description:
|
|
55
|
+
name: "ci",
|
|
56
|
+
value: "ci",
|
|
57
|
+
description: "CI configuration (GitHub, GitLab, RenovateBot, ...)",
|
|
58
58
|
},
|
|
59
59
|
{
|
|
60
|
-
name:
|
|
61
|
-
value:
|
|
62
|
-
description:
|
|
60
|
+
name: "revert",
|
|
61
|
+
value: "revert",
|
|
62
|
+
description: "Reverts a previous commit",
|
|
63
63
|
},
|
|
64
64
|
],
|
|
65
65
|
});
|
|
66
66
|
}
|
|
67
67
|
export function askForScope() {
|
|
68
68
|
return input({
|
|
69
|
-
message:
|
|
69
|
+
message: "scope?",
|
|
70
70
|
validate: (value) => {
|
|
71
71
|
if (value.length > 20) {
|
|
72
72
|
return `Your text is ${value.length - 20} char(s) too long.`;
|
|
@@ -79,7 +79,7 @@ export function askForScope() {
|
|
|
79
79
|
}
|
|
80
80
|
export function askForDescription() {
|
|
81
81
|
return input({
|
|
82
|
-
message:
|
|
82
|
+
message: "description?",
|
|
83
83
|
validate: (value) => {
|
|
84
84
|
if (value.length > 70) {
|
|
85
85
|
return `Your text is ${value.length - 70} char(s) too long.`;
|
|
@@ -95,16 +95,16 @@ export function askForDescription() {
|
|
|
95
95
|
}
|
|
96
96
|
export function askForBody() {
|
|
97
97
|
return input({
|
|
98
|
-
message:
|
|
98
|
+
message: "body?",
|
|
99
99
|
});
|
|
100
100
|
}
|
|
101
101
|
export function askForIssue() {
|
|
102
102
|
return input({
|
|
103
|
-
message:
|
|
103
|
+
message: "issue?",
|
|
104
104
|
validate: (value) => {
|
|
105
105
|
const regularExpression = /^\d+$/;
|
|
106
106
|
if (value.length > 0 && !regularExpression.test(value)) {
|
|
107
|
-
return
|
|
107
|
+
return "Your issue is not a number.";
|
|
108
108
|
}
|
|
109
109
|
else {
|
|
110
110
|
return true;
|
|
@@ -114,7 +114,7 @@ export function askForIssue() {
|
|
|
114
114
|
}
|
|
115
115
|
export function askForConfirmation() {
|
|
116
116
|
return confirm({
|
|
117
|
-
message:
|
|
117
|
+
message: "Is this okay?",
|
|
118
118
|
default: true,
|
|
119
119
|
});
|
|
120
120
|
}
|
package/dist/questions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"questions.js","sourceRoot":"","sources":["../src/questions.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,kBAAkB,CAAC;AACtC,OAAO,KAAK,MAAM,iBAAiB,CAAC;AACpC,OAAO,OAAO,MAAM,mBAAmB,CAAC;AAUxC,MAAM,UAAU,UAAU;IACxB,OAAO,MAAM,CAAC;QACZ,OAAO,EAAE,OAAO;QAChB,QAAQ,EAAE,EAAE;QACZ,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,KAAK;gBACX,KAAK,EAAE,KAAK;gBACZ,WAAW,EAAE,UAAU;aACxB;YACD;gBACE,IAAI,EAAE,MAAM;gBACZ,KAAK,EAAE,MAAM;gBACb,WAAW,EAAE,eAAe;aAC7B;YACD;gBACE,IAAI,EAAE,UAAU;gBAChB,KAAK,EAAE,UAAU;gBACjB,WAAW,EAAE,2DAA2D;aACzE;YACD;gBACE,IAAI,EAAE,MAAM;gBACZ,KAAK,EAAE,MAAM;gBACb,WAAW,EAAE,yCAAyC;aACvD;YACD;gBACE,IAAI,EAAE,MAAM;gBACZ,KAAK,EAAE,MAAM;gBACb,WAAW,EAAE,4BAA4B;aAC1C;YACD;gBACE,IAAI,E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I,CAAC;aACb;QACH,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,UAAU;IACxB,OAAO,KAAK,CAAC;QACX,OAAO,EAAE,OAAO;KACjB,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,WAAW;IACzB,OAAO,KAAK,CAAC;QACX,OAAO,EAAE,QAAQ;QACjB,QAAQ,EAAE,CAAC,KAAa,EAAoB,EAAE;YAC5C,MAAM,iBAAiB,GAAG,OAAO,CAAC;YAClC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;gBACtD,OAAO,6BAA6B,CAAC;aACtC;iBAAM;gBACL,OAAO,IAAI,CAAC;aACb;QACH,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,kBAAkB;IAChC,OAAO,OAAO,CAAC;QACb,OAAO,EAAE,eAAe;QACxB,OAAO,EAAE,IAAI;KACd,CAAC,CAAC;AACL,CAAC","sourcesContent":["import select from
|
|
1
|
+
{"version":3,"file":"questions.js","sourceRoot":"","sources":["../src/questions.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,kBAAkB,CAAC;AACtC,OAAO,KAAK,MAAM,iBAAiB,CAAC;AACpC,OAAO,OAAO,MAAM,mBAAmB,CAAC;AAUxC,MAAM,UAAU,UAAU;IACxB,OAAO,MAAM,CAAC;QACZ,OAAO,EAAE,OAAO;QAChB,QAAQ,EAAE,EAAE;QACZ,OAAO,EAAE;YACP;gBACE,IAAI,EAAE,KAAK;gBACX,KAAK,EAAE,KAAK;gBACZ,WAAW,EAAE,UAAU;aACxB;YACD;gBACE,IAAI,EAAE,MAAM;gBACZ,KAAK,EAAE,MAAM;gBACb,WAAW,EAAE,eAAe;aAC7B;YACD;gBACE,IAAI,EAAE,UAAU;gBAChB,KAAK,EAAE,UAAU;gBACjB,WAAW,EAAE,2DAA2D;aACzE;YACD;gBACE,IAAI,EAA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AE,oBAAoB,CAAC;aAC9D;iBAAM,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE;gBAC3B,OAAO,gBAAgB,CAAC,GAAG,KAAK,CAAC,MAAM,qBAAqB,CAAC;aAC9D;iBAAM;gBACL,OAAO,IAAI,CAAC;aACb;QACH,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,UAAU;IACxB,OAAO,KAAK,CAAC;QACX,OAAO,EAAE,OAAO;KACjB,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,WAAW;IACzB,OAAO,KAAK,CAAC;QACX,OAAO,EAAE,QAAQ;QACjB,QAAQ,EAAE,CAAC,KAAa,EAAoB,EAAE;YAC5C,MAAM,iBAAiB,GAAG,OAAO,CAAC;YAClC,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE;gBACtD,OAAO,6BAA6B,CAAC;aACtC;iBAAM;gBACL,OAAO,IAAI,CAAC;aACb;QACH,CAAC;KACF,CAAC,CAAC;AACL,CAAC;AAED,MAAM,UAAU,kBAAkB;IAChC,OAAO,OAAO,CAAC;QACb,OAAO,EAAE,eAAe;QACxB,OAAO,EAAE,IAAI;KACd,CAAC,CAAC;AACL,CAAC","sourcesContent":["import select from \"@inquirer/select\";\nimport input from \"@inquirer/input\";\nimport confirm from \"@inquirer/confirm\";\n\nexport interface AnswersType {\n type: string;\n scope: string;\n description: string;\n body: string;\n issue: string;\n}\n\nexport function askForType(): Promise<string> {\n return select({\n message: \"type?\",\n pageSize: 99,\n choices: [\n {\n name: \"fix\",\n value: \"fix\",\n description: \"A bugfix\",\n },\n {\n name: \"feat\",\n value: \"feat\",\n description: \"A new feature\",\n },\n {\n name: \"refactor\",\n value: \"refactor\",\n description: \"A code change that neither fixes a bug nor adds a feature\",\n },\n {\n name: \"perf\",\n value: \"perf\",\n description: \"A code change that improves performance\",\n },\n {\n name: \"docs\",\n value: \"docs\",\n description: \"Documentation only changes\",\n },\n {\n name: \"style\",\n value: \"style\",\n description: \"Code style (semicolon, indentation, white-space, formatting, ...)\",\n },\n {\n name: \"test\",\n value: \"test\",\n description: \"add/change/delete tests\",\n },\n {\n name: \"chore\",\n value: \"chore\",\n description: \"Other changes that don't modify src or test files\",\n },\n {\n name: \"build\",\n value: \"build\",\n description: \"build system (npm, git, VSCode, tsconfig, angular.json, ...)\",\n },\n {\n name: \"ci\",\n value: \"ci\",\n description: \"CI configuration (GitHub, GitLab, RenovateBot, ...)\",\n },\n {\n name: \"revert\",\n value: \"revert\",\n description: \"Reverts a previous commit\",\n },\n ],\n });\n}\n\nexport function askForScope(): Promise<string> {\n return input({\n message: \"scope?\",\n validate: (value: string): string | boolean => {\n if (value.length > 20) {\n return `Your text is ${value.length - 20} char(s) too long.`;\n } else {\n return true;\n }\n },\n });\n}\n\nexport function askForDescription(): Promise<string> {\n return input({\n message: \"description?\",\n validate: (value: string): string | boolean => {\n if (value.length > 70) {\n return `Your text is ${value.length - 70} char(s) too long.`;\n } else if (value.length < 3) {\n return `Your text is ${3 - value.length} char(s) too short.`;\n } else {\n return true;\n }\n },\n });\n}\n\nexport function askForBody(): Promise<string> {\n return input({\n message: \"body?\",\n });\n}\n\nexport function askForIssue(): Promise<string> {\n return input({\n message: \"issue?\",\n validate: (value: string): string | boolean => {\n const regularExpression = /^\\d+$/;\n if (value.length > 0 && !regularExpression.test(value)) {\n return \"Your issue is not a number.\";\n } else {\n return true;\n }\n },\n });\n}\n\nexport function askForConfirmation(): Promise<boolean> {\n return confirm({\n message: \"Is this okay?\",\n default: true,\n });\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@4s1/conventional-commit-creator",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.8.0",
|
|
4
4
|
"description": "Conventional Commit Creator",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"conventional commit",
|
|
7
7
|
"4s1"
|
|
8
8
|
],
|
|
9
9
|
"bugs": {
|
|
10
|
-
"url": "https://
|
|
10
|
+
"url": "https://codeberg.org/4s1/conventional-commit-creator/issues"
|
|
11
11
|
},
|
|
12
12
|
"repository": {
|
|
13
13
|
"type": "git",
|
|
14
|
-
"url": "https://
|
|
14
|
+
"url": "https://codeberg.org/4s1/conventional-commit-creator.git"
|
|
15
15
|
},
|
|
16
16
|
"license": "MIT",
|
|
17
17
|
"author": "Steffen <steffen@4s1.de>",
|
|
@@ -26,37 +26,36 @@
|
|
|
26
26
|
"files": [
|
|
27
27
|
"dist/"
|
|
28
28
|
],
|
|
29
|
+
"prettier": "@4s1/eslint-config",
|
|
30
|
+
"dependencies": {
|
|
31
|
+
"@inquirer/confirm": "2.0.14",
|
|
32
|
+
"@inquirer/input": "1.2.13",
|
|
33
|
+
"@inquirer/select": "1.3.0"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@4s1/eslint-config": "7.1.1",
|
|
37
|
+
"@4s1/ts-config": "5.3.0",
|
|
38
|
+
"@types/node": "20.8.7",
|
|
39
|
+
"@types/prompts": "2.4.7",
|
|
40
|
+
"eslint": "8.51.0",
|
|
41
|
+
"prettier": "3.0.3",
|
|
42
|
+
"ts-node": "10.9.1",
|
|
43
|
+
"typescript": "5.1.6"
|
|
44
|
+
},
|
|
45
|
+
"publishConfig": {
|
|
46
|
+
"access": "public"
|
|
47
|
+
},
|
|
29
48
|
"scripts": {
|
|
30
49
|
"build": "rm -rf dist && tsc",
|
|
31
50
|
"build:dev": "rm -rf dist && tsc --project tsconfig.dev.json",
|
|
32
51
|
"format": "prettier --write .",
|
|
33
|
-
"lbt": "
|
|
52
|
+
"lbt": "pnpm run lint && pnpm run build && pnpm run test",
|
|
34
53
|
"lint": "eslint --ext .ts src/ && prettier --check .",
|
|
35
54
|
"start": "node dist/index.js",
|
|
36
55
|
"start:dev": "ts-node --esm src/index.ts",
|
|
37
56
|
"test": "echo no tests",
|
|
38
|
-
"test:cov": "pnpm run test --coverage",
|
|
39
57
|
"test:watch": "pnpm run test --watch",
|
|
40
|
-
"preversion": "
|
|
58
|
+
"preversion": "pnpm run lbt",
|
|
41
59
|
"postversion": "git push && git push --follow-tags"
|
|
42
|
-
},
|
|
43
|
-
"prettier": "@4s1/eslint-config",
|
|
44
|
-
"dependencies": {
|
|
45
|
-
"@inquirer/confirm": "2.0.2",
|
|
46
|
-
"@inquirer/input": "1.2.1",
|
|
47
|
-
"@inquirer/select": "1.2.1"
|
|
48
|
-
},
|
|
49
|
-
"devDependencies": {
|
|
50
|
-
"@4s1/eslint-config": "6.6.0",
|
|
51
|
-
"@4s1/ts-config": "5.0.1",
|
|
52
|
-
"@types/node": "18.16.18",
|
|
53
|
-
"@types/prompts": "2.4.4",
|
|
54
|
-
"eslint": "8.42.0",
|
|
55
|
-
"prettier": "2.8.8",
|
|
56
|
-
"ts-node": "10.9.1",
|
|
57
|
-
"typescript": "5.0.4"
|
|
58
|
-
},
|
|
59
|
-
"publishConfig": {
|
|
60
|
-
"access": "public"
|
|
61
60
|
}
|
|
62
|
-
}
|
|
61
|
+
}
|