Merge pull request 'Make commit signing possible' (#3) from develop into main

Reviewed-on: technology/rcz#3
This commit is contained in:
2023-08-20 15:13:30 +00:00
4 changed files with 25 additions and 7 deletions

View File

@@ -2,6 +2,12 @@
Generation of this changelog is based on commits Generation of this changelog is based on commits
## v1.2.0
### Features
- [46a52ddeb] - **commands**: add the ability to sign conventional commits (#2)
## v1.1.3 ## v1.1.3
### Fixes ### Fixes

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

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

@@ -38,7 +38,10 @@ program
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");
@@ -178,9 +181,11 @@ program
}${body ? `\n\n${body}` : ``}`; }${body ? `\n\n${body}` : ``}`;
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);
@@ -372,7 +377,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(
( (
@@ -392,8 +399,12 @@ 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.parse(); program.parse();