Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
098c427
fix: Added version to the asset and entries that will be published us…
cs-raj Feb 15, 2025
87bffbe
Feat: Added Check for publish detials for Assets and Entries
cs-raj Feb 26, 2025
76b3e6a
PR fixes
cs-raj Feb 26, 2025
1fb8af2
Merge branch 'development' into feat/DX-2243
cs-raj Feb 26, 2025
e0293d3
Fix update
cs-raj Feb 26, 2025
e021fe2
Fixed PR comments
cs-raj Feb 26, 2025
181902f
Added GCP-EU support in CLI commands
ntrjpatel Feb 28, 2025
fa7a5de
Merge pull request #1790 from contentstack/feat/dx-2247
netrajpatel Feb 28, 2025
2c4ca99
feat: added skip-assets-publish & skip-entries-publish support in import
aman19K Mar 4, 2025
ec94730
Merge pull request #1795 from contentstack/main
harshithad0703 Mar 4, 2025
4a4777b
Merge branch 'development' into fix/back-merge-04-03
harshithad0703 Mar 4, 2025
d5345d5
Merge pull request #1797 from contentstack/fix/back-merge-04-03
harshithad0703 Mar 4, 2025
2c04961
Merge pull request #1792 from contentstack/feat/DX-2171
aman19K Mar 5, 2025
e9410c8
Merge branch 'main' into staging
cs-raj Mar 5, 2025
304e10e
Merge pull request #1800 from contentstack/fix/staging3
cs-raj Mar 5, 2025
0c81247
Merge branch 'staging' into development
cs-raj Mar 5, 2025
82d1299
Merge pull request #1801 from contentstack/fix/dev3
cs-raj Mar 5, 2025
37e1188
Merge branch 'development' into feat/DX-2243
cs-raj Mar 5, 2025
f720b43
lock-file update
cs-raj Mar 5, 2025
3aa8325
Merge pull request #1778 from contentstack/feat/DX-2243
cs-raj Mar 5, 2025
72654b6
Merge pull request #1802 from contentstack/development
cs-raj Mar 5, 2025
b6ea187
Merge branch 'development' into fix/DX-592
cs-raj Mar 5, 2025
722cb9a
lock-file update
cs-raj Mar 5, 2025
5d474dc
Merge pull request #1768 from contentstack/fix/DX-592
cs-raj Mar 5, 2025
c5c21da
Merge branch 'staging' into development
cs-raj Mar 5, 2025
d92b3de
Merge pull request #1805 from contentstack/fix/dev3
cs-raj Mar 5, 2025
fe3f3f6
Merge pull request #1804 from contentstack/development
cs-raj Mar 5, 2025
023c4e7
Utilities Version bump
cs-raj Mar 10, 2025
db71dc3
Merge pull request #1807 from contentstack/fix/DX-2302
cs-raj Mar 10, 2025
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
351 changes: 176 additions & 175 deletions package-lock.json

Large diffs are not rendered by default.

30 changes: 15 additions & 15 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.7.5 darwin-arm64 node-v22.14.0
@contentstack/cli-audit/1.8.0 darwin-arm64 node-v23.6.0
$ csdx --help [COMMAND]
USAGE
$ csdx COMMAND
Expand Down Expand Up @@ -53,12 +53,12 @@ Perform audits and find possible errors in the exported Contentstack data
```
USAGE
$ csdx audit [--report-path <value>] [--modules
content-types|global-fields|entries|extensions|workflows|custom-roles] [--columns <value> | ] [--sort <value>]
[--filter <value>] [--csv | --no-truncate]
content-types|global-fields|entries|extensions|workflows|custom-roles|assets] [--columns <value> | ] [--sort
<value>] [--filter <value>] [--csv | --no-truncate]

FLAGS
--modules=<option>... Provide the list of modules to be audited
<options: content-types|global-fields|entries|extensions|workflows|custom-roles>
<options: content-types|global-fields|entries|extensions|workflows|custom-roles|assets>
--report-path=<value> Path to store the audit reports

TABLE FLAGS
Expand Down Expand Up @@ -94,17 +94,17 @@ Perform audits and fix possible errors in the exported Contentstack data.
```
USAGE
$ csdx audit:fix [--report-path <value>] [--modules
content-types|global-fields|entries|extensions|workflows|custom-roles] [--copy-path <value> --copy-dir] [--fix-only
reference|global_field|json:rte|json:extension|blocks|group|content_types] [--columns <value> | ] [--sort <value>]
[--filter <value>] [--csv | --no-truncate]
content-types|global-fields|entries|extensions|workflows|custom-roles|assets] [--copy-path <value> --copy-dir]
[--fix-only reference|global_field|json:rte|json:extension|blocks|group|content_types] [--columns <value> | ]
[--sort <value>] [--filter <value>] [--csv | --no-truncate]

FLAGS
--copy-dir Create backup from the original data.
--copy-path=<value> Provide the path to backup the copied data
--fix-only=<option>... Provide the list of fix options
<options: reference|global_field|json:rte|json:extension|blocks|group|content_types>
--modules=<option>... Provide the list of modules to be audited
<options: content-types|global-fields|entries|extensions|workflows|custom-roles>
<options: content-types|global-fields|entries|extensions|workflows|custom-roles|assets>
--report-path=<value> Path to store the audit reports

TABLE FLAGS
Expand Down Expand Up @@ -142,12 +142,12 @@ Perform audits and find possible errors in the exported Contentstack data
```
USAGE
$ csdx cm:stacks:audit [--report-path <value>] [--modules
content-types|global-fields|entries|extensions|workflows|custom-roles] [--columns <value> | ] [--sort <value>]
[--filter <value>] [--csv | --no-truncate]
content-types|global-fields|entries|extensions|workflows|custom-roles|assets] [--columns <value> | ] [--sort
<value>] [--filter <value>] [--csv | --no-truncate]

FLAGS
--modules=<option>... Provide the list of modules to be audited
<options: content-types|global-fields|entries|extensions|workflows|custom-roles>
<options: content-types|global-fields|entries|extensions|workflows|custom-roles|assets>
--report-path=<value> Path to store the audit reports

TABLE FLAGS
Expand Down Expand Up @@ -185,17 +185,17 @@ Perform audits and fix possible errors in the exported Contentstack data.
```
USAGE
$ csdx cm:stacks:audit:fix [--report-path <value>] [--modules
content-types|global-fields|entries|extensions|workflows|custom-roles] [--copy-path <value> --copy-dir] [--fix-only
reference|global_field|json:rte|json:extension|blocks|group|content_types] [--columns <value> | ] [--sort <value>]
[--filter <value>] [--csv | --no-truncate]
content-types|global-fields|entries|extensions|workflows|custom-roles|assets] [--copy-path <value> --copy-dir]
[--fix-only reference|global_field|json:rte|json:extension|blocks|group|content_types] [--columns <value> | ]
[--sort <value>] [--filter <value>] [--csv | --no-truncate]

FLAGS
--copy-dir Create backup from the original data.
--copy-path=<value> Provide the path to backup the copied data
--fix-only=<option>... Provide the list of fix options
<options: reference|global_field|json:rte|json:extension|blocks|group|content_types>
--modules=<option>... Provide the list of modules to be audited
<options: content-types|global-fields|entries|extensions|workflows|custom-roles>
<options: content-types|global-fields|entries|extensions|workflows|custom-roles|assets>
--report-path=<value> Path to store the audit reports

TABLE FLAGS
Expand Down
16 changes: 8 additions & 8 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.7.5",
"version": "1.8.0",
"description": "Contentstack audit plugin",
"author": "Contentstack CLI",
"homepage": "https://github.com/contentstack/cli",
Expand All @@ -19,34 +19,34 @@
],
"dependencies": {
"@contentstack/cli-command": "~1.3.3",
"@contentstack/cli-utilities": "~1.8.3",
"@contentstack/cli-utilities": "~1.8.4",
"@oclif/plugin-help": "^5.2.20",
"@oclif/plugin-plugins": "^5.4.24",
"@oclif/plugin-plugins": "^5.4.34",
"chalk": "^4.1.2",
"fast-csv": "^4.3.6",
"fs-extra": "^11.2.0",
"fs-extra": "^11.3.0",
"lodash": "^4.17.21",
"uuid": "^9.0.1",
"winston": "^3.17.0"
},
"devDependencies": {
"@oclif/test": "^4.1.6",
"@oclif/test": "^4.1.11",
"@types/chai": "^4.3.20",
"@types/fs-extra": "^11.0.4",
"@types/mocha": "^10.0.10",
"@types/node": "^20.17.10",
"@types/node": "^20.17.19",
"@types/uuid": "^9.0.8",
"chai": "^4.5.0",
"eslint": "^8.57.1",
"eslint-config-oclif": "^4.0.0",
"eslint-config-oclif-typescript": "^3.1.13",
"eslint-config-oclif-typescript": "^3.1.14",
"mocha": "^10.8.2",
"nyc": "^15.1.0",
"oclif": "^3.17.2",
"shx": "^0.3.4",
"sinon": "^19.0.2",
"ts-node": "^10.9.2",
"typescript": "^5.7.2"
"typescript": "^5.7.3"
},
"oclif": {
"bin": "csdx",
Expand Down
29 changes: 24 additions & 5 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, Extensions, Workflows } from './modules';
import { Entries, GlobalField, ContentType, Extensions, Workflows, Assets } from './modules';
import {
CommandNames,
ContentTypeStruct,
Expand Down Expand Up @@ -58,7 +58,9 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
missingSelectFeild,
missingMandatoryFields,
missingTitleFields,
missingRefInCustomRoles
missingRefInCustomRoles,
missingEnvLocalesInAssets,
missingEnvLocalesInEntries
} = await this.scanAndFix();

this.showOutputOnScreen([
Expand All @@ -76,6 +78,8 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
{ module: 'Entries Title Field', missingRefs: missingTitleFields },
]);
this.showOutputOnScreenWorkflowsAndExtension([{ module: 'Custom Roles', missingRefs: missingRefInCustomRoles }]);
this.showOutputOnScreenWorkflowsAndExtension([{ module: 'Assets', missingRefs: missingEnvLocalesInAssets }]);
this.showOutputOnScreenWorkflowsAndExtension([{ module: 'Entries Missing Locale and Environments', missingRefs: missingEnvLocalesInEntries }])
if (
!isEmpty(missingCtRefs) ||
!isEmpty(missingGfRefs) ||
Expand All @@ -84,7 +88,9 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
!isEmpty(missingCtRefsInExtensions) ||
!isEmpty(missingSelectFeild) ||
!isEmpty(missingTitleFields) ||
!isEmpty(missingRefInCustomRoles)
!isEmpty(missingRefInCustomRoles) ||
!isEmpty(missingEnvLocalesInAssets) ||
!isEmpty(missingEnvLocalesInEntries)
) {
if (this.currentCommand === 'cm:stacks:audit') {
this.log(this.$t(auditMsg.FINAL_REPORT_PATH, { path: this.sharedConfig.reportPath }), 'warn');
Expand Down Expand Up @@ -112,7 +118,9 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
!isEmpty(missingCtRefsInWorkflow) ||
!isEmpty(missingCtRefsInExtensions) ||
!isEmpty(missingSelectFeild) ||
!isEmpty(missingRefInCustomRoles)
!isEmpty(missingRefInCustomRoles) ||
!isEmpty(missingEnvLocalesInAssets) ||
!isEmpty(missingEnvLocalesInEntries)
);
}

Expand All @@ -133,7 +141,9 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
missingEntry,
missingMandatoryFields,
missingTitleFields,
missingRefInCustomRoles;
missingRefInCustomRoles,
missingEnvLocalesInAssets,
missingEnvLocalesInEntries;

for (const module of this.sharedConfig.flags.modules || this.sharedConfig.modules) {
print([
Expand All @@ -153,6 +163,10 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
fix: this.currentCommand === 'cm:stacks:audit:fix',
};
switch (module) {
case 'assets':
missingEnvLocalesInAssets = await new Assets(cloneDeep(constructorParam)).run();
await this.prepareReport(module, missingEnvLocalesInAssets);
break;
case 'content-types':
missingCtRefs = await new ContentType(cloneDeep(constructorParam)).run();
await this.prepareReport(module, missingCtRefs);
Expand All @@ -167,6 +181,7 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
missingSelectFeild = missingEntry.missingSelectFeild ?? {};
missingMandatoryFields = missingEntry.missingMandatoryFields ?? {};
missingTitleFields = missingEntry.missingTitleFields ?? {};
missingEnvLocalesInEntries = missingEntry.missingEnvLocale??{};
await this.prepareReport(module, missingEntryRefs);

await this.prepareReport(`Entries_Select_feild`, missingSelectFeild);
Expand All @@ -175,6 +190,8 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma

await this.prepareReport('Entries_Title_feild', missingTitleFields);

await this.prepareReport('Entry_Missing_Locale_and_Env_in_Publish_Details', missingEnvLocalesInEntries);

break;
case 'workflows':
missingCtRefsInWorkflow = await new Workflows({
Expand Down Expand Up @@ -220,6 +237,8 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
missingMandatoryFields,
missingTitleFields,
missingRefInCustomRoles,
missingEnvLocalesInAssets,
missingEnvLocalesInEntries
};
}

Expand Down
24 changes: 22 additions & 2 deletions packages/contentstack-audit/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const config = {
showTerminalOutput: true,
skipRefs: ['sys_assets'],
skipFieldTypes: ['taxonomy', 'group'],
modules: ['content-types', 'global-fields', 'entries', 'extensions', 'workflows', 'custom-roles'],
modules: ['content-types', 'global-fields', 'entries', 'extensions', 'workflows', 'custom-roles', 'assets'],
'fix-fields': ['reference', 'global_field', 'json:rte', 'json:extension', 'blocks', 'group', 'content_types'],
moduleConfig: {
'content-types': {
Expand Down Expand Up @@ -40,6 +40,16 @@ const config = {
dirName: 'custom-roles',
fileName: 'custom-roles.json',
},
'assets': {
name: 'assets',
dirName: 'assets',
fileName: 'assets.json',
},
'environments': {
name: 'environments',
dirName: 'environments',
fileName: 'environments.json',
}
},
entries: {
systemKeys: [
Expand Down Expand Up @@ -76,13 +86,23 @@ const config = {
'min_instance',
'missingFieldUid',
'isPublished',
'locale',
'environment',
'ctUid',
'ctLocale',
'entry_uid',
'publish_locale',
'publish_environment',
'asset_uid'
],
ReportTitleForEntries: {
Entries_Select_feild: 'Entries_Select_feild',
Entries_Mandatory_feild: 'Entries_Mandatory_feild',
Entries_Title_feild: 'Entries_Title_feild',
Entry_Missing_Locale_and_Env: 'Entry_Missing_Locale_and_Env',
Entry_Missing_Locale_and_Env_in_Publish_Details: 'Entry_Missing_Locale_and_Env_in_Publish_Details'
},
feild_level_modules: ['Entries_Title_feild', 'Entries_Mandatory_feild', 'Entries_Select_feild'],
feild_level_modules: ['Entries_Title_feild', 'Entries_Mandatory_feild', 'Entries_Select_feild', 'Entry_Missing_Locale_and_Env_in_Publish_Details'],
};

export default config;
7 changes: 7 additions & 0 deletions packages/contentstack-audit/src/messages/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ const auditMsg = {
AUDIT_CMD_DESCRIPTION: 'Perform audits and find possible errors in the exported Contentstack data',
SCAN_WF_SUCCESS_MSG: 'Successfully completed the scanning of workflow with UID {uid} and name {name}.',
SCAN_CR_SUCCESS_MSG: 'Successfully completed the scanning of custom role with UID {uid} and name {name}.',
SCAN_ASSET_SUCCESS_MSG: `Successfully completed the scanning of Asset with UID '{uid}'.`,
SCAN_ASSET_WARN_MSG: `The locale '{locale}' or environment '{environment}' are not present for asset with uid '{uid}'`,
ENTRY_PUBLISH_DETAILS: `Removing the publish detials for entry '{uid}' of ct '{ctuid}' in locale '{locale}' as locale '{publocale}' or environment '{environment}' does not exist`,
CT_REFERENCE_FIELD: `The mentioned Reference Field is not Array field name 'reference_to' having display name 'display_name'`,
ASSET_NOT_EXIST: `The publish_details either does not exist or is not an array for asset uid '{uid}'`,
ENTRY_PUBLISH_DETAILS_NOT_EXIST: `The publish_details either does not exist or is not an array for entry uid '{uid}'`,
};

const auditFixMsg = {
Expand All @@ -49,6 +55,7 @@ const auditFixMsg = {
WF_FIX_MSG: 'Successfully removed the workflow {uid} named {name}.',
ENTRY_MANDATORY_FIELD_FIX: `Removing the publish details from the entry with UID '{uid}' in Locale '{locale}'...`,
ENTRY_SELECT_FIELD_FIX: `Adding the value '{value}' in the select field of entry UID '{uid}'...`,
ASSET_FIX: `Fixed publish detials for Asset with UID '{uid}'`,
};

const messages: typeof errors &
Expand Down
Loading
Loading