From c80d763259e7bb1272f57adadee1276e87846909 Mon Sep 17 00:00:00 2001 From: Olivers Vitins Date: Sat, 16 Dec 2023 14:37:47 +0200 Subject: [PATCH] feat(config): add auto-signing options --- README.md | 4 +++- package.json | 2 +- src/index.ts | 13 ++++++++----- src/types.ts | 2 ++ 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index ce81777..30c0adf 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,8 @@ You can create an `.rczrc`, `.rczrc.json` or `rcz.config.json` file in your root "value": "chore", "hint": "a routine action" } - ] + ], + "autoSignCommits": false, + "autoSignReleases": true } ``` diff --git a/package.json b/package.json index 3ca152f..d7cd623 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@resultium/rcz", - "version": "1.6.0", + "version": "1.7.0", "description": "Resultium commit standardization library, based on conventional commits", "main": "./dist/index.js", "bin": { diff --git a/src/index.ts b/src/index.ts index 21908a7..cbfdc95 100644 --- a/src/index.ts +++ b/src/index.ts @@ -45,7 +45,7 @@ const program = new Command(); program .name("rcz") .description("Resultium commit standardization command-line interface") - .version("1.6.0"); + .version("1.7.0"); program .command("commit") @@ -53,11 +53,11 @@ program .option("-S, --sign", "sign the commit") .option("--amend", "amend commit message to the last commit") .action(async (options) => { - const sign = options.sign ? true : false; - const amend = options.amend ? true : false; - const config = await GetConfig(); + const sign = config?.autoSignCommits || options.sign ? true : false; + const amend = options.amend ? true : false; + intro("Creating a conventional commit"); if (!fs.existsSync(path.join(process.cwd(), ".git"))) { @@ -421,7 +421,10 @@ program .argument("", "new version formatted in SemVer") .option("-S, --sign", "sign the release commit and tag") .action(async (string: string, options) => { - const sign = options.sign ? true : false; + const config = await GetConfig(); + + const sign = config?.autoSignReleases || options.sign ? true : false; + const version = string.replace("v", ""); const packageFile = JSON.parse( ( diff --git a/src/types.ts b/src/types.ts index 611218f..4031e54 100644 --- a/src/types.ts +++ b/src/types.ts @@ -3,6 +3,8 @@ import { DefaultLogFields, ListLogLine } from "simple-git"; export interface Config { types?: Array; scopes?: Array; + autoSignCommits?: boolean; + autoSignReleases?: boolean; } export interface Type {