20 Commits

Author SHA1 Message Date
77dfc9a73b chore(release): v1.4.0 2023-08-21 18:33:50 +03:00
8ab631549a feat(commands): add the ability to return code only for validation 2023-08-21 18:33:33 +03:00
2670f79e2f Merge pull request 'Release v1.3.0' (#5) from develop into main
Reviewed-on: technology/rcz#5
2023-08-21 15:14:26 +00:00
3afc2ed071 Merge branch 'main' into develop 2023-08-21 15:14:16 +00:00
45458d14e2 docs(changelog): generate for v1.3.0 2023-08-21 18:12:59 +03:00
f3c55fac30 chore(release): v1.3.0 2023-08-21 18:11:10 +03:00
755da3bb57 feat(commands): add ability to write a footer 2023-08-21 18:10:39 +03:00
9311be80b2 feat(commands): add commit message validation command (#4) 2023-08-21 18:03:36 +03:00
d61c9ecf2e Merge pull request 'Make commit signing possible' (#3) from develop into main
Reviewed-on: technology/rcz#3
2023-08-20 15:13:30 +00:00
8816db86fe docs(changelog): generate 2023-08-20 18:11:20 +03:00
c69db8f4b9 chore(release): v1.2.0 2023-08-20 18:09:28 +03:00
46a52ddebb feat(commands): add the ability to sign conventional commits (#2) 2023-08-20 18:01:12 +03:00
37a1d0b25c docs(changelog): regenerate to have hashes reference 2023-08-20 04:07:04 +03:00
2ac0307c87 docs(changelog): generate 2023-08-20 04:04:45 +03:00
66db269317 chore(release): v1.1.3 2023-08-20 04:03:28 +03:00
d3cf78aacb fix(commands): incorrect formatting of changelog hashes 2023-08-20 04:03:11 +03:00
605055eb76 docs(changelog): generate 2023-08-20 03:59:52 +03:00
e4ba7dab53 chore(release): v1.1.2 2023-08-20 03:57:57 +03:00
85649a71a6 refactor(commands): change changelog output text
remove quote literals from hashes in order to make them reference, add changelog description
2023-08-20 03:57:01 +03:00
d30071e3d7 docs(changelog): generate changelog 2023-08-20 03:53:08 +03:00
6 changed files with 154 additions and 14 deletions

9
.rczrc
View File

@@ -1 +1,8 @@
{} {
"scopes": [
"commands",
"changelog",
"readme",
"release"
]
}

70
CHANGELOG.md Normal file
View File

@@ -0,0 +1,70 @@
# Changelog
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
- [46a52ddeb] - **commands**: add the ability to sign conventional commits (#2)
## v1.1.3
### Fixes
- [d3cf78aac] - **commands**: incorrect formatting of changelog hashes
## v1.1.2
### Miscellaneous
- [85649a71a] - **commands**: change changelog output text
## v1.1.1
### Fixes
- [7a5880d21] - **commands**: incorrect changelog version generation
## v1.1.0
### Features
- [8e5158726] - **commands**: add release and changelog commands
### Miscellaneous
- [b05591a31] - **release**: v1.1.0
## v1.0.0
### Breaking
- [7ef777bb2] - use commander for command management
### Miscellaneous
- [b07d9aaaa] - change question formatting, improve readme
## v1.0.0-alpha.1
### Features
- [b5ca3152c] - add support for body (#1)
- [ce0c01347] - initial commit
### Fixes
- [2be2887ce] - make commit body wrap properly
- [e9d3c5e29] - incorrect config parsing
### Miscellaneous
- [4e16104d6] - change intro and outro messages

View File

@@ -17,6 +17,7 @@ Resultium commit standardization library
1. Make changes to your git initialized project 1. Make changes to your git initialized project
2. Run `rcz commit` in the root directory 2. Run `rcz commit` in the root directory
- if you wish to sign your commit use `--sign` option
3. Answer all the questions 3. Answer all the questions
4. Push to remote 4. Push to remote

View File

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

View File

@@ -1,6 +1,6 @@
{ {
"name": "@resultium/rcz", "name": "@resultium/rcz",
"version": "1.1.1", "version": "1.4.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

@@ -33,12 +33,15 @@ 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.0.0"); .version("1.4.0");
program program
.command("commit") .command("commit")
.description("Create a conventional commit") .description("Create a conventional commit")
.action(async () => { .option("-S, --sign", "sign the commit")
.action(async (options) => {
const sign = options.sign ? true : false;
const config = await GetConfig(); const config = await GetConfig();
intro("Creating a conventional commit"); intro("Creating a conventional commit");
@@ -142,6 +145,15 @@ program
process.exit(0); 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({ const isBreaking = await confirm({
message: "Does this commit have breaking changes?", message: "Does this commit have breaking changes?",
initialValue: false, initialValue: false,
@@ -175,12 +187,14 @@ program
scope ? `(${scope.toString()})` : `` scope ? `(${scope.toString()})` : ``
}${isBreaking ? "!" : ""}: ${message.toString()}${ }${isBreaking ? "!" : ""}: ${message.toString()}${
resolvesIssue ? ` (${issue?.toString()})` : `` resolvesIssue ? ` (${issue?.toString()})` : ``
}${body ? `\n\n${body}` : ``}`; }${body ? `\n\n${body}` : ``}${footer ? `\n\n${footer}` : ``}`;
if (stageAll) { if (stageAll) {
await simpleGit().add(".").commit(commitMessage); await simpleGit()
.add(".")
.commit(commitMessage, sign ? ["-S"] : []);
} else { } else {
await simpleGit().commit(commitMessage); await simpleGit().commit(commitMessage, sign ? ["-S"] : []);
} }
note(commitMessage); note(commitMessage);
@@ -208,6 +222,7 @@ program
let parsedCommitStacks: Array<CommitStack> = []; let parsedCommitStacks: Array<CommitStack> = [];
console.log("# Changelog"); console.log("# Changelog");
console.log("Generation of this changelog is based on commits");
for (const commit of commits) { for (const commit of commits) {
const tag = semver.sort( const tag = semver.sort(
@@ -296,7 +311,7 @@ program
: firstMessageLine[0]; : firstMessageLine[0];
console.log( console.log(
`${showHashes ? `- [${"`"}${shortHash}${"`"}]` : ``} - ${ `${showHashes ? `- [${shortHash}]` : ``} - ${
type ? `**${type}**: ${briefMessage}` : briefMessage type ? `**${type}**: ${briefMessage}` : briefMessage
}` }`
); );
@@ -316,7 +331,7 @@ program
: firstMessageLine[0]; : firstMessageLine[0];
console.log( console.log(
`${showHashes ? `- [${"`"}${shortHash}${"`"}]` : ``} - ${ `${showHashes ? `- [${shortHash}]` : ``} - ${
type ? `**${type}**: ${briefMessage}` : briefMessage type ? `**${type}**: ${briefMessage}` : briefMessage
}` }`
); );
@@ -336,7 +351,7 @@ program
: firstMessageLine[0]; : firstMessageLine[0];
console.log( console.log(
`${showHashes ? `- [${"`"}${shortHash}${"`"}]` : ``} - ${ `${showHashes ? `- [${shortHash}]` : ``} - ${
type ? `**${type}**: ${briefMessage}` : briefMessage type ? `**${type}**: ${briefMessage}` : briefMessage
}` }`
); );
@@ -356,7 +371,7 @@ program
: firstMessageLine[0]; : firstMessageLine[0];
console.log( console.log(
`${showHashes ? `- [${"`"}${shortHash}${"`"}]` : ``} - ${ `${showHashes ? `- [${shortHash}]` : ``} - ${
type ? `**${type}**: ${briefMessage}` : briefMessage type ? `**${type}**: ${briefMessage}` : briefMessage
}` }`
); );
@@ -371,7 +386,9 @@ program
"Changes package.json version and creates a new commit with a tag" "Changes package.json version and creates a new commit with a tag"
) )
.argument("<version>", "new version formatted in SemVer") .argument("<version>", "new version formatted in SemVer")
.action(async (string: string) => { .option("-S, --sign", "sign the release commit and tag")
.action(async (string: string, options) => {
const sign = options.sign ? true : false;
const version = string.replace("v", ""); const version = string.replace("v", "");
const packageFile = JSON.parse( const packageFile = JSON.parse(
( (
@@ -391,8 +408,51 @@ program
await simpleGit() await simpleGit()
.add(".") .add(".")
.commit(`chore(release): v${version}`) .commit(`chore(release): v${version}`, sign ? ["-S"] : [])
.addTag(`v${version}`); .tag(
sign
? [`-s`, `v${version}`, `-m`, `"Version ${version}"`]
: [`-a`, `v${version}`, `-m`, `"Version ${version}"`]
);
});
program
.command("validate")
.description("Validate whether a string fits given commit conventions")
.argument("[message]", "string for validation")
.option("-C, --code-only", "return code only")
.action(async (string: string, options) => {
try {
const message = string || fs.readFileSync(0, "utf-8");
const codeOnly = options.codeOnly ? true : false;
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"
);
if (codeOnly) {
console.log(testRegex.test(message) ? 0 : 1);
} else {
console.log(
testRegex.test(message)
? "[rcz]: valid message"
: "[rcz]: invalid message"
);
}
} catch (err) {
console.log("[rcz]: no stdin found");
}
}); });
program.parse(); program.parse();