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 any issues related to references in content types, global fields, entries, content types used in workflows, and extensions of a given stack data. Additionally, it includes commands that validate these references and content types as well as try to resolve any potential issues.

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:

Supported Modules

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:
    csdx cm:stacks:audit
    
  3. Enter the local path where the data is stored.

    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|extensions|workflows]
  • --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).

Note: If the workflow module has branches enabled and you want audit to operate on all the branches except a particular branch, then you can provide that specific branch name using the --config flag as given below:
{
"branch": "<branch-name>"
}
Passing this flag makes the auditing process check and report on all branches except the one specified in the config file.

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:
    csdx cm:stacks:audit:fix
    
  3. Enter the local path where the data is stored.

    CLI_Audit_Plugin_Path.png

  4. 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 backup 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|extensions|workflows]
  • --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:
  • If the workflow module has branches enabled and you want audit to operate on all the branches except a particular branch, then you can provide that specific branch name using the --config flag as given below:
    {
    "branch": "<branch-name>"
    }
    Passing this flag makes the auditing process check and remove all branches except the one specified in the config file.
  • 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

Was this article helpful?
^