Skip to content

Feat DX - 2333 - Added Summary for Audit Fix #1867

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 15, 2025
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
411 changes: 213 additions & 198 deletions package-lock.json

Large diffs are not rendered by default.

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.11.0",
"version": "1.12.0",
"description": "Contentstack audit plugin",
"author": "Contentstack CLI",
"homepage": "https://github.com/contentstack/cli",
Expand Down
42 changes: 30 additions & 12 deletions packages/contentstack-audit/src/audit-base-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
this.showOutputOnScreenWorkflowsAndExtension([
{ module: 'Entries Changed Multiple Fields', missingRefs: missingMultipleFields },
]);

}
this.showOutputOnScreenWorkflowsAndExtension([{ module: 'Summary', missingRefs: this.summaryDataToPrint }]);

Expand Down Expand Up @@ -186,7 +185,7 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
fix: this.currentCommand === 'cm:stacks:audit:fix',
};

let dataModuleWise: Record<string,any> = await new ModuleDataReader(cloneDeep(constructorParam)).run();
let dataModuleWise: Record<string, any> = await new ModuleDataReader(cloneDeep(constructorParam)).run();
for (const module of this.sharedConfig.flags.modules || this.sharedConfig.modules) {
print([
{
Expand Down Expand Up @@ -449,15 +448,16 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
.map((key: string) => ({
value: key,
formatter: (cellValue: any) => {
if (key === 'fixStatus' || key === 'Fixable') {
if (key === 'fixStatus' || key === 'Fixable' || key === 'Fixed') {
return chalk.green(typeof cellValue === 'object' ? JSON.stringify(cellValue) : cellValue);
} else if (
key === 'content_types' ||
key === 'branches' ||
key === 'missingCTSelectFieldValues' ||
key === 'missingFieldUid' ||
key === 'action' ||
key === 'Non-Fixable'
key === 'Non-Fixable' ||
key === 'Not-Fixed'
) {
return chalk.red(typeof cellValue === 'object' ? JSON.stringify(cellValue) : cellValue);
} else {
Expand Down Expand Up @@ -590,27 +590,45 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma

for (const [key, refs] of missingRefs) {
const uids = Object.keys(refs);
if (key !== 'missingTitleFields') {
uids.forEach((uid) => uidSet.add(uid));
} else {

if (
key === 'missingTitleFields' ||
(!this.sharedConfig.fixSelectField &&
key === 'missingSelectFeild' &&
this.currentCommand === 'cm:stacks:audit:fix')
) {
uids.forEach((uid) => {
if (uidSet.has(uid)) {
uidSet.delete(uid);
nonFixable.add(uid);
} else {
nonFixable.add(uid);
}
});
} else {
uids.forEach((uid) => uidSet.add(uid));
}
}

result.Passed = dataExported.Total - uidSet.size;
result.Fixable = uidSet.size - nonFixable.size;
result['Non-Fixable'] = nonFixable.size;
result.Passed = dataExported.Total - (uidSet.size + nonFixable.size);
if (this.currentCommand === 'cm:stacks:audit:fix') {
result.Fixed = uidSet.size;
result['Not-Fixed'] = nonFixable.size;
} else {
result.Fixable = uidSet.size;
result['Non-Fixable'] = nonFixable.size;
}
} else {
const missingCount = Object.keys(listOfMissingRefs).length;
result.Passed = dataExported.Total - missingCount;

result.Fixable = missingCount > 0 && isFixable ? missingCount : 0;
result['Non-Fixable'] = missingCount > 0 && !isFixable ? missingCount : 0;
if (this.currentCommand === 'cm:stacks:audit:fix') {
result.Fixed = missingCount > 0 && isFixable ? missingCount : 0;
result['Not-Fixed'] = missingCount > 0 && !isFixable ? missingCount : 0;
} else {
result.Fixable = missingCount > 0 && isFixable ? missingCount : 0;
result['Non-Fixable'] = missingCount > 0 && !isFixable ? missingCount : 0;
}
}

this.summaryDataToPrint.push(result);
Expand Down
2 changes: 2 additions & 0 deletions packages/contentstack-audit/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,8 @@ const config = {
"Total",
"Fixable",
"Non-Fixable",
"Fixed",
"Not-Fixed",
"Passed",
],
ReportTitleForEntries: {
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-audit/src/modules/modulesData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ export default class ModuleDataReader {
count = this.gfSchema.length;
break;
case 'assets':
count = keys(await this.readEntryAssetsModule(this.folderPath,'assets')).length;
count = await this.readEntryAssetsModule(join(this.folderPath,'assets'),'assets') || 0;
break;
case 'entries':
{
Expand Down
4 changes: 3 additions & 1 deletion packages/contentstack-audit/src/types/content-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,9 @@ enum OutputColumn {
"Total"="Total",
"Passed"="Passed",
"Fixable"="Fixable",
"Non-Fixable"="Non-Fixable"
"Non-Fixable"="Non-Fixable",
"Fixed" = "Fixed",
"Not-Fixed" = "Not-Fixed",
}

export {
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-clone/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"dependencies": {
"@colors/colors": "^1.6.0",
"@contentstack/cli-cm-export": "~1.16.0",
"@contentstack/cli-cm-import": "~1.21.1",
"@contentstack/cli-cm-import": "~1.21.2",
"@contentstack/cli-command": "~1.5.0",
"@contentstack/cli-utilities": "~1.11.0",
"chalk": "^4.1.2",
Expand Down
6 changes: 3 additions & 3 deletions packages/contentstack-import/package.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
{
"name": "@contentstack/cli-cm-import",
"description": "Contentstack CLI plugin to import content into stack",
"version": "1.21.1",
"version": "1.21.2",
"author": "Contentstack",
"bugs": "https://github.com/contentstack/cli/issues",
"dependencies": {
"@contentstack/cli-audit": "~1.11.0",
"@contentstack/cli-audit": "~1.12.0",
"@contentstack/cli-command": "~1.5.0",
"@contentstack/cli-utilities": "~1.11.0",
"@contentstack/management": "~1.20.1",
"@contentstack/management": "~1.20.2",
"@contentstack/cli-variants": "~1.2.0",
"@oclif/core": "^4.2.7",
"big-json": "^3.2.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/contentstack-seed/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
"author": "Contentstack",
"bugs": "https://github.com/contentstack/cli/issues",
"dependencies": {
"@contentstack/cli-cm-import": "~1.21.1",
"@contentstack/cli-cm-import": "~1.21.2",
"@contentstack/cli-command": "~1.5.0",
"@contentstack/cli-utilities": "~1.11.0",
"@contentstack/management": "~1.20.1",
"@contentstack/management": "~1.20.2",
"inquirer": "8.2.6",
"mkdirp": "^1.0.4",
"tar": "^6.2.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-utilities/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
"author": "contentstack",
"license": "MIT",
"dependencies": {
"@contentstack/management": "~1.20.1",
"@contentstack/management": "~1.20.2",
"@contentstack/marketplace-sdk": "^1.2.5",
"@oclif/core": "^4.2.7",
"axios": "^1.8.2",
Expand Down
22 changes: 11 additions & 11 deletions packages/contentstack/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@
"prepack": "pnpm compile && oclif manifest && oclif readme"
},
"dependencies": {
"@contentstack/cli-audit": "~1.11.0",
"@contentstack/cli-audit": "~1.12.0",
"@contentstack/cli-auth": "~1.4.0",
"@contentstack/cli-cm-bootstrap": "~1.14.0",
"@contentstack/cli-cm-branches": "~1.4.0",
"@contentstack/cli-cm-bulk-publish": "~1.8.0",
"@contentstack/cli-cm-clone": "~1.14.0",
"@contentstack/cli-cm-export": "~1.16.0",
"@contentstack/cli-cm-export-to-csv": "~1.8.0",
"@contentstack/cli-cm-import": "~1.21.1",
"@contentstack/cli-cm-import": "~1.21.2",
"@contentstack/cli-cm-import-setup": "1.2.0",
"@contentstack/cli-cm-migrate-rte": "~1.5.0",
"@contentstack/cli-cm-seed": "~1.11.0",
Expand All @@ -40,14 +40,14 @@
"@contentstack/cli-migration": "~1.7.0",
"@contentstack/cli-utilities": "~1.11.0",
"@contentstack/cli-variants": "~1.2.0",
"@contentstack/management": "~1.20.1",
"@oclif/core": "^4.2.7",
"@oclif/plugin-help": "^6.2.25",
"@oclif/plugin-not-found": "^3.2.42",
"@oclif/plugin-plugins": "^5.4.24",
"@contentstack/management": "~1.20.2",
"@oclif/core": "^4.2.10",
"@oclif/plugin-help": "^6.2.27",
"@oclif/plugin-not-found": "^3.2.49",
"@oclif/plugin-plugins": "^5.4.36",
"chalk": "^4.1.2",
"debug": "^4.4.0",
"figlet": "^1.8.0",
"figlet": "^1.8.1",
"inquirer": "8.2.6",
"node-machine-id": "^1.1.12",
"open": "^8.4.2",
Expand All @@ -67,16 +67,16 @@
"@types/sinon": "^10.0.20",
"chai": "^4.5.0",
"eslint": "^8.57.1",
"eslint-config-oclif": "^6.0.15",
"eslint-config-oclif": "^6.0.44",
"eslint-config-oclif-typescript": "^3.1.13",
"globby": "^10.0.2",
"mocha": "10.8.2",
"nock": "^13.5.6",
"nyc": "^15.1.0",
"oclif": "^4.17.30",
"oclif": "^4.17.44",
"rimraf": "^5.0.10",
"shelljs": "^0.9.2",
"sinon": "^19.0.2",
"sinon": "^19.0.5",
"tmp": "^0.2.3",
"ts-node": "^10.9.2",
"tslib": "^2.8.1",
Expand Down
Loading
Loading