Merge pull request 'Release v1.3.0' (#5) from develop into main

Reviewed-on: technology/rcz#5
This commit is contained in:
2023-08-21 15:14:26 +00:00
4 changed files with 54 additions and 3 deletions

View File

@@ -2,6 +2,13 @@
Generation of this changelog is based on commits
## v1.3.0
### Features
- [755da3bb5] - **commands**: add ability to write a footer
- [9311be80b] - **commands**: add commit message validation command (#4)
## v1.2.0
### Features

View File

@@ -4,6 +4,8 @@
"dictionaryDefinitions": [],
"dictionaries": [],
"words": [
"Acked",
"johndoe",
"outro",
"rczrc"
],

View File

@@ -1,6 +1,6 @@
{
"name": "@resultium/rcz",
"version": "1.2.0",
"version": "1.3.0",
"description": "Resultium commit standardization library, based on conventional commits",
"main": "./dist/index.js",
"bin": {

View File

@@ -33,7 +33,7 @@ const program = new Command();
program
.name("rcz")
.description("Resultium commit standardization command-line interface")
.version("1.0.0");
.version("1.3.0");
program
.command("commit")
@@ -145,6 +145,15 @@ program
process.exit(0);
}
const footer = await text({
message: `Insert commit footer, can be left empty, e.g. Acked-by: @johndoe`,
});
if (isCancel(footer)) {
cancel("Commit creation cancelled");
process.exit(0);
}
const isBreaking = await confirm({
message: "Does this commit have breaking changes?",
initialValue: false,
@@ -178,7 +187,7 @@ program
scope ? `(${scope.toString()})` : ``
}${isBreaking ? "!" : ""}: ${message.toString()}${
resolvesIssue ? ` (${issue?.toString()})` : ``
}${body ? `\n\n${body}` : ``}`;
}${body ? `\n\n${body}` : ``}${footer ? `\n\n${footer}` : ``}`;
if (stageAll) {
await simpleGit()
@@ -407,4 +416,37 @@ program
);
});
program
.command("validate")
.description("Validate whether a string fits given commit conventions")
.argument("[message]", "string for validation")
.action(async (string: string) => {
try {
const message = string || fs.readFileSync(0, "utf-8");
const config = await GetConfig();
// Regex for testing:
// /(build|feat|docs)(\((commands|changelog)\))?!?: .* ?(\(..*\))?((\n\n..*)?(\n\n..*)?)?/gm
const testRegex = new RegExp(
`(${
config?.types?.map((type) => type.value).join("|") ||
"feat|fix|build|ci|docs|perf|refactor"
})(\\((${
config?.scopes?.join("|") || "..*"
})\\))?!?: .* ?(\\(..*\\))?((\n\n..*)?(\n\n..*)?)?`,
"gm"
);
console.log(
testRegex.test(message)
? "[rcz]: valid message"
: "[rcz]: invalid message"
);
} catch (err) {
console.log("[rcz]: no stdin found");
}
});
program.parse();