55 * For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
66 */
77import * as os from 'os' ;
8- import * as path from 'path' ;
8+ // import * as path from 'path';
99import { flags , FlagsConfig } from '@salesforce/command' ;
1010import { Lifecycle , Messages , SfdxError , SfdxProjectJson } from '@salesforce/core' ;
11- import { SourceRetrieveResult } from '@salesforce/source-deploy-retrieve' ;
11+ // import { SourceRetrieveResult } from '@salesforce/source-deploy-retrieve';
1212import { Duration } from '@salesforce/kit' ;
1313import { asArray , asString } from '@salesforce/ts-types' ;
14- import { blue , yellow } from 'chalk' ;
14+ // import { blue, yellow } from 'chalk';
1515import { SourceCommand } from '../../../sourceCommand' ;
1616
1717Messages . importMessagesDirectory ( __dirname ) ;
@@ -51,7 +51,8 @@ export class retrieve extends SourceCommand {
5151 } ;
5252 protected readonly lifecycleEventNames = [ 'preretrieve' , 'postretrieve' ] ;
5353
54- public async run ( ) : Promise < SourceRetrieveResult > {
54+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
55+ public async run ( ) : Promise < any > {
5556 const hookEmitter = Lifecycle . getInstance ( ) ;
5657
5758 const proj = await SfdxProjectJson . create ( { } ) ;
@@ -70,20 +71,25 @@ export class retrieve extends SourceCommand {
7071 // needs to be a path to the temp dir package.xml
7172 await hookEmitter . emit ( 'preretrieve' , { packageXmlPath : cs . getPackageXml ( ) } ) ;
7273
73- const results = await cs . retrieve ( this . org . getUsername ( ) , path . resolve ( defaultPackage . path ) , {
74- merge : true ,
75- // TODO: fix this once wait has been updated in library
76- wait : ( this . flags . wait as Duration ) . milliseconds ,
77- // TODO: implement retrieve via package name
78- // package: options.packagenames
79- } ) ;
74+ const mdapiResult = await cs
75+ . retrieve ( {
76+ usernameOrConnection : this . org . getUsername ( ) ,
77+ merge : true ,
78+ output : ( this . flags . sourcepath as string ) ?? defaultPackage . path ,
79+ // TODO: fix this once wait has been updated in library
80+ // wait: (this.flags.wait as Duration).milliseconds,
81+ // TODO: implement retrieve via package name
82+ // package: options.packagenames
83+ } )
84+ . start ( ) ;
8085
86+ const results = mdapiResult . response ;
8187 await hookEmitter . emit ( 'postretrieve' , results ) ;
8288
8389 if ( results . status === 'InProgress' ) {
8490 throw new SfdxError ( messages . getMessage ( 'retrieveTimeout' , [ ( this . flags . wait as Duration ) . minutes ] ) ) ;
8591 }
86- this . printTable ( results , true ) ;
92+ // this.printTable(results, true);
8793
8894 return results ;
8995 }
@@ -94,28 +100,28 @@ export class retrieve extends SourceCommand {
94100 * @param results what the .deploy or .retrieve method returns
95101 * @param withoutState a boolean to add state, default to true
96102 */
97- public printTable ( results : SourceRetrieveResult , withoutState ?: boolean ) : void {
98- const stateCol = withoutState ? [ ] : [ { key : 'state' , label : messages . getMessage ( 'stateTableColumn' ) } ] ;
103+ // public printTable(results: SourceRetrieveResult, withoutState?: boolean): void {
104+ // const stateCol = withoutState ? [] : [{ key: 'state', label: messages.getMessage('stateTableColumn') }];
99105
100- this . ux . styledHeader ( blue ( messages . getMessage ( 'retrievedSourceHeader' ) ) ) ;
101- if ( results . success && results . successes . length ) {
102- const columns = [
103- { key : 'properties.fullName' , label : messages . getMessage ( 'fullNameTableColumn' ) } ,
104- { key : 'properties.type' , label : messages . getMessage ( 'typeTableColumn' ) } ,
105- {
106- key : 'properties.fileName' ,
107- label : messages . getMessage ( 'workspacePathTableColumn' ) ,
108- } ,
109- ] ;
110- this . ux . table ( results . successes , { columns : [ ...stateCol , ...columns ] } ) ;
111- } else {
112- this . ux . log ( messages . getMessage ( 'NoResultsFound' ) ) ;
113- }
106+ // this.ux.styledHeader(blue(messages.getMessage('retrievedSourceHeader')));
107+ // if (results.success && results.successes.length) {
108+ // const columns = [
109+ // { key: 'properties.fullName', label: messages.getMessage('fullNameTableColumn') },
110+ // { key: 'properties.type', label: messages.getMessage('typeTableColumn') },
111+ // {
112+ // key: 'properties.fileName',
113+ // label: messages.getMessage('workspacePathTableColumn'),
114+ // },
115+ // ];
116+ // this.ux.table(results.successes, { columns: [...stateCol, ...columns] });
117+ // } else {
118+ // this.ux.log(messages.getMessage('NoResultsFound'));
119+ // }
114120
115- if ( results . status === 'PartialSuccess' && results . successes . length && results . failures . length ) {
116- this . ux . log ( '' ) ;
117- this . ux . styledHeader ( yellow ( messages . getMessage ( 'metadataNotFoundWarning' ) ) ) ;
118- results . failures . forEach ( ( warning ) => this . ux . log ( warning . message ) ) ;
119- }
120- }
121+ // if (results.status === 'PartialSuccess' && results.successes.length && results.failures.length) {
122+ // this.ux.log('');
123+ // this.ux.styledHeader(yellow(messages.getMessage('metadataNotFoundWarning')));
124+ // results.failures.forEach((warning) => this.ux.log(warning.message));
125+ // }
126+ // }
121127}
0 commit comments