@contentstack/cli-audit 1.8.0 → 1.9.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.
package/README.md CHANGED
@@ -19,7 +19,7 @@ $ npm install -g @contentstack/cli-audit
19
19
  $ csdx COMMAND
20
20
  running command...
21
21
  $ csdx (--version|-v)
22
- @contentstack/cli-audit/1.8.0 linux-x64 node-v22.14.0
22
+ @contentstack/cli-audit/1.9.0 linux-x64 node-v22.14.0
23
23
  $ csdx --help [COMMAND]
24
24
  USAGE
25
25
  $ csdx COMMAND
@@ -269,7 +269,7 @@ EXAMPLES
269
269
  $ csdx plugins
270
270
  ```
271
271
 
272
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.34/src/commands/plugins/index.ts)_
272
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.36/src/commands/plugins/index.ts)_
273
273
 
274
274
  ## `csdx plugins:add PLUGIN`
275
275
 
@@ -343,7 +343,7 @@ EXAMPLES
343
343
  $ csdx plugins:inspect myplugin
344
344
  ```
345
345
 
346
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.34/src/commands/plugins/inspect.ts)_
346
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.36/src/commands/plugins/inspect.ts)_
347
347
 
348
348
  ## `csdx plugins:install PLUGIN`
349
349
 
@@ -392,7 +392,7 @@ EXAMPLES
392
392
  $ csdx plugins:install someuser/someplugin
393
393
  ```
394
394
 
395
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.34/src/commands/plugins/install.ts)_
395
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.36/src/commands/plugins/install.ts)_
396
396
 
397
397
  ## `csdx plugins:link PATH`
398
398
 
@@ -423,7 +423,7 @@ EXAMPLES
423
423
  $ csdx plugins:link myplugin
424
424
  ```
425
425
 
426
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.34/src/commands/plugins/link.ts)_
426
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.36/src/commands/plugins/link.ts)_
427
427
 
428
428
  ## `csdx plugins:remove [PLUGIN]`
429
429
 
@@ -464,7 +464,7 @@ FLAGS
464
464
  --reinstall Reinstall all plugins after uninstalling.
465
465
  ```
466
466
 
467
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.34/src/commands/plugins/reset.ts)_
467
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.36/src/commands/plugins/reset.ts)_
468
468
 
469
469
  ## `csdx plugins:uninstall [PLUGIN]`
470
470
 
@@ -492,7 +492,7 @@ EXAMPLES
492
492
  $ csdx plugins:uninstall myplugin
493
493
  ```
494
494
 
495
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.34/src/commands/plugins/uninstall.ts)_
495
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.36/src/commands/plugins/uninstall.ts)_
496
496
 
497
497
  ## `csdx plugins:unlink [PLUGIN]`
498
498
 
@@ -536,5 +536,5 @@ DESCRIPTION
536
536
  Update installed plugins.
537
537
  ```
538
538
 
539
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.34/src/commands/plugins/update.ts)_
539
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.36/src/commands/plugins/update.ts)_
540
540
  <!-- commandsstop -->
@@ -63,5 +63,6 @@ declare const config: {
63
63
  Entry_Missing_Locale_and_Env_in_Publish_Details: string;
64
64
  };
65
65
  feild_level_modules: string[];
66
+ fixSelectField: boolean;
66
67
  };
67
68
  export default config;
@@ -95,7 +95,8 @@ const config = {
95
95
  'entry_uid',
96
96
  'publish_locale',
97
97
  'publish_environment',
98
- 'asset_uid'
98
+ 'asset_uid',
99
+ 'selectedValue'
99
100
  ],
100
101
  ReportTitleForEntries: {
101
102
  Entries_Select_feild: 'Entries_Select_feild',
@@ -105,5 +106,6 @@ const config = {
105
106
  Entry_Missing_Locale_and_Env_in_Publish_Details: 'Entry_Missing_Locale_and_Env_in_Publish_Details'
106
107
  },
107
108
  feild_level_modules: ['Entries_Title_feild', 'Entries_Mandatory_feild', 'Entries_Select_feild', 'Entry_Missing_Locale_and_Env_in_Publish_Details'],
109
+ fixSelectField: false
108
110
  };
109
111
  exports.default = config;
@@ -43,7 +43,7 @@ const auditMsg = {
43
43
  SCAN_ASSET_SUCCESS_MSG: `Successfully completed the scanning of Asset with UID '{uid}'.`,
44
44
  SCAN_ASSET_WARN_MSG: `The locale '{locale}' or environment '{environment}' are not present for asset with uid '{uid}'`,
45
45
  ENTRY_PUBLISH_DETAILS: `Removing the publish detials for entry '{uid}' of ct '{ctuid}' in locale '{locale}' as locale '{publocale}' or environment '{environment}' does not exist`,
46
- CT_REFERENCE_FIELD: `The mentioned Reference Field is not Array field name 'reference_to' having display name 'display_name'`,
46
+ CT_REFERENCE_FIELD: `The mentioned Reference field is not Array field reference is '{reference_to}' having display name '{display_name}''`,
47
47
  ASSET_NOT_EXIST: `The publish_details either does not exist or is not an array for asset uid '{uid}'`,
48
48
  ENTRY_PUBLISH_DETAILS_NOT_EXIST: `The publish_details either does not exist or is not an array for entry uid '{uid}'`,
49
49
  };
@@ -288,14 +288,26 @@ class ContentType {
288
288
  return [];
289
289
  const missingRefs = [];
290
290
  let { reference_to, display_name, data_type } = field;
291
- for (const reference of reference_to !== null && reference_to !== void 0 ? reference_to : []) {
292
- // NOTE Can skip specific references keys (Ex, system defined keys can be skipped)
293
- if (this.config.skipRefs.includes(reference)) {
294
- continue;
291
+ if (!Array.isArray(reference_to)) {
292
+ this.log((0, messages_1.$t)(messages_1.auditMsg.CT_REFERENCE_FIELD, { reference_to, data_type, display_name }), 'error');
293
+ this.log((0, messages_1.$t)(messages_1.auditMsg.CT_REFERENCE_FIELD, { reference_to, display_name }), 'info');
294
+ if (!this.config.skipRefs.includes(reference_to)) {
295
+ const refExist = (0, find_1.default)(this.ctSchema, { uid: reference_to });
296
+ if (!refExist) {
297
+ missingRefs.push(reference_to);
298
+ }
295
299
  }
296
- const refExist = (0, find_1.default)(this.ctSchema, { uid: reference });
297
- if (!refExist) {
298
- missingRefs.push(reference);
300
+ }
301
+ else {
302
+ for (const reference of reference_to !== null && reference_to !== void 0 ? reference_to : []) {
303
+ // NOTE Can skip specific references keys (Ex, system defined keys can be skipped)
304
+ if (this.config.skipRefs.includes(reference)) {
305
+ continue;
306
+ }
307
+ const refExist = (0, find_1.default)(this.ctSchema, { uid: reference });
308
+ if (!refExist) {
309
+ missingRefs.push(reference);
310
+ }
299
311
  }
300
312
  }
301
313
  return missingRefs.length
@@ -511,16 +523,27 @@ class ContentType {
511
523
  const missingRefs = [];
512
524
  const { reference_to, data_type, display_name } = field;
513
525
  if (!Array.isArray(reference_to)) {
514
- this.log((0, messages_1.$t)(messages_1.auditMsg.CT_REFERENCE_FIELD, { reference_to, data_type, display_name }), { color: 'green' });
515
- }
516
- for (const reference of reference_to !== null && reference_to !== void 0 ? reference_to : []) {
517
- // NOTE Can skip specific references keys (Ex, system defined keys can be skipped)
518
- if (this.config.skipRefs.includes(reference)) {
519
- continue;
526
+ this.log((0, messages_1.$t)(messages_1.auditMsg.CT_REFERENCE_FIELD, { reference_to, display_name }), 'error');
527
+ this.log((0, messages_1.$t)(messages_1.auditMsg.CT_REFERENCE_FIELD, { reference_to, display_name }), 'info');
528
+ if (!this.config.skipRefs.includes(reference_to)) {
529
+ const refExist = (0, find_1.default)(this.ctSchema, { uid: reference_to });
530
+ if (!refExist) {
531
+ missingRefs.push(reference_to);
532
+ }
520
533
  }
521
- const refExist = (0, find_1.default)(this.ctSchema, { uid: reference });
522
- if (!refExist) {
523
- missingRefs.push(reference);
534
+ field.reference_to = [reference_to];
535
+ field.field_metadata = Object.assign(Object.assign({}, field.field_metadata), { ref_multiple_content_types: true });
536
+ }
537
+ else {
538
+ for (const reference of reference_to !== null && reference_to !== void 0 ? reference_to : []) {
539
+ // NOTE Can skip specific references keys (Ex, system defined keys can be skipped)
540
+ if (this.config.skipRefs.includes(reference)) {
541
+ continue;
542
+ }
543
+ const refExist = (0, find_1.default)(this.ctSchema, { uid: reference });
544
+ if (!refExist) {
545
+ missingRefs.push(reference);
546
+ }
524
547
  }
525
548
  }
526
549
  if (this.fix && !(0, isEmpty_1.default)(missingRefs)) {
@@ -133,10 +133,24 @@ class Entries {
133
133
  environment: pd.environment,
134
134
  }), { color: 'red' });
135
135
  if (!Object.keys(this.missingEnvLocale).includes(entryUid)) {
136
- this.missingEnvLocale[entryUid] = [{ entry_uid: entryUid, publish_locale: pd.locale, publish_environment: pd.environment, ctUid: ctSchema.uid, ctLocale: code }];
136
+ this.missingEnvLocale[entryUid] = [
137
+ {
138
+ entry_uid: entryUid,
139
+ publish_locale: pd.locale,
140
+ publish_environment: pd.environment,
141
+ ctUid: ctSchema.uid,
142
+ ctLocale: code,
143
+ },
144
+ ];
137
145
  }
138
146
  else {
139
- this.missingEnvLocale[entryUid].push({ entry_uid: entryUid, publish_locale: pd.locale, publish_environment: pd.environment, ctUid: ctSchema.uid, ctLocale: code });
147
+ this.missingEnvLocale[entryUid].push({
148
+ entry_uid: entryUid,
149
+ publish_locale: pd.locale,
150
+ publish_environment: pd.environment,
151
+ ctUid: ctSchema.uid,
152
+ ctLocale: code,
153
+ });
140
154
  }
141
155
  return false;
142
156
  }
@@ -468,15 +482,28 @@ class Entries {
468
482
  if (this.fix)
469
483
  return [];
470
484
  const missingRefs = [];
471
- const { uid: data_type, display_name } = fieldStructure;
485
+ const { uid: data_type, display_name, reference_to } = fieldStructure;
472
486
  for (const index in field !== null && field !== void 0 ? field : []) {
473
487
  const reference = field[index];
474
488
  const { uid } = reference;
489
+ if (!uid && reference.startsWith('blt')) {
490
+ const refExist = (0, find_1.default)(this.entryMetaData, { uid: reference });
491
+ if (!refExist) {
492
+ if (Array.isArray(reference_to) && reference_to.length === 1) {
493
+ missingRefs.push({ uid: reference, _content_type_uid: reference_to[0] });
494
+ }
495
+ else {
496
+ missingRefs.push(reference);
497
+ }
498
+ }
499
+ }
475
500
  // NOTE Can skip specific references keys (Ex, system defined keys can be skipped)
476
501
  // if (this.config.skipRefs.includes(reference)) continue;
477
- const refExist = (0, find_1.default)(this.entryMetaData, { uid });
478
- if (!refExist) {
479
- missingRefs.push(reference);
502
+ else {
503
+ const refExist = (0, find_1.default)(this.entryMetaData, { uid });
504
+ if (!refExist) {
505
+ missingRefs.push(reference);
506
+ }
480
507
  }
481
508
  }
482
509
  return missingRefs.length
@@ -644,9 +671,13 @@ class Entries {
644
671
  * @returns
645
672
  */
646
673
  fixSelectField(tree, field, entry) {
674
+ if (!this.config.fixSelectField) {
675
+ return entry;
676
+ }
647
677
  const { enum: selectOptions, multiple, min_instance, display_type, display_name, uid } = field;
648
678
  let missingCTSelectFieldValues;
649
679
  let isMissingValuePresent = false;
680
+ let selectedValue = '';
650
681
  if (multiple) {
651
682
  let obj = this.findNotPresentSelectField(entry, selectOptions);
652
683
  let { notPresent, filteredFeild } = obj;
@@ -664,6 +695,7 @@ class Entries {
664
695
  .slice(0, missingInstances)
665
696
  .map((choice) => choice.value);
666
697
  entry.push(...newValues);
698
+ selectedValue = newValues;
667
699
  this.log((0, messages_1.$t)(messages_1.auditFixMsg.ENTRY_SELECT_FIELD_FIX, { value: newValues.join(' '), uid }), 'error');
668
700
  }
669
701
  }
@@ -672,6 +704,7 @@ class Entries {
672
704
  isMissingValuePresent = true;
673
705
  const defaultValue = selectOptions.choices.length > 0 ? selectOptions.choices[0].value : null;
674
706
  entry.push(defaultValue);
707
+ selectedValue = defaultValue;
675
708
  this.log((0, messages_1.$t)(messages_1.auditFixMsg.ENTRY_SELECT_FIELD_FIX, { value: defaultValue, uid }), 'error');
676
709
  }
677
710
  }
@@ -683,6 +716,7 @@ class Entries {
683
716
  isMissingValuePresent = true;
684
717
  let defaultValue = selectOptions.choices.length > 0 ? selectOptions.choices[0].value : null;
685
718
  entry = defaultValue;
719
+ selectedValue = defaultValue;
686
720
  this.log((0, messages_1.$t)(messages_1.auditFixMsg.ENTRY_SELECT_FIELD_FIX, { value: defaultValue, uid }), 'error');
687
721
  }
688
722
  }
@@ -693,6 +727,7 @@ class Entries {
693
727
  display_name,
694
728
  display_type,
695
729
  missingCTSelectFieldValues,
730
+ selectedValue,
696
731
  min_instance: min_instance !== null && min_instance !== void 0 ? min_instance : 'NA',
697
732
  tree,
698
733
  treeStr: tree
@@ -719,6 +754,9 @@ class Entries {
719
754
  if (data_type === 'number' && !multiple) {
720
755
  fieldValue = entry[uid] || entry[uid] === 0 ? true : false;
721
756
  }
757
+ if (data_type === 'text' && !multiple) {
758
+ fieldValue = entry[uid] || entry[uid] === 0 ? true : false;
759
+ }
722
760
  if (Array.isArray(entry[uid]) && data_type === 'reference') {
723
761
  fieldValue = ((_b = entry[uid]) === null || _b === void 0 ? void 0 : _b.length) ? true : false;
724
762
  }
@@ -924,12 +962,31 @@ class Entries {
924
962
  }
925
963
  entry = entry === null || entry === void 0 ? void 0 : entry.map((reference) => {
926
964
  const { uid } = reference;
927
- const refExist = (0, find_1.default)(this.entryMetaData, { uid });
928
- if (!refExist) {
929
- missingRefs.push(reference);
930
- return null;
965
+ const { reference_to } = field;
966
+ if (!uid && reference.startsWith('blt')) {
967
+ const refExist = (0, find_1.default)(this.entryMetaData, { uid: reference });
968
+ if (!refExist) {
969
+ if (Array.isArray(reference_to) && reference_to.length === 1) {
970
+ missingRefs.push({ uid: reference, _content_type_uid: reference_to[0] });
971
+ }
972
+ else {
973
+ missingRefs.push(reference);
974
+ }
975
+ }
976
+ else {
977
+ return { uid: reference, _content_type_uid: refExist.ctUid };
978
+ }
979
+ }
980
+ else {
981
+ const refExist = (0, find_1.default)(this.entryMetaData, { uid });
982
+ if (!refExist) {
983
+ missingRefs.push(reference);
984
+ return null;
985
+ }
986
+ else {
987
+ return reference;
988
+ }
931
989
  }
932
- return reference;
933
990
  }).filter((val) => val);
934
991
  if (!(0, isEmpty_1.default)(missingRefs)) {
935
992
  this.missingRefs[this.currentUid].push({
@@ -1056,7 +1113,7 @@ class Entries {
1056
1113
  else if (!title) {
1057
1114
  this.log(`The 'title' field in Entry with UID '${entryUid}' of Content Type '${uid}' in Locale '${code}' is empty.`, `error`);
1058
1115
  }
1059
- this.entryMetaData.push({ uid: entryUid, title });
1116
+ this.entryMetaData.push({ uid: entryUid, title, ctUid: uid });
1060
1117
  }
1061
1118
  }
1062
1119
  }
@@ -3,5 +3,6 @@ import GlobalField from './global-fields';
3
3
  import ContentType from './content-types';
4
4
  import Workflows from './workflows';
5
5
  import Extensions from './extensions';
6
+ import CustomRoles from './custom-roles';
6
7
  import Assets from './assets';
7
- export { Entries, GlobalField, ContentType, Workflows, Extensions, Assets };
8
+ export { Entries, GlobalField, ContentType, Workflows, Extensions, Assets, CustomRoles };
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Assets = exports.Extensions = exports.Workflows = exports.ContentType = exports.GlobalField = exports.Entries = void 0;
3
+ exports.CustomRoles = exports.Assets = exports.Extensions = exports.Workflows = exports.ContentType = exports.GlobalField = exports.Entries = void 0;
4
4
  const tslib_1 = require("tslib");
5
5
  const entries_1 = tslib_1.__importDefault(require("./entries"));
6
6
  exports.Entries = entries_1.default;
@@ -12,5 +12,7 @@ const workflows_1 = tslib_1.__importDefault(require("./workflows"));
12
12
  exports.Workflows = workflows_1.default;
13
13
  const extensions_1 = tslib_1.__importDefault(require("./extensions"));
14
14
  exports.Extensions = extensions_1.default;
15
+ const custom_roles_1 = tslib_1.__importDefault(require("./custom-roles"));
16
+ exports.CustomRoles = custom_roles_1.default;
15
17
  const assets_1 = tslib_1.__importDefault(require("./assets"));
16
18
  exports.Assets = assets_1.default;
@@ -112,6 +112,8 @@ declare enum OutputColumn {
112
112
  'entry_uid' = "entry_uid",
113
113
  'publish_locale' = "publish_locale",
114
114
  'publish_environment' = "publish_environment",
115
- 'asset_uid' = "asset_uid"
115
+ 'asset_uid' = "asset_uid",
116
+ 'selectedValue' = "selectedValue",
117
+ 'fixStatus' = "fixStatus"
116
118
  }
117
119
  export { CtConstructorParam, ContentTypeStruct, ModuleConstructorParam, ReferenceFieldDataType, GlobalFieldDataType, ExtensionOrAppFieldDataType, JsonRTEFieldDataType, GroupFieldDataType, ModularBlocksDataType, RefErrorReturnType, ModularBlocksSchemaTypes, ModularBlockType, OutputColumn, ContentTypeSchemaType, GlobalFieldSchemaTypes, WorkflowExtensionsRefErrorReturnType, SelectFeildStruct, };
@@ -29,5 +29,7 @@ var OutputColumn;
29
29
  OutputColumn["publish_locale"] = "publish_locale";
30
30
  OutputColumn["publish_environment"] = "publish_environment";
31
31
  OutputColumn["asset_uid"] = "asset_uid";
32
+ OutputColumn["selectedValue"] = "selectedValue";
33
+ OutputColumn["fixStatus"] = "fixStatus";
32
34
  })(OutputColumn || (OutputColumn = {}));
33
35
  exports.OutputColumn = OutputColumn;
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.8.0",
2
+ "version": "1.9.0",
3
3
  "commands": {
4
4
  "cm:stacks:audit:fix": {
5
5
  "id": "cm:stacks:audit:fix",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentstack/cli-audit",
3
- "version": "1.8.0",
3
+ "version": "1.9.0",
4
4
  "description": "Contentstack audit plugin",
5
5
  "author": "Contentstack CLI",
6
6
  "homepage": "https://github.com/contentstack/cli",