Skip to content

Commit

Permalink
Merge pull request #1377 from contentstack/bugfix/CS-44750
Browse files Browse the repository at this point in the history
CS- 44750 - fix: Checking the title for the entry before running the audit command and version bump.
  • Loading branch information
cs-raj authored Apr 18, 2024
2 parents 49876a4 + 83a96f7 commit ecd2cdf
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 8 deletions.
6 changes: 3 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 11 additions & 1 deletion packages/contentstack-audit/src/modules/entries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export default class Entries {
protected missingRefs: Record<string, any> = {};
public entryMetaData: Record<string, any>[] = [];
public moduleName: keyof typeof auditConfig.moduleConfig = 'entries';
public isEntryWithoutTitleField: boolean = false;

constructor({ log, fix, config, moduleName, ctSchema, gfSchema }: ModuleConstructorParam & CtConstructorParam) {
this.log = log;
Expand Down Expand Up @@ -105,7 +106,6 @@ export default class Entries {
if (this.fix) {
this.removeMissingKeysOnEntry(ctSchema.schema as ContentTypeSchemaType[], this.entries[entryUid]);
}

this.lookForReference([{ locale: code, uid, name: title }], ctSchema, this.entries[entryUid]);
const message = $t(auditMsg.SCAN_ENTRY_SUCCESS_MSG, {
title,
Expand Down Expand Up @@ -981,10 +981,20 @@ 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) {
this.isEntryWithoutTitleField = true;
this.log(
`Entry with UID '${entryUid}' of Content Type '${uid}' in Locale '${code}' does not have a 'title' field.`,
`error`,
);
}
this.entryMetaData.push({ uid: entryUid, title });
}
}
}
}
if (this.isEntryWithoutTitleField) {
throw Error(`Entries found with missing 'title' field! Please make the data corrections and re-run the audit.`);
}
}
}
2 changes: 1 addition & 1 deletion packages/contentstack-import/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"author": "Contentstack",
"bugs": "https://github.com/contentstack/cli/issues",
"dependencies": {
"@contentstack/cli-audit": "~1.5.3",
"@contentstack/cli-audit": "~1.5.4",
"@contentstack/cli-command": "~1.2.16",
"@contentstack/cli-utilities": "~1.6.0",
"@contentstack/management": "~1.15.3",
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"prepack": "pnpm compile && oclif manifest && oclif readme"
},
"dependencies": {
"@contentstack/cli-audit": "~1.5.3",
"@contentstack/cli-audit": "~1.5.4",
"@contentstack/cli-auth": "~1.3.17",
"@contentstack/cli-cm-bootstrap": "~1.9.0",
"@contentstack/cli-cm-branches": "~1.0.24",
Expand Down
4 changes: 2 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit ecd2cdf

Please sign in to comment.