Skip to content

Commit

Permalink
Merge pull request #1441 from contentstack/fix/DX-829
Browse files Browse the repository at this point in the history
DX - 829 - fixed the failing of audit when no publish details were found and deleted the unused sections of the code
  • Loading branch information
cs-raj authored Jun 26, 2024
2 parents 2eb005b + 325236b commit 4294568
Show file tree
Hide file tree
Showing 11 changed files with 224 additions and 230 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
4 changes: 2 additions & 2 deletions packages/contentstack-audit/src/messages/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ const auditFixMsg = {
EMPTY_FIX_MSG: 'Successfully removed the empty field/block found at {path} from the schema.',
AUDIT_FIX_CMD_DESCRIPTION: 'Perform audits and fix possible errors in the exported Contentstack data.',
WF_FIX_MSG: 'Successfully removed the workflow {uid} named {name}.',
ENTRY_MANDATORY_FIELD_FIX: `Removing the publish details from entry uid '{uid}' from locale '{locale}'`,
ENTRY_SELECT_FIELD_FIX: `Adding the value '{value}' in select field of uid '{uid}'`
ENTRY_MANDATORY_FIELD_FIX: `Removing the publish details from the entry with UID '{uid}' in Locale '{locale}'...`,
ENTRY_SELECT_FIELD_FIX: `Adding the value '{value}' in the select field of entry UID '{uid}'...`
};

const messages: typeof errors &
Expand Down
10 changes: 2 additions & 8 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,15 +1261,13 @@ 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.`,
`The 'title' field in Entry with UID '${entryUid}' of Content Type '${uid}' in Locale '${code}' is empty.`,
`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
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export default class ImportCommand extends Command {
description: 'Skips the audit fix.',
}),
'exclude-global-modules': flags.boolean({
description: 'Excluded the Module that are branch independent from the import',
description: 'Excludes the branch-independent module from the import operation',
default: false
}),
};
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-import/src/import/module-importer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ class ModuleImporter {
// use the algorithm to determine the parallel and sequential execution of modules
for (let moduleName of this.importConfig.modules.types) {
if (this.importConfig.globalModules.includes(moduleName) && this.importConfig['exclude-global-modules']) {
log(this.importConfig, `Skipping the import of Global Module '${moduleName}' ...`,'warn');
log(this.importConfig, `Skipping the import of the global module '${moduleName}', as it already exists in the stack.`,'warn');
continue;
}
await this.importByModuleByName(moduleName);
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 4294568

Please sign in to comment.