fork-version 1.7.0 → 1.7.6

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,53 @@
1
1
  # Fork Version
2
2
 
3
+ ## 1.7.6 (2024-11-09)
4
+
5
+
6
+ ### Refactor
7
+
8
+ * remove git-semver-tags library in favour of vendoring it ([#80](https://github.com/eglavin/fork-version/issues/80)) ([5e1b9cb](https://github.com/eglavin/fork-version/commit/5e1b9cbe7c7d77479235fcdc6f1dbc182c10ecd3))
9
+
10
+
11
+ ## 1.7.5 (2024-11-09)
12
+
13
+
14
+ ### Refactor
15
+
16
+ * rename strategies folder to files ([#79](https://github.com/eglavin/fork-version/issues/79)) ([9a06f63](https://github.com/eglavin/fork-version/commit/9a06f63c95d760fa0d729a839d2dc576c9c059e9))
17
+
18
+
19
+ ## 1.7.4 (2024-11-08)
20
+
21
+
22
+ ### Bug Fixes
23
+
24
+ * match casing of logs between steps ([df88a60](https://github.com/eglavin/fork-version/commit/df88a60429b508dcbaa55aff34ff816e745b26f5))
25
+
26
+
27
+ ## 1.7.3 (2024-11-03)
28
+
29
+
30
+ ### Refactor
31
+
32
+ * general cleanup of error message handling ([#78](https://github.com/eglavin/fork-version/issues/78)) ([a83ff13](https://github.com/eglavin/fork-version/commit/a83ff13443d50edfba18c5502d9c38e834e3236d))
33
+
34
+
35
+ ## 1.7.2 (2024-11-02)
36
+
37
+
38
+ ### Chore
39
+
40
+ * bump pnpm dependency ([#77](https://github.com/eglavin/fork-version/issues/77)) ([158c70c](https://github.com/eglavin/fork-version/commit/158c70c06311fb624be03b522c06730f8f314d37))
41
+
42
+
43
+ ## 1.7.1 (2024-11-01)
44
+
45
+
46
+ ### Docs
47
+
48
+ * update using npx section of readme ([737a72a](https://github.com/eglavin/fork-version/commit/737a72a8485a5e1035543245c498e9f76ce1050b))
49
+
50
+
3
51
  ## 1.7.0 (2024-10-31)
4
52
 
5
53
 
package/README.md CHANGED
@@ -14,7 +14,7 @@ Fork-Version automates version control tasks such as determining, updating, and
14
14
  </p>
15
15
 
16
16
  <details>
17
- <summary>This project is essentially a complete re-write of standard-version following on from its deprecation in May 2022.</summary>
17
+ <summary>This project is essentially a complete re-write of <a href=https://github.com/conventional-changelog/standard-version>standard-version</a> following on from its deprecation in May 2022.</summary>
18
18
  Although there are many alternatives such as <a href=https://github.com/googleapis/release-please>release-please</a>. This project aims to continue focusing on just the versioning and changelog generation aspect of the process for use in other Git hosts outside of Github.
19
19
  </details>
20
20
 
@@ -23,7 +23,7 @@ Although there are many alternatives such as <a href=https://github.com/googleap
23
23
  By following the [conventional commit](https://www.conventionalcommits.org) standard Fork-Version can automate the following tasks for you:
24
24
 
25
25
  1. Determine the current and next version
26
- 1. Update the version in the selected files
26
+ 1. Update the version in the selected files [(View the supported files)](#supported-file-types)
27
27
  1. Update your changelog
28
28
  1. Commit the changed files
29
29
  1. Create a tag for the new version
@@ -41,19 +41,28 @@ Fork-Version can be configured either through a config file or by passing option
41
41
 
42
42
  ### Using `npx` (Recommended)
43
43
 
44
- To use Fork-Version with `npx` you can use the following command, by using `npx` you can also use Fork-Version without installation and on other projects including non node projects.
44
+ To use Fork-Version without installation you can use `npx`:
45
45
 
46
46
  ```sh
47
47
  npx fork-version
48
48
  ```
49
49
 
50
+ `npx` is a package runner which allows you to execute npm packages without installation, this can be useful when working on projects outside of the Node ecosystem.
51
+
50
52
  > [!NOTE]
51
- > If you want to use a specific version you can add a version tag to the end of the name.
53
+ > By default `npx` will use the latest release, if you want to use a specific version you can add a version tag to the end of the name.
52
54
  >
53
- > Example: `npx fork-version@1.4.67`
55
+ > Example: `npx fork-version@1.7.0`
54
56
  >
55
57
  > The version tag needs to match against one of the [published versions on npm](https://www.npmjs.com/package/fork-version?activeTab=versions).
56
58
 
59
+ Alternatively you can use other npm compatible javascript runtime's:
60
+
61
+ | Runner | Command |
62
+ | ------ | -------------------------- |
63
+ | bun | `bunx fork-version` |
64
+ | deno | `deno -A npm:fork-version` |
65
+
57
66
  ### Install Locally
58
67
 
59
68
  To install the package locally to your project you can use one of the following commands:
@@ -63,10 +72,12 @@ To install the package locally to your project you can use one of the following
63
72
  | npm | `npm install fork-version --save-dev` |
64
73
  | yarn | `yarn add fork-version --dev` |
65
74
  | pnpm | `pnpm add fork-version --save-dev` |
75
+ | bun | `bun install fork-version --dev` |
66
76
 
67
77
  You can then add the following entry to your package.json scripts section and use it like any other script you already use in your project.
68
78
 
69
79
  ```json
80
+ // package.json
70
81
  {
71
82
  "scripts": {
72
83
  "release": "fork-version"
@@ -76,8 +87,20 @@ You can then add the following entry to your package.json scripts section and us
76
87
 
77
88
  For example if you use npm you can now use `npm run release` to run Fork-Version.
78
89
 
90
+ ### Exit Codes
91
+
92
+ When ran as a cli tool Fork-Version will exit with one of the following exit codes:
93
+
94
+ | Exit Code | Description |
95
+ | --------- | ---------------------------- |
96
+ | 0 | Success |
97
+ | 1 | General Error |
98
+ | 3 | Config File Validation Error |
99
+
79
100
  ### Command Line Options
80
101
 
102
+ The following help text can be viewed by running the following command: `npx fork-version --help`
103
+
81
104
  <!-- START COMMAND LINE OPTIONS -->
82
105
 
83
106
  ```text
@@ -129,6 +152,11 @@ Conventional Changelog Overrides:
129
152
  --release-commit-message-format Override the default release commit message format.
130
153
  --release-message-suffix Add a suffix to the end of the release message.
131
154
 
155
+ Exit Codes:
156
+ 0: Success
157
+ 1: General Error
158
+ 3: Config File Validation Error
159
+
132
160
  Examples:
133
161
  $ fork-version
134
162
  Run fork-version in the current directory with default options.
@@ -163,6 +191,7 @@ You can configure Fork-Version using one of the following files:
163
191
  Configuring using a javascript file is the most flexible option. You can use any javascript file type you prefer including typescript. Both commonjs and esm exports styles are supported. The `defineConfig` function in the following snippet is optional, using it will give you intellisense information in your code editor of choice.
164
192
 
165
193
  ```js
194
+ // fork.config.ts
166
195
  import { defineConfig } from 'fork-version';
167
196
 
168
197
  export default defineConfig({
@@ -174,6 +203,7 @@ export default defineConfig({
174
203
  Alternatively you can use typescript type annotations in a typescript file:
175
204
 
176
205
  ```ts
206
+ // fork.config.ts
177
207
  import type { Config } from 'fork-version';
178
208
 
179
209
  const config: Config = {
@@ -187,6 +217,7 @@ export default config;
187
217
  Or jsdocs in a javascript file:
188
218
 
189
219
  ```js
220
+ // fork.config.js
190
221
  /** @type {import("fork-version").Config} */
191
222
  export default {
192
223
  header: `# My Changelog`,
@@ -203,6 +234,7 @@ Another way you can configure Fork-Version is by using a json file called `fork.
203
234
  If you still want intellisense information you can use the following schema in your json file, otherwise `$schema` is an optional key.
204
235
 
205
236
  ```json
237
+ // fork.config.json
206
238
  {
207
239
  "$schema": "https://raw.githubusercontent.com/eglavin/fork-version/main/schema/latest.json",
208
240
  "header": "# My Changelog",
@@ -218,6 +250,7 @@ Internally we're using [zod-to-json-schema](https://github.com/StefanTerdell/zod
218
250
  Alternatively you can define your config using a key in your `package.json` file called `fork-version`:
219
251
 
220
252
  ```json
253
+ // package.json
221
254
  {
222
255
  "name": "my-js-project",
223
256
  "version": "1.2.3",
@@ -318,14 +351,14 @@ Marking a release as a pre-release allows you to define a change as a patch to a
318
351
  | Example Value | Version Created |
319
352
  |:--------------|:----------------|
320
353
  | `true` | `1.2.3-0` |
321
- | `alpha` | `1.2.3-alpha-0` |
354
+ | `alpha` | `1.2.3-alpha.0` |
322
355
 
323
356
  Fork-Version uses [meow](https://github.com/sindresorhus/meow) to parse cli arguments which is unable to take a single argument and parse it as either a string and or a boolean. So to do the above through the cli interface you'll need to use two different arguments:
324
357
 
325
358
  | Example CLI Usage | Version Created |
326
359
  |:---------------------------------------|:----------------|
327
360
  | `fork-version --pre-release` | `1.2.3-0` |
328
- | `fork-version --pre-release-tag alpha` | `1.2.3-alpha-0` |
361
+ | `fork-version --pre-release-tag alpha` | `1.2.3-alpha.0` |
329
362
 
330
363
  ##### config.releaseAs
331
364
 
@@ -364,7 +397,7 @@ Checkout the `fork.config.js` file [here](./fork.config.js) to see an example of
364
397
  | section | string | The name of the section in the `CHANGELOG` the commit should show up in. |
365
398
  | hidden | boolean | Should show in the generated changelog message? |
366
399
 
367
- ###### config.releaseMessageSuffix
400
+ ##### config.releaseMessageSuffix
368
401
 
369
402
  Adds a suffix to the end of the release message, useful to add a `[skip ci]` message to the end of the created commit.
370
403
 
@@ -406,7 +439,7 @@ version: 1.2.3
406
439
 
407
440
  #### Plain Text
408
441
 
409
- A plain text file will have just the version as the content.
442
+ A plain text file is a file which contains just the version as the content. Files that end with `version.txt` will be treated as a plain text version file.
410
443
 
411
444
  ```text
412
445
  1.2.3
@@ -1,5 +1,5 @@
1
1
  import { z } from 'zod';
2
- import { readFileSync, writeFileSync } from 'node:fs';
2
+ import { readFileSync, writeFileSync, lstatSync } from 'node:fs';
3
3
  import { resolve, parse } from 'node:path';
4
4
  import JoyCon from 'joycon';
5
5
  import { bundleRequire } from 'bundle-require';
@@ -7,13 +7,11 @@ import { glob } from 'glob';
7
7
  import meow from 'meow';
8
8
  import conventionalChangelogConfigSpec from 'conventional-changelog-config-spec';
9
9
  import { execFile } from 'node:child_process';
10
- import { parse as parse$1, modify, applyEdits } from 'jsonc-parser';
11
- import { lstatSync } from 'fs';
10
+ import { modify, applyEdits, parse as parse$1 } from 'jsonc-parser';
12
11
  import { parse as parse$2, parseDocument } from 'yaml';
13
12
  import * as cheerio from 'cheerio/slim';
14
- import semver3 from 'semver';
13
+ import semver2 from 'semver';
15
14
  import conventionalRecommendedBump from 'conventional-recommended-bump';
16
- import gitSemverTags from 'git-semver-tags';
17
15
  import conventionalChangelog from 'conventional-changelog';
18
16
 
19
17
  // src/config/schema.js
@@ -359,6 +357,11 @@ Conventional Changelog Overrides:
359
357
  --release-commit-message-format Override the default release commit message format.
360
358
  --release-message-suffix Add a suffix to the end of the release message.
361
359
 
360
+ Exit Codes:
361
+ 0: Success
362
+ 1: General Error
363
+ 3: Config File Validation Error
364
+
362
365
  Examples:
363
366
  $ fork-version
364
367
  Run fork-version in the current directory with default options.
@@ -571,7 +574,7 @@ async function loadConfigFile(configFilePath) {
571
574
  if (fileContent2[PACKAGE_JSON_CONFIG_KEY] && typeof fileContent2[PACKAGE_JSON_CONFIG_KEY] === "object") {
572
575
  const parsed3 = ForkConfigSchema.partial().safeParse(fileContent2[PACKAGE_JSON_CONFIG_KEY]);
573
576
  if (!parsed3.success) {
574
- throw parsed3.error;
577
+ throw new Error(`Validation error in: ${configFilePath}`, { cause: parsed3.error });
575
578
  }
576
579
  return parsed3.data;
577
580
  }
@@ -579,14 +582,14 @@ async function loadConfigFile(configFilePath) {
579
582
  }
580
583
  const parsed2 = ForkConfigSchema.partial().safeParse(fileContent2);
581
584
  if (!parsed2.success) {
582
- throw parsed2.error;
585
+ throw new Error(`Validation error in: ${configFilePath}`, { cause: parsed2.error });
583
586
  }
584
587
  return parsed2.data;
585
588
  }
586
589
  const fileContent = await bundleRequire({ filepath: configFilePath });
587
590
  const parsed = ForkConfigSchema.partial().safeParse(fileContent.mod.default || fileContent.mod);
588
591
  if (!parsed.success) {
589
- throw parsed.error;
592
+ throw new Error(`Validation error in: ${configFilePath}`, { cause: parsed.error });
590
593
  }
591
594
  return parsed.data;
592
595
  }
@@ -648,23 +651,35 @@ function fileExists(filePath) {
648
651
  }
649
652
  }
650
653
 
651
- // src/strategies/json-package.ts
652
- var PARSE_OPTIONS = {
653
- allowTrailingComma: true,
654
- allowEmptyContent: false,
655
- disallowComments: false
656
- };
654
+ // src/files/json-package.ts
657
655
  var JSONPackage = class {
658
656
  constructor(config, logger) {
659
657
  this.config = config;
660
658
  this.logger = logger;
661
659
  }
660
+ /** Options for parsing JSON and JSONC files. */
661
+ PARSE_OPTIONS = {
662
+ allowEmptyContent: false,
663
+ allowTrailingComma: true,
664
+ disallowComments: false
665
+ };
666
+ /**
667
+ * Sets a new string value at the given path in a JSON or JSONC string.
668
+ * @param jsonc the JSON or JSONC string (the contents of a file)
669
+ * @param jsonPath path to the value to set, as an array of segments
670
+ * @param newString string to set the value to
671
+ * @returns the JSON or JSONC string with the value set
672
+ */
673
+ setStringInJsonc(jsonc, jsonPath, newString) {
674
+ const edits = modify(jsonc, jsonPath, newString, {});
675
+ return applyEdits(jsonc, edits);
676
+ }
662
677
  read(fileName) {
663
678
  const filePath = resolve(this.config.path, fileName);
664
679
  if (fileExists(filePath)) {
665
680
  const fileContents = readFileSync(filePath, "utf8");
666
681
  const parseErrors = [];
667
- const parsedJson = parse$1(fileContents, parseErrors, PARSE_OPTIONS);
682
+ const parsedJson = parse$1(fileContents, parseErrors, this.PARSE_OPTIONS);
668
683
  if (parseErrors.length) {
669
684
  this.logger.warn(`[File Manager] Unable to parse JSON: ${fileName}`, parseErrors);
670
685
  return void 0;
@@ -677,20 +692,20 @@ var JSONPackage = class {
677
692
  isPrivate: typeof parsedJson?.private === "boolean" ? parsedJson.private : true
678
693
  };
679
694
  }
680
- this.logger.warn(`[File Manager] Unable to determine json package: ${fileName}`);
695
+ this.logger.warn(`[File Manager] Unable to determine json version: ${fileName}`);
681
696
  }
682
697
  }
683
698
  write(fileState, newVersion) {
684
699
  let fileContents = readFileSync(fileState.path, "utf8");
685
700
  const parseErrors = [];
686
- const parsedJson = parse$1(fileContents, parseErrors, PARSE_OPTIONS);
701
+ const parsedJson = parse$1(fileContents, parseErrors, this.PARSE_OPTIONS);
687
702
  if (parseErrors.length) {
688
703
  this.logger.warn(`[File Manager] Unable to parse JSON: ${fileState.path}`, parseErrors);
689
704
  return;
690
705
  }
691
- fileContents = setStringInJsonc(fileContents, ["version"], newVersion);
706
+ fileContents = this.setStringInJsonc(fileContents, ["version"], newVersion);
692
707
  if (parsedJson?.packages?.[""]) {
693
- fileContents = setStringInJsonc(fileContents, ["packages", "", "version"], newVersion);
708
+ fileContents = this.setStringInJsonc(fileContents, ["packages", "", "version"], newVersion);
694
709
  }
695
710
  writeFileSync(fileState.path, fileContents, "utf8");
696
711
  }
@@ -698,10 +713,6 @@ var JSONPackage = class {
698
713
  return fileName.endsWith(".json") || fileName.endsWith(".jsonc");
699
714
  }
700
715
  };
701
- function setStringInJsonc(jsonc, jsonPath, newString) {
702
- const edits = modify(jsonc, jsonPath, newString, {});
703
- return applyEdits(jsonc, edits);
704
- }
705
716
  var YAMLPackage = class {
706
717
  constructor(config, logger) {
707
718
  this.config = config;
@@ -739,7 +750,7 @@ var YAMLPackage = class {
739
750
  };
740
751
  }
741
752
  }
742
- this.logger.warn(`[File Manager] Unable to determine PubSpec file: ${fileName}`);
753
+ this.logger.warn(`[File Manager] Unable to determine yaml version: ${fileName}`);
743
754
  }
744
755
  write(fileState, newVersion) {
745
756
  const fileContents = readFileSync(fileState.path, "utf8");
@@ -770,7 +781,7 @@ var PlainText = class {
770
781
  version: fileContents || ""
771
782
  };
772
783
  }
773
- this.logger.warn(`[File Manager] Unable to determine plain text: ${fileName}`);
784
+ this.logger.warn(`[File Manager] Unable to determine plain text version: ${fileName}`);
774
785
  }
775
786
  write(fileState, newVersion) {
776
787
  writeFileSync(fileState.path, newVersion, "utf8");
@@ -800,7 +811,7 @@ var MSBuildProject = class {
800
811
  version
801
812
  };
802
813
  }
803
- this.logger.warn(`[File Manager] Unable to determine ms-build package: ${fileName}`);
814
+ this.logger.warn(`[File Manager] Unable to determine ms-build version: ${fileName}`);
804
815
  }
805
816
  }
806
817
  write(fileState, newVersion) {
@@ -820,7 +831,7 @@ var MSBuildProject = class {
820
831
  }
821
832
  };
822
833
 
823
- // src/strategies/file-manager.ts
834
+ // src/files/file-manager.ts
824
835
  var FileManager = class {
825
836
  constructor(config, logger) {
826
837
  this.config = config;
@@ -894,25 +905,11 @@ var FileManager = class {
894
905
  this.logger.error(`[File Manager] Unsupported file: ${fileState.path}`);
895
906
  }
896
907
  };
897
- async function getLatestGitTagVersion(tagPrefix) {
898
- const gitTags = await gitSemverTags({ tagPrefix });
899
- if (!gitTags.length) {
900
- return "";
901
- }
902
- const cleanedTags = [];
903
- for (const tag of gitTags) {
904
- const cleanedTag = semver3.clean(tag.replace(new RegExp(`^${tagPrefix}`), ""));
905
- if (cleanedTag) {
906
- cleanedTags.push(cleanedTag);
907
- }
908
- }
909
- return cleanedTags.sort(semver3.rcompare)[0];
910
- }
911
908
  function getPriority(type) {
912
909
  return ["patch", "minor", "major"].indexOf(type ?? "");
913
910
  }
914
911
  function getVersionType(version) {
915
- const parseVersion = semver3.parse(version);
912
+ const parseVersion = semver2.parse(version);
916
913
  if (parseVersion?.major) {
917
914
  return "major";
918
915
  } else if (parseVersion?.minor) {
@@ -926,7 +923,7 @@ function getReleaseType(releaseType, currentVersion, preReleaseTag) {
926
923
  if (!preReleaseTag) {
927
924
  return releaseType;
928
925
  }
929
- const currentVersionsIsPreRelease = Array.isArray(semver3.prerelease(currentVersion));
926
+ const currentVersionsIsPreRelease = Array.isArray(semver2.prerelease(currentVersion));
930
927
  if (currentVersionsIsPreRelease) {
931
928
  const currentReleaseType = getVersionType(currentVersion);
932
929
  if (currentReleaseType === releaseType || getPriority(currentReleaseType) > getPriority(releaseType)) {
@@ -937,26 +934,29 @@ function getReleaseType(releaseType, currentVersion, preReleaseTag) {
937
934
  }
938
935
 
939
936
  // src/process/version.ts
940
- async function getCurrentVersion(config, logger, fileManager, filesToUpdate) {
937
+ async function getCurrentVersion(config, logger, git, fileManager, filesToUpdate) {
941
938
  const files = [];
942
939
  const versions = /* @__PURE__ */ new Set();
943
940
  for (const file of filesToUpdate) {
941
+ if (await git.isIgnored(file)) {
942
+ logger.debug(`[Git Ignored] ${file}`);
943
+ continue;
944
+ }
944
945
  const fileState = fileManager.read(file);
945
946
  if (fileState) {
946
947
  files.push(fileState);
947
- if (config.currentVersion) {
948
- continue;
948
+ if (!config.currentVersion) {
949
+ versions.add(fileState.version);
949
950
  }
950
- versions.add(fileState.version);
951
951
  }
952
952
  }
953
953
  if (config.currentVersion) {
954
954
  versions.add(config.currentVersion);
955
955
  }
956
956
  if (versions.size === 0 && config.gitTagFallback) {
957
- const version = await getLatestGitTagVersion(config.tagPrefix);
957
+ const version = await git.getLatestTag(config.tagPrefix);
958
958
  if (version) {
959
- logger.log(`[Version] Using git tag fallback.`);
959
+ logger.warn(`Using latest git tag as fallback`);
960
960
  versions.add(version);
961
961
  }
962
962
  }
@@ -966,10 +966,11 @@ async function getCurrentVersion(config, logger, fileManager, filesToUpdate) {
966
966
  if (!config.allowMultipleVersions) {
967
967
  throw new Error("Found multiple versions");
968
968
  }
969
- logger.warn("[WARNING] Found multiple versions, using the first one.");
970
- logger.log(`Versions: ${Array.from(versions).join(", ")}`);
969
+ logger.warn(
970
+ `Found multiple versions (${Array.from(versions).join(", ")}), using the higher semver version`
971
+ );
971
972
  }
972
- const currentVersion = semver3.rsort(Array.from(versions))[0];
973
+ const currentVersion = semver2.rsort(Array.from(versions))[0];
973
974
  if (config.inspectVersion) {
974
975
  console.log(currentVersion);
975
976
  process.exit(0);
@@ -982,27 +983,27 @@ async function getCurrentVersion(config, logger, fileManager, filesToUpdate) {
982
983
  }
983
984
  async function getNextVersion(config, logger, currentVersion) {
984
985
  if (config.skipBump) {
985
- logger.log("Skip bump, using current version as next version");
986
+ logger.warn(`Skip bump, using ${currentVersion} as the next version`);
986
987
  return {
987
988
  version: currentVersion
988
989
  };
989
990
  }
990
- if (config.nextVersion && semver3.valid(config.nextVersion)) {
991
+ if (config.nextVersion && semver2.valid(config.nextVersion)) {
991
992
  logger.log(`Next version: ${config.nextVersion}`);
992
993
  return {
993
994
  version: config.nextVersion
994
995
  };
995
996
  }
996
- const isPreMajor = semver3.lt(currentVersion, "1.0.0");
997
+ const isPreMajor = semver2.lt(currentVersion, "1.0.0");
997
998
  let recommendedBump;
998
- try {
999
- if (config.releaseAs) {
1000
- recommendedBump = {
1001
- releaseType: config.releaseAs,
1002
- level: -1,
1003
- reason: "User defined"
1004
- };
1005
- } else {
999
+ if (config.releaseAs) {
1000
+ recommendedBump = {
1001
+ releaseType: config.releaseAs,
1002
+ level: -1,
1003
+ reason: "User defined"
1004
+ };
1005
+ } else {
1006
+ try {
1006
1007
  recommendedBump = await conventionalRecommendedBump({
1007
1008
  preset: {
1008
1009
  name: "conventionalcommits",
@@ -1013,9 +1014,11 @@ async function getNextVersion(config, logger, currentVersion) {
1013
1014
  tagPrefix: config.tagPrefix,
1014
1015
  cwd: config.path
1015
1016
  });
1017
+ } catch (cause) {
1018
+ throw new Error(`[conventional-recommended-bump] Unable to determine next version`, {
1019
+ cause
1020
+ });
1016
1021
  }
1017
- } catch (_error) {
1018
- throw new Error(`[conventional-recommended-bump] Unable to determine next version`);
1019
1022
  }
1020
1023
  if (recommendedBump.releaseType) {
1021
1024
  const releaseType = getReleaseType(
@@ -1023,18 +1026,18 @@ async function getNextVersion(config, logger, currentVersion) {
1023
1026
  currentVersion,
1024
1027
  config.preRelease
1025
1028
  );
1026
- const state = {
1029
+ const nextVersion = semver2.inc(
1030
+ currentVersion,
1031
+ releaseType,
1032
+ typeof config.preRelease === "string" ? config.preRelease : void 0
1033
+ ) ?? "";
1034
+ logger.log(`Next version: ${nextVersion} (${releaseType})`);
1035
+ return {
1027
1036
  ...recommendedBump,
1028
1037
  preMajor: isPreMajor,
1029
1038
  releaseType,
1030
- version: semver3.inc(
1031
- currentVersion,
1032
- releaseType,
1033
- typeof config.preRelease === "string" ? config.preRelease : void 0
1034
- ) ?? ""
1039
+ version: nextVersion
1035
1040
  };
1036
- logger.log(`Next version: ${state.version} (${state.releaseType})`);
1037
- return state;
1038
1041
  }
1039
1042
  throw new Error("Unable to find next version");
1040
1043
  }
@@ -1069,9 +1072,8 @@ function getNewReleaseContent(config, logger, nextVersion) {
1069
1072
  merges: null,
1070
1073
  path: config.path
1071
1074
  }
1072
- ).on("error", (error) => {
1073
- logger.error("[conventional-changelog] Unable to parse changes");
1074
- throw error;
1075
+ ).on("error", (cause) => {
1076
+ throw new Error("[conventional-changelog] Unable to parse changes", { cause });
1075
1077
  }).on("data", (chunk) => {
1076
1078
  newContent += chunk.toString();
1077
1079
  }).on("end", () => {
@@ -1081,7 +1083,7 @@ function getNewReleaseContent(config, logger, nextVersion) {
1081
1083
  }
1082
1084
  async function updateChangelog(config, logger, nextVersion) {
1083
1085
  if (config.skipChangelog) {
1084
- logger.log("Skip changelog update");
1086
+ logger.warn("Skip changelog update");
1085
1087
  return;
1086
1088
  }
1087
1089
  if (config.header.search(RELEASE_PATTERN) !== -1) {
@@ -1089,12 +1091,13 @@ async function updateChangelog(config, logger, nextVersion) {
1089
1091
  }
1090
1092
  const changelogPath = resolve(config.path, config.changelog);
1091
1093
  if (!config.dryRun && !fileExists(changelogPath)) {
1092
- logger.log(`Creating Changelog file: ${changelogPath}`);
1094
+ logger.log(`Creating changelog: ${changelogPath}`);
1093
1095
  writeFileSync(changelogPath, "\n", "utf8");
1096
+ } else {
1097
+ logger.log(`Updating changelog: ${changelogPath}`);
1094
1098
  }
1095
1099
  const oldContent = getOldReleaseContent(changelogPath, fileExists(changelogPath));
1096
1100
  const newContent = await getNewReleaseContent(config, logger, nextVersion);
1097
- logger.log(`Updating Changelog: ${changelogPath}`);
1098
1101
  if (!config.dryRun && newContent) {
1099
1102
  writeFileSync(
1100
1103
  changelogPath,
@@ -1118,7 +1121,7 @@ function formatCommitMessage(message, version) {
1118
1121
  // src/process/commit.ts
1119
1122
  async function commitChanges(config, logger, git, files, nextVersion) {
1120
1123
  if (config.skipCommit) {
1121
- logger.log("Skip commit");
1124
+ logger.warn("Skip commit");
1122
1125
  return;
1123
1126
  }
1124
1127
  logger.log("Committing changes");
@@ -1150,11 +1153,11 @@ async function commitChanges(config, logger, git, files, nextVersion) {
1150
1153
  // src/process/tag.ts
1151
1154
  async function tagChanges(config, logger, git, nextVersion) {
1152
1155
  if (config.skipTag) {
1153
- logger.log("Skip tag creation");
1156
+ logger.warn("Skip tag creation");
1154
1157
  return;
1155
1158
  }
1156
1159
  const tag = `${config.tagPrefix}${nextVersion}`;
1157
- logger.log(`Creating Tag: ${tag}`);
1160
+ logger.log(`Creating tag: ${tag}`);
1158
1161
  await git.tag(
1159
1162
  config.sign ? "--sign" : "--annotate",
1160
1163
  tag,
@@ -1164,5 +1167,5 @@ async function tagChanges(config, logger, git, nextVersion) {
1164
1167
  }
1165
1168
 
1166
1169
  export { FileManager, ForkConfigSchema, Logger, commitChanges, defineConfig, getCurrentVersion, getNextVersion, getUserConfig, tagChanges, updateChangelog };
1167
- //# sourceMappingURL=chunk-D7324DNL.js.map
1168
- //# sourceMappingURL=chunk-D7324DNL.js.map
1170
+ //# sourceMappingURL=chunk-4M7BP5DG.js.map
1171
+ //# sourceMappingURL=chunk-4M7BP5DG.js.map