Compare commits
7 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
1bce93a24e
|
|||
| f767b846d8 | |||
| 0cac22a7e0 | |||
|
6df1021561
|
|||
| 87edf8cfad | |||
| 47a8b05856 | |||
| b6d749beae |
@@ -3,20 +3,20 @@ const { execSync } = require("child_process");
|
|||||||
|
|
||||||
const packageFile = fs.readFileSync("./package.json").toString();
|
const packageFile = fs.readFileSync("./package.json").toString();
|
||||||
const newPackageFile = packageFile.replace(
|
const newPackageFile = packageFile.replace(
|
||||||
/"version": "[0-9]+.[0-9]+.[0-9]+"/,
|
/"version": "[0-9]+\.[0-9]+\.[0-9]+(-(alpha|beta|rc|dev)\.[0-9]+)?"/,
|
||||||
`"version": "${__NEW_VERSION__}"`
|
`"version": "${__NEW_VERSION__}"`,
|
||||||
);
|
);
|
||||||
|
|
||||||
fs.writeFileSync("./package.json", newPackageFile);
|
fs.writeFileSync("./package.json", newPackageFile);
|
||||||
|
|
||||||
const indexFile = fs.readFileSync("./src/index.ts").toString();
|
const indexFile = fs.readFileSync("./src/index.ts").toString();
|
||||||
const newIndexFile = indexFile.replace(
|
const newIndexFile = indexFile.replace(
|
||||||
/version\("[0-9]+\.[0-9]+\.[0-9]+"\)/,
|
/version\("[0-9]+\.[0-9]+\.[0-9]+(-(alpha|beta|rc|dev)\.[0-9]+)?"\)/,
|
||||||
`version("${__NEW_VERSION__}")`
|
`version("${__NEW_VERSION__}")`,
|
||||||
);
|
);
|
||||||
|
|
||||||
fs.writeFileSync("./src/index.ts", newIndexFile);
|
fs.writeFileSync("./src/index.ts", newIndexFile);
|
||||||
|
|
||||||
execSync(
|
execSync(
|
||||||
`rcz changelog --show-hashes --unreleased-as v${__NEW_VERSION__} > CHANGELOG.md`
|
`rcz changelog --show-hashes --unreleased-as v${__NEW_VERSION__} > CHANGELOG.md`,
|
||||||
);
|
);
|
||||||
|
|||||||
13
CHANGELOG.md
13
CHANGELOG.md
@@ -1,9 +1,22 @@
|
|||||||
# Changelog
|
# Changelog
|
||||||
Generation of this changelog is based on commits
|
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
|
## v1.13.0
|
||||||
### Fixes
|
### Fixes
|
||||||
- [7b499d763] - **commands**: commit crash upon missing HEAD (#19)
|
- [7b499d763] - **commands**: commit crash upon missing HEAD (#19)
|
||||||
### Miscellaneous
|
### Miscellaneous
|
||||||
|
- [87a7c4dcc] - **release**: v1.13.0
|
||||||
- [6ce6e88d8] - Merge pull request 'Refactor into multiple command files' (#20) from refactor/#18 into main
|
- [6ce6e88d8] - Merge pull request 'Refactor into multiple command files' (#20) from refactor/#18 into main
|
||||||
## v1.13.0-rc.0
|
## v1.13.0-rc.0
|
||||||
### Miscellaneous
|
### Miscellaneous
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@resultium/rcz",
|
"name": "@resultium/rcz",
|
||||||
"version": "1.13.0",
|
"version": "1.14.0",
|
||||||
"license": "GPL-3.0-or-later",
|
"license": "GPL-3.0-or-later",
|
||||||
"description": "Resultium commit standardization library, inspired by conventional commits",
|
"description": "Resultium commit standardization library, inspired by conventional commits",
|
||||||
"main": "./dist/index.js",
|
"main": "./dist/index.js",
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ along with RCZ. If not, see <https://www.gnu.org/licenses/>.
|
|||||||
import { Command } from "commander";
|
import { Command } from "commander";
|
||||||
import simpleGit from "simple-git";
|
import simpleGit from "simple-git";
|
||||||
import { CommitStack } from "../types";
|
import { CommitStack } from "../types";
|
||||||
import { sort } from "semver";
|
import { gt, sort } from "semver";
|
||||||
|
|
||||||
const command = new Command("changelog")
|
const command = new Command("changelog")
|
||||||
.alias("ch")
|
.alias("ch")
|
||||||
@@ -51,69 +51,50 @@ const command = new Command("changelog")
|
|||||||
|
|
||||||
for (const commit of commits) {
|
for (const commit of commits) {
|
||||||
const tag =
|
const tag =
|
||||||
sort((await simpleGit().tags([`--contains=${commit.hash}`])).all)[0]! ||
|
(commit.refs.match(/tag: (\S+)(?:,|$)/)?.[1] ?? lastTag) || unreleased;
|
||||||
unreleased;
|
|
||||||
|
|
||||||
const currentCommitStack = parsedCommitStacks.find(
|
let currentCommitStackIndex = parsedCommitStacks.findIndex(
|
||||||
(commitStack) => commitStack.version === tag,
|
(commitStack) => commitStack.version === tag,
|
||||||
) || {
|
);
|
||||||
|
|
||||||
|
if (currentCommitStackIndex === -1) {
|
||||||
|
parsedCommitStacks.push({
|
||||||
version: tag || unreleased,
|
version: tag || unreleased,
|
||||||
breaking: [],
|
breaking: [],
|
||||||
features: [],
|
features: [],
|
||||||
fixes: [],
|
fixes: [],
|
||||||
miscellaneous: [],
|
miscellaneous: [],
|
||||||
};
|
});
|
||||||
|
|
||||||
if (lastTag !== tag) {
|
currentCommitStackIndex = parsedCommitStacks.findIndex(
|
||||||
parsedCommitStacks = [currentCommitStack, ...parsedCommitStacks];
|
(commitStack) => commitStack.version === tag,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (commit.message.includes("!:")) {
|
if (commit.message.includes("!:")) {
|
||||||
parsedCommitStacks = [
|
parsedCommitStacks[currentCommitStackIndex].breaking.push(commit);
|
||||||
{
|
|
||||||
...currentCommitStack,
|
|
||||||
breaking: [...currentCommitStack.breaking, commit],
|
|
||||||
},
|
|
||||||
...parsedCommitStacks.filter(
|
|
||||||
(commitStack) => commitStack.version !== tag,
|
|
||||||
),
|
|
||||||
];
|
|
||||||
} else if (commit.message.startsWith("feat")) {
|
} else if (commit.message.startsWith("feat")) {
|
||||||
parsedCommitStacks = [
|
parsedCommitStacks[currentCommitStackIndex].features.push(commit);
|
||||||
{
|
|
||||||
...currentCommitStack,
|
|
||||||
features: [...currentCommitStack.features, commit],
|
|
||||||
},
|
|
||||||
...parsedCommitStacks.filter(
|
|
||||||
(commitStack) => commitStack.version !== tag,
|
|
||||||
),
|
|
||||||
];
|
|
||||||
} else if (commit.message.startsWith("fix")) {
|
} else if (commit.message.startsWith("fix")) {
|
||||||
parsedCommitStacks = [
|
parsedCommitStacks[currentCommitStackIndex].fixes.push(commit);
|
||||||
{
|
|
||||||
...currentCommitStack,
|
|
||||||
fixes: [...currentCommitStack.fixes, commit],
|
|
||||||
},
|
|
||||||
...parsedCommitStacks.filter(
|
|
||||||
(commitStack) => commitStack.version !== tag,
|
|
||||||
),
|
|
||||||
];
|
|
||||||
} else {
|
} else {
|
||||||
parsedCommitStacks = [
|
parsedCommitStacks[currentCommitStackIndex].miscellaneous.push(commit);
|
||||||
{
|
|
||||||
...currentCommitStack,
|
|
||||||
miscellaneous: [...currentCommitStack.miscellaneous, commit],
|
|
||||||
},
|
|
||||||
...parsedCommitStacks.filter(
|
|
||||||
(commitStack) => commitStack.version !== tag,
|
|
||||||
),
|
|
||||||
];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
lastTag = tag;
|
lastTag = tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
parsedCommitStacks = parsedCommitStacks.reverse();
|
// Might be confusing so I will leave mdn docs here
|
||||||
|
// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort
|
||||||
|
parsedCommitStacks = parsedCommitStacks.sort((a, b) => {
|
||||||
|
if (a.version === unreleased) {
|
||||||
|
return -1;
|
||||||
|
} else if (b.version === unreleased) {
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
return gt(a.version, b.version) ? -1 : 1;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
if (lastOnly) {
|
if (lastOnly) {
|
||||||
parsedCommitStacks = [parsedCommitStacks[0]];
|
parsedCommitStacks = [parsedCommitStacks[0]];
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import {
|
|||||||
confirm,
|
confirm,
|
||||||
intro,
|
intro,
|
||||||
isCancel,
|
isCancel,
|
||||||
|
multiselect,
|
||||||
note,
|
note,
|
||||||
outro,
|
outro,
|
||||||
select,
|
select,
|
||||||
@@ -31,7 +32,7 @@ import {
|
|||||||
} from "@clack/prompts";
|
} from "@clack/prompts";
|
||||||
import { existsSync } from "fs";
|
import { existsSync } from "fs";
|
||||||
import { join } from "path";
|
import { join } from "path";
|
||||||
import simpleGit from "simple-git";
|
import simpleGit, { ResetMode } from "simple-git";
|
||||||
|
|
||||||
const command = new Command("commit")
|
const command = new Command("commit")
|
||||||
.alias("c")
|
.alias("c")
|
||||||
@@ -69,6 +70,37 @@ const command = new Command("commit")
|
|||||||
process.exit(0);
|
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 {
|
try {
|
||||||
const changedLines = (
|
const changedLines = (
|
||||||
(
|
(
|
||||||
@@ -94,7 +126,7 @@ const command = new Command("commit")
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
note("HEAD hasn't been found, skipping commit line amount check");
|
note("HEAD hasn't been found, skipping commit line sum check");
|
||||||
}
|
}
|
||||||
|
|
||||||
const type: string | symbol = await select({
|
const type: string | symbol = await select({
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ import { join } from "path";
|
|||||||
program
|
program
|
||||||
.name("rcz")
|
.name("rcz")
|
||||||
.description("Resultium commit standardization command-line interface")
|
.description("Resultium commit standardization command-line interface")
|
||||||
.version("1.13.0");
|
.version("1.14.0");
|
||||||
|
|
||||||
const commandFiles = await readdir(join(__dirname, "commands"));
|
const commandFiles = await readdir(join(__dirname, "commands"));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user