Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
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
4 changes: 3 additions & 1 deletion .talismanrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
fileignoreconfig:
- filename: pnpm-lock.yaml
checksum: 8b5a2f43585d3191cdc71ad611f50c94b6d13fb7442cf4218ee0851a068af178
checksum: 0efb2a2f86f58006abbacf7de17e0d498824c046d1d3cb58c6a64b7364e93ff5
- filename: packages/contentstack-audit/src/modules/assets.ts
checksum: 968dde65ca1e6526d3a16766c86d4d9976752ba8589c27facbbb4df7a8f1f963
version: '1.0'
2 changes: 1 addition & 1 deletion 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/2.0.0-beta.6 darwin-arm64 node-v24.13.0
@contentstack/cli-audit/2.0.0-beta.9 darwin-arm64 node-v22.13.1
$ csdx --help [COMMAND]
USAGE
$ csdx COMMAND
Expand Down
1 change: 1 addition & 0 deletions packages/contentstack-audit/src/config/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ const config = {
'publish_locale',
'publish_environment',
'asset_uid',
'space_id',
'selectedValue',
'ct_uid',
'action',
Expand Down
1 change: 1 addition & 0 deletions packages/contentstack-audit/src/messages/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const auditMsg = {
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`,
CT_REFERENCE_FIELD: `The mentioned Reference field is not Array field reference is '{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}'`,
AUDITING_SPACE: `Auditing assets for space: '{spaceId}'`,
ENTRY_PUBLISH_DETAILS_NOT_EXIST: `The publish_details either does not exist or is not an array for entry uid '{uid}'`,
FIELD_RULE_CONDITION_ABSENT: `The operand field '{condition_field}' is not present in the schema of the content-type {ctUid}`,
FIELD_RULE_TARGET_ABSENT: `The target field '{target_field}' is not present in the schema of the content-type {ctUid}`,
Expand Down
271 changes: 176 additions & 95 deletions packages/contentstack-audit/src/modules/assets.ts

Large diffs are not rendered by default.

25 changes: 20 additions & 5 deletions packages/contentstack-audit/src/modules/modulesData.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { join, resolve } from 'path';
import { existsSync, readFileSync } from 'fs';
import { existsSync, readFileSync, readdirSync } from 'fs';
import { FsUtility, sanitizePath, log } from '@contentstack/cli-utilities';
import { ConfigType, ContentTypeStruct, CtConstructorParam, ModuleConstructorParam } from '../types';
import { keys, values } from 'lodash';
Expand Down Expand Up @@ -46,10 +46,25 @@ export default class ModuleDataReader {
break;
case 'assets': {
log.debug(`Counting assets`, this.config.auditContext);
const assetsPath = join(this.folderPath, 'assets');
log.debug(`Assets path: ${assetsPath}`, this.config.auditContext);
count = (await this.readEntryAssetsModule(assetsPath, 'assets')) || 0;
log.debug(`Assets count: ${count}`, this.config.auditContext);
const spacesDir = join(this.folderPath, 'spaces');
if (existsSync(spacesDir)) {
log.debug(`Multi-space structure detected at: ${spacesDir}`, this.config.auditContext);
const spaceDirs = readdirSync(spacesDir, { withFileTypes: true }).filter(
(entry) => entry.isDirectory() && existsSync(join(spacesDir, entry.name, 'assets')),
);
for (const spaceDir of spaceDirs) {
const spaceAssetsPath = join(spacesDir, spaceDir.name, 'assets');
log.debug(`Counting assets in space: ${spaceDir.name} at ${spaceAssetsPath}`, this.config.auditContext);
const spaceCount = (await this.readEntryAssetsModule(spaceAssetsPath, 'assets')) || 0;
log.debug(`Space ${spaceDir.name} asset count: ${spaceCount}`, this.config.auditContext);
count += spaceCount;
}
} else {
const assetsPath = join(this.folderPath, 'assets');
log.debug(`Flat structure detected, assets path: ${assetsPath}`, this.config.auditContext);
count = (await this.readEntryAssetsModule(assetsPath, 'assets')) || 0;
}
log.debug(`Total assets count: ${count}`, this.config.auditContext);
break;
}
case 'entries':
Expand Down
1 change: 1 addition & 0 deletions packages/contentstack-audit/src/types/content-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ enum OutputColumn {
'publish_locale' = 'publish_locale',
'publish_environment' = 'publish_environment',
'asset_uid' = 'asset_uid',
'space_id' = 'space_id',
'selectedValue' = 'selectedValue',
'fixStatus' = 'fixStatus',
'Content_type_uid' = 'ct_uid',
Expand Down
57 changes: 21 additions & 36 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading