From d6731517a2e734e4b6131e6da438e050091576f2 Mon Sep 17 00:00:00 2001 From: Narek Hovhannisyan Date: Wed, 7 Aug 2024 10:23:34 +0400 Subject: [PATCH 1/4] feat(config): add EMPTY_PIPELINE to strings --- src/if-run/config/strings.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/if-run/config/strings.ts b/src/if-run/config/strings.ts index 24835f8ed..deb7d0052 100644 --- a/src/if-run/config/strings.ts +++ b/src/if-run/config/strings.ts @@ -58,6 +58,8 @@ Note that for the '--output' option you also need to define the output type in y PREPARING_OUTPUT_DATA: 'Preparing output data', EXPORTING_TO_YAML_FILE: (savepath: string) => `Exporting to yaml file: ${savepath}`, + EMPTY_PIPELINE: `You've using an old style manifest. Please update for phased execution. More information can be found here: +https://if.greensoftware.foundation/major-concepts/manifest-file`, /** Exhaust messages */ OUTPUT_REQUIRED: 'Output path is required, please make sure output is configured properly.', From 4f6dc3d6112b721041115fc0ca2f824da1ba535b Mon Sep 17 00:00:00 2001 From: Narek Hovhannisyan Date: Wed, 7 Aug 2024 10:28:00 +0400 Subject: [PATCH 2/4] feat(lib): add empty pipeline message --- src/if-run/lib/compute.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/if-run/lib/compute.ts b/src/if-run/lib/compute.ts index 41a153448..27426bbc6 100644 --- a/src/if-run/lib/compute.ts +++ b/src/if-run/lib/compute.ts @@ -5,13 +5,14 @@ import {addExplainData} from './explain'; import {mergeObjects} from '../util/helpers'; import {debugLogger} from '../../common/util/debug-logger'; +import {logger} from '../../common/util/logger'; import {STRINGS} from '../config/strings'; import {ComputeParams, Node, PhasedPipeline} from '../types/compute'; import {isExecute} from '../types/interface'; -const {MERGING_DEFAULTS_WITH_INPUT_DATA} = STRINGS; +const {MERGING_DEFAULTS_WITH_INPUT_DATA, EMPTY_PIPELINE} = STRINGS; /** * Traverses all child nodes based on children grouping. @@ -77,6 +78,10 @@ const computeNode = async (node: Node, params: ComputeParams): Promise => { inputStorage = mergeDefaults(inputStorage, defaults); const pipelineCopy = structuredClone(pipeline) || {}; + if (Object.keys(pipelineCopy).length === 0) { + logger.warn(EMPTY_PIPELINE); + } + /** * If iteration is on observe pipeline, then executes observe plugins and sets the inputs value. */ From 1b8d5f1bf3b9b14c5e56d0471def0de17172f4ed Mon Sep 17 00:00:00 2001 From: Narek Hovhannisyan Date: Thu, 8 Aug 2024 14:22:45 +0400 Subject: [PATCH 3/4] Update src/if-run/config/strings.ts Co-authored-by: Manushak Keramyan Signed-off-by: Narek Hovhannisyan --- src/if-run/config/strings.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/if-run/config/strings.ts b/src/if-run/config/strings.ts index deb7d0052..f09dc349e 100644 --- a/src/if-run/config/strings.ts +++ b/src/if-run/config/strings.ts @@ -58,7 +58,7 @@ Note that for the '--output' option you also need to define the output type in y PREPARING_OUTPUT_DATA: 'Preparing output data', EXPORTING_TO_YAML_FILE: (savepath: string) => `Exporting to yaml file: ${savepath}`, - EMPTY_PIPELINE: `You've using an old style manifest. Please update for phased execution. More information can be found here: + EMPTY_PIPELINE: `You're using an old style manifest. Please update for phased execution. More information can be found here: https://if.greensoftware.foundation/major-concepts/manifest-file`, /** Exhaust messages */ OUTPUT_REQUIRED: From 29f29163687d53ae037d95493a742108980af089 Mon Sep 17 00:00:00 2001 From: Narek Hovhannisyan Date: Thu, 8 Aug 2024 18:14:23 +0400 Subject: [PATCH 4/4] fix(lib): do more advanced checking on pipeline --- src/if-run/lib/compute.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/if-run/lib/compute.ts b/src/if-run/lib/compute.ts index 27426bbc6..710e15373 100644 --- a/src/if-run/lib/compute.ts +++ b/src/if-run/lib/compute.ts @@ -78,7 +78,13 @@ const computeNode = async (node: Node, params: ComputeParams): Promise => { inputStorage = mergeDefaults(inputStorage, defaults); const pipelineCopy = structuredClone(pipeline) || {}; - if (Object.keys(pipelineCopy).length === 0) { + /** Checks if pipeline is not an array or empty object. */ + if ( + Array.isArray(pipelineCopy) || + (typeof pipelineCopy === 'object' && + pipelineCopy !== null && + Object.keys(pipelineCopy).length === 0) + ) { logger.warn(EMPTY_PIPELINE); }