7 Commits

6 changed files with 55 additions and 28 deletions

View File

@@ -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`,
); );

View File

@@ -1,7 +1,20 @@
# Changelog # Changelog
Generation of this changelog is based on commits Generation of this changelog is based on commits
## v1.13.1
### Fixes
- [87edf8cfa] - **changelog**: wrong semver sequence generation (#21)
### Miscellaneous
- [47a8b0585] - **commands**: change head error message
- [b6d749bea] - fix version regex to include pre-releases
## v1.13.0
### Fixes
- [7b499d763] - **commands**: commit crash upon missing HEAD (#19)
### Miscellaneous
- [87a7c4dcc] - **release**: v1.13.0
- [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
- [4b0ce0fd3] - **release**: v1.13.0-rc.0
- [778175a2f] - split commands into files (#18) - [778175a2f] - split commands into files (#18)
## v1.12.4 ## v1.12.4
### Fixes ### Fixes

View File

@@ -1,6 +1,6 @@
{ {
"name": "@resultium/rcz", "name": "@resultium/rcz",
"version": "1.13.0-rc.0", "version": "1.13.1",
"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",

View File

@@ -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")
@@ -113,7 +113,17 @@ const command = new Command("changelog")
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]];

View File

@@ -69,6 +69,7 @@ const command = new Command("commit")
process.exit(0); process.exit(0);
} }
try {
const changedLines = ( const changedLines = (
( (
await simpleGit().diff(["--numstat", stageAll ? "HEAD" : "--cached"]) await simpleGit().diff(["--numstat", stageAll ? "HEAD" : "--cached"])
@@ -92,6 +93,9 @@ const command = new Command("commit")
process.exit(0); process.exit(0);
} }
} }
} catch {
note("HEAD hasn't been found, skipping commit line sum check");
}
const type: string | symbol = await select({ const type: string | symbol = await select({
message: "Choose a commit type", message: "Choose a commit type",

View File

@@ -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-rc.0"); .version("1.13.1");
const commandFiles = await readdir(join(__dirname, "commands")); const commandFiles = await readdir(join(__dirname, "commands"));