From fc3286c55eef5b9d7ea8012587eb6f66277785c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Berkefeld?= Date: Mon, 29 May 2023 20:01:12 +0200 Subject: [PATCH] #730: eslint --fix and improving error messages --- docs/dist/documentation.md | 12 ++++++------ lib/index.js | 12 +++++++----- lib/metadataTypes/MetadataType.js | 8 ++++---- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/docs/dist/documentation.md b/docs/dist/documentation.md index 8f36cb5f3..fc4a56044 100644 --- a/docs/dist/documentation.md +++ b/docs/dist/documentation.md @@ -496,8 +496,8 @@ main class * [.buildDefinition(businessUnit, selectedType, name, market)](#Mcdev.buildDefinition) ⇒ Promise.<void> * [.buildDefinitionBulk(listName, type, name)](#Mcdev.buildDefinitionBulk) ⇒ Promise.<void> * [.getFilesToCommit(businessUnit, selectedType, keyArr)](#Mcdev.getFilesToCommit) ⇒ Promise.<Array.<string>> - * [.execute(businessUnit, [selectedTypesArr], keys)](#Mcdev.execute) ⇒ Promise.<Boolean> - * [._executeBU(cred, bu, [selectedTypesArr], keyArr)](#Mcdev._executeBU) ⇒ Promise.<Boolean> + * [.execute(businessUnit, [selectedTypesArr], keys)](#Mcdev.execute) ⇒ Promise.<boolean> + * [._executeBU(cred, bu, [selectedTypesArr], keyArr)](#Mcdev._executeBU) ⇒ Promise.<boolean> @@ -752,11 +752,11 @@ Build a specific metadata file based on a template using a list of bu-market com -### Mcdev.execute(businessUnit, [selectedTypesArr], keys) ⇒ Promise.<Boolean> +### Mcdev.execute(businessUnit, [selectedTypesArr], keys) ⇒ Promise.<boolean> Start an item (query) **Kind**: static method of [Mcdev](#Mcdev) -**Returns**: Promise.<Boolean> - true if all started successfully, false if not +**Returns**: Promise.<boolean> - true if all started successfully, false if not | Param | Type | Description | | --- | --- | --- | @@ -766,11 +766,11 @@ Start an item (query) -### Mcdev.\_executeBU(cred, bu, [selectedTypesArr], keyArr) ⇒ Promise.<Boolean> +### Mcdev.\_executeBU(cred, bu, [selectedTypesArr], keyArr) ⇒ Promise.<boolean> helper for @link execute **Kind**: static method of [Mcdev](#Mcdev) -**Returns**: Promise.<Boolean> - true if all items were executed, false otherwise +**Returns**: Promise.<boolean> - true if all items were executed, false otherwise | Param | Type | Description | | --- | --- | --- | diff --git a/lib/index.js b/lib/index.js index 803a2ff52..5d7ee4091 100644 --- a/lib/index.js +++ b/lib/index.js @@ -683,10 +683,11 @@ class Mcdev { } /** * Start an item (query) - * @param {string} businessUnit name of BU + * + * @param {string} businessUnit name of BU * @param {TYPE.SupportedMetadataTypes[]} [selectedTypesArr] limit to given metadata types * @param {string[]} keys customerkey of the metadata - * @returns {Promise.} true if all started successfully, false if not + * @returns {Promise.} true if all started successfully, false if not */ static async execute(businessUnit, selectedTypesArr, keys) { Util.logger.info('mcdev:: Execute'); @@ -780,11 +781,12 @@ class Mcdev { } /** * helper for @link execute + * * @param {string} cred name of Credential * @param {string} bu name of BU * @param {TYPE.SupportedMetadataTypes[]} [selectedTypesArr] limit execution to given metadata type * @param {string[]} keyArr customerkey of the metadata - * @returns {Promise.} true if all items were executed, false otherwise + * @returns {Promise.} true if all items were executed, false otherwise */ static async _executeBU(cred, bu, selectedTypesArr, keyArr) { const properties = await config.getProperties(); @@ -810,7 +812,7 @@ class Mcdev { `\n :: Executing ${selectedTypesArr.join(', ')} on ${cred}/${bu}\n` ); try { - //more than one type was provided, iterate types and execute items + // more than one type was provided, iterate types and execute items for (const type of selectedTypesArr) { try { MetadataTypeInfo[type].client = auth.getSDK(buObject); @@ -818,7 +820,7 @@ class Mcdev { Util.logger.error(ex.message); return; } - //result will be undefined (false) if execute is not supported for the type + // result will be undefined (false) if execute is not supported for the type result = await MetadataTypeInfo[type].execute(keyArr); } } catch (ex) { diff --git a/lib/metadataTypes/MetadataType.js b/lib/metadataTypes/MetadataType.js index a3a2501dd..8fe50236f 100644 --- a/lib/metadataTypes/MetadataType.js +++ b/lib/metadataTypes/MetadataType.js @@ -1091,15 +1091,15 @@ class MetadataType { */ static async executeREST(uri, key) { try { - const response = await this.client.rest.post(uri, {}); //payload is empty for this request + const response = await this.client.rest.post(uri, {}); // payload is empty for this request if (response === 'OK') { Util.logger.info(`Executed ${this.definition.type} key: ${key}`); } else { - throw new Error(`${this.definition.type} key: ${key} was not executed`); + throw new Error(`server response = (${response})`); } return response; - } catch { - Util.logger.error(`Failed to start ${this.definition.type} key: ${key}`); + } catch (ex) { + Util.logger.error(`Failed to start ${this.definition.type} ${key}: ${ex.message}`); } }