@contentstack/cli-audit 1.10.0 → 1.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -17,8 +17,11 @@ const messages_1 = require("./messages");
17
17
  const base_command_1 = require("./base-command");
18
18
  const modules_1 = require("./modules");
19
19
  const types_1 = require("./types");
20
- const custom_roles_1 = tslib_1.__importDefault(require("./modules/custom-roles"));
21
20
  class AuditBaseCommand extends base_command_1.BaseCommand {
21
+ constructor() {
22
+ super(...arguments);
23
+ this.summaryDataToPrint = [];
24
+ }
22
25
  get fixStatus() {
23
26
  return {
24
27
  fixStatus: {
@@ -41,25 +44,35 @@ class AuditBaseCommand extends base_command_1.BaseCommand {
41
44
  await this.promptQueue();
42
45
  await this.createBackUp();
43
46
  this.sharedConfig.reportPath = (0, path_1.resolve)(this.flags['report-path'] || process.cwd(), 'audit-report');
44
- const { missingCtRefs, missingGfRefs, missingEntryRefs, missingCtRefsInExtensions, missingCtRefsInWorkflow, missingSelectFeild, missingMandatoryFields, missingTitleFields, missingRefInCustomRoles, missingEnvLocalesInAssets, missingEnvLocalesInEntries, missingMultipleFields } = await this.scanAndFix();
45
- this.showOutputOnScreen([
46
- { module: 'Content types', missingRefs: missingCtRefs },
47
- { module: 'Global Fields', missingRefs: missingGfRefs },
48
- { module: 'Entries', missingRefs: missingEntryRefs },
49
- ]);
50
- this.showOutputOnScreenWorkflowsAndExtension([{ module: 'Extensions', missingRefs: missingCtRefsInExtensions }]);
51
- this.showOutputOnScreenWorkflowsAndExtension([{ module: 'Workflows', missingRefs: missingCtRefsInWorkflow }]);
52
- this.showOutputOnScreenWorkflowsAndExtension([{ module: 'Entries Select Field', missingRefs: missingSelectFeild }]);
53
- this.showOutputOnScreenWorkflowsAndExtension([
54
- { module: 'Entries Mandatory Field', missingRefs: missingMandatoryFields },
55
- ]);
56
- this.showOutputOnScreenWorkflowsAndExtension([
57
- { module: 'Entries Title Field', missingRefs: missingTitleFields },
58
- ]);
59
- this.showOutputOnScreenWorkflowsAndExtension([{ module: 'Custom Roles', missingRefs: missingRefInCustomRoles }]);
60
- this.showOutputOnScreenWorkflowsAndExtension([{ module: 'Assets', missingRefs: missingEnvLocalesInAssets }]);
61
- this.showOutputOnScreenWorkflowsAndExtension([{ module: 'Entries Missing Locale and Environments', missingRefs: missingEnvLocalesInEntries }]);
62
- this.showOutputOnScreenWorkflowsAndExtension([{ module: 'Entries Changed Multiple Fields', missingRefs: missingMultipleFields }]);
47
+ const { missingCtRefs, missingGfRefs, missingEntryRefs, missingCtRefsInExtensions, missingCtRefsInWorkflow, missingSelectFeild, missingMandatoryFields, missingTitleFields, missingRefInCustomRoles, missingEnvLocalesInAssets, missingEnvLocalesInEntries, missingFieldRules, missingMultipleFields, } = await this.scanAndFix();
48
+ if (this.flags['show-console-output']) {
49
+ this.showOutputOnScreen([
50
+ { module: 'Content types', missingRefs: missingCtRefs },
51
+ { module: 'Global Fields', missingRefs: missingGfRefs },
52
+ { module: 'Entries', missingRefs: missingEntryRefs },
53
+ ]);
54
+ this.showOutputOnScreenWorkflowsAndExtension([{ module: 'Extensions', missingRefs: missingCtRefsInExtensions }]);
55
+ this.showOutputOnScreenWorkflowsAndExtension([{ module: 'Workflows', missingRefs: missingCtRefsInWorkflow }]);
56
+ this.showOutputOnScreenWorkflowsAndExtension([
57
+ { module: 'Entries Select Field', missingRefs: missingSelectFeild },
58
+ ]);
59
+ this.showOutputOnScreenWorkflowsAndExtension([
60
+ { module: 'Entries Mandatory Field', missingRefs: missingMandatoryFields },
61
+ ]);
62
+ this.showOutputOnScreenWorkflowsAndExtension([
63
+ { module: 'Entries Title Field', missingRefs: missingTitleFields },
64
+ ]);
65
+ this.showOutputOnScreenWorkflowsAndExtension([{ module: 'Custom Roles', missingRefs: missingRefInCustomRoles }]);
66
+ this.showOutputOnScreenWorkflowsAndExtension([{ module: 'Assets', missingRefs: missingEnvLocalesInAssets }]);
67
+ this.showOutputOnScreenWorkflowsAndExtension([
68
+ { module: 'Entries Missing Locale and Environments', missingRefs: missingEnvLocalesInEntries },
69
+ ]);
70
+ this.showOutputOnScreenWorkflowsAndExtension([{ module: 'Field Rules', missingRefs: missingFieldRules }]);
71
+ this.showOutputOnScreenWorkflowsAndExtension([
72
+ { module: 'Entries Changed Multiple Fields', missingRefs: missingMultipleFields },
73
+ ]);
74
+ }
75
+ this.showOutputOnScreenWorkflowsAndExtension([{ module: 'Summary', missingRefs: this.summaryDataToPrint }]);
63
76
  if (!(0, isEmpty_1.default)(missingCtRefs) ||
64
77
  !(0, isEmpty_1.default)(missingGfRefs) ||
65
78
  !(0, isEmpty_1.default)(missingEntryRefs) ||
@@ -70,6 +83,7 @@ class AuditBaseCommand extends base_command_1.BaseCommand {
70
83
  !(0, isEmpty_1.default)(missingRefInCustomRoles) ||
71
84
  !(0, isEmpty_1.default)(missingEnvLocalesInAssets) ||
72
85
  !(0, isEmpty_1.default)(missingEnvLocalesInEntries) ||
86
+ !(0, isEmpty_1.default)(missingFieldRules) ||
73
87
  !(0, isEmpty_1.default)(missingMultipleFields)) {
74
88
  if (this.currentCommand === 'cm:stacks:audit') {
75
89
  this.log(this.$t(messages_1.auditMsg.FINAL_REPORT_PATH, { path: this.sharedConfig.reportPath }), 'warn');
@@ -96,7 +110,8 @@ class AuditBaseCommand extends base_command_1.BaseCommand {
96
110
  !(0, isEmpty_1.default)(missingSelectFeild) ||
97
111
  !(0, isEmpty_1.default)(missingRefInCustomRoles) ||
98
112
  !(0, isEmpty_1.default)(missingEnvLocalesInAssets) ||
99
- !(0, isEmpty_1.default)(missingEnvLocalesInEntries));
113
+ !(0, isEmpty_1.default)(missingEnvLocalesInEntries) ||
114
+ !(0, isEmpty_1.default)(missingFieldRules));
100
115
  }
101
116
  /**
102
117
  * The `scan` function performs an audit on different modules (content-types, global-fields, and
@@ -107,7 +122,15 @@ class AuditBaseCommand extends base_command_1.BaseCommand {
107
122
  async scanAndFix() {
108
123
  var _a, _b, _c, _d, _e, _f;
109
124
  let { ctSchema, gfSchema } = this.getCtAndGfSchema();
110
- let missingCtRefs, missingGfRefs, missingEntryRefs, missingCtRefsInExtensions, missingCtRefsInWorkflow, missingSelectFeild, missingEntry, missingMandatoryFields, missingTitleFields, missingRefInCustomRoles, missingEnvLocalesInAssets, missingEnvLocalesInEntries, missingMultipleFields;
125
+ let missingCtRefs, missingGfRefs, missingEntryRefs, missingCtRefsInExtensions, missingCtRefsInWorkflow, missingSelectFeild, missingEntry, missingMandatoryFields, missingTitleFields, missingRefInCustomRoles, missingEnvLocalesInAssets, missingEnvLocalesInEntries, missingFieldRules, missingMultipleFields;
126
+ const constructorParam = {
127
+ ctSchema,
128
+ gfSchema,
129
+ log: this.log,
130
+ config: this.sharedConfig,
131
+ fix: this.currentCommand === 'cm:stacks:audit:fix',
132
+ };
133
+ let dataModuleWise = await new modules_1.ModuleDataReader((0, cloneDeep_1.default)(constructorParam)).run();
111
134
  for (const module of this.sharedConfig.flags.modules || this.sharedConfig.modules) {
112
135
  (0, log_1.print)([
113
136
  {
@@ -116,26 +139,22 @@ class AuditBaseCommand extends base_command_1.BaseCommand {
116
139
  message: this.$t(this.messages.AUDIT_START_SPINNER, { module }),
117
140
  },
118
141
  ]);
119
- const constructorParam = {
120
- ctSchema,
121
- gfSchema,
122
- log: this.log,
123
- moduleName: module,
124
- config: this.sharedConfig,
125
- fix: this.currentCommand === 'cm:stacks:audit:fix',
126
- };
142
+ constructorParam['moduleName'] = module;
127
143
  switch (module) {
128
144
  case 'assets':
129
145
  missingEnvLocalesInAssets = await new modules_1.Assets((0, cloneDeep_1.default)(constructorParam)).run();
130
146
  await this.prepareReport(module, missingEnvLocalesInAssets);
147
+ this.getAffectedData('assets', dataModuleWise['assets'], missingEnvLocalesInAssets);
131
148
  break;
132
149
  case 'content-types':
133
150
  missingCtRefs = await new modules_1.ContentType((0, cloneDeep_1.default)(constructorParam)).run();
134
151
  await this.prepareReport(module, missingCtRefs);
152
+ this.getAffectedData('content-types', dataModuleWise['content-types'], missingCtRefs);
135
153
  break;
136
154
  case 'global-fields':
137
155
  missingGfRefs = await new modules_1.GlobalField((0, cloneDeep_1.default)(constructorParam)).run();
138
156
  await this.prepareReport(module, missingGfRefs);
157
+ this.getAffectedData('global-fields', dataModuleWise['global-fields'], missingGfRefs);
139
158
  break;
140
159
  case 'entries':
141
160
  missingEntry = await new modules_1.Entries((0, cloneDeep_1.default)(constructorParam)).run();
@@ -151,6 +170,7 @@ class AuditBaseCommand extends base_command_1.BaseCommand {
151
170
  await this.prepareReport('Entries_Title_feild', missingTitleFields);
152
171
  await this.prepareReport('Entry_Missing_Locale_and_Env_in_Publish_Details', missingEnvLocalesInEntries);
153
172
  await this.prepareReport('Entry_Multiple_Fields', missingMultipleFields);
173
+ this.getAffectedData('entries', dataModuleWise['entries'], missingEntry);
154
174
  break;
155
175
  case 'workflows':
156
176
  missingCtRefsInWorkflow = await new modules_1.Workflows({
@@ -161,14 +181,22 @@ class AuditBaseCommand extends base_command_1.BaseCommand {
161
181
  fix: this.currentCommand === 'cm:stacks:audit:fix',
162
182
  }).run();
163
183
  await this.prepareReport(module, missingCtRefsInWorkflow);
184
+ this.getAffectedData('workflows', dataModuleWise['workflows'], missingCtRefsInWorkflow);
164
185
  break;
165
186
  case 'extensions':
166
187
  missingCtRefsInExtensions = await new modules_1.Extensions((0, cloneDeep_1.default)(constructorParam)).run();
167
188
  await this.prepareReport(module, missingCtRefsInExtensions);
189
+ this.getAffectedData('extensions', dataModuleWise['extensions'], missingCtRefsInExtensions);
168
190
  break;
169
191
  case 'custom-roles':
170
- missingRefInCustomRoles = await new custom_roles_1.default((0, cloneDeep_1.default)(constructorParam)).run();
192
+ missingRefInCustomRoles = await new modules_1.CustomRoles((0, cloneDeep_1.default)(constructorParam)).run();
171
193
  await this.prepareReport(module, missingRefInCustomRoles);
194
+ this.getAffectedData('custom-roles', dataModuleWise['custom-roles'], missingRefInCustomRoles);
195
+ break;
196
+ case 'field-rules':
197
+ missingFieldRules = await new modules_1.FieldRule((0, cloneDeep_1.default)(constructorParam)).run();
198
+ await this.prepareReport(module, missingFieldRules);
199
+ this.getAffectedData('field-rules', dataModuleWise['content-types'], missingFieldRules);
172
200
  break;
173
201
  }
174
202
  (0, log_1.print)([
@@ -184,6 +212,8 @@ class AuditBaseCommand extends base_command_1.BaseCommand {
184
212
  },
185
213
  ]);
186
214
  }
215
+ this.prepareReport('Summary', this.summaryDataToPrint);
216
+ this.prepareCSV('Summary', this.summaryDataToPrint);
187
217
  return {
188
218
  missingCtRefs,
189
219
  missingGfRefs,
@@ -196,7 +226,8 @@ class AuditBaseCommand extends base_command_1.BaseCommand {
196
226
  missingRefInCustomRoles,
197
227
  missingEnvLocalesInAssets,
198
228
  missingEnvLocalesInEntries,
199
- missingMultipleFields
229
+ missingFieldRules,
230
+ missingMultipleFields,
200
231
  };
201
232
  }
202
233
  /**
@@ -253,7 +284,7 @@ class AuditBaseCommand extends base_command_1.BaseCommand {
253
284
  * objects, where each object has two properties:
254
285
  */
255
286
  showOutputOnScreen(allMissingRefs) {
256
- var _a, _b;
287
+ var _a;
257
288
  if (this.sharedConfig.showTerminalOutput && !((_a = this.flags['external-config']) === null || _a === void 0 ? void 0 : _a.noTerminalOutput)) {
258
289
  this.log(''); // NOTE adding new line
259
290
  for (const { module, missingRefs } of allMissingRefs) {
@@ -266,31 +297,40 @@ class AuditBaseCommand extends base_command_1.BaseCommand {
266
297
  },
267
298
  ]);
268
299
  const tableValues = Object.values(missingRefs).flat();
269
- cli_utilities_1.ux.table(tableValues, Object.assign(Object.assign({ name: {
270
- minWidth: 7,
271
- header: 'Title',
272
- }, ct: {
273
- minWidth: 7,
274
- header: "Content Type"
275
- }, locale: {
276
- minWidth: 7,
277
- header: "Locale"
278
- }, display_name: {
279
- minWidth: 7,
280
- header: 'Field name',
281
- }, data_type: {
282
- minWidth: 7,
283
- header: 'Field type',
284
- }, missingRefs: {
285
- minWidth: 7,
286
- header: 'Missing references',
287
- get: (row) => {
288
- return chalk_1.default.red(typeof row.missingRefs === 'object' ? JSON.stringify(row.missingRefs) : row.missingRefs);
300
+ const tableHeaders = [
301
+ {
302
+ value: 'name',
303
+ alias: 'Title',
304
+ },
305
+ {
306
+ value: 'ct',
307
+ alias: 'Content Type',
308
+ },
309
+ {
310
+ value: 'locale',
311
+ alias: 'Locale',
312
+ },
313
+ {
314
+ value: 'display_name',
315
+ alias: 'Field name',
316
+ },
317
+ {
318
+ value: 'data_type',
319
+ alias: 'Field type',
320
+ },
321
+ {
322
+ value: 'missingRefs',
323
+ alias: 'Missing references',
324
+ formatter: (cellValue) => {
325
+ return chalk_1.default.red(typeof cellValue === 'object' ? JSON.stringify(cellValue) : cellValue);
289
326
  },
290
- } }, (((_b = tableValues[0]) === null || _b === void 0 ? void 0 : _b.fixStatus) ? this.fixStatus : {})), { treeStr: {
291
- minWidth: 7,
292
- header: 'Path',
293
- } }), Object.assign({}, this.flags));
327
+ },
328
+ {
329
+ value: 'treeStr',
330
+ alias: 'Path',
331
+ },
332
+ ];
333
+ cli_utilities_1.cliux.table(tableHeaders, tableValues, Object.assign({}, this.flags));
294
334
  this.log(''); // NOTE adding new line
295
335
  }
296
336
  }
@@ -311,33 +351,29 @@ class AuditBaseCommand extends base_command_1.BaseCommand {
311
351
  const tableValues = Object.values(missingRefs).flat();
312
352
  missingRefs = Object.values(missingRefs).flat();
313
353
  const tableKeys = Object.keys(missingRefs[0]);
314
- const arrayOfObjects = tableKeys.map((key) => {
315
- if (config_1.default.OutputTableKeys.includes(key)) {
316
- return {
317
- [key]: {
318
- minWidth: 7,
319
- header: key,
320
- get: (row) => {
321
- if (key === 'fixStatus') {
322
- return chalk_1.default.green(typeof row[key] === 'object' ? JSON.stringify(row[key]) : row[key]);
323
- }
324
- else if (key === 'content_types' ||
325
- key === 'branches' ||
326
- key === 'missingCTSelectFieldValues' ||
327
- key === 'missingFieldUid') {
328
- return chalk_1.default.red(typeof row[key] === 'object' ? JSON.stringify(row[key]) : row[key]);
329
- }
330
- else {
331
- return chalk_1.default.white(typeof row[key] === 'object' ? JSON.stringify(row[key]) : row[key]);
332
- }
333
- },
334
- },
335
- };
336
- }
337
- return {};
338
- });
339
- const mergedObject = Object.assign({}, ...arrayOfObjects);
340
- cli_utilities_1.ux.table(tableValues, mergedObject, Object.assign({}, this.flags));
354
+ const tableHeaders = tableKeys
355
+ .filter((key) => config_1.default.OutputTableKeys.includes(key)) // Remove invalid keys early
356
+ .map((key) => ({
357
+ value: key,
358
+ formatter: (cellValue) => {
359
+ if (key === 'fixStatus' || key === 'Fixable' || key === 'Fixed') {
360
+ return chalk_1.default.green(typeof cellValue === 'object' ? JSON.stringify(cellValue) : cellValue);
361
+ }
362
+ else if (key === 'content_types' ||
363
+ key === 'branches' ||
364
+ key === 'missingCTSelectFieldValues' ||
365
+ key === 'missingFieldUid' ||
366
+ key === 'action' ||
367
+ key === 'Non-Fixable' ||
368
+ key === 'Not-Fixed') {
369
+ return chalk_1.default.red(typeof cellValue === 'object' ? JSON.stringify(cellValue) : cellValue);
370
+ }
371
+ else {
372
+ return chalk_1.default.white(typeof cellValue === 'object' ? JSON.stringify(cellValue) : cellValue);
373
+ }
374
+ },
375
+ }));
376
+ cli_utilities_1.cliux.table(tableHeaders, tableValues, Object.assign({}, this.flags));
341
377
  this.log(''); // Adding a new line
342
378
  }
343
379
  }
@@ -419,5 +455,55 @@ class AuditBaseCommand extends base_command_1.BaseCommand {
419
455
  });
420
456
  }
421
457
  }
458
+ getAffectedData(module, dataExported, listOfMissingRefs, isFixable = true) {
459
+ const result = Object.assign({ Module: module }, dataExported);
460
+ if (module === 'entries') {
461
+ const missingRefs = Object.entries(listOfMissingRefs);
462
+ const uidSet = new Set();
463
+ const nonFixable = new Set();
464
+ for (const [key, refs] of missingRefs) {
465
+ const uids = Object.keys(refs);
466
+ if (key === 'missingTitleFields' ||
467
+ (!this.sharedConfig.fixSelectField &&
468
+ key === 'missingSelectFeild' &&
469
+ this.currentCommand === 'cm:stacks:audit:fix')) {
470
+ uids.forEach((uid) => {
471
+ if (uidSet.has(uid)) {
472
+ uidSet.delete(uid);
473
+ nonFixable.add(uid);
474
+ }
475
+ else {
476
+ nonFixable.add(uid);
477
+ }
478
+ });
479
+ }
480
+ else {
481
+ uids.forEach((uid) => uidSet.add(uid));
482
+ }
483
+ }
484
+ result.Passed = dataExported.Total - (uidSet.size + nonFixable.size);
485
+ if (this.currentCommand === 'cm:stacks:audit:fix') {
486
+ result.Fixed = uidSet.size;
487
+ result['Not-Fixed'] = nonFixable.size;
488
+ }
489
+ else {
490
+ result.Fixable = uidSet.size;
491
+ result['Non-Fixable'] = nonFixable.size;
492
+ }
493
+ }
494
+ else {
495
+ const missingCount = Object.keys(listOfMissingRefs).length;
496
+ result.Passed = dataExported.Total - missingCount;
497
+ if (this.currentCommand === 'cm:stacks:audit:fix') {
498
+ result.Fixed = missingCount > 0 && isFixable ? missingCount : 0;
499
+ result['Not-Fixed'] = missingCount > 0 && !isFixable ? missingCount : 0;
500
+ }
501
+ else {
502
+ result.Fixable = missingCount > 0 && isFixable ? missingCount : 0;
503
+ result['Non-Fixable'] = missingCount > 0 && !isFixable ? missingCount : 0;
504
+ }
505
+ }
506
+ this.summaryDataToPrint.push(result);
507
+ }
422
508
  }
423
509
  exports.AuditBaseCommand = AuditBaseCommand;
@@ -101,4 +101,8 @@ BaseCommand.baseFlags = {
101
101
  helpGroup: 'COMMON',
102
102
  description: messages_1.commonMsg.DATA_DIR,
103
103
  }),
104
+ 'show-console-output': cli_utilities_1.Flags.boolean({
105
+ helpGroup: 'COMMON',
106
+ description: messages_1.commonMsg.SHOW_CONSOLE_OUTPUT,
107
+ }),
104
108
  };
@@ -28,7 +28,6 @@ class AuditFix extends audit_base_command_1.AuditBaseCommand {
28
28
  }
29
29
  }
30
30
  }
31
- exports.default = AuditFix;
32
31
  AuditFix.aliases = ['audit:fix', 'cm:stacks:audit:fix'];
33
32
  AuditFix.description = messages_1.auditFixMsg.AUDIT_FIX_CMD_DESCRIPTION;
34
33
  AuditFix.examples = [
@@ -61,4 +60,5 @@ AuditFix.flags = Object.assign({ 'report-path': cli_utilities_1.Flags.string({
61
60
  char: 'y',
62
61
  hidden: true,
63
62
  description: 'Use this flag to skip confirmation',
64
- }), 'external-config': jsonFlag() }, (0, util_1.getTableFlags)());
63
+ }), 'external-config': jsonFlag() }, util_1.tableFlags);
64
+ exports.default = AuditFix;
@@ -23,7 +23,6 @@ class Audit extends audit_base_command_1.AuditBaseCommand {
23
23
  }
24
24
  }
25
25
  }
26
- exports.default = Audit;
27
26
  Audit.aliases = ['audit', 'cm:stacks:audit'];
28
27
  Audit.description = messages_1.auditMsg.AUDIT_CMD_DESCRIPTION;
29
28
  Audit.examples = [
@@ -42,4 +41,5 @@ Audit.flags = Object.assign({ 'report-path': cli_utilities_1.Flags.string({
42
41
  multiple: true,
43
42
  options: config_1.default.modules,
44
43
  description: messages_1.auditMsg.MODULES,
45
- }) }, (0, util_1.getTableFlags)());
44
+ }) }, util_1.tableFlags);
45
+ exports.default = Audit;
@@ -4,7 +4,16 @@ const config = {
4
4
  showTerminalOutput: true,
5
5
  skipRefs: ['sys_assets'],
6
6
  skipFieldTypes: ['taxonomy', 'group'],
7
- modules: ['content-types', 'global-fields', 'entries', 'extensions', 'workflows', 'custom-roles', 'assets'],
7
+ modules: [
8
+ 'content-types',
9
+ 'global-fields',
10
+ 'entries',
11
+ 'extensions',
12
+ 'workflows',
13
+ 'custom-roles',
14
+ 'assets',
15
+ 'field-rules',
16
+ ],
8
17
  'fix-fields': ['reference', 'global_field', 'json:rte', 'json:extension', 'blocks', 'group', 'content_types'],
9
18
  moduleConfig: {
10
19
  'content-types': {
@@ -42,16 +51,16 @@ const config = {
42
51
  dirName: 'custom-roles',
43
52
  fileName: 'custom-roles.json',
44
53
  },
45
- 'assets': {
54
+ assets: {
46
55
  name: 'assets',
47
56
  dirName: 'assets',
48
57
  fileName: 'assets.json',
49
58
  },
50
- 'environments': {
59
+ environments: {
51
60
  name: 'environments',
52
61
  dirName: 'environments',
53
62
  fileName: 'environments.json',
54
- }
63
+ },
55
64
  },
56
65
  entries: {
57
66
  systemKeys: [
@@ -96,7 +105,16 @@ const config = {
96
105
  'publish_locale',
97
106
  'publish_environment',
98
107
  'asset_uid',
99
- 'selectedValue'
108
+ 'selectedValue',
109
+ 'ct_uid',
110
+ 'action',
111
+ "Module",
112
+ "Total",
113
+ "Fixable",
114
+ "Non-Fixable",
115
+ "Fixed",
116
+ "Not-Fixed",
117
+ "Passed",
100
118
  ],
101
119
  ReportTitleForEntries: {
102
120
  Entries_Select_feild: 'Entries_Select_feild',
@@ -104,9 +122,17 @@ const config = {
104
122
  Entries_Title_feild: 'Entries_Title_feild',
105
123
  Entry_Missing_Locale_and_Env: 'Entry_Missing_Locale_and_Env',
106
124
  Entry_Missing_Locale_and_Env_in_Publish_Details: 'Entry_Missing_Locale_and_Env_in_Publish_Details',
107
- Entry_Multiple_Fields: 'Entry_Multiple_Fields'
125
+ Entry_Multiple_Fields: "Entry_Multiple_Fields"
108
126
  },
109
- feild_level_modules: ['Entries_Title_feild', 'Entries_Mandatory_feild', 'Entries_Select_feild', 'Entry_Missing_Locale_and_Env_in_Publish_Details', 'Entry_Multiple_Fields'],
110
- fixSelectField: false
127
+ feild_level_modules: [
128
+ 'Entries_Title_feild',
129
+ 'Entries_Mandatory_feild',
130
+ 'Entries_Select_feild',
131
+ 'Entry_Missing_Locale_and_Env_in_Publish_Details',
132
+ 'field-rules',
133
+ 'Entry_Multiple_Fields',
134
+ 'Summary'
135
+ ],
136
+ fixSelectField: false,
111
137
  };
112
138
  exports.default = config;
@@ -16,6 +16,7 @@ declare const commonMsg: {
16
16
  EXTENSION_FIX_CONFIRMATION: string;
17
17
  WF_BRANCH_REMOVAL: string;
18
18
  CR_BRANCH_REMOVAL: string;
19
+ SHOW_CONSOLE_OUTPUT: string;
19
20
  };
20
21
  declare const auditMsg: {
21
22
  REPORT_PATH: string;
@@ -38,6 +39,10 @@ declare const auditMsg: {
38
39
  CT_REFERENCE_FIELD: string;
39
40
  ASSET_NOT_EXIST: string;
40
41
  ENTRY_PUBLISH_DETAILS_NOT_EXIST: string;
42
+ FIELD_RULE_CONDITION_ABSENT: string;
43
+ FIELD_RULE_TARGET_ABSENT: string;
44
+ FIELD_RULE_CONDITION_SCAN_MESSAGE: string;
45
+ FIELD_RULE_TARGET_SCAN_MESSAGE: string;
41
46
  };
42
47
  declare const auditFixMsg: {
43
48
  COPY_DATA: string;
@@ -50,6 +55,7 @@ declare const auditFixMsg: {
50
55
  ENTRY_MANDATORY_FIELD_FIX: string;
51
56
  ENTRY_SELECT_FIELD_FIX: string;
52
57
  ASSET_FIX: string;
58
+ FIELD_RULE_FIX_MESSAGE: string;
53
59
  };
54
60
  declare const messages: typeof errors & typeof commonMsg & typeof auditMsg & typeof auditFixMsg & typeof tableColumnDescriptions;
55
61
  /**
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.tableColumnDescriptions = exports.auditFixMsg = exports.auditMsg = exports.commonMsg = exports.errors = exports.$t = void 0;
3
+ exports.tableColumnDescriptions = exports.auditFixMsg = exports.auditMsg = exports.commonMsg = exports.errors = void 0;
4
+ exports.$t = $t;
4
5
  const tslib_1 = require("tslib");
5
6
  const memoize_1 = tslib_1.__importDefault(require("lodash/memoize"));
6
7
  const errors = {};
@@ -23,6 +24,7 @@ const commonMsg = {
23
24
  EXTENSION_FIX_CONFIRMATION: `Would you like to overwrite existing file?`,
24
25
  WF_BRANCH_REMOVAL: `Removing the branch '{branch} from workflow with UID {uid} and name {name} will be removed.'`,
25
26
  CR_BRANCH_REMOVAL: `Removing the branch '{branch} from custom role with UID {uid} and name {name} will be removed.'`,
27
+ SHOW_CONSOLE_OUTPUT: `Display the audit and audit fix result for individual modules`,
26
28
  };
27
29
  exports.commonMsg = commonMsg;
28
30
  const auditMsg = {
@@ -46,6 +48,10 @@ const auditMsg = {
46
48
  CT_REFERENCE_FIELD: `The mentioned Reference field is not Array field reference is '{reference_to}' having display name '{display_name}''`,
47
49
  ASSET_NOT_EXIST: `The publish_details either does not exist or is not an array for asset uid '{uid}'`,
48
50
  ENTRY_PUBLISH_DETAILS_NOT_EXIST: `The publish_details either does not exist or is not an array for entry uid '{uid}'`,
51
+ FIELD_RULE_CONDITION_ABSENT: `The operand field '{condition_field}' is not present in the schema of the content-type {ctUid}`,
52
+ FIELD_RULE_TARGET_ABSENT: `The target field '{target_field}' is not present in the schema of the content-type {ctUid}`,
53
+ FIELD_RULE_CONDITION_SCAN_MESSAGE: `Completed Scanning of Field Rule '{num}' condition of Content-type '{ctUid}'`,
54
+ FIELD_RULE_TARGET_SCAN_MESSAGE: `Completed Scanning of Field Rule '{num}' target of Content-type '{ctUid}'`
49
55
  };
50
56
  exports.auditMsg = auditMsg;
51
57
  const auditFixMsg = {
@@ -59,6 +65,7 @@ const auditFixMsg = {
59
65
  ENTRY_MANDATORY_FIELD_FIX: `Removing the publish details from the entry with UID '{uid}' in Locale '{locale}'...`,
60
66
  ENTRY_SELECT_FIELD_FIX: `Adding the value '{value}' in the select field of entry UID '{uid}'...`,
61
67
  ASSET_FIX: `Fixed publish detials for Asset with UID '{uid}'`,
68
+ FIELD_RULE_FIX_MESSAGE: `Fixed Field Rule '{num}' target of Content-type '{ctUid}`,
62
69
  };
63
70
  exports.auditFixMsg = auditFixMsg;
64
71
  const messages = Object.assign(Object.assign(Object.assign(Object.assign(Object.assign({}, errors), commonMsg), auditMsg), auditFixMsg), tableColumnDescriptions);
@@ -84,5 +91,4 @@ function $t(msg, args) {
84
91
  });
85
92
  return transfer(msg, args);
86
93
  }
87
- exports.$t = $t;
88
94
  exports.default = messages;
@@ -21,7 +21,7 @@ export default class Assets {
21
21
  * iterates over the schema and looks for references, and returns a list of missing references.
22
22
  * @returns the `missingEnvLocales` object.
23
23
  */
24
- run(returnFixSchema?: boolean): Promise<Record<string, any>>;
24
+ run(returnFixSchema?: boolean): Promise<Record<string, any> | ContentTypeStruct[]>;
25
25
  /**
26
26
  * @method prerequisiteData
27
27
  * The `prerequisiteData` function reads and parses JSON files to retrieve extension and marketplace
@@ -80,7 +80,7 @@ class Assets {
80
80
  let canWrite = true;
81
81
  if (this.fix) {
82
82
  if (!this.config.flags['copy-dir'] && !((_a = this.config.flags['external-config']) === null || _a === void 0 ? void 0 : _a.skipConfirm)) {
83
- canWrite = this.config.flags.yes || (await cli_utilities_1.ux.confirm(messages_1.commonMsg.FIX_CONFIRMATION));
83
+ canWrite = this.config.flags.yes || (await cli_utilities_1.cliux.confirm(messages_1.commonMsg.FIX_CONFIRMATION));
84
84
  }
85
85
  if (canWrite) {
86
86
  (0, fs_1.writeFileSync)(filePath, JSON.stringify(schema));
@@ -22,7 +22,7 @@ export default class ContentType {
22
22
  * iterates over the schema and looks for references, and returns a list of missing references.
23
23
  * @returns the `missingRefs` object.
24
24
  */
25
- run(returnFixSchema?: boolean): Promise<Record<string, any>>;
25
+ run(returnFixSchema?: boolean): Promise<Record<string, any> | ContentTypeStruct[]>;
26
26
  /**
27
27
  * @method prerequisiteData
28
28
  * The `prerequisiteData` function reads and parses JSON files to retrieve extension and marketplace
@@ -102,7 +102,7 @@ class ContentType {
102
102
  let canWrite = true;
103
103
  if (!this.inMemoryFix && this.fix) {
104
104
  if (!this.config.flags['copy-dir'] && !((_a = this.config.flags['external-config']) === null || _a === void 0 ? void 0 : _a.skipConfirm)) {
105
- canWrite = (_b = this.config.flags.yes) !== null && _b !== void 0 ? _b : (await cli_utilities_1.ux.confirm(messages_1.commonMsg.FIX_CONFIRMATION));
105
+ canWrite = (_b = this.config.flags.yes) !== null && _b !== void 0 ? _b : (await cli_utilities_1.cliux.confirm(messages_1.commonMsg.FIX_CONFIRMATION));
106
106
  }
107
107
  if (canWrite) {
108
108
  (0, fs_1.writeFileSync)((0, path_1.join)(this.folderPath, this.config.moduleConfig[this.moduleName].fileName), JSON.stringify(this.schema));
@@ -117,7 +117,7 @@ class CustomRoles {
117
117
  (this.config.flags['copy-dir'] ||
118
118
  ((_a = this.config.flags['external-config']) === null || _a === void 0 ? void 0 : _a.skipConfirm) ||
119
119
  this.config.flags.yes ||
120
- (await cli_utilities_1.ux.confirm(messages_1.commonMsg.FIX_CONFIRMATION)))) {
120
+ (await cli_utilities_1.cliux.confirm(messages_1.commonMsg.FIX_CONFIRMATION)))) {
121
121
  (0, fs_1.writeFileSync)((0, path_1.join)(this.folderPath, this.config.moduleConfig[this.moduleName].fileName), JSON.stringify(newCustomRoleSchema));
122
122
  }
123
123
  }
@@ -198,6 +198,7 @@ export default class Entries {
198
198
  * @returns if there is missing field returns field and path
199
199
  * Else empty array
200
200
  */
201
+ removeEmojiAndImages(str: string): string;
201
202
  validateSelectField(tree: Record<string, unknown>[], fieldStructure: SelectFeildStruct, field: any): {
202
203
  uid: string;
203
204
  name: string;