8
8
import { Command , Flags } from '@oclif/core' ;
9
9
import { fs , Messages } from '@salesforce/core' ;
10
10
import { Env } from '@salesforce/kit' ;
11
- import {
12
- Deployable ,
13
- Deployer ,
14
- generateTableChoices ,
15
- DeployOptions ,
16
- Prompter ,
17
- } from '@salesforce/plugin-deploy-retrieve-utils' ;
11
+ import { Deployable , Deployer , generateTableChoices , Prompter , SfHook } from '@salesforce/sf-plugins-core' ;
18
12
19
13
Messages . importMessagesDirectory ( __dirname ) ;
20
14
@@ -47,8 +41,9 @@ export default class Deploy extends Command {
47
41
this . log ( `Using options found in ${ DEPLOY_OPTIONS_FILE } ` ) ;
48
42
}
49
43
50
- let deployers = ( await this . config . runHook ( 'project:findDeployers' , options ) ) as Deployer [ ] ;
51
- deployers = deployers . reduce ( ( x , y ) => x . concat ( y ) , [ ] as Deployer [ ] ) ;
44
+ const hookResults = await SfHook . run ( this . config , 'sf:deploy' , options ) ;
45
+
46
+ let deployers = hookResults . successes . flatMap ( ( s ) => s . result ) ;
52
47
53
48
if ( deployers . length === 0 ) {
54
49
this . log ( 'Found nothing in the project to deploy' ) ;
@@ -61,7 +56,7 @@ export default class Deploy extends Command {
61
56
this . log ( 'Nothing was selected to deploy.' ) ;
62
57
}
63
58
64
- const deployOptions : DeployOptions = { } ;
59
+ const deployOptions : Deployer . Options = { } ;
65
60
for ( const deployer of deployers ) {
66
61
const opts = options [ deployer . getName ( ) ] ?? { } ;
67
62
deployOptions [ deployer . getName ( ) ] = await deployer . setup ( flags , opts ) ;
@@ -89,9 +84,9 @@ export default class Deploy extends Command {
89
84
return deployFileExists ? false : true ;
90
85
}
91
86
92
- public async readOptions ( ) : Promise < DeployOptions > {
87
+ public async readOptions ( ) : Promise < Record < string , Deployer . Options > > {
93
88
if ( await fs . fileExists ( DEPLOY_OPTIONS_FILE ) ) {
94
- return ( await fs . readJson ( DEPLOY_OPTIONS_FILE ) ) as DeployOptions ;
89
+ return ( await fs . readJson ( DEPLOY_OPTIONS_FILE ) ) as Record < string , Deployer . Options > ;
95
90
} else {
96
91
return { } ;
97
92
}
@@ -111,9 +106,9 @@ export default class Deploy extends Command {
111
106
const deployables : Deployable [ ] = deployers . reduce ( ( x , y ) => x . concat ( y . deployables ) , [ ] as Deployable [ ] ) ;
112
107
const columns = { name : 'APP OR PACKAGE' , type : 'TYPE' , path : 'PATH' } ;
113
108
const options = deployables . map ( ( deployable ) => ( {
114
- name : deployable . getAppName ( ) ,
115
- type : deployable . getAppType ( ) ,
116
- path : deployable . getAppPath ( ) ,
109
+ name : deployable . getName ( ) ,
110
+ type : deployable . getType ( ) ,
111
+ path : deployable . getPath ( ) ,
117
112
value : deployable ,
118
113
} ) ) ;
119
114
const prompter = new Prompter ( ) ;
@@ -138,7 +133,7 @@ export default class Deploy extends Command {
138
133
}
139
134
140
135
const final : Deployer [ ] = [ ] ;
141
- for ( const [ parent , children ] of chosenDeployers . entries ( ) ) {
136
+ for ( const [ parent , children ] of Array . from ( chosenDeployers . entries ( ) ) ) {
142
137
parent . selectDeployables ( children ) ;
143
138
final . push ( parent ) ;
144
139
}
0 commit comments