@@ -14,6 +14,7 @@ import {
1414 DeployResult ,
1515 FileResponse ,
1616 FileResponseFailure ,
17+ FileResponseSuccess ,
1718 MetadataResolver ,
1819 SourceComponent ,
1920 VirtualTreeContainer ,
@@ -23,7 +24,7 @@ import { ensureArray } from '@salesforce/kit';
2324import { Ux } from '@salesforce/sf-plugins-core' ;
2425import { ResultFormatter , ResultFormatterOptions } from '../resultFormatter.js' ;
2526
26- Messages . importMessagesDirectoryFromMetaUrl ( import . meta. url )
27+ Messages . importMessagesDirectoryFromMetaUrl ( import . meta. url ) ;
2728const messages = Messages . loadMessages ( '@salesforce/plugin-source' , 'push' ) ;
2829
2930export type PushResponse = {
@@ -132,33 +133,32 @@ export class PushResultFormatter extends ResultFormatter {
132133 }
133134 // "content" property of the bundles as a string
134135 const contentFilePathFromDeployedBundles = this . componentsFromFilenames (
135- // the .filter(isString) should ensure only strings are present, but TS isn't finding that
136- bundlesDeployed . map ( ( fileResponse ) => fileResponse . filePath as string )
136+ bundlesDeployed . map ( ( fileResponse ) => fileResponse . filePath ) . filter ( isString )
137137 )
138138 . map ( ( c ) => c . content )
139139 . filter ( isString ) ;
140140
141141 // there may be deletes not represented in the file responses (if bundle type)
142142 const resolver = new MetadataResolver ( undefined , VirtualTreeContainer . fromFilePaths ( this . deletes ) ) ;
143- return (
144- this . deletes
145- . map ( ( filePath ) => {
146- const cmp = this . resolveComponentsOrWarn ( filePath , resolver ) [ 0 ] ;
147- if (
148- cmp . type . strategies ?. adapter === 'bundle' &&
149- contentFilePathFromDeployedBundles . includes ( pathResolve ( cmp . content ?? '' ) )
150- ) {
151- return {
152- state : ComponentStatus . Deleted ,
153- fullName : cmp . fullName ,
154- type : cmp . type . name ,
155- filePath ,
156- } as FileResponse ;
157- }
158- } )
159- . filter ( ( fileResponse ) => fileResponse )
160- // we can be sure there's no undefined responses because of the filter above
161- . concat ( withoutUnchanged ) as FileResponse [ ]
143+
144+ return withoutUnchanged . concat (
145+ this . deletes . flatMap ( ( filePath ) =>
146+ this . resolveComponentsOrWarn ( filePath , resolver )
147+ . filter (
148+ ( cmp ) =>
149+ cmp . type . strategies ?. adapter === 'bundle' &&
150+ contentFilePathFromDeployedBundles . includes ( pathResolve ( cmp . content ?? '' ) )
151+ )
152+ . map (
153+ ( cmp ) =>
154+ ( {
155+ state : ComponentStatus . Deleted ,
156+ fullName : cmp . fullName ,
157+ type : cmp . type . name ,
158+ filePath ,
159+ } satisfies FileResponseSuccess )
160+ )
161+ )
162162 ) ;
163163 }
164164
0 commit comments