Release v1.5.0 #8

Merged
CTO merged 4 commits from develop into main 2023-08-23 19:47:45 +00:00
4 changed files with 43 additions and 11 deletions

View File

@@ -3,6 +3,7 @@
"commands", "commands",
"changelog", "changelog",
"readme", "readme",
"release" "release",
"config"
] ]
} }

View File

@@ -23,7 +23,7 @@ Resultium commit standardization library
## Configuration ## 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 ```json
{ {

View File

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

@@ -24,6 +24,18 @@ const GetConfig = async () => {
await fs.promises.readFile(path.join(process.cwd(), ".rczrc")) await fs.promises.readFile(path.join(process.cwd(), ".rczrc"))
).toString() ).toString()
) as Config; ) 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 { } else {
return null; return null;
} }
@@ -39,8 +51,10 @@ program
.command("commit") .command("commit")
.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")
.action(async (options) => { .action(async (options) => {
const sign = options.sign ? true : false; const sign = options.sign ? true : false;
const amend = options.amend ? true : false;
const config = await GetConfig(); const config = await GetConfig();
@@ -51,7 +65,9 @@ program
process.exit(0); process.exit(0);
} }
const stageAll = await confirm({ const stageAll = amend
? null
: await confirm({
message: "Stage all changes?", message: "Stage all changes?",
initialValue: true, initialValue: true,
}); });
@@ -99,6 +115,11 @@ program
value: "refactor", value: "refactor",
hint: "code change that neither fixes a bug nor adds a feature", 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",
},
], ],
}); });
@@ -192,14 +213,24 @@ program
if (stageAll) { if (stageAll) {
await simpleGit() await simpleGit()
.add(".") .add(".")
.commit(commitMessage, sign ? ["-S"] : []); .commit(
commitMessage,
sign ? (amend ? ["-S", "--amend"] : ["-S"]) : amend ? ["--amend"] : []
);
} else { } else {
await simpleGit().commit(commitMessage, sign ? ["-S"] : []); await simpleGit().commit(
commitMessage,
sign ? (amend ? ["-S", "--amend"] : ["-S"]) : amend ? ["--amend"] : []
);
} }
note(commitMessage); 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 program
@@ -436,7 +467,7 @@ program
config?.types?.map((type) => type.value).join("|") || config?.types?.map((type) => type.value).join("|") ||
"feat|fix|build|ci|docs|perf|refactor" "feat|fix|build|ci|docs|perf|refactor"
})(\\((${ })(\\((${
config?.scopes?.join("|") || "..*" config?.scopes ? [...config?.scopes, "release"] : "..*"
})\\))?!?: .* ?(\\(..*\\))?((\n\n..*)?(\n\n..*)?)?`, })\\))?!?: .* ?(\\(..*\\))?((\n\n..*)?(\n\n..*)?)?`,
"gm" "gm"
); );