From e02b42666719c5ba2869a0cac89eb699aa419abb Mon Sep 17 00:00:00 2001 From: Ismayil Ismayilov Date: Thu, 16 Feb 2023 14:13:36 +0400 Subject: [PATCH] Added deprecated runner validation --- app/lib/jsonvalidate.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/app/lib/jsonvalidate.ts b/app/lib/jsonvalidate.ts index faa9a95e..931cce86 100644 --- a/app/lib/jsonvalidate.ts +++ b/app/lib/jsonvalidate.ts @@ -4,6 +4,8 @@ var fs = require("fs"); var check = require("validator"); var trace = require("./trace"); +const deprecatedRunners = ["Node6"]; + /* * Checks a json file for correct formatting against some validation function * @param jsonFilePath path to the json file being validated @@ -36,6 +38,7 @@ export function validate(jsonFilePath: string, jsonMissingErrorMessage?: string) } trace.debug("Json is valid."); + validateRunner(taskJson); deferred.resolve(taskJson); return deferred.promise; } @@ -50,6 +53,20 @@ export function exists(path: string, errorMessage: string) { } } +/* + * Validates a task against deprecated runner + * @param taskData the parsed json file + */ +export function validateRunner(taskData: any) { + if(taskData == undefined || taskData.execution == undefined) + return + + const validRunnerCount = Object.keys(taskData.execution).filter(itm=> deprecatedRunners.indexOf(itm) == -1) || 0; + if(validRunnerCount == 0){ + trace.warn("Task %s is dependent on a task runner that is end-of-life and will be removed in the future. Authors should review Node upgrade guidance: https://aka.ms/node-runner-guidance.",taskData.name) + } +} + /* * Validates a parsed json file describing a build task * @param taskPath the path to the original json file