Address review

This commit is contained in:
Paolo Tranquilli
2025-08-07 15:43:56 +02:00
parent 1cfc0c2621
commit bb56324516
12 changed files with 155 additions and 147 deletions

35
lib/cli-errors.js generated
View File

@@ -5,6 +5,12 @@ exports.wrapCliConfigurationError = wrapCliConfigurationError;
const actions_util_1 = require("./actions-util");
const doc_url_1 = require("./doc-url");
const util_1 = require("./util");
const SUPPORTED_PLATFORMS = [
["linux", "x64"],
["win32", "x64"],
["darwin", "x64"],
["darwin", "arm64"],
];
/**
* An error from a CodeQL CLI invocation, with associated exit code, stderr, etc.
*/
@@ -272,22 +278,18 @@ function getCliConfigCategoryIfExists(cliError) {
}
/**
* Check if we are running on an unsupported platform/architecture combination.
* If so, return a ConfigurationError with a message that explains that, mentioning
* the underlying `cliError`. Otherwise, reutrn `undefined`.
*/
function isUnsupportedPlatform() {
return !SUPPORTED_PLATFORMS.some(([platform, arch]) => platform === process.platform && arch === process.arch);
}
/**
* Transform a CLI error into a ConfigurationError for an unsupported platform.
*/
function getUnsupportedPlatformError(cliError) {
if (![
["linux", "x64"],
["win32", "x64"],
["darwin", "x64"],
["darwin", "arm64"],
].some(([platform, arch]) => platform === process.platform && arch === process.arch)) {
return new util_1.ConfigurationError("The CodeQL CLI does not support the platform/architecture combination of " +
`${process.platform}/${process.arch} ` +
"(see https://codeql.github.com/docs/codeql-overview/system-requirements). " +
`The underlying error was: ${cliError.message}`);
}
return undefined;
return new util_1.ConfigurationError("The CodeQL CLI does not support the platform/architecture combination of " +
`${process.platform}/${process.arch} ` +
`(see ${doc_url_1.DocUrl.SYSTEM_REQUIREMENTS}). ` +
`The underlying error was: ${cliError.message}`);
}
/**
* Changes an error received from the CLI to a ConfigurationError with the message
@@ -295,9 +297,8 @@ function getUnsupportedPlatformError(cliError) {
* simply returns the original error.
*/
function wrapCliConfigurationError(cliError) {
const unsupportedPlatformError = getUnsupportedPlatformError(cliError);
if (unsupportedPlatformError !== undefined) {
return unsupportedPlatformError;
if (isUnsupportedPlatform()) {
return getUnsupportedPlatformError(cliError);
}
const cliConfigErrorCategory = getCliConfigCategoryIfExists(cliError);
if (cliConfigErrorCategory === undefined) {