Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sprint 53 Release #1336

Merged
merged 76 commits into from
Mar 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
76 commits
Select commit Hold shift + click to select a range
269c45e
added audit for workflow
cs-raj Feb 22, 2024
6868e44
Merge branch 'development' into feat/CS-43976
cs-raj Feb 22, 2024
22ee92b
refactor: package-lock update script and cache clear scripts added
antonyagustine Feb 23, 2024
41c3f3c
Merge branch 'development' into refactor/CS-44108
antonyagustine Feb 23, 2024
ea56baf
Merge branch 'development' into feat/CS-43976
cs-raj Feb 23, 2024
4ea5f5d
audit fix in workflows
cs-raj Feb 23, 2024
65322fb
Returning empty object when file path is not valid
cs-raj Feb 23, 2024
9498841
version bump
cs-raj Feb 23, 2024
392b6c3
Merge branch 'development' into refactor/CS-44108
antonyagustine Feb 27, 2024
133d848
pnpm access issue fix
antonyagustine Feb 27, 2024
69c4586
Update jira.yml
aravindbuilt Feb 27, 2024
eece807
Merge pull request #1309 from contentstack/refactor/CS-44108
antonyagustine Feb 27, 2024
25990f0
unit test case for audit workflow
cs-raj Feb 27, 2024
512f5f3
fixed test cases
cs-raj Feb 27, 2024
38d6f17
Merge branch 'development' into feat/CS-43976
cs-raj Feb 27, 2024
88fd509
when adding the path using the inquirer for both import and export re…
cs-raj Feb 27, 2024
719c3f4
mockdataForWorkflows
cs-raj Feb 27, 2024
412bd64
fixed data and test case
cs-raj Feb 27, 2024
80f5e86
removing single and double quotes, and also checking for special char…
cs-raj Feb 28, 2024
750d2a9
removed i and used proper variable name
cs-raj Feb 28, 2024
0389df2
version bump for dependency
cs-raj Feb 28, 2024
7a8d0ae
version bump
cs-raj Feb 28, 2024
ad21c9f
Merge pull request #1318 from contentstack/fix/CS-44190
cs-raj Feb 28, 2024
ca7c050
initial commit, added extensions to audit command
cs-raj Feb 28, 2024
b510c0a
audit fix for extensions
cs-raj Feb 28, 2024
588d073
Merge branch 'development' into bugfix/CS-44158
cs-raj Feb 28, 2024
de91d36
merged development to resolve sca scan failing
cs-raj Feb 28, 2024
fcf88fd
removed stray console logs
cs-raj Feb 28, 2024
df8504b
fix: path validator issue in all plugins
aman19K Feb 29, 2024
f522cda
fixed merge prompt with zero changes
shafeeqd959 Feb 29, 2024
30508e1
added lock file
shafeeqd959 Feb 29, 2024
d46df6b
added test case and code optimization
cs-raj Feb 29, 2024
5026eb2
Merge branch 'development' into feat/CS-43978
cs-raj Feb 29, 2024
8e97ea0
Fix: Audit group field removal issue fix
antonyagustine Mar 1, 2024
7f718a6
test cases fixed and csv
cs-raj Mar 1, 2024
2fa1bc9
added test case and moved validate path to utiltites and version bump
cs-raj Mar 1, 2024
bda90c3
Version bump
antonyagustine Mar 1, 2024
a3bdd7e
Merge pull request #1323 from contentstack/fix/CS-44077
antonyagustine Mar 1, 2024
e97798b
code optimisation, fixed test cases, and wrote generic function for s…
cs-raj Mar 2, 2024
ffe1f89
Merge branch 'development' into feat/CS-43976
cs-raj Mar 2, 2024
d5db4c9
test case fixed, code optimisation
cs-raj Mar 2, 2024
e025d79
Audit fix log sequence issue fix
antonyagustine Mar 4, 2024
5f8e913
Merge pull request #1324 from contentstack/fix/audit-log-fix
antonyagustine Mar 4, 2024
b0cd610
Merge branch 'staging' into stage-to-development
aman19K Mar 4, 2024
63ec8fa
Merge pull request #1327 from contentstack/stage-to-development
aman19K Mar 4, 2024
333bf94
merged changes
shafeeqd959 Mar 4, 2024
3c9e178
Merge branch 'development' into fix/CS-42524
aman19K Mar 4, 2024
3901cea
Merge pull request #1321 from contentstack/fix/CS-43935
shafeeqd959 Mar 4, 2024
f870a50
version bump
aman19K Mar 4, 2024
27f06e3
Merge branch 'development' into fix/CS-42524
aman19K Mar 4, 2024
96cff53
Merge pull request #1320 from contentstack/fix/CS-42524
aman19K Mar 4, 2024
4213a69
fix: semgrep reported issues
aman19K Mar 5, 2024
d459016
fix: indentation issue
aman19K Mar 5, 2024
bfefdf5
Merge branch 'development' into bugfix/CS-44158
cs-raj Mar 5, 2024
cb51803
Merge pull request #1328 from contentstack/fix/CS-43472
aman19K Mar 5, 2024
9e3f198
Merge branch 'development' into bugfix/CS-44158
cs-raj Mar 5, 2024
c444b8b
fixed message parse in config
shafeeqd959 Mar 5, 2024
ecb7d0c
Merge pull request #1329 from contentstack/fix/CS-43156
shafeeqd959 Mar 5, 2024
a9c69e7
Merge branch 'development' into bugfix/CS-44158
cs-raj Mar 5, 2024
26af493
Merge pull request #1315 from contentstack/bugfix/CS-44158
cs-raj Mar 5, 2024
69b4854
Merge branch 'staging' into stage-to-development
antonyagustine Mar 6, 2024
38e95d9
Lock files updated
antonyagustine Mar 6, 2024
db734b8
Merge pull request #1333 from contentstack/stage-to-development
antonyagustine Mar 6, 2024
c918b37
added optional chaining
cs-raj Mar 8, 2024
ba5726b
Merge branch 'development' into bugfix/CS-44326
cs-raj Mar 8, 2024
94d3d5f
Ui text update
cs-raj Mar 8, 2024
a023eba
Merge pull request #1334 from contentstack/bugfix/CS-44326
cs-raj Mar 8, 2024
e99a99a
Merge branch 'development' into feat/CS-43976
cs-raj Mar 8, 2024
e702414
Merge branch 'development' into feat/CS-43978
cs-raj Mar 8, 2024
a674682
ui text update
cs-raj Mar 8, 2024
4ede5b2
fixed audit during import
cs-raj Mar 8, 2024
2e9bed0
bugfix
cs-raj Mar 8, 2024
81be69b
Merge pull request #1322 from contentstack/feat/CS-43978
cs-raj Mar 8, 2024
50c1d19
Merge branch 'development' into feat/CS-43976
cs-raj Mar 8, 2024
233985d
version bump
cs-raj Mar 8, 2024
a4359a1
Merge pull request #1306 from contentstack/feat/CS-43976
cs-raj Mar 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23,666 changes: 12,518 additions & 11,148 deletions package-lock.json

Large diffs are not rendered by default.

9 changes: 6 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"name": "csdx",
"version": "1.0.0",
"devDependencies": {
"pnpm": "^7.23.0"
"pnpm": "^7.33.7"
},
"engines": {
"node": ">=14.0.0"
"node": ">=18.0.0"
},
"private": true,
"scripts": {
Expand All @@ -14,7 +14,10 @@
"bootstrap": "pnpm install --no-frozen-lockfile",
"prepack": "pnpm --filter \"./packages/*\" -w prepack",
"package-lock-only": "npm i --package-lock-only --workspaces",
"setup-repo": "npm i && pnpm package-lock-only && pnpm clean && pnpm install --no-frozen-lockfile && pnpm prepack"
"setup-repo-old": "npm i && pnpm package-lock-only && pnpm clean && pnpm install --no-frozen-lockfile && pnpm prepack",
"clean-repo": "rm -rf ./package-lock.json ./node_modules ./packages/**/node_modules ./packages/**/.nyc_output ./packages/**/package-lock.json",
"preinstall-clean": "npm run clean-repo && npm cache clean --force && npx pnpm store prune",
"setup-repo": "npm run preinstall-clean && npm i && npm run package-lock-only && npm run clean && pnpm install --no-frozen-lockfile && npm run prepack"
},
"license": "MIT",
"workspaces": [
Expand Down
22 changes: 13 additions & 9 deletions packages/contentstack-audit/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ $ npm install -g @contentstack/cli-audit
$ csdx COMMAND
running command...
$ csdx (--version|-v)
@contentstack/cli-audit/1.4.0 darwin-arm64 node-v20.8.0
@contentstack/cli-audit/1.4.1 darwin-arm64 node-v20.8.0
$ csdx --help [COMMAND]
USAGE
$ csdx COMMAND
Expand Down Expand Up @@ -285,7 +285,7 @@ EXAMPLES
$ csdx plugins
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.1.17/src/commands/plugins/index.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.2.6/src/commands/plugins/index.ts)_

## `csdx plugins:install PLUGIN...`

Expand Down Expand Up @@ -354,7 +354,7 @@ EXAMPLES
$ csdx plugins:inspect myplugin
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.1.17/src/commands/plugins/inspect.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.2.6/src/commands/plugins/inspect.ts)_

## `csdx plugins:install PLUGIN...`

Expand Down Expand Up @@ -398,7 +398,7 @@ EXAMPLES
$ csdx plugins:install someuser/someplugin
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.1.17/src/commands/plugins/install.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.2.6/src/commands/plugins/install.ts)_

## `csdx plugins:link PLUGIN`

Expand Down Expand Up @@ -428,7 +428,7 @@ EXAMPLES
$ csdx plugins:link myplugin
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.1.17/src/commands/plugins/link.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.2.6/src/commands/plugins/link.ts)_

## `csdx plugins:uninstall PLUGIN...`

Expand Down Expand Up @@ -462,10 +462,14 @@ Remove all user-installed and linked plugins.

```
USAGE
$ csdx plugins:reset
$ csdx plugins:reset [--hard] [--reinstall]

FLAGS
--hard Delete node_modules and package manager related files in addition to uninstalling plugins.
--reinstall Reinstall all plugins after uninstalling.
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.1.17/src/commands/plugins/reset.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.2.6/src/commands/plugins/reset.ts)_

## `csdx plugins:uninstall PLUGIN...`

Expand Down Expand Up @@ -493,7 +497,7 @@ EXAMPLES
$ csdx plugins:uninstall myplugin
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.1.17/src/commands/plugins/uninstall.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.2.6/src/commands/plugins/uninstall.ts)_

## `csdx plugins:uninstall PLUGIN...`

Expand Down Expand Up @@ -537,5 +541,5 @@ DESCRIPTION
Update installed plugins.
```

_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.1.17/src/commands/plugins/update.ts)_
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v4.2.6/src/commands/plugins/update.ts)_
<!-- commandsstop -->
4 changes: 2 additions & 2 deletions packages/contentstack-audit/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@contentstack/cli-audit",
"version": "1.4.1",
"version": "1.5.0",
"description": "Contentstack audit plugin",
"author": "Contentstack CLI",
"homepage": "https://github.com/contentstack/cli",
Expand All @@ -19,7 +19,7 @@
],
"dependencies": {
"@contentstack/cli-command": "~1.2.16",
"@contentstack/cli-utilities": "~1.5.12",
"@contentstack/cli-utilities": "~1.6.0",
"@oclif/plugin-help": "^5",
"@oclif/plugin-plugins": "^4.1.9",
"chalk": "^4.1.2",
Expand Down
97 changes: 84 additions & 13 deletions packages/contentstack-audit/src/audit-base-command.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import config from './config';
import { print } from './util/log';
import { auditMsg } from './messages';
import { BaseCommand } from './base-command';
import { Entries, GlobalField, ContentType } from './modules';
import { Entries, GlobalField, ContentType, Extensions, Workflows } from './modules';
import { CommandNames, ContentTypeStruct, OutputColumn, RefErrorReturnType } from './types';

export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseCommand> {
Expand All @@ -31,7 +31,7 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
}

/**
* The `start` function performs an audit on content types, global fields, and entries, and displays
* The `start` function performs an audit on content types, global fields, entries, and workflows and displays
* any missing references.
* @param {string} command - The `command` parameter is a string that represents the current command
* being executed.
Expand All @@ -42,15 +42,23 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
await this.createBackUp();
this.sharedConfig.reportPath = resolve(this.flags['report-path'] || process.cwd(), 'audit-report');

const { missingCtRefs, missingGfRefs, missingEntryRefs } = await this.scanAndFix();
const { missingCtRefs, missingGfRefs, missingEntryRefs, missingCtRefsInExtensions, missingCtRefsInWorkflow } =
await this.scanAndFix();

this.showOutputOnScreen([
{ module: 'Content types', missingRefs: missingCtRefs },
{ module: 'Global Fields', missingRefs: missingGfRefs },
{ module: 'Entries', missingRefs: missingEntryRefs },
]);

if (!isEmpty(missingCtRefs) || !isEmpty(missingGfRefs) || !isEmpty(missingEntryRefs)) {
this.showOutputOnScreenWorkflowsAndExtension([{ module: 'Extensions', missingRefs: missingCtRefsInExtensions }]);
this.showOutputOnScreenWorkflowsAndExtension([{ module: 'Workflows', missingRefs: missingCtRefsInWorkflow }]);
if (
!isEmpty(missingCtRefs) ||
!isEmpty(missingGfRefs) ||
!isEmpty(missingEntryRefs) ||
!isEmpty(missingCtRefsInWorkflow) ||
!isEmpty(missingCtRefsInExtensions)
) {
if (this.currentCommand === 'cm:stacks:audit') {
this.log(this.$t(auditMsg.FINAL_REPORT_PATH, { path: this.sharedConfig.reportPath }), 'warn');
} else {
Expand All @@ -70,7 +78,13 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
}
}

return !isEmpty(missingCtRefs) || !isEmpty(missingGfRefs) || !isEmpty(missingEntryRefs);
return (
!isEmpty(missingCtRefs) ||
!isEmpty(missingGfRefs) ||
!isEmpty(missingEntryRefs) ||
!isEmpty(missingCtRefsInWorkflow) ||
!isEmpty(missingCtRefsInExtensions)
);
}

/**
Expand All @@ -81,7 +95,7 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
*/
async scanAndFix() {
let { ctSchema, gfSchema } = this.getCtAndGfSchema();
let missingCtRefs, missingGfRefs, missingEntryRefs;
let missingCtRefs, missingGfRefs, missingEntryRefs, missingCtRefsInExtensions, missingCtRefsInWorkflow;
for (const module of this.sharedConfig.flags.modules || this.sharedConfig.modules) {
print([
{
Expand Down Expand Up @@ -113,6 +127,20 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
missingEntryRefs = await new Entries(cloneDeep(constructorParam)).run();
await this.prepareReport(module, missingEntryRefs);
break;
case 'workflows':
missingCtRefsInWorkflow = await new Workflows({
ctSchema,
log: this.log,
moduleName: module,
config: this.sharedConfig,
fix: this.currentCommand === 'cm:stacks:audit:fix',
}).run();
await this.prepareReport(module, missingCtRefsInWorkflow);
break;
case 'extensions':
missingCtRefsInExtensions = await new Extensions(cloneDeep(constructorParam)).run();
await this.prepareReport(module, missingCtRefsInExtensions);
break;
}

print([
Expand All @@ -129,7 +157,7 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
]);
}

return { missingCtRefs, missingGfRefs, missingEntryRefs };
return { missingCtRefs, missingGfRefs, missingEntryRefs, missingCtRefsInExtensions, missingCtRefsInWorkflow };
}

/**
Expand Down Expand Up @@ -217,7 +245,6 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
},
]);
const tableValues = Object.values(missingRefs).flat();

ux.table(
tableValues,
{
Expand Down Expand Up @@ -258,6 +285,50 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
}
}

// Make it generic it takes the column header as param
showOutputOnScreenWorkflowsAndExtension(allMissingRefs: { module: string; missingRefs?: Record<string, any> }[]) {
if (!this.sharedConfig.showTerminalOutput || this.flags['external-config']?.noTerminalOutput) {
return;
}
this.log(''); // Adding a new line

for (const { module, missingRefs } of allMissingRefs) {
if (isEmpty(missingRefs)) {
continue;
}

print([{ bold: true, color: 'cyan', message: ` ${module}` }]);

const tableValues = Object.values(missingRefs).flat();

const tableKeys = Object.keys(missingRefs[0]);
const arrayOfObjects = tableKeys.map((key) => {
if (['title', 'name', 'uid', 'content_types', 'fixStatus'].includes(key)) {
return {
[key]: {
minWidth: 7,
header: key,
get: (row: Record<string, unknown>) => {
if (key === 'fixStatus') {
return chalk.green(typeof row[key] === 'object' ? JSON.stringify(row[key]) : row[key]);
} else if (key === 'content_types') {
return chalk.red(typeof row[key] === 'object' ? JSON.stringify(row[key]) : row[key]);
} else {
return chalk.white(typeof row[key] === 'object' ? JSON.stringify(row[key]) : row[key]);
}
},
},
};
}
return {};
});
const mergedObject = Object.assign({}, ...arrayOfObjects);

ux.table(tableValues, mergedObject, { ...this.flags });
this.log(''); // Adding a new line
}
}

/**
* The function prepares a report by writing a JSON file and a CSV file with a list of missing
* references for a given module.
Expand Down Expand Up @@ -311,13 +382,14 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
}

const rowData: Record<string, string | string[]>[] = [];

for (const issue of missingRefs) {
let row: Record<string, string | string[]> = {};

for (const column of columns) {
row[column] = issue[OutputColumn[column]];
row[column] = typeof row[column] === 'object' ? JSON.stringify(row[column]) : row[column];
if (Object.keys(issue).includes(OutputColumn[column])) {
row[column] = issue[OutputColumn[column]] as string;
row[column] = typeof row[column] === 'object' ? JSON.stringify(row[column]) : row[column];
}
}

if (this.currentCommand === 'cm:stacks:audit:fix') {
Expand All @@ -326,7 +398,6 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma

rowData.push(row);
}

csv.write(rowData, { headers: true }).pipe(ws).on('error', reject).on('finish', resolve);
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export default class Audit extends AuditBaseCommand {

/**
* The `run` function is an asynchronous function that performs an audit on different modules
* (content-types, global-fields, entries) and generates a report.
* (content-types, global-fields, entries, workflows) and generates a report.
*/
async run(): Promise<void> {
try {
Expand Down
14 changes: 12 additions & 2 deletions packages/contentstack-audit/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ const config = {
showTerminalOutput: true,
skipRefs: ['sys_assets'],
skipFieldTypes: ['taxonomy', 'group'],
modules: ['content-types', 'global-fields', 'entries'],
'fix-fields': ['reference', 'global_field', 'json:rte', 'json:extension', 'blocks', 'group'],
modules: ['content-types', 'global-fields', 'entries', 'extensions', 'workflows'],
'fix-fields': ['reference', 'global_field', 'json:rte', 'json:extension', 'blocks', 'group', 'content_types'],
moduleConfig: {
'content-types': {
name: 'content type',
Expand All @@ -25,6 +25,16 @@ const config = {
dirName: 'locales',
fileName: 'locales.json',
},
workflows: {
name: 'workflows',
dirName: 'workflows',
fileName: 'workflows.json',
},
extensions: {
name: 'extensions',
dirName: 'extensions',
fileName: 'extensions.json',
},
},
entries: {
systemKeys: [
Expand Down
12 changes: 10 additions & 2 deletions packages/contentstack-audit/src/messages/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import memoize from 'lodash/memoize';
import { escapeRegExp } from '@contentstack/cli-utilities';

const errors = {};

Expand All @@ -14,6 +15,10 @@ const commonMsg = {
CONFIG: 'Path of the external config',
DATA_DIR: 'Path where the data is stored',
FIX_CONFIRMATION: 'Would you like to overwrite existing file.?',
WORKFLOW_FIX_WARN: `The workflow associated with UID {uid} and name {name} will be removed.`,
WORKFLOW_FIX_CONFIRMATION: 'Would you like to overwrite existing file?',
EXTENSION_FIX_WARN: `The extension associated with UID {uid} and title '{title}' will be removed.`,
EXTENSION_FIX_CONFIRMATION: `Would you like to overwrite existing file?`,
};

const auditMsg = {
Expand All @@ -27,7 +32,9 @@ const auditMsg = {
FINAL_REPORT_PATH: "Reports ready. Please find the reports at '{path}'.",
SCAN_CT_SUCCESS_MSG: "Successfully completed the scanning of {module} '{title}'.",
SCAN_ENTRY_SUCCESS_MSG: "Successfully completed the scanning of {module} ({local}) '{title}'.",
SCAN_EXT_SUCCESS_MSG: "Successfully completed scanning the {module} titled '{title}' with UID '{uid}'",
AUDIT_CMD_DESCRIPTION: 'Perform audits and find possible errors in the exported Contentstack data',
SCAN_WF_SUCCESS_MSG: 'Successfully removed the workflow with UID {uid} and name {name}.',
};

const auditFixMsg = {
Expand All @@ -37,6 +44,7 @@ const auditFixMsg = {
FIXED_CONTENT_PATH_MAG: 'You can locate the fixed content at {path}.',
EMPTY_FIX_MSG: 'Successfully removed the empty field/block found at {path} from the schema.',
AUDIT_FIX_CMD_DESCRIPTION: 'Perform audits and fix possible errors in the exported Contentstack data.',
WF_FIX_MSG: 'Successfully removed the workflow {uid} named {name}.',
};

const messages: typeof errors &
Expand Down Expand Up @@ -65,8 +73,8 @@ function $t(msg: string, args: Record<string, string>): string {
if (!msg) return '';

for (const key of Object.keys(args)) {
const escapedKey = key.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
msg = msg.replace(new RegExp(`{${escapedKey}}`, 'g'), args[key] || escapedKey);
const escapedKey = escapeRegExp(key);
msg = msg.replace(new RegExp(`{${escapedKey}}`, 'g'), escapeRegExp(args[key]) || escapedKey);
}

return msg;
Expand Down
2 changes: 1 addition & 1 deletion packages/contentstack-audit/src/modules/content-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ export default class ContentType {
treeStr: tree.map(({ name }) => name).join(' ➜ '),
});

return null
return null;
}

return field;
Expand Down
Loading
Loading