Skip to content

Commit 075bdaa

Browse files
authored
Merge pull request #95 from contentstack/feat/DX-4977
added support for am2.0 in audit
2 parents c8597a9 + c7a05de commit 075bdaa

16 files changed

Lines changed: 243 additions & 138 deletions

File tree

.talismanrc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
fileignoreconfig:
22
- filename: packages/contentstack-import/src/utils/import-config-handler.ts
33
checksum: 3194f537cee8041f07a7ea91cdc6351c84e400766696d9c3cf80b98f99961f76
4+
- filename: pnpm-lock.yaml
5+
checksum: cea25dedde40bf962d825a088e505113c997ae666a4385d3eec0ae3f9f5d1404
46
version: '1.0'

packages/contentstack-audit/README.md

Lines changed: 2 additions & 2 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/2.0.0-beta.6 darwin-arm64 node-v24.13.0
22+
@contentstack/cli-audit/2.0.0-beta.10 darwin-arm64 node-v22.13.1
2323
$ csdx --help [COMMAND]
2424
USAGE
2525
$ csdx COMMAND
@@ -157,5 +157,5 @@ DESCRIPTION
157157
Display help for csdx.
158158
```
159159

160-
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/v6.2.37/src/commands/help.ts)_
160+
_See code: [@oclif/plugin-help](https://github.com/oclif/plugin-help/blob/6.2.44/src/commands/help.ts)_
161161
<!-- commandsstop -->

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,7 @@ const config = {
110110
'publish_locale',
111111
'publish_environment',
112112
'asset_uid',
113+
'space_id',
113114
'selectedValue',
114115
'ct_uid',
115116
'action',

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ const auditMsg = {
4444
ENTRY_PUBLISH_DETAILS: `Removing the publish details for entry '{uid}' of ct '{ctuid}' in locale '{locale}' as locale '{publocale}' or environment '{environment}' does not exist`,
4545
CT_REFERENCE_FIELD: `The mentioned Reference field is not Array field reference is '{reference_to}' having display name '{display_name}''`,
4646
ASSET_NOT_EXIST: `The publish_details either does not exist or is not an array for asset uid '{uid}'`,
47+
AUDITING_SPACE: `Auditing assets for space: '{spaceId}'`,
4748
ENTRY_PUBLISH_DETAILS_NOT_EXIST: `The publish_details either does not exist or is not an array for entry uid '{uid}'`,
4849
FIELD_RULE_CONDITION_ABSENT: `The operand field '{condition_field}' is not present in the schema of the content-type {ctUid}`,
4950
FIELD_RULE_TARGET_ABSENT: `The target field '{target_field}' is not present in the schema of the content-type {ctUid}`,

packages/contentstack-audit/src/modules/assets.ts

Lines changed: 180 additions & 95 deletions
Large diffs are not rendered by default.

packages/contentstack-audit/src/modules/modulesData.ts

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { join, resolve } from 'path';
2-
import { existsSync, readFileSync } from 'fs';
2+
import { existsSync, readFileSync, readdirSync } from 'fs';
33
import { FsUtility, sanitizePath, log } from '@contentstack/cli-utilities';
44
import { ConfigType, ContentTypeStruct, CtConstructorParam, ModuleConstructorParam } from '../types';
55
import { keys, values } from 'lodash';
@@ -46,10 +46,25 @@ export default class ModuleDataReader {
4646
break;
4747
case 'assets': {
4848
log.debug(`Counting assets`, this.config.auditContext);
49-
const assetsPath = join(this.folderPath, 'assets');
50-
log.debug(`Assets path: ${assetsPath}`, this.config.auditContext);
51-
count = (await this.readEntryAssetsModule(assetsPath, 'assets')) || 0;
52-
log.debug(`Assets count: ${count}`, this.config.auditContext);
49+
const spacesDir = join(this.folderPath, 'spaces');
50+
if (existsSync(spacesDir)) {
51+
log.debug(`Multi-space structure detected at: ${spacesDir}`, this.config.auditContext);
52+
const spaceDirs = readdirSync(spacesDir, { withFileTypes: true }).filter(
53+
(entry) => entry.isDirectory() && existsSync(join(spacesDir, entry.name, 'assets')),
54+
);
55+
for (const spaceDir of spaceDirs) {
56+
const spaceAssetsPath = join(spacesDir, spaceDir.name, 'assets');
57+
log.debug(`Counting assets in space: ${spaceDir.name} at ${spaceAssetsPath}`, this.config.auditContext);
58+
const spaceCount = (await this.readEntryAssetsModule(spaceAssetsPath, 'assets')) || 0;
59+
log.debug(`Space ${spaceDir.name} asset count: ${spaceCount}`, this.config.auditContext);
60+
count += spaceCount;
61+
}
62+
} else {
63+
const assetsPath = join(this.folderPath, 'assets');
64+
log.debug(`Flat structure detected, assets path: ${assetsPath}`, this.config.auditContext);
65+
count = (await this.readEntryAssetsModule(assetsPath, 'assets')) || 0;
66+
}
67+
log.debug(`Total assets count: ${count}`, this.config.auditContext);
5368
break;
5469
}
5570
case 'entries':

packages/contentstack-audit/src/types/content-types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,7 @@ enum OutputColumn {
162162
'publish_locale' = 'publish_locale',
163163
'publish_environment' = 'publish_environment',
164164
'asset_uid' = 'asset_uid',
165+
'space_id' = 'space_id',
165166
'selectedValue' = 'selectedValue',
166167
'fixStatus' = 'fixStatus',
167168
'Content_type_uid' = 'ct_uid',

packages/contentstack-bootstrap/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ $ npm install -g @contentstack/cli-cm-bootstrap
1515
$ csdx COMMAND
1616
running command...
1717
$ csdx (--version)
18-
@contentstack/cli-cm-bootstrap/2.0.0-beta.11 darwin-arm64 node-v24.13.0
18+
@contentstack/cli-cm-bootstrap/2.0.0-beta.15 darwin-arm64 node-v22.13.1
1919
$ csdx --help [COMMAND]
2020
USAGE
2121
$ csdx COMMAND

packages/contentstack-branches/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ $ npm install -g @contentstack/cli-cm-branches
3737
$ csdx COMMAND
3838
running command...
3939
$ csdx (--version)
40-
@contentstack/cli-cm-branches/2.0.0-beta.2 darwin-arm64 node-v24.13.0
40+
@contentstack/cli-cm-branches/2.0.0-beta.6 darwin-arm64 node-v22.13.1
4141
$ csdx --help [COMMAND]
4242
USAGE
4343
$ csdx COMMAND

packages/contentstack-clone/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ $ npm install -g @contentstack/cli-cm-clone
1616
$ csdx COMMAND
1717
running command...
1818
$ csdx (--version)
19-
@contentstack/cli-cm-clone/2.0.0-beta.12 darwin-arm64 node-v24.13.0
19+
@contentstack/cli-cm-clone/2.0.0-beta.16 darwin-arm64 node-v22.13.1
2020
$ csdx --help [COMMAND]
2121
USAGE
2222
$ csdx COMMAND

0 commit comments

Comments
 (0)