cs-icon.svg

Audit Plugin

Contentstack lets you perform audit operations to find out the missing references in the exported stacks data using the Audit plugin in Contentstack CLI.

The Audit plugin provides users with detailed reports about problems related to references in content types, global fields, and entries of a given stack data. Additionally, it includes commands that validate these references as well as try to resolve any potential issues in locally exported stack data.

This step-by-step guide lets you install and use the Audit plugin in CLI.

Prerequisites

Commands

The Audit plugin lets you perform the following operation in Contentstack CLI:

Issue Identification in References

The cm:stacks:audit command allows you to validate references and identify the issues.

  1. Open the terminal.
  2. Fire the following command:
  3. csdx cm:stacks:audit
    
  4. Enter the local path where the data is stored.
  5. CLI_Audit_Plugin_Path.png

    Note: If you exported data from a branch-enabled stack, make sure to provide the complete local path up to the branch. For example, C:\Users\...\CLI\Content\branch_folder.

You have successfully performed an audit operation to find the missing references in your stack.

Alternatively, you can pass the path in the command as given below:

csdx cm:stacks:audit --data-dir <path>
Usage
csdx cm:stacks:audit

Options

  • -c, --config=config: [optional] Path of the external config.
  • -d, --data-dir=data-dir: [optional] Path where the data is stored.
  • --columns=columns: Show only the specified columns (comma-separated).
  • --csv: The output is in the CSV format [alias: --output=csv].
  • --filter=filter: Filter property by partial string matching. For example: name=foo.
  • --modules=modules: Provide the list of modules to be audited. [options: content-types|global-fields|entries]
  • --no-truncate: The output is not truncated to fit the screen.
  • --report-path=report-path: Path to store the audit reports.
  • --sort=sort: Property to sort by (prepend '-' for descending).

Examples

  • To perform the audit operation by providing the path to store the audit reports:
  • csdx cm:stacks:audit --report-path <path>
    
  • To perform the audit operation by fetching the results in CSV format and providing the path to store the audit reports:
  • csdx cm:stacks:audit --report-path <path> --csv
    
  • To perform the audit operation with a name filter and by providing the path to store the audit reports:
  • csdx cm:stacks:audit --report-path <path> --filter="name=<filter-value>"
    
  • To perform the audit operation by providing the module for which the audit must be performed, along with the path to store the audit reports:
  • csdx cm:stacks:audit --report-path <path> --modules=content-types
    

Issue Resolution in References

The cm:stacks:audit:fix command allows you to validate references and actively resolve the identified issues.

  1. Open the terminal.
  2. Fire the following command:
  3. csdx cm:stacks:audit:fix
    
  4. Enter the local path where the data is stored.
  5. CLI_Audit_Plugin_Path.png

  6. In the prompt that appears, enter the following:
    • Yes, to overwrite the existing file.
    • No, to skip overwriting the existing file.

    Note: The prompt appears only if you have not passed the --copy-dir flag.

You have successfully performed an audit operation to fix the missing references in your stack.

Alternatively, you can pass the path in the command as given below:

csdx cm:stacks:audit:fix --data-dir <path>
Usage
csdx cm:stacks:audit:fix

or

csdx audit:fix

Options

  • -c, --config=config: [optional] Path of the external config.
  • -d, --data-dir=data-dir: [optional] Path where the data is stored.
  • --copy-path=copy-path: Provide the path to store the copied data.
  • --columns=columns: Show only the specified columns (comma-separated).
  • --copy-dir: [recommended] Create backup from the original data.
  • --csv: The output is in the CSV format [alias: --output=csv].
  • --filter=filter: Filter property by partial string matching. For example: name=foo.
  • --modules=modules: Provide the list of modules to be audited. [options: content-types|global-fields|entries]
  • --no-truncate: The output is not truncated to fit the screen.
  • --report-path=report-path: Path to store the audit reports.
  • --sort=sort: Property to sort by (prepend '-' for descending).
  • --fix-only: Provide the list of fix options. [options: reference|global_field|json:rte|json:custom-field|blocks|group]

Note: When you use the --copy-dir flag, a copy of the original data gets created and the audit fix operation occurs on the copied data.

Examples

  • To perform the audit fix operation on a copied version of the original data:
  • csdx cm:stacks:audit:fix --copy-dir
    
  • To perform the audit operation on a copied version of the original data by providing the path to store the audit reports:
  • csdx cm:stacks:audit:fix --report-path <path> --copy-dir
    
  • To perform the audit fix operation with a name filter and by providing the path to store the audit reports:
  • csdx cm:stacks:audit:fix --report-path <path> --filter="name=<filter-value>"
    
  • To perform the audit operation on a copied version of the original data by providing the backup directory path to store the copied data, along with the path to store the audit reports:
  • csdx cm:stacks:audit:fix --report-path <path> --copy-dir --copy-path <path>
    

Limitation

  • Currently, the Audit plugin can perform audit operation to find only the missing reference issues on content types, global fields, and entries of a given stack data.
Was this article helpful?
^