fork-version 5.0.0 → 5.0.1
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 +9 -0
- package/dist/files/arm-bicep.js +4 -10
- package/dist/files/file-manager.d.ts +10 -1
- package/dist/files/file-manager.js +31 -9
- package/dist/files/install-shield-ism.js +3 -7
- package/dist/files/json-package.js +3 -7
- package/dist/files/ms-build-project.js +3 -7
- package/dist/files/plain-text.js +3 -7
- package/dist/files/yaml-package.js +3 -7
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
1
|
# Fork Version
|
|
2
2
|
|
|
3
|
+
## [5.0.1](https://github.com/eglavin/fork-version/compare/v5.0.0...v5.0.1) (2026-04-10)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Refactor
|
|
7
|
+
|
|
8
|
+
* remove logger from file manager classes ([7800d8b](https://github.com/eglavin/fork-version/commit/7800d8b29fd959f82216ee7061ce5fb44a883368))
|
|
9
|
+
* show file name in the missing property exception log ([f7c80fc](https://github.com/eglavin/fork-version/commit/f7c80fcaeadaba897f637619931562f82cc9a707))
|
|
10
|
+
|
|
11
|
+
|
|
3
12
|
## [5.0.0](https://github.com/eglavin/fork-version/compare/v4.1.10...v5.0.0) (2026-04-09)
|
|
4
13
|
|
|
5
14
|
|
package/dist/files/arm-bicep.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { MissingPropertyException } from "./file-manager.js";
|
|
1
2
|
import { basename } from "node:path";
|
|
2
3
|
import { readFileSync, writeFileSync } from "node:fs";
|
|
3
4
|
//#region src/files/arm-bicep.ts
|
|
@@ -11,26 +12,19 @@ import { readFileSync, writeFileSync } from "node:fs";
|
|
|
11
12
|
* ```
|
|
12
13
|
*/
|
|
13
14
|
var ARMBicep = class {
|
|
14
|
-
#logger;
|
|
15
|
-
constructor(logger) {
|
|
16
|
-
this.#logger = logger;
|
|
17
|
-
}
|
|
18
15
|
/** https://regex101.com/r/Lriphb/2 */
|
|
19
16
|
#metadataRegex = /(metadata contentVersion *= *['"])(?<version>[^'"]+)(['"])/;
|
|
20
17
|
/** https://regex101.com/r/iKCTF9/1 */
|
|
21
18
|
#varRegex = /(var contentVersion(?: string)? *= *['"])(?<version>[^'"]+)(['"])/;
|
|
22
19
|
read(filePath) {
|
|
23
|
-
const fileName = basename(filePath);
|
|
24
20
|
const fileContents = readFileSync(filePath, "utf8");
|
|
25
21
|
const metadataMatch = this.#metadataRegex.exec(fileContents);
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
name: fileName,
|
|
22
|
+
if (metadataMatch?.groups?.version) return {
|
|
23
|
+
name: basename(filePath),
|
|
29
24
|
path: filePath,
|
|
30
25
|
version: metadataMatch.groups.version
|
|
31
26
|
};
|
|
32
|
-
|
|
33
|
-
if (!varMatch) this.#logger.warn(`[File Manager] Missing 'var contentVersion' in bicep file: ${fileName}`);
|
|
27
|
+
throw new MissingPropertyException("ARM Bicep", "metadata contentVersion");
|
|
34
28
|
}
|
|
35
29
|
write(fileState, newVersion) {
|
|
36
30
|
const updatedContent = readFileSync(fileState.path, "utf8").replace(this.#metadataRegex, `$1${newVersion}$3`).replace(this.#varRegex, `$1${newVersion}$3`);
|
|
@@ -2,6 +2,15 @@ import { ForkConfig } from "../config/types.js";
|
|
|
2
2
|
import { Logger } from "../services/logger.js";
|
|
3
3
|
|
|
4
4
|
//#region src/files/file-manager.d.ts
|
|
5
|
+
/**
|
|
6
|
+
* Exception thrown if a file manager encounters a file missing a required property,
|
|
7
|
+
* such as the "version" property in a JSON package file.
|
|
8
|
+
*/
|
|
9
|
+
declare class MissingPropertyException extends Error {
|
|
10
|
+
fileType: string;
|
|
11
|
+
propertyName: string;
|
|
12
|
+
constructor(fileType: string, propertyName: string);
|
|
13
|
+
}
|
|
5
14
|
interface FileState {
|
|
6
15
|
name: string;
|
|
7
16
|
path: string;
|
|
@@ -44,4 +53,4 @@ declare class FileManager {
|
|
|
44
53
|
write(fileState: FileState, newVersion: string): void;
|
|
45
54
|
}
|
|
46
55
|
//#endregion
|
|
47
|
-
export { FileManager, FileState, IFileManager };
|
|
56
|
+
export { FileManager, FileState, IFileManager, MissingPropertyException };
|
|
@@ -5,8 +5,22 @@ 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 { isAbsolute, resolve } from "node:path";
|
|
8
|
+
import { basename, isAbsolute, resolve } from "node:path";
|
|
9
9
|
//#region src/files/file-manager.ts
|
|
10
|
+
/**
|
|
11
|
+
* Exception thrown if a file manager encounters a file missing a required property,
|
|
12
|
+
* such as the "version" property in a JSON package file.
|
|
13
|
+
*/
|
|
14
|
+
var MissingPropertyException = class extends Error {
|
|
15
|
+
fileType;
|
|
16
|
+
propertyName;
|
|
17
|
+
constructor(fileType, propertyName) {
|
|
18
|
+
super(`Missing '${propertyName}' property in ${fileType}`);
|
|
19
|
+
this.name = "MissingPropertyException";
|
|
20
|
+
this.fileType = fileType;
|
|
21
|
+
this.propertyName = propertyName;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
10
24
|
var FileManager = class {
|
|
11
25
|
#config;
|
|
12
26
|
#logger;
|
|
@@ -15,12 +29,12 @@ var FileManager = class {
|
|
|
15
29
|
this.#config = config;
|
|
16
30
|
this.#logger = logger;
|
|
17
31
|
this.#fileManagers = [
|
|
18
|
-
new JSONPackage(
|
|
19
|
-
new YAMLPackage(
|
|
20
|
-
new PlainText(
|
|
21
|
-
new MSBuildProject(
|
|
22
|
-
new ARMBicep(
|
|
23
|
-
new InstallShieldISM(
|
|
32
|
+
new JSONPackage(),
|
|
33
|
+
new YAMLPackage(),
|
|
34
|
+
new PlainText(),
|
|
35
|
+
new MSBuildProject(),
|
|
36
|
+
new ARMBicep(),
|
|
37
|
+
new InstallShieldISM()
|
|
24
38
|
];
|
|
25
39
|
}
|
|
26
40
|
/**
|
|
@@ -40,7 +54,15 @@ var FileManager = class {
|
|
|
40
54
|
const _fileName = pathOrName.toLowerCase();
|
|
41
55
|
const filePath = isAbsolute(pathOrName) ? pathOrName : resolve(this.#config.path, pathOrName);
|
|
42
56
|
if (!fileExists(filePath)) return;
|
|
43
|
-
for (const fileManager of this.#fileManagers) if (fileManager.isSupportedFile(_fileName))
|
|
57
|
+
for (const fileManager of this.#fileManagers) if (fileManager.isSupportedFile(_fileName)) {
|
|
58
|
+
try {
|
|
59
|
+
return fileManager.read(filePath);
|
|
60
|
+
} catch (error) {
|
|
61
|
+
if (error instanceof MissingPropertyException) this.#logger.warn(`[File Manager] Missing '${error.propertyName}' property in ${error.fileType} file: ${basename(_fileName)}`);
|
|
62
|
+
else throw new Error(`An unexpected error occurred while reading file: ${filePath}`, { cause: error });
|
|
63
|
+
}
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
44
66
|
this.#logger.error(`[File Manager] Unsupported file: ${pathOrName}`);
|
|
45
67
|
}
|
|
46
68
|
/**
|
|
@@ -62,4 +84,4 @@ var FileManager = class {
|
|
|
62
84
|
}
|
|
63
85
|
};
|
|
64
86
|
//#endregion
|
|
65
|
-
export { FileManager };
|
|
87
|
+
export { FileManager, MissingPropertyException };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { MissingPropertyException } from "./file-manager.js";
|
|
1
2
|
import { basename } from "node:path";
|
|
2
3
|
import { readFileSync, writeFileSync } from "node:fs";
|
|
3
4
|
import * as cheerio from "cheerio/slim";
|
|
@@ -24,24 +25,19 @@ import * as cheerio from "cheerio/slim";
|
|
|
24
25
|
* ```
|
|
25
26
|
*/
|
|
26
27
|
var InstallShieldISM = class {
|
|
27
|
-
#logger;
|
|
28
|
-
constructor(logger) {
|
|
29
|
-
this.#logger = logger;
|
|
30
|
-
}
|
|
31
28
|
#cheerioOptions = {
|
|
32
29
|
xmlMode: true,
|
|
33
30
|
xml: { decodeEntities: false }
|
|
34
31
|
};
|
|
35
32
|
read(filePath) {
|
|
36
|
-
const fileName = basename(filePath);
|
|
37
33
|
const fileContents = readFileSync(filePath, "utf8");
|
|
38
34
|
const version = cheerio.load(fileContents, this.#cheerioOptions)("msi > table[name=\"Property\"] > row > td:contains(\"ProductVersion\")").next().text().trim();
|
|
39
35
|
if (version) return {
|
|
40
|
-
name:
|
|
36
|
+
name: basename(filePath),
|
|
41
37
|
path: filePath,
|
|
42
38
|
version
|
|
43
39
|
};
|
|
44
|
-
|
|
40
|
+
throw new MissingPropertyException("InstallShield ISM", "ProductVersion");
|
|
45
41
|
}
|
|
46
42
|
write(fileState, newVersion) {
|
|
47
43
|
const fileContents = readFileSync(fileState.path, "utf8");
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { MissingPropertyException } from "./file-manager.js";
|
|
1
2
|
import { basename } from "node:path";
|
|
2
3
|
import { readFileSync, writeFileSync } from "node:fs";
|
|
3
4
|
import { applyEdits, modify, parse as parse$1 } from "jsonc-parser";
|
|
@@ -16,10 +17,6 @@ import { applyEdits, modify, parse as parse$1 } from "jsonc-parser";
|
|
|
16
17
|
* ```
|
|
17
18
|
*/
|
|
18
19
|
var JSONPackage = class {
|
|
19
|
-
#logger;
|
|
20
|
-
constructor(logger) {
|
|
21
|
-
this.#logger = logger;
|
|
22
|
-
}
|
|
23
20
|
/** Options for parsing JSON and JSONC files. */
|
|
24
21
|
#jsoncOptions = {
|
|
25
22
|
allowEmptyContent: false,
|
|
@@ -37,17 +34,16 @@ var JSONPackage = class {
|
|
|
37
34
|
return applyEdits(jsonc, modify(jsonc, jsonPath, newString, {}));
|
|
38
35
|
}
|
|
39
36
|
read(filePath) {
|
|
40
|
-
const fileName = basename(filePath);
|
|
41
37
|
const fileContents = readFileSync(filePath, "utf8");
|
|
42
38
|
const parseErrors = [];
|
|
43
39
|
const parsedJson = parse$1(fileContents, parseErrors, this.#jsoncOptions);
|
|
44
40
|
if (parsedJson?.version && parseErrors.length === 0) return {
|
|
45
|
-
name:
|
|
41
|
+
name: basename(filePath),
|
|
46
42
|
path: filePath,
|
|
47
43
|
version: parsedJson.version,
|
|
48
44
|
isPrivate: typeof parsedJson?.private === "boolean" ? parsedJson.private : true
|
|
49
45
|
};
|
|
50
|
-
|
|
46
|
+
throw new MissingPropertyException("JSON", "version");
|
|
51
47
|
}
|
|
52
48
|
write(fileState, newVersion) {
|
|
53
49
|
let fileContents = readFileSync(fileState.path, "utf8");
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { MissingPropertyException } from "./file-manager.js";
|
|
1
2
|
import { basename } from "node:path";
|
|
2
3
|
import { readFileSync, writeFileSync } from "node:fs";
|
|
3
4
|
import * as cheerio from "cheerio/slim";
|
|
@@ -17,24 +18,19 @@ import * as cheerio from "cheerio/slim";
|
|
|
17
18
|
* ```
|
|
18
19
|
*/
|
|
19
20
|
var MSBuildProject = class {
|
|
20
|
-
#logger;
|
|
21
|
-
constructor(logger) {
|
|
22
|
-
this.#logger = logger;
|
|
23
|
-
}
|
|
24
21
|
#cheerioOptions = {
|
|
25
22
|
xmlMode: true,
|
|
26
23
|
xml: { decodeEntities: false }
|
|
27
24
|
};
|
|
28
25
|
read(filePath) {
|
|
29
|
-
const fileName = basename(filePath);
|
|
30
26
|
const fileContents = readFileSync(filePath, "utf8");
|
|
31
27
|
const version = cheerio.load(fileContents, this.#cheerioOptions)("Project > PropertyGroup > Version").text();
|
|
32
28
|
if (version) return {
|
|
33
|
-
name:
|
|
29
|
+
name: basename(filePath),
|
|
34
30
|
path: filePath,
|
|
35
31
|
version
|
|
36
32
|
};
|
|
37
|
-
|
|
33
|
+
throw new MissingPropertyException("MSBuild", "Version");
|
|
38
34
|
}
|
|
39
35
|
write(fileState, newVersion) {
|
|
40
36
|
const fileContents = readFileSync(fileState.path, "utf8");
|
package/dist/files/plain-text.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { MissingPropertyException } from "./file-manager.js";
|
|
1
2
|
import { basename } from "node:path";
|
|
2
3
|
import { readFileSync, writeFileSync } from "node:fs";
|
|
3
4
|
//#region src/files/plain-text.ts
|
|
@@ -10,19 +11,14 @@ import { readFileSync, writeFileSync } from "node:fs";
|
|
|
10
11
|
* ```
|
|
11
12
|
*/
|
|
12
13
|
var PlainText = class {
|
|
13
|
-
#logger;
|
|
14
|
-
constructor(logger) {
|
|
15
|
-
this.#logger = logger;
|
|
16
|
-
}
|
|
17
14
|
read(filePath) {
|
|
18
|
-
const fileName = basename(filePath);
|
|
19
15
|
const fileContents = readFileSync(filePath, "utf8").trim();
|
|
20
16
|
if (fileContents) return {
|
|
21
|
-
name:
|
|
17
|
+
name: basename(filePath),
|
|
22
18
|
path: filePath,
|
|
23
19
|
version: fileContents
|
|
24
20
|
};
|
|
25
|
-
|
|
21
|
+
throw new MissingPropertyException("Plain Text", "version");
|
|
26
22
|
}
|
|
27
23
|
write(fileState, newVersion) {
|
|
28
24
|
writeFileSync(fileState.path, newVersion, "utf8");
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { MissingPropertyException } from "./file-manager.js";
|
|
1
2
|
import { basename } from "node:path";
|
|
2
3
|
import { readFileSync, writeFileSync } from "node:fs";
|
|
3
4
|
import { parse as parse$1, parseDocument } from "yaml";
|
|
@@ -15,10 +16,6 @@ import { parse as parse$1, parseDocument } from "yaml";
|
|
|
15
16
|
* ```
|
|
16
17
|
*/
|
|
17
18
|
var YAMLPackage = class {
|
|
18
|
-
#logger;
|
|
19
|
-
constructor(logger) {
|
|
20
|
-
this.#logger = logger;
|
|
21
|
-
}
|
|
22
19
|
/**
|
|
23
20
|
* If the version is returned with a "+" symbol in the value then the version might be from a
|
|
24
21
|
* flutter `pubspec.yaml` file, if so we want to retain the input builderNumber by splitting it
|
|
@@ -33,18 +30,17 @@ var YAMLPackage = class {
|
|
|
33
30
|
return { version: fileVersion };
|
|
34
31
|
}
|
|
35
32
|
read(filePath) {
|
|
36
|
-
const fileName = basename(filePath);
|
|
37
33
|
const fileVersion = parse$1(readFileSync(filePath, "utf-8"))?.version;
|
|
38
34
|
if (fileVersion) {
|
|
39
35
|
const parsedVersion = this.#handleBuildNumber(fileVersion);
|
|
40
36
|
return {
|
|
41
|
-
name:
|
|
37
|
+
name: basename(filePath),
|
|
42
38
|
path: filePath,
|
|
43
39
|
version: parsedVersion.version || "",
|
|
44
40
|
builderNumber: parsedVersion.builderNumber ?? void 0
|
|
45
41
|
};
|
|
46
42
|
}
|
|
47
|
-
|
|
43
|
+
throw new MissingPropertyException("YAML", "version");
|
|
48
44
|
}
|
|
49
45
|
write(fileState, newVersion) {
|
|
50
46
|
const yamlDocument = parseDocument(readFileSync(fileState.path, "utf8"));
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ParserOptions, createParserOptions } from "./commit-parser/options.js";
|
|
2
2
|
import { ChangelogPresetConfig, ChangelogPresetConfigType, Config, ForkConfig } from "./config/types.js";
|
|
3
3
|
import { Logger } from "./services/logger.js";
|
|
4
|
-
import { FileManager, FileState, IFileManager } from "./files/file-manager.js";
|
|
4
|
+
import { FileManager, FileState, IFileManager, MissingPropertyException } from "./files/file-manager.js";
|
|
5
5
|
import { Git } from "./services/git.js";
|
|
6
6
|
import { inspect } from "./commands/inspect.js";
|
|
7
7
|
import { main } from "./commands/main.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, ForkConfigSchema, Git, type IFileManager, Logger, 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, ForkConfigSchema, Git, type IFileManager, Logger, MissingPropertyException, type NextVersion, type ParserOptions, commitChanges, createParserOptions, defineConfig, filterRevertedCommits, getCommitsSinceTag, getCurrentVersion, getNextVersion, getUserConfig, inspect, main, tagChanges, updateChangelog, validateConfig };
|
package/dist/index.js
CHANGED
|
@@ -14,6 +14,6 @@ import { ForkConfigSchema } 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 } from "./files/file-manager.js";
|
|
17
|
+
import { FileManager, MissingPropertyException } from "./files/file-manager.js";
|
|
18
18
|
import { Logger } from "./services/logger.js";
|
|
19
|
-
export { CommitParser, FileManager, ForkConfigSchema, Git, Logger, commitChanges, createParserOptions, defineConfig, filterRevertedCommits, getCommitsSinceTag, getCurrentVersion, getNextVersion, getUserConfig, inspect, main, tagChanges, updateChangelog, validateConfig };
|
|
19
|
+
export { CommitParser, FileManager, ForkConfigSchema, Git, Logger, MissingPropertyException, commitChanges, createParserOptions, defineConfig, filterRevertedCommits, getCommitsSinceTag, getCurrentVersion, getNextVersion, getUserConfig, inspect, main, tagChanges, updateChangelog, validateConfig };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fork-version",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.1",
|
|
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": [
|