@codacy/tools-hadolint-2 0.23.1 → 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 +28 -17
- package/dist/metadata.js +1 -0
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -947,6 +947,7 @@ var patterns_default = [
|
|
|
947
947
|
// src/metadata.ts
|
|
948
948
|
var descriptor = {
|
|
949
949
|
id: "Hadolint",
|
|
950
|
+
shortName: "hadolint",
|
|
950
951
|
displayName: "Hadolint",
|
|
951
952
|
preferredVersion: "2.14.0",
|
|
952
953
|
languages: ["Dockerfile"],
|
|
@@ -1014,22 +1015,32 @@ var PLATFORM_MAP = {
|
|
|
1014
1015
|
// suffix is added at the download/resolve sites via exeName.
|
|
1015
1016
|
"win32-x64": "Windows-x86_64"
|
|
1016
1017
|
};
|
|
1017
|
-
async function
|
|
1018
|
+
async function probeVersion(binaryPath) {
|
|
1018
1019
|
try {
|
|
1019
|
-
const { stdout, exitCode } = await (0, import_tooling.spawnTool)(binaryPath, ["--version"], {
|
|
1020
|
+
const { stdout, stderr, exitCode } = await (0, import_tooling.spawnTool)(binaryPath, ["--version"], {
|
|
1020
1021
|
cwd: process.cwd()
|
|
1021
1022
|
});
|
|
1022
|
-
if (exitCode !== 0) return null;
|
|
1023
1023
|
const match = stdout.match(/(\d+\.\d+\.\d+)/);
|
|
1024
|
-
|
|
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;
|
|
1025
1036
|
} catch {
|
|
1026
|
-
return
|
|
1037
|
+
return false;
|
|
1027
1038
|
}
|
|
1028
1039
|
}
|
|
1029
1040
|
async function resolveBinaryPath(ctx) {
|
|
1030
1041
|
const codacyBin = import_path.default.join(ctx.toolInstallDir, (0, import_tooling.exeName)(BINARY));
|
|
1031
|
-
const
|
|
1032
|
-
if (version) return codacyBin;
|
|
1042
|
+
const probe = await probeVersion(codacyBin);
|
|
1043
|
+
if ("version" in probe) return codacyBin;
|
|
1033
1044
|
return BINARY;
|
|
1034
1045
|
}
|
|
1035
1046
|
var adapter = {
|
|
@@ -1051,9 +1062,10 @@ var adapter = {
|
|
|
1051
1062
|
*/
|
|
1052
1063
|
async checkAvailability(ctx) {
|
|
1053
1064
|
ctx.logger.debug("Checking availability", { toolId: TOOL_ID });
|
|
1054
|
-
const codacyBin = import_path.default.join(ctx.toolInstallDir, BINARY);
|
|
1055
|
-
const
|
|
1056
|
-
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;
|
|
1057
1069
|
ctx.logger.debug("Found codacy-managed binary", {
|
|
1058
1070
|
toolId: TOOL_ID,
|
|
1059
1071
|
version: codacyVersion,
|
|
@@ -1066,8 +1078,9 @@ var adapter = {
|
|
|
1066
1078
|
installation: "codacy"
|
|
1067
1079
|
};
|
|
1068
1080
|
}
|
|
1069
|
-
const
|
|
1070
|
-
if (
|
|
1081
|
+
const globalProbe = await probeVersion(BINARY);
|
|
1082
|
+
if ("version" in globalProbe) {
|
|
1083
|
+
const globalVersion = globalProbe.version;
|
|
1071
1084
|
ctx.logger.debug("Found global binary", { toolId: TOOL_ID, version: globalVersion });
|
|
1072
1085
|
return {
|
|
1073
1086
|
available: true,
|
|
@@ -1075,13 +1088,11 @@ var adapter = {
|
|
|
1075
1088
|
installation: "global"
|
|
1076
1089
|
};
|
|
1077
1090
|
}
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
reason: "not in PATH or Codacy install directory"
|
|
1081
|
-
});
|
|
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 });
|
|
1082
1093
|
return {
|
|
1083
1094
|
available: false,
|
|
1084
|
-
reason
|
|
1095
|
+
reason,
|
|
1085
1096
|
installHint: "brew install hadolint # macOS\ncodacy-analysis analyze . --install-dependencies # auto-install"
|
|
1086
1097
|
};
|
|
1087
1098
|
},
|
package/dist/metadata.js
CHANGED
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)",
|