@@ -144,17 +144,17 @@ export async function deployCommand(dir: string, anyOptions: unknown) {
144
144
145
145
await printStandloneInitialBanner ( true ) ;
146
146
147
- const { config } = await readConfig ( dir , {
147
+ const resolvedConfig = await readConfig ( dir , {
148
148
configFile : options . data . config ,
149
149
projectRef : options . data . projectRef ,
150
150
} ) ;
151
151
152
- logger . debug ( "Resolved config" , { config } ) ;
152
+ logger . debug ( "Resolved config" , { resolvedConfig } ) ;
153
153
154
154
const apiClient = new CliApiClient ( authorization . config . apiUrl , authorization . config . accessToken ) ;
155
155
156
156
const deploymentEnv = await apiClient . getProjectEnv ( {
157
- projectRef : config . project ,
157
+ projectRef : resolvedConfig . config . project ,
158
158
env : options . data . env ,
159
159
} ) ;
160
160
@@ -168,19 +168,25 @@ export async function deployCommand(dir: string, anyOptions: unknown) {
168
168
) ;
169
169
170
170
intro (
171
- `Preparing to deploy "${ deploymentEnv . data . name } " (${ config . project } ) to ${ options . data . env } `
171
+ `Preparing to deploy "${ deploymentEnv . data . name } " (${ resolvedConfig . config . project } ) to ${ options . data . env } `
172
172
) ;
173
173
174
174
// Step 1: Build the project into a temporary directory
175
- const compilation = await compileProject ( config , options . data ) ;
175
+ const compilation = await compileProject (
176
+ resolvedConfig . config ,
177
+ options . data ,
178
+ resolvedConfig . status === "file" ? resolvedConfig . path : undefined
179
+ ) ;
176
180
177
181
logger . debug ( "Compilation result" , { compilation } ) ;
178
182
179
183
const environmentVariablesSpinner = spinner ( ) ;
180
184
181
185
environmentVariablesSpinner . start ( "Checking environment variables" ) ;
182
186
183
- const environmentVariables = await environmentClient . getEnvironmentVariables ( config . project ) ;
187
+ const environmentVariables = await environmentClient . getEnvironmentVariables (
188
+ resolvedConfig . config . project
189
+ ) ;
184
190
185
191
if ( ! environmentVariables . success ) {
186
192
environmentVariablesSpinner . stop ( `Failed to fetch environment variables, skipping check` ) ;
@@ -197,7 +203,7 @@ export async function deployCommand(dir: string, anyOptions: unknown) {
197
203
) } . Aborting deployment. ${ chalk . bgBlueBright (
198
204
terminalLink (
199
205
"Manage env vars" ,
200
- `${ authorization . config . apiUrl } /projects/v3/${ config . project } /environment-variables`
206
+ `${ authorization . config . apiUrl } /projects/v3/${ resolvedConfig . config . project } /environment-variables`
201
207
)
202
208
) } `
203
209
) ;
@@ -239,11 +245,11 @@ export async function deployCommand(dir: string, anyOptions: unknown) {
239
245
return buildAndPushSelfHostedImage ( {
240
246
imageTag : deploymentResponse . data . imageTag ,
241
247
cwd : compilation . path ,
242
- projectId : config . project ,
248
+ projectId : resolvedConfig . config . project ,
243
249
deploymentId : deploymentResponse . data . id ,
244
250
deploymentVersion : version ,
245
251
contentHash : deploymentResponse . data . contentHash ,
246
- projectRef : config . project ,
252
+ projectRef : resolvedConfig . config . project ,
247
253
buildPlatform : options . data . buildPlatform ,
248
254
} ) ;
249
255
}
@@ -263,11 +269,11 @@ export async function deployCommand(dir: string, anyOptions: unknown) {
263
269
buildToken : deploymentResponse . data . externalBuildData . buildToken ,
264
270
buildProjectId : deploymentResponse . data . externalBuildData . projectId ,
265
271
cwd : compilation . path ,
266
- projectId : config . project ,
272
+ projectId : resolvedConfig . config . project ,
267
273
deploymentId : deploymentResponse . data . id ,
268
274
deploymentVersion : deploymentResponse . data . version ,
269
275
contentHash : deploymentResponse . data . contentHash ,
270
- projectRef : config . project ,
276
+ projectRef : resolvedConfig . config . project ,
271
277
loadImage : options . data . loadImage ,
272
278
buildPlatform : options . data . buildPlatform ,
273
279
} ) ;
@@ -321,7 +327,7 @@ export async function deployCommand(dir: string, anyOptions: unknown) {
321
327
322
328
const deploymentLink = terminalLink (
323
329
"View deployment" ,
324
- `${ authorization . config . apiUrl } /projects/v3/${ config . project } /deployments/${ finishedDeployment . id } `
330
+ `${ authorization . config . apiUrl } /projects/v3/${ resolvedConfig . config . project } /deployments/${ finishedDeployment . id } `
325
331
) ;
326
332
327
333
switch ( finishedDeployment . status ) {
@@ -584,7 +590,11 @@ function extractImageDigest(outputs: string[]) {
584
590
}
585
591
}
586
592
587
- async function compileProject ( config : ResolvedConfig , options : DeployCommandOptions ) {
593
+ async function compileProject (
594
+ config : ResolvedConfig ,
595
+ options : DeployCommandOptions ,
596
+ configPath ?: string
597
+ ) {
588
598
if ( ! options . skipTypecheck ) {
589
599
await typecheckProject ( config , options ) ;
590
600
}
@@ -605,10 +615,24 @@ async function compileProject(config: ResolvedConfig, options: DeployCommandOpti
605
615
importResolve ( "./workers/prod/worker-setup.js" , import . meta. url )
606
616
) . href . replace ( "file://" , "" ) ;
607
617
608
- const workerContents = workerFacade
618
+ let workerContents = workerFacade
609
619
. replace ( "__TASKS__" , createTaskFileImports ( taskFiles ) )
610
620
. replace ( "__WORKER_SETUP__" , `import { tracingSDK } from "${ workerSetupPath } ";` ) ;
611
621
622
+ if ( configPath ) {
623
+ logger . debug ( "Importing project config from" , { configPath } ) ;
624
+
625
+ workerContents = workerContents . replace (
626
+ "__IMPORTED_PROJECT_CONFIG__" ,
627
+ `import importedConfig from "${ configPath } ";`
628
+ ) ;
629
+ } else {
630
+ workerContents = workerContents . replace (
631
+ "__IMPORTED_PROJECT_CONFIG__" ,
632
+ `const importedConfig = undefined;`
633
+ ) ;
634
+ }
635
+
612
636
const result = await build ( {
613
637
stdin : {
614
638
contents : workerContents ,
0 commit comments