fork-version 4.1.9 → 5.0.0

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.
Files changed (81) hide show
  1. package/CHANGELOG.md +19 -0
  2. package/dist/cli.d.ts +1 -1
  3. package/dist/cli.js +54 -193
  4. package/dist/commands/inspect.d.ts +9 -0
  5. package/dist/commands/inspect.js +41 -0
  6. package/dist/commands/main.d.ts +16 -0
  7. package/dist/commands/main.js +30 -0
  8. package/dist/commands/validate-config.d.ts +6 -0
  9. package/dist/commands/validate-config.js +11 -0
  10. package/dist/commit-parser/commit-parser.d.ts +114 -0
  11. package/dist/commit-parser/commit-parser.js +327 -0
  12. package/dist/commit-parser/filter-reverted-commits.d.ts +17 -0
  13. package/dist/commit-parser/filter-reverted-commits.js +34 -0
  14. package/dist/commit-parser/options.d.ts +74 -0
  15. package/dist/commit-parser/options.js +70 -0
  16. package/dist/commit-parser/parser-error.js +14 -0
  17. package/dist/commit-parser/types.d.ts +53 -0
  18. package/dist/config/changelog-preset-config.js +41 -0
  19. package/dist/config/cli-arguments.d.ts +109 -0
  20. package/dist/config/cli-arguments.js +141 -0
  21. package/dist/config/defaults.js +38 -0
  22. package/dist/config/define-config.d.ts +9 -0
  23. package/dist/config/define-config.js +9 -0
  24. package/dist/config/load-config.js +45 -0
  25. package/dist/config/merge-files.js +12 -0
  26. package/dist/config/schema.d.ts +50 -0
  27. package/dist/config/schema.js +61 -0
  28. package/dist/config/types.d.ts +279 -0
  29. package/dist/config/user-config.d.ts +6 -0
  30. package/dist/config/user-config.js +50 -0
  31. package/dist/detect-git-host/detect-git-host.js +35 -0
  32. package/dist/detect-git-host/host-azure-devops.js +28 -0
  33. package/dist/detect-git-host/host-bitbucket.js +28 -0
  34. package/dist/detect-git-host/host-github.js +32 -0
  35. package/dist/detect-git-host/host-gitlab.js +48 -0
  36. package/dist/files/arm-bicep.js +44 -0
  37. package/dist/files/file-manager.d.ts +47 -0
  38. package/dist/files/file-manager.js +65 -0
  39. package/dist/files/install-shield-ism.js +59 -0
  40. package/dist/files/json-package.js +68 -0
  41. package/dist/files/ms-build-project.js +59 -0
  42. package/dist/files/plain-text.js +35 -0
  43. package/dist/files/yaml-package.js +61 -0
  44. package/dist/index.d.ts +21 -646
  45. package/dist/index.js +19 -10
  46. package/dist/process/changelog.d.ts +7 -0
  47. package/dist/process/changelog.js +69 -0
  48. package/dist/process/commit.d.ts +9 -0
  49. package/dist/process/commit.js +22 -0
  50. package/dist/process/get-commits.d.ts +14 -0
  51. package/dist/process/get-commits.js +25 -0
  52. package/dist/process/get-current-version.d.ts +13 -0
  53. package/dist/process/get-current-version.js +35 -0
  54. package/dist/process/get-next-version.d.ts +21 -0
  55. package/dist/process/get-next-version.js +72 -0
  56. package/dist/process/tag.d.ts +8 -0
  57. package/dist/process/tag.js +15 -0
  58. package/dist/services/git.d.ts +141 -0
  59. package/dist/services/git.js +236 -0
  60. package/dist/services/logger.d.ts +18 -0
  61. package/dist/services/logger.js +35 -0
  62. package/dist/utils/clean-tag.js +21 -0
  63. package/dist/utils/escape-regex.js +17 -0
  64. package/dist/utils/file-state.js +19 -0
  65. package/dist/utils/format-commit-message.js +13 -0
  66. package/dist/utils/parse-regexp-string.js +31 -0
  67. package/dist/utils/release-type.js +47 -0
  68. package/dist/utils/trim-string-array.js +20 -0
  69. package/package.json +11 -29
  70. package/dist/chunk-KRGBUNRK.cjs +0 -2264
  71. package/dist/chunk-KRGBUNRK.cjs.map +0 -1
  72. package/dist/chunk-X4NB24VR.js +0 -2220
  73. package/dist/chunk-X4NB24VR.js.map +0 -1
  74. package/dist/cli.cjs +0 -205
  75. package/dist/cli.cjs.map +0 -1
  76. package/dist/cli.d.cts +0 -1
  77. package/dist/cli.js.map +0 -1
  78. package/dist/index.cjs +0 -80
  79. package/dist/index.cjs.map +0 -1
  80. package/dist/index.d.cts +0 -646
  81. package/dist/index.js.map +0 -1
@@ -0,0 +1,59 @@
1
+ import { basename } from "node:path";
2
+ import { readFileSync, writeFileSync } from "node:fs";
3
+ import * as cheerio from "cheerio/slim";
4
+ //#region src/files/install-shield-ism.ts
5
+ /**
6
+ * An InstallShield ISM file can be either XML or binary, only the XML format is supported
7
+ * by this file manager. The XML format typically contains a "Property" table with a
8
+ * "ProductVersion" property.
9
+ *
10
+ * @example
11
+ * ```xml
12
+ * <?xml version="1.0" encoding="UTF-8" standalone="yes"?>
13
+ * <?xml-stylesheet type="text/xsl" href="is.xsl" ?>
14
+ * <!DOCTYPE msi [
15
+ * ...
16
+ * ]>
17
+ * <msi version="2.0" xmlns:dt="urn:schemas-microsoft-com:datatypes">
18
+ *
19
+ * <table name="Property">
20
+ * <row><td>ProductVersion</td><td>1.2.3</td><td/></row>
21
+ * </table>
22
+ *
23
+ * </msi>
24
+ * ```
25
+ */
26
+ var InstallShieldISM = class {
27
+ #logger;
28
+ constructor(logger) {
29
+ this.#logger = logger;
30
+ }
31
+ #cheerioOptions = {
32
+ xmlMode: true,
33
+ xml: { decodeEntities: false }
34
+ };
35
+ read(filePath) {
36
+ const fileName = basename(filePath);
37
+ const fileContents = readFileSync(filePath, "utf8");
38
+ const version = cheerio.load(fileContents, this.#cheerioOptions)("msi > table[name=\"Property\"] > row > td:contains(\"ProductVersion\")").next().text().trim();
39
+ if (version) return {
40
+ name: fileName,
41
+ path: filePath,
42
+ version
43
+ };
44
+ this.#logger.warn(`[File Manager] Unable to determine InstallShield ISM version: ${fileName}`);
45
+ }
46
+ write(fileState, newVersion) {
47
+ const fileContents = readFileSync(fileState.path, "utf8");
48
+ const $ = cheerio.load(fileContents, this.#cheerioOptions);
49
+ const versionCell = $("msi > table[name=\"Property\"] > row > td:contains(\"ProductVersion\")").next();
50
+ if (versionCell.length > 0) versionCell.text(newVersion);
51
+ const updatedContent = $.xml().replaceAll("\"/>", "\" />");
52
+ writeFileSync(fileState.path, updatedContent, "utf8");
53
+ }
54
+ isSupportedFile(fileName) {
55
+ return fileName.endsWith(".ism");
56
+ }
57
+ };
58
+ //#endregion
59
+ export { InstallShieldISM };
@@ -0,0 +1,68 @@
1
+ import { basename } from "node:path";
2
+ import { readFileSync, writeFileSync } from "node:fs";
3
+ import { applyEdits, modify, parse as parse$1 } from "jsonc-parser";
4
+ //#region src/files/json-package.ts
5
+ /**
6
+ * A json package file should have a version property, like what can be seen
7
+ * in the package.json file in the root of this project.
8
+ *
9
+ * @example
10
+ * ```json
11
+ * {
12
+ * "name": "fork-version",
13
+ * "version": "1.2.3",
14
+ * "private": true,
15
+ * }
16
+ * ```
17
+ */
18
+ var JSONPackage = class {
19
+ #logger;
20
+ constructor(logger) {
21
+ this.#logger = logger;
22
+ }
23
+ /** Options for parsing JSON and JSONC files. */
24
+ #jsoncOptions = {
25
+ allowEmptyContent: false,
26
+ allowTrailingComma: true,
27
+ disallowComments: false
28
+ };
29
+ /**
30
+ * Sets a new string value at the given path in a JSON or JSONC string.
31
+ * @param jsonc the JSON or JSONC string (the contents of a file)
32
+ * @param jsonPath path to the value to set, as an array of segments
33
+ * @param newString string to set the value to
34
+ * @returns the JSON or JSONC string with the value set
35
+ */
36
+ #setStringInJsonc(jsonc, jsonPath, newString) {
37
+ return applyEdits(jsonc, modify(jsonc, jsonPath, newString, {}));
38
+ }
39
+ read(filePath) {
40
+ const fileName = basename(filePath);
41
+ const fileContents = readFileSync(filePath, "utf8");
42
+ const parseErrors = [];
43
+ const parsedJson = parse$1(fileContents, parseErrors, this.#jsoncOptions);
44
+ if (parsedJson?.version && parseErrors.length === 0) return {
45
+ name: fileName,
46
+ path: filePath,
47
+ version: parsedJson.version,
48
+ isPrivate: typeof parsedJson?.private === "boolean" ? parsedJson.private : true
49
+ };
50
+ this.#logger.warn(`[File Manager] Unable to determine json version: ${fileName}`);
51
+ }
52
+ write(fileState, newVersion) {
53
+ let fileContents = readFileSync(fileState.path, "utf8");
54
+ const parsedJson = parse$1(fileContents, [], this.#jsoncOptions);
55
+ fileContents = this.#setStringInJsonc(fileContents, ["version"], newVersion);
56
+ if (parsedJson?.packages?.[""]) fileContents = this.#setStringInJsonc(fileContents, [
57
+ "packages",
58
+ "",
59
+ "version"
60
+ ], newVersion);
61
+ writeFileSync(fileState.path, fileContents, "utf8");
62
+ }
63
+ isSupportedFile(fileName) {
64
+ return fileName.endsWith(".json") || fileName.endsWith(".jsonc");
65
+ }
66
+ };
67
+ //#endregion
68
+ export { JSONPackage };
@@ -0,0 +1,59 @@
1
+ import { basename } from "node:path";
2
+ import { readFileSync, writeFileSync } from "node:fs";
3
+ import * as cheerio from "cheerio/slim";
4
+ //#region src/files/ms-build-project.ts
5
+ /**
6
+ * A ms-build file is an xml file with a version property under the Project > PropertyGroup node.
7
+ *
8
+ * [Microsoft Learn - MSBuild Reference](https://learn.microsoft.com/en-us/visualstudio/msbuild/msbuild?view=vs-2022)
9
+ *
10
+ * @example
11
+ * ```xml
12
+ * <Project Sdk="Microsoft.NET.Sdk">
13
+ * <PropertyGroup>
14
+ * <Version>1.2.3</Version>
15
+ * </PropertyGroup>
16
+ * </Project>
17
+ * ```
18
+ */
19
+ var MSBuildProject = class {
20
+ #logger;
21
+ constructor(logger) {
22
+ this.#logger = logger;
23
+ }
24
+ #cheerioOptions = {
25
+ xmlMode: true,
26
+ xml: { decodeEntities: false }
27
+ };
28
+ read(filePath) {
29
+ const fileName = basename(filePath);
30
+ const fileContents = readFileSync(filePath, "utf8");
31
+ const version = cheerio.load(fileContents, this.#cheerioOptions)("Project > PropertyGroup > Version").text();
32
+ if (version) return {
33
+ name: fileName,
34
+ path: filePath,
35
+ version
36
+ };
37
+ this.#logger.warn(`[File Manager] Unable to determine ms-build version: ${fileName}`);
38
+ }
39
+ write(fileState, newVersion) {
40
+ const fileContents = readFileSync(fileState.path, "utf8");
41
+ const $ = cheerio.load(fileContents, this.#cheerioOptions);
42
+ $("Project > PropertyGroup > Version").text(newVersion);
43
+ const updatedContent = $.xml().replaceAll("\"/>", "\" />");
44
+ writeFileSync(fileState.path, updatedContent, "utf8");
45
+ }
46
+ isSupportedFile(fileName) {
47
+ return [
48
+ ".csproj",
49
+ ".dbproj",
50
+ ".esproj",
51
+ ".fsproj",
52
+ ".props",
53
+ ".vbproj",
54
+ ".vcxproj"
55
+ ].findIndex((ext) => fileName.endsWith(ext)) !== -1;
56
+ }
57
+ };
58
+ //#endregion
59
+ export { MSBuildProject };
@@ -0,0 +1,35 @@
1
+ import { basename } from "node:path";
2
+ import { readFileSync, writeFileSync } from "node:fs";
3
+ //#region src/files/plain-text.ts
4
+ /**
5
+ * A plain text file will have just the version as the content.
6
+ *
7
+ * @example
8
+ * ```txt
9
+ * 1.2.3
10
+ * ```
11
+ */
12
+ var PlainText = class {
13
+ #logger;
14
+ constructor(logger) {
15
+ this.#logger = logger;
16
+ }
17
+ read(filePath) {
18
+ const fileName = basename(filePath);
19
+ const fileContents = readFileSync(filePath, "utf8").trim();
20
+ if (fileContents) return {
21
+ name: fileName,
22
+ path: filePath,
23
+ version: fileContents
24
+ };
25
+ this.#logger.warn(`[File Manager] Unable to determine plain text version: ${fileName}`);
26
+ }
27
+ write(fileState, newVersion) {
28
+ writeFileSync(fileState.path, newVersion, "utf8");
29
+ }
30
+ isSupportedFile(fileName) {
31
+ return fileName.endsWith("version.txt");
32
+ }
33
+ };
34
+ //#endregion
35
+ export { PlainText };
@@ -0,0 +1,61 @@
1
+ import { basename } from "node:path";
2
+ import { readFileSync, writeFileSync } from "node:fs";
3
+ import { parse as parse$1, parseDocument } from "yaml";
4
+ //#region src/files/yaml-package.ts
5
+ /**
6
+ * A yaml package file should have a version property on the top level, like what can be seen
7
+ * in [this example project](https://github.com/eglavin/wordionary/blob/01ae9b9d604cecdf9d320ed6028a727be5e5349e/pubspec.yaml#L19C1-L19C17).
8
+ *
9
+ * @example
10
+ * ```yaml
11
+ * name: wordionary
12
+ * description: "A Flutter project."
13
+ * publish_to: 'none'
14
+ * version: 1.2.3
15
+ * ```
16
+ */
17
+ var YAMLPackage = class {
18
+ #logger;
19
+ constructor(logger) {
20
+ this.#logger = logger;
21
+ }
22
+ /**
23
+ * If the version is returned with a "+" symbol in the value then the version might be from a
24
+ * flutter `pubspec.yaml` file, if so we want to retain the input builderNumber by splitting it
25
+ * and joining it again later.
26
+ */
27
+ #handleBuildNumber(fileVersion) {
28
+ const [version, builderNumber] = fileVersion.split("+");
29
+ if (/^\d+$/.test(builderNumber)) return {
30
+ version,
31
+ builderNumber
32
+ };
33
+ return { version: fileVersion };
34
+ }
35
+ read(filePath) {
36
+ const fileName = basename(filePath);
37
+ const fileVersion = parse$1(readFileSync(filePath, "utf-8"))?.version;
38
+ if (fileVersion) {
39
+ const parsedVersion = this.#handleBuildNumber(fileVersion);
40
+ return {
41
+ name: fileName,
42
+ path: filePath,
43
+ version: parsedVersion.version || "",
44
+ builderNumber: parsedVersion.builderNumber ?? void 0
45
+ };
46
+ }
47
+ this.#logger.warn(`[File Manager] Unable to determine yaml version: ${fileName}`);
48
+ }
49
+ write(fileState, newVersion) {
50
+ const yamlDocument = parseDocument(readFileSync(fileState.path, "utf8"));
51
+ let newFileVersion = newVersion;
52
+ if (fileState.builderNumber !== void 0) newFileVersion += `+${fileState.builderNumber}`;
53
+ yamlDocument.set("version", newFileVersion);
54
+ writeFileSync(fileState.path, yamlDocument.toString(), "utf8");
55
+ }
56
+ isSupportedFile(fileName) {
57
+ return fileName.endsWith(".yaml") || fileName.endsWith(".yml");
58
+ }
59
+ };
60
+ //#endregion
61
+ export { YAMLPackage };