Skip to content

Commit e9bcf67

Browse files
authored
Merge pull request #1548 from contentstack/staging
Staging
2 parents 9f4bf30 + bff053a commit e9bcf67

117 files changed

Lines changed: 6179 additions & 3375 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

100755100644
File mode changed.

package-lock.json

Lines changed: 905 additions & 2638 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/contentstack-audit/README.md

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ $ npm install -g @contentstack/cli-audit
1919
$ csdx COMMAND
2020
running command...
2121
$ csdx (--version|-v)
22-
@contentstack/cli-audit/1.6.5 darwin-arm64 node-v22.2.0
22+
@contentstack/cli-audit/1.7.0 darwin-arm64 node-v22.2.0
2323
$ csdx --help [COMMAND]
2424
USAGE
2525
$ csdx COMMAND
@@ -52,12 +52,13 @@ Perform audits and find possible errors in the exported Contentstack data
5252

5353
```
5454
USAGE
55-
$ csdx audit [--report-path <value>] [--modules content-types|global-fields|entries|extensions|workflows]
56-
[--columns <value> | ] [--sort <value>] [--filter <value>] [--csv | --no-truncate]
55+
$ csdx audit [--report-path <value>] [--modules
56+
content-types|global-fields|entries|extensions|workflows|custom-roles] [--columns <value> | ] [--sort <value>]
57+
[--filter <value>] [--csv | --no-truncate]
5758
5859
FLAGS
5960
--modules=<option>... Provide the list of modules to be audited
60-
<options: content-types|global-fields|entries|extensions|workflows>
61+
<options: content-types|global-fields|entries|extensions|workflows|custom-roles>
6162
--report-path=<value> Path to store the audit reports
6263
6364
TABLE FLAGS
@@ -92,8 +93,8 @@ Perform audits and fix possible errors in the exported Contentstack data.
9293

9394
```
9495
USAGE
95-
$ csdx audit:fix [--report-path <value>] [--modules content-types|global-fields|entries|extensions|workflows]
96-
[--copy-path <value> --copy-dir] [--fix-only
96+
$ csdx audit:fix [--report-path <value>] [--modules
97+
content-types|global-fields|entries|extensions|workflows|custom-roles] [--copy-path <value> --copy-dir] [--fix-only
9798
reference|global_field|json:rte|json:extension|blocks|group|content_types] [--columns <value> | ] [--sort <value>]
9899
[--filter <value>] [--csv | --no-truncate]
99100
@@ -103,7 +104,7 @@ FLAGS
103104
--fix-only=<option>... Provide the list of fix options
104105
<options: reference|global_field|json:rte|json:extension|blocks|group|content_types>
105106
--modules=<option>... Provide the list of modules to be audited
106-
<options: content-types|global-fields|entries|extensions|workflows>
107+
<options: content-types|global-fields|entries|extensions|workflows|custom-roles>
107108
--report-path=<value> Path to store the audit reports
108109
109110
TABLE FLAGS
@@ -140,12 +141,13 @@ Perform audits and find possible errors in the exported Contentstack data
140141

141142
```
142143
USAGE
143-
$ csdx cm:stacks:audit [--report-path <value>] [--modules content-types|global-fields|entries|extensions|workflows]
144-
[--columns <value> | ] [--sort <value>] [--filter <value>] [--csv | --no-truncate]
144+
$ csdx cm:stacks:audit [--report-path <value>] [--modules
145+
content-types|global-fields|entries|extensions|workflows|custom-roles] [--columns <value> | ] [--sort <value>]
146+
[--filter <value>] [--csv | --no-truncate]
145147
146148
FLAGS
147149
--modules=<option>... Provide the list of modules to be audited
148-
<options: content-types|global-fields|entries|extensions|workflows>
150+
<options: content-types|global-fields|entries|extensions|workflows|custom-roles>
149151
--report-path=<value> Path to store the audit reports
150152
151153
TABLE FLAGS
@@ -182,8 +184,8 @@ Perform audits and fix possible errors in the exported Contentstack data.
182184

183185
```
184186
USAGE
185-
$ csdx cm:stacks:audit:fix [--report-path <value>] [--modules content-types|global-fields|entries|extensions|workflows]
186-
[--copy-path <value> --copy-dir] [--fix-only
187+
$ csdx cm:stacks:audit:fix [--report-path <value>] [--modules
188+
content-types|global-fields|entries|extensions|workflows|custom-roles] [--copy-path <value> --copy-dir] [--fix-only
187189
reference|global_field|json:rte|json:extension|blocks|group|content_types] [--columns <value> | ] [--sort <value>]
188190
[--filter <value>] [--csv | --no-truncate]
189191
@@ -193,7 +195,7 @@ FLAGS
193195
--fix-only=<option>... Provide the list of fix options
194196
<options: reference|global_field|json:rte|json:extension|blocks|group|content_types>
195197
--modules=<option>... Provide the list of modules to be audited
196-
<options: content-types|global-fields|entries|extensions|workflows>
198+
<options: content-types|global-fields|entries|extensions|workflows|custom-roles>
197199
--report-path=<value> Path to store the audit reports
198200
199201
TABLE FLAGS
@@ -267,7 +269,7 @@ EXAMPLES
267269
$ csdx plugins
268270
```
269271

270-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.4/src/commands/plugins/index.ts)_
272+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.6/src/commands/plugins/index.ts)_
271273

272274
## `csdx plugins:add PLUGIN`
273275

@@ -341,7 +343,7 @@ EXAMPLES
341343
$ csdx plugins:inspect myplugin
342344
```
343345

344-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.4/src/commands/plugins/inspect.ts)_
346+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.6/src/commands/plugins/inspect.ts)_
345347

346348
## `csdx plugins:install PLUGIN`
347349

@@ -390,7 +392,7 @@ EXAMPLES
390392
$ csdx plugins:install someuser/someplugin
391393
```
392394

393-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.4/src/commands/plugins/install.ts)_
395+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.6/src/commands/plugins/install.ts)_
394396

395397
## `csdx plugins:link PATH`
396398

@@ -420,7 +422,7 @@ EXAMPLES
420422
$ csdx plugins:link myplugin
421423
```
422424

423-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.4/src/commands/plugins/link.ts)_
425+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.6/src/commands/plugins/link.ts)_
424426

425427
## `csdx plugins:remove [PLUGIN]`
426428

@@ -461,7 +463,7 @@ FLAGS
461463
--reinstall Reinstall all plugins after uninstalling.
462464
```
463465

464-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.4/src/commands/plugins/reset.ts)_
466+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.6/src/commands/plugins/reset.ts)_
465467

466468
## `csdx plugins:uninstall [PLUGIN]`
467469

@@ -489,7 +491,7 @@ EXAMPLES
489491
$ csdx plugins:uninstall myplugin
490492
```
491493

492-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.4/src/commands/plugins/uninstall.ts)_
494+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.6/src/commands/plugins/uninstall.ts)_
493495

494496
## `csdx plugins:unlink [PLUGIN]`
495497

@@ -533,5 +535,5 @@ DESCRIPTION
533535
Update installed plugins.
534536
```
535537

536-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.4/src/commands/plugins/update.ts)_
538+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.6/src/commands/plugins/update.ts)_
537539
<!-- commandsstop -->

packages/contentstack-audit/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@contentstack/cli-audit",
3-
"version": "1.6.5",
3+
"version": "1.7.0",
44
"description": "Contentstack audit plugin",
55
"author": "Contentstack CLI",
66
"homepage": "https://github.com/contentstack/cli",
@@ -19,7 +19,7 @@
1919
],
2020
"dependencies": {
2121
"@contentstack/cli-command": "~1.3.0",
22-
"@contentstack/cli-utilities": "~1.7.1",
22+
"@contentstack/cli-utilities": "~1.7.2",
2323
"@oclif/plugin-help": "^5",
2424
"@oclif/plugin-plugins": "^5.0.0",
2525
"chalk": "^4.1.2",

packages/contentstack-audit/src/audit-base-command.ts

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
RefErrorReturnType,
2121
WorkflowExtensionsRefErrorReturnType,
2222
} from './types';
23+
import CustomRoles from './modules/custom-roles';
2324

2425
export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseCommand> {
2526
private currentCommand!: CommandNames;
@@ -56,6 +57,8 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
5657
missingCtRefsInWorkflow,
5758
missingSelectFeild,
5859
missingMandatoryFields,
60+
missingTitleFields,
61+
missingRefInCustomRoles
5962
} = await this.scanAndFix();
6063

6164
this.showOutputOnScreen([
@@ -69,13 +72,19 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
6972
this.showOutputOnScreenWorkflowsAndExtension([
7073
{ module: 'Entries Mandatory Field', missingRefs: missingMandatoryFields },
7174
]);
75+
this.showOutputOnScreenWorkflowsAndExtension([
76+
{ module: 'Entries Title Field', missingRefs: missingTitleFields },
77+
]);
78+
this.showOutputOnScreenWorkflowsAndExtension([{ module: 'Custom Roles', missingRefs: missingRefInCustomRoles }]);
7279
if (
7380
!isEmpty(missingCtRefs) ||
7481
!isEmpty(missingGfRefs) ||
7582
!isEmpty(missingEntryRefs) ||
7683
!isEmpty(missingCtRefsInWorkflow) ||
7784
!isEmpty(missingCtRefsInExtensions) ||
78-
!isEmpty(missingSelectFeild)
85+
!isEmpty(missingSelectFeild) ||
86+
!isEmpty(missingTitleFields) ||
87+
!isEmpty(missingRefInCustomRoles)
7988
) {
8089
if (this.currentCommand === 'cm:stacks:audit') {
8190
this.log(this.$t(auditMsg.FINAL_REPORT_PATH, { path: this.sharedConfig.reportPath }), 'warn');
@@ -102,7 +111,8 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
102111
!isEmpty(missingEntryRefs) ||
103112
!isEmpty(missingCtRefsInWorkflow) ||
104113
!isEmpty(missingCtRefsInExtensions) ||
105-
!isEmpty(missingSelectFeild)
114+
!isEmpty(missingSelectFeild) ||
115+
!isEmpty(missingRefInCustomRoles)
106116
);
107117
}
108118

@@ -121,7 +131,9 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
121131
missingCtRefsInWorkflow,
122132
missingSelectFeild,
123133
missingEntry,
124-
missingMandatoryFields;
134+
missingMandatoryFields,
135+
missingTitleFields,
136+
missingRefInCustomRoles;
125137

126138
for (const module of this.sharedConfig.flags.modules || this.sharedConfig.modules) {
127139
print([
@@ -154,11 +166,15 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
154166
missingEntryRefs = missingEntry.missingEntryRefs ?? {};
155167
missingSelectFeild = missingEntry.missingSelectFeild ?? {};
156168
missingMandatoryFields = missingEntry.missingMandatoryFields ?? {};
169+
missingTitleFields = missingEntry.missingTitleFields ?? {};
157170
await this.prepareReport(module, missingEntryRefs);
158171

159172
await this.prepareReport(`Entries_Select_feild`, missingSelectFeild);
160173

161174
await this.prepareReport('Entries_Mandatory_feild', missingMandatoryFields);
175+
176+
await this.prepareReport('Entries_Title_feild', missingTitleFields);
177+
162178
break;
163179
case 'workflows':
164180
missingCtRefsInWorkflow = await new Workflows({
@@ -174,6 +190,10 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
174190
missingCtRefsInExtensions = await new Extensions(cloneDeep(constructorParam)).run();
175191
await this.prepareReport(module, missingCtRefsInExtensions);
176192
break;
193+
case 'custom-roles':
194+
missingRefInCustomRoles = await new CustomRoles(cloneDeep(constructorParam)).run();
195+
await this.prepareReport(module, missingRefInCustomRoles);
196+
break;
177197
}
178198

179199
print([
@@ -198,6 +218,8 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
198218
missingCtRefsInWorkflow,
199219
missingSelectFeild,
200220
missingMandatoryFields,
221+
missingTitleFields,
222+
missingRefInCustomRoles,
201223
};
202224
}
203225

@@ -416,7 +438,7 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
416438
moduleName: keyof typeof config.moduleConfig | keyof typeof config.ReportTitleForEntries,
417439
listOfMissingRefs: Record<string, any>,
418440
): Promise<void> {
419-
if (Object.keys(config.moduleConfig).includes(moduleName)) {
441+
if (Object.keys(config.moduleConfig).includes(moduleName) || config.feild_level_modules.includes(moduleName)) {
420442
const csvPath = join(sanitizePath(this.sharedConfig.reportPath), `${sanitizePath(moduleName)}.csv`);
421443
return new Promise<void>((resolve, reject) => {
422444
// file deepcode ignore MissingClose: Will auto close once csv stream end

packages/contentstack-audit/src/config/index.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ const config = {
22
showTerminalOutput: true,
33
skipRefs: ['sys_assets'],
44
skipFieldTypes: ['taxonomy', 'group'],
5-
modules: ['content-types', 'global-fields', 'entries', 'extensions', 'workflows'],
5+
modules: ['content-types', 'global-fields', 'entries', 'extensions', 'workflows', 'custom-roles'],
66
'fix-fields': ['reference', 'global_field', 'json:rte', 'json:extension', 'blocks', 'group', 'content_types'],
77
moduleConfig: {
88
'content-types': {
@@ -35,6 +35,11 @@ const config = {
3535
dirName: 'extensions',
3636
fileName: 'extensions.json',
3737
},
38+
'custom-roles': {
39+
name: 'custom-roles',
40+
dirName: 'custom-roles',
41+
fileName: 'custom-roles.json',
42+
},
3843
},
3944
entries: {
4045
systemKeys: [
@@ -75,7 +80,9 @@ const config = {
7580
ReportTitleForEntries: {
7681
Entries_Select_feild: 'Entries_Select_feild',
7782
Entries_Mandatory_feild: 'Entries_Mandatory_feild',
83+
Entries_Title_feild: 'Entries_Title_feild',
7884
},
85+
feild_level_modules: ['Entries_Title_feild', 'Entries_Mandatory_feild', 'Entries_Select_feild'],
7986
};
8087

8188
export default config;

packages/contentstack-audit/src/messages/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ const commonMsg = {
1919
EXTENSION_FIX_WARN: `The extension associated with UID {uid} and title '{title}' will be removed.`,
2020
EXTENSION_FIX_CONFIRMATION: `Would you like to overwrite existing file?`,
2121
WF_BRANCH_REMOVAL: `Removing the branch '{branch} from workflow with UID {uid} and name {name} will be removed.'`,
22+
CR_BRANCH_REMOVAL: `Removing the branch '{branch} from custom role with UID {uid} and name {name} will be removed.'`,
2223
};
2324

2425
const auditMsg = {
@@ -35,6 +36,7 @@ const auditMsg = {
3536
SCAN_EXT_SUCCESS_MSG: "Successfully completed scanning the {module} titled '{title}' with UID '{uid}'",
3637
AUDIT_CMD_DESCRIPTION: 'Perform audits and find possible errors in the exported Contentstack data',
3738
SCAN_WF_SUCCESS_MSG: 'Successfully completed the scanning of workflow with UID {uid} and name {name}.',
39+
SCAN_CR_SUCCESS_MSG: 'Successfully completed the scanning of custom role with UID {uid} and name {name}.',
3840
};
3941

4042
const auditFixMsg = {

0 commit comments

Comments
 (0)