From a0236d21750bb628c3b89a89287bc09ab1c5428a Mon Sep 17 00:00:00 2001 From: raj pandey Date: Wed, 24 Apr 2024 15:33:23 +0530 Subject: [PATCH 1/2] Ui text updated --- .../contentstack-audit/src/modules/entries.ts | 9 ++++++++- .../05-Update-reference-entry-from-mapper.js | 16 ++++++++-------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/packages/contentstack-audit/src/modules/entries.ts b/packages/contentstack-audit/src/modules/entries.ts index dfce908806..8f32c4c165 100644 --- a/packages/contentstack-audit/src/modules/entries.ts +++ b/packages/contentstack-audit/src/modules/entries.ts @@ -981,7 +981,14 @@ export default class Entries { const entries = (await fsUtility.readChunkFiles.next()) as Record; for (const entryUid in entries) { let { title } = entries[entryUid]; - if (!title) { + + if (entries[entryUid].hasOwnProperty('title') && !title) { + this.isEntryWithoutTitleField = true; + this.log( + `The 'title' field in Entry with UID '${entryUid}' of Content Type '${uid}' in Locale '${code}' is empty.`, + `error`, + ); + } else if (!title) { this.isEntryWithoutTitleField = true; this.log( `Entry with UID '${entryUid}' of Content Type '${uid}' in Locale '${code}' does not have a 'title' field.`, diff --git a/packages/contentstack-migration/examples/05-Update-reference-entry-from-mapper.js b/packages/contentstack-migration/examples/05-Update-reference-entry-from-mapper.js index 0124825f18..33d9c25229 100644 --- a/packages/contentstack-migration/examples/05-Update-reference-entry-from-mapper.js +++ b/packages/contentstack-migration/examples/05-Update-reference-entry-from-mapper.js @@ -37,7 +37,7 @@ module.exports = async ({ migration, stackSDKInstance, managementAPIClient, conf } return entries; } catch (err) { - console.log(chalk.red(`Cannot Fetch Entries`)); + console.log(chalk.red(`Failed to fetch the entries...`)); throw err; } }; @@ -46,7 +46,7 @@ module.exports = async ({ migration, stackSDKInstance, managementAPIClient, conf try { return await stackSDKInstance.contentType(ct).fetch(); } catch (err) { - console.log(chalk.red(`Error in Fetching the Content-type '${ct}' due to ${err.errorMessage}`)); + console.log(chalk.red(`Failed to fetch the Content Type '${ct}' due to ${err.errorMessage}`)); } }; @@ -63,7 +63,7 @@ module.exports = async ({ migration, stackSDKInstance, managementAPIClient, conf if (oldUids.includes(m)) { let regex = new RegExp(m, 'g'); stringifiedEntry = stringifiedEntry.replace(regex, uidMapping[m]); - console.log(chalk.green(`Replacing UID '${m}' with '${uidMapping[m]}'`)); + console.log(chalk.green(`Replacing the UID '${m}' with '${uidMapping[m]}'...`)); isUpdated = true; } }); @@ -81,7 +81,7 @@ module.exports = async ({ migration, stackSDKInstance, managementAPIClient, conf if ((!config.contentTypes && !Array.isArray(config.contentTypes)) || !config['mapper-path']) { throw Error( - `Content-type or the Mapper Path is missing from the config. Please provide Content-type in Array and mapper path`, + `Missing Content Type or mapper path in config! Please make sure to have the Content Type [in Array] and the mapper path in config.`, ); } @@ -129,24 +129,24 @@ module.exports = async ({ migration, stackSDKInstance, managementAPIClient, conf log( chalk.green( - `Updated the References in Entry with UID '${e.uid}' and title '${e.title}' in locale '${e.locale}' of content-type '${ct}'`, + `Successfully updated the references in the entry with UID '${e.uid}' and title '${e.title}' of Content Type '${ct}' in Locale '${e.locale}'`, ), ); } else { log( chalk.red( - `Not Updated the Entry with UID '${e.uid}' and title '${e.title}' in locale '${e.locale}' of content-type '${ct}'`, + `Failed to update the references in the entry with UID '${e.uid}' and title '${e.title}' of Content Type '${ct}' in Locale '${e.locale}'`, ), ); } } - log(chalk.green(`Updated the entries of CT '${ct}'`)); + log(chalk.green(`Successfully updated the references in the entries of Content Type '${ct}'`)); } } catch (err) { if (err.request?.headers) { delete err.request['headers']; } - console.log(chalk.red(`References not updated`)); + console.log(chalk.red(`Failed to update references...`)); throw err; } }, From 644f539f96cc0ca1e6a7d7d625b306038d031366 Mon Sep 17 00:00:00 2001 From: raj pandey Date: Wed, 24 Apr 2024 16:09:24 +0530 Subject: [PATCH 2/2] fix when entry does not have title or title is empty --- packages/contentstack-audit/src/modules/entries.ts | 6 +++--- packages/contentstack-utilities/src/helpers.ts | 4 +--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/packages/contentstack-audit/src/modules/entries.ts b/packages/contentstack-audit/src/modules/entries.ts index 8f32c4c165..75affa8be8 100644 --- a/packages/contentstack-audit/src/modules/entries.ts +++ b/packages/contentstack-audit/src/modules/entries.ts @@ -1000,8 +1000,8 @@ export default class Entries { } } } - if (this.isEntryWithoutTitleField) { - throw Error(`Entries found with missing 'title' field! Please make the data corrections and re-run the audit.`); - } + // if (this.isEntryWithoutTitleField) { + // throw Error(`Entries found with missing 'title' field! Please make the data corrections and re-run the audit.`); + // } } } diff --git a/packages/contentstack-utilities/src/helpers.ts b/packages/contentstack-utilities/src/helpers.ts index 6270ca906f..144770fe9a 100644 --- a/packages/contentstack-utilities/src/helpers.ts +++ b/packages/contentstack-utilities/src/helpers.ts @@ -37,7 +37,6 @@ export const createDeveloperHubUrl = (developerHubBaseUrl: string): string => { return developerHubBaseUrl.startsWith('http') ? developerHubBaseUrl : `https://${developerHubBaseUrl}`; }; - export const validatePath = (input: string) => { const pattern = /[*$%#<>{}!&?]/g; if (pattern.test(input)) { @@ -53,5 +52,4 @@ export const validatePath = (input: string) => { }; // To escape special characters in a string -export const escapeRegExp = (str: string) => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); - +export const escapeRegExp = (str: string) => str?.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');