@codacy/tools-hadolint-2 0.24.0 → 0.25.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.
- package/dist/index.js +27 -17
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1015,22 +1015,32 @@ var PLATFORM_MAP = {
|
|
|
1015
1015
|
// suffix is added at the download/resolve sites via exeName.
|
|
1016
1016
|
"win32-x64": "Windows-x86_64"
|
|
1017
1017
|
};
|
|
1018
|
-
async function
|
|
1018
|
+
async function probeVersion(binaryPath) {
|
|
1019
1019
|
try {
|
|
1020
|
-
const { stdout, exitCode } = await (0, import_tooling.spawnTool)(binaryPath, ["--version"], {
|
|
1020
|
+
const { stdout, stderr, exitCode } = await (0, import_tooling.spawnTool)(binaryPath, ["--version"], {
|
|
1021
1021
|
cwd: process.cwd()
|
|
1022
1022
|
});
|
|
1023
|
-
if (exitCode !== 0) return null;
|
|
1024
1023
|
const match = stdout.match(/(\d+\.\d+\.\d+)/);
|
|
1025
|
-
|
|
1024
|
+
if (exitCode === 0 && match) return { version: match[1] };
|
|
1025
|
+
const output = `${stderr}
|
|
1026
|
+
${stdout}`.trim().slice(0, 500);
|
|
1027
|
+
return { failure: `exit ${exitCode}${output ? `: ${output}` : " with no output"}` };
|
|
1028
|
+
} catch (err) {
|
|
1029
|
+
return { failure: err instanceof Error ? err.message : String(err) };
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
async function fileExists(filePath) {
|
|
1033
|
+
try {
|
|
1034
|
+
await import_promises.default.access(filePath);
|
|
1035
|
+
return true;
|
|
1026
1036
|
} catch {
|
|
1027
|
-
return
|
|
1037
|
+
return false;
|
|
1028
1038
|
}
|
|
1029
1039
|
}
|
|
1030
1040
|
async function resolveBinaryPath(ctx) {
|
|
1031
1041
|
const codacyBin = import_path.default.join(ctx.toolInstallDir, (0, import_tooling.exeName)(BINARY));
|
|
1032
|
-
const
|
|
1033
|
-
if (version) return codacyBin;
|
|
1042
|
+
const probe = await probeVersion(codacyBin);
|
|
1043
|
+
if ("version" in probe) return codacyBin;
|
|
1034
1044
|
return BINARY;
|
|
1035
1045
|
}
|
|
1036
1046
|
var adapter = {
|
|
@@ -1052,9 +1062,10 @@ var adapter = {
|
|
|
1052
1062
|
*/
|
|
1053
1063
|
async checkAvailability(ctx) {
|
|
1054
1064
|
ctx.logger.debug("Checking availability", { toolId: TOOL_ID });
|
|
1055
|
-
const codacyBin = import_path.default.join(ctx.toolInstallDir, BINARY);
|
|
1056
|
-
const
|
|
1057
|
-
if (
|
|
1065
|
+
const codacyBin = import_path.default.join(ctx.toolInstallDir, (0, import_tooling.exeName)(BINARY));
|
|
1066
|
+
const codacyProbe = await probeVersion(codacyBin);
|
|
1067
|
+
if ("version" in codacyProbe) {
|
|
1068
|
+
const codacyVersion = codacyProbe.version;
|
|
1058
1069
|
ctx.logger.debug("Found codacy-managed binary", {
|
|
1059
1070
|
toolId: TOOL_ID,
|
|
1060
1071
|
version: codacyVersion,
|
|
@@ -1067,8 +1078,9 @@ var adapter = {
|
|
|
1067
1078
|
installation: "codacy"
|
|
1068
1079
|
};
|
|
1069
1080
|
}
|
|
1070
|
-
const
|
|
1071
|
-
if (
|
|
1081
|
+
const globalProbe = await probeVersion(BINARY);
|
|
1082
|
+
if ("version" in globalProbe) {
|
|
1083
|
+
const globalVersion = globalProbe.version;
|
|
1072
1084
|
ctx.logger.debug("Found global binary", { toolId: TOOL_ID, version: globalVersion });
|
|
1073
1085
|
return {
|
|
1074
1086
|
available: true,
|
|
@@ -1076,13 +1088,11 @@ var adapter = {
|
|
|
1076
1088
|
installation: "global"
|
|
1077
1089
|
};
|
|
1078
1090
|
}
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
reason: "not in PATH or Codacy install directory"
|
|
1082
|
-
});
|
|
1091
|
+
const reason = await fileExists(codacyBin) ? `hadolint at ${codacyBin} did not run (\`--version\` failed: ${codacyProbe.failure})` : "hadolint binary not found in PATH or Codacy install directory";
|
|
1092
|
+
ctx.logger.debug("Binary not available", { toolId: TOOL_ID, reason });
|
|
1083
1093
|
return {
|
|
1084
1094
|
available: false,
|
|
1085
|
-
reason
|
|
1095
|
+
reason,
|
|
1086
1096
|
installHint: "brew install hadolint # macOS\ncodacy-analysis analyze . --install-dependencies # auto-install"
|
|
1087
1097
|
};
|
|
1088
1098
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codacy/tools-hadolint-2",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.25.0",
|
|
4
4
|
"description": "Hadolint adapter — CLI-mode Dockerfile linter",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
"dist"
|
|
9
9
|
],
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@codacy/tooling": "0.
|
|
11
|
+
"@codacy/tooling": "0.25.0"
|
|
12
12
|
},
|
|
13
13
|
"license": "MIT",
|
|
14
14
|
"author": "Codacy <support@codacy.com> (https://www.codacy.com)",
|