@contentstack/cli-audit 1.14.2 → 1.16.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.14.2 linux-x64 node-v22.20.0
22
+ @contentstack/cli-audit/1.16.0 linux-x64 node-v22.21.1
23
23
  $ csdx --help [COMMAND]
24
24
  USAGE
25
25
  $ csdx COMMAND
@@ -273,7 +273,7 @@ USAGE
273
273
  $ csdx help [COMMAND...] [-n]
274
274
 
275
275
  ARGUMENTS
276
- COMMAND... Command to show help for.
276
+ [COMMAND...] Command to show help for.
277
277
 
278
278
  FLAGS
279
279
  -n, --nested-commands Include all nested commands in the output.
@@ -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.33/src/commands/help.ts)_
285
+ _See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.2.35/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.49/src/commands/plugins/index.ts)_
308
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.53/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.49/src/commands/plugins/inspect.ts)_
382
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.53/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.49/src/commands/plugins/install.ts)_
431
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.53/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.49/src/commands/plugins/link.ts)_
462
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.53/src/commands/plugins/link.ts)_
463
463
 
464
464
  ## `csdx plugins:remove [PLUGIN]`
465
465
 
@@ -470,7 +470,7 @@ USAGE
470
470
  $ csdx plugins:remove [PLUGIN...] [-h] [-v]
471
471
 
472
472
  ARGUMENTS
473
- PLUGIN... plugin to uninstall
473
+ [PLUGIN...] plugin to uninstall
474
474
 
475
475
  FLAGS
476
476
  -h, --help Show CLI help.
@@ -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.49/src/commands/plugins/reset.ts)_
503
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.53/src/commands/plugins/reset.ts)_
504
504
 
505
505
  ## `csdx plugins:uninstall [PLUGIN]`
506
506
 
@@ -511,7 +511,7 @@ USAGE
511
511
  $ csdx plugins:uninstall [PLUGIN...] [-h] [-v]
512
512
 
513
513
  ARGUMENTS
514
- PLUGIN... plugin to uninstall
514
+ [PLUGIN...] plugin to uninstall
515
515
 
516
516
  FLAGS
517
517
  -h, --help Show CLI help.
@@ -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.49/src/commands/plugins/uninstall.ts)_
531
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.53/src/commands/plugins/uninstall.ts)_
532
532
 
533
533
  ## `csdx plugins:unlink [PLUGIN]`
534
534
 
@@ -539,7 +539,7 @@ USAGE
539
539
  $ csdx plugins:unlink [PLUGIN...] [-h] [-v]
540
540
 
541
541
  ARGUMENTS
542
- PLUGIN... plugin to uninstall
542
+ [PLUGIN...] plugin to uninstall
543
543
 
544
544
  FLAGS
545
545
  -h, --help Show CLI help.
@@ -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.49/src/commands/plugins/update.ts)_
575
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.53/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
- this.log(this.$t(messages_1.auditMsg.FINAL_REPORT_PATH, { path: this.sharedConfig.reportPath }), 'warn');
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
- this.log(this.$t(this.messages.FIXED_CONTENT_PATH_MAG, { path: this.sharedConfig.basePath }), 'warn');
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
- this.log(this.messages.NO_MISSING_REF_FOUND, 'info');
97
- this.log('');
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
- let missingCtRefs, missingGfRefs, missingEntryRefs, missingCtRefsInExtensions, missingCtRefsInWorkflow, missingSelectFeild, missingEntry, missingMandatoryFields, missingTitleFields, missingRefInCustomRoles, missingEnvLocalesInAssets, missingEnvLocalesInEntries, missingFieldRules, missingMultipleFields;
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
- log: this.log,
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
- this.log(''); // NOTE adding new line
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
- this.log(''); // NOTE adding new line
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
- this.log(''); // Adding a new line
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
- this.log(''); // Adding a new line
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
- if ((0, isEmpty_1.default)(listOfMissingRefs))
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
- (0, fs_1.writeFileSync)((0, path_1.join)((0, cli_utilities_1.sanitizePath)(this.sharedConfig.reportPath), `${(0, cli_utilities_1.sanitizePath)(moduleName)}.json`), JSON.stringify(listOfMissingRefs));
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
  /**
@@ -1,13 +1,10 @@
1
1
  import { Command } from '@contentstack/cli-command';
2
2
  import { FlagInput, Interfaces } from '@contentstack/cli-utilities';
3
- import { Logger } from './util';
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;
@@ -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
- this.log(error, 'error');
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
- this.log(error instanceof Error ? error.message : error, 'error');
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
- console.trace(error);
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
  }
@@ -1,7 +1,6 @@
1
- import { LogFn, ConfigType, ContentTypeStruct, CtConstructorParam, ModuleConstructorParam, EntryStruct } from '../types';
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({ log, fix, config, moduleName }: ModuleConstructorParam & CtConstructorParam);
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,