Skip to content

Commit e4d3274

Browse files
shafeeqd959naman-contentstack
authored andcommitted
fixed audit plugin
1 parent 5541a49 commit e4d3274

7 files changed

Lines changed: 506 additions & 252 deletions

File tree

package-lock.json

Lines changed: 112 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/contentstack-audit/src/audit-base-command.ts

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,17 @@ import { v4 as uuid } from 'uuid';
55
import isEmpty from 'lodash/isEmpty';
66
import { join, resolve } from 'path';
77
import cloneDeep from 'lodash/cloneDeep';
8-
import { cliux, sanitizePath, TableFlags, TableHeader, log, configHandler, CLIProgressManager, clearProgressModuleSetting, readContentTypeSchemas } from '@contentstack/cli-utilities';
8+
import {
9+
cliux,
10+
sanitizePath,
11+
TableFlags,
12+
TableHeader,
13+
log,
14+
configHandler,
15+
CLIProgressManager,
16+
clearProgressModuleSetting,
17+
readContentTypeSchemas,
18+
} from '@contentstack/cli-utilities';
919
import { createWriteStream, existsSync, mkdirSync, readFileSync, writeFileSync, rmSync } from 'fs';
1020
import config from './config';
1121
import { print } from './util/log';
@@ -59,7 +69,7 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
5969
*/
6070
async start(command: CommandNames): Promise<boolean> {
6171
this.currentCommand = command;
62-
72+
6373
// Set progress supported module and console logs setting BEFORE any log calls
6474
// This ensures the logger respects the setting when it's initialized
6575
const logConfig = configHandler.get('log') || {};
@@ -68,10 +78,10 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
6878
configHandler.set('log.showConsoleLogs', false);
6979
}
7080
configHandler.set('log.progressSupportedModule', 'audit');
71-
81+
7282
// Initialize global summary for progress tracking
7383
CLIProgressManager.initializeGlobalSummary('AUDIT', '', 'Auditing content...');
74-
84+
7585
await this.promptQueue();
7686
await this.createBackUp();
7787
this.sharedConfig.reportPath = resolve(this.flags['report-path'] || process.cwd(), 'audit-report');
@@ -166,7 +176,7 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
166176

167177
// Print comprehensive summary at the end
168178
CLIProgressManager.printGlobalSummary();
169-
179+
170180
// Clear progress module setting now that audit is complete
171181
clearProgressModuleSetting();
172182

@@ -234,11 +244,11 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
234244

235245
let dataModuleWise: Record<string, any> = await new ModuleDataReader(cloneDeep(constructorParam)).run();
236246
log.debug(`Data module wise: ${JSON.stringify(dataModuleWise)}`, this.auditContext);
237-
247+
238248
// Extract logConfig and showConsoleLogs once before the loop to reuse throughout
239249
const logConfig = configHandler.get('log') || {};
240250
const showConsoleLogs = logConfig.showConsoleLogs ?? false;
241-
251+
242252
for (const module of this.sharedConfig.flags.modules || this.sharedConfig.modules) {
243253
// Update audit context with current module
244254
this.auditContext = { module: module };
@@ -480,10 +490,7 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
480490
* `gfSchema`. The values of these properties are the parsed JSON data from two different files.
481491
*/
482492
getCtAndGfSchema() {
483-
const ctDirPath = join(
484-
this.sharedConfig.basePath,
485-
this.sharedConfig.moduleConfig['content-types'].dirName,
486-
);
493+
const ctDirPath = join(this.sharedConfig.basePath, this.sharedConfig.moduleConfig['content-types'].dirName);
487494
const gfPath = join(
488495
this.sharedConfig.basePath,
489496
this.sharedConfig.moduleConfig['global-fields'].dirName,

0 commit comments

Comments
 (0)