@releasekit/version 0.7.32 → 0.7.45

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -531,14 +531,14 @@ function enableJsonOutput(dryRun = false) {
531
531
  _jsonData.commitMessage = void 0;
532
532
  _pendingWrites.length = 0;
533
533
  }
534
- function recordPendingWrite(path10, content) {
534
+ function recordPendingWrite(path11, content) {
535
535
  if (!_jsonOutputMode) return;
536
- _pendingWrites.push({ path: path10, content });
536
+ _pendingWrites.push({ path: path11, content });
537
537
  }
538
538
  function flushPendingWrites() {
539
539
  try {
540
- for (const { path: path10, content } of _pendingWrites) {
541
- fs4.writeFileSync(path10, content);
540
+ for (const { path: path11, content } of _pendingWrites) {
541
+ fs4.writeFileSync(path11, content);
542
542
  }
543
543
  } finally {
544
544
  _pendingWrites.length = 0;
@@ -582,8 +582,686 @@ function printJsonOutput() {
582
582
 
583
583
  // src/core/versionCalculator.ts
584
584
  import { cwd } from "process";
585
- import { Bumper } from "conventional-recommended-bump";
586
- import semver3 from "semver";
585
+
586
+ // ../../node_modules/.pnpm/@conventional-changelog+git-client@2.5.1_conventional-commits-filter@5.0.0_conventional-commits-parser@6.2.1/node_modules/@conventional-changelog/git-client/dist/utils.js
587
+ function formatArgs(...args) {
588
+ return args.reduce((finalArgs, arg) => {
589
+ if (arg) {
590
+ finalArgs.push(String(arg));
591
+ }
592
+ return finalArgs;
593
+ }, []);
594
+ }
595
+ function toArray(value) {
596
+ return Array.isArray(value) ? value : [value];
597
+ }
598
+
599
+ // ../../node_modules/.pnpm/@conventional-changelog+git-client@2.5.1_conventional-commits-filter@5.0.0_conventional-commits-parser@6.2.1/node_modules/@conventional-changelog/git-client/dist/GitClient.js
600
+ import { spawn } from "child_process";
601
+
602
+ // ../../node_modules/.pnpm/@simple-libs+stream-utils@1.1.0/node_modules/@simple-libs/stream-utils/dist/index.js
603
+ import { Readable } from "stream";
604
+ async function toArray2(iterable) {
605
+ const result = [];
606
+ for await (const item of iterable) {
607
+ result.push(item);
608
+ }
609
+ return result;
610
+ }
611
+ async function concatBufferStream(iterable) {
612
+ return Buffer.concat(await toArray2(iterable));
613
+ }
614
+ async function firstFromStream(stream) {
615
+ for await (const tag of stream) {
616
+ return tag;
617
+ }
618
+ return null;
619
+ }
620
+ async function* splitStream(stream, separator) {
621
+ let chunk;
622
+ let payload;
623
+ let buffer = "";
624
+ for await (chunk of stream) {
625
+ buffer += chunk.toString();
626
+ if (buffer.includes(separator)) {
627
+ payload = buffer.split(separator);
628
+ buffer = payload.pop() || "";
629
+ yield* payload;
630
+ }
631
+ }
632
+ if (buffer) {
633
+ yield buffer;
634
+ }
635
+ }
636
+
637
+ // ../../node_modules/.pnpm/@simple-libs+child-process-utils@1.0.1/node_modules/@simple-libs/child-process-utils/dist/index.js
638
+ async function exitCode(process2) {
639
+ if (process2.exitCode !== null) {
640
+ return process2.exitCode;
641
+ }
642
+ return new Promise((resolve2) => process2.once("close", resolve2));
643
+ }
644
+ async function catchProcessError(process2) {
645
+ let error = new Error("Process exited with non-zero code");
646
+ let stderr = "";
647
+ process2.on("error", (err) => {
648
+ error = err;
649
+ });
650
+ if (process2.stderr) {
651
+ let chunk;
652
+ for await (chunk of process2.stderr) {
653
+ stderr += chunk.toString();
654
+ }
655
+ }
656
+ const code = await exitCode(process2);
657
+ if (stderr) {
658
+ error = new Error(stderr);
659
+ }
660
+ return code ? error : null;
661
+ }
662
+ async function* outputStream(process2) {
663
+ const { stdout } = process2;
664
+ const errorPromise = catchProcessError(process2);
665
+ if (stdout) {
666
+ stdout.on("error", (err) => {
667
+ if (err.name === "AbortError" && process2.exitCode === null) {
668
+ process2.kill("SIGKILL");
669
+ }
670
+ });
671
+ yield* stdout;
672
+ }
673
+ const error = await errorPromise;
674
+ if (error) {
675
+ throw error;
676
+ }
677
+ }
678
+ function output(process2) {
679
+ return concatBufferStream(outputStream(process2));
680
+ }
681
+
682
+ // ../../node_modules/.pnpm/@conventional-changelog+git-client@2.5.1_conventional-commits-filter@5.0.0_conventional-commits-parser@6.2.1/node_modules/@conventional-changelog/git-client/dist/GitClient.js
683
+ var SCISSOR = "------------------------ >8 ------------------------";
684
+ var GitClient = class {
685
+ cwd;
686
+ debug;
687
+ constructor(cwd3, debug) {
688
+ this.cwd = cwd3;
689
+ this.debug = debug;
690
+ }
691
+ formatArgs(...args) {
692
+ const finalArgs = formatArgs(...args);
693
+ if (this.debug) {
694
+ this.debug(finalArgs);
695
+ }
696
+ return finalArgs;
697
+ }
698
+ /**
699
+ * Raw exec method to run git commands.
700
+ * @param args
701
+ * @returns Stdout string output of the command.
702
+ */
703
+ async exec(...args) {
704
+ return (await output(spawn("git", this.formatArgs(...args), {
705
+ cwd: this.cwd
706
+ }))).toString().trim();
707
+ }
708
+ /**
709
+ * Raw exec method to run git commands with stream output.
710
+ * @param args
711
+ * @returns Stdout stream of the command.
712
+ */
713
+ execStream(...args) {
714
+ return outputStream(spawn("git", this.formatArgs(...args), {
715
+ cwd: this.cwd
716
+ }));
717
+ }
718
+ /**
719
+ * Initialize a new git repository.
720
+ * @returns Boolean result.
721
+ */
722
+ async init() {
723
+ try {
724
+ await this.exec("init");
725
+ return true;
726
+ } catch (err) {
727
+ return false;
728
+ }
729
+ }
730
+ /**
731
+ * Get raw commits stream.
732
+ * @param params
733
+ * @param params.path - Read commits from specific path.
734
+ * @param params.from - Start commits range.
735
+ * @param params.to - End commits range.
736
+ * @param params.format - Commits format.
737
+ * @yields Raw commits data.
738
+ */
739
+ async *getRawCommits(params = {}) {
740
+ const { path: path11, from = "", to = "HEAD", format = "%B", ignore, reverse, merges, since } = params;
741
+ const shouldNotIgnore = ignore ? (chunk2) => !ignore.test(chunk2) : () => true;
742
+ const stdout = this.execStream("log", `--format=${format}%n${SCISSOR}`, since && `--since=${since instanceof Date ? since.toISOString() : since}`, reverse && "--reverse", merges && "--merges", merges === false && "--no-merges", [from, to].filter(Boolean).join(".."), ...path11 ? ["--", ...toArray(path11)] : []);
743
+ const commitsStream = splitStream(stdout, `${SCISSOR}
744
+ `);
745
+ let chunk;
746
+ for await (chunk of commitsStream) {
747
+ if (shouldNotIgnore(chunk)) {
748
+ yield chunk;
749
+ }
750
+ }
751
+ }
752
+ /**
753
+ * Get tags stream.
754
+ * @param params
755
+ * @yields Tags
756
+ */
757
+ async *getTags(params = {}) {
758
+ const { path: path11, from = "", to = "HEAD", since } = params;
759
+ const tagRegex = /tag:\s*(.+?)[,)]/gi;
760
+ const stdout = this.execStream("log", "--decorate", "--no-color", "--date-order", since && `--since=${since instanceof Date ? since.toISOString() : since}`, [from, to].filter(Boolean).join(".."), ...path11 ? ["--", ...toArray(path11)] : []);
761
+ let chunk;
762
+ let matches;
763
+ let tag;
764
+ for await (chunk of stdout) {
765
+ matches = chunk.toString().trim().matchAll(tagRegex);
766
+ for ([, tag] of matches) {
767
+ yield tag;
768
+ }
769
+ }
770
+ }
771
+ /**
772
+ * Get last tag.
773
+ * @param params
774
+ * @returns Last tag, `null` if not found.
775
+ */
776
+ async getLastTag(params) {
777
+ return firstFromStream(this.getTags(params));
778
+ }
779
+ /**
780
+ * Check file is ignored via .gitignore.
781
+ * @param file - Path to target file.
782
+ * @returns Boolean value.
783
+ */
784
+ async checkIgnore(file) {
785
+ try {
786
+ await this.exec("check-ignore", "--", file);
787
+ return true;
788
+ } catch (err) {
789
+ return false;
790
+ }
791
+ }
792
+ /**
793
+ * Add files to git index.
794
+ * @param files - Files to stage.
795
+ */
796
+ async add(files) {
797
+ await this.exec("add", "--", ...toArray(files));
798
+ }
799
+ /**
800
+ * Commit changes.
801
+ * @param params
802
+ * @param params.verify
803
+ * @param params.sign
804
+ * @param params.files
805
+ * @param params.allowEmpty
806
+ * @param params.message
807
+ */
808
+ async commit(params) {
809
+ const { verify = true, sign = false, files = [], allowEmpty = false, message } = params;
810
+ await this.exec("commit", !verify && "--no-verify", sign && "-S", allowEmpty && "--allow-empty", "-m", message, "--", ...files);
811
+ }
812
+ /**
813
+ * Create a tag for the current commit.
814
+ * @param params
815
+ * @param params.sign
816
+ * @param params.name
817
+ * @param params.message
818
+ */
819
+ async tag(params) {
820
+ let { sign = false, name, message } = params;
821
+ if (sign) {
822
+ message = "";
823
+ }
824
+ await this.exec("tag", sign && "-s", message && "-a", ...message ? ["-m", message] : [], "--", name);
825
+ }
826
+ /**
827
+ * Get current branch name.
828
+ * @returns Current branch name.
829
+ */
830
+ async getCurrentBranch() {
831
+ const branch = await this.exec("rev-parse", "--abbrev-ref", "HEAD");
832
+ return branch;
833
+ }
834
+ /**
835
+ * Get default branch name.
836
+ * @returns Default branch name.
837
+ */
838
+ async getDefaultBranch() {
839
+ const branch = (await this.exec("rev-parse", "--abbrev-ref", "origin/HEAD")).replace(/^origin\//, "");
840
+ return branch;
841
+ }
842
+ /**
843
+ * Push changes to remote.
844
+ * @param branch
845
+ * @param params
846
+ * @param params.verify
847
+ */
848
+ async push(branch, params = {}) {
849
+ const { verify = true, tags = false, followTags = false, force = false } = params;
850
+ await this.exec("push", followTags && "--follow-tags", tags && "--tags", !verify && "--no-verify", force && "--force", "origin", "--", branch);
851
+ }
852
+ /**
853
+ * Verify rev exists.
854
+ * @param rev
855
+ * @param safe - If `true`, will not throw error if rev not found.
856
+ * @returns Target hash.
857
+ */
858
+ async verify(rev, safe) {
859
+ let git = this.exec("rev-parse", "--verify", rev);
860
+ if (safe) {
861
+ git = git.catch(() => "");
862
+ }
863
+ return await git;
864
+ }
865
+ /**
866
+ * Get config value by key.
867
+ * @param key - Config key.
868
+ * @returns Config value.
869
+ */
870
+ async getConfig(key) {
871
+ return await this.exec("config", "--get", "--", key);
872
+ }
873
+ /**
874
+ * Set config value by key.
875
+ * @param key - Config key.
876
+ * @param value - Config value.
877
+ */
878
+ async setConfig(key, value) {
879
+ await this.exec("config", "--", key, value);
880
+ }
881
+ /**
882
+ * Fetch changes from remote.
883
+ * @param params
884
+ */
885
+ async fetch(params = {}) {
886
+ const { prune = false, unshallow = false, tags = false, all = false, remote, branch } = params;
887
+ await this.exec("fetch", prune && "--prune", unshallow && "--unshallow", tags && "--tags", all && "--all", ...remote && branch ? [
888
+ "--",
889
+ remote,
890
+ branch
891
+ ] : []);
892
+ }
893
+ /**
894
+ * Create a new branch.
895
+ * @param branch - Branch name.
896
+ */
897
+ async createBranch(branch) {
898
+ await this.exec("checkout", "-b", branch);
899
+ }
900
+ /**
901
+ * Delete a branch.
902
+ * @param branch - Branch name.
903
+ */
904
+ async deleteBranch(branch) {
905
+ await this.exec("branch", "-D", "--", branch);
906
+ }
907
+ /**
908
+ * Checkout a branch.
909
+ * @param branch - Branch name.
910
+ */
911
+ async checkout(branch) {
912
+ await this.exec("checkout", branch);
913
+ }
914
+ };
915
+
916
+ // ../../node_modules/.pnpm/@conventional-changelog+git-client@2.5.1_conventional-commits-filter@5.0.0_conventional-commits-parser@6.2.1/node_modules/@conventional-changelog/git-client/dist/ConventionalGitClient.js
917
+ import semver from "semver";
918
+ var ConventionalGitClient = class extends GitClient {
919
+ deps = null;
920
+ loadDeps() {
921
+ if (this.deps) {
922
+ return this.deps;
923
+ }
924
+ this.deps = Promise.all([
925
+ import("./dist-3B6ZXCEH.js").then(({ parseCommits }) => parseCommits),
926
+ import("./dist-XFQOB6BJ.js").then(({ filterRevertedCommits }) => filterRevertedCommits)
927
+ ]);
928
+ return this.deps;
929
+ }
930
+ /**
931
+ * Get parsed commits stream.
932
+ * @param params
933
+ * @param params.path - Read commits from specific path.
934
+ * @param params.from - Start commits range.
935
+ * @param params.to - End commits range.
936
+ * @param params.format - Commits format.
937
+ * @param parserOptions - Commit parser options.
938
+ * @yields Raw commits data.
939
+ */
940
+ async *getCommits(params = {}, parserOptions = {}) {
941
+ const { filterReverts, ...gitLogParams } = params;
942
+ const [parseCommits, filterRevertedCommits] = await this.loadDeps();
943
+ if (filterReverts) {
944
+ yield* filterRevertedCommits(this.getCommits(gitLogParams, parserOptions));
945
+ return;
946
+ }
947
+ const parse2 = parseCommits(parserOptions);
948
+ const commitsStream = this.getRawCommits(gitLogParams);
949
+ yield* parse2(commitsStream);
950
+ }
951
+ /**
952
+ * Get semver tags stream.
953
+ * @param params
954
+ * @param params.prefix - Get semver tags with specific prefix.
955
+ * @param params.skipUnstable - Skip semver tags with unstable versions.
956
+ * @param params.clean - Clean version from prefix and trash.
957
+ * @yields Semver tags.
958
+ */
959
+ async *getSemverTags(params = {}) {
960
+ const { prefix, skipUnstable, clean } = params;
961
+ const tagsStream = this.getTags();
962
+ const unstableTagRegex = /\d+\.\d+\.\d+-.+/;
963
+ const cleanTag = clean ? (tag2, unprefixed2) => semver.clean(unprefixed2 || tag2) : (tag2) => tag2;
964
+ let unprefixed;
965
+ let tag;
966
+ for await (tag of tagsStream) {
967
+ if (skipUnstable && unstableTagRegex.test(tag)) {
968
+ continue;
969
+ }
970
+ if (prefix) {
971
+ const isPrefixed = typeof prefix === "string" ? tag.startsWith(prefix) : prefix.test(tag);
972
+ if (isPrefixed) {
973
+ unprefixed = tag.replace(prefix, "");
974
+ if (semver.valid(unprefixed)) {
975
+ tag = cleanTag(tag, unprefixed);
976
+ if (tag) {
977
+ yield tag;
978
+ }
979
+ }
980
+ }
981
+ } else if (semver.valid(tag)) {
982
+ tag = cleanTag(tag);
983
+ if (tag) {
984
+ yield tag;
985
+ }
986
+ }
987
+ }
988
+ }
989
+ /**
990
+ * Get last semver tag.
991
+ * @param params - getSemverTags params.
992
+ * @returns Last semver tag, `null` if not found.
993
+ */
994
+ async getLastSemverTag(params = {}) {
995
+ return firstFromStream(this.getSemverTags(params));
996
+ }
997
+ /**
998
+ * Get current sematic version from git tags.
999
+ * @param params - Additional git params.
1000
+ * @returns Current sematic version, `null` if not found.
1001
+ */
1002
+ async getVersionFromTags(params = {}) {
1003
+ const semverTagsStream = this.getSemverTags({
1004
+ clean: true,
1005
+ ...params
1006
+ });
1007
+ const semverTags = [];
1008
+ for await (const tag of semverTagsStream) {
1009
+ semverTags.push(tag);
1010
+ }
1011
+ if (!semverTags.length) {
1012
+ return null;
1013
+ }
1014
+ return semverTags.sort(semver.rcompare)[0] || null;
1015
+ }
1016
+ };
1017
+
1018
+ // ../../node_modules/.pnpm/conventional-changelog-preset-loader@5.0.0/node_modules/conventional-changelog-preset-loader/dist/presetLoader.js
1019
+ import path4 from "path";
1020
+ function resolvePresetNameVariants(preset) {
1021
+ if (path4.isAbsolute(preset)) {
1022
+ return [preset];
1023
+ }
1024
+ let scope = "";
1025
+ let name = preset.toLocaleLowerCase();
1026
+ if (preset.startsWith("@")) {
1027
+ const parts = preset.split("/");
1028
+ scope = `${parts.shift()}/`;
1029
+ if (scope === "@conventional-changelog/") {
1030
+ return [preset];
1031
+ }
1032
+ name = parts.join("/");
1033
+ }
1034
+ if (!name.startsWith("conventional-changelog-")) {
1035
+ name = `conventional-changelog-${name}`;
1036
+ }
1037
+ const altPreset = `${scope}${name}`;
1038
+ if (altPreset !== preset) {
1039
+ return [altPreset, preset];
1040
+ }
1041
+ return [preset];
1042
+ }
1043
+ function getModuleDefaultExport(module) {
1044
+ if (("__esModule" in module || Object.getPrototypeOf(module) === null) && "default" in module) {
1045
+ return module.default;
1046
+ }
1047
+ return module;
1048
+ }
1049
+ async function loadWithFallbacks(moduleLoader, variants) {
1050
+ let error = null;
1051
+ for (const variant of variants) {
1052
+ try {
1053
+ return getModuleDefaultExport(await moduleLoader(variant));
1054
+ } catch (err) {
1055
+ if (!error) {
1056
+ error = err;
1057
+ }
1058
+ }
1059
+ }
1060
+ throw error;
1061
+ }
1062
+ function createPresetLoader(moduleLoader) {
1063
+ return async function loadPreset2(presetOrParams) {
1064
+ let preset = "";
1065
+ let params = null;
1066
+ if (typeof presetOrParams === "string") {
1067
+ preset = presetOrParams;
1068
+ } else if (typeof presetOrParams === "object" && typeof presetOrParams.name === "string") {
1069
+ preset = presetOrParams.name;
1070
+ params = presetOrParams;
1071
+ } else {
1072
+ throw Error("Preset must be string or object with property `name`");
1073
+ }
1074
+ const presetNameVariants = resolvePresetNameVariants(preset);
1075
+ let createPreset = null;
1076
+ try {
1077
+ createPreset = await loadWithFallbacks(moduleLoader, presetNameVariants);
1078
+ } catch (err) {
1079
+ throw new Error(`Unable to load the "${preset}" preset. Please make sure it's installed.`, {
1080
+ cause: err
1081
+ });
1082
+ }
1083
+ if (typeof createPreset !== "function") {
1084
+ throw new Error(`The "${preset}" preset does not export a function. Maybe you are using an old version of the preset. Please upgrade.`);
1085
+ }
1086
+ return params ? await createPreset(params) : await createPreset();
1087
+ };
1088
+ }
1089
+ var loadPreset = createPresetLoader((preset) => import(preset));
1090
+
1091
+ // ../../node_modules/.pnpm/conventional-recommended-bump@11.2.0/node_modules/conventional-recommended-bump/dist/utils.js
1092
+ function isIterable(value) {
1093
+ return value !== null && (typeof value[Symbol.iterator] === "function" || typeof value[Symbol.asyncIterator] === "function");
1094
+ }
1095
+ function bindLogNamespace(namespace, logger) {
1096
+ return (messages) => logger(namespace, messages);
1097
+ }
1098
+
1099
+ // ../../node_modules/.pnpm/conventional-recommended-bump@11.2.0/node_modules/conventional-recommended-bump/dist/bumper.js
1100
+ var VERSIONS = [
1101
+ "major",
1102
+ "minor",
1103
+ "patch"
1104
+ ];
1105
+ var Bumper = class {
1106
+ gitClient;
1107
+ params;
1108
+ whatBump;
1109
+ tagGetter;
1110
+ commitsGetter;
1111
+ constructor(cwdOrGitClient = process.cwd()) {
1112
+ this.gitClient = typeof cwdOrGitClient === "string" ? new ConventionalGitClient(cwdOrGitClient) : cwdOrGitClient;
1113
+ this.whatBump = null;
1114
+ this.params = Promise.resolve({
1115
+ commits: {
1116
+ format: "%B%n-hash-%n%H",
1117
+ filterReverts: true
1118
+ }
1119
+ });
1120
+ this.tagGetter = () => this.getLastSemverTag();
1121
+ this.commitsGetter = () => this.getCommits();
1122
+ }
1123
+ composeParams(params) {
1124
+ this.params = Promise.all([params, this.params]).then(([params2, prevParams]) => ({
1125
+ options: {
1126
+ ...prevParams.options,
1127
+ ...params2.options
1128
+ },
1129
+ tags: {
1130
+ ...prevParams.tags,
1131
+ ...params2.tags
1132
+ },
1133
+ commits: {
1134
+ ...prevParams.commits,
1135
+ ...params2.commits
1136
+ },
1137
+ parser: {
1138
+ ...prevParams.parser,
1139
+ ...params2.parser
1140
+ }
1141
+ }));
1142
+ }
1143
+ async getLastSemverTag() {
1144
+ const { tags } = await this.params;
1145
+ return await this.gitClient.getLastSemverTag(tags);
1146
+ }
1147
+ async *getCommits() {
1148
+ const { options, commits, parser } = await this.params;
1149
+ const parserParams = {
1150
+ ...parser
1151
+ };
1152
+ if (!parserParams.warn && options?.warn) {
1153
+ parserParams.warn = bindLogNamespace("parser", options.warn);
1154
+ }
1155
+ yield* this.gitClient.getCommits({
1156
+ from: await this.tagGetter() || "",
1157
+ ...commits
1158
+ }, parserParams);
1159
+ }
1160
+ /**
1161
+ * Load configs from a preset
1162
+ * @param preset
1163
+ * @param loader - Preset module loader, if not provided, will use default loader
1164
+ * @returns this
1165
+ */
1166
+ loadPreset(preset, loader) {
1167
+ const loadPreset2 = loader ? createPresetLoader(loader) : loadPreset;
1168
+ const config = loadPreset2(preset).then((config2) => {
1169
+ if (!config2) {
1170
+ throw Error("Preset is not loaded or have incorrect exports");
1171
+ }
1172
+ return config2;
1173
+ });
1174
+ this.whatBump = async (commits) => {
1175
+ const { whatBump } = await config;
1176
+ return whatBump(commits);
1177
+ };
1178
+ this.composeParams(config);
1179
+ return this;
1180
+ }
1181
+ /**
1182
+ * Set config directly
1183
+ * @param config - Config object
1184
+ * @returns this
1185
+ */
1186
+ config(config) {
1187
+ this.composeParams(config);
1188
+ return this;
1189
+ }
1190
+ /**
1191
+ * Set bumper options
1192
+ * @param options - Bumper options
1193
+ * @returns this
1194
+ */
1195
+ options(options) {
1196
+ this.composeParams({
1197
+ options
1198
+ });
1199
+ return this;
1200
+ }
1201
+ /**
1202
+ * Set params to get the last semver tag
1203
+ * @param paramsOrTag - Params to get the last semver tag or a tag name
1204
+ * @returns this
1205
+ */
1206
+ tag(paramsOrTag) {
1207
+ if (typeof paramsOrTag === "string") {
1208
+ this.tagGetter = () => paramsOrTag;
1209
+ } else {
1210
+ this.tagGetter = () => this.getLastSemverTag();
1211
+ this.composeParams({
1212
+ tags: paramsOrTag
1213
+ });
1214
+ }
1215
+ return this;
1216
+ }
1217
+ commits(paramsOrCommits, parserOptions) {
1218
+ if (isIterable(paramsOrCommits)) {
1219
+ this.commitsGetter = () => paramsOrCommits;
1220
+ } else {
1221
+ this.commitsGetter = () => this.getCommits();
1222
+ this.composeParams({
1223
+ commits: paramsOrCommits,
1224
+ parser: parserOptions
1225
+ });
1226
+ }
1227
+ return this;
1228
+ }
1229
+ /**
1230
+ * Recommend a bump by `whatBump` function
1231
+ * @param whatBump - Function to recommend a bump from commits
1232
+ * @returns Bump recommendation
1233
+ */
1234
+ async bump(whatBump = this.whatBump) {
1235
+ if (typeof whatBump !== "function") {
1236
+ throw Error("`whatBump` must be a function");
1237
+ }
1238
+ const { gitClient } = this;
1239
+ const { options } = await this.params;
1240
+ if (!gitClient.debug && options?.debug) {
1241
+ gitClient.debug = bindLogNamespace("git-client", options.debug);
1242
+ }
1243
+ const commitsStream = this.commitsGetter();
1244
+ const commits = [];
1245
+ let commit;
1246
+ for await (commit of commitsStream) {
1247
+ commits.push(commit);
1248
+ }
1249
+ const result = await whatBump(commits);
1250
+ if (result && "level" in result) {
1251
+ return {
1252
+ ...result,
1253
+ releaseType: VERSIONS[result.level],
1254
+ commits
1255
+ };
1256
+ }
1257
+ return {
1258
+ commits
1259
+ };
1260
+ }
1261
+ };
1262
+
1263
+ // src/core/versionCalculator.ts
1264
+ import semver4 from "semver";
587
1265
 
588
1266
  // src/git/repository.ts
589
1267
  import { existsSync as existsSync3, statSync } from "fs";
@@ -595,7 +1273,7 @@ function getCurrentBranch() {
595
1273
 
596
1274
  // src/git/tagsAndBranches.ts
597
1275
  import { getSemverTags } from "git-semver-tags";
598
- import semver from "semver";
1276
+ import semver2 from "semver";
599
1277
 
600
1278
  // src/utils/logging.ts
601
1279
  import chalk from "chalk";
@@ -713,9 +1391,9 @@ async function getLatestTag(versionPrefix) {
713
1391
  }
714
1392
  const chronologicalLatest = tags[0];
715
1393
  const sortedTags = [...tags].sort((a, b) => {
716
- const versionA = semver.clean(a) || "0.0.0";
717
- const versionB = semver.clean(b) || "0.0.0";
718
- return semver.rcompare(versionA, versionB);
1394
+ const versionA = semver2.clean(a) || "0.0.0";
1395
+ const versionB = semver2.clean(b) || "0.0.0";
1396
+ return semver2.rcompare(versionA, versionB);
719
1397
  });
720
1398
  const semanticLatest = sortedTags[0];
721
1399
  if (semanticLatest !== chronologicalLatest) {
@@ -807,11 +1485,11 @@ async function getLatestTagForPackage(packageName, versionPrefix, options) {
807
1485
 
808
1486
  // src/utils/manifestHelpers.ts
809
1487
  import fs6 from "fs";
810
- import path5 from "path";
1488
+ import path6 from "path";
811
1489
 
812
1490
  // src/cargo/cargoHandler.ts
813
1491
  import fs5 from "fs";
814
- import path4 from "path";
1492
+ import path5 from "path";
815
1493
  import * as TOML2 from "smol-toml";
816
1494
  function getCargoInfo(cargoPath) {
817
1495
  if (!fs5.existsSync(cargoPath)) {
@@ -828,7 +1506,7 @@ function getCargoInfo(cargoPath) {
828
1506
  name: cargo.package.name,
829
1507
  version: cargo.package.version || "0.0.0",
830
1508
  path: cargoPath,
831
- dir: path4.dirname(cargoPath),
1509
+ dir: path5.dirname(cargoPath),
832
1510
  content: cargo
833
1511
  };
834
1512
  } catch (error) {
@@ -871,8 +1549,8 @@ function updateCargoVersion(cargoPath, version, dryRun = false) {
871
1549
 
872
1550
  // src/utils/manifestHelpers.ts
873
1551
  function getVersionFromManifests(packageDir) {
874
- const packageJsonPath = path5.join(packageDir, "package.json");
875
- const cargoTomlPath = path5.join(packageDir, "Cargo.toml");
1552
+ const packageJsonPath = path6.join(packageDir, "package.json");
1553
+ const cargoTomlPath = path6.join(packageDir, "Cargo.toml");
876
1554
  if (fs6.existsSync(packageJsonPath)) {
877
1555
  try {
878
1556
  const packageJson = JSON.parse(fs6.readFileSync(packageJsonPath, "utf-8"));
@@ -919,7 +1597,7 @@ function getVersionFromManifests(packageDir) {
919
1597
 
920
1598
  // src/utils/versionUtils.ts
921
1599
  import fs7 from "fs";
922
- import semver2 from "semver";
1600
+ import semver3 from "semver";
923
1601
 
924
1602
  // src/git/tagVerification.ts
925
1603
  function verifyTag(tagName, cwd3) {
@@ -961,33 +1639,33 @@ function normalizePrereleaseIdentifier(prereleaseIdentifier, config) {
961
1639
  return void 0;
962
1640
  }
963
1641
  function bumpVersion(currentVersion, bumpType, prereleaseIdentifier) {
964
- if (prereleaseIdentifier && STANDARD_BUMP_TYPES.includes(bumpType) && !semver2.prerelease(currentVersion)) {
1642
+ if (prereleaseIdentifier && STANDARD_BUMP_TYPES.includes(bumpType) && !semver3.prerelease(currentVersion)) {
965
1643
  const preBumpType = `pre${bumpType}`;
966
1644
  log(`Creating prerelease version with identifier '${prereleaseIdentifier}' using ${preBumpType}`, "debug");
967
- return semver2.inc(currentVersion, preBumpType, prereleaseIdentifier) || "";
1645
+ return semver3.inc(currentVersion, preBumpType, prereleaseIdentifier) || "";
968
1646
  }
969
- if (semver2.prerelease(currentVersion) && STANDARD_BUMP_TYPES.includes(bumpType)) {
970
- const parsed = semver2.parse(currentVersion);
1647
+ if (semver3.prerelease(currentVersion) && STANDARD_BUMP_TYPES.includes(bumpType)) {
1648
+ const parsed = semver3.parse(currentVersion);
971
1649
  if (!parsed) {
972
- return semver2.inc(currentVersion, bumpType) || "";
1650
+ return semver3.inc(currentVersion, bumpType) || "";
973
1651
  }
974
1652
  if (bumpType === "major" && parsed.minor === 0 && parsed.patch === 0 || bumpType === "minor" && parsed.patch === 0 || bumpType === "patch") {
975
1653
  log(`Cleaning prerelease identifier from ${currentVersion} for ${bumpType} bump`, "debug");
976
1654
  return `${parsed.major}.${parsed.minor}.${parsed.patch}`;
977
1655
  }
978
1656
  log(`Standard increment for ${currentVersion} with ${bumpType} bump`, "debug");
979
- return semver2.inc(currentVersion, bumpType) || "";
1657
+ return semver3.inc(currentVersion, bumpType) || "";
980
1658
  }
981
1659
  if (prereleaseIdentifier) {
982
- return semver2.inc(currentVersion, bumpType, prereleaseIdentifier) || "";
1660
+ return semver3.inc(currentVersion, bumpType, prereleaseIdentifier) || "";
983
1661
  }
984
- return semver2.inc(currentVersion, bumpType) || "";
1662
+ return semver3.inc(currentVersion, bumpType) || "";
985
1663
  }
986
1664
  function detectVersionMismatch(tagVersion, packageVersion) {
987
- const tagIsPrerelease = semver2.prerelease(tagVersion) !== null;
988
- const packageIsPrerelease = semver2.prerelease(packageVersion) !== null;
989
- const tagParsed = semver2.parse(tagVersion);
990
- const packageParsed = semver2.parse(packageVersion);
1665
+ const tagIsPrerelease = semver3.prerelease(tagVersion) !== null;
1666
+ const packageIsPrerelease = semver3.prerelease(packageVersion) !== null;
1667
+ const tagParsed = semver3.parse(tagVersion);
1668
+ const packageParsed = semver3.parse(packageVersion);
991
1669
  if (!tagParsed || !packageParsed) {
992
1670
  return { isMismatch: false, severity: "minor", message: "" };
993
1671
  }
@@ -998,9 +1676,9 @@ function detectVersionMismatch(tagVersion, packageVersion) {
998
1676
  message: `Git tag ${tagVersion} (stable) is ahead of package ${packageVersion} (prerelease). This may indicate a reverted release. Consider deleting tag ${tagVersion} or updating package.json.`
999
1677
  };
1000
1678
  }
1001
- const tagHigher = semver2.gt(tagVersion, packageVersion);
1679
+ const tagHigher = semver3.gt(tagVersion, packageVersion);
1002
1680
  if (tagHigher) {
1003
- const diff = semver2.diff(packageVersion, tagVersion);
1681
+ const diff = semver3.diff(packageVersion, tagVersion);
1004
1682
  if (diff === "major" || diff === "minor") {
1005
1683
  return {
1006
1684
  isMismatch: true,
@@ -1099,7 +1777,7 @@ To resolve: delete the conflicting tag, update package.json, or change mismatchS
1099
1777
  };
1100
1778
  }
1101
1779
  }
1102
- if (semver2.gt(cleanPackageVersion, cleanTagVersion)) {
1780
+ if (semver3.gt(cleanPackageVersion, cleanTagVersion)) {
1103
1781
  log(`Package version ${packageVersion} is newer than git tag ${tagName}, using package version`, "info");
1104
1782
  return {
1105
1783
  source: "package",
@@ -1108,7 +1786,7 @@ To resolve: delete the conflicting tag, update package.json, or change mismatchS
1108
1786
  mismatch: mismatchInfo
1109
1787
  };
1110
1788
  }
1111
- if (semver2.gt(cleanTagVersion, cleanPackageVersion)) {
1789
+ if (semver3.gt(cleanTagVersion, cleanPackageVersion)) {
1112
1790
  log(`Git tag ${tagName} is newer than package version ${packageVersion}, using git tag`, "info");
1113
1791
  return {
1114
1792
  source: "git",
@@ -1169,12 +1847,12 @@ async function calculateVersion(config, options) {
1169
1847
  if (hasNoTags) {
1170
1848
  return initialVersion;
1171
1849
  }
1172
- const cleanedTag = semver3.clean(latestTag) || latestTag;
1173
- return semver3.clean(cleanedTag.replace(new RegExp(`^${escapedTagPattern}`), "")) || "0.0.0";
1850
+ const cleanedTag = semver4.clean(latestTag) || latestTag;
1851
+ return semver4.clean(cleanedTag.replace(new RegExp(`^${escapedTagPattern}`), "")) || "0.0.0";
1174
1852
  }
1175
1853
  if (versionSource.source === "git") {
1176
- const cleanedTag = semver3.clean(versionSource.version) || versionSource.version;
1177
- return semver3.clean(cleanedTag.replace(new RegExp(`^${escapedTagPattern}`), "")) || "0.0.0";
1854
+ const cleanedTag = semver4.clean(versionSource.version) || versionSource.version;
1855
+ return semver4.clean(cleanedTag.replace(new RegExp(`^${escapedTagPattern}`), "")) || "0.0.0";
1178
1856
  }
1179
1857
  return versionSource.version;
1180
1858
  };
@@ -1198,7 +1876,7 @@ async function calculateVersion(config, options) {
1198
1876
  const specifiedType = type;
1199
1877
  if (specifiedType) {
1200
1878
  const currentVersion = getCurrentVersionFromSource2();
1201
- const isCurrentPrerelease = semver3.prerelease(currentVersion);
1879
+ const isCurrentPrerelease = semver4.prerelease(currentVersion);
1202
1880
  const explicitlyRequestedPrerelease = config.isPrerelease;
1203
1881
  if (STANDARD_BUMP_TYPES.includes(specifiedType) && (isCurrentPrerelease || explicitlyRequestedPrerelease)) {
1204
1882
  const prereleaseId2 = explicitlyRequestedPrerelease || isCurrentPrerelease ? normalizedPrereleaseId : void 0;
@@ -1294,7 +1972,7 @@ async function calculateVersion(config, options) {
1294
1972
 
1295
1973
  // src/package/packageProcessor.ts
1296
1974
  import * as fs9 from "fs";
1297
- import path7 from "path";
1975
+ import path8 from "path";
1298
1976
 
1299
1977
  // src/changelog/commitParser.ts
1300
1978
  var CONVENTIONAL_COMMIT_REGEX = /^(\w+)(?:\(([^)]+)\))?(!)?: (.+)(?:\n\n([\s\S]*))?/;
@@ -1302,8 +1980,8 @@ var BREAKING_CHANGE_REGEX = /BREAKING CHANGE: ([\s\S]+?)(?:\n\n|$)/;
1302
1980
  function extractAllChangelogEntriesWithHash(projectDir, revisionRange) {
1303
1981
  try {
1304
1982
  const args = ["log", revisionRange, "--pretty=format:%H|||%B---COMMIT_DELIMITER---", "--no-merges"];
1305
- const output = execSync("git", args, { cwd: projectDir, encoding: "utf8" }).toString();
1306
- const commits = output.split("---COMMIT_DELIMITER---").filter((commit) => commit.trim() !== "");
1983
+ const output2 = execSync("git", args, { cwd: projectDir, encoding: "utf8" }).toString();
1984
+ const commits = output2.split("---COMMIT_DELIMITER---").filter((commit) => commit.trim() !== "");
1307
1985
  return commits.map((commit) => {
1308
1986
  const [hash, ...messageParts] = commit.split("|||");
1309
1987
  const message = messageParts.join("|||").trim();
@@ -1321,14 +1999,14 @@ function extractAllChangelogEntriesWithHash(projectDir, revisionRange) {
1321
1999
  }
1322
2000
  function commitTouchesAnyPackage(projectDir, commitHash, packageDirs, sharedPackageDirs = []) {
1323
2001
  try {
1324
- const output = execSync("git", ["diff-tree", "--no-commit-id", "--name-only", "-r", commitHash], {
2002
+ const output2 = execSync("git", ["diff-tree", "--no-commit-id", "--name-only", "-r", commitHash], {
1325
2003
  cwd: projectDir,
1326
2004
  encoding: "utf8"
1327
2005
  }).toString().trim();
1328
- if (!output) {
2006
+ if (!output2) {
1329
2007
  return false;
1330
2008
  }
1331
- const changedFiles = output.split("\n");
2009
+ const changedFiles = output2.split("\n");
1332
2010
  return changedFiles.some((file) => {
1333
2011
  return packageDirs.some((pkgDir) => {
1334
2012
  if (sharedPackageDirs.some((sharedDir) => pkgDir.includes(sharedDir))) {
@@ -1375,8 +2053,8 @@ function extractCommitsFromGitLog(projectDir, revisionRange, filterToPath) {
1375
2053
  if (filterToPath) {
1376
2054
  args.push("--", ".");
1377
2055
  }
1378
- const output = execSync("git", args, { cwd: projectDir, encoding: "utf8" }).toString();
1379
- const commits = output.split("---COMMIT_DELIMITER---").filter((commit) => commit.trim() !== "");
2056
+ const output2 = execSync("git", args, { cwd: projectDir, encoding: "utf8" }).toString();
2057
+ const commits = output2.split("---COMMIT_DELIMITER---").filter((commit) => commit.trim() !== "");
1380
2058
  return commits.map((commit) => parseCommitMessage(commit)).filter((entry) => entry !== null);
1381
2059
  } catch (error) {
1382
2060
  const errorMessage = error instanceof Error ? error.message : String(error);
@@ -1499,7 +2177,7 @@ function shouldProcessPackage(packageName, skip = []) {
1499
2177
 
1500
2178
  // src/package/packageManagement.ts
1501
2179
  import fs8 from "fs";
1502
- import path6 from "path";
2180
+ import path7 from "path";
1503
2181
  function updatePackageVersion(packagePath, version, dryRun = false) {
1504
2182
  if (isCargoToml(packagePath)) {
1505
2183
  updateCargoVersion(packagePath, version, dryRun);
@@ -1684,7 +2362,7 @@ var PackageProcessor = class {
1684
2362
  }
1685
2363
  let repoUrl;
1686
2364
  try {
1687
- const packageJsonPath2 = path7.join(pkgPath, "package.json");
2365
+ const packageJsonPath2 = path8.join(pkgPath, "package.json");
1688
2366
  if (fs9.existsSync(packageJsonPath2)) {
1689
2367
  const packageJson = JSON.parse(fs9.readFileSync(packageJsonPath2, "utf8"));
1690
2368
  if (packageJson.repository) {
@@ -1712,7 +2390,7 @@ var PackageProcessor = class {
1712
2390
  repoUrl: repoUrl || null,
1713
2391
  entries: changelogEntries
1714
2392
  });
1715
- const packageJsonPath = path7.join(pkgPath, "package.json");
2393
+ const packageJsonPath = path8.join(pkgPath, "package.json");
1716
2394
  if (fs9.existsSync(packageJsonPath)) {
1717
2395
  updatePackageVersion(packageJsonPath, nextVersion, this.dryRun);
1718
2396
  }
@@ -1723,7 +2401,7 @@ var PackageProcessor = class {
1723
2401
  log(`Cargo paths config for ${name}: ${JSON.stringify(cargoPaths)}`, "debug");
1724
2402
  if (cargoPaths && cargoPaths.length > 0) {
1725
2403
  for (const cargoPath of cargoPaths) {
1726
- const resolvedCargoPath = path7.resolve(pkgPath, cargoPath, "Cargo.toml");
2404
+ const resolvedCargoPath = path8.resolve(pkgPath, cargoPath, "Cargo.toml");
1727
2405
  log(`Checking cargo path for ${name}: ${resolvedCargoPath}`, "debug");
1728
2406
  if (fs9.existsSync(resolvedCargoPath)) {
1729
2407
  log(`Found Cargo.toml for ${name} at ${resolvedCargoPath}, updating...`, "debug");
@@ -1733,7 +2411,7 @@ var PackageProcessor = class {
1733
2411
  }
1734
2412
  }
1735
2413
  } else {
1736
- const cargoTomlPath = path7.join(pkgPath, "Cargo.toml");
2414
+ const cargoTomlPath = path8.join(pkgPath, "Cargo.toml");
1737
2415
  log(`Checking default cargo path for ${name}: ${cargoTomlPath}`, "debug");
1738
2416
  if (fs9.existsSync(cargoTomlPath)) {
1739
2417
  log(`Found Cargo.toml for ${name} at ${cargoTomlPath}, updating...`, "debug");
@@ -1802,7 +2480,7 @@ var PackageProcessor = class {
1802
2480
 
1803
2481
  // src/core/versionStrategies.ts
1804
2482
  import fs10 from "fs";
1805
- import * as path8 from "path";
2483
+ import * as path9 from "path";
1806
2484
  function shouldProcessPackage2(pkg, config) {
1807
2485
  const pkgName = pkg.packageJson.name;
1808
2486
  return shouldProcessPackage(pkgName, config.skip);
@@ -1816,14 +2494,14 @@ function updateCargoFiles(packageDir, version, cargoConfig, dryRun = false) {
1816
2494
  const cargoPaths = cargoConfig?.paths;
1817
2495
  if (cargoPaths && cargoPaths.length > 0) {
1818
2496
  for (const cargoPath of cargoPaths) {
1819
- const resolvedCargoPath = path8.resolve(packageDir, cargoPath, "Cargo.toml");
2497
+ const resolvedCargoPath = path9.resolve(packageDir, cargoPath, "Cargo.toml");
1820
2498
  if (fs10.existsSync(resolvedCargoPath)) {
1821
2499
  updatePackageVersion(resolvedCargoPath, version, dryRun);
1822
2500
  updatedFiles.push(resolvedCargoPath);
1823
2501
  }
1824
2502
  }
1825
2503
  } else {
1826
- const cargoTomlPath = path8.join(packageDir, "Cargo.toml");
2504
+ const cargoTomlPath = path9.join(packageDir, "Cargo.toml");
1827
2505
  if (fs10.existsSync(cargoTomlPath)) {
1828
2506
  updatePackageVersion(cargoTomlPath, version, dryRun);
1829
2507
  updatedFiles.push(cargoTomlPath);
@@ -1904,7 +2582,7 @@ function createSyncStrategy(config) {
1904
2582
  const processedPaths = /* @__PURE__ */ new Set();
1905
2583
  try {
1906
2584
  if (packages.root) {
1907
- const rootPkgPath = path8.join(packages.root, "package.json");
2585
+ const rootPkgPath = path9.join(packages.root, "package.json");
1908
2586
  if (fs10.existsSync(rootPkgPath)) {
1909
2587
  updatePackageVersion(rootPkgPath, nextVersion, dryRun);
1910
2588
  files.push(rootPkgPath);
@@ -1924,7 +2602,7 @@ function createSyncStrategy(config) {
1924
2602
  if (!shouldProcessPackage2(pkg, config)) {
1925
2603
  continue;
1926
2604
  }
1927
- const packageJsonPath = path8.join(pkg.dir, "package.json");
2605
+ const packageJsonPath = path9.join(pkg.dir, "package.json");
1928
2606
  if (processedPaths.has(packageJsonPath)) {
1929
2607
  continue;
1930
2608
  }
@@ -1983,7 +2661,7 @@ function createSyncStrategy(config) {
1983
2661
  let repoUrl = null;
1984
2662
  for (const searchPath of [mainPkgPath, versionSourcePath].filter(Boolean)) {
1985
2663
  try {
1986
- const pkgJsonPath = path8.join(searchPath, "package.json");
2664
+ const pkgJsonPath = path9.join(searchPath, "package.json");
1987
2665
  if (fs10.existsSync(pkgJsonPath)) {
1988
2666
  const pkgJson = JSON.parse(fs10.readFileSync(pkgJsonPath, "utf8"));
1989
2667
  let url;
@@ -2152,7 +2830,7 @@ function createSingleStrategy(config) {
2152
2830
  }
2153
2831
  let repoUrl;
2154
2832
  try {
2155
- const packageJsonPath2 = path8.join(pkgPath, "package.json");
2833
+ const packageJsonPath2 = path9.join(pkgPath, "package.json");
2156
2834
  if (fs10.existsSync(packageJsonPath2)) {
2157
2835
  const packageJson = JSON.parse(fs10.readFileSync(packageJsonPath2, "utf8"));
2158
2836
  if (packageJson.repository) {
@@ -2180,7 +2858,7 @@ function createSingleStrategy(config) {
2180
2858
  repoUrl: repoUrl || null,
2181
2859
  entries: changelogEntries
2182
2860
  });
2183
- const packageJsonPath = path8.join(pkgPath, "package.json");
2861
+ const packageJsonPath = path9.join(pkgPath, "package.json");
2184
2862
  updatePackageVersion(packageJsonPath, nextVersion, dryRun);
2185
2863
  const filesToCommit = [packageJsonPath];
2186
2864
  const cargoFiles = updateCargoFiles(pkgPath, nextVersion, config.cargo, dryRun);
@@ -2286,7 +2964,7 @@ var GitError = class extends BaseVersionError {
2286
2964
  };
2287
2965
 
2288
2966
  // src/utils/packageFiltering.ts
2289
- import path9 from "path";
2967
+ import path10 from "path";
2290
2968
  import { minimatch as minimatch2 } from "minimatch";
2291
2969
  function filterPackagesByConfig(packages, configTargets, workspaceRoot) {
2292
2970
  if (configTargets.length === 0) {
@@ -2312,7 +2990,7 @@ function filterByDirectoryPattern(packages, pattern, workspaceRoot) {
2312
2990
  }
2313
2991
  const normalizedPattern = pattern.replace(/\\/g, "/");
2314
2992
  return packages.filter((pkg) => {
2315
- const relativePath = path9.relative(workspaceRoot, pkg.dir);
2993
+ const relativePath = path10.relative(workspaceRoot, pkg.dir);
2316
2994
  const normalizedRelativePath = relativePath.replace(/\\/g, "/");
2317
2995
  if (normalizedPattern === normalizedRelativePath) {
2318
2996
  return true;