@contentstack/cli-audit 1.3.3 → 1.3.5
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 +8 -8
- package/lib/audit-base-command.js +0 -11
- package/lib/modules/content-types.js +3 -1
- package/lib/modules/entries.js +15 -14
- package/oclif.manifest.json +1 -1
- package/package.json +6 -4
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.3.
|
|
22
|
+
@contentstack/cli-audit/1.3.5 linux-x64 node-v18.19.0
|
|
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/v4.1.
|
|
288
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.1.17/src/commands/plugins/index.ts)_
|
|
289
289
|
|
|
290
290
|
## `csdx plugins:install PLUGIN...`
|
|
291
291
|
|
|
@@ -354,7 +354,7 @@ EXAMPLES
|
|
|
354
354
|
$ csdx plugins:inspect myplugin
|
|
355
355
|
```
|
|
356
356
|
|
|
357
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.1.
|
|
357
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.1.17/src/commands/plugins/inspect.ts)_
|
|
358
358
|
|
|
359
359
|
## `csdx plugins:install PLUGIN...`
|
|
360
360
|
|
|
@@ -398,7 +398,7 @@ EXAMPLES
|
|
|
398
398
|
$ csdx plugins:install someuser/someplugin
|
|
399
399
|
```
|
|
400
400
|
|
|
401
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.1.
|
|
401
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.1.17/src/commands/plugins/install.ts)_
|
|
402
402
|
|
|
403
403
|
## `csdx plugins:link PLUGIN`
|
|
404
404
|
|
|
@@ -428,7 +428,7 @@ EXAMPLES
|
|
|
428
428
|
$ csdx plugins:link myplugin
|
|
429
429
|
```
|
|
430
430
|
|
|
431
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.1.
|
|
431
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.1.17/src/commands/plugins/link.ts)_
|
|
432
432
|
|
|
433
433
|
## `csdx plugins:uninstall PLUGIN...`
|
|
434
434
|
|
|
@@ -465,7 +465,7 @@ USAGE
|
|
|
465
465
|
$ csdx plugins:reset
|
|
466
466
|
```
|
|
467
467
|
|
|
468
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.1.
|
|
468
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.1.17/src/commands/plugins/reset.ts)_
|
|
469
469
|
|
|
470
470
|
## `csdx plugins:uninstall PLUGIN...`
|
|
471
471
|
|
|
@@ -493,7 +493,7 @@ EXAMPLES
|
|
|
493
493
|
$ csdx plugins:uninstall myplugin
|
|
494
494
|
```
|
|
495
495
|
|
|
496
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.1.
|
|
496
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.1.17/src/commands/plugins/uninstall.ts)_
|
|
497
497
|
|
|
498
498
|
## `csdx plugins:uninstall PLUGIN...`
|
|
499
499
|
|
|
@@ -537,5 +537,5 @@ DESCRIPTION
|
|
|
537
537
|
Update installed plugins.
|
|
538
538
|
```
|
|
539
539
|
|
|
540
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.1.
|
|
540
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.1.17/src/commands/plugins/update.ts)_
|
|
541
541
|
<!-- commandsstop -->
|
|
@@ -143,19 +143,8 @@ class AuditBaseCommand extends base_command_1.BaseCommand {
|
|
|
143
143
|
* `gfSchema`. The values of these properties are the parsed JSON data from two different files.
|
|
144
144
|
*/
|
|
145
145
|
getCtAndGfSchema() {
|
|
146
|
-
const modules = this.sharedConfig.flags.modules || this.sharedConfig.modules;
|
|
147
146
|
const ctPath = (0, path_1.join)(this.sharedConfig.basePath, this.sharedConfig.moduleConfig['content-types'].dirName, this.sharedConfig.moduleConfig['content-types'].fileName);
|
|
148
147
|
const gfPath = (0, path_1.join)(this.sharedConfig.basePath, this.sharedConfig.moduleConfig['global-fields'].dirName, this.sharedConfig.moduleConfig['global-fields'].fileName);
|
|
149
|
-
if (modules.includes('content-types')) {
|
|
150
|
-
if (!(0, fs_1.existsSync)(ctPath)) {
|
|
151
|
-
this.log(this.$t(messages_1.auditMsg.NOT_VALID_PATH, { path: ctPath }), 'error');
|
|
152
|
-
}
|
|
153
|
-
}
|
|
154
|
-
if (modules.includes('global-fields')) {
|
|
155
|
-
if (!(0, fs_1.existsSync)(gfPath)) {
|
|
156
|
-
this.log(this.$t(messages_1.auditMsg.NOT_VALID_PATH, { path: ctPath }), 'error');
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
148
|
const gfSchema = (0, fs_1.existsSync)(gfPath) ? JSON.parse((0, fs_1.readFileSync)(gfPath, 'utf8')) : [];
|
|
160
149
|
const ctSchema = (0, fs_1.existsSync)(ctPath) ? JSON.parse((0, fs_1.readFileSync)(ctPath, 'utf8')) : [];
|
|
161
150
|
return { ctSchema, gfSchema };
|
|
@@ -32,7 +32,9 @@ class ContentType {
|
|
|
32
32
|
var _a;
|
|
33
33
|
this.inMemoryFix = returnFixSchema;
|
|
34
34
|
if (!(0, fs_1.existsSync)(this.folderPath)) {
|
|
35
|
-
|
|
35
|
+
this.log(`Skipping ${this.moduleName} audit`, 'warn');
|
|
36
|
+
this.log((0, messages_1.$t)(messages_1.auditMsg.NOT_VALID_PATH, { path: this.folderPath }), { color: 'yellow' });
|
|
37
|
+
return returnFixSchema ? [] : {};
|
|
36
38
|
}
|
|
37
39
|
this.schema = this.moduleName === 'content-types' ? this.ctSchema : this.gfSchema;
|
|
38
40
|
for (const schema of (_a = this.schema) !== null && _a !== void 0 ? _a : []) {
|
package/lib/modules/entries.js
CHANGED
|
@@ -31,7 +31,9 @@ class Entries {
|
|
|
31
31
|
*/
|
|
32
32
|
async run() {
|
|
33
33
|
if (!(0, fs_1.existsSync)(this.folderPath)) {
|
|
34
|
-
|
|
34
|
+
this.log(`Skipping ${this.moduleName} audit`, 'warn');
|
|
35
|
+
this.log((0, messages_1.$t)(messages_1.auditMsg.NOT_VALID_PATH, { path: this.folderPath }), { color: 'yellow' });
|
|
36
|
+
return {};
|
|
35
37
|
}
|
|
36
38
|
await this.prepareEntryMetaData();
|
|
37
39
|
await this.fixPrerequisiteData();
|
|
@@ -354,6 +356,9 @@ class Entries {
|
|
|
354
356
|
}
|
|
355
357
|
// NOTE Reference field
|
|
356
358
|
entry[uid] = this.fixMissingReferences([...tree, { uid: field.uid, name: field.display_name, data_type: field.data_type }], field, entry[uid]);
|
|
359
|
+
if (!entry[uid]) {
|
|
360
|
+
delete entry[uid];
|
|
361
|
+
}
|
|
357
362
|
break;
|
|
358
363
|
case 'blocks':
|
|
359
364
|
entry[uid] = this.fixModularBlocksReferences([...tree, { uid: field.uid, name: field.display_name, data_type: field.data_type }], field.blocks, entry[uid]);
|
|
@@ -392,20 +397,16 @@ class Entries {
|
|
|
392
397
|
* @returns the updated `entry` array after performing some modifications.
|
|
393
398
|
*/
|
|
394
399
|
fixModularBlocksReferences(tree, blocks, entry) {
|
|
395
|
-
entry = entry
|
|
396
|
-
.map((block, index) => this.modularBlockRefCheck(tree, blocks, block, index))
|
|
397
|
-
.filter((val) => !(0, isEmpty_1.default)(val));
|
|
400
|
+
entry = entry === null || entry === void 0 ? void 0 : entry.map((block, index) => this.modularBlockRefCheck(tree, blocks, block, index)).filter((val) => !(0, isEmpty_1.default)(val));
|
|
398
401
|
blocks.forEach((block) => {
|
|
399
|
-
entry = entry
|
|
400
|
-
.map((eBlock) => {
|
|
402
|
+
entry = entry === null || entry === void 0 ? void 0 : entry.map((eBlock) => {
|
|
401
403
|
if (!(0, isEmpty_1.default)(block.schema)) {
|
|
402
404
|
if (eBlock[block.uid]) {
|
|
403
405
|
eBlock[block.uid] = this.runFixOnSchema([...tree, { uid: block.uid, display_name: block.title }], block.schema, eBlock[block.uid]);
|
|
404
406
|
}
|
|
405
407
|
}
|
|
406
408
|
return eBlock;
|
|
407
|
-
})
|
|
408
|
-
.filter((val) => !(0, isEmpty_1.default)(val));
|
|
409
|
+
}).filter((val) => !(0, isEmpty_1.default)(val));
|
|
409
410
|
});
|
|
410
411
|
return entry;
|
|
411
412
|
}
|
|
@@ -482,8 +483,7 @@ class Entries {
|
|
|
482
483
|
*/
|
|
483
484
|
fixMissingReferences(tree, field, entry) {
|
|
484
485
|
const missingRefs = [];
|
|
485
|
-
entry = entry
|
|
486
|
-
.map((reference) => {
|
|
486
|
+
entry = entry === null || entry === void 0 ? void 0 : entry.map((reference) => {
|
|
487
487
|
const { uid } = reference;
|
|
488
488
|
const refExist = (0, find_1.default)(this.entryMetaData, { uid });
|
|
489
489
|
if (!refExist) {
|
|
@@ -491,8 +491,7 @@ class Entries {
|
|
|
491
491
|
return null;
|
|
492
492
|
}
|
|
493
493
|
return reference;
|
|
494
|
-
})
|
|
495
|
-
.filter((val) => val);
|
|
494
|
+
}).filter((val) => val);
|
|
496
495
|
if (!(0, isEmpty_1.default)(missingRefs)) {
|
|
497
496
|
this.missingRefs[this.currentUid].push({
|
|
498
497
|
tree,
|
|
@@ -592,8 +591,10 @@ class Entries {
|
|
|
592
591
|
const localesFolderPath = (0, path_1.resolve)(this.config.basePath, this.config.moduleConfig.locales.dirName);
|
|
593
592
|
const localesPath = (0, path_1.join)(localesFolderPath, this.config.moduleConfig.locales.fileName);
|
|
594
593
|
const masterLocalesPath = (0, path_1.join)(localesFolderPath, 'master-locale.json');
|
|
595
|
-
this.locales = (0, values_1.default)(JSON.parse((0, fs_1.readFileSync)(masterLocalesPath, 'utf8')));
|
|
596
|
-
|
|
594
|
+
this.locales = (0, fs_1.existsSync)(masterLocalesPath) ? (0, values_1.default)(JSON.parse((0, fs_1.readFileSync)(masterLocalesPath, 'utf8'))) : [];
|
|
595
|
+
if ((0, fs_1.existsSync)(localesPath)) {
|
|
596
|
+
this.locales.push(...(0, values_1.default)(JSON.parse((0, fs_1.readFileSync)(localesPath, 'utf8'))));
|
|
597
|
+
}
|
|
597
598
|
for (const { code } of this.locales) {
|
|
598
599
|
for (const { uid } of this.ctSchema) {
|
|
599
600
|
let basePath = (0, path_1.join)(this.folderPath, uid, code);
|
package/oclif.manifest.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@contentstack/cli-audit",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.5",
|
|
4
4
|
"description": "Contentstack audit plugin",
|
|
5
5
|
"author": "Contentstack CLI",
|
|
6
6
|
"homepage": "https://github.com/contentstack/cli",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
],
|
|
20
20
|
"dependencies": {
|
|
21
21
|
"@contentstack/cli-command": "~1.2.16",
|
|
22
|
-
"@contentstack/cli-utilities": "~1.5.
|
|
22
|
+
"@contentstack/cli-utilities": "~1.5.11",
|
|
23
23
|
"@oclif/plugin-help": "^5",
|
|
24
24
|
"@oclif/plugin-plugins": "^4.1.9",
|
|
25
25
|
"chalk": "^4.1.2",
|
|
@@ -31,9 +31,10 @@
|
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
33
|
"@contentstack/cli-dev-dependencies": "^1.2.4",
|
|
34
|
-
"@oclif/test": "^2.
|
|
34
|
+
"@oclif/test": "^2.5.6",
|
|
35
35
|
"@types/chai": "^4.3.5",
|
|
36
36
|
"@types/fs-extra": "^11.0.2",
|
|
37
|
+
"@types/mocha": "^10.0.6",
|
|
37
38
|
"@types/node": "^20.3.1",
|
|
38
39
|
"@types/uuid": "^9.0.4",
|
|
39
40
|
"chai": "^4.3.7",
|
|
@@ -71,6 +72,7 @@
|
|
|
71
72
|
"lint": "eslint . --ext .ts --config .eslintrc",
|
|
72
73
|
"postpack": "shx rm -f oclif.manifest.json",
|
|
73
74
|
"posttest": "npm run lint",
|
|
75
|
+
"compile": "shx rm -rf lib && tsc -b",
|
|
74
76
|
"prepack": "npm run build && oclif manifest && oclif readme",
|
|
75
77
|
"test": "mocha --forbid-only \"test/**/*.test.ts\"",
|
|
76
78
|
"version": "oclif readme && git add README.md",
|
|
@@ -84,4 +86,4 @@
|
|
|
84
86
|
"keywords": [
|
|
85
87
|
"oclif"
|
|
86
88
|
]
|
|
87
|
-
}
|
|
89
|
+
}
|