@contentstack/cli-audit 1.14.1 → 1.15.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 +9 -9
- package/lib/audit-base-command.d.ts +6 -1
- package/lib/audit-base-command.js +67 -14
- package/lib/base-command.d.ts +1 -4
- package/lib/base-command.js +1 -8
- package/lib/commands/cm/stacks/audit/fix.js +1 -2
- package/lib/commands/cm/stacks/audit/index.js +1 -2
- package/lib/modules/assets.d.ts +2 -3
- package/lib/modules/assets.js +71 -13
- package/lib/modules/content-types.d.ts +3 -4
- package/lib/modules/content-types.js +254 -43
- package/lib/modules/custom-roles.d.ts +2 -3
- package/lib/modules/custom-roles.js +98 -18
- package/lib/modules/entries.d.ts +3 -18
- package/lib/modules/entries.js +456 -61
- package/lib/modules/extensions.d.ts +2 -3
- package/lib/modules/extensions.js +81 -17
- package/lib/modules/field_rules.d.ts +2 -3
- package/lib/modules/field_rules.js +216 -42
- package/lib/modules/global-fields.js +18 -1
- package/lib/modules/modulesData.d.ts +2 -3
- package/lib/modules/modulesData.js +71 -9
- package/lib/modules/workflows.d.ts +2 -3
- package/lib/modules/workflows.js +98 -18
- package/lib/types/content-types.d.ts +1 -2
- package/lib/types/context.d.ts +8 -0
- package/lib/types/context.js +2 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.js +1 -0
- package/oclif.manifest.json +1 -1
- package/package.json +2 -2
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.
|
|
22
|
+
@contentstack/cli-audit/1.15.0 linux-x64 node-v22.20.0
|
|
23
23
|
$ csdx --help [COMMAND]
|
|
24
24
|
USAGE
|
|
25
25
|
$ csdx COMMAND
|
|
@@ -282,7 +282,7 @@ DESCRIPTION
|
|
|
282
282
|
Display help for csdx.
|
|
283
283
|
```
|
|
284
284
|
|
|
285
|
-
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.2.
|
|
285
|
+
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.2.33/src/commands/help.ts)_
|
|
286
286
|
|
|
287
287
|
## `csdx plugins`
|
|
288
288
|
|
|
@@ -305,7 +305,7 @@ EXAMPLES
|
|
|
305
305
|
$ csdx plugins
|
|
306
306
|
```
|
|
307
307
|
|
|
308
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.
|
|
308
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.50/src/commands/plugins/index.ts)_
|
|
309
309
|
|
|
310
310
|
## `csdx plugins:add PLUGIN`
|
|
311
311
|
|
|
@@ -379,7 +379,7 @@ EXAMPLES
|
|
|
379
379
|
$ csdx plugins:inspect myplugin
|
|
380
380
|
```
|
|
381
381
|
|
|
382
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.
|
|
382
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.50/src/commands/plugins/inspect.ts)_
|
|
383
383
|
|
|
384
384
|
## `csdx plugins:install PLUGIN`
|
|
385
385
|
|
|
@@ -428,7 +428,7 @@ EXAMPLES
|
|
|
428
428
|
$ csdx plugins:install someuser/someplugin
|
|
429
429
|
```
|
|
430
430
|
|
|
431
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.
|
|
431
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.50/src/commands/plugins/install.ts)_
|
|
432
432
|
|
|
433
433
|
## `csdx plugins:link PATH`
|
|
434
434
|
|
|
@@ -459,7 +459,7 @@ EXAMPLES
|
|
|
459
459
|
$ csdx plugins:link myplugin
|
|
460
460
|
```
|
|
461
461
|
|
|
462
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.
|
|
462
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.50/src/commands/plugins/link.ts)_
|
|
463
463
|
|
|
464
464
|
## `csdx plugins:remove [PLUGIN]`
|
|
465
465
|
|
|
@@ -500,7 +500,7 @@ FLAGS
|
|
|
500
500
|
--reinstall Reinstall all plugins after uninstalling.
|
|
501
501
|
```
|
|
502
502
|
|
|
503
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.
|
|
503
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.50/src/commands/plugins/reset.ts)_
|
|
504
504
|
|
|
505
505
|
## `csdx plugins:uninstall [PLUGIN]`
|
|
506
506
|
|
|
@@ -528,7 +528,7 @@ EXAMPLES
|
|
|
528
528
|
$ csdx plugins:uninstall myplugin
|
|
529
529
|
```
|
|
530
530
|
|
|
531
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.
|
|
531
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.50/src/commands/plugins/uninstall.ts)_
|
|
532
532
|
|
|
533
533
|
## `csdx plugins:unlink [PLUGIN]`
|
|
534
534
|
|
|
@@ -572,5 +572,5 @@ DESCRIPTION
|
|
|
572
572
|
Update installed plugins.
|
|
573
573
|
```
|
|
574
574
|
|
|
575
|
-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.
|
|
575
|
+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.50/src/commands/plugins/update.ts)_
|
|
576
576
|
<!-- commandsstop -->
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import config from './config';
|
|
2
2
|
import { BaseCommand } from './base-command';
|
|
3
|
-
import { CommandNames, ContentTypeStruct } from './types';
|
|
3
|
+
import { CommandNames, ContentTypeStruct, AuditContext } from './types';
|
|
4
4
|
export declare abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseCommand> {
|
|
5
5
|
private currentCommand;
|
|
6
6
|
private readonly summaryDataToPrint;
|
|
7
|
+
protected auditContext: AuditContext;
|
|
7
8
|
get fixStatus(): {
|
|
8
9
|
fixStatus: {
|
|
9
10
|
minWidth: number;
|
|
@@ -11,6 +12,10 @@ export declare abstract class AuditBaseCommand extends BaseCommand<typeof AuditB
|
|
|
11
12
|
get: (row: any) => string;
|
|
12
13
|
};
|
|
13
14
|
};
|
|
15
|
+
/**
|
|
16
|
+
* Create audit context object similar to export command
|
|
17
|
+
*/
|
|
18
|
+
private createAuditContext;
|
|
14
19
|
/**
|
|
15
20
|
* The `start` function performs an audit on content types, global fields, entries, and workflows and displays
|
|
16
21
|
* any missing references.
|
|
@@ -33,6 +33,19 @@ class AuditBaseCommand extends base_command_1.BaseCommand {
|
|
|
33
33
|
},
|
|
34
34
|
};
|
|
35
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Create audit context object similar to export command
|
|
38
|
+
*/
|
|
39
|
+
createAuditContext(moduleName) {
|
|
40
|
+
var _a, _b, _c;
|
|
41
|
+
return {
|
|
42
|
+
command: ((_b = (_a = this.context) === null || _a === void 0 ? void 0 : _a.info) === null || _b === void 0 ? void 0 : _b.command) || 'cm:stacks:audit',
|
|
43
|
+
module: moduleName || 'audit',
|
|
44
|
+
email: cli_utilities_1.configHandler.get('email') || '',
|
|
45
|
+
sessionId: ((_c = this.context) === null || _c === void 0 ? void 0 : _c.sessionId) || '',
|
|
46
|
+
authenticationMethod: cli_utilities_1.configHandler.get('authenticationMethod') || '',
|
|
47
|
+
};
|
|
48
|
+
}
|
|
36
49
|
/**
|
|
37
50
|
* The `start` function performs an audit on content types, global fields, entries, and workflows and displays
|
|
38
51
|
* any missing references.
|
|
@@ -41,9 +54,15 @@ class AuditBaseCommand extends base_command_1.BaseCommand {
|
|
|
41
54
|
*/
|
|
42
55
|
async start(command) {
|
|
43
56
|
this.currentCommand = command;
|
|
57
|
+
// Initialize audit context
|
|
58
|
+
this.auditContext = this.createAuditContext();
|
|
59
|
+
cli_utilities_1.log.debug(`Starting audit command: ${command}`, this.auditContext);
|
|
60
|
+
cli_utilities_1.log.info(`Starting audit command: ${command}`, this.auditContext);
|
|
44
61
|
await this.promptQueue();
|
|
45
62
|
await this.createBackUp();
|
|
46
63
|
this.sharedConfig.reportPath = (0, path_1.resolve)(this.flags['report-path'] || process.cwd(), 'audit-report');
|
|
64
|
+
cli_utilities_1.log.debug(`Data directory: ${this.flags['data-dir']}`, this.auditContext);
|
|
65
|
+
cli_utilities_1.log.debug(`Report path: ${this.flags['report-path'] || process.cwd()}`, this.auditContext);
|
|
47
66
|
const { missingCtRefs, missingGfRefs, missingEntryRefs, missingCtRefsInExtensions, missingCtRefsInWorkflow, missingSelectFeild, missingMandatoryFields, missingTitleFields, missingRefInCustomRoles, missingEnvLocalesInAssets, missingEnvLocalesInEntries, missingFieldRules, missingMultipleFields, } = await this.scanAndFix();
|
|
48
67
|
if (this.flags['show-console-output']) {
|
|
49
68
|
this.showOutputOnScreen([
|
|
@@ -86,15 +105,15 @@ class AuditBaseCommand extends base_command_1.BaseCommand {
|
|
|
86
105
|
!(0, isEmpty_1.default)(missingFieldRules) ||
|
|
87
106
|
!(0, isEmpty_1.default)(missingMultipleFields)) {
|
|
88
107
|
if (this.currentCommand === 'cm:stacks:audit') {
|
|
89
|
-
|
|
108
|
+
cli_utilities_1.log.warn(this.$t(messages_1.auditMsg.FINAL_REPORT_PATH, { path: this.sharedConfig.reportPath }), this.auditContext);
|
|
90
109
|
}
|
|
91
110
|
else {
|
|
92
|
-
|
|
111
|
+
cli_utilities_1.log.warn(this.$t(this.messages.FIXED_CONTENT_PATH_MAG, { path: this.sharedConfig.basePath }), this.auditContext);
|
|
93
112
|
}
|
|
94
113
|
}
|
|
95
114
|
else {
|
|
96
|
-
|
|
97
|
-
|
|
115
|
+
cli_utilities_1.log.info(this.messages.NO_MISSING_REF_FOUND, this.auditContext);
|
|
116
|
+
cli_utilities_1.cliux.print('');
|
|
98
117
|
if (this.flags['copy-dir'] &&
|
|
99
118
|
this.currentCommand === 'cm:stacks:audit:fix' &&
|
|
100
119
|
(0, fs_1.existsSync)(this.sharedConfig.basePath)) {
|
|
@@ -121,17 +140,23 @@ class AuditBaseCommand extends base_command_1.BaseCommand {
|
|
|
121
140
|
*/
|
|
122
141
|
async scanAndFix() {
|
|
123
142
|
var _a, _b, _c, _d, _e, _f;
|
|
143
|
+
cli_utilities_1.log.debug('Starting scan and fix process', this.auditContext);
|
|
124
144
|
let { ctSchema, gfSchema } = this.getCtAndGfSchema();
|
|
125
|
-
|
|
145
|
+
cli_utilities_1.log.info(`Retrieved ${(ctSchema === null || ctSchema === void 0 ? void 0 : ctSchema.length) || 0} content types and ${(gfSchema === null || gfSchema === void 0 ? void 0 : gfSchema.length) || 0} global fields`, this.auditContext);
|
|
146
|
+
let missingCtRefs, missingGfRefs, missingEntryRefs, missingCtRefsInExtensions, missingCtRefsInWorkflow, missingSelectFeild, missingEntry = {}, missingMandatoryFields, missingTitleFields, missingRefInCustomRoles, missingEnvLocalesInAssets, missingEnvLocalesInEntries, missingFieldRules, missingMultipleFields;
|
|
126
147
|
const constructorParam = {
|
|
127
148
|
ctSchema,
|
|
128
149
|
gfSchema,
|
|
129
|
-
|
|
130
|
-
config: this.sharedConfig,
|
|
150
|
+
config: Object.assign(Object.assign({}, this.sharedConfig), { auditContext: this.auditContext }),
|
|
131
151
|
fix: this.currentCommand === 'cm:stacks:audit:fix',
|
|
132
152
|
};
|
|
133
153
|
let dataModuleWise = await new modules_1.ModuleDataReader((0, cloneDeep_1.default)(constructorParam)).run();
|
|
154
|
+
cli_utilities_1.log.debug(`Data module wise: ${JSON.stringify(dataModuleWise)}`, this.auditContext);
|
|
134
155
|
for (const module of this.sharedConfig.flags.modules || this.sharedConfig.modules) {
|
|
156
|
+
// Update audit context with current module
|
|
157
|
+
this.auditContext = this.createAuditContext(module);
|
|
158
|
+
cli_utilities_1.log.debug(`Starting audit for module: ${module}`, this.auditContext);
|
|
159
|
+
cli_utilities_1.log.info(`Starting audit for module: ${module}`, this.auditContext);
|
|
135
160
|
(0, log_1.print)([
|
|
136
161
|
{
|
|
137
162
|
bold: true,
|
|
@@ -142,21 +167,28 @@ class AuditBaseCommand extends base_command_1.BaseCommand {
|
|
|
142
167
|
constructorParam['moduleName'] = module;
|
|
143
168
|
switch (module) {
|
|
144
169
|
case 'assets':
|
|
170
|
+
cli_utilities_1.log.info('Executing assets audit', this.auditContext);
|
|
145
171
|
missingEnvLocalesInAssets = await new modules_1.Assets((0, cloneDeep_1.default)(constructorParam)).run();
|
|
146
172
|
await this.prepareReport(module, missingEnvLocalesInAssets);
|
|
147
173
|
this.getAffectedData('assets', dataModuleWise['assets'], missingEnvLocalesInAssets);
|
|
174
|
+
cli_utilities_1.log.success(`Assets audit completed. Found ${Object.keys(missingEnvLocalesInAssets || {}).length} issues`, this.auditContext);
|
|
148
175
|
break;
|
|
149
176
|
case 'content-types':
|
|
177
|
+
cli_utilities_1.log.info('Executing content-types audit', this.auditContext);
|
|
150
178
|
missingCtRefs = await new modules_1.ContentType((0, cloneDeep_1.default)(constructorParam)).run();
|
|
151
179
|
await this.prepareReport(module, missingCtRefs);
|
|
152
180
|
this.getAffectedData('content-types', dataModuleWise['content-types'], missingCtRefs);
|
|
181
|
+
cli_utilities_1.log.success(`Content-types audit completed. Found ${Object.keys(missingCtRefs || {}).length} issues`, this.auditContext);
|
|
153
182
|
break;
|
|
154
183
|
case 'global-fields':
|
|
184
|
+
cli_utilities_1.log.info('Executing global-fields audit', this.auditContext);
|
|
155
185
|
missingGfRefs = await new modules_1.GlobalField((0, cloneDeep_1.default)(constructorParam)).run();
|
|
156
186
|
await this.prepareReport(module, missingGfRefs);
|
|
157
187
|
this.getAffectedData('global-fields', dataModuleWise['global-fields'], missingGfRefs);
|
|
188
|
+
cli_utilities_1.log.success(`Global-fields audit completed. Found ${Object.keys(missingGfRefs || {}).length} issues`, this.auditContext);
|
|
158
189
|
break;
|
|
159
190
|
case 'entries':
|
|
191
|
+
cli_utilities_1.log.info('Executing entries audit', this.auditContext);
|
|
160
192
|
missingEntry = await new modules_1.Entries((0, cloneDeep_1.default)(constructorParam)).run();
|
|
161
193
|
missingEntryRefs = (_a = missingEntry.missingEntryRefs) !== null && _a !== void 0 ? _a : {};
|
|
162
194
|
missingSelectFeild = (_b = missingEntry.missingSelectFeild) !== null && _b !== void 0 ? _b : {};
|
|
@@ -171,29 +203,36 @@ class AuditBaseCommand extends base_command_1.BaseCommand {
|
|
|
171
203
|
await this.prepareReport('Entry_Missing_Locale_and_Env_in_Publish_Details', missingEnvLocalesInEntries);
|
|
172
204
|
await this.prepareReport('Entry_Multiple_Fields', missingMultipleFields);
|
|
173
205
|
this.getAffectedData('entries', dataModuleWise['entries'], missingEntry);
|
|
206
|
+
cli_utilities_1.log.success(`Entries audit completed. Found ${Object.keys(missingEntryRefs || {}).length} reference issues`, this.auditContext);
|
|
174
207
|
break;
|
|
175
208
|
case 'workflows':
|
|
209
|
+
cli_utilities_1.log.info('Executing workflows audit', this.auditContext);
|
|
176
210
|
missingCtRefsInWorkflow = await new modules_1.Workflows({
|
|
177
211
|
ctSchema,
|
|
178
|
-
log: this.log,
|
|
179
212
|
moduleName: module,
|
|
180
213
|
config: this.sharedConfig,
|
|
181
214
|
fix: this.currentCommand === 'cm:stacks:audit:fix',
|
|
182
215
|
}).run();
|
|
183
216
|
await this.prepareReport(module, missingCtRefsInWorkflow);
|
|
184
217
|
this.getAffectedData('workflows', dataModuleWise['workflows'], missingCtRefsInWorkflow);
|
|
218
|
+
cli_utilities_1.log.success(`Workflows audit completed. Found ${Object.keys(missingCtRefsInWorkflow || {}).length} issues`, this.auditContext);
|
|
185
219
|
break;
|
|
186
220
|
case 'extensions':
|
|
221
|
+
cli_utilities_1.log.info('Executing extensions audit', this.auditContext);
|
|
187
222
|
missingCtRefsInExtensions = await new modules_1.Extensions((0, cloneDeep_1.default)(constructorParam)).run();
|
|
188
223
|
await this.prepareReport(module, missingCtRefsInExtensions);
|
|
189
224
|
this.getAffectedData('extensions', dataModuleWise['extensions'], missingCtRefsInExtensions);
|
|
225
|
+
cli_utilities_1.log.success(`Extensions audit completed. Found ${Object.keys(missingCtRefsInExtensions || {}).length} issues`, this.auditContext);
|
|
190
226
|
break;
|
|
191
227
|
case 'custom-roles':
|
|
228
|
+
cli_utilities_1.log.info('Executing custom-roles audit', this.auditContext);
|
|
192
229
|
missingRefInCustomRoles = await new modules_1.CustomRoles((0, cloneDeep_1.default)(constructorParam)).run();
|
|
193
230
|
await this.prepareReport(module, missingRefInCustomRoles);
|
|
194
231
|
this.getAffectedData('custom-roles', dataModuleWise['custom-roles'], missingRefInCustomRoles);
|
|
232
|
+
cli_utilities_1.log.success(`Custom-roles audit completed. Found ${Object.keys(missingRefInCustomRoles || {}).length} issues`, this.auditContext);
|
|
195
233
|
break;
|
|
196
234
|
case 'field-rules':
|
|
235
|
+
cli_utilities_1.log.info('Executing field-rules audit', this.auditContext);
|
|
197
236
|
// NOTE: We are using the fixed content-type for validation of field rules
|
|
198
237
|
const data = this.getCtAndGfSchema();
|
|
199
238
|
constructorParam.ctSchema = data.ctSchema;
|
|
@@ -201,6 +240,7 @@ class AuditBaseCommand extends base_command_1.BaseCommand {
|
|
|
201
240
|
missingFieldRules = await new modules_1.FieldRule((0, cloneDeep_1.default)(constructorParam)).run();
|
|
202
241
|
await this.prepareReport(module, missingFieldRules);
|
|
203
242
|
this.getAffectedData('field-rules', dataModuleWise['content-types'], missingFieldRules);
|
|
243
|
+
cli_utilities_1.log.success(`Field-rules audit completed. Found ${Object.keys(missingFieldRules || {}).length} issues`, this.auditContext);
|
|
204
244
|
break;
|
|
205
245
|
}
|
|
206
246
|
(0, log_1.print)([
|
|
@@ -216,6 +256,7 @@ class AuditBaseCommand extends base_command_1.BaseCommand {
|
|
|
216
256
|
},
|
|
217
257
|
]);
|
|
218
258
|
}
|
|
259
|
+
cli_utilities_1.log.debug('Scan and fix process completed', this.auditContext);
|
|
219
260
|
this.prepareReport('Summary', this.summaryDataToPrint);
|
|
220
261
|
this.prepareCSV('Summary', this.summaryDataToPrint);
|
|
221
262
|
return {
|
|
@@ -290,7 +331,7 @@ class AuditBaseCommand extends base_command_1.BaseCommand {
|
|
|
290
331
|
showOutputOnScreen(allMissingRefs) {
|
|
291
332
|
var _a;
|
|
292
333
|
if (this.sharedConfig.showTerminalOutput && !((_a = this.flags['external-config']) === null || _a === void 0 ? void 0 : _a.noTerminalOutput)) {
|
|
293
|
-
|
|
334
|
+
cli_utilities_1.cliux.print(''); // NOTE adding new line
|
|
294
335
|
for (const { module, missingRefs } of allMissingRefs) {
|
|
295
336
|
if (!(0, isEmpty_1.default)(missingRefs)) {
|
|
296
337
|
(0, log_1.print)([
|
|
@@ -335,7 +376,7 @@ class AuditBaseCommand extends base_command_1.BaseCommand {
|
|
|
335
376
|
},
|
|
336
377
|
];
|
|
337
378
|
cli_utilities_1.cliux.table(tableHeaders, tableValues, Object.assign({}, this.flags));
|
|
338
|
-
|
|
379
|
+
cli_utilities_1.cliux.print(''); // NOTE adding new line
|
|
339
380
|
}
|
|
340
381
|
}
|
|
341
382
|
}
|
|
@@ -346,7 +387,7 @@ class AuditBaseCommand extends base_command_1.BaseCommand {
|
|
|
346
387
|
if (!this.sharedConfig.showTerminalOutput || ((_a = this.flags['external-config']) === null || _a === void 0 ? void 0 : _a.noTerminalOutput)) {
|
|
347
388
|
return;
|
|
348
389
|
}
|
|
349
|
-
|
|
390
|
+
cli_utilities_1.cliux.print(''); // Adding a new line
|
|
350
391
|
for (let { module, missingRefs } of allMissingRefs) {
|
|
351
392
|
if ((0, isEmpty_1.default)(missingRefs)) {
|
|
352
393
|
continue;
|
|
@@ -378,7 +419,7 @@ class AuditBaseCommand extends base_command_1.BaseCommand {
|
|
|
378
419
|
},
|
|
379
420
|
}));
|
|
380
421
|
cli_utilities_1.cliux.table(tableHeaders, tableValues, Object.assign({}, this.flags));
|
|
381
|
-
|
|
422
|
+
cli_utilities_1.cliux.print(''); // Adding a new line
|
|
382
423
|
}
|
|
383
424
|
}
|
|
384
425
|
/**
|
|
@@ -392,14 +433,26 @@ class AuditBaseCommand extends base_command_1.BaseCommand {
|
|
|
392
433
|
* @returns The function `prepareReport` returns a Promise that resolves to `void`.
|
|
393
434
|
*/
|
|
394
435
|
prepareReport(moduleName, listOfMissingRefs) {
|
|
395
|
-
|
|
436
|
+
cli_utilities_1.log.debug(`Preparing report for module: ${moduleName}`, this.auditContext);
|
|
437
|
+
cli_utilities_1.log.debug(`Report path: ${this.sharedConfig.reportPath}`, this.auditContext);
|
|
438
|
+
cli_utilities_1.log.info(`Missing references count: ${Object.keys(listOfMissingRefs).length}`, this.auditContext);
|
|
439
|
+
if ((0, isEmpty_1.default)(listOfMissingRefs)) {
|
|
440
|
+
cli_utilities_1.log.debug(`No missing references found for ${moduleName}, skipping report generation`, this.auditContext);
|
|
396
441
|
return Promise.resolve(void 0);
|
|
442
|
+
}
|
|
397
443
|
if (!(0, fs_1.existsSync)(this.sharedConfig.reportPath)) {
|
|
444
|
+
cli_utilities_1.log.debug(`Creating report directory: ${this.sharedConfig.reportPath}`, this.auditContext);
|
|
398
445
|
(0, fs_1.mkdirSync)(this.sharedConfig.reportPath, { recursive: true });
|
|
399
446
|
}
|
|
447
|
+
else {
|
|
448
|
+
cli_utilities_1.log.debug(`Report directory already exists: ${this.sharedConfig.reportPath}`, this.auditContext);
|
|
449
|
+
}
|
|
400
450
|
// NOTE write int json
|
|
401
|
-
|
|
451
|
+
const jsonFilePath = (0, path_1.join)((0, cli_utilities_1.sanitizePath)(this.sharedConfig.reportPath), `${(0, cli_utilities_1.sanitizePath)(moduleName)}.json`);
|
|
452
|
+
cli_utilities_1.log.debug(`Writing JSON report to: ${jsonFilePath}`, this.auditContext);
|
|
453
|
+
(0, fs_1.writeFileSync)(jsonFilePath, JSON.stringify(listOfMissingRefs));
|
|
402
454
|
// NOTE write into CSV
|
|
455
|
+
cli_utilities_1.log.debug(`Preparing CSV report for: ${moduleName}`, this.auditContext);
|
|
403
456
|
return this.prepareCSV(moduleName, listOfMissingRefs);
|
|
404
457
|
}
|
|
405
458
|
/**
|
package/lib/base-command.d.ts
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
1
|
import { Command } from '@contentstack/cli-command';
|
|
2
2
|
import { FlagInput, Interfaces } from '@contentstack/cli-utilities';
|
|
3
|
-
import {
|
|
4
|
-
import { ConfigType, LogFn } from './types';
|
|
3
|
+
import { ConfigType } from './types';
|
|
5
4
|
import messages, { $t } from './messages';
|
|
6
5
|
export type Args<T extends typeof Command> = Interfaces.InferredArgs<T['args']>;
|
|
7
6
|
export type Flags<T extends typeof Command> = Interfaces.InferredFlags<(typeof BaseCommand)['baseFlags'] & T['flags']>;
|
|
8
7
|
export declare abstract class BaseCommand<T extends typeof Command> extends Command {
|
|
9
|
-
log: LogFn;
|
|
10
|
-
logger: Logger;
|
|
11
8
|
readonly $t: typeof $t;
|
|
12
9
|
protected sharedConfig: ConfigType;
|
|
13
10
|
readonly messages: typeof messages;
|
package/lib/base-command.js
CHANGED
|
@@ -8,9 +8,7 @@ const fs_1 = require("fs");
|
|
|
8
8
|
const cli_command_1 = require("@contentstack/cli-command");
|
|
9
9
|
const cli_utilities_1 = require("@contentstack/cli-utilities");
|
|
10
10
|
const config_1 = tslib_1.__importDefault(require("./config"));
|
|
11
|
-
const util_1 = require("./util");
|
|
12
11
|
const messages_1 = tslib_1.__importStar(require("./messages"));
|
|
13
|
-
const noLog = (_message, _logType) => { };
|
|
14
12
|
class BaseCommand extends cli_command_1.Command {
|
|
15
13
|
constructor() {
|
|
16
14
|
super(...arguments);
|
|
@@ -41,14 +39,9 @@ class BaseCommand extends cli_command_1.Command {
|
|
|
41
39
|
this.registerConfig();
|
|
42
40
|
// Init logger
|
|
43
41
|
if ((_c = this.flags['external-config']) === null || _c === void 0 ? void 0 : _c.noLog) {
|
|
44
|
-
this.log = noLog;
|
|
45
42
|
cli_utilities_1.ux.action.start = () => { };
|
|
46
43
|
cli_utilities_1.ux.action.stop = () => { };
|
|
47
44
|
}
|
|
48
|
-
else {
|
|
49
|
-
const logger = new util_1.Logger(this.sharedConfig);
|
|
50
|
-
this.log = logger.log.bind(logger);
|
|
51
|
-
}
|
|
52
45
|
}
|
|
53
46
|
/**
|
|
54
47
|
* The catch function is used to handle errors from a command, either by adding custom logic or
|
|
@@ -83,7 +76,7 @@ class BaseCommand extends cli_command_1.Command {
|
|
|
83
76
|
this.sharedConfig = (0, merge_1.default)(this.sharedConfig, JSON.parse((0, fs_1.readFileSync)(this.flags.config, { encoding: 'utf-8' })));
|
|
84
77
|
}
|
|
85
78
|
catch (error) {
|
|
86
|
-
|
|
79
|
+
(0, cli_utilities_1.handleAndLogError)(error);
|
|
87
80
|
}
|
|
88
81
|
}
|
|
89
82
|
}
|
|
@@ -21,8 +21,7 @@ class AuditFix extends audit_base_command_1.AuditBaseCommand {
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
catch (error) {
|
|
24
|
-
|
|
25
|
-
console.trace(error);
|
|
24
|
+
(0, cli_utilities_1.handleAndLogError)(error);
|
|
26
25
|
cli_utilities_1.ux.action.stop('Process failed.!');
|
|
27
26
|
this.exit(1);
|
|
28
27
|
}
|
|
@@ -16,8 +16,7 @@ class Audit extends audit_base_command_1.AuditBaseCommand {
|
|
|
16
16
|
await this.start('cm:stacks:audit');
|
|
17
17
|
}
|
|
18
18
|
catch (error) {
|
|
19
|
-
|
|
20
|
-
this.log(error instanceof Error ? error.message : error, 'error');
|
|
19
|
+
(0, cli_utilities_1.handleAndLogError)(error);
|
|
21
20
|
cli_utilities_1.ux.action.stop('Process failed.!');
|
|
22
21
|
this.exit(1);
|
|
23
22
|
}
|
package/lib/modules/assets.d.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ConfigType, ContentTypeStruct, CtConstructorParam, ModuleConstructorParam, EntryStruct } from '../types';
|
|
2
2
|
import auditConfig from '../config';
|
|
3
3
|
export default class Assets {
|
|
4
|
-
log: LogFn;
|
|
5
4
|
protected fix: boolean;
|
|
6
5
|
fileName: string;
|
|
7
6
|
config: ConfigType;
|
|
@@ -14,7 +13,7 @@ export default class Assets {
|
|
|
14
13
|
protected schema: ContentTypeStruct[];
|
|
15
14
|
protected missingEnvLocales: Record<string, any>;
|
|
16
15
|
moduleName: keyof typeof auditConfig.moduleConfig;
|
|
17
|
-
constructor({
|
|
16
|
+
constructor({ fix, config, moduleName }: ModuleConstructorParam & CtConstructorParam);
|
|
18
17
|
validateModules(moduleName: keyof typeof auditConfig.moduleConfig, moduleConfig: Record<string, unknown>): keyof typeof auditConfig.moduleConfig;
|
|
19
18
|
/**
|
|
20
19
|
* The `run` function checks if a folder path exists, sets the schema based on the module name,
|
package/lib/modules/assets.js
CHANGED
|
@@ -10,12 +10,11 @@ const lodash_1 = require("lodash");
|
|
|
10
10
|
/* The `ContentType` class is responsible for scanning content types, looking for references, and
|
|
11
11
|
generating a report in JSON and CSV formats. */
|
|
12
12
|
class Assets {
|
|
13
|
-
constructor({
|
|
13
|
+
constructor({ fix, config, moduleName }) {
|
|
14
14
|
this.locales = [];
|
|
15
15
|
this.environments = [];
|
|
16
16
|
this.schema = [];
|
|
17
17
|
this.missingEnvLocales = {};
|
|
18
|
-
this.log = log;
|
|
19
18
|
this.config = config;
|
|
20
19
|
this.fix = fix !== null && fix !== void 0 ? fix : false;
|
|
21
20
|
this.moduleName = this.validateModules(moduleName, this.config.moduleConfig);
|
|
@@ -34,16 +33,25 @@ class Assets {
|
|
|
34
33
|
* @returns the `missingEnvLocales` object.
|
|
35
34
|
*/
|
|
36
35
|
async run(returnFixSchema = false) {
|
|
36
|
+
var _a;
|
|
37
|
+
cli_utilities_1.log.debug(`Starting ${this.moduleName} audit process`, this.config.auditContext);
|
|
38
|
+
cli_utilities_1.log.debug(`Data directory: ${this.folderPath}`, this.config.auditContext);
|
|
39
|
+
cli_utilities_1.log.debug(`Fix mode: ${this.fix}`, this.config.auditContext);
|
|
37
40
|
if (!(0, fs_1.existsSync)(this.folderPath)) {
|
|
38
|
-
|
|
39
|
-
|
|
41
|
+
cli_utilities_1.log.debug(`Skipping ${this.moduleName} audit - path does not exist`, this.config.auditContext);
|
|
42
|
+
cli_utilities_1.log.warn(`Skipping ${this.moduleName} audit`, this.config.auditContext);
|
|
43
|
+
cli_utilities_1.cliux.print((0, messages_1.$t)(messages_1.auditMsg.NOT_VALID_PATH, { path: this.folderPath }), { color: 'yellow' });
|
|
40
44
|
return returnFixSchema ? [] : {};
|
|
41
45
|
}
|
|
46
|
+
cli_utilities_1.log.debug('Loading prerequisite data (locales and environments)', this.config.auditContext);
|
|
42
47
|
await this.prerequisiteData();
|
|
48
|
+
cli_utilities_1.log.debug('Starting asset Reference, Environment and Locale validation', this.config.auditContext);
|
|
43
49
|
await this.lookForReference();
|
|
44
50
|
if (returnFixSchema) {
|
|
51
|
+
cli_utilities_1.log.debug(`Returning fixed schema with ${((_a = this.schema) === null || _a === void 0 ? void 0 : _a.length) || 0} items`, this.config.auditContext);
|
|
45
52
|
return this.schema;
|
|
46
53
|
}
|
|
54
|
+
cli_utilities_1.log.debug('Cleaning up empty missing environment/locale references', this.config.auditContext);
|
|
47
55
|
for (let propName in this.missingEnvLocales) {
|
|
48
56
|
if (Array.isArray(this.missingEnvLocales[propName])) {
|
|
49
57
|
if (!this.missingEnvLocales[propName].length) {
|
|
@@ -51,6 +59,8 @@ class Assets {
|
|
|
51
59
|
}
|
|
52
60
|
}
|
|
53
61
|
}
|
|
62
|
+
const totalIssues = Object.keys(this.missingEnvLocales).length;
|
|
63
|
+
cli_utilities_1.log.debug(`${this.moduleName} audit completed. Found ${totalIssues} assets with missing environment/locale references`, this.config.auditContext);
|
|
54
64
|
return this.missingEnvLocales;
|
|
55
65
|
}
|
|
56
66
|
/**
|
|
@@ -59,17 +69,33 @@ class Assets {
|
|
|
59
69
|
* app data, and stores them in the `extensions` array.
|
|
60
70
|
*/
|
|
61
71
|
async prerequisiteData() {
|
|
62
|
-
|
|
72
|
+
cli_utilities_1.log.debug('Loading prerequisite data (locales and environments)', this.config.auditContext);
|
|
73
|
+
cli_utilities_1.log.info(messages_1.auditMsg.PREPARING_ENTRY_METADATA, this.config.auditContext);
|
|
63
74
|
const localesFolderPath = (0, path_1.resolve)(this.config.basePath, this.config.moduleConfig.locales.dirName);
|
|
64
75
|
const localesPath = (0, path_1.join)(localesFolderPath, this.config.moduleConfig.locales.fileName);
|
|
65
76
|
const masterLocalesPath = (0, path_1.join)(localesFolderPath, 'master-locale.json');
|
|
77
|
+
cli_utilities_1.log.debug(`Loading locales from: ${localesFolderPath}`, this.config.auditContext);
|
|
78
|
+
cli_utilities_1.log.debug(`Master locales path: ${masterLocalesPath}`, this.config.auditContext);
|
|
79
|
+
cli_utilities_1.log.debug(`Locales path: ${localesPath}`, this.config.auditContext);
|
|
66
80
|
this.locales = (0, fs_1.existsSync)(masterLocalesPath) ? (0, values_1.default)(JSON.parse((0, fs_1.readFileSync)(masterLocalesPath, 'utf8'))) : [];
|
|
81
|
+
cli_utilities_1.log.debug(`Loaded ${this.locales.length} locales from master-locale.json`, this.config.auditContext);
|
|
67
82
|
if ((0, fs_1.existsSync)(localesPath)) {
|
|
68
|
-
|
|
83
|
+
cli_utilities_1.log.debug(`Loading additional locales from: ${localesPath}`, this.config.auditContext);
|
|
84
|
+
const additionalLocales = (0, values_1.default)(JSON.parse((0, fs_1.readFileSync)(localesPath, 'utf8')));
|
|
85
|
+
this.locales.push(...additionalLocales);
|
|
86
|
+
cli_utilities_1.log.debug(`Added ${additionalLocales.length} additional locales`, this.config.auditContext);
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
cli_utilities_1.log.debug('No additional locales file found', this.config.auditContext);
|
|
69
90
|
}
|
|
70
91
|
this.locales = this.locales.map((locale) => locale.code);
|
|
92
|
+
cli_utilities_1.log.debug(`Total locales loaded: ${this.locales.length}`, this.config.auditContext);
|
|
93
|
+
cli_utilities_1.log.debug(`Locale codes: ${this.locales.join(', ')}`, this.config.auditContext);
|
|
71
94
|
const environmentPath = (0, path_1.resolve)(this.config.basePath, this.config.moduleConfig.environments.dirName, this.config.moduleConfig.environments.fileName);
|
|
95
|
+
cli_utilities_1.log.debug(`Loading environments from: ${environmentPath}`, this.config.auditContext);
|
|
72
96
|
this.environments = (0, fs_1.existsSync)(environmentPath) ? (0, lodash_1.keys)(JSON.parse((0, fs_1.readFileSync)(environmentPath, 'utf8'))) : [];
|
|
97
|
+
cli_utilities_1.log.debug(`Total environments loaded: ${this.environments.length}`, this.config.auditContext);
|
|
98
|
+
cli_utilities_1.log.debug(`Environment names: ${this.environments.join(', ')}`, this.config.auditContext);
|
|
73
99
|
}
|
|
74
100
|
/**
|
|
75
101
|
* The function checks if it can write the fix content to a file and if so, it writes the content as
|
|
@@ -77,61 +103,93 @@ class Assets {
|
|
|
77
103
|
*/
|
|
78
104
|
async writeFixContent(filePath, schema) {
|
|
79
105
|
var _a;
|
|
106
|
+
cli_utilities_1.log.debug(`Starting writeFixContent process for: ${filePath}`, this.config.auditContext);
|
|
80
107
|
let canWrite = true;
|
|
81
108
|
if (this.fix) {
|
|
109
|
+
cli_utilities_1.log.debug('Fix mode enabled, checking write permissions', this.config.auditContext);
|
|
82
110
|
if (!this.config.flags['copy-dir'] && !((_a = this.config.flags['external-config']) === null || _a === void 0 ? void 0 : _a.skipConfirm)) {
|
|
111
|
+
cli_utilities_1.log.debug(`Asking user for confirmation to write fix content (--yes flag: ${this.config.flags.yes})`, this.config.auditContext);
|
|
83
112
|
canWrite = this.config.flags.yes || (await cli_utilities_1.cliux.confirm(messages_1.commonMsg.FIX_CONFIRMATION));
|
|
84
113
|
}
|
|
114
|
+
else {
|
|
115
|
+
cli_utilities_1.log.debug('Skipping confirmation due to copy-dir or external-config flags', this.config.auditContext);
|
|
116
|
+
}
|
|
85
117
|
if (canWrite) {
|
|
118
|
+
cli_utilities_1.log.debug(`Writing fixed assets to: ${filePath}`, this.config.auditContext);
|
|
86
119
|
(0, fs_1.writeFileSync)(filePath, JSON.stringify(schema));
|
|
120
|
+
cli_utilities_1.log.debug(`Successfully wrote ${Object.keys(schema).length} assets to file`, this.config.auditContext);
|
|
87
121
|
}
|
|
122
|
+
else {
|
|
123
|
+
cli_utilities_1.log.debug('User declined to write fix content', this.config.auditContext);
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
cli_utilities_1.log.debug('Skipping writeFixContent - not in fix mode', this.config.auditContext);
|
|
88
128
|
}
|
|
89
129
|
}
|
|
90
130
|
/**
|
|
91
131
|
* This function traverse over the publish detials of the assets and remove the publish details where the locale or environment does not exist
|
|
92
132
|
*/
|
|
93
133
|
async lookForReference() {
|
|
94
|
-
var _a, _b;
|
|
134
|
+
var _a, _b, _c, _d;
|
|
135
|
+
cli_utilities_1.log.debug('Starting asset reference validation', this.config.auditContext);
|
|
95
136
|
let basePath = (0, path_1.join)(this.folderPath);
|
|
137
|
+
cli_utilities_1.log.debug(`Assets base path: ${basePath}`, this.config.auditContext);
|
|
96
138
|
let fsUtility = new cli_utilities_1.FsUtility({ basePath, indexFileName: 'assets.json' });
|
|
97
139
|
let indexer = fsUtility.indexFileContent;
|
|
140
|
+
cli_utilities_1.log.debug(`Found ${Object.keys(indexer).length} asset files to process`, this.config.auditContext);
|
|
98
141
|
for (const fileIndex in indexer) {
|
|
142
|
+
cli_utilities_1.log.debug(`Processing asset file: ${indexer[fileIndex]}`, this.config.auditContext);
|
|
99
143
|
const assets = (await fsUtility.readChunkFiles.next());
|
|
100
144
|
this.assets = assets;
|
|
145
|
+
cli_utilities_1.log.debug(`Loaded ${Object.keys(assets).length} assets from file`, this.config.auditContext);
|
|
101
146
|
for (const assetUid in assets) {
|
|
147
|
+
cli_utilities_1.log.debug(`Processing asset: ${assetUid}`, this.config.auditContext);
|
|
102
148
|
if (((_a = this.assets[assetUid]) === null || _a === void 0 ? void 0 : _a.publish_details) && !Array.isArray(this.assets[assetUid].publish_details)) {
|
|
103
|
-
|
|
149
|
+
cli_utilities_1.log.debug(`Asset ${assetUid} has invalid publish_details format`, this.config.auditContext);
|
|
150
|
+
cli_utilities_1.cliux.print((0, messages_1.$t)(messages_1.auditMsg.ASSET_NOT_EXIST, { uid: assetUid }), { color: 'red' });
|
|
104
151
|
}
|
|
105
|
-
|
|
152
|
+
const publishDetails = (_b = this.assets[assetUid]) === null || _b === void 0 ? void 0 : _b.publish_details;
|
|
153
|
+
cli_utilities_1.log.debug(`Asset ${assetUid} has ${(publishDetails === null || publishDetails === void 0 ? void 0 : publishDetails.length) || 0} publish details`, this.config.auditContext);
|
|
154
|
+
this.assets[assetUid].publish_details = (_c = this.assets[assetUid]) === null || _c === void 0 ? void 0 : _c.publish_details.filter((pd) => {
|
|
106
155
|
var _a, _b;
|
|
156
|
+
cli_utilities_1.log.debug(`Checking publish detail: locale=${pd === null || pd === void 0 ? void 0 : pd.locale}, environment=${pd === null || pd === void 0 ? void 0 : pd.environment}`, this.config.auditContext);
|
|
107
157
|
if (((_a = this.locales) === null || _a === void 0 ? void 0 : _a.includes(pd === null || pd === void 0 ? void 0 : pd.locale)) && ((_b = this.environments) === null || _b === void 0 ? void 0 : _b.includes(pd === null || pd === void 0 ? void 0 : pd.environment))) {
|
|
108
|
-
|
|
158
|
+
cli_utilities_1.log.debug(`Publish detail valid for asset ${assetUid}: locale=${pd.locale}, environment=${pd.environment}`, this.config.auditContext);
|
|
159
|
+
cli_utilities_1.log.info((0, messages_1.$t)(messages_1.auditMsg.SCAN_ASSET_SUCCESS_MSG, { uid: assetUid }), this.config.auditContext);
|
|
109
160
|
return true;
|
|
110
161
|
}
|
|
111
162
|
else {
|
|
112
|
-
|
|
163
|
+
cli_utilities_1.log.debug(`Publish detail invalid for asset ${assetUid}: locale=${pd.locale}, environment=${pd.environment}`, this.config.auditContext);
|
|
164
|
+
cli_utilities_1.cliux.print((0, messages_1.$t)(messages_1.auditMsg.SCAN_ASSET_WARN_MSG, { uid: assetUid, locale: pd.locale, environment: pd.environment }), { color: 'yellow' });
|
|
113
165
|
if (!Object.keys(this.missingEnvLocales).includes(assetUid)) {
|
|
166
|
+
cli_utilities_1.log.debug(`Creating new missing reference entry for asset ${assetUid}`, this.config.auditContext);
|
|
114
167
|
this.missingEnvLocales[assetUid] = [
|
|
115
168
|
{ asset_uid: assetUid, publish_locale: pd.locale, publish_environment: pd.environment },
|
|
116
169
|
];
|
|
117
170
|
}
|
|
118
171
|
else {
|
|
172
|
+
cli_utilities_1.log.debug(`Adding to existing missing reference entry for asset ${assetUid}`, this.config.auditContext);
|
|
119
173
|
this.missingEnvLocales[assetUid].push({
|
|
120
174
|
asset_uid: assetUid,
|
|
121
175
|
publish_locale: pd.locale,
|
|
122
176
|
publish_environment: pd.environment,
|
|
123
177
|
});
|
|
124
178
|
}
|
|
125
|
-
|
|
179
|
+
cli_utilities_1.log.success((0, messages_1.$t)(messages_1.auditMsg.SCAN_ASSET_SUCCESS_MSG, { uid: assetUid }), this.config.auditContext);
|
|
126
180
|
return false;
|
|
127
181
|
}
|
|
128
182
|
});
|
|
183
|
+
const remainingPublishDetails = ((_d = this.assets[assetUid].publish_details) === null || _d === void 0 ? void 0 : _d.length) || 0;
|
|
184
|
+
cli_utilities_1.log.debug(`Asset ${assetUid} now has ${remainingPublishDetails} valid publish details`, this.config.auditContext);
|
|
129
185
|
if (this.fix) {
|
|
130
|
-
|
|
186
|
+
cli_utilities_1.log.debug(`Fixing asset ${assetUid}`, this.config.auditContext);
|
|
187
|
+
cli_utilities_1.log.info((0, messages_1.$t)(messages_1.auditFixMsg.ASSET_FIX, { uid: assetUid }), this.config.auditContext);
|
|
131
188
|
await this.writeFixContent(`${basePath}/${indexer[fileIndex]}`, this.assets);
|
|
132
189
|
}
|
|
133
190
|
}
|
|
134
191
|
}
|
|
192
|
+
cli_utilities_1.log.debug(`Asset reference validation completed. Processed ${Object.keys(this.missingEnvLocales).length} assets with issues`, this.config.auditContext);
|
|
135
193
|
}
|
|
136
194
|
}
|
|
137
195
|
exports.default = Assets;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ConfigType, ModularBlockType, ContentTypeStruct, GroupFieldDataType, RefErrorReturnType, CtConstructorParam, GlobalFieldDataType, JsonRTEFieldDataType, ModularBlocksDataType, ModuleConstructorParam, ReferenceFieldDataType, ContentTypeSchemaType, ExtensionOrAppFieldDataType } from '../types';
|
|
2
2
|
import auditConfig from '../config';
|
|
3
3
|
export default class ContentType {
|
|
4
|
-
log: LogFn;
|
|
5
4
|
protected fix: boolean;
|
|
6
5
|
fileName: string;
|
|
7
6
|
config: ConfigType;
|
|
@@ -15,7 +14,7 @@ export default class ContentType {
|
|
|
15
14
|
protected schema: ContentTypeStruct[];
|
|
16
15
|
protected missingRefs: Record<string, any>;
|
|
17
16
|
moduleName: keyof typeof auditConfig.moduleConfig;
|
|
18
|
-
constructor({
|
|
17
|
+
constructor({ fix, config, moduleName, ctSchema, gfSchema }: ModuleConstructorParam & CtConstructorParam);
|
|
19
18
|
validateModules(moduleName: keyof typeof auditConfig.moduleConfig, moduleConfig: Record<string, unknown>): keyof typeof auditConfig.moduleConfig;
|
|
20
19
|
/**
|
|
21
20
|
* The `run` function checks if a folder path exists, sets the schema based on the module name,
|
|
@@ -127,7 +126,7 @@ export default class ContentType {
|
|
|
127
126
|
* contains properties such as `data_type`, `field_metadata`, `uid`, `name`, etc.
|
|
128
127
|
* @returns an array of ContentTypeSchemaType objects.
|
|
129
128
|
*/
|
|
130
|
-
runFixOnSchema(tree: Record<string, unknown>[], schema: ContentTypeSchemaType[]):
|
|
129
|
+
runFixOnSchema(tree: Record<string, unknown>[], schema: ContentTypeSchemaType[]): any[];
|
|
131
130
|
/**
|
|
132
131
|
* The function fixes global field references in a tree structure by adding missing references and
|
|
133
132
|
* returning the field if the reference exists, otherwise returning null.
|