@contentstack/cli-audit 1.5.1 → 1.5.3

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.5.1 linux-x64 node-v18.19.1
22
+ @contentstack/cli-audit/1.5.3 linux-x64 node-v18.20.1
23
23
  $ csdx --help [COMMAND]
24
24
  USAGE
25
25
  $ csdx COMMAND
@@ -285,7 +285,7 @@ EXAMPLES
285
285
  $ csdx plugins
286
286
  ```
287
287
 
288
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.0.0/src/commands/plugins/index.ts)_
288
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.0.7/src/commands/plugins/index.ts)_
289
289
 
290
290
  ## `csdx plugins:add PLUGIN`
291
291
 
@@ -359,7 +359,7 @@ EXAMPLES
359
359
  $ csdx plugins:inspect myplugin
360
360
  ```
361
361
 
362
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.0.0/src/commands/plugins/inspect.ts)_
362
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.0.7/src/commands/plugins/inspect.ts)_
363
363
 
364
364
  ## `csdx plugins:install PLUGIN`
365
365
 
@@ -408,7 +408,7 @@ EXAMPLES
408
408
  $ csdx plugins:install someuser/someplugin
409
409
  ```
410
410
 
411
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.0.0/src/commands/plugins/install.ts)_
411
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.0.7/src/commands/plugins/install.ts)_
412
412
 
413
413
  ## `csdx plugins:link PATH`
414
414
 
@@ -438,7 +438,7 @@ EXAMPLES
438
438
  $ csdx plugins:link myplugin
439
439
  ```
440
440
 
441
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.0.0/src/commands/plugins/link.ts)_
441
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.0.7/src/commands/plugins/link.ts)_
442
442
 
443
443
  ## `csdx plugins:remove [PLUGIN]`
444
444
 
@@ -479,7 +479,7 @@ FLAGS
479
479
  --reinstall Reinstall all plugins after uninstalling.
480
480
  ```
481
481
 
482
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.0.0/src/commands/plugins/reset.ts)_
482
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.0.7/src/commands/plugins/reset.ts)_
483
483
 
484
484
  ## `csdx plugins:uninstall [PLUGIN]`
485
485
 
@@ -507,7 +507,7 @@ EXAMPLES
507
507
  $ csdx plugins:uninstall myplugin
508
508
  ```
509
509
 
510
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.0.0/src/commands/plugins/uninstall.ts)_
510
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.0.7/src/commands/plugins/uninstall.ts)_
511
511
 
512
512
  ## `csdx plugins:unlink [PLUGIN]`
513
513
 
@@ -551,5 +551,5 @@ DESCRIPTION
551
551
  Update installed plugins.
552
552
  ```
553
553
 
554
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.0.0/src/commands/plugins/update.ts)_
554
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.0.7/src/commands/plugins/update.ts)_
555
555
  <!-- commandsstop -->
@@ -206,6 +206,11 @@ class Entries {
206
206
  * `tree`, `fieldStructure`, and `field`.
207
207
  */
208
208
  validateReferenceField(tree, fieldStructure, field) {
209
+ if (typeof field === 'string') {
210
+ let stringReference = field;
211
+ stringReference = stringReference.replace(/'/g, '"');
212
+ field = JSON.parse(stringReference);
213
+ }
209
214
  return this.validateReferenceValues(tree, fieldStructure, field);
210
215
  }
211
216
  /**
@@ -601,6 +606,11 @@ class Entries {
601
606
  */
602
607
  fixMissingReferences(tree, field, entry) {
603
608
  const missingRefs = [];
609
+ if (typeof entry === 'string') {
610
+ let stringReference = entry;
611
+ stringReference = stringReference.replace(/'/g, '"');
612
+ entry = JSON.parse(stringReference);
613
+ }
604
614
  entry = entry === null || entry === void 0 ? void 0 : entry.map((reference) => {
605
615
  const { uid } = reference;
606
616
  const refExist = (0, find_1.default)(this.entryMetaData, { uid });
@@ -29,7 +29,7 @@ class Workflows {
29
29
  * @returns Array of object containing the workflow name, uid and content_types that are missing
30
30
  */
31
31
  async run() {
32
- var _a;
32
+ var _a, _b, _c;
33
33
  if (!(0, fs_1.existsSync)(this.folderPath)) {
34
34
  this.log(`Skipping ${this.moduleName} audit`, 'warn');
35
35
  this.log((0, messages_1.$t)(messages_1.auditMsg.NOT_VALID_PATH, { path: this.folderPath }), { color: 'yellow' });
@@ -42,14 +42,17 @@ class Workflows {
42
42
  this.ctSchema.forEach((ct) => this.ctUidSet.add(ct.uid));
43
43
  for (const workflow of this.workflowSchema) {
44
44
  const ctNotPresent = workflow.content_types.filter((ct) => !this.ctUidSet.has(ct));
45
- const branch = (_a = workflow === null || workflow === void 0 ? void 0 : workflow.branches) === null || _a === void 0 ? void 0 : _a.filter((branch) => { var _a; return branch !== ((_a = this.config) === null || _a === void 0 ? void 0 : _a.branch); });
46
- if (ctNotPresent.length || (branch === null || branch === void 0 ? void 0 : branch.length)) {
45
+ let branchesToBeRemoved = [];
46
+ if ((_a = this.config) === null || _a === void 0 ? void 0 : _a.branch) {
47
+ branchesToBeRemoved = ((_b = workflow === null || workflow === void 0 ? void 0 : workflow.branches) === null || _b === void 0 ? void 0 : _b.filter((branch) => { var _a; return branch !== ((_a = this.config) === null || _a === void 0 ? void 0 : _a.branch); })) || [];
48
+ }
49
+ if (ctNotPresent.length || (branchesToBeRemoved === null || branchesToBeRemoved === void 0 ? void 0 : branchesToBeRemoved.length)) {
47
50
  const tempwf = (0, lodash_1.cloneDeep)(workflow);
48
51
  tempwf.content_types = ctNotPresent || [];
49
- if (workflow === null || workflow === void 0 ? void 0 : workflow.branches) {
50
- tempwf.branches = branch;
52
+ if ((workflow === null || workflow === void 0 ? void 0 : workflow.branches) && ((_c = this.config) === null || _c === void 0 ? void 0 : _c.branch)) {
53
+ tempwf.branches = branchesToBeRemoved;
51
54
  }
52
- if (branch === null || branch === void 0 ? void 0 : branch.length) {
55
+ if (branchesToBeRemoved === null || branchesToBeRemoved === void 0 ? void 0 : branchesToBeRemoved.length) {
53
56
  this.isBranchFixDone = true;
54
57
  }
55
58
  ctNotPresent.forEach((ct) => this.missingCts.add(ct));
@@ -75,18 +78,20 @@ class Workflows {
75
78
  for (const workflow of this.workflowSchema) {
76
79
  const fixedCts = workflow.content_types.filter((ct) => !this.missingCts.has(ct));
77
80
  const fixedBranches = [];
78
- (_a = workflow === null || workflow === void 0 ? void 0 : workflow.branches) === null || _a === void 0 ? void 0 : _a.forEach((branch) => {
79
- var _a;
80
- if (branch !== ((_a = this.config) === null || _a === void 0 ? void 0 : _a.branch)) {
81
- const { uid, name } = workflow;
82
- this.log((0, messages_1.$t)(messages_1.commonMsg.WF_BRANCH_REMOVAL, { uid, name, branch }), { color: 'yellow' });
83
- }
84
- else {
85
- fixedBranches.push(branch);
81
+ if (this.config.branch) {
82
+ (_a = workflow === null || workflow === void 0 ? void 0 : workflow.branches) === null || _a === void 0 ? void 0 : _a.forEach((branch) => {
83
+ var _a;
84
+ if (branch !== ((_a = this.config) === null || _a === void 0 ? void 0 : _a.branch)) {
85
+ const { uid, name } = workflow;
86
+ this.log((0, messages_1.$t)(messages_1.commonMsg.WF_BRANCH_REMOVAL, { uid, name, branch }), { color: 'yellow' });
87
+ }
88
+ else {
89
+ fixedBranches.push(branch);
90
+ }
91
+ });
92
+ if (fixedBranches.length > 0) {
93
+ newWorkflowSchema[workflow.uid].branches = fixedBranches;
86
94
  }
87
- });
88
- if (fixedBranches.length > 0) {
89
- newWorkflowSchema[workflow.uid].branches = fixedBranches;
90
95
  }
91
96
  if (fixedCts.length) {
92
97
  newWorkflowSchema[workflow.uid].content_types = fixedCts;
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.5.1",
2
+ "version": "1.5.3",
3
3
  "commands": {
4
4
  "cm:stacks:audit:fix": {
5
5
  "id": "cm:stacks:audit:fix",
@@ -12,6 +12,7 @@
12
12
  "audit:fix",
13
13
  "cm:stacks:audit:fix"
14
14
  ],
15
+ "hiddenAliases": [],
15
16
  "examples": [
16
17
  "$ <%= config.bin %> <%= command.id %> --copy-dir",
17
18
  "$ <%= config.bin %> <%= command.id %> --report-path=<path> --copy-dir",
@@ -166,6 +167,7 @@
166
167
  "audit",
167
168
  "cm:stacks:audit"
168
169
  ],
170
+ "hiddenAliases": [],
169
171
  "examples": [
170
172
  "$ <%= config.bin %> <%= command.id %>",
171
173
  "$ <%= config.bin %> <%= command.id %> --report-path=<path>",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@contentstack/cli-audit",
3
- "version": "1.5.1",
3
+ "version": "1.5.3",
4
4
  "description": "Contentstack audit plugin",
5
5
  "author": "Contentstack CLI",
6
6
  "homepage": "https://github.com/contentstack/cli",