Skip to content

Commit a296583

Browse files
committed
fix: resolved the table not displaying ct_uid in output. Removed console and formatting
1 parent 96137e4 commit a296583

File tree

1 file changed

+46
-43
lines changed

1 file changed

+46
-43
lines changed

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

Lines changed: 46 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,20 @@ export default class ContentType {
5353
this.gfSchema = gfSchema;
5454
this.moduleName = this.validateModules(moduleName!, this.config.moduleConfig);
5555
this.fileName = config.moduleConfig[this.moduleName].fileName;
56-
this.folderPath = resolve(sanitizePath(config.basePath), sanitizePath(config.moduleConfig[this.moduleName].dirName));
56+
this.folderPath = resolve(
57+
sanitizePath(config.basePath),
58+
sanitizePath(config.moduleConfig[this.moduleName].dirName),
59+
);
5760
}
5861

59-
validateModules(moduleName: keyof typeof auditConfig.moduleConfig, moduleConfig: Record<string, unknown>): keyof typeof auditConfig.moduleConfig {
62+
validateModules(
63+
moduleName: keyof typeof auditConfig.moduleConfig,
64+
moduleConfig: Record<string, unknown>,
65+
): keyof typeof auditConfig.moduleConfig {
6066
if (Object.keys(moduleConfig).includes(moduleName)) {
6167
return moduleName;
6268
}
63-
return 'content-types'
69+
return 'content-types';
6470
}
6571
/**
6672
* The `run` function checks if a folder path exists, sets the schema based on the module name,
@@ -121,7 +127,7 @@ export default class ContentType {
121127
if (existsSync(extensionPath)) {
122128
try {
123129
this.extensions = Object.keys(JSON.parse(readFileSync(extensionPath, 'utf8')));
124-
} catch (error) { }
130+
} catch (error) {}
125131
}
126132

127133
if (existsSync(marketplacePath)) {
@@ -134,7 +140,7 @@ export default class ContentType {
134140
) as string[];
135141
this.extensions.push(...metaData);
136142
}
137-
} catch (error) { }
143+
} catch (error) {}
138144
}
139145
}
140146

@@ -270,19 +276,19 @@ export default class ContentType {
270276

271277
return missingRefs.length
272278
? [
273-
{
274-
tree,
275-
data_type,
276-
missingRefs,
277-
display_name,
278-
ct_uid: this.currentUid,
279-
name: this.currentTitle,
280-
treeStr: tree
281-
.map(({ name }) => name)
282-
.filter((val) => val)
283-
.join(' ➜ '),
284-
},
285-
]
279+
{
280+
tree,
281+
data_type,
282+
missingRefs,
283+
display_name,
284+
ct_uid: this.currentUid,
285+
name: this.currentTitle,
286+
treeStr: tree
287+
.map(({ name }) => name)
288+
.filter((val) => val)
289+
.join(' ➜ '),
290+
},
291+
]
286292
: [];
287293
}
288294

@@ -297,37 +303,36 @@ export default class ContentType {
297303
*/
298304
async validateGlobalField(tree: Record<string, unknown>[], field: GlobalFieldDataType): Promise<void> {
299305
// NOTE Any GlobalField related logic can be added here
300-
if(this.moduleName==='global-fields') {
306+
if (this.moduleName === 'global-fields') {
301307
let { reference_to } = field;
302308
const refExist = find(this.schema, { uid: reference_to });
303-
if(!refExist){
309+
if (!refExist) {
304310
this.missingRefs[this.currentUid].push({
305311
tree,
306-
ct_uid: this.currentUid,
312+
ct: this.currentUid,
307313
name: this.currentTitle,
308314
data_type: field.data_type,
309315
display_name: field.display_name,
310316
missingRefs: 'Referred Global Field Does not Exist',
311317
treeStr: tree.map(({ name }) => name).join(' ➜ '),
312318
});
319+
return void 0;
313320
}
314-
}
315-
else {
321+
} else if (this.moduleName === 'content-types') {
316322
if (!field.schema && !this.fix) {
317323
this.missingRefs[this.currentUid].push({
318324
tree,
319-
ct_uid: this.currentUid,
325+
ct: this.currentUid,
320326
name: this.currentTitle,
321327
data_type: field.data_type,
322328
display_name: field.display_name,
323329
missingRefs: 'Empty schema found',
324330
treeStr: tree.map(({ name }) => name).join(' ➜ '),
325331
});
326-
332+
327333
return void 0;
328334
}
329335
}
330-
331336

332337
await this.lookForReference(tree, field);
333338
}
@@ -416,19 +421,19 @@ export default class ContentType {
416421

417422
return missingRefs.length
418423
? [
419-
{
420-
tree,
421-
data_type,
422-
missingRefs,
423-
display_name,
424-
ct_uid: this.currentUid,
425-
name: this.currentTitle,
426-
treeStr: tree
427-
.map(({ name }) => name)
428-
.filter((val) => val)
429-
.join(' ➜ '),
430-
},
431-
]
424+
{
425+
tree,
426+
data_type,
427+
missingRefs,
428+
display_name,
429+
ct_uid: this.currentUid,
430+
name: this.currentTitle,
431+
treeStr: tree
432+
.map(({ name }) => name)
433+
.filter((val) => val)
434+
.join(' ➜ '),
435+
},
436+
]
432437
: [];
433438
}
434439

@@ -521,7 +526,7 @@ export default class ContentType {
521526
missingRefs: [reference_to],
522527
treeStr: tree.map(({ name }) => name).join(' ➜ '),
523528
});
524-
} else if (!field.schema && this.moduleName==='content-types') {
529+
} else if (!field.schema && this.moduleName === 'content-types') {
525530
const gfSchema = find(this.gfSchema, { uid: field.reference_to })?.schema;
526531

527532
if (gfSchema) {
@@ -538,10 +543,8 @@ export default class ContentType {
538543
treeStr: tree.map(({ name }) => name).join(' ➜ '),
539544
});
540545
}
541-
} else if (!field.schema && this.moduleName==='global-fields') {
542-
console.log(this.moduleName,this.currentTitle,field)
546+
} else if (!field.schema && this.moduleName === 'global-fields') {
543547
const gfSchema = find(this.gfSchema, { uid: field.reference_to })?.schema;
544-
console.log("gfSchema",gfSchema)
545548
if (gfSchema) {
546549
field.schema = gfSchema as GlobalFieldSchemaTypes[];
547550

0 commit comments

Comments
 (0)