@@ -7,12 +7,11 @@ import { join, resolve } from 'path';
77import cloneDeep from 'lodash/cloneDeep' ;
88import { cliux , sanitizePath , ux } 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 ,
@@ -60,7 +59,8 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
6059 missingTitleFields,
6160 missingRefInCustomRoles,
6261 missingEnvLocalesInAssets,
63- missingEnvLocalesInEntries
62+ missingEnvLocalesInEntries,
63+ missingFieldRules
6464 } = await this . scanAndFix ( ) ;
6565
6666 this . showOutputOnScreen ( [
@@ -70,6 +70,7 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
7070 ] ) ;
7171 this . showOutputOnScreenWorkflowsAndExtension ( [ { module : 'Extensions' , missingRefs : missingCtRefsInExtensions } ] ) ;
7272 this . showOutputOnScreenWorkflowsAndExtension ( [ { module : 'Workflows' , missingRefs : missingCtRefsInWorkflow } ] ) ;
73+
7374 this . showOutputOnScreenWorkflowsAndExtension ( [ { module : 'Entries Select Field' , missingRefs : missingSelectFeild } ] ) ;
7475 this . showOutputOnScreenWorkflowsAndExtension ( [
7576 { module : 'Entries Mandatory Field' , missingRefs : missingMandatoryFields } ,
@@ -80,6 +81,8 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
8081 this . showOutputOnScreenWorkflowsAndExtension ( [ { module : 'Custom Roles' , missingRefs : missingRefInCustomRoles } ] ) ;
8182 this . showOutputOnScreenWorkflowsAndExtension ( [ { module : 'Assets' , missingRefs : missingEnvLocalesInAssets } ] ) ;
8283 this . showOutputOnScreenWorkflowsAndExtension ( [ { module : 'Entries Missing Locale and Environments' , missingRefs : missingEnvLocalesInEntries } ] )
84+ this . showOutputOnScreenWorkflowsAndExtension ( [ { module : 'Field Rules' , missingRefs : missingFieldRules } ] )
85+
8386 if (
8487 ! isEmpty ( missingCtRefs ) ||
8588 ! isEmpty ( missingGfRefs ) ||
@@ -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 ( missingSelectFeild )
9498 ) {
9599 if ( this . currentCommand === 'cm:stacks:audit' ) {
96100 this . log ( this . $t ( auditMsg . FINAL_REPORT_PATH , { path : this . sharedConfig . reportPath } ) , 'warn' ) ;
@@ -120,7 +124,8 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
120124 ! isEmpty ( missingSelectFeild ) ||
121125 ! isEmpty ( missingRefInCustomRoles ) ||
122126 ! isEmpty ( missingEnvLocalesInAssets ) ||
123- ! isEmpty ( missingEnvLocalesInEntries )
127+ ! isEmpty ( missingEnvLocalesInEntries ) ||
128+ ! isEmpty ( missingFieldRules )
124129 ) ;
125130 }
126131
@@ -143,7 +148,8 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
143148 missingTitleFields ,
144149 missingRefInCustomRoles ,
145150 missingEnvLocalesInAssets ,
146- missingEnvLocalesInEntries ;
151+ missingEnvLocalesInEntries ,
152+ missingFieldRules ;
147153
148154 for ( const module of this . sharedConfig . flags . modules || this . sharedConfig . modules ) {
149155 print ( [
@@ -211,6 +217,10 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
211217 missingRefInCustomRoles = await new CustomRoles ( cloneDeep ( constructorParam ) ) . run ( ) ;
212218 await this . prepareReport ( module , missingRefInCustomRoles ) ;
213219 break ;
220+ case 'field-rules' :
221+ missingFieldRules = await new FieldRule ( cloneDeep ( constructorParam ) ) . run ( ) ;
222+ await this . prepareReport ( module , missingFieldRules ) ;
223+ break ;
214224 }
215225
216226 print ( [
@@ -238,7 +248,8 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
238248 missingTitleFields,
239249 missingRefInCustomRoles,
240250 missingEnvLocalesInAssets,
241- missingEnvLocalesInEntries
251+ missingEnvLocalesInEntries,
252+ missingFieldRules
242253 } ;
243254 }
244255
@@ -435,7 +446,7 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
435446 * @returns The function `prepareReport` returns a Promise that resolves to `void`.
436447 */
437448 prepareReport (
438- moduleName : keyof typeof config . moduleConfig | keyof typeof config . ReportTitleForEntries ,
449+ moduleName : keyof typeof config . moduleConfig | keyof typeof config . ReportTitleForEntries | 'field-rules' ,
439450 listOfMissingRefs : Record < string , any > ,
440451 ) : Promise < void > {
441452 if ( isEmpty ( listOfMissingRefs ) ) return Promise . resolve ( void 0 ) ;
@@ -462,7 +473,7 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
462473 * @returns The function `prepareCSV` returns a Promise that resolves to `void`.
463474 */
464475 prepareCSV (
465- moduleName : keyof typeof config . moduleConfig | keyof typeof config . ReportTitleForEntries ,
476+ moduleName : keyof typeof config . moduleConfig | keyof typeof config . ReportTitleForEntries | 'field-rules' ,
466477 listOfMissingRefs : Record < string , any > ,
467478 ) : Promise < void > {
468479 if ( Object . keys ( config . moduleConfig ) . includes ( moduleName ) || config . feild_level_modules . includes ( moduleName ) ) {
0 commit comments