@4s1/conventional-commit-creator 3.8.0 → 3.9.0-rc.1
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.js.map +1 -1
- package/dist/git.js.map +1 -1
- package/dist/index.js +22 -26
- package/dist/index.js.map +1 -1
- package/dist/questions.d.ts +1 -1
- package/dist/questions.d.ts.map +1 -1
- package/dist/questions.js.map +1 -1
- package/dist/utils.d.ts +2 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +21 -0
- package/dist/utils.js.map +1 -0
- package/package.json +15 -14
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;AA8B7B,MAAM,UAAU,UAAU;IACxB,MAAM,UAAU,GAAG,GAAG,EAAE,CAAC,OAAO,EAAE,kDAAkD,CAAC;IAErF,IAAI,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE;
|
|
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;AA8B7B,MAAM,UAAU,UAAU;IACxB,MAAM,UAAU,GAAG,GAAG,EAAE,CAAC,OAAO,EAAE,kDAAkD,CAAC;IAErF,IAAI,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC9B,MAAM,MAAM,GAAG,EAAE,CAAC,YAAY,CAAC,UAAU,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;QAClE,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;IAC5B,CAAC;SAAM,CAAC;QACN,MAAM,MAAM,GAAe;YACzB,OAAO,EAAE,4DAA4D;YACrE,OAAO,EAAE,CAAC;YACV,SAAS,EAAE;gBACT;oBACE,IAAI,EAAE,SAAS;oBACf,KAAK,EAAE,IAAI;oBACX,OAAO,EAAE,2CAA2C;oBAEpD,QAAQ,EAAE,EAAE;oBACZ,SAAS,EAAE,EAAE;oBACb,SAAS,EAAE,GAAG;oBACd,UAAU,EAAE,GAAG;oBACf,eAAe,EAAE,EAAE;oBACnB,gBAAgB,EAAE,EAAE;oBACpB,QAAQ,EAAE,MAAM;oBAChB,SAAS,EAAE,EAAE;oBAEb,SAAS,EAAE,KAAK;oBAChB,UAAU,EAAE,GAAG;oBACf,UAAU,EAAE,EAAE;oBACd,WAAW,EAAE,EAAE;oBACf,UAAU,EAAE,EAAE;oBACd,WAAW,EAAE,EAAE;iBAChB;aACF;SACF,CAAC;QACF,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;QAC5D,EAAE,CAAC,aAAa,CAAC,UAAU,EAAE,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,CAAC,CAAC;QACrF,OAAO,MAAM,CAAC;IAChB,CAAC;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.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;
|
|
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,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,qCAAqC,CAAC,CAAC;YACzE,OAAO,MAAM,CAAC,IAAI,EAAE,KAAK,MAAM,CAAC;QAClC,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,OAAO,CAAC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BACD,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
|
@@ -3,6 +3,7 @@ import { Git } from "./git.js";
|
|
|
3
3
|
import { loadConfig } from "./config.js";
|
|
4
4
|
import { AppError } from "./app-error.js";
|
|
5
5
|
import { askForBody, askForConfirmation, askForDescription, askForIssue, askForScope, askForType, } from "./questions.js";
|
|
6
|
+
import { splitText } from "./utils.js";
|
|
6
7
|
async function main() {
|
|
7
8
|
try {
|
|
8
9
|
const git = new Git();
|
|
@@ -17,11 +18,11 @@ async function main() {
|
|
|
17
18
|
const template = getMatchingTemplate(config, remoteOriginUrl);
|
|
18
19
|
console.info(`Using template "${template.name}"\n`);
|
|
19
20
|
const answers = {
|
|
20
|
-
type: await askForType(),
|
|
21
|
-
scope: await askForScope(),
|
|
22
|
-
description: await askForDescription(),
|
|
23
|
-
body: await askForBody(),
|
|
24
|
-
issue: await askForIssue(),
|
|
21
|
+
type: (await askForType()).trim(),
|
|
22
|
+
scope: (await askForScope()).trim(),
|
|
23
|
+
description: (await askForDescription()).trim(),
|
|
24
|
+
body: splitText((await askForBody()).trim(), 100),
|
|
25
|
+
issue: (await askForIssue()).trim(),
|
|
25
26
|
};
|
|
26
27
|
const msg = await createMsg(answers, template);
|
|
27
28
|
console.info(`${"-".repeat(42)}\n${msg}\n${"-".repeat(42)}`);
|
|
@@ -33,6 +34,11 @@ async function main() {
|
|
|
33
34
|
catch (err) {
|
|
34
35
|
if (err instanceof AppError) {
|
|
35
36
|
console.error(err.message);
|
|
37
|
+
process.exit(100);
|
|
38
|
+
}
|
|
39
|
+
else if (err instanceof Error &&
|
|
40
|
+
err.message.startsWith("User force closed the prompt with")) {
|
|
41
|
+
// Abort exception of @inquirer
|
|
36
42
|
process.exit(0);
|
|
37
43
|
}
|
|
38
44
|
else {
|
|
@@ -56,34 +62,24 @@ function getMatchingTemplate(config, remoteOriginUrl) {
|
|
|
56
62
|
return template2;
|
|
57
63
|
}
|
|
58
64
|
async function createMsg(answers, template) {
|
|
59
|
-
const
|
|
60
|
-
const scope = answers.scope ? answers.scope.trim() : "";
|
|
61
|
-
const body = answers.body
|
|
62
|
-
? answers.body
|
|
63
|
-
.split("\\n")
|
|
64
|
-
.map((x) => x.trim())
|
|
65
|
-
.join("\n")
|
|
66
|
-
.trim()
|
|
67
|
-
: "";
|
|
68
|
-
const description = answers.description ? answers.description.trim() : "";
|
|
69
|
-
const issue = answers.issue ? answers.issue.trim() : "";
|
|
65
|
+
const body = answers.body.join("\n");
|
|
70
66
|
let msg = template.pattern;
|
|
71
|
-
if (type) {
|
|
72
|
-
const typeText = `${template.pre_type ?? ""}${type}${template.post_type ?? ""}`;
|
|
67
|
+
if (answers.type) {
|
|
68
|
+
const typeText = `${template.pre_type ?? ""}${answers.type}${template.post_type ?? ""}`;
|
|
73
69
|
msg = msg.replace("{type}", typeText);
|
|
74
70
|
}
|
|
75
71
|
else {
|
|
76
72
|
msg = msg.replace("{type}", "");
|
|
77
73
|
}
|
|
78
|
-
if (scope) {
|
|
79
|
-
const scopeText = `${template.pre_scope ?? ""}${scope}${template.post_scope ?? ""}`;
|
|
74
|
+
if (answers.scope) {
|
|
75
|
+
const scopeText = `${template.pre_scope ?? ""}${answers.scope}${template.post_scope ?? ""}`;
|
|
80
76
|
msg = msg.replace("{scope}", scopeText);
|
|
81
77
|
}
|
|
82
78
|
else {
|
|
83
79
|
msg = msg.replace("{scope}", "");
|
|
84
80
|
}
|
|
85
|
-
if (description) {
|
|
86
|
-
const descriptionText = `${template.pre_description ?? ""}${description}${template.post_description ?? ""}`;
|
|
81
|
+
if (answers.description) {
|
|
82
|
+
const descriptionText = `${template.pre_description ?? ""}${answers.description}${template.post_description ?? ""}`;
|
|
87
83
|
msg = msg.replace("{description}", descriptionText);
|
|
88
84
|
}
|
|
89
85
|
else {
|
|
@@ -96,12 +92,12 @@ async function createMsg(answers, template) {
|
|
|
96
92
|
else {
|
|
97
93
|
msg = msg.replace("{body}", "");
|
|
98
94
|
}
|
|
99
|
-
if (issue) {
|
|
100
|
-
const issueText = `${template.pre_issue ?? ""}${issue}${template.post_issue ?? ""}`;
|
|
95
|
+
if (answers.issue) {
|
|
96
|
+
const issueText = `${template.pre_issue ?? ""}${answers.issue}${template.post_issue ?? ""}`;
|
|
101
97
|
msg = msg.replace("{issue}", issueText);
|
|
102
|
-
const issue2Text = `${template.pre_issue2 ?? ""}${issue}${template.post_issue2 ?? ""}`;
|
|
98
|
+
const issue2Text = `${template.pre_issue2 ?? ""}${answers.issue}${template.post_issue2 ?? ""}`;
|
|
103
99
|
msg = msg.replace("{issue2}", issue2Text);
|
|
104
|
-
const issue3Text = `${template.pre_issue3 ?? ""}${issue}${template.post_issue3 ?? ""}`;
|
|
100
|
+
const issue3Text = `${template.pre_issue3 ?? ""}${answers.issue}${template.post_issue3 ?? ""}`;
|
|
105
101
|
msg = msg.replace("{issue3}", issue3Text);
|
|
106
102
|
}
|
|
107
103
|
else {
|
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,EACL,UAAU,EACV,kBAAkB,EAClB,iBAAiB,EACjB,WAAW,EACX,WAAW,EACX,UAAU,GACX,MAAM,gBAAgB,CAAC;
|
|
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,EACL,UAAU,EACV,kBAAkB,EAClB,iBAAiB,EACjB,WAAW,EACX,WAAW,EACX,UAAU,GACX,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEvC,KAAK,UAAU,IAAI;IACjB,IAAI,CAAC;QACH,MAAM,GAAG,GAAG,IAAI,GAAG,EAAE,CAAC;QAEtB,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,2BAA2B,EAAE,CAAC,EAAE,CAAC;YAC/C,MAAM,IAAI,QAAQ,CAAC,4CAA4C,CAAC,CAAC;QACnE,CAAC;QAED,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,iBAAiB,EAAE,CAAC,EAAE,CAAC;YACrC,MAAM,IAAI,QAAQ,CAAC,mBAAmB,CAAC,CAAC;QAC1C,CAAC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AAC;QAClB,MAAM,SAAS,GAAG,GAAG,QAAQ,CAAC,SAAS,IAAI,EAAE,GAAG,OAAO,CAAC,KAAK,GAAG,QAAQ,CAAC,UAAU,IAAI,EAAE,EAAE,CAAC;QAC5F,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QACxC,MAAM,UAAU,GAAG,GAAG,QAAQ,CAAC,UAAU,IAAI,EAAE,GAAG,OAAO,CAAC,KAAK,GAAG,QAAQ,CAAC,WAAW,IAAI,EAAE,EAAE,CAAC;QAC/F,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;QAC1C,MAAM,UAAU,GAAG,GAAG,QAAQ,CAAC,UAAU,IAAI,EAAE,GAAG,OAAO,CAAC,KAAK,GAAG,QAAQ,CAAC,WAAW,IAAI,EAAE,EAAE,CAAC;QAC/F,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC;IAC5C,CAAC;SAAM,CAAC;QACN,GAAG,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;IACpC,CAAC;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\";\nimport { splitText } from \"./utils.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()).trim(),\n scope: (await askForScope()).trim(),\n description: (await askForDescription()).trim(),\n body: splitText((await askForBody()).trim(), 100),\n issue: (await askForIssue()).trim(),\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(100);\n } else if (\n err instanceof Error &&\n err.message.startsWith(\"User force closed the prompt with\")\n ) {\n // Abort exception of @inquirer\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 body = answers.body.join(\"\\n\");\n\n let msg = template.pattern;\n\n if (answers.type) {\n const typeText = `${template.pre_type ?? \"\"}${answers.type}${template.post_type ?? \"\"}`;\n msg = msg.replace(\"{type}\", typeText);\n } else {\n msg = msg.replace(\"{type}\", \"\");\n }\n\n if (answers.scope) {\n const scopeText = `${template.pre_scope ?? \"\"}${answers.scope}${template.post_scope ?? \"\"}`;\n msg = msg.replace(\"{scope}\", scopeText);\n } else {\n msg = msg.replace(\"{scope}\", \"\");\n }\n\n if (answers.description) {\n const descriptionText = `${template.pre_description ?? \"\"}${answers.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 (answers.issue) {\n const issueText = `${template.pre_issue ?? \"\"}${answers.issue}${template.post_issue ?? \"\"}`;\n msg = msg.replace(\"{issue}\", issueText);\n const issue2Text = `${template.pre_issue2 ?? \"\"}${answers.issue}${template.post_issue2 ?? \"\"}`;\n msg = msg.replace(\"{issue2}\", issue2Text);\n const issue3Text = `${template.pre_issue3 ?? \"\"}${answers.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
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,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;
|
|
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,EAAE,CAAC;IACf,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.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,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MAAM,GAAG,EAAE,EAAE,CAAC;gBACtB,OAAO,gBAAgB,KAAK,CAAC,MAAM,GAAG,EAAE,oBAAoB,CAAC;YAC/D,CAAC;iBAAM,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAC5B,OAAO,gBAAgB,CAAC,GAAG,KAAK,CAAC,MAAM,qBAAqB,CAAC;YAC/D,CAAC;iBAAM,CAAC;gBACN,OAAO,IAAI,CAAC;YACd,CAAC;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,CAAC;gBACvD,OAAO,6BAA6B,CAAC;YACvC,CAAC;iBAAM,CAAC;gBACN,OAAO,IAAI,CAAC;YACd,CAAC;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/dist/utils.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,EAAE,CAqBpE"}
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export function splitText(text, lineLength) {
|
|
2
|
+
const result = [];
|
|
3
|
+
let remainingText = text.trim();
|
|
4
|
+
while (remainingText.length > lineLength) {
|
|
5
|
+
const rawPart = remainingText.substring(0, lineLength);
|
|
6
|
+
const lastSpaceIndex = rawPart.lastIndexOf(" ");
|
|
7
|
+
let part = "";
|
|
8
|
+
if (lastSpaceIndex >= 0) {
|
|
9
|
+
part = remainingText.substring(0, lastSpaceIndex);
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
part = remainingText.substring(0, lineLength);
|
|
13
|
+
}
|
|
14
|
+
result.push(part.trim());
|
|
15
|
+
remainingText = remainingText.slice(part.length).trim();
|
|
16
|
+
}
|
|
17
|
+
result.push(remainingText);
|
|
18
|
+
return result;
|
|
19
|
+
}
|
|
20
|
+
splitText("Hello https://www.example.com World", 10);
|
|
21
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,SAAS,CAAC,IAAY,EAAE,UAAkB;IACxD,MAAM,MAAM,GAAa,EAAE,CAAC;IAC5B,IAAI,aAAa,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC;IAEhC,OAAO,aAAa,CAAC,MAAM,GAAG,UAAU,EAAE,CAAC;QACzC,MAAM,OAAO,GAAG,aAAa,CAAC,SAAS,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;QACvD,MAAM,cAAc,GAAG,OAAO,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QAEhD,IAAI,IAAI,GAAG,EAAE,CAAC;QAEd,IAAI,cAAc,IAAI,CAAC,EAAE,CAAC;YACxB,IAAI,GAAG,aAAa,CAAC,SAAS,CAAC,CAAC,EAAE,cAAc,CAAC,CAAC;QACpD,CAAC;aAAM,CAAC;YACN,IAAI,GAAG,aAAa,CAAC,SAAS,CAAC,CAAC,EAAE,UAAU,CAAC,CAAC;QAChD,CAAC;QACD,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;QACzB,aAAa,GAAG,aAAa,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,CAAC;IAC1D,CAAC;IACD,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAE3B,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,SAAS,CAAC,qCAAqC,EAAE,EAAE,CAAC,CAAC","sourcesContent":["export function splitText(text: string, lineLength: number): string[] {\n const result: string[] = [];\n let remainingText = text.trim();\n\n while (remainingText.length > lineLength) {\n const rawPart = remainingText.substring(0, lineLength);\n const lastSpaceIndex = rawPart.lastIndexOf(\" \");\n\n let part = \"\";\n\n if (lastSpaceIndex >= 0) {\n part = remainingText.substring(0, lastSpaceIndex);\n } else {\n part = remainingText.substring(0, lineLength);\n }\n result.push(part.trim());\n remainingText = remainingText.slice(part.length).trim();\n }\n result.push(remainingText);\n\n return result;\n}\n\nsplitText(\"Hello https://www.example.com World\", 10);\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@4s1/conventional-commit-creator",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.9.0-rc.1",
|
|
4
4
|
"description": "Conventional Commit Creator",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"conventional commit",
|
|
@@ -28,19 +28,20 @@
|
|
|
28
28
|
],
|
|
29
29
|
"prettier": "@4s1/eslint-config",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@inquirer/confirm": "
|
|
32
|
-
"@inquirer/input": "
|
|
33
|
-
"@inquirer/select": "
|
|
31
|
+
"@inquirer/confirm": "3.0.0",
|
|
32
|
+
"@inquirer/input": "2.0.0",
|
|
33
|
+
"@inquirer/select": "2.0.0"
|
|
34
34
|
},
|
|
35
35
|
"devDependencies": {
|
|
36
|
-
"@4s1/eslint-config": "7.
|
|
37
|
-
"@4s1/ts-config": "
|
|
38
|
-
"@types/node": "20.
|
|
39
|
-
"@types/prompts": "2.4.
|
|
40
|
-
"eslint": "8.
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
36
|
+
"@4s1/eslint-config": "7.4.0",
|
|
37
|
+
"@4s1/ts-config": "7.0.0",
|
|
38
|
+
"@types/node": "20.11.19",
|
|
39
|
+
"@types/prompts": "2.4.9",
|
|
40
|
+
"eslint": "8.56.0",
|
|
41
|
+
"glob": "10.3.10",
|
|
42
|
+
"prettier": "3.2.5",
|
|
43
|
+
"tsx": "4.7.1",
|
|
44
|
+
"typescript": "5.3.3"
|
|
44
45
|
},
|
|
45
46
|
"publishConfig": {
|
|
46
47
|
"access": "public"
|
|
@@ -52,8 +53,8 @@
|
|
|
52
53
|
"lbt": "pnpm run lint && pnpm run build && pnpm run test",
|
|
53
54
|
"lint": "eslint --ext .ts src/ && prettier --check .",
|
|
54
55
|
"start": "node dist/index.js",
|
|
55
|
-
"start:dev": "
|
|
56
|
-
"test": "
|
|
56
|
+
"start:dev": "tsx src/index.ts",
|
|
57
|
+
"test": "glob -c \"node --test --import tsx/esm\" \"./src/**/*.spec.ts\"",
|
|
57
58
|
"test:watch": "pnpm run test --watch",
|
|
58
59
|
"preversion": "pnpm run lbt",
|
|
59
60
|
"postversion": "git push && git push --follow-tags"
|