fork-version 5.1.3 → 5.1.5

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,27 @@
1
1
  # Fork Version
2
2
 
3
+ ## [5.1.5](https://github.com/eglavin/fork-version/compare/v5.1.4...v5.1.5) (2026-04-26)
4
+
5
+
6
+ ### Refactor
7
+
8
+ * set no-color and date-order opts when getting commits ([2756155](https://github.com/eglavin/fork-version/commit/27561551745da68f7eaa2b298a2a34b803cc2a6d))
9
+
10
+
11
+ ### Test
12
+
13
+ * add test for long running branch scenario ([4dfcbbc](https://github.com/eglavin/fork-version/commit/4dfcbbcec5a27a8baf66dff440b58d9d6ef864f9))
14
+ * tag out of order commit test as skippable when not running in e2e mode ([b7d67e3](https://github.com/eglavin/fork-version/commit/b7d67e3fd5cfaccccffd2173473dfd85d2dc2728))
15
+
16
+
17
+ ## [5.1.4](https://github.com/eglavin/fork-version/compare/v5.1.3...v5.1.4) (2026-04-18)
18
+
19
+
20
+ ### Refactor
21
+
22
+ * add defineFileManager function ([6e0f437](https://github.com/eglavin/fork-version/commit/6e0f4371824a232f85880a80b218d13b3decb25f))
23
+
24
+
3
25
  ## [5.1.3](https://github.com/eglavin/fork-version/compare/v5.1.2...v5.1.3) (2026-04-18)
4
26
 
5
27
 
package/README.md CHANGED
@@ -574,6 +574,9 @@ Example `test.json` file:
574
574
 
575
575
  Example Custom File Manager implementation:
576
576
 
577
+ - [Using a class to define a file manager](./examples/custom-file-manager/fork.config.ts)
578
+ - [Using the defineFileManager function](./examples/custom-file-manager/fork.config.defineFileManager.ts)
579
+
577
580
  ```ts
578
581
  // fork.config.ts
579
582
  import { readFile, writeFile } from "node:fs/promises";
@@ -61,6 +61,12 @@ interface IFileManager {
61
61
  */
62
62
  isSupportedFile(filePath: string): boolean;
63
63
  }
64
+ /**
65
+ * Helper function to define a custom file manager with proper typing.
66
+ *
67
+ * [Fork-Version - Custom File Managers](https://github.com/eglavin/fork-version#custom-file-updaters)
68
+ */
69
+ declare function defineFileManager(fileManager: IFileManager): IFileManager;
64
70
  declare class FileManager {
65
71
  #private;
66
72
  constructor(config: ForkConfig, logger: Logger);
@@ -90,4 +96,4 @@ declare class FileManager {
90
96
  write(fileState: FileState, newVersion: string): Promise<void>;
91
97
  }
92
98
  //#endregion
93
- export { FileManager, FileState, IFileManager, MissingPropertyException };
99
+ export { FileManager, FileState, IFileManager, MissingPropertyException, defineFileManager };
@@ -22,6 +22,14 @@ var MissingPropertyException = class extends Error {
22
22
  this.propertyName = propertyName;
23
23
  }
24
24
  };
25
+ /**
26
+ * Helper function to define a custom file manager with proper typing.
27
+ *
28
+ * [Fork-Version - Custom File Managers](https://github.com/eglavin/fork-version#custom-file-updaters)
29
+ */
30
+ function defineFileManager(fileManager) {
31
+ return fileManager;
32
+ }
25
33
  var FileManager = class {
26
34
  #config;
27
35
  #logger;
@@ -97,4 +105,4 @@ var FileManager = class {
97
105
  }
98
106
  };
99
107
  //#endregion
100
- export { FileManager, MissingPropertyException };
108
+ export { FileManager, MissingPropertyException, defineFileManager };
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { ParserOptions, createParserOptions } from "./commit-parser/options.js";
2
2
  import { Logger } from "./services/logger.js";
3
- import { FileManager, FileState, IFileManager, MissingPropertyException } from "./files/file-manager.js";
3
+ import { FileManager, FileState, IFileManager, MissingPropertyException, defineFileManager } from "./files/file-manager.js";
4
4
  import { ChangelogPresetConfig, ChangelogPresetConfigType, Config, ForkConfig } from "./config/types.js";
5
5
  import { Git } from "./services/git.js";
6
6
  import { inspect } from "./commands/inspect.js";
@@ -18,4 +18,4 @@ import { NextVersion, getNextVersion } from "./process/get-next-version.js";
18
18
  import { updateChangelog } from "./process/changelog.js";
19
19
  import { commitChanges } from "./process/commit.js";
20
20
  import { tagChanges } from "./process/tag.js";
21
- export { type ChangelogPresetConfig, type ChangelogPresetConfigType, type Commit, type CommitMerge, type CommitNote, CommitParser, type CommitReference, type CommitRevert, type CommitsSinceTag, type Config, type CurrentVersion, FileManager, type FileState, type ForkConfig, ForkConfigJSONSchema, ForkConfigJSSchema, Git, type IFileManager, Logger, MissingPropertyException, type NextVersion, type ParserOptions, commitChanges, createParserOptions, defineConfig, filterRevertedCommits, getCommitsSinceTag, getCurrentVersion, getNextVersion, getUserConfig, inspect, main, tagChanges, updateChangelog, validateConfig };
21
+ export { type ChangelogPresetConfig, type ChangelogPresetConfigType, type Commit, type CommitMerge, type CommitNote, CommitParser, type CommitReference, type CommitRevert, type CommitsSinceTag, type Config, type CurrentVersion, FileManager, type FileState, type ForkConfig, ForkConfigJSONSchema, ForkConfigJSSchema, Git, type IFileManager, Logger, MissingPropertyException, type NextVersion, type ParserOptions, commitChanges, createParserOptions, defineConfig, defineFileManager, filterRevertedCommits, getCommitsSinceTag, getCurrentVersion, getNextVersion, getUserConfig, inspect, main, tagChanges, updateChangelog, validateConfig };
package/dist/index.js CHANGED
@@ -14,6 +14,6 @@ import { ForkConfigJSONSchema, ForkConfigJSSchema } from "./config/schema.js";
14
14
  import { defineConfig } from "./config/define-config.js";
15
15
  import { Git } from "./services/git.js";
16
16
  import { getUserConfig } from "./config/user-config.js";
17
- import { FileManager, MissingPropertyException } from "./files/file-manager.js";
17
+ import { FileManager, MissingPropertyException, defineFileManager } from "./files/file-manager.js";
18
18
  import { Logger } from "./services/logger.js";
19
- export { CommitParser, FileManager, ForkConfigJSONSchema, ForkConfigJSSchema, Git, Logger, MissingPropertyException, commitChanges, createParserOptions, defineConfig, filterRevertedCommits, getCommitsSinceTag, getCurrentVersion, getNextVersion, getUserConfig, inspect, main, tagChanges, updateChangelog, validateConfig };
19
+ export { CommitParser, FileManager, ForkConfigJSONSchema, ForkConfigJSSchema, Git, Logger, MissingPropertyException, commitChanges, createParserOptions, defineConfig, defineFileManager, filterRevertedCommits, getCommitsSinceTag, getCurrentVersion, getNextVersion, getUserConfig, inspect, main, tagChanges, updateChangelog, validateConfig };
@@ -87,35 +87,33 @@ declare class Git {
87
87
  */
88
88
  getRemoteUrl(): Promise<string>;
89
89
  /**
90
- * `getTags` returns valid semver version tags in order of the commit history
90
+ * Returns an array of tags from the git log, filtered by an optional tag prefix and pre-release configuration.
91
91
  *
92
- * Using `git log` to get the commit history, we then parse the tags from the
93
- * commit details which is expected to be in the following format:
94
- * ```txt
95
- * commit 3841b1d05750d42197fe958e3d8e06df378a842d (HEAD -> main, tag: v1.0.2, tag: v1.0.1, tag: v1.0.0)
96
- * Author: Username <username@example.com>
97
- * Date: Sat Nov 9 15:00:00 2024 +0000
92
+ * @example
93
+ * ```ts
94
+ * // Given the following git log: (HEAD -> main, tag: v1.0.2, tag: v1.0.1, tag: v1.0.0)
95
+ * await git.getTags("v"); // ["v1.0.2", "v1.0.1", "v1.0.0"]
96
+ *
97
+ * // Given the following git log: (HEAD -> main, tag: v1.0.2-0, tag: v1.0.1-0, tag: v1.0.0)
98
+ * await git.getTags("v", true); // ["v1.0.2-0", "v1.0.1-0", "v1.0.0"]
98
99
  *
99
- * chore(release): v1.0.0
100
+ * // Given the following git log: (HEAD -> main, tag: v1.0.2-alpha.0, tag: v1.0.1-alpha.0, tag: v1.0.0)
101
+ * await git.getTags("v", "alpha"); // ["v1.0.2-alpha.0", "v1.0.1-alpha.0", "v1.0.0"]
100
102
  * ```
101
103
  *
102
104
  * - [Functionality extracted from the conventional-changelog - git-semver-tags project](https://github.com/conventional-changelog/conventional-changelog/blob/fac8045242099c016f5f3905e54e02b7d466bd7b/packages/git-semver-tags/index.js)
103
105
  * - [conventional-changelog git-semver-tags MIT Licence](https://github.com/conventional-changelog/conventional-changelog/blob/fac8045242099c016f5f3905e54e02b7d466bd7b/packages/git-semver-tags/LICENSE.md)
104
- *
105
- * @example
106
- * ```ts
107
- * await git.getTags("v"); // ["v1.0.2", "v1.0.1", "v1.0.0"]
108
- * ```
109
106
  */
110
107
  getTags(tagPrefix?: string, preRelease?: string | boolean): Promise<string[]>;
111
108
  /**
112
- * Get commit history in a parsable format
109
+ * Returns an array of commits between two git references (e.g., tags, branches, or commits), optionally filtered by file paths.
113
110
  *
114
- * An array of strings with commit details is returned in the following format:
111
+ * Each commit in the returned array is a string containing the following information, separated by newlines:
115
112
  * ```txt
116
113
  * subject
117
114
  * body
118
115
  * hash
116
+ * ref names
119
117
  * committer date
120
118
  * committer name
121
119
  * committer email
@@ -123,6 +121,7 @@ declare class Git {
123
121
  *
124
122
  * @example
125
123
  * ```ts
124
+ * await git.getCommits("v1.0.0", "HEAD");
126
125
  * await git.getCommits("v1.0.0", "HEAD", "src/utils");
127
126
  * ```
128
127
  */
@@ -180,28 +180,25 @@ var Git = class {
180
180
  return false;
181
181
  }
182
182
  /**
183
- * `getTags` returns valid semver version tags in order of the commit history
183
+ * Returns an array of tags from the git log, filtered by an optional tag prefix and pre-release configuration.
184
184
  *
185
- * Using `git log` to get the commit history, we then parse the tags from the
186
- * commit details which is expected to be in the following format:
187
- * ```txt
188
- * commit 3841b1d05750d42197fe958e3d8e06df378a842d (HEAD -> main, tag: v1.0.2, tag: v1.0.1, tag: v1.0.0)
189
- * Author: Username <username@example.com>
190
- * Date: Sat Nov 9 15:00:00 2024 +0000
185
+ * @example
186
+ * ```ts
187
+ * // Given the following git log: (HEAD -> main, tag: v1.0.2, tag: v1.0.1, tag: v1.0.0)
188
+ * await git.getTags("v"); // ["v1.0.2", "v1.0.1", "v1.0.0"]
189
+ *
190
+ * // Given the following git log: (HEAD -> main, tag: v1.0.2-0, tag: v1.0.1-0, tag: v1.0.0)
191
+ * await git.getTags("v", true); // ["v1.0.2-0", "v1.0.1-0", "v1.0.0"]
191
192
  *
192
- * chore(release): v1.0.0
193
+ * // Given the following git log: (HEAD -> main, tag: v1.0.2-alpha.0, tag: v1.0.1-alpha.0, tag: v1.0.0)
194
+ * await git.getTags("v", "alpha"); // ["v1.0.2-alpha.0", "v1.0.1-alpha.0", "v1.0.0"]
193
195
  * ```
194
196
  *
195
197
  * - [Functionality extracted from the conventional-changelog - git-semver-tags project](https://github.com/conventional-changelog/conventional-changelog/blob/fac8045242099c016f5f3905e54e02b7d466bd7b/packages/git-semver-tags/index.js)
196
198
  * - [conventional-changelog git-semver-tags MIT Licence](https://github.com/conventional-changelog/conventional-changelog/blob/fac8045242099c016f5f3905e54e02b7d466bd7b/packages/git-semver-tags/LICENSE.md)
197
- *
198
- * @example
199
- * ```ts
200
- * await git.getTags("v"); // ["v1.0.2", "v1.0.1", "v1.0.0"]
201
- * ```
202
199
  */
203
200
  async getTags(tagPrefix, preRelease) {
204
- const logOutput = await this.log("--decorate", "--no-color", "--date-order");
201
+ const logOutput = await this.log("--format=%d", "--no-color", "--date-order");
205
202
  /**
206
203
  * Search for tags in the following formats:
207
204
  * @example "tag: 1.2.3," or "tag: 1.2.3)"
@@ -221,13 +218,14 @@ var Git = class {
221
218
  return tags;
222
219
  }
223
220
  /**
224
- * Get commit history in a parsable format
221
+ * Returns an array of commits between two git references (e.g., tags, branches, or commits), optionally filtered by file paths.
225
222
  *
226
- * An array of strings with commit details is returned in the following format:
223
+ * Each commit in the returned array is a string containing the following information, separated by newlines:
227
224
  * ```txt
228
225
  * subject
229
226
  * body
230
227
  * hash
228
+ * ref names
231
229
  * committer date
232
230
  * committer name
233
231
  * committer email
@@ -235,6 +233,7 @@ var Git = class {
235
233
  *
236
234
  * @example
237
235
  * ```ts
236
+ * await git.getCommits("v1.0.0", "HEAD");
238
237
  * await git.getCommits("v1.0.0", "HEAD", "src/utils");
239
238
  * ```
240
239
  */
@@ -250,7 +249,7 @@ var Git = class {
250
249
  "%cE",
251
250
  SCISSOR
252
251
  ].join("%n");
253
- const splitCommits = (await this.log(`--format=${LOG_FORMAT}`, [from, to].filter(Boolean).join(".."), paths.length ? "--" : "", ...paths)).split(`\n${SCISSOR}\n`);
252
+ const splitCommits = (await this.log(`--format=${LOG_FORMAT}`, "--no-color", "--date-order", [from, to].filter(Boolean).join(".."), paths.length ? "--" : "", ...paths)).split(`\n${SCISSOR}\n`);
254
253
  if (splitCommits.length === 0) return splitCommits;
255
254
  if (splitCommits[0] === SCISSOR) splitCommits.shift();
256
255
  if (splitCommits[splitCommits.length - 1] === "") splitCommits.pop();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "fork-version",
3
- "version": "5.1.3",
3
+ "version": "5.1.5",
4
4
  "license": "MIT",
5
5
  "description": "Fork-Version automates version control tasks such as determining, updating, and committing versions, files, and changelogs, simplifying the process when adhering to the conventional commit standard.",
6
6
  "keywords": [