Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions packages/contentstack-audit/src/modules/entries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -981,7 +981,14 @@ export default class Entries {
const entries = (await fsUtility.readChunkFiles.next()) as Record<string, EntryStruct>;
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.`,
Expand All @@ -993,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.`);
// }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
};
Expand All @@ -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}`));
}
};

Expand All @@ -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;
}
});
Expand All @@ -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.`,
);
}

Expand Down Expand Up @@ -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;
}
},
Expand Down
4 changes: 1 addition & 3 deletions packages/contentstack-utilities/src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand All @@ -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, '\\$&');