From 5080d71fb830f479047e18df4ded7508f2879928 Mon Sep 17 00:00:00 2001 From: Olivers Vitins Date: Tue, 22 Aug 2023 17:28:21 +0300 Subject: [PATCH 1/4] feat(config): allow more config file names .rczrc.json and rcz.config.json can now be used as rcz configuration --- .rczrc | 3 ++- README.md | 2 +- src/index.ts | 12 ++++++++++++ 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.rczrc b/.rczrc index ea4301a..8ecc533 100644 --- a/.rczrc +++ b/.rczrc @@ -3,6 +3,7 @@ "commands", "changelog", "readme", - "release" + "release", + "config" ] } diff --git a/README.md b/README.md index 043a821..ce81777 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ Resultium commit standardization library ## Configuration -You can create an `.rczrc` file in your root directory and specify available scopes and commit types +You can create an `.rczrc`, `.rczrc.json` or `rcz.config.json` file in your root directory and specify available scopes and commit types ```json { diff --git a/src/index.ts b/src/index.ts index 18c9913..b6549db 100644 --- a/src/index.ts +++ b/src/index.ts @@ -24,6 +24,18 @@ const GetConfig = async () => { await fs.promises.readFile(path.join(process.cwd(), ".rczrc")) ).toString() ) as Config; + } else if (fs.existsSync(path.join(process.cwd(), ".rczrc.json"))) { + return JSON.parse( + ( + await fs.promises.readFile(path.join(process.cwd(), ".rczrc.json")) + ).toString() + ) as Config; + } else if (fs.existsSync(path.join(process.cwd(), "rcz.config.json"))) { + return JSON.parse( + ( + await fs.promises.readFile(path.join(process.cwd(), "rcz.config.json")) + ).toString() + ) as Config; } else { return null; } From 92f8126abfa3a3a077acf633f7265f55ebc4f49c Mon Sep 17 00:00:00 2001 From: Olivers Vitins Date: Tue, 22 Aug 2023 17:43:30 +0300 Subject: [PATCH 2/4] feat(commands): add --amend option to commit sub-command --- src/index.ts | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/src/index.ts b/src/index.ts index b6549db..55e0118 100644 --- a/src/index.ts +++ b/src/index.ts @@ -51,8 +51,10 @@ program .command("commit") .description("Create a conventional commit") .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(); @@ -63,10 +65,12 @@ program process.exit(0); } - const stageAll = await confirm({ - message: "Stage all changes?", - initialValue: true, - }); + const stageAll = amend + ? null + : await confirm({ + message: "Stage all changes?", + initialValue: true, + }); if (isCancel(stageAll)) { cancel("Commit creation cancelled"); @@ -204,14 +208,24 @@ program if (stageAll) { await simpleGit() .add(".") - .commit(commitMessage, sign ? ["-S"] : []); + .commit( + commitMessage, + sign ? (amend ? ["-S", "--amend"] : ["-S"]) : amend ? ["--amend"] : [] + ); } else { - await simpleGit().commit(commitMessage, sign ? ["-S"] : []); + await simpleGit().commit( + commitMessage, + sign ? (amend ? ["-S", "--amend"] : ["-S"]) : amend ? ["--amend"] : [] + ); } note(commitMessage); - outro("Finished creating a conventional commit, feel free to push"); + outro( + `Finished ${ + amend ? "amending" : "creating" + } a conventional commit, feel free to push` + ); }); program From 53bb1437a0b88977d7f45af3152f2a2c4bdfdd56 Mon Sep 17 00:00:00 2001 From: Olivers Vitins Date: Wed, 23 Aug 2023 22:43:23 +0300 Subject: [PATCH 3/4] fix(commands): allow chore type (#7) allow chore type to permit validate subcommand usage together with release subcommand --- .rczrc => .rczrc.json | 0 src/index.ts | 7 ++++++- 2 files changed, 6 insertions(+), 1 deletion(-) rename .rczrc => .rczrc.json (100%) diff --git a/.rczrc b/.rczrc.json similarity index 100% rename from .rczrc rename to .rczrc.json diff --git a/src/index.ts b/src/index.ts index 55e0118..e4a7c1e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -115,6 +115,11 @@ program value: "refactor", hint: "code change that neither fixes a bug nor adds a feature", }, + { + label: "chore", + value: "chore", + hint: "changes that are routinely, e.g. dependency update or a release commit", + }, ], }); @@ -462,7 +467,7 @@ program config?.types?.map((type) => type.value).join("|") || "feat|fix|build|ci|docs|perf|refactor" })(\\((${ - config?.scopes?.join("|") || "..*" + config?.scopes ? [...config?.scopes, "release"] : "..*" })\\))?!?: .* ?(\\(..*\\))?((\n\n..*)?(\n\n..*)?)?`, "gm" ); From 71925553c15a37deb2c361efb9d4f346cfb223da Mon Sep 17 00:00:00 2001 From: Olivers Vitins Date: Wed, 23 Aug 2023 22:46:00 +0300 Subject: [PATCH 4/4] chore(release): v1.5.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 550a8bc..e20396a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@resultium/rcz", - "version": "1.4.0", + "version": "1.5.0", "description": "Resultium commit standardization library, based on conventional commits", "main": "./dist/index.js", "bin": {