@@ -13,7 +13,7 @@ import {
13
13
updateSwaCliConfigFile ,
14
14
} from "../../../core" ;
15
15
import { chooseOrCreateProjectDetails , getStaticSiteDeployment } from "../../../core/account" ;
16
- import { DEFAULT_RUNTIME_LANGUAGE } from "../../../core/constants" ;
16
+ import { DEFAULT_RUNTIME_LANGUAGE , STATIC_SITE_CLIENT_WORKING_FOLDER } from "../../../core/constants" ;
17
17
import { cleanUp , getDeployClientPath } from "../../../core/deploy-client" ;
18
18
import { swaCLIEnv } from "../../../core/env" ;
19
19
import { getDefaultVersion } from "../../../core/functions-versions" ;
@@ -63,13 +63,17 @@ export async function deploy(options: SWACLIConfig) {
63
63
}
64
64
}
65
65
66
- // make sure outputLocation is set
67
- const resolvedOutputLocation = path . resolve ( appLocation , outputLocation || process . cwd ( ) ) ;
66
+ logger . silly ( `Resolving outputLocation= ${ outputLocation } full path...` ) ;
67
+ let resolvedOutputLocation = path . resolve ( appLocation , outputLocation as string ) ;
68
68
69
69
// if folder exists, deploy from a specific build folder (outputLocation), relative to appLocation
70
70
if ( ! fs . existsSync ( resolvedOutputLocation ) ) {
71
- logger . error ( `The folder "${ resolvedOutputLocation } " is not found. Exit.` , true ) ;
72
- return ;
71
+ if ( ! fs . existsSync ( outputLocation as string ) ) {
72
+ logger . error ( `The folder "${ resolvedOutputLocation } " is not found. Exit.` , true ) ;
73
+ return ;
74
+ }
75
+ // otherwise, build folder (outputLocation) is using the absolute location
76
+ resolvedOutputLocation = path . resolve ( outputLocation as string ) ;
73
77
}
74
78
75
79
logger . log ( `Deploying front-end files from folder:` ) ;
@@ -240,8 +244,8 @@ export async function deploy(options: SWACLIConfig) {
240
244
DEPLOYMENT_TOKEN : deploymentToken ,
241
245
// /!\ Static site client doesn't use OUTPUT_LOCATION at all if SKIP_APP_BUILD is set,
242
246
// so you need to provide the output path as the app location
243
- APP_LOCATION : userWorkflowConfig ?. appLocation ,
244
- OUTPUT_LOCATION : userWorkflowConfig ?. outputLocation ,
247
+ APP_LOCATION : userWorkflowConfig ?. outputLocation ,
248
+ // OUTPUT_LOCATION: outputLocation,
245
249
API_LOCATION : userWorkflowConfig ?. apiLocation ,
246
250
DATA_API_LOCATION : userWorkflowConfig ?. dataApiLocation ,
247
251
// If config file is not in output location, we need to tell where to find it
@@ -251,6 +255,11 @@ export async function deploy(options: SWACLIConfig) {
251
255
FUNCTION_LANGUAGE_VERSION : apiVersion ,
252
256
} ;
253
257
258
+ const clientWorkingDir = path . resolve ( deployClientEnv . REPOSITORY_BASE ?? "" , STATIC_SITE_CLIENT_WORKING_FOLDER ) ;
259
+ if ( ! fs . existsSync ( clientWorkingDir ) ) {
260
+ fs . mkdirSync ( clientWorkingDir ) ;
261
+ }
262
+
254
263
// set the DEPLOYMENT_ENVIRONMENT env variable only when the user has provided
255
264
// a deployment environment which is not "production".
256
265
if ( options . env ?. toLowerCase ( ) !== "production" && options . env ?. toLowerCase ( ) !== "prod" ) {
@@ -271,15 +280,15 @@ export async function deploy(options: SWACLIConfig) {
271
280
logger . silly ( `Deploying using ${ cliEnv . SWA_CLI_DEPLOY_BINARY } ` ) ;
272
281
logger . silly ( `Deploying using the following options:` ) ;
273
282
logger . silly ( { env : { ...cliEnv , ...deployClientEnv } } ) ;
274
- logger . silly ( `StaticSiteClient working directory: ${ path . dirname ( userWorkflowConfig ?. appLocation ! ) } ` ) ;
283
+ logger . silly ( `StaticSiteClient working directory: ${ clientWorkingDir } ` ) ;
275
284
276
285
spinner . start ( `Preparing deployment. Please wait...` ) ;
277
286
278
287
const child = spawn ( binary , [ ] , {
279
288
env : {
280
289
...swaCLIEnv ( cliEnv , deployClientEnv ) ,
281
290
} ,
282
- cwd : path . dirname ( userWorkflowConfig ?. appLocation ! ) ,
291
+ cwd : clientWorkingDir ,
283
292
} ) ;
284
293
285
294
let projectUrl = "" ;
@@ -321,7 +330,7 @@ export async function deploy(options: SWACLIConfig) {
321
330
} ) ;
322
331
323
332
child . on ( "close" , ( code ) => {
324
- cleanUp ( ) ;
333
+ cleanUp ( clientWorkingDir ) ;
325
334
326
335
if ( code === 0 ) {
327
336
spinner . succeed ( chalk . green ( `Project deployed to ${ chalk . underline ( projectUrl ) } 🚀` ) ) ;
@@ -338,7 +347,7 @@ export async function deploy(options: SWACLIConfig) {
338
347
) ;
339
348
logGitHubIssueMessageAndExit ( ) ;
340
349
} finally {
341
- cleanUp ( ) ;
350
+ cleanUp ( clientWorkingDir ) ;
342
351
}
343
352
}
344
353
0 commit comments