fork-version 4.1.0 → 4.1.4
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 +37 -0
- package/dist/{chunk-DB3R2W4M.cjs → chunk-CISRFIID.cjs} +195 -219
- package/dist/chunk-CISRFIID.cjs.map +1 -0
- package/dist/{chunk-YMZ6L6ML.js → chunk-I76EAKJC.js} +196 -220
- package/dist/chunk-I76EAKJC.js.map +1 -0
- package/dist/cli.cjs +10 -10
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +2 -2
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +19 -19
- package/dist/index.d.cts +9 -13
- package/dist/index.d.ts +9 -13
- package/dist/index.js +1 -1
- package/package.json +1 -2
- package/dist/chunk-DB3R2W4M.cjs.map +0 -1
- package/dist/chunk-YMZ6L6ML.js.map +0 -1
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { execFile } from 'child_process';
|
|
3
3
|
import semver from 'semver';
|
|
4
|
-
import { resolve, parse } from 'path';
|
|
5
|
-
import { glob } from '
|
|
4
|
+
import { resolve, join, isAbsolute, parse, basename } from 'path';
|
|
5
|
+
import { glob } from 'fs/promises';
|
|
6
6
|
import conventionalChangelogConfigSpec from 'conventional-changelog-config-spec';
|
|
7
7
|
import { writeFileSync, readFileSync, lstatSync } from 'fs';
|
|
8
8
|
import JoyCon from 'joycon';
|
|
9
9
|
import { bundleRequire } from 'bundle-require';
|
|
10
|
+
import { styleText } from 'util';
|
|
10
11
|
import { modify, applyEdits, parse as parse$1 } from 'jsonc-parser';
|
|
11
12
|
import { parse as parse$2, parseDocument } from 'yaml';
|
|
12
13
|
import * as cheerio from 'cheerio/slim';
|
|
@@ -797,13 +798,19 @@ async function getUserConfig(cliArguments) {
|
|
|
797
798
|
...configFile,
|
|
798
799
|
...cliArguments.flags
|
|
799
800
|
};
|
|
800
|
-
|
|
801
|
+
const globResults = [];
|
|
801
802
|
if (mergedConfig.glob) {
|
|
802
|
-
|
|
803
|
+
const IGNORE_LIST = /* @__PURE__ */ new Set(["node_modules", ".git"]);
|
|
804
|
+
const entries = glob(mergedConfig.glob, {
|
|
803
805
|
cwd,
|
|
804
|
-
|
|
805
|
-
|
|
806
|
+
withFileTypes: true,
|
|
807
|
+
exclude: (entry) => IGNORE_LIST.has(entry.name)
|
|
806
808
|
});
|
|
809
|
+
for await (const entry of entries) {
|
|
810
|
+
if (entry.isFile()) {
|
|
811
|
+
globResults.push(join(entry.parentPath, entry.name));
|
|
812
|
+
}
|
|
813
|
+
}
|
|
807
814
|
}
|
|
808
815
|
const files = mergeFiles(configFile?.files, cliArguments.flags.files, globResults);
|
|
809
816
|
const detectedGitHost = await detectGitHost(cwd);
|
|
@@ -835,8 +842,6 @@ async function getUserConfig(cliArguments) {
|
|
|
835
842
|
changelogPresetConfig
|
|
836
843
|
};
|
|
837
844
|
}
|
|
838
|
-
|
|
839
|
-
// src/services/logger.ts
|
|
840
845
|
var Logger = class {
|
|
841
846
|
constructor(config) {
|
|
842
847
|
this.config = config;
|
|
@@ -844,27 +849,36 @@ var Logger = class {
|
|
|
844
849
|
this.warn = this.warn.bind(this);
|
|
845
850
|
this.error = this.error.bind(this);
|
|
846
851
|
this.debug = this.debug.bind(this);
|
|
852
|
+
this.skipping = this.skipping.bind(this);
|
|
847
853
|
this.disableLogs = this.config.silent;
|
|
848
854
|
}
|
|
849
855
|
disableLogs = false;
|
|
850
|
-
log(
|
|
856
|
+
log(message) {
|
|
851
857
|
if (!this.disableLogs) {
|
|
852
|
-
console.log(
|
|
858
|
+
console.log(message);
|
|
853
859
|
}
|
|
854
860
|
}
|
|
855
|
-
warn(
|
|
861
|
+
warn(message) {
|
|
856
862
|
if (!this.disableLogs) {
|
|
857
|
-
console.warn(
|
|
863
|
+
console.warn(styleText("yellowBright", message));
|
|
858
864
|
}
|
|
859
865
|
}
|
|
860
|
-
error(
|
|
866
|
+
error(message) {
|
|
861
867
|
if (!this.disableLogs) {
|
|
862
|
-
console.error(
|
|
868
|
+
console.error(styleText("redBright", message));
|
|
863
869
|
}
|
|
864
870
|
}
|
|
865
|
-
debug(...
|
|
871
|
+
debug(message, ...optionalParams) {
|
|
866
872
|
if (this.config.debug && !this.disableLogs) {
|
|
867
|
-
console.debug(
|
|
873
|
+
console.debug(styleText("cyanBright", message));
|
|
874
|
+
if (optionalParams.length > 0) {
|
|
875
|
+
console.debug(...optionalParams);
|
|
876
|
+
}
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
skipping(message) {
|
|
880
|
+
if (!this.disableLogs) {
|
|
881
|
+
console.log(styleText("magenta", message));
|
|
868
882
|
}
|
|
869
883
|
}
|
|
870
884
|
};
|
|
@@ -875,15 +889,13 @@ function fileExists(filePath) {
|
|
|
875
889
|
return false;
|
|
876
890
|
}
|
|
877
891
|
}
|
|
878
|
-
|
|
879
|
-
// src/files/json-package.ts
|
|
880
892
|
var JSONPackage = class {
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
this
|
|
893
|
+
#logger;
|
|
894
|
+
constructor(logger) {
|
|
895
|
+
this.#logger = logger;
|
|
884
896
|
}
|
|
885
897
|
/** Options for parsing JSON and JSONC files. */
|
|
886
|
-
|
|
898
|
+
#jsoncOptions = {
|
|
887
899
|
allowEmptyContent: false,
|
|
888
900
|
allowTrailingComma: true,
|
|
889
901
|
disallowComments: false
|
|
@@ -895,42 +907,32 @@ var JSONPackage = class {
|
|
|
895
907
|
* @param newString string to set the value to
|
|
896
908
|
* @returns the JSON or JSONC string with the value set
|
|
897
909
|
*/
|
|
898
|
-
setStringInJsonc(jsonc, jsonPath, newString) {
|
|
910
|
+
#setStringInJsonc(jsonc, jsonPath, newString) {
|
|
899
911
|
const edits = modify(jsonc, jsonPath, newString, {});
|
|
900
912
|
return applyEdits(jsonc, edits);
|
|
901
913
|
}
|
|
902
|
-
read(
|
|
903
|
-
const
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
name: fileName,
|
|
915
|
-
path: filePath,
|
|
916
|
-
version: parsedJson.version,
|
|
917
|
-
isPrivate: typeof parsedJson?.private === "boolean" ? parsedJson.private : true
|
|
918
|
-
};
|
|
919
|
-
}
|
|
920
|
-
this.logger.warn(`[File Manager] Unable to determine json version: ${fileName}`);
|
|
914
|
+
read(filePath) {
|
|
915
|
+
const fileName = basename(filePath);
|
|
916
|
+
const fileContents = readFileSync(filePath, "utf8");
|
|
917
|
+
const parseErrors = [];
|
|
918
|
+
const parsedJson = parse$1(fileContents, parseErrors, this.#jsoncOptions);
|
|
919
|
+
if (parsedJson?.version && parseErrors.length === 0) {
|
|
920
|
+
return {
|
|
921
|
+
name: fileName,
|
|
922
|
+
path: filePath,
|
|
923
|
+
version: parsedJson.version,
|
|
924
|
+
isPrivate: typeof parsedJson?.private === "boolean" ? parsedJson.private : true
|
|
925
|
+
};
|
|
921
926
|
}
|
|
927
|
+
this.#logger.warn(`[File Manager] Unable to determine json version: ${fileName}`);
|
|
922
928
|
}
|
|
923
929
|
write(fileState, newVersion) {
|
|
924
930
|
let fileContents = readFileSync(fileState.path, "utf8");
|
|
925
931
|
const parseErrors = [];
|
|
926
|
-
const parsedJson = parse$1(fileContents, parseErrors, this
|
|
927
|
-
|
|
928
|
-
this.logger.warn(`[File Manager] Unable to parse JSON: ${fileState.path}`, parseErrors);
|
|
929
|
-
return;
|
|
930
|
-
}
|
|
931
|
-
fileContents = this.setStringInJsonc(fileContents, ["version"], newVersion);
|
|
932
|
+
const parsedJson = parse$1(fileContents, parseErrors, this.#jsoncOptions);
|
|
933
|
+
fileContents = this.#setStringInJsonc(fileContents, ["version"], newVersion);
|
|
932
934
|
if (parsedJson?.packages?.[""]) {
|
|
933
|
-
fileContents = this
|
|
935
|
+
fileContents = this.#setStringInJsonc(fileContents, ["packages", "", "version"], newVersion);
|
|
934
936
|
}
|
|
935
937
|
writeFileSync(fileState.path, fileContents, "utf8");
|
|
936
938
|
}
|
|
@@ -939,16 +941,16 @@ var JSONPackage = class {
|
|
|
939
941
|
}
|
|
940
942
|
};
|
|
941
943
|
var YAMLPackage = class {
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
this
|
|
944
|
+
#logger;
|
|
945
|
+
constructor(logger) {
|
|
946
|
+
this.#logger = logger;
|
|
945
947
|
}
|
|
946
948
|
/**
|
|
947
949
|
* If the version is returned with a "+" symbol in the value then the version might be from a
|
|
948
950
|
* flutter `pubspec.yaml` file, if so we want to retain the input builderNumber by splitting it
|
|
949
951
|
* and joining it again later.
|
|
950
952
|
*/
|
|
951
|
-
handleBuildNumber(fileVersion) {
|
|
953
|
+
#handleBuildNumber(fileVersion) {
|
|
952
954
|
const [version, builderNumber] = fileVersion.split("+");
|
|
953
955
|
if (/^\d+$/.test(builderNumber)) {
|
|
954
956
|
return {
|
|
@@ -960,22 +962,20 @@ var YAMLPackage = class {
|
|
|
960
962
|
version: fileVersion
|
|
961
963
|
};
|
|
962
964
|
}
|
|
963
|
-
read(
|
|
964
|
-
const
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
};
|
|
976
|
-
}
|
|
965
|
+
read(filePath) {
|
|
966
|
+
const fileName = basename(filePath);
|
|
967
|
+
const fileContents = readFileSync(filePath, "utf-8");
|
|
968
|
+
const fileVersion = parse$2(fileContents)?.version;
|
|
969
|
+
if (fileVersion) {
|
|
970
|
+
const parsedVersion = this.#handleBuildNumber(fileVersion);
|
|
971
|
+
return {
|
|
972
|
+
name: fileName,
|
|
973
|
+
path: filePath,
|
|
974
|
+
version: parsedVersion.version || "",
|
|
975
|
+
builderNumber: parsedVersion.builderNumber ?? void 0
|
|
976
|
+
};
|
|
977
977
|
}
|
|
978
|
-
this
|
|
978
|
+
this.#logger.warn(`[File Manager] Unable to determine yaml version: ${fileName}`);
|
|
979
979
|
}
|
|
980
980
|
write(fileState, newVersion) {
|
|
981
981
|
const fileContents = readFileSync(fileState.path, "utf8");
|
|
@@ -992,21 +992,21 @@ var YAMLPackage = class {
|
|
|
992
992
|
}
|
|
993
993
|
};
|
|
994
994
|
var PlainText = class {
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
this
|
|
995
|
+
#logger;
|
|
996
|
+
constructor(logger) {
|
|
997
|
+
this.#logger = logger;
|
|
998
998
|
}
|
|
999
|
-
read(
|
|
1000
|
-
const
|
|
1001
|
-
|
|
1002
|
-
|
|
999
|
+
read(filePath) {
|
|
1000
|
+
const fileName = basename(filePath);
|
|
1001
|
+
const fileContents = readFileSync(filePath, "utf8").trim();
|
|
1002
|
+
if (fileContents) {
|
|
1003
1003
|
return {
|
|
1004
1004
|
name: fileName,
|
|
1005
1005
|
path: filePath,
|
|
1006
|
-
version: fileContents
|
|
1006
|
+
version: fileContents
|
|
1007
1007
|
};
|
|
1008
1008
|
}
|
|
1009
|
-
this
|
|
1009
|
+
this.#logger.warn(`[File Manager] Unable to determine plain text version: ${fileName}`);
|
|
1010
1010
|
}
|
|
1011
1011
|
write(fileState, newVersion) {
|
|
1012
1012
|
writeFileSync(fileState.path, newVersion, "utf8");
|
|
@@ -1016,35 +1016,31 @@ var PlainText = class {
|
|
|
1016
1016
|
}
|
|
1017
1017
|
};
|
|
1018
1018
|
var MSBuildProject = class {
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
this
|
|
1022
|
-
}
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
}
|
|
1039
|
-
this.logger.warn(`[File Manager] Unable to determine ms-build version: ${fileName}`);
|
|
1019
|
+
#logger;
|
|
1020
|
+
constructor(logger) {
|
|
1021
|
+
this.#logger = logger;
|
|
1022
|
+
}
|
|
1023
|
+
#cheerioOptions = {
|
|
1024
|
+
xmlMode: true,
|
|
1025
|
+
xml: { decodeEntities: false }
|
|
1026
|
+
};
|
|
1027
|
+
read(filePath) {
|
|
1028
|
+
const fileName = basename(filePath);
|
|
1029
|
+
const fileContents = readFileSync(filePath, "utf8");
|
|
1030
|
+
const $ = cheerio.load(fileContents, this.#cheerioOptions);
|
|
1031
|
+
const version = $("Project > PropertyGroup > Version").text();
|
|
1032
|
+
if (version) {
|
|
1033
|
+
return {
|
|
1034
|
+
name: fileName,
|
|
1035
|
+
path: filePath,
|
|
1036
|
+
version
|
|
1037
|
+
};
|
|
1040
1038
|
}
|
|
1039
|
+
this.#logger.warn(`[File Manager] Unable to determine ms-build version: ${fileName}`);
|
|
1041
1040
|
}
|
|
1042
1041
|
write(fileState, newVersion) {
|
|
1043
1042
|
const fileContents = readFileSync(fileState.path, "utf8");
|
|
1044
|
-
const $ = cheerio.load(fileContents,
|
|
1045
|
-
xmlMode: true,
|
|
1046
|
-
xml: { decodeEntities: false }
|
|
1047
|
-
});
|
|
1043
|
+
const $ = cheerio.load(fileContents, this.#cheerioOptions);
|
|
1048
1044
|
$("Project > PropertyGroup > Version").text(newVersion);
|
|
1049
1045
|
const updatedContent = $.xml().replaceAll('"/>', '" />');
|
|
1050
1046
|
writeFileSync(fileState.path, updatedContent, "utf8");
|
|
@@ -1056,40 +1052,38 @@ var MSBuildProject = class {
|
|
|
1056
1052
|
}
|
|
1057
1053
|
};
|
|
1058
1054
|
var ARMBicep = class {
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
this
|
|
1055
|
+
#logger;
|
|
1056
|
+
constructor(logger) {
|
|
1057
|
+
this.#logger = logger;
|
|
1062
1058
|
}
|
|
1063
1059
|
/** https://regex101.com/r/Lriphb/2 */
|
|
1064
|
-
metadataRegex = /(metadata contentVersion *= *['"])(?<version>[^'"]+)(['"])/;
|
|
1060
|
+
#metadataRegex = /(metadata contentVersion *= *['"])(?<version>[^'"]+)(['"])/;
|
|
1065
1061
|
/** https://regex101.com/r/iKCTF9/1 */
|
|
1066
|
-
varRegex = /(var contentVersion(?: string)? *= *['"])(?<version>[^'"]+)(['"])/;
|
|
1067
|
-
read(
|
|
1068
|
-
const
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
this.logger.warn(`[File Manager] Missing 'var contentVersion' in bicep file: ${fileName}`);
|
|
1087
|
-
}
|
|
1062
|
+
#varRegex = /(var contentVersion(?: string)? *= *['"])(?<version>[^'"]+)(['"])/;
|
|
1063
|
+
read(filePath) {
|
|
1064
|
+
const fileName = basename(filePath);
|
|
1065
|
+
const fileContents = readFileSync(filePath, "utf8");
|
|
1066
|
+
const metadataMatch = this.#metadataRegex.exec(fileContents);
|
|
1067
|
+
const varMatch = this.#varRegex.exec(fileContents);
|
|
1068
|
+
if (metadataMatch?.groups?.version && varMatch?.groups?.version) {
|
|
1069
|
+
return {
|
|
1070
|
+
name: fileName,
|
|
1071
|
+
path: filePath,
|
|
1072
|
+
version: metadataMatch.groups.version
|
|
1073
|
+
};
|
|
1074
|
+
}
|
|
1075
|
+
if (!metadataMatch) {
|
|
1076
|
+
this.#logger.warn(
|
|
1077
|
+
`[File Manager] Missing 'metadata contentVersion' in bicep file: ${fileName}`
|
|
1078
|
+
);
|
|
1079
|
+
}
|
|
1080
|
+
if (!varMatch) {
|
|
1081
|
+
this.#logger.warn(`[File Manager] Missing 'var contentVersion' in bicep file: ${fileName}`);
|
|
1088
1082
|
}
|
|
1089
1083
|
}
|
|
1090
1084
|
write(fileState, newVersion) {
|
|
1091
1085
|
const fileContents = readFileSync(fileState.path, "utf8");
|
|
1092
|
-
const updatedContent = fileContents.replace(this
|
|
1086
|
+
const updatedContent = fileContents.replace(this.#metadataRegex, `$1${newVersion}$3`).replace(this.#varRegex, `$1${newVersion}$3`);
|
|
1093
1087
|
writeFileSync(fileState.path, updatedContent, "utf8");
|
|
1094
1088
|
}
|
|
1095
1089
|
isSupportedFile(fileName) {
|
|
@@ -1097,35 +1091,31 @@ var ARMBicep = class {
|
|
|
1097
1091
|
}
|
|
1098
1092
|
};
|
|
1099
1093
|
var InstallShieldISM = class {
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
this
|
|
1103
|
-
}
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
}
|
|
1120
|
-
this.logger.warn(`[File Manager] Unable to determine InstallShield ISM version: ${fileName}`);
|
|
1094
|
+
#logger;
|
|
1095
|
+
constructor(logger) {
|
|
1096
|
+
this.#logger = logger;
|
|
1097
|
+
}
|
|
1098
|
+
#cheerioOptions = {
|
|
1099
|
+
xmlMode: true,
|
|
1100
|
+
xml: { decodeEntities: false }
|
|
1101
|
+
};
|
|
1102
|
+
read(filePath) {
|
|
1103
|
+
const fileName = basename(filePath);
|
|
1104
|
+
const fileContents = readFileSync(filePath, "utf8");
|
|
1105
|
+
const $ = cheerio.load(fileContents, this.#cheerioOptions);
|
|
1106
|
+
const version = $('msi > table[name="Property"] > row > td:contains("ProductVersion")').next().text().trim();
|
|
1107
|
+
if (version) {
|
|
1108
|
+
return {
|
|
1109
|
+
name: fileName,
|
|
1110
|
+
path: filePath,
|
|
1111
|
+
version
|
|
1112
|
+
};
|
|
1121
1113
|
}
|
|
1114
|
+
this.#logger.warn(`[File Manager] Unable to determine InstallShield ISM version: ${fileName}`);
|
|
1122
1115
|
}
|
|
1123
1116
|
write(fileState, newVersion) {
|
|
1124
1117
|
const fileContents = readFileSync(fileState.path, "utf8");
|
|
1125
|
-
const $ = cheerio.load(fileContents,
|
|
1126
|
-
xmlMode: true,
|
|
1127
|
-
xml: { decodeEntities: false }
|
|
1128
|
-
});
|
|
1118
|
+
const $ = cheerio.load(fileContents, this.#cheerioOptions);
|
|
1129
1119
|
const versionCell = $(
|
|
1130
1120
|
'msi > table[name="Property"] > row > td:contains("ProductVersion")'
|
|
1131
1121
|
).next();
|
|
@@ -1142,22 +1132,21 @@ var InstallShieldISM = class {
|
|
|
1142
1132
|
|
|
1143
1133
|
// src/files/file-manager.ts
|
|
1144
1134
|
var FileManager = class {
|
|
1135
|
+
#config;
|
|
1136
|
+
#logger;
|
|
1137
|
+
#fileManagers = [];
|
|
1145
1138
|
constructor(config, logger) {
|
|
1146
|
-
this
|
|
1147
|
-
this
|
|
1148
|
-
this
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
PlainText;
|
|
1158
|
-
MSBuildProject;
|
|
1159
|
-
ARMBicep;
|
|
1160
|
-
InstallShieldISM;
|
|
1139
|
+
this.#config = config;
|
|
1140
|
+
this.#logger = logger;
|
|
1141
|
+
this.#fileManagers = [
|
|
1142
|
+
new JSONPackage(logger),
|
|
1143
|
+
new YAMLPackage(logger),
|
|
1144
|
+
new PlainText(logger),
|
|
1145
|
+
new MSBuildProject(logger),
|
|
1146
|
+
new ARMBicep(logger),
|
|
1147
|
+
new InstallShieldISM(logger)
|
|
1148
|
+
];
|
|
1149
|
+
}
|
|
1161
1150
|
/**
|
|
1162
1151
|
* Get the state from the given file name.
|
|
1163
1152
|
*
|
|
@@ -1171,27 +1160,16 @@ var FileManager = class {
|
|
|
1171
1160
|
* { "name": "package.json", "path": "/path/to/package.json", "version": "1.2.3", "isPrivate": true }
|
|
1172
1161
|
* ```
|
|
1173
1162
|
*/
|
|
1174
|
-
read(
|
|
1175
|
-
const _fileName =
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
if (this.PlainText.isSupportedFile(_fileName)) {
|
|
1183
|
-
return this.PlainText.read(fileName);
|
|
1184
|
-
}
|
|
1185
|
-
if (this.MSBuildProject.isSupportedFile(_fileName)) {
|
|
1186
|
-
return this.MSBuildProject.read(fileName);
|
|
1187
|
-
}
|
|
1188
|
-
if (this.ARMBicep.isSupportedFile(_fileName)) {
|
|
1189
|
-
return this.ARMBicep.read(fileName);
|
|
1190
|
-
}
|
|
1191
|
-
if (this.InstallShieldISM.isSupportedFile(_fileName)) {
|
|
1192
|
-
return this.InstallShieldISM.read(fileName);
|
|
1163
|
+
read(pathOrName) {
|
|
1164
|
+
const _fileName = pathOrName.toLowerCase();
|
|
1165
|
+
const filePath = isAbsolute(pathOrName) ? pathOrName : resolve(this.#config.path, pathOrName);
|
|
1166
|
+
if (!fileExists(filePath)) return;
|
|
1167
|
+
for (const fileManager of this.#fileManagers) {
|
|
1168
|
+
if (fileManager.isSupportedFile(_fileName)) {
|
|
1169
|
+
return fileManager.read(filePath);
|
|
1170
|
+
}
|
|
1193
1171
|
}
|
|
1194
|
-
this
|
|
1172
|
+
this.#logger.error(`[File Manager] Unsupported file: ${pathOrName}`);
|
|
1195
1173
|
}
|
|
1196
1174
|
/**
|
|
1197
1175
|
* Write the new version to the given file.
|
|
@@ -1205,29 +1183,16 @@ var FileManager = class {
|
|
|
1205
1183
|
* ```
|
|
1206
1184
|
*/
|
|
1207
1185
|
write(fileState, newVersion) {
|
|
1208
|
-
if (this
|
|
1186
|
+
if (this.#config.dryRun) {
|
|
1209
1187
|
return;
|
|
1210
1188
|
}
|
|
1211
1189
|
const _fileName = fileState.name.toLowerCase();
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
return this.YAMLPackage.write(fileState, newVersion);
|
|
1217
|
-
}
|
|
1218
|
-
if (this.PlainText.isSupportedFile(_fileName)) {
|
|
1219
|
-
return this.PlainText.write(fileState, newVersion);
|
|
1220
|
-
}
|
|
1221
|
-
if (this.MSBuildProject.isSupportedFile(_fileName)) {
|
|
1222
|
-
return this.MSBuildProject.write(fileState, newVersion);
|
|
1223
|
-
}
|
|
1224
|
-
if (this.ARMBicep.isSupportedFile(_fileName)) {
|
|
1225
|
-
return this.ARMBicep.write(fileState, newVersion);
|
|
1226
|
-
}
|
|
1227
|
-
if (this.InstallShieldISM.isSupportedFile(_fileName)) {
|
|
1228
|
-
return this.InstallShieldISM.write(fileState, newVersion);
|
|
1190
|
+
for (const fileManager of this.#fileManagers) {
|
|
1191
|
+
if (fileManager.isSupportedFile(_fileName)) {
|
|
1192
|
+
return fileManager.write(fileState, newVersion);
|
|
1193
|
+
}
|
|
1229
1194
|
}
|
|
1230
|
-
this
|
|
1195
|
+
this.#logger.error(`[File Manager] Unsupported file: ${fileState.path}`);
|
|
1231
1196
|
}
|
|
1232
1197
|
};
|
|
1233
1198
|
|
|
@@ -1773,7 +1738,6 @@ async function getCommitsSinceTag(config, logger, git) {
|
|
|
1773
1738
|
logger.warn("No previous tag found, using all commits");
|
|
1774
1739
|
}
|
|
1775
1740
|
const foundCommits = await git.getCommits(latestTag, "HEAD");
|
|
1776
|
-
logger.debug(`Found ${foundCommits.length} commits since last tag (${latestTag ?? "none"})`);
|
|
1777
1741
|
const commits = foundCommits.reduce((acc, commit) => {
|
|
1778
1742
|
const parsed = commitParser.parse(commit);
|
|
1779
1743
|
if (parsed) {
|
|
@@ -1781,9 +1745,10 @@ async function getCommitsSinceTag(config, logger, git) {
|
|
|
1781
1745
|
}
|
|
1782
1746
|
return acc;
|
|
1783
1747
|
}, []);
|
|
1784
|
-
logger.debug(`Parsed ${commits.length} commits after applying commit parser`);
|
|
1785
1748
|
const filteredCommits = filterRevertedCommits(commits);
|
|
1786
|
-
logger.debug(
|
|
1749
|
+
logger.debug(
|
|
1750
|
+
`Found ${foundCommits.length} commits since tag: ${latestTag ?? "none"} (${commits.length} parsed, ${filteredCommits.length} after filtering reverts)`
|
|
1751
|
+
);
|
|
1787
1752
|
return {
|
|
1788
1753
|
latestTag,
|
|
1789
1754
|
commits: filteredCommits
|
|
@@ -1820,7 +1785,7 @@ function getReleaseType(releaseType, currentVersion, preReleaseTag) {
|
|
|
1820
1785
|
// src/process/get-next-version.ts
|
|
1821
1786
|
async function getNextVersion(config, logger, commits, currentVersion) {
|
|
1822
1787
|
if (config.skipBump) {
|
|
1823
|
-
logger.
|
|
1788
|
+
logger.skipping(`Skipping bump, using ${currentVersion} as the next version`);
|
|
1824
1789
|
return {
|
|
1825
1790
|
version: currentVersion
|
|
1826
1791
|
};
|
|
@@ -1836,14 +1801,25 @@ async function getNextVersion(config, logger, commits, currentVersion) {
|
|
|
1836
1801
|
}
|
|
1837
1802
|
const isPreMajor = semver.lt(currentVersion, "1.0.0");
|
|
1838
1803
|
let releaseType = "patch";
|
|
1839
|
-
const changes = {
|
|
1804
|
+
const changes = {
|
|
1805
|
+
major: 0,
|
|
1806
|
+
minor: 0,
|
|
1807
|
+
patch: 0,
|
|
1808
|
+
merges: 0,
|
|
1809
|
+
reverts: 0
|
|
1810
|
+
};
|
|
1840
1811
|
if (config.releaseAs) {
|
|
1841
1812
|
releaseType = config.releaseAs;
|
|
1842
1813
|
} else {
|
|
1843
1814
|
let level = 2;
|
|
1844
1815
|
const MINOR_TYPES = ["feat", "feature"];
|
|
1845
1816
|
for (const commit of commits) {
|
|
1846
|
-
if (commit.merge
|
|
1817
|
+
if (commit.merge) {
|
|
1818
|
+
changes.merges += 1;
|
|
1819
|
+
continue;
|
|
1820
|
+
}
|
|
1821
|
+
if (commit.revert) {
|
|
1822
|
+
changes.reverts += 1;
|
|
1847
1823
|
continue;
|
|
1848
1824
|
}
|
|
1849
1825
|
if (commit.notes.length > 0 || commit.breakingChange) {
|
|
@@ -1881,7 +1857,7 @@ async function getNextVersion(config, logger, commits, currentVersion) {
|
|
|
1881
1857
|
logger.log(`Next version: ${nextVersion} (${releaseTypeOrPreRelease})`);
|
|
1882
1858
|
if (commits.length > 0) {
|
|
1883
1859
|
logger.log(
|
|
1884
|
-
` - Commits: ${commits.length}` + (changes.major > 0 ? `,
|
|
1860
|
+
` - Commits: ${commits.length}` + (changes.major > 0 ? `, Majors: ${changes.major}` : "") + (changes.minor > 0 ? `, Minors: ${changes.minor}` : "") + (changes.patch > 0 ? `, Patches: ${changes.patch}` : "") + (changes.reverts > 0 ? `, Reverts: ${changes.reverts}` : "") + (changes.merges > 0 ? `, Merges: ${changes.merges}` : "")
|
|
1885
1861
|
);
|
|
1886
1862
|
} else {
|
|
1887
1863
|
logger.log(" - No commits found.");
|
|
@@ -1935,7 +1911,7 @@ function getNewReleaseContent(config, logger, nextVersion) {
|
|
|
1935
1911
|
}
|
|
1936
1912
|
async function updateChangelog(config, logger, nextVersion) {
|
|
1937
1913
|
if (config.skipChangelog) {
|
|
1938
|
-
logger.
|
|
1914
|
+
logger.skipping("Skipping changelog update");
|
|
1939
1915
|
return;
|
|
1940
1916
|
}
|
|
1941
1917
|
if (config.header.search(RELEASE_PATTERN) !== -1) {
|
|
@@ -1973,7 +1949,7 @@ function formatCommitMessage(message, version) {
|
|
|
1973
1949
|
// src/process/commit.ts
|
|
1974
1950
|
async function commitChanges(config, logger, git, files, nextVersion) {
|
|
1975
1951
|
if (config.skipCommit) {
|
|
1976
|
-
logger.
|
|
1952
|
+
logger.skipping("Skipping commit");
|
|
1977
1953
|
return;
|
|
1978
1954
|
}
|
|
1979
1955
|
logger.log("Committing changes");
|
|
@@ -2005,7 +1981,7 @@ async function commitChanges(config, logger, git, files, nextVersion) {
|
|
|
2005
1981
|
// src/process/tag.ts
|
|
2006
1982
|
async function tagChanges(config, logger, git, nextVersion) {
|
|
2007
1983
|
if (config.skipTag) {
|
|
2008
|
-
logger.
|
|
1984
|
+
logger.skipping("Skipping tag creation");
|
|
2009
1985
|
return;
|
|
2010
1986
|
}
|
|
2011
1987
|
const tag = `${config.tagPrefix}${nextVersion}`;
|
|
@@ -2044,5 +2020,5 @@ async function main(config, logger, fileManager, git) {
|
|
|
2044
2020
|
}
|
|
2045
2021
|
|
|
2046
2022
|
export { CommitParser, FileManager, ForkConfigSchema, Git, Logger, commitChanges, createParserOptions, filterRevertedCommits, getCommitsSinceTag, getCurrentVersion, getNextVersion, getUserConfig, inspectTag, inspectVersion, main, tagChanges, updateChangelog, validateConfig };
|
|
2047
|
-
//# sourceMappingURL=chunk-
|
|
2048
|
-
//# sourceMappingURL=chunk-
|
|
2023
|
+
//# sourceMappingURL=chunk-I76EAKJC.js.map
|
|
2024
|
+
//# sourceMappingURL=chunk-I76EAKJC.js.map
|