@@ -192,12 +192,19 @@ export function findWranglerToml(
192
192
return findUpSync ( `wrangler.toml` , { cwd : referencePath } ) ;
193
193
}
194
194
195
+ function addLocalSuffix ( id : string , local : boolean = false ) {
196
+ return `${ id } ${ local ? " (local)" : "" } ` ;
197
+ }
198
+
195
199
/**
196
200
* Print all the bindings a worker using a given config would have access to
197
201
*/
198
202
export function printBindings (
199
203
bindings : CfWorkerInit [ "bindings" ] ,
200
- registry ?: WorkerRegistry
204
+ context : {
205
+ registry ?: WorkerRegistry ;
206
+ local ?: boolean ;
207
+ } = { }
201
208
) {
202
209
const truncate = ( item : string | Record < string , unknown > ) => {
203
210
const s = typeof item === "string" ? item : JSON . stringify ( item ) ;
@@ -257,7 +264,7 @@ export function printBindings(
257
264
( { name, class_name, script_name } ) => {
258
265
let value = class_name ;
259
266
if ( script_name ) {
260
- const registryDefinition = registry ?. [ script_name ] ;
267
+ const registryDefinition = context . registry ?. [ script_name ] ;
261
268
if (
262
269
registryDefinition &&
263
270
registryDefinition . durableObjects . some (
@@ -302,7 +309,7 @@ export function printBindings(
302
309
entries : kv_namespaces . map ( ( { binding, id } ) => {
303
310
return {
304
311
key : binding ,
305
- value : id ,
312
+ value : addLocalSuffix ( id , context . local ) ,
306
313
} ;
307
314
} ) ,
308
315
} ) ;
@@ -331,7 +338,7 @@ export function printBindings(
331
338
entries : queues . map ( ( { binding, queue_name } ) => {
332
339
return {
333
340
key : binding ,
334
- value : queue_name ,
341
+ value : addLocalSuffix ( queue_name , context . local ) ,
335
342
} ;
336
343
} ) ,
337
344
} ) ;
@@ -352,7 +359,7 @@ export function printBindings(
352
359
}
353
360
return {
354
361
key : binding ,
355
- value : databaseValue ,
362
+ value : addLocalSuffix ( databaseValue , context . local ) ,
356
363
} ;
357
364
}
358
365
) ,
@@ -365,7 +372,7 @@ export function printBindings(
365
372
entries : vectorize . map ( ( { binding, index_name } ) => {
366
373
return {
367
374
key : binding ,
368
- value : index_name ,
375
+ value : addLocalSuffix ( index_name , context . local ) ,
369
376
} ;
370
377
} ) ,
371
378
} ) ;
@@ -377,7 +384,7 @@ export function printBindings(
377
384
entries : hyperdrive . map ( ( { binding, id } ) => {
378
385
return {
379
386
key : binding ,
380
- value : id ,
387
+ value : addLocalSuffix ( id , context . local ) ,
381
388
} ;
382
389
} ) ,
383
390
} ) ;
@@ -392,7 +399,7 @@ export function printBindings(
392
399
}
393
400
return {
394
401
key : binding ,
395
- value : bucket_name ,
402
+ value : addLocalSuffix ( bucket_name , context . local ) ,
396
403
} ;
397
404
} ) ,
398
405
} ) ;
@@ -419,7 +426,7 @@ export function printBindings(
419
426
value += `#${ entrypoint } ` ;
420
427
}
421
428
422
- const registryDefinition = registry ?. [ service ] ;
429
+ const registryDefinition = context . registry ?. [ service ] ;
423
430
if (
424
431
registryDefinition &&
425
432
( ! entrypoint || registryDefinition . entrypointAddresses ?. [ entrypoint ] )
@@ -478,7 +485,7 @@ export function printBindings(
478
485
479
486
output . push ( {
480
487
type : "AI" ,
481
- entries : entries ,
488
+ entries,
482
489
} ) ;
483
490
}
484
491
@@ -541,7 +548,7 @@ export function printBindings(
541
548
542
549
if ( dispatch_namespaces !== undefined && dispatch_namespaces . length > 0 ) {
543
550
output . push ( {
544
- type : "dispatch namespaces " ,
551
+ type : "Dispatch Namespaces " ,
545
552
entries : dispatch_namespaces . map ( ( { binding, namespace, outbound } ) => {
546
553
return {
547
554
key : binding ,
0 commit comments