14 Commits

Author SHA1 Message Date
63a6c9feab chore(release): v1.5.2 2023-08-23 23:36:31 +03:00
8cb67f2cfd fix(commands): incorrect regex generation with specified scopes 2023-08-23 23:35:48 +03:00
8dbe266e39 Merge pull request 'Allow chore type in validation regex' (#9) from develop into main
Reviewed-on: technology/rcz#9
2023-08-23 19:54:05 +00:00
58f4dde9c9 docs(changelog): generate for v1.5.1 2023-08-23 22:53:43 +03:00
9586a567de chore(release): v1.5.1 2023-08-23 22:53:05 +03:00
6c663cf7fc fix(commands): allow chore type in validation regex 2023-08-23 22:52:54 +03:00
535a62857c docs(changelog): generate for v1.5.0 2023-08-23 22:48:52 +03:00
03f68e2912 Merge pull request 'Release v1.5.0' (#8) from develop into main
Reviewed-on: technology/rcz#8
2023-08-23 19:47:44 +00:00
71925553c1 chore(release): v1.5.0 2023-08-23 22:46:00 +03:00
53bb1437a0 fix(commands): allow chore type (#7)
allow chore type to permit validate subcommand usage together with release subcommand
2023-08-23 22:43:23 +03:00
92f8126abf feat(commands): add --amend option to commit sub-command 2023-08-22 17:43:30 +03:00
5080d71fb8 feat(config): allow more config file names
.rczrc.json and rcz.config.json can now be used as rcz configuration
2023-08-22 17:41:36 +03:00
56ad837b82 Merge pull request 'Add the ability to return only the code of validation command' (#6) from develop into main
Reviewed-on: technology/rcz#6
2023-08-21 15:37:11 +00:00
003c943a74 docs(changelog): generate for v1.4.0 2023-08-21 18:35:05 +03:00
6 changed files with 68 additions and 19 deletions

8
.rczrc
View File

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

3
.rczrc.json Normal file
View File

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

View File

@@ -2,6 +2,29 @@
Generation of this changelog is based on commits
## v1.5.1
### Fixes
- [6c663cf7f] - **commands**: allow chore type in validation regex
## v1.5.0
### Features
- [92f8126ab] - **commands**: add --amend option to commit sub-command
- [5080d71fb] - **config**: allow more config file names
### Fixes
- [53bb1437a] - **commands**: allow chore type (#7)
## v1.4.0
### Features
- [8ab631549] - **commands**: add the ability to return code only for validation command
## v1.3.0
### Features

View File

@@ -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
{

View File

@@ -1,6 +1,6 @@
{
"name": "@resultium/rcz",
"version": "1.4.0",
"version": "1.5.2",
"description": "Resultium commit standardization library, based on conventional commits",
"main": "./dist/index.js",
"bin": {

View File

@@ -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;
}
@@ -39,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();
@@ -51,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");
@@ -99,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",
},
],
});
@@ -192,14 +213,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
@@ -434,9 +465,9 @@ program
const testRegex = new RegExp(
`(${
config?.types?.map((type) => type.value).join("|") ||
"feat|fix|build|ci|docs|perf|refactor"
"feat|fix|build|ci|docs|perf|refactor|chore"
})(\\((${
config?.scopes?.join("|") || "..*"
config?.scopes ? [...config?.scopes, "release"].join("|") : "..*"
})\\))?!?: .* ?(\\(..*\\))?((\n\n..*)?(\n\n..*)?)?`,
"gm"
);