fork-version 5.1.0 → 5.1.2
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 +22 -0
- package/README.md +9 -3
- package/dist/files/file-manager.d.ts +1 -0
- package/dist/files/file-manager.js +13 -2
- package/dist/files/yaml-package.js +5 -24
- package/dist/utils/extract-build-metadata.js +37 -0
- package/package.json +2 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
1
|
# Fork Version
|
|
2
2
|
|
|
3
|
+
## [5.1.2](https://github.com/eglavin/fork-version/compare/v5.1.1...v5.1.2) (2026-04-13)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Refactor
|
|
7
|
+
|
|
8
|
+
* remove pnpm from engines ([6902123](https://github.com/eglavin/fork-version/commit/69021234530b1fb6e88c56d1b036c81962b19cf2))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
## [5.1.1](https://github.com/eglavin/fork-version/compare/v5.1.0...v5.1.1) (2026-04-12)
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
### Docs
|
|
15
|
+
|
|
16
|
+
* add all files and custom file manager examples ([43c85a4](https://github.com/eglavin/fork-version/commit/43c85a482906f73c7b45a28a522bec150b3f2cff))
|
|
17
|
+
* update build metadata info in readme ([e03c362](https://github.com/eglavin/fork-version/commit/e03c362094b7f0685fd386c7754f705a4d727472))
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Refactor
|
|
21
|
+
|
|
22
|
+
* move build metadata out of yaml class ([59627fc](https://github.com/eglavin/fork-version/commit/59627fc903bcd5aae1b44954fd6183417025a2f3))
|
|
23
|
+
|
|
24
|
+
|
|
3
25
|
## [5.1.0](https://github.com/eglavin/fork-version/compare/v5.0.2...v5.1.0) (2026-04-11)
|
|
4
26
|
|
|
5
27
|
|
package/README.md
CHANGED
|
@@ -472,6 +472,15 @@ If you are using one of the following Git hosts, Fork-Version will automatically
|
|
|
472
472
|
- [Install Shield ISM](#install-shield-ism)
|
|
473
473
|
- [Custom File Updater's](#custom-file-updaters)
|
|
474
474
|
|
|
475
|
+
> [!Note]
|
|
476
|
+
> If your version strings include build metadata like one of the following examples:
|
|
477
|
+
>
|
|
478
|
+
> - 1.2.3+49a3f2b
|
|
479
|
+
> - 1.2.3-0+49a3f2b
|
|
480
|
+
> - 1.2.3-alpha.0+49a3f2b
|
|
481
|
+
>
|
|
482
|
+
> this metadata will be retained without modification.
|
|
483
|
+
|
|
475
484
|
#### Json Package
|
|
476
485
|
|
|
477
486
|
A json package is a json file which contains a version property, such as a npm package.json file.
|
|
@@ -495,9 +504,6 @@ publish_to: 'none'
|
|
|
495
504
|
version: 1.2.3
|
|
496
505
|
```
|
|
497
506
|
|
|
498
|
-
> [!NOTE]
|
|
499
|
-
> If you're using Fork-Version for a flutter project, Fork-Version will split the version and the builder number on the "+" character, the version will be updated and the builder number will be left as is.
|
|
500
|
-
|
|
501
507
|
#### Plain Text
|
|
502
508
|
|
|
503
509
|
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.
|
|
@@ -5,6 +5,7 @@ import { PlainText } from "./plain-text.js";
|
|
|
5
5
|
import { MSBuildProject } from "./ms-build-project.js";
|
|
6
6
|
import { ARMBicep } from "./arm-bicep.js";
|
|
7
7
|
import { InstallShieldISM } from "./install-shield-ism.js";
|
|
8
|
+
import { extractBuildMetadata } from "../utils/extract-build-metadata.js";
|
|
8
9
|
import { isAbsolute, relative, resolve } from "node:path";
|
|
9
10
|
//#region src/files/file-manager.ts
|
|
10
11
|
/**
|
|
@@ -57,7 +58,15 @@ var FileManager = class {
|
|
|
57
58
|
if (!fileExists(filePath)) return;
|
|
58
59
|
for (const fileManager of this.#fileManagers) if (fileManager.isSupportedFile(fileNameLower)) {
|
|
59
60
|
try {
|
|
60
|
-
|
|
61
|
+
const fileState = await fileManager.read(filePath);
|
|
62
|
+
if (fileState) {
|
|
63
|
+
const { version, buildMetadata } = extractBuildMetadata(fileState.version);
|
|
64
|
+
if (buildMetadata) {
|
|
65
|
+
fileState.version = version;
|
|
66
|
+
fileState.buildMetadata = buildMetadata;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
return fileState;
|
|
61
70
|
} catch (error) {
|
|
62
71
|
if (error instanceof MissingPropertyException) this.#logger.warn(`[File Manager] Missing '${error.propertyName}' property in ${error.fileType} file: ${relativePath}`);
|
|
63
72
|
else throw new Error(`An unexpected error occurred while reading file: ${filePath}`, { cause: error });
|
|
@@ -81,7 +90,9 @@ var FileManager = class {
|
|
|
81
90
|
if (this.#config.dryRun) return;
|
|
82
91
|
const relativePath = relative(this.#config.path, fileState.path);
|
|
83
92
|
const fileNameLower = relativePath.toLocaleLowerCase();
|
|
84
|
-
|
|
93
|
+
let updatedVersion = newVersion;
|
|
94
|
+
if (fileState?.buildMetadata) updatedVersion += `+${fileState.buildMetadata}`;
|
|
95
|
+
for (const fileManager of this.#fileManagers) if (fileManager.isSupportedFile(fileNameLower)) return await fileManager.write(fileState, updatedVersion);
|
|
85
96
|
this.#logger.error(`[File Manager] Unsupported file: ${relativePath}`);
|
|
86
97
|
}
|
|
87
98
|
};
|
|
@@ -15,36 +15,17 @@ import { parse, parseDocument } from "yaml";
|
|
|
15
15
|
* ```
|
|
16
16
|
*/
|
|
17
17
|
var YAMLPackage = class {
|
|
18
|
-
/**
|
|
19
|
-
* If the version is returned with a "+" symbol in the value then the version might be from a
|
|
20
|
-
* flutter `pubspec.yaml` file, if so we want to retain the input builderNumber by splitting it
|
|
21
|
-
* and joining it again later.
|
|
22
|
-
*/
|
|
23
|
-
#handleBuildNumber(fileVersion) {
|
|
24
|
-
const [version, builderNumber] = fileVersion.split("+");
|
|
25
|
-
if (/^\d+$/.test(builderNumber)) return {
|
|
26
|
-
version,
|
|
27
|
-
builderNumber
|
|
28
|
-
};
|
|
29
|
-
return { version: fileVersion };
|
|
30
|
-
}
|
|
31
18
|
async read(filePath) {
|
|
32
19
|
const fileVersion = parse(await readFile(filePath, "utf8"))?.version;
|
|
33
|
-
if (fileVersion) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
version: parsedVersion.version || "",
|
|
38
|
-
builderNumber: parsedVersion.builderNumber ?? void 0
|
|
39
|
-
};
|
|
40
|
-
}
|
|
20
|
+
if (fileVersion) return {
|
|
21
|
+
path: filePath,
|
|
22
|
+
version: fileVersion
|
|
23
|
+
};
|
|
41
24
|
throw new MissingPropertyException("YAML", "version");
|
|
42
25
|
}
|
|
43
26
|
async write(fileState, newVersion) {
|
|
44
27
|
const yamlDocument = parseDocument(await readFile(fileState.path, "utf8"));
|
|
45
|
-
|
|
46
|
-
if (fileState.builderNumber !== void 0) newFileVersion += `+${fileState.builderNumber}`;
|
|
47
|
-
yamlDocument.set("version", newFileVersion);
|
|
28
|
+
yamlDocument.set("version", newVersion);
|
|
48
29
|
await writeFile(fileState.path, yamlDocument.toString(), "utf8");
|
|
49
30
|
}
|
|
50
31
|
isSupportedFile(fileName) {
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
//#region src/utils/extract-build-metadata.ts
|
|
2
|
+
/**
|
|
3
|
+
* This function is used to separate build metadata from the version string.
|
|
4
|
+
* Build metadata is denoted by a plus sign (`+`) followed by a string of characters.
|
|
5
|
+
*
|
|
6
|
+
* Example version strings including build metadata:
|
|
7
|
+
* - `1.2.3+49a3f2b`
|
|
8
|
+
* - `1.2.3-0+49a3f2b`
|
|
9
|
+
* - `1.2.3-alpha.0+49a3f2b`
|
|
10
|
+
*
|
|
11
|
+
* In the above examples, the build metadata is `+49a3f2b`, which should be
|
|
12
|
+
* ignored when determining the next version.
|
|
13
|
+
*
|
|
14
|
+
* @param version The version string to extract build metadata from.
|
|
15
|
+
* @return Both the version string without build metadata and the extracted build metadata (if any).
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```ts
|
|
19
|
+
* const versionWithMetadata = "1.2.3+49a3f2b";
|
|
20
|
+
* const { version, buildMetadata } = extractBuildMetadata(versionWithMetadata);
|
|
21
|
+
* console.log(version); // Output: "1.2.3"
|
|
22
|
+
* console.log(buildMetadata); // Output: "49a3f2b"
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
function extractBuildMetadata(version) {
|
|
26
|
+
const plusIndex = version.indexOf("+");
|
|
27
|
+
if (plusIndex === -1) return {
|
|
28
|
+
version,
|
|
29
|
+
buildMetadata: void 0
|
|
30
|
+
};
|
|
31
|
+
return {
|
|
32
|
+
version: version.substring(0, plusIndex),
|
|
33
|
+
buildMetadata: version.substring(plusIndex + 1) || void 0
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
//#endregion
|
|
37
|
+
export { extractBuildMetadata };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fork-version",
|
|
3
|
-
"version": "5.1.
|
|
3
|
+
"version": "5.1.2",
|
|
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": [
|
|
@@ -30,8 +30,7 @@
|
|
|
30
30
|
},
|
|
31
31
|
"packageManager": "pnpm@10.30.3",
|
|
32
32
|
"engines": {
|
|
33
|
-
"node": ">=22.0.0"
|
|
34
|
-
"pnpm": ">=10.0.0"
|
|
33
|
+
"node": ">=22.0.0"
|
|
35
34
|
},
|
|
36
35
|
"private": false,
|
|
37
36
|
"type": "module",
|