3 Commits

5 changed files with 60 additions and 51 deletions

View File

@@ -1,9 +1,15 @@
# Changelog
Generation of this changelog is based on commits
## v1.14.0
### Features
- [f767b846d] - **commands**: add ability to choose files to stage (#22)
### Miscellaneous
- [0cac22a7e] - **changelog**: improve generation time by ~2800 times (#23)
## v1.13.1
### Fixes
- [87edf8cfa] - **changelog**: wrong semver sequence generation (#21)
### Miscellaneous
- [6df102156] - **release**: v1.13.1
- [47a8b0585] - **commands**: change head error message
- [b6d749bea] - fix version regex to include pre-releases
## v1.13.0

View File

@@ -1,6 +1,6 @@
{
"name": "@resultium/rcz",
"version": "1.13.1",
"version": "1.14.0",
"license": "GPL-3.0-or-later",
"description": "Resultium commit standardization library, inspired by conventional commits",
"main": "./dist/index.js",

View File

@@ -51,63 +51,34 @@ const command = new Command("changelog")
for (const commit of commits) {
const tag =
sort((await simpleGit().tags([`--contains=${commit.hash}`])).all)[0]! ||
unreleased;
(commit.refs.match(/tag: (\S+)(?:,|$)/)?.[1] ?? lastTag) || unreleased;
const currentCommitStack = parsedCommitStacks.find(
let currentCommitStackIndex = parsedCommitStacks.findIndex(
(commitStack) => commitStack.version === tag,
) || {
);
if (currentCommitStackIndex === -1) {
parsedCommitStacks.push({
version: tag || unreleased,
breaking: [],
features: [],
fixes: [],
miscellaneous: [],
};
});
if (lastTag !== tag) {
parsedCommitStacks = [currentCommitStack, ...parsedCommitStacks];
currentCommitStackIndex = parsedCommitStacks.findIndex(
(commitStack) => commitStack.version === tag,
);
}
if (commit.message.includes("!:")) {
parsedCommitStacks = [
{
...currentCommitStack,
breaking: [...currentCommitStack.breaking, commit],
},
...parsedCommitStacks.filter(
(commitStack) => commitStack.version !== tag,
),
];
parsedCommitStacks[currentCommitStackIndex].breaking.push(commit);
} else if (commit.message.startsWith("feat")) {
parsedCommitStacks = [
{
...currentCommitStack,
features: [...currentCommitStack.features, commit],
},
...parsedCommitStacks.filter(
(commitStack) => commitStack.version !== tag,
),
];
parsedCommitStacks[currentCommitStackIndex].features.push(commit);
} else if (commit.message.startsWith("fix")) {
parsedCommitStacks = [
{
...currentCommitStack,
fixes: [...currentCommitStack.fixes, commit],
},
...parsedCommitStacks.filter(
(commitStack) => commitStack.version !== tag,
),
];
parsedCommitStacks[currentCommitStackIndex].fixes.push(commit);
} else {
parsedCommitStacks = [
{
...currentCommitStack,
miscellaneous: [...currentCommitStack.miscellaneous, commit],
},
...parsedCommitStacks.filter(
(commitStack) => commitStack.version !== tag,
),
];
parsedCommitStacks[currentCommitStackIndex].miscellaneous.push(commit);
}
lastTag = tag;

View File

@@ -24,6 +24,7 @@ import {
confirm,
intro,
isCancel,
multiselect,
note,
outro,
select,
@@ -31,7 +32,7 @@ import {
} from "@clack/prompts";
import { existsSync } from "fs";
import { join } from "path";
import simpleGit from "simple-git";
import simpleGit, { ResetMode } from "simple-git";
const command = new Command("commit")
.alias("c")
@@ -69,6 +70,37 @@ const command = new Command("commit")
process.exit(0);
}
const stageableFiles = (await simpleGit().status()).files;
if (stageAll === false) {
const stagedFiles = (await simpleGit().diff(["--name-only", "--cached"]))
.split("\n")
.filter((file) => file);
const filesToStage = await multiselect({
message: "Which files would you like to stash?",
options: stageableFiles.map((file) => ({
value: file.path,
label: file.path,
hint: file.from,
})),
initialValues: stagedFiles,
required: false,
});
if (isCancel(filesToStage)) {
cancel("Commit creation cancelled");
process.exit(0);
}
await simpleGit().reset(ResetMode.MIXED);
await simpleGit().add(filesToStage);
} else if (stageAll === true) {
note(
stageableFiles.map((file) => file.path).join("\n"),
"Committing following files",
);
}
try {
const changedLines = (
(

View File

@@ -29,7 +29,7 @@ import { join } from "path";
program
.name("rcz")
.description("Resultium commit standardization command-line interface")
.version("1.13.1");
.version("1.14.0");
const commandFiles = await readdir(join(__dirname, "commands"));