Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| f3c55fac30 | |||
| 755da3bb57 | |||
| 9311be80b2 | |||
| 8816db86fe | |||
|
c69db8f4b9
|
|||
|
46a52ddebb
|
|||
| 37a1d0b25c | |||
| 2ac0307c87 |
22
CHANGELOG.md
22
CHANGELOG.md
@@ -2,6 +2,18 @@
|
||||
|
||||
Generation of this changelog is based on commits
|
||||
|
||||
## 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
|
||||
|
||||
### Miscellaneous
|
||||
@@ -18,7 +30,11 @@ Generation of this changelog is based on commits
|
||||
|
||||
### Features
|
||||
|
||||
- [`8e5158726`] - **commands**: add release and changelog commands
|
||||
- [8e5158726] - **commands**: add release and changelog commands
|
||||
|
||||
### Miscellaneous
|
||||
|
||||
- [b05591a31] - **release**: v1.1.0
|
||||
|
||||
## v1.0.0
|
||||
|
||||
@@ -34,8 +50,8 @@ Generation of this changelog is based on commits
|
||||
|
||||
### Features
|
||||
|
||||
- [`b5ca3152c`] - add support for body (#1)
|
||||
- [`ce0c01347`] - initial commit
|
||||
- [b5ca3152c] - add support for body (#1)
|
||||
- [ce0c01347] - initial commit
|
||||
|
||||
### Fixes
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ Resultium commit standardization library
|
||||
|
||||
1. Make changes to your git initialized project
|
||||
2. Run `rcz commit` in the root directory
|
||||
- if you wish to sign your commit use `--sign` option
|
||||
3. Answer all the questions
|
||||
4. Push to remote
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
"dictionaryDefinitions": [],
|
||||
"dictionaries": [],
|
||||
"words": [
|
||||
"Acked",
|
||||
"johndoe",
|
||||
"outro",
|
||||
"rczrc"
|
||||
],
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@resultium/rcz",
|
||||
"version": "1.1.3",
|
||||
"version": "1.3.0",
|
||||
"description": "Resultium commit standardization library, based on conventional commits",
|
||||
"main": "./dist/index.js",
|
||||
"bin": {
|
||||
|
||||
69
src/index.ts
69
src/index.ts
@@ -33,12 +33,15 @@ const program = new Command();
|
||||
program
|
||||
.name("rcz")
|
||||
.description("Resultium commit standardization command-line interface")
|
||||
.version("1.0.0");
|
||||
.version("1.3.0");
|
||||
|
||||
program
|
||||
.command("commit")
|
||||
.description("Create a conventional commit")
|
||||
.action(async () => {
|
||||
.option("-S, --sign", "sign the commit")
|
||||
.action(async (options) => {
|
||||
const sign = options.sign ? true : false;
|
||||
|
||||
const config = await GetConfig();
|
||||
|
||||
intro("Creating a conventional commit");
|
||||
@@ -142,6 +145,15 @@ program
|
||||
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({
|
||||
message: "Does this commit have breaking changes?",
|
||||
initialValue: false,
|
||||
@@ -175,12 +187,14 @@ program
|
||||
scope ? `(${scope.toString()})` : ``
|
||||
}${isBreaking ? "!" : ""}: ${message.toString()}${
|
||||
resolvesIssue ? ` (${issue?.toString()})` : ``
|
||||
}${body ? `\n\n${body}` : ``}`;
|
||||
}${body ? `\n\n${body}` : ``}${footer ? `\n\n${footer}` : ``}`;
|
||||
|
||||
if (stageAll) {
|
||||
await simpleGit().add(".").commit(commitMessage);
|
||||
await simpleGit()
|
||||
.add(".")
|
||||
.commit(commitMessage, sign ? ["-S"] : []);
|
||||
} else {
|
||||
await simpleGit().commit(commitMessage);
|
||||
await simpleGit().commit(commitMessage, sign ? ["-S"] : []);
|
||||
}
|
||||
|
||||
note(commitMessage);
|
||||
@@ -372,7 +386,9 @@ program
|
||||
"Changes package.json version and creates a new commit with a tag"
|
||||
)
|
||||
.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 packageFile = JSON.parse(
|
||||
(
|
||||
@@ -392,8 +408,45 @@ program
|
||||
|
||||
await simpleGit()
|
||||
.add(".")
|
||||
.commit(`chore(release): v${version}`)
|
||||
.addTag(`v${version}`);
|
||||
.commit(`chore(release): v${version}`, sign ? ["-S"] : [])
|
||||
.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")
|
||||
.action(async (string: string) => {
|
||||
try {
|
||||
const message = string || fs.readFileSync(0, "utf-8");
|
||||
|
||||
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"
|
||||
})(\\((${
|
||||
config?.scopes?.join("|") || "..*"
|
||||
})\\))?!?: .* ?(\\(..*\\))?((\n\n..*)?(\n\n..*)?)?`,
|
||||
"gm"
|
||||
);
|
||||
|
||||
console.log(
|
||||
testRegex.test(message)
|
||||
? "[rcz]: valid message"
|
||||
: "[rcz]: invalid message"
|
||||
);
|
||||
} catch (err) {
|
||||
console.log("[rcz]: no stdin found");
|
||||
}
|
||||
});
|
||||
|
||||
program.parse();
|
||||
|
||||
Reference in New Issue
Block a user