@@ -112,6 +112,56 @@ export async function deploymentCredentialsOrConfigure(
112
112
teamSlug : string | null ;
113
113
} | null ;
114
114
}
115
+ > {
116
+ const selectedDeployment = await _deploymentCredentialsOrConfigure (
117
+ ctx ,
118
+ deploymentSelection ,
119
+ chosenConfiguration ,
120
+ cmdOptions ,
121
+ partitionId ,
122
+ ) ;
123
+
124
+ if ( selectedDeployment . deploymentFields !== null ) {
125
+ await updateEnvAndConfigForDeploymentSelection (
126
+ ctx ,
127
+ {
128
+ url : selectedDeployment . url ,
129
+ deploymentName : selectedDeployment . deploymentFields . deploymentName ,
130
+ teamSlug : selectedDeployment . deploymentFields . teamSlug ,
131
+ projectSlug : selectedDeployment . deploymentFields . projectSlug ,
132
+ deploymentType : selectedDeployment . deploymentFields
133
+ . deploymentType as DeploymentType ,
134
+ } ,
135
+ deploymentNameFromSelection ( deploymentSelection ) ,
136
+ ) ;
137
+ } else {
138
+ await handleManuallySetUrlAndAdminKey ( ctx , {
139
+ url : selectedDeployment . url ,
140
+ adminKey : selectedDeployment . adminKey ,
141
+ } ) ;
142
+ }
143
+ return {
144
+ url : selectedDeployment . url ,
145
+ adminKey : selectedDeployment . adminKey ,
146
+ deploymentFields : selectedDeployment . deploymentFields ,
147
+ } ;
148
+ }
149
+
150
+ export async function _deploymentCredentialsOrConfigure (
151
+ ctx : Context ,
152
+ deploymentSelection : DeploymentSelection ,
153
+ chosenConfiguration : ChosenConfiguration ,
154
+ cmdOptions : ConfigureCmdOptions ,
155
+ partitionId ?: number | undefined ,
156
+ ) : Promise <
157
+ DeploymentCredentials & {
158
+ deploymentFields : {
159
+ deploymentName : DeploymentName ;
160
+ deploymentType : string ;
161
+ projectSlug : string | null ;
162
+ teamSlug : string | null ;
163
+ } | null ;
164
+ }
115
165
> {
116
166
const config = readGlobalConfig ( ctx ) ;
117
167
const globallyForceCloud = ! ! config ?. optOutOfLocalDevDeploymentsUntilBetaOver ;
@@ -174,12 +224,7 @@ export async function deploymentCredentialsOrConfigure(
174
224
overrideAuthUsername : cmdOptions . overrideAuthUsername ,
175
225
overrideAuthPassword : cmdOptions . overrideAuthPassword ,
176
226
} ) ;
177
- const accessResult = await checkAccessToSelectedProject (
178
- ctx ,
179
- deploymentSelection . targetProject ,
180
- ) ;
181
- if ( accessResult . kind === "noAccess" ) {
182
- logMessage ( ctx , "You don't have access to the selected project." ) ;
227
+ if ( chosenConfiguration !== null ) {
183
228
const result = await handleChooseProject (
184
229
ctx ,
185
230
chosenConfiguration ,
@@ -191,7 +236,13 @@ export async function deploymentCredentialsOrConfigure(
191
236
) ;
192
237
return result ;
193
238
}
194
- if ( chosenConfiguration === "new" ) {
239
+
240
+ const accessResult = await checkAccessToSelectedProject (
241
+ ctx ,
242
+ deploymentSelection . targetProject ,
243
+ ) ;
244
+ if ( accessResult . kind === "noAccess" ) {
245
+ logMessage ( ctx , "You don't have access to the selected project." ) ;
195
246
const result = await handleChooseProject (
196
247
ctx ,
197
248
chosenConfiguration ,
@@ -211,33 +262,17 @@ export async function deploymentCredentialsOrConfigure(
211
262
// We'll start running it below
212
263
{ ensureLocalRunning : false } ,
213
264
) ;
214
-
215
- if ( selectedDeployment . deploymentFields !== null ) {
216
- await updateEnvAndConfigForDeploymentSelection (
217
- ctx ,
218
- {
219
- url : selectedDeployment . url ,
220
- deploymentName : selectedDeployment . deploymentFields . deploymentName ,
221
- teamSlug : selectedDeployment . deploymentFields . teamSlug ,
222
- projectSlug : selectedDeployment . deploymentFields . projectSlug ,
223
- deploymentType : selectedDeployment . deploymentFields
224
- . deploymentType as DeploymentType ,
225
- } ,
226
- deploymentNameFromSelection ( deploymentSelection ) ,
227
- ) ;
228
- if (
229
- selectedDeployment . deploymentFields !== null &&
230
- selectedDeployment . deploymentFields . deploymentType === "local"
231
- ) {
232
- await handleLocalDeployment ( ctx , {
233
- teamSlug : selectedDeployment . deploymentFields . teamSlug ! ,
234
- projectSlug : selectedDeployment . deploymentFields . projectSlug ! ,
235
- forceUpgrade : cmdOptions . localOptions . forceUpgrade ,
236
- ports : cmdOptions . localOptions . ports ,
237
- backendVersion : cmdOptions . localOptions . backendVersion ,
238
- } ) ;
239
- }
240
- return selectedDeployment ;
265
+ if (
266
+ selectedDeployment . deploymentFields !== null &&
267
+ selectedDeployment . deploymentFields . deploymentType === "local"
268
+ ) {
269
+ await handleLocalDeployment ( ctx , {
270
+ teamSlug : selectedDeployment . deploymentFields . teamSlug ! ,
271
+ projectSlug : selectedDeployment . deploymentFields . projectSlug ! ,
272
+ forceUpgrade : cmdOptions . localOptions . forceUpgrade ,
273
+ ports : cmdOptions . localOptions . ports ,
274
+ backendVersion : cmdOptions . localOptions . backendVersion ,
275
+ } ) ;
241
276
}
242
277
return {
243
278
url : selectedDeployment . url ,
@@ -299,17 +334,6 @@ async function handleChooseProject(
299
334
deploymentOptions,
300
335
partitionId : args . partitionId ,
301
336
} ) ;
302
- await updateEnvAndConfigForDeploymentSelection (
303
- ctx ,
304
- {
305
- url,
306
- deploymentName,
307
- teamSlug : project . teamSlug ,
308
- projectSlug : project . projectSlug ,
309
- deploymentType : deploymentOptions . kind ,
310
- } ,
311
- null ,
312
- ) ;
313
337
return {
314
338
url,
315
339
adminKey,
0 commit comments