@@ -25,7 +25,7 @@ import {
2525import { PATH_CONSTANTS } from '../../constants' ;
2626
2727import config from '../../config' ;
28- import { ModuleClassParams } from '../../types' ;
28+ import { ModuleClassParams , GlobalSummary } from '../../types' ;
2929import BaseClass , { CustomPromiseHandler , CustomPromiseHandlerInput } from './base-class' ;
3030import { ExportSpaces , type AssetExportCounts } from '@contentstack/cli-asset-management' ;
3131import {
@@ -38,23 +38,6 @@ import {
3838} from '../../utils' ;
3939import { handle } from '@oclif/core' ;
4040
41- // cli-utilities' CLIProgressManager.globalSummary is runtime-accessible but typed private. These
42- // shapes describe the slice we mutate; the single accessor (getGlobalSummary) owns the structural
43- // cast + feature-detect so applyAssetSummaryCounts and markAssetsSkippedInSummary don't each copy it.
44- type SummaryModuleShape = {
45- status : string ;
46- successCount : number ;
47- failureCount : number ;
48- failures : Array < { item : string ; error : string } > ;
49- endTime ?: number ;
50- } ;
51- type GlobalSummaryShape = {
52- getModules ( ) : Map < string , SummaryModuleShape > ;
53- registerModule ( name : string , totalItems ?: number ) : void ;
54- startModule ( name : string ) : void ;
55- completeModule ( name : string , success ?: boolean ) : void ;
56- } ;
57-
5841export default class ExportAssets extends BaseClass {
5942 private assetsRootPath : string ;
6043 public assetConfig = config . modules . assets ;
@@ -75,14 +58,10 @@ export default class ExportAssets extends BaseClass {
7558 } ;
7659 }
7760
78- /**
79- * cli-utilities' CLIProgressManager.globalSummary is runtime-accessible but typed private. Reach it
80- * via a single structural cast + feature-detect here so both callers share one copy of the
81- * private-shape assumption; returns null (caller degrades) if a future cli-utilities version
82- * changes the shape.
83- */
84- private getGlobalSummary ( ) : GlobalSummaryShape | null {
85- const gs = ( CLIProgressManager as unknown as { globalSummary ?: GlobalSummaryShape | null } ) . globalSummary ;
61+ // globalSummary is runtime-accessible but typed private; feature-detect the shape and return null
62+ // so callers degrade instead of throwing if a future cli-utilities version changes it.
63+ private getGlobalSummary ( ) : GlobalSummary | null {
64+ const gs = ( CLIProgressManager as unknown as { globalSummary ?: GlobalSummary | null } ) . globalSummary ;
8665 if (
8766 ! gs ||
8867 typeof gs . getModules !== 'function' ||
@@ -138,15 +117,9 @@ export default class ExportAssets extends BaseClass {
138117 }
139118 }
140119
141- /**
142- * DX-9314 — record the AM 2.0 asset skip in the FINAL export summary without a live progress bar.
143- * We do NOT call createNestedProgress (it would print an empty "ASSETS:" section); instead we reach
144- * the global summary directly (same structural cast + feature-detect + degrade pattern as
145- * applyAssetSummaryCounts) and push a failure entry so the Module Details row shows `✗ ASSETS` and the
146- * Failure Summary prints the reason verbatim. failureCount stays 0 so the row reads `0/0 items`.
147- * NOTE: this reuses the failure channel deliberately — a first-class "skipped" summary status is a
148- * separate cli-utilities ticket.
149- */
120+ // Records the skip in the final summary via the failure channel, which is the only per-module
121+ // slot carrying a message. createNestedProgress is intentionally not used: it would render an
122+ // empty "ASSETS:" live section.
150123 private markAssetsSkippedInSummary ( reason : string ) : void {
151124 const gs = this . getGlobalSummary ( ) ;
152125 if ( ! gs ) {
@@ -170,24 +143,14 @@ export default class ExportAssets extends BaseClass {
170143 }
171144
172145 async start ( ) : Promise < void > {
173- // AM 2.0 assets cannot be exported with a management token — the CS Assets API only
174- // accepts a logged-in session (auth token / OAuth). Today the linked-workspaces lookup silently
175- // returns [] under a management token, so the export falls back to the legacy layout and import
176- // later reports success with broken entry->asset references. Detect the AM 2.0 org up front via
177- // the plan-check (which DOES accept a management token) and skip the assets module with a loud
178- // warning instead of silently emitting the wrong layout.
179- const amInPlan = this . exportConfig . planStatus ?. [ FEATURE . ASSET_MANAGEMENT ] ?. is_part_of_plan ;
180- if ( amInPlan && this . exportConfig . management_token ) {
146+ const csAssetsInPlan = this . exportConfig . planStatus ?. [ FEATURE . ASSET_MANAGEMENT ] ?. is_part_of_plan ;
147+ if ( csAssetsInPlan && this . exportConfig . management_token ) {
181148 const warning =
182- 'Skipping AM 2.0 asset export: management token authentication is not supported by the Assets APIs. ' +
149+ 'Skipping Contentstack Assets export: management token authentication is not supported by the Assets APIs. ' +
183150 'Entry-to-asset references will NOT resolve in the exported content. ' +
184- 'Re-run the export with a logged-in session (auth token or OAuth) to export AM 2.0 assets .' ;
151+ 'Re-run the export with a logged-in session (auth token or OAuth) to export Contentstack Assets .' ;
185152 cliux . print ( `\nWARNING!!! ${ warning } ` , { color : 'yellow' } ) ;
186- // Log at error level so the reason lands in error.log — the final summary's failure section
187- // points users to the error logs, and a bare warn would leave error.log empty.
188153 log . error ( warning , this . exportConfig . context ) ;
189- // Surface the skip in the FINAL global summary without opening a live progress section
190- // (createNestedProgress would render an empty "ASSETS:" bar). See markAssetsSkippedInSummary.
191154 this . markAssetsSkippedInSummary ( warning ) ;
192155 return ;
193156 }
0 commit comments