cloud-report
Version:
Collects and analyzes cloud resources
53 lines (52 loc) • 2.67 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const types_1 = require("../../../types");
const base_1 = require("../../base");
class NodeVersionCheckAnalyzer extends base_1.BaseAnalyzer {
analyze(params, fullReport) {
const allFunctions = params.functions;
if (!allFunctions) {
return undefined;
}
const node_version_check = { type: types_1.CheckAnalysisType.PerformanceEfficiency };
node_version_check.what = "Is your function node updated?";
node_version_check.why = `We need to regularly check the node version for the function as the older version will lose compatibility
some features of the function you are using.`;
node_version_check.recommendation = `Keep a regular check on node updates to use all the features efficiently.`;
node_version_check.benchmark = ['all'];
const allRegionsAnalysis = {};
for (const region in allFunctions) {
const regionFunctions = allFunctions[region];
allRegionsAnalysis[region] = [];
for (const fn of regionFunctions) {
const nodeVersionAnalysis = {};
nodeVersionAnalysis.resource = fn;
if (fn.Runtime.indexOf("nodejs") != -1) {
const nodejs_V = fn.Runtime;
const version_validator = this.nodeVersionValidator(nodejs_V);
nodeVersionAnalysis.resourceSummary = {
name: "Node-Version",
value: fn.Runtime,
};
if (version_validator >= 8) {
nodeVersionAnalysis.severity = types_1.SeverityStatus.Good;
nodeVersionAnalysis.message = "The version is upto date";
}
else {
nodeVersionAnalysis.severity = types_1.SeverityStatus.Warning;
nodeVersionAnalysis.message = "You need to update your node version.";
nodeVersionAnalysis.action = "Some feature won't be supported with the following verion. UPDATE IS REQUIRED!!!!";
}
allRegionsAnalysis[region].push(nodeVersionAnalysis);
}
}
}
node_version_check.regions = allRegionsAnalysis;
return { node_version_check };
}
nodeVersionValidator(nodejs_V) {
const version = nodejs_V.split("nodejs")[1];
return parseInt(version.split('.')[0]);
}
}
exports.NodeVersionCheckAnalyzer = NodeVersionCheckAnalyzer;