Skip to content

Commit c68ac12

Browse files
authored
Merge pull request #1885 from contentstack/fix/DX-2894
Fix: Added check for removing field
2 parents d6ab8e1 + 1291a7e commit c68ac12

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

packages/contentstack-audit/src/config/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const config = {
1313
'field-rules',
1414
],
1515
'fix-fields': ['reference', 'global_field', 'json:rte', 'json:extension', 'blocks', 'group', 'content_types'],
16+
'schema-fields-data-type': ['blocks','group','global_field'],
1617
moduleConfig: {
1718
'content-types': {
1819
name: 'content type',

packages/contentstack-audit/src/modules/content-types.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,6 @@ export default class ContentType {
185185
field.schema = this.runFixOnSchema(tree, field.schema as ContentTypeSchemaType[]);
186186
}
187187
for (let child of field.schema ?? []) {
188-
189188
if (!fixTypes.includes(child.data_type) && child.data_type !== 'json') continue;
190189

191190
switch (child.data_type) {
@@ -487,8 +486,13 @@ export default class ContentType {
487486
})
488487
.filter((val: any) => {
489488
if (this.config.skipFieldTypes.includes(val?.data_type)) return true;
490-
if (val?.schema && isEmpty(val?.schema)) return false;
491-
if (val?.reference_to && isEmpty(val?.reference_to) && val.data_type==='reference') return false;
489+
if (
490+
val?.schema &&
491+
isEmpty(val?.schema) &&
492+
(!val?.data_type || this.config['schema-fields-data-type'].includes(val.data_type))
493+
)
494+
return false;
495+
if (val?.reference_to && isEmpty(val?.reference_to) && val.data_type === 'reference') return false;
492496

493497
return !!val;
494498
}) as ContentTypeSchemaType[];

0 commit comments

Comments
 (0)