@contentstack/cli-audit 1.4.0 → 1.4.1

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.4.0 linux-x64 node-v18.19.1
22
+ @contentstack/cli-audit/1.4.1 linux-x64 node-v18.19.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/v4.1.17/src/commands/plugins/index.ts)_
288
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.2.6/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.17/src/commands/plugins/inspect.ts)_
357
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.2.6/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.17/src/commands/plugins/install.ts)_
401
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.2.6/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.17/src/commands/plugins/link.ts)_
431
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.2.6/src/commands/plugins/link.ts)_
432
432
 
433
433
  ## `csdx plugins:uninstall PLUGIN...`
434
434
 
@@ -462,10 +462,14 @@ Remove all user-installed and linked plugins.
462
462
 
463
463
  ```
464
464
  USAGE
465
- $ csdx plugins:reset
465
+ $ csdx plugins:reset [--hard] [--reinstall]
466
+
467
+ FLAGS
468
+ --hard Delete node_modules and package manager related files in addition to uninstalling plugins.
469
+ --reinstall Reinstall all plugins after uninstalling.
466
470
  ```
467
471
 
468
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.1.17/src/commands/plugins/reset.ts)_
472
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.2.6/src/commands/plugins/reset.ts)_
469
473
 
470
474
  ## `csdx plugins:uninstall PLUGIN...`
471
475
 
@@ -493,7 +497,7 @@ EXAMPLES
493
497
  $ csdx plugins:uninstall myplugin
494
498
  ```
495
499
 
496
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.1.17/src/commands/plugins/uninstall.ts)_
500
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.2.6/src/commands/plugins/uninstall.ts)_
497
501
 
498
502
  ## `csdx plugins:uninstall PLUGIN...`
499
503
 
@@ -537,5 +541,5 @@ DESCRIPTION
537
541
  Update installed plugins.
538
542
  ```
539
543
 
540
- _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.1.17/src/commands/plugins/update.ts)_
544
+ _See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.2.6/src/commands/plugins/update.ts)_
541
545
  <!-- commandsstop -->
@@ -75,7 +75,13 @@ class AuditBaseCommand extends base_command_1.BaseCommand {
75
75
  let { ctSchema, gfSchema } = this.getCtAndGfSchema();
76
76
  let missingCtRefs, missingGfRefs, missingEntryRefs;
77
77
  for (const module of this.sharedConfig.flags.modules || this.sharedConfig.modules) {
78
- cli_utilities_1.ux.action.start(this.$t(this.messages.AUDIT_START_SPINNER, { module }));
78
+ (0, log_1.print)([
79
+ {
80
+ bold: true,
81
+ color: 'whiteBright',
82
+ message: this.$t(this.messages.AUDIT_START_SPINNER, { module }),
83
+ },
84
+ ]);
79
85
  const constructorParam = {
80
86
  ctSchema,
81
87
  gfSchema,
@@ -98,7 +104,18 @@ class AuditBaseCommand extends base_command_1.BaseCommand {
98
104
  await this.prepareReport(module, missingEntryRefs);
99
105
  break;
100
106
  }
101
- cli_utilities_1.ux.action.stop();
107
+ (0, log_1.print)([
108
+ {
109
+ bold: true,
110
+ color: 'whiteBright',
111
+ message: this.$t(this.messages.AUDIT_START_SPINNER, { module }),
112
+ },
113
+ {
114
+ bold: true,
115
+ message: ' done',
116
+ color: 'whiteBright',
117
+ },
118
+ ]);
102
119
  }
103
120
  return { missingCtRefs, missingGfRefs, missingEntryRefs };
104
121
  }
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  const config = {
4
4
  showTerminalOutput: true,
5
5
  skipRefs: ['sys_assets'],
6
- skipFieldTypes: ['taxonomy'],
6
+ skipFieldTypes: ['taxonomy', 'group'],
7
7
  modules: ['content-types', 'global-fields', 'entries'],
8
8
  'fix-fields': ['reference', 'global_field', 'json:rte', 'json:extension', 'blocks', 'group'],
9
9
  moduleConfig: {
@@ -1,6 +1,8 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.tableColumnDescriptions = exports.auditFixMsg = exports.auditMsg = exports.commonMsg = exports.errors = exports.$t = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const memoize_1 = tslib_1.__importDefault(require("lodash/memoize"));
4
6
  const errors = {};
5
7
  exports.errors = errors;
6
8
  const tableColumnDescriptions = {
@@ -51,13 +53,16 @@ const messages = Object.assign(Object.assign(Object.assign(Object.assign(Object.
51
53
  * @returns a string.
52
54
  */
53
55
  function $t(msg, args) {
54
- if (!msg)
55
- return '';
56
- for (const key of Object.keys(args)) {
57
- const escapedKey = key.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
58
- msg = msg.replace(new RegExp(`{${escapedKey}}`, 'g'), args[key]);
59
- }
60
- return msg;
56
+ const transfer = (0, memoize_1.default)(function (msg, args) {
57
+ if (!msg)
58
+ return '';
59
+ for (const key of Object.keys(args)) {
60
+ const escapedKey = key.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
61
+ msg = msg.replace(new RegExp(`{${escapedKey}}`, 'g'), args[key] || escapedKey);
62
+ }
63
+ return msg;
64
+ });
65
+ return transfer(msg, args);
61
66
  }
62
67
  exports.$t = $t;
63
68
  exports.default = messages;
@@ -10,6 +10,7 @@ const cli_utilities_1 = require("@contentstack/cli-utilities");
10
10
  const fs_1 = require("fs");
11
11
  const content_types_1 = tslib_1.__importDefault(require("./content-types"));
12
12
  const messages_1 = require("../messages");
13
+ const util_1 = require("../util");
13
14
  const global_fields_1 = tslib_1.__importDefault(require("./global-fields"));
14
15
  class Entries {
15
16
  constructor({ log, fix, config, moduleName, ctSchema, gfSchema }) {
@@ -59,11 +60,13 @@ class Entries {
59
60
  this.removeMissingKeysOnEntry(ctSchema.schema, this.entries[entryUid]);
60
61
  }
61
62
  this.lookForReference([{ locale: code, uid, name: title }], ctSchema, this.entries[entryUid]);
62
- this.log((0, messages_1.$t)(messages_1.auditMsg.SCAN_ENTRY_SUCCESS_MSG, {
63
+ const message = (0, messages_1.$t)(messages_1.auditMsg.SCAN_ENTRY_SUCCESS_MSG, {
63
64
  title,
64
65
  local: code,
65
66
  module: this.config.moduleConfig.entries.name,
66
- }), 'info');
67
+ });
68
+ this.log(message, 'hidden');
69
+ (0, util_1.print)([{ message: `info: ${message}`, color: 'green' }]);
67
70
  }
68
71
  if (this.fix) {
69
72
  await this.writeFixContent(`${basePath}/${indexer[fileIndex]}`, this.entries);
@@ -71,7 +74,7 @@ class Entries {
71
74
  }
72
75
  }
73
76
  }
74
- this.log('', 'info'); // Adding empty line
77
+ // this.log('', 'info'); // Adding empty line
75
78
  this.removeEmptyVal();
76
79
  return this.missingRefs;
77
80
  }
@@ -1,7 +1,7 @@
1
1
  import { Color } from "chalk";
2
2
  import { PrintOptions } from "@contentstack/cli-utilities";
3
3
  import config from "../config";
4
- type LogFn = (message: string | any, logType?: LoggerType | PrintOptions | undefined) => void;
4
+ type LogFn = (message: string | any, logType?: LoggerType | PrintOptions | undefined, skipCredentialCheck?: boolean) => void;
5
5
  type ExitFn = (code?: number | undefined) => void;
6
6
  type Partial<T> = {
7
7
  [P in keyof T]?: T[P];
@@ -10,7 +10,7 @@ type ConfigType = {
10
10
  config?: string;
11
11
  } & typeof config & Record<string, any>;
12
12
  export { LogFn, ExitFn, Partial, ConfigType };
13
- export type LoggerType = "info" | "warn" | "error" | "debug";
13
+ export type LoggerType = "info" | "warn" | "error" | "debug" | 'hidden';
14
14
  export type PrintType = {
15
15
  message: string;
16
16
  bold?: boolean;
package/lib/util/log.d.ts CHANGED
@@ -5,6 +5,7 @@ export default class Logger {
5
5
  private infoLogger;
6
6
  private errorLogger;
7
7
  private config;
8
+ private hiddenInfoLogger;
8
9
  get loggerOptions(): winston.transports.FileTransportOptions;
9
10
  constructor(config: Record<string, any>);
10
11
  /**
@@ -24,7 +25,7 @@ export default class Logger {
24
25
  * @param {LoggerType | PrintOptions | undefined} [logType] - The `logType` parameter is an optional
25
26
  * parameter that specifies the type of log. It can be one of the following values:
26
27
  */
27
- log(message: string | any, logType?: LoggerType | PrintOptions | undefined): void;
28
+ log(message: string | any, logType?: LoggerType | PrintOptions | undefined, skipCredentialCheck?: boolean): void;
28
29
  /**
29
30
  * The function `returnString` takes a message as input and returns a modified version of the message
30
31
  * with sensitive credentials replaced and any ANSI escape codes removed.
package/lib/util/log.js CHANGED
@@ -35,6 +35,7 @@ class Logger {
35
35
  this.config = config;
36
36
  this.infoLogger = this.getLoggerInstance('info');
37
37
  this.errorLogger = this.getLoggerInstance('error');
38
+ this.hiddenInfoLogger = this.getLoggerInstance('hidden');
38
39
  }
39
40
  /**
40
41
  * The function getLoggerInstance creates and returns a winston logger instance based on the provided
@@ -48,15 +49,20 @@ class Logger {
48
49
  const consoleOptions = {
49
50
  format: winston_1.default.format.combine(winston_1.default.format.simple(), winston_1.default.format.colorize({ all: true })),
50
51
  };
52
+ const isHidden = logType === 'hidden';
53
+ logType = logType === 'hidden' ? 'info' : logType;
51
54
  if (logType === 'error') {
52
55
  consoleOptions.level = logType;
53
56
  }
54
57
  const filename = (0, path_1.normalize)((0, path_1.resolve)(this.config.basePath, 'logs', `${logType}.log`)).replace(/^(\.\.(\/|\\|$))+/, '');
58
+ const transports = [
59
+ new winston_1.default.transports.File(Object.assign(Object.assign({}, this.loggerOptions), { level: logType, filename })),
60
+ ];
61
+ if (!isHidden) {
62
+ transports.push(new winston_1.default.transports.Console(consoleOptions));
63
+ }
55
64
  const loggerOptions = {
56
- transports: [
57
- new winston_1.default.transports.File(Object.assign(Object.assign({}, this.loggerOptions), { level: logType, filename })),
58
- new winston_1.default.transports.Console(consoleOptions),
59
- ],
65
+ transports,
60
66
  levels: customLevels.levels,
61
67
  };
62
68
  if (logType === 'error') {
@@ -72,8 +78,8 @@ class Logger {
72
78
  * @param {LoggerType | PrintOptions | undefined} [logType] - The `logType` parameter is an optional
73
79
  * parameter that specifies the type of log. It can be one of the following values:
74
80
  */
75
- log(message, logType) {
76
- const logString = this.returnString(message);
81
+ log(message, logType, skipCredentialCheck = false) {
82
+ const logString = skipCredentialCheck ? message : this.returnString(message);
77
83
  switch (logType) {
78
84
  case 'info':
79
85
  case 'debug':
@@ -83,6 +89,9 @@ class Logger {
83
89
  case 'error':
84
90
  this.errorLogger.error(logString);
85
91
  break;
92
+ case 'hidden':
93
+ this.hiddenInfoLogger.log('info', logString);
94
+ break;
86
95
  default:
87
96
  cli_utilities_1.cliux.print(logString, logType || {});
88
97
  break;
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.4.0",
2
+ "version": "1.4.1",
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.4.0",
3
+ "version": "1.4.1",
4
4
  "description": "Contentstack audit plugin",
5
5
  "author": "Contentstack CLI",
6
6
  "homepage": "https://github.com/contentstack/cli",