Feature branch for Asset scanning v2 - #294
Conversation
feat: add support for asset scaning in import command
feat: add asset scanning support
feat: enhance bulk asset operations with data-dir support and user prompts
…nto feat/Asset-Scanning
fix: minor fixes in asset scanning flow
🔒 Security Scan Results
⏱️ SLA Breach Summary
ℹ️ Vulnerabilities Without Available Fixes (Informational Only)The following vulnerabilities were detected but do not have fixes available (no upgrade or patch). These are excluded from failure thresholds:
Consider reviewing these vulnerabilities when fixes become available. |
Feat/asset scanning plan check
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
|
Approved |
There was a problem hiding this comment.
🟡 Changes recommended
It includes a broken .talismanrc structure plus an unused method and lacks unit tests for the newly introduced data-dir scanning logic.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
This review doesn't count toward merge requirements. Sign up for the private preview to control whether Copilot approvals count.
Pull request overview
This PR extends the Contentstack CLI plugins to support “Asset scanning v2” behaviors by wiring plan/feature checks into import/export flows and adding scan-status-aware bulk asset publishing, including a new --data-dir publish mode for post-import publishing once scanning completes.
Changes:
- Add plan-protected feature handling for
assetsScanand propagate plan status into import/export configs. - Update import assets flow to skip publishing when asset scanning is enabled and print follow-up bulk publish guidance.
- Enhance bulk asset operations to fetch/include asset scan status, skip pending/quarantined assets, and add a streaming
--data-dirpublish flow (plus--dry-run).
File summaries
| File | Description |
|---|---|
| pnpm-lock.yaml | Dependency lock updates to support the new/updated functionality. |
| packages/contentstack-import/src/utils/import-config-handler.ts | Adds deferred plan checks and sets import flags for asset scanning. |
| packages/contentstack-import/src/types/import-config.ts | Extends import config with plan status and asset scanning flags. |
| packages/contentstack-import/src/import/modules/assets.ts | Adjusts assets import messaging/behavior based on plan scanning status. |
| packages/contentstack-import/src/import/module-importer.ts | Adds (currently unused) org plan feature detection helper. |
| packages/contentstack-import/src/commands/cm/stacks/import.ts | Passes command context into import config and prints scan follow-up guidance. |
| packages/contentstack-import/package.json | Declares assetsScan as a plan-protected feature for the import plugin. |
| packages/contentstack-export/src/utils/export-config-handler.ts | Minor formatting adjustment while preserving deferred plan check behavior. |
| packages/contentstack-export/package.json | Adds assetsScan alongside amAssets to plan-protected features. |
| packages/contentstack-bulk-operations/test/unit/services/bulk-operation-service.test.ts | Updates expectations for new bulk payload validation behavior. |
| packages/contentstack-bulk-operations/src/utils/item-fetcher.ts | Includes _asset_scan_status when building asset items. |
| packages/contentstack-bulk-operations/src/utils/interactive.ts | Skips env/locale prompts when --data-dir selects the backup-driven flow. |
| packages/contentstack-bulk-operations/src/utils/index.ts | Exports new helpers for scan/status + data-dir scanning. |
| packages/contentstack-bulk-operations/src/utils/helpers.ts | Adds categorizeByScanStatus helper for scan-status filtering. |
| packages/contentstack-bulk-operations/src/utils/data-dir-asset-fetcher.ts | New pass-1 scanner to summarize backup directory publishability before enqueueing. |
| packages/contentstack-bulk-operations/src/utils/config-builder.ts | Adds dataDir/dryRun to config and relaxes env/locale validation for data-dir mode. |
| packages/contentstack-bulk-operations/src/utils/batch-queue-handler.ts | Passes batch env/locales into bulk publish submission and adjusts batch logging. |
| packages/contentstack-bulk-operations/src/services/bulk-operation-service.ts | Threads env/locale overrides into payload creation and adds validation errors. |
| packages/contentstack-bulk-operations/src/services/asset-service.ts | Adds scan-status inclusion in queries and a helper to fetch scan status by UID batches. |
| packages/contentstack-bulk-operations/src/messages/index.ts | Adds new message strings for scan-status dashboards and data-dir flow messaging. |
| packages/contentstack-bulk-operations/src/interfaces/index.ts | Extends interfaces with scan status and new data-dir/dry-run flags. |
| packages/contentstack-bulk-operations/src/commands/cm/stacks/bulk-assets.ts | Adds streaming --data-dir publish flow and scan-status-aware filtering/dashboarding. |
| packages/contentstack-bulk-operations/src/base-bulk-command.ts | Exposes batchResults to subclasses and allows overriding interactive flag resolution. |
| packages/contentstack-apps-cli/package.json | Formatting-only JSON change. |
| .talismanrc | Updates ignore list (but currently has invalid structure that needs correction). |
Review details
Files not reviewed (1)
- pnpm-lock.yaml: Generated file
- Files reviewed: 23/25 changed files
- Comments generated: 3
- Review effort level: Lite
We're testing this review assessment. Please use 👍 or 👎 to tell us if it's correct.
| fileignoreconfig: | ||
| - filename: pnpm-lock.yaml | ||
| checksum: a90a8f0dbfa98da53ecb9e63f021ae8a1ac44c03cfe5dccd52a539c948d1625a | ||
| - filename: packages/contentstack-export/src/utils/export-config-handler.ts | ||
| checksum: 3ff8e8ea60f92311f8224bce457f7aaab026194de61e13eebdc6ca5a39f66bc9 | ||
| - filename: packages/contentstack-asset-management/src/utils/export-helpers.ts | ||
| checksum: 726d1632110ebc203ce70dc1cbe7d4b3011f56349ed371b6645d0375e7818cad | ||
| - filename: packages/contentstack-asset-management/src/utils/cs-assets-api-adapter.ts | ||
| checksum: bc4a53f96be6a10786e00133245c7bdc43c965c8a98b753e3879e1110cf9c601 | ||
| - filename: packages/contentstack-asset-management/test/unit/utils/cs-assets-api-adapter.test.ts | ||
| checksum: 63c6bff4d51842d8fa3cce88545259d0a2c3cfe71df95d303d993f692cee883b | ||
| version: '1.0' | ||
| checksum: e37e3f40d68a726bd19d13f93cfc1279d726f1509b9bfbffcdf657df4efad70b | ||
| - filename: packages/contentstack-import/src/import/modules/assets.ts | ||
| checksum: f00f743e50ddc040e79e40677bfd2f220b55bab02d8924265cb2c0ef508e9008 | ||
| - filename: packages/contentstack-import/src/utils/import-config-handler.ts | ||
| checksum: 5b2050b283ea3d990e8ad3207b054c6932b76d2bd82a9f659b287ef11dec9f83 | ||
| version: "" |
| private async detectAssetScanning(orgUid: string): Promise<boolean> { | ||
| try { | ||
| const orgDetails = await this.managementAPIClient.organization(orgUid).fetch({ include_plan: true }); | ||
| const features: Array<{ uid: string; enabled?: boolean }> = orgDetails?.plan?.features || []; | ||
| return features.some((f) => (f.uid === 'assetsScan' || f.uid === 'amAssetsScan') && f.enabled === true); | ||
| } catch { | ||
| return false; | ||
| } | ||
| } |
| export async function scanDataDirStats( | ||
| dataDir: string, | ||
| overrideEnvs?: string[], | ||
| overrideLocales?: string[], | ||
| logger?: any | ||
| ): Promise<DataDirScanStats> { | ||
| const assetsIndexPath = path.join(dataDir, 'assets', 'assets.json'); | ||
| const environmentsPath = path.join(dataDir, 'environments', 'environments.json'); | ||
| const assetUidMapperPath = path.join(dataDir, 'mapper', 'assets', 'uid-mapping.json'); |
No description provided.