4 Commits

3 changed files with 45 additions and 30 deletions

View File

@@ -1,5 +1,13 @@
# Changelog # Changelog
Generation of this changelog is based on commits Generation of this changelog is based on commits
## v1.11.0
### Features
- [30a7e0b28] - **commands**: add --sudo option to commit command (#16)
## v1.10.1
### Fixes
- [782894dae] - **commands**: failure to cancel commit creation
### Miscellaneous
- [ebfa3859f] - **release**: v1.10.1
## v1.10.0 ## v1.10.0
### Features ### Features
- [d707aaffe] - **config**: allow RCZ configs to be located in a folder (#15) - [d707aaffe] - **config**: allow RCZ configs to be located in a folder (#15)
@@ -7,6 +15,7 @@ Generation of this changelog is based on commits
- [83d655931] - **commands**: warn on >250 line commits, improve text (#13) - [83d655931] - **commands**: warn on >250 line commits, improve text (#13)
- [f371102a8] - **commands**: add aliases to main commands - [f371102a8] - **commands**: add aliases to main commands
### Miscellaneous ### Miscellaneous
- [399f65dab] - **release**: v1.10.0
- [28e1caf28] - push to main post release - [28e1caf28] - push to main post release
## v1.9.0 ## v1.9.0
### Features ### Features

View File

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

View File

@@ -123,7 +123,7 @@ const program = new Command();
program program
.name("rcz") .name("rcz")
.description("Resultium commit standardization command-line interface") .description("Resultium commit standardization command-line interface")
.version("1.10.0"); .version("1.11.0");
program program
.command("commit") .command("commit")
@@ -131,6 +131,7 @@ program
.description("Create a conventional commit") .description("Create a conventional commit")
.option("-S, --sign", "sign the commit") .option("-S, --sign", "sign the commit")
.option("--amend", "amend commit message to the last commit") .option("--amend", "amend commit message to the last commit")
.option("--sudo", "remove any validation")
.action(async (options) => { .action(async (options) => {
await CheckForUpdates(); await CheckForUpdates();
@@ -138,6 +139,7 @@ program
const sign = config?.autoSignCommits || options.sign ? true : false; const sign = config?.autoSignCommits || options.sign ? true : false;
const amend = options.amend ? true : false; const amend = options.amend ? true : false;
const sudo = options.sudo ? true : false;
intro("Creating a conventional commit"); intro("Creating a conventional commit");
@@ -166,7 +168,7 @@ program
).match(/\d+/gm) || [] ).match(/\d+/gm) || []
).reduce((partialSum, num) => partialSum + Number(num), 0); ).reduce((partialSum, num) => partialSum + Number(num), 0);
if (changedLines > 250) { if (changedLines > 250 && !sudo) {
const proceedCommitting = await confirm({ const proceedCommitting = await confirm({
message: message:
"You are about to commit changes to more than 250 lines, are you sure you want to proceed?", "You are about to commit changes to more than 250 lines, are you sure you want to proceed?",
@@ -177,6 +179,11 @@ program
cancel("Commit creation cancelled"); cancel("Commit creation cancelled");
process.exit(0); process.exit(0);
} }
if (!proceedCommitting) {
cancel("Cancelled, please split this commit into smaller ones");
process.exit(0);
}
} }
const type: string | symbol = await select({ const type: string | symbol = await select({
@@ -235,6 +242,10 @@ program
"Input a scope (subsystem which change is relevant to e.g. router, forms, core) or leave empty", "Input a scope (subsystem which change is relevant to e.g. router, forms, core) or leave empty",
placeholder: "router", placeholder: "router",
validate: (value) => { validate: (value) => {
if (sudo) {
return
}
if (config?.scopes && value) { if (config?.scopes && value) {
if (!config?.scopes.includes(value)) if (!config?.scopes.includes(value))
return "This scope is not allowed by local configuration"; return "This scope is not allowed by local configuration";
@@ -255,6 +266,10 @@ program
message: `Briefly describe made changes in imperative tense, maximum length 50`, message: `Briefly describe made changes in imperative tense, maximum length 50`,
placeholder: "warn upon suspicious router requests", placeholder: "warn upon suspicious router requests",
validate: (value) => { validate: (value) => {
if (sudo) {
return
}
if (value.length > 50) { if (value.length > 50) {
return "Your message is too long"; return "Your message is too long";
} }
@@ -316,10 +331,8 @@ program
process.exit(0); process.exit(0);
} }
const commitMessage = `${type.toString()}${ const commitMessage = `${type.toString()}${scope ? `(${scope.toString()})` : ``
scope ? `(${scope.toString()})` : `` }${isBreaking ? "!" : ""}: ${message.toString()}${resolvesIssue ? ` (${issue?.toString()})` : ``
}${isBreaking ? "!" : ""}: ${message.toString()}${
resolvesIssue ? ` (${issue?.toString()})` : ``
}${body ? `\n\n${body}` : ``}${footer ? `\n\n${footer}` : ``}`; }${body ? `\n\n${body}` : ``}${footer ? `\n\n${footer}` : ``}`;
if (stageAll) { if (stageAll) {
@@ -339,8 +352,7 @@ program
note(commitMessage); note(commitMessage);
outro( outro(
`Finished ${ `Finished ${amend ? "amending" : "creating"
amend ? "amending" : "creating"
} a conventional commit, feel free to push` } a conventional commit, feel free to push`
); );
}); });
@@ -462,8 +474,7 @@ program
: firstMessageLine[0]; : firstMessageLine[0];
console.log( console.log(
`${showHashes ? `- [${shortHash}]` : ``} - ${ `${showHashes ? `- [${shortHash}]` : ``} - ${type ? `**${type}**: ${briefMessage}` : briefMessage
type ? `**${type}**: ${briefMessage}` : briefMessage
}` }`
); );
} }
@@ -482,8 +493,7 @@ program
: firstMessageLine[0]; : firstMessageLine[0];
console.log( console.log(
`${showHashes ? `- [${shortHash}]` : ``} - ${ `${showHashes ? `- [${shortHash}]` : ``} - ${type ? `**${type}**: ${briefMessage}` : briefMessage
type ? `**${type}**: ${briefMessage}` : briefMessage
}` }`
); );
} }
@@ -502,8 +512,7 @@ program
: firstMessageLine[0]; : firstMessageLine[0];
console.log( console.log(
`${showHashes ? `- [${shortHash}]` : ``} - ${ `${showHashes ? `- [${shortHash}]` : ``} - ${type ? `**${type}**: ${briefMessage}` : briefMessage
type ? `**${type}**: ${briefMessage}` : briefMessage
}` }`
); );
} }
@@ -522,8 +531,7 @@ program
: firstMessageLine[0]; : firstMessageLine[0];
console.log( console.log(
`${showHashes ? `- [${shortHash}]` : ``} - ${ `${showHashes ? `- [${shortHash}]` : ``} - ${type ? `**${type}**: ${briefMessage}` : briefMessage
type ? `**${type}**: ${briefMessage}` : briefMessage
}` }`
); );
} }
@@ -611,11 +619,9 @@ program
// /(build|feat|docs)(\((commands|changelog)\))?!?: .* ?(\(..*\))?((\n\n..*)?(\n\n..*)?)?/gm // /(build|feat|docs)(\((commands|changelog)\))?!?: .* ?(\(..*\))?((\n\n..*)?(\n\n..*)?)?/gm
const testRegex = new RegExp( const testRegex = new RegExp(
`(${ `(${config?.types?.map((type) => type.value).join("|") ||
config?.types?.map((type) => type.value).join("|") ||
"feat|fix|build|ci|docs|perf|refactor|chore" "feat|fix|build|ci|docs|perf|refactor|chore"
})(\\((${ })(\\((${config?.scopes ? [...config?.scopes, "release"].join("|") : "..*"
config?.scopes ? [...config?.scopes, "release"].join("|") : "..*"
})\\))?!?: .* ?(\\(..*\\))?((\n\n..*)?(\n\n..*)?)?`, })\\))?!?: .* ?(\\(..*\\))?((\n\n..*)?(\n\n..*)?)?`,
"gm" "gm"
); );