diff --git a/lib/utils.js b/lib/utils.js index 311f279..07f7707 100644 --- a/lib/utils.js +++ b/lib/utils.js @@ -15,7 +15,7 @@ function setupAuth(core) { // Check if any authentication method is provided if (!checkEnvVarValid(fileName) && !checkEnvVarValid(authStr)) { - core.info("Using default provider environment variable variables as AUTH_FILE_PATH or AUTH_STR are not set..."); + core.info("using default provider environment variable variables as AUTH_FILE_PATH or AUTH_STR are not set..."); return; } @@ -24,7 +24,7 @@ function setupAuth(core) { auth = fs.readFileSync(fileName, "utf-8"); } catch (error) { core.error(error); - core.setFailed(`Cannot find auth file ${fileName}`); + core.setFailed(`cannot find auth file ${fileName}`); return; } } @@ -33,7 +33,7 @@ function setupAuth(core) { auth = authStr; } - core.info("Setting AUTH environment variable..."); + core.info("setting AUTH environment variable..."); core.exportVariable("AUTH", auth); } @@ -50,12 +50,12 @@ async function getStackqlCommand(core) { // output supports: json, csv, table, text only, fail if not supported if (!["json", "csv", "table", "text"].includes(output)) { - core.setFailed(`Output format not supported: ${output}`); + core.setFailed(`output format not supported: ${output}`); return; } if (!checkEnvVarValid(query) && !checkEnvVarValid(queryFilePath)) { - core.setFailed("Either query or query_file_path need to be set"); + core.setFailed("either query or query_file_path need to be set"); return; } @@ -68,7 +68,7 @@ async function getStackqlCommand(core) { ]; } else if (queryFilePath) { if (!fs.existsSync(queryFilePath)) { - core.setFailed(`Query file path does not exist: ${queryFilePath}`); + core.setFailed(`query file path does not exist: ${queryFilePath}`); return; } args = [ @@ -80,7 +80,7 @@ async function getStackqlCommand(core) { if (checkEnvVarValid(dataFilePath)) { if (!fs.existsSync(dataFilePath)) { - core.setFailed(`Data file path does not exist: ${dataFilePath}`); + core.setFailed(`data file path does not exist: ${dataFilePath}`); return; } args.push(`--iqldata "${dataFilePath}"`); @@ -98,6 +98,7 @@ async function getStackqlCommand(core) { let stackQLExecutable = "stackql"; // Default for non-Windows systems const isWindows = process.platform === "win32"; + isWindows ? core.info("running on Windows") : null; if (isWindows) { (async () => { try { @@ -105,12 +106,12 @@ async function getStackqlCommand(core) { const lines = stdout.split('\n').filter(line => line.trim() !== ''); if (lines.length > 0) { stackQLExecutable = lines[0].trim(); // Take the first result - console.log(`Found stackql.exe at: ${stackQLExecutable}`); + core.info(`found stackql.exe at: ${stackQLExecutable}`); } else { - console.error('stackql.exe not found on the filesystem.'); + core.error('stackql.exe not found on the filesystem.'); } } catch (error) { - console.error('Error searching for stackql.exe:', error.message); + core.error('error searching for stackql.exe:', error.message); } })(); } @@ -121,7 +122,7 @@ async function getStackqlCommand(core) { core.info(`STACKQL_COMMAND: ${stackQLCommand}`); } catch (error) { core.error(error); - core.setFailed("Error when executing stackql"); + core.setFailed("error when executing stackql"); } } @@ -136,7 +137,7 @@ const checkEnvVarValid = (variable) => { * @param {boolean} isCommand - Indicates if the operation is a command (true) or query (false). */ function execStackQLQuery(core, command, isCommand) { - core.info(`Executing StackQL query (isCommand : ${isCommand}): ${command}`); + core.info(`executing StackQL query (isCommand : ${isCommand}): ${command}`); exec(command, (error, stdout, stderr) => { if (stdout) { @@ -147,9 +148,9 @@ function execStackQLQuery(core, command, isCommand) { } if (error) { - core.error(`Error executing StackQL command: ${stderr}`); + core.error(`error executing StackQL command: ${stderr}`); if (!isCommand) { - core.setFailed(`StackQL command failed with error: ${error.message}`); + core.setFailed(`stackql command failed with error: ${error.message}`); } return; } @@ -157,13 +158,13 @@ function execStackQLQuery(core, command, isCommand) { core.exportVariable('STACKQL_COMMAND_OUTPUT', stdout); if (isCommand) { - core.info(`Command output: ${stdout}`); + core.info(`command output: ${stdout}`); } else { if (stderr) { - core.setFailed(`StackQL command reported an error: ${stderr}`); + core.setFailed(`stackql command reported an error: ${stderr}`); core.exportVariable('STACKQL_COMMAND_ERROR', stderr); } else { - core.info(`Query output: ${stdout}`); + core.info(`query output: ${stdout}`); } } });