31 Commits

Author SHA1 Message Date
f51bb88de4 chore(release): v1.6.0 2023-12-09 19:42:25 +02:00
a5626dbc54 feat: improve default 'stage all changes' behavior 2023-12-09 19:38:01 +02:00
4c892e8b11 docs(changelog): generate for v1.5.2 2023-08-23 23:37:08 +03:00
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
77dfc9a73b chore(release): v1.4.0 2023-08-21 18:33:50 +03:00
8ab631549a feat(commands): add the ability to return code only for validation 2023-08-21 18:33:33 +03:00
2670f79e2f Merge pull request 'Release v1.3.0' (#5) from develop into main
Reviewed-on: technology/rcz#5
2023-08-21 15:14:26 +00:00
3afc2ed071 Merge branch 'main' into develop 2023-08-21 15:14:16 +00:00
45458d14e2 docs(changelog): generate for v1.3.0 2023-08-21 18:12:59 +03:00
f3c55fac30 chore(release): v1.3.0 2023-08-21 18:11:10 +03:00
755da3bb57 feat(commands): add ability to write a footer 2023-08-21 18:10:39 +03:00
9311be80b2 feat(commands): add commit message validation command (#4) 2023-08-21 18:03:36 +03:00
d61c9ecf2e Merge pull request 'Make commit signing possible' (#3) from develop into main
Reviewed-on: technology/rcz#3
2023-08-20 15:13:30 +00:00
8816db86fe docs(changelog): generate 2023-08-20 18:11:20 +03:00
c69db8f4b9 chore(release): v1.2.0 2023-08-20 18:09:28 +03:00
46a52ddebb feat(commands): add the ability to sign conventional commits (#2) 2023-08-20 18:01:12 +03:00
37a1d0b25c docs(changelog): regenerate to have hashes reference 2023-08-20 04:07:04 +03:00
2ac0307c87 docs(changelog): generate 2023-08-20 04:04:45 +03:00
8 changed files with 181 additions and 38 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"]
}

3
.vscode/settings.json vendored Normal file
View File

@@ -0,0 +1,3 @@
{
"cSpell.words": ["Resultium", "Acked", "johndoe", "outro", "rczrc"]
}

View File

@@ -2,6 +2,64 @@
Generation of this changelog is based on commits Generation of this changelog is based on commits
## v1.6.0
### Features
- [a5626dbc5] - improve default 'stage all changes' behavior
### Miscellaneous
- [4c892e8b1] - **changelog**: generate for v1.5.2
## v1.5.2
### Fixes
- [8cb67f2cf] - **commands**: incorrect regex generation with specified scopes
## 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
- [755da3bb5] - **commands**: add ability to write a footer
- [9311be80b] - **commands**: add commit message validation command (#4)
## v1.2.0
### Features
- [46a52ddeb] - **commands**: add the ability to sign conventional commits (#2)
## v1.1.3
### Fixes
- [d3cf78aac] - **commands**: incorrect formatting of changelog hashes
## v1.1.2 ## v1.1.2
### Miscellaneous ### Miscellaneous
@@ -18,7 +76,11 @@ Generation of this changelog is based on commits
### Features ### Features
- [`8e5158726`] - **commands**: add release and changelog commands - [8e5158726] - **commands**: add release and changelog commands
### Miscellaneous
- [b05591a31] - **release**: v1.1.0
## v1.0.0 ## v1.0.0
@@ -34,8 +96,8 @@ Generation of this changelog is based on commits
### Features ### Features
- [`b5ca3152c`] - add support for body (#1) - [b5ca3152c] - add support for body (#1)
- [`ce0c01347`] - initial commit - [ce0c01347] - initial commit
### Fixes ### Fixes

View File

@@ -17,12 +17,13 @@ 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
## 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,12 +0,0 @@
{
"version": "0.2",
"ignorePaths": [],
"dictionaryDefinitions": [],
"dictionaries": [],
"words": [
"outro",
"rczrc"
],
"ignoreWords": [],
"import": []
}

View File

@@ -1,6 +1,6 @@
{ {
"name": "@resultium/rcz", "name": "@resultium/rcz",
"version": "1.1.3", "version": "1.6.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;
} }
@@ -33,12 +45,17 @@ const program = new Command();
program program
.name("rcz") .name("rcz")
.description("Resultium commit standardization command-line interface") .description("Resultium commit standardization command-line interface")
.version("1.0.0"); .version("1.6.0");
program program
.command("commit") .command("commit")
.description("Create a conventional commit") .description("Create a conventional commit")
.action(async () => { .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 config = await GetConfig();
intro("Creating a conventional commit"); intro("Creating a conventional commit");
@@ -48,9 +65,15 @@ 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: (
await simpleGit().diff(["--name-only", "--cached"])
).toString()
? false
: true,
}); });
if (isCancel(stageAll)) { if (isCancel(stageAll)) {
@@ -96,6 +119,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",
},
], ],
}); });
@@ -142,6 +170,15 @@ program
process.exit(0); process.exit(0);
} }
const footer = await text({
message: `Insert commit footer, can be left empty, e.g. Acked-by: @johndoe`,
});
if (isCancel(footer)) {
cancel("Commit creation cancelled");
process.exit(0);
}
const isBreaking = await confirm({ const isBreaking = await confirm({
message: "Does this commit have breaking changes?", message: "Does this commit have breaking changes?",
initialValue: false, initialValue: false,
@@ -175,17 +212,29 @@ program
scope ? `(${scope.toString()})` : `` scope ? `(${scope.toString()})` : ``
}${isBreaking ? "!" : ""}: ${message.toString()}${ }${isBreaking ? "!" : ""}: ${message.toString()}${
resolvesIssue ? ` (${issue?.toString()})` : `` resolvesIssue ? ` (${issue?.toString()})` : ``
}${body ? `\n\n${body}` : ``}`; }${body ? `\n\n${body}` : ``}${footer ? `\n\n${footer}` : ``}`;
if (stageAll) { if (stageAll) {
await simpleGit().add(".").commit(commitMessage); await simpleGit()
.add(".")
.commit(
commitMessage,
sign ? (amend ? ["-S", "--amend"] : ["-S"]) : amend ? ["--amend"] : []
);
} else { } else {
await simpleGit().commit(commitMessage); 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
@@ -372,7 +421,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 +443,51 @@ 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
.command("validate")
.description("Validate whether a string fits given commit conventions")
.argument("[message]", "string for validation")
.option("-C, --code-only", "return code only")
.action(async (string: string, options) => {
try {
const message = string || fs.readFileSync(0, "utf-8");
const codeOnly = options.codeOnly ? true : false;
const config = await GetConfig();
// Regex for testing:
// /(build|feat|docs)(\((commands|changelog)\))?!?: .* ?(\(..*\))?((\n\n..*)?(\n\n..*)?)?/gm
const testRegex = new RegExp(
`(${
config?.types?.map((type) => type.value).join("|") ||
"feat|fix|build|ci|docs|perf|refactor|chore"
})(\\((${
config?.scopes ? [...config?.scopes, "release"].join("|") : "..*"
})\\))?!?: .* ?(\\(..*\\))?((\n\n..*)?(\n\n..*)?)?`,
"gm"
);
if (codeOnly) {
console.log(testRegex.test(message) ? 0 : 1);
} else {
console.log(
testRegex.test(message)
? "[rcz]: valid message"
: "[rcz]: invalid message"
);
}
} catch (err) {
console.log("[rcz]: no stdin found");
}
}); });
program.parse(); program.parse();