Skip to content

Commit

Permalink
fixed the failing of audit when no publish details were found and del…
Browse files Browse the repository at this point in the history
…eted the unused sections of the code
  • Loading branch information
cs-raj committed Jun 24, 2024
1 parent 6914581 commit 94d8bb6
Show file tree
Hide file tree
Showing 8 changed files with 219 additions and 225 deletions.
406 changes: 203 additions & 203 deletions package-lock.json

Large diffs are not rendered by default.

16 changes: 8 additions & 8 deletions packages/contentstack-audit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ $ npm install -g @contentstack/cli-audit
$ csdx COMMAND
running command...
$ csdx (--version|-v)
@contentstack/cli-audit/1.6.2 darwin-arm64 node-v22.2.0
@contentstack/cli-audit/1.6.3 darwin-arm64 node-v22.2.0
$ csdx --help [COMMAND]
USAGE
$ csdx COMMAND
Expand Down Expand Up @@ -267,7 +267,7 @@ EXAMPLES
$ csdx plugins
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.2.4/src/commands/plugins/index.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.2/src/commands/plugins/index.ts)_

## `csdx plugins:add PLUGIN`

Expand Down Expand Up @@ -341,7 +341,7 @@ EXAMPLES
$ csdx plugins:inspect myplugin
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.2.4/src/commands/plugins/inspect.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.2/src/commands/plugins/inspect.ts)_

## `csdx plugins:install PLUGIN`

Expand Down Expand Up @@ -390,7 +390,7 @@ EXAMPLES
$ csdx plugins:install someuser/someplugin
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.2.4/src/commands/plugins/install.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.2/src/commands/plugins/install.ts)_

## `csdx plugins:link PATH`

Expand Down Expand Up @@ -420,7 +420,7 @@ EXAMPLES
$ csdx plugins:link myplugin
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.2.4/src/commands/plugins/link.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.2/src/commands/plugins/link.ts)_

## `csdx plugins:remove [PLUGIN]`

Expand Down Expand Up @@ -461,7 +461,7 @@ FLAGS
--reinstall Reinstall all plugins after uninstalling.
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.2.4/src/commands/plugins/reset.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.2/src/commands/plugins/reset.ts)_

## `csdx plugins:uninstall [PLUGIN]`

Expand Down Expand Up @@ -489,7 +489,7 @@ EXAMPLES
$ csdx plugins:uninstall myplugin
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.2.4/src/commands/plugins/uninstall.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.2/src/commands/plugins/uninstall.ts)_

## `csdx plugins:unlink [PLUGIN]`

Expand Down Expand Up @@ -533,5 +533,5 @@ DESCRIPTION
Update installed plugins.
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.2.4/src/commands/plugins/update.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.3.2/src/commands/plugins/update.ts)_
<!-- commandsstop -->
2 changes: 1 addition & 1 deletion packages/contentstack-audit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@contentstack/cli-audit",
"version": "1.6.2",
"version": "1.6.3",
"description": "Contentstack audit plugin",
"author": "Contentstack CLI",
"homepage": "https://github.com/contentstack/cli",
Expand Down
8 changes: 1 addition & 7 deletions packages/contentstack-audit/src/modules/entries.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ export default class Entries {
protected missingMandatoryFields: 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 @@ -128,7 +127,7 @@ export default class Entries {
this.lookForReference([{ locale: code, uid, name: title }], ctSchema, this.entries[entryUid]);

const fields = this.missingMandatoryFields[uid];
const isPublished = entry.publish_details.length > 0;
const isPublished = entry.publish_details?.length > 0;
if ((this.fix && fields.length && isPublished) || (!this.fix && fields)) {
const fixStatus = this.fix ? 'Fixed' : '';
fields?.forEach((field: { isPublished: boolean; fixStatus?: string }) => {
Expand Down Expand Up @@ -1262,13 +1261,11 @@ export default class Entries {
let { title } = entries[entryUid];

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.`,
`error`,
Expand All @@ -1279,8 +1276,5 @@ 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.`);
}
}
}
4 changes: 2 additions & 2 deletions packages/contentstack-audit/src/modules/extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ export default class Extensions {

if (ctNotPresent?.length && ext.scope) {
ext.content_types = ctNotPresent;
ctNotPresent.forEach((ct) => this.missingCts.add(ct));
this.missingCtInExtensions.push(cloneDeep(ext));
ctNotPresent.forEach((ct) => this.missingCts?.add(ct));
this.missingCtInExtensions?.push(cloneDeep(ext));
}

this.log(
Expand Down
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.6.2",
"@contentstack/cli-audit": "~1.6.3",
"@contentstack/cli-command": "~1.2.18",
"@contentstack/cli-utilities": "~1.6.3",
"@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.6.2",
"@contentstack/cli-audit": "~1.6.3",
"@contentstack/cli-auth": "~1.3.18",
"@contentstack/cli-cm-bootstrap": "~1.9.3",
"@contentstack/cli-cm-branches": "~1.1.0",
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 94d8bb6

Please sign in to comment.