Skip to content

Commit be96e4c

Browse files
Merge branch 'development' into feat/nested-global-fields
2 parents 3f28c59 + 2695c2f commit be96e4c

File tree

71 files changed

+5587
-2128
lines changed

Some content is hidden

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

71 files changed

+5587
-2128
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
version: 7
1515
- uses: actions/setup-node@v4
1616
with:
17-
node-version: '18.x'
17+
node-version: '22.x'
1818
cache: 'pnpm'
1919
- name: Reading Configuration
2020
id: release_config

package-lock.json

Lines changed: 3480 additions & 1068 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 & 22 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.7.5 darwin-arm64 node-v18.18.0
22+
@contentstack/cli-audit/1.9.0 darwin-arm64 node-v23.6.0
2323
$ csdx --help [COMMAND]
2424
USAGE
2525
$ csdx COMMAND
@@ -53,12 +53,12 @@ Perform audits and find possible errors in the exported Contentstack data
5353
```
5454
USAGE
5555
$ 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]
56+
content-types|global-fields|entries|extensions|workflows|custom-roles|assets] [--columns <value> | ] [--sort
57+
<value>] [--filter <value>] [--csv | --no-truncate]
5858
5959
FLAGS
6060
--modules=<option>... Provide the list of modules to be audited
61-
<options: content-types|global-fields|entries|extensions|workflows|custom-roles>
61+
<options: content-types|global-fields|entries|extensions|workflows|custom-roles|assets>
6262
--report-path=<value> Path to store the audit reports
6363
6464
TABLE FLAGS
@@ -94,17 +94,17 @@ Perform audits and fix possible errors in the exported Contentstack data.
9494
```
9595
USAGE
9696
$ csdx audit:fix [--report-path <value>] [--modules
97-
content-types|global-fields|entries|extensions|workflows|custom-roles] [--copy-path <value> --copy-dir] [--fix-only
98-
reference|global_field|json:rte|json:extension|blocks|group|content_types] [--columns <value> | ] [--sort <value>]
99-
[--filter <value>] [--csv | --no-truncate]
97+
content-types|global-fields|entries|extensions|workflows|custom-roles|assets] [--copy-path <value> --copy-dir]
98+
[--fix-only reference|global_field|json:rte|json:extension|blocks|group|content_types] [--columns <value> | ]
99+
[--sort <value>] [--filter <value>] [--csv | --no-truncate]
100100
101101
FLAGS
102102
--copy-dir Create backup from the original data.
103103
--copy-path=<value> Provide the path to backup the copied data
104104
--fix-only=<option>... Provide the list of fix options
105105
<options: reference|global_field|json:rte|json:extension|blocks|group|content_types>
106106
--modules=<option>... Provide the list of modules to be audited
107-
<options: content-types|global-fields|entries|extensions|workflows|custom-roles>
107+
<options: content-types|global-fields|entries|extensions|workflows|custom-roles|assets>
108108
--report-path=<value> Path to store the audit reports
109109
110110
TABLE FLAGS
@@ -142,12 +142,12 @@ Perform audits and find possible errors in the exported Contentstack data
142142
```
143143
USAGE
144144
$ 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]
145+
content-types|global-fields|entries|extensions|workflows|custom-roles|assets] [--columns <value> | ] [--sort
146+
<value>] [--filter <value>] [--csv | --no-truncate]
147147
148148
FLAGS
149149
--modules=<option>... Provide the list of modules to be audited
150-
<options: content-types|global-fields|entries|extensions|workflows|custom-roles>
150+
<options: content-types|global-fields|entries|extensions|workflows|custom-roles|assets>
151151
--report-path=<value> Path to store the audit reports
152152
153153
TABLE FLAGS
@@ -185,17 +185,17 @@ Perform audits and fix possible errors in the exported Contentstack data.
185185
```
186186
USAGE
187187
$ 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
189-
reference|global_field|json:rte|json:extension|blocks|group|content_types] [--columns <value> | ] [--sort <value>]
190-
[--filter <value>] [--csv | --no-truncate]
188+
content-types|global-fields|entries|extensions|workflows|custom-roles|assets] [--copy-path <value> --copy-dir]
189+
[--fix-only reference|global_field|json:rte|json:extension|blocks|group|content_types] [--columns <value> | ]
190+
[--sort <value>] [--filter <value>] [--csv | --no-truncate]
191191
192192
FLAGS
193193
--copy-dir Create backup from the original data.
194194
--copy-path=<value> Provide the path to backup the copied data
195195
--fix-only=<option>... Provide the list of fix options
196196
<options: reference|global_field|json:rte|json:extension|blocks|group|content_types>
197197
--modules=<option>... Provide the list of modules to be audited
198-
<options: content-types|global-fields|entries|extensions|workflows|custom-roles>
198+
<options: content-types|global-fields|entries|extensions|workflows|custom-roles|assets>
199199
--report-path=<value> Path to store the audit reports
200200
201201
TABLE FLAGS
@@ -269,7 +269,7 @@ EXAMPLES
269269
$ csdx plugins
270270
```
271271

272-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.31/src/commands/plugins/index.ts)_
272+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.36/src/commands/plugins/index.ts)_
273273

274274
## `csdx plugins:add PLUGIN`
275275

@@ -343,7 +343,7 @@ EXAMPLES
343343
$ csdx plugins:inspect myplugin
344344
```
345345

346-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.31/src/commands/plugins/inspect.ts)_
346+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.36/src/commands/plugins/inspect.ts)_
347347

348348
## `csdx plugins:install PLUGIN`
349349

@@ -392,7 +392,7 @@ EXAMPLES
392392
$ csdx plugins:install someuser/someplugin
393393
```
394394

395-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.31/src/commands/plugins/install.ts)_
395+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.36/src/commands/plugins/install.ts)_
396396

397397
## `csdx plugins:link PATH`
398398

@@ -423,7 +423,7 @@ EXAMPLES
423423
$ csdx plugins:link myplugin
424424
```
425425

426-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.31/src/commands/plugins/link.ts)_
426+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.36/src/commands/plugins/link.ts)_
427427

428428
## `csdx plugins:remove [PLUGIN]`
429429

@@ -464,7 +464,7 @@ FLAGS
464464
--reinstall Reinstall all plugins after uninstalling.
465465
```
466466

467-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.31/src/commands/plugins/reset.ts)_
467+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.36/src/commands/plugins/reset.ts)_
468468

469469
## `csdx plugins:uninstall [PLUGIN]`
470470

@@ -492,7 +492,7 @@ EXAMPLES
492492
$ csdx plugins:uninstall myplugin
493493
```
494494

495-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.31/src/commands/plugins/uninstall.ts)_
495+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.36/src/commands/plugins/uninstall.ts)_
496496

497497
## `csdx plugins:unlink [PLUGIN]`
498498

@@ -536,5 +536,5 @@ DESCRIPTION
536536
Update installed plugins.
537537
```
538538

539-
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.31/src/commands/plugins/update.ts)_
539+
_See code: [@oclif/plugin-plugins](https://github.com/oclif/plugin-plugins/blob/v5.4.36/src/commands/plugins/update.ts)_
540540
<!-- commandsstop -->

packages/contentstack-audit/package.json

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@contentstack/cli-audit",
3-
"version": "1.7.5",
3+
"version": "1.9.0",
44
"description": "Contentstack audit plugin",
55
"author": "Contentstack CLI",
66
"homepage": "https://github.com/contentstack/cli",
@@ -19,34 +19,34 @@
1919
],
2020
"dependencies": {
2121
"@contentstack/cli-command": "~1.3.3",
22-
"@contentstack/cli-utilities": "~1.8.1",
22+
"@contentstack/cli-utilities": "~1.8.4",
2323
"@oclif/plugin-help": "^5.2.20",
24-
"@oclif/plugin-plugins": "^5.4.24",
24+
"@oclif/plugin-plugins": "^5.4.34",
2525
"chalk": "^4.1.2",
2626
"fast-csv": "^4.3.6",
27-
"fs-extra": "^11.2.0",
27+
"fs-extra": "^11.3.0",
2828
"lodash": "^4.17.21",
2929
"uuid": "^9.0.1",
3030
"winston": "^3.17.0"
3131
},
3232
"devDependencies": {
33-
"@oclif/test": "^4.1.6",
33+
"@oclif/test": "^4.1.11",
3434
"@types/chai": "^4.3.20",
3535
"@types/fs-extra": "^11.0.4",
3636
"@types/mocha": "^10.0.10",
37-
"@types/node": "^20.17.10",
37+
"@types/node": "^20.17.19",
3838
"@types/uuid": "^9.0.8",
3939
"chai": "^4.5.0",
4040
"eslint": "^8.57.1",
4141
"eslint-config-oclif": "^4.0.0",
42-
"eslint-config-oclif-typescript": "^3.1.13",
42+
"eslint-config-oclif-typescript": "^3.1.14",
4343
"mocha": "^10.8.2",
4444
"nyc": "^15.1.0",
4545
"oclif": "^3.17.2",
4646
"shx": "^0.3.4",
4747
"sinon": "^19.0.2",
4848
"ts-node": "^10.9.2",
49-
"typescript": "^5.7.2"
49+
"typescript": "^5.7.3"
5050
},
5151
"oclif": {
5252
"bin": "csdx",

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

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import config from './config';
1212
import { print } from './util/log';
1313
import { auditMsg } from './messages';
1414
import { BaseCommand } from './base-command';
15-
import { Entries, GlobalField, ContentType, Extensions, Workflows } from './modules';
15+
import { Entries, GlobalField, ContentType, Extensions, Workflows, Assets } from './modules';
1616
import {
1717
CommandNames,
1818
ContentTypeStruct,
@@ -58,7 +58,9 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
5858
missingSelectFeild,
5959
missingMandatoryFields,
6060
missingTitleFields,
61-
missingRefInCustomRoles
61+
missingRefInCustomRoles,
62+
missingEnvLocalesInAssets,
63+
missingEnvLocalesInEntries
6264
} = await this.scanAndFix();
6365

6466
this.showOutputOnScreen([
@@ -76,6 +78,8 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
7678
{ module: 'Entries Title Field', missingRefs: missingTitleFields },
7779
]);
7880
this.showOutputOnScreenWorkflowsAndExtension([{ module: 'Custom Roles', missingRefs: missingRefInCustomRoles }]);
81+
this.showOutputOnScreenWorkflowsAndExtension([{ module: 'Assets', missingRefs: missingEnvLocalesInAssets }]);
82+
this.showOutputOnScreenWorkflowsAndExtension([{ module: 'Entries Missing Locale and Environments', missingRefs: missingEnvLocalesInEntries }])
7983
if (
8084
!isEmpty(missingCtRefs) ||
8185
!isEmpty(missingGfRefs) ||
@@ -84,7 +88,9 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
8488
!isEmpty(missingCtRefsInExtensions) ||
8589
!isEmpty(missingSelectFeild) ||
8690
!isEmpty(missingTitleFields) ||
87-
!isEmpty(missingRefInCustomRoles)
91+
!isEmpty(missingRefInCustomRoles) ||
92+
!isEmpty(missingEnvLocalesInAssets) ||
93+
!isEmpty(missingEnvLocalesInEntries)
8894
) {
8995
if (this.currentCommand === 'cm:stacks:audit') {
9096
this.log(this.$t(auditMsg.FINAL_REPORT_PATH, { path: this.sharedConfig.reportPath }), 'warn');
@@ -112,7 +118,9 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
112118
!isEmpty(missingCtRefsInWorkflow) ||
113119
!isEmpty(missingCtRefsInExtensions) ||
114120
!isEmpty(missingSelectFeild) ||
115-
!isEmpty(missingRefInCustomRoles)
121+
!isEmpty(missingRefInCustomRoles) ||
122+
!isEmpty(missingEnvLocalesInAssets) ||
123+
!isEmpty(missingEnvLocalesInEntries)
116124
);
117125
}
118126

@@ -133,7 +141,9 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
133141
missingEntry,
134142
missingMandatoryFields,
135143
missingTitleFields,
136-
missingRefInCustomRoles;
144+
missingRefInCustomRoles,
145+
missingEnvLocalesInAssets,
146+
missingEnvLocalesInEntries;
137147

138148
for (const module of this.sharedConfig.flags.modules || this.sharedConfig.modules) {
139149
print([
@@ -153,6 +163,10 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
153163
fix: this.currentCommand === 'cm:stacks:audit:fix',
154164
};
155165
switch (module) {
166+
case 'assets':
167+
missingEnvLocalesInAssets = await new Assets(cloneDeep(constructorParam)).run();
168+
await this.prepareReport(module, missingEnvLocalesInAssets);
169+
break;
156170
case 'content-types':
157171
missingCtRefs = await new ContentType(cloneDeep(constructorParam)).run();
158172
await this.prepareReport(module, missingCtRefs);
@@ -167,6 +181,7 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
167181
missingSelectFeild = missingEntry.missingSelectFeild ?? {};
168182
missingMandatoryFields = missingEntry.missingMandatoryFields ?? {};
169183
missingTitleFields = missingEntry.missingTitleFields ?? {};
184+
missingEnvLocalesInEntries = missingEntry.missingEnvLocale??{};
170185
await this.prepareReport(module, missingEntryRefs);
171186

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

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

193+
await this.prepareReport('Entry_Missing_Locale_and_Env_in_Publish_Details', missingEnvLocalesInEntries);
194+
178195
break;
179196
case 'workflows':
180197
missingCtRefsInWorkflow = await new Workflows({
@@ -220,6 +237,8 @@ export abstract class AuditBaseCommand extends BaseCommand<typeof AuditBaseComma
220237
missingMandatoryFields,
221238
missingTitleFields,
222239
missingRefInCustomRoles,
240+
missingEnvLocalesInAssets,
241+
missingEnvLocalesInEntries
223242
};
224243
}
225244

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

Lines changed: 24 additions & 2 deletions
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', 'custom-roles'],
5+
modules: ['content-types', 'global-fields', 'entries', 'extensions', 'workflows', 'custom-roles', 'assets'],
66
'fix-fields': ['reference', 'global_field', 'json:rte', 'json:extension', 'blocks', 'group', 'content_types'],
77
moduleConfig: {
88
'content-types': {
@@ -40,6 +40,16 @@ const config = {
4040
dirName: 'custom-roles',
4141
fileName: 'custom-roles.json',
4242
},
43+
'assets': {
44+
name: 'assets',
45+
dirName: 'assets',
46+
fileName: 'assets.json',
47+
},
48+
'environments': {
49+
name: 'environments',
50+
dirName: 'environments',
51+
fileName: 'environments.json',
52+
}
4353
},
4454
entries: {
4555
systemKeys: [
@@ -76,13 +86,25 @@ const config = {
7686
'min_instance',
7787
'missingFieldUid',
7888
'isPublished',
89+
'locale',
90+
'environment',
91+
'ctUid',
92+
'ctLocale',
93+
'entry_uid',
94+
'publish_locale',
95+
'publish_environment',
96+
'asset_uid',
97+
'selectedValue'
7998
],
8099
ReportTitleForEntries: {
81100
Entries_Select_feild: 'Entries_Select_feild',
82101
Entries_Mandatory_feild: 'Entries_Mandatory_feild',
83102
Entries_Title_feild: 'Entries_Title_feild',
103+
Entry_Missing_Locale_and_Env: 'Entry_Missing_Locale_and_Env',
104+
Entry_Missing_Locale_and_Env_in_Publish_Details: 'Entry_Missing_Locale_and_Env_in_Publish_Details'
84105
},
85-
feild_level_modules: ['Entries_Title_feild', 'Entries_Mandatory_feild', 'Entries_Select_feild'],
106+
feild_level_modules: ['Entries_Title_feild', 'Entries_Mandatory_feild', 'Entries_Select_feild', 'Entry_Missing_Locale_and_Env_in_Publish_Details'],
107+
fixSelectField: false
86108
};
87109

88110
export default config;

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,12 @@ const auditMsg = {
3737
AUDIT_CMD_DESCRIPTION: 'Perform audits and find possible errors in the exported Contentstack data',
3838
SCAN_WF_SUCCESS_MSG: 'Successfully completed the scanning of workflow with UID {uid} and name {name}.',
3939
SCAN_CR_SUCCESS_MSG: 'Successfully completed the scanning of custom role with UID {uid} and name {name}.',
40+
SCAN_ASSET_SUCCESS_MSG: `Successfully completed the scanning of Asset with UID '{uid}'.`,
41+
SCAN_ASSET_WARN_MSG: `The locale '{locale}' or environment '{environment}' are not present for asset with uid '{uid}'`,
42+
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`,
43+
CT_REFERENCE_FIELD: `The mentioned Reference field is not Array field reference is '{reference_to}' having display name '{display_name}''`,
44+
ASSET_NOT_EXIST: `The publish_details either does not exist or is not an array for asset uid '{uid}'`,
45+
ENTRY_PUBLISH_DETAILS_NOT_EXIST: `The publish_details either does not exist or is not an array for entry uid '{uid}'`,
4046
};
4147

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

5461
const messages: typeof errors &

0 commit comments

Comments
 (0)