@@ -7,12 +7,11 @@ import { join, resolve } from 'path';
77import cloneDeep from 'lodash/cloneDeep' ;
88import { cliux , sanitizePath , TableFlags , TableHeader } from '@contentstack/cli-utilities' ;
99import { createWriteStream , existsSync , mkdirSync , readFileSync , writeFileSync , rmSync } from 'fs' ;
10-
1110import config from './config' ;
1211import { print } from './util/log' ;
1312import { auditMsg } from './messages' ;
1413import { BaseCommand } from './base-command' ;
15- import { Entries , GlobalField , ContentType , Extensions , Workflows , Assets } from './modules' ;
14+ import { Entries , GlobalField , ContentType , Extensions , Workflows , Assets , FieldRule } from './modules' ;
1615import {
1716 CommandNames ,
1817 ContentTypeStruct ,
@@ -61,6 +60,7 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
6160 missingRefInCustomRoles,
6261 missingEnvLocalesInAssets,
6362 missingEnvLocalesInEntries,
63+ missingFieldRules,
6464 missingMultipleFields
6565 } = await this . scanAndFix ( ) ;
6666
@@ -71,6 +71,7 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
7171 ] ) ;
7272 this . showOutputOnScreenWorkflowsAndExtension ( [ { module : 'Extensions' , missingRefs : missingCtRefsInExtensions } ] ) ;
7373 this . showOutputOnScreenWorkflowsAndExtension ( [ { module : 'Workflows' , missingRefs : missingCtRefsInWorkflow } ] ) ;
74+
7475 this . showOutputOnScreenWorkflowsAndExtension ( [ { module : 'Entries Select Field' , missingRefs : missingSelectFeild } ] ) ;
7576 this . showOutputOnScreenWorkflowsAndExtension ( [
7677 { module : 'Entries Mandatory Field' , missingRefs : missingMandatoryFields } ,
@@ -79,6 +80,8 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
7980 this . showOutputOnScreenWorkflowsAndExtension ( [ { module : 'Custom Roles' , missingRefs : missingRefInCustomRoles } ] ) ;
8081 this . showOutputOnScreenWorkflowsAndExtension ( [ { module : 'Assets' , missingRefs : missingEnvLocalesInAssets } ] ) ;
8182 this . showOutputOnScreenWorkflowsAndExtension ( [ { module : 'Entries Missing Locale and Environments' , missingRefs : missingEnvLocalesInEntries } ] )
83+ this . showOutputOnScreenWorkflowsAndExtension ( [ { module : 'Field Rules' , missingRefs : missingFieldRules } ] )
84+
8285 this . showOutputOnScreenWorkflowsAndExtension ( [ { module : 'Entries Changed Multiple Fields' , missingRefs : missingMultipleFields } ] )
8386 if (
8487 ! isEmpty ( missingCtRefs ) ||
@@ -90,7 +93,8 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
9093 ! isEmpty ( missingTitleFields ) ||
9194 ! isEmpty ( missingRefInCustomRoles ) ||
9295 ! isEmpty ( missingEnvLocalesInAssets ) ||
93- ! isEmpty ( missingEnvLocalesInEntries ) ||
96+ ! isEmpty ( missingEnvLocalesInEntries ) ||
97+ ! isEmpty ( missingFieldRules ) ||
9498 ! isEmpty ( missingMultipleFields )
9599 ) {
96100 if ( this . currentCommand === 'cm:stacks:audit' ) {
@@ -121,7 +125,8 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
121125 ! isEmpty ( missingSelectFeild ) ||
122126 ! isEmpty ( missingRefInCustomRoles ) ||
123127 ! isEmpty ( missingEnvLocalesInAssets ) ||
124- ! isEmpty ( missingEnvLocalesInEntries )
128+ ! isEmpty ( missingEnvLocalesInEntries ) ||
129+ ! isEmpty ( missingFieldRules )
125130 ) ;
126131 }
127132
@@ -145,6 +150,7 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
145150 missingRefInCustomRoles ,
146151 missingEnvLocalesInAssets ,
147152 missingEnvLocalesInEntries ,
153+ missingFieldRules ,
148154 missingMultipleFields ;
149155
150156 for ( const module of this . sharedConfig . flags . modules || this . sharedConfig . modules ) {
@@ -216,6 +222,10 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
216222 missingRefInCustomRoles = await new CustomRoles ( cloneDeep ( constructorParam ) ) . run ( ) ;
217223 await this . prepareReport ( module , missingRefInCustomRoles ) ;
218224 break ;
225+ case 'field-rules' :
226+ missingFieldRules = await new FieldRule ( cloneDeep ( constructorParam ) ) . run ( ) ;
227+ await this . prepareReport ( module , missingFieldRules ) ;
228+ break ;
219229 }
220230
221231 print ( [
@@ -244,6 +254,7 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
244254 missingRefInCustomRoles,
245255 missingEnvLocalesInAssets,
246256 missingEnvLocalesInEntries,
257+ missingFieldRules,
247258 missingMultipleFields
248259 } ;
249260 }
@@ -404,7 +415,8 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
404415 key === 'content_types' ||
405416 key === 'branches' ||
406417 key === 'missingCTSelectFieldValues' ||
407- key === 'missingFieldUid'
418+ key === 'missingFieldUid' ||
419+ key === 'action'
408420 ) {
409421 return chalk . red ( typeof cellValue === 'object' ? JSON . stringify ( cellValue ) : cellValue ) ;
410422 } else {
@@ -429,7 +441,7 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
429441 * @returns The function `prepareReport` returns a Promise that resolves to `void`.
430442 */
431443 prepareReport (
432- moduleName : keyof typeof config . moduleConfig | keyof typeof config . ReportTitleForEntries ,
444+ moduleName : keyof typeof config . moduleConfig | keyof typeof config . ReportTitleForEntries | 'field-rules' ,
433445 listOfMissingRefs : Record < string , any > ,
434446 ) : Promise < void > {
435447 if ( isEmpty ( listOfMissingRefs ) ) return Promise . resolve ( void 0 ) ;
@@ -459,7 +471,7 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
459471 * @returns The function `prepareCSV` returns a Promise that resolves to `void`.
460472 */
461473 prepareCSV (
462- moduleName : keyof typeof config . moduleConfig | keyof typeof config . ReportTitleForEntries ,
474+ moduleName : keyof typeof config . moduleConfig | keyof typeof config . ReportTitleForEntries | 'field-rules' ,
463475 listOfMissingRefs : Record < string , any > ,
464476 ) : Promise < void > {
465477 if ( Object . keys ( config . moduleConfig ) . includes ( moduleName ) || config . feild_level_modules . includes ( moduleName ) ) {
0 commit comments