@@ -192,12 +192,19 @@ export function findWranglerToml(
192192 return findUpSync ( `wrangler.toml` , { cwd : referencePath } ) ;
193193}
194194
195+ function addLocalSuffix ( id : string , local : boolean = false ) {
196+ return `${ id } ${ local ? " (local)" : "" } ` ;
197+ }
198+
195199/**
196200 * Print all the bindings a worker using a given config would have access to
197201 */
198202export function printBindings (
199203 bindings : CfWorkerInit [ "bindings" ] ,
200- registry ?: WorkerRegistry
204+ context : {
205+ registry ?: WorkerRegistry ;
206+ local ?: boolean ;
207+ } = { }
201208) {
202209 const truncate = ( item : string | Record < string , unknown > ) => {
203210 const s = typeof item === "string" ? item : JSON . stringify ( item ) ;
@@ -257,7 +264,7 @@ export function printBindings(
257264 ( { name, class_name, script_name } ) => {
258265 let value = class_name ;
259266 if ( script_name ) {
260- const registryDefinition = registry ?. [ script_name ] ;
267+ const registryDefinition = context . registry ?. [ script_name ] ;
261268 if (
262269 registryDefinition &&
263270 registryDefinition . durableObjects . some (
@@ -302,7 +309,7 @@ export function printBindings(
302309 entries : kv_namespaces . map ( ( { binding, id } ) => {
303310 return {
304311 key : binding ,
305- value : id ,
312+ value : addLocalSuffix ( id , context . local ) ,
306313 } ;
307314 } ) ,
308315 } ) ;
@@ -331,7 +338,7 @@ export function printBindings(
331338 entries : queues . map ( ( { binding, queue_name } ) => {
332339 return {
333340 key : binding ,
334- value : queue_name ,
341+ value : addLocalSuffix ( queue_name , context . local ) ,
335342 } ;
336343 } ) ,
337344 } ) ;
@@ -352,7 +359,7 @@ export function printBindings(
352359 }
353360 return {
354361 key : binding ,
355- value : databaseValue ,
362+ value : addLocalSuffix ( databaseValue , context . local ) ,
356363 } ;
357364 }
358365 ) ,
@@ -365,7 +372,7 @@ export function printBindings(
365372 entries : vectorize . map ( ( { binding, index_name } ) => {
366373 return {
367374 key : binding ,
368- value : index_name ,
375+ value : addLocalSuffix ( index_name , context . local ) ,
369376 } ;
370377 } ) ,
371378 } ) ;
@@ -377,7 +384,7 @@ export function printBindings(
377384 entries : hyperdrive . map ( ( { binding, id } ) => {
378385 return {
379386 key : binding ,
380- value : id ,
387+ value : addLocalSuffix ( id , context . local ) ,
381388 } ;
382389 } ) ,
383390 } ) ;
@@ -392,7 +399,7 @@ export function printBindings(
392399 }
393400 return {
394401 key : binding ,
395- value : bucket_name ,
402+ value : addLocalSuffix ( bucket_name , context . local ) ,
396403 } ;
397404 } ) ,
398405 } ) ;
@@ -419,7 +426,7 @@ export function printBindings(
419426 value += `#${ entrypoint } ` ;
420427 }
421428
422- const registryDefinition = registry ?. [ service ] ;
429+ const registryDefinition = context . registry ?. [ service ] ;
423430 if (
424431 registryDefinition &&
425432 ( ! entrypoint || registryDefinition . entrypointAddresses ?. [ entrypoint ] )
@@ -478,7 +485,7 @@ export function printBindings(
478485
479486 output . push ( {
480487 type : "AI" ,
481- entries : entries ,
488+ entries,
482489 } ) ;
483490 }
484491
@@ -541,7 +548,7 @@ export function printBindings(
541548
542549 if ( dispatch_namespaces !== undefined && dispatch_namespaces . length > 0 ) {
543550 output . push ( {
544- type : "dispatch namespaces " ,
551+ type : "Dispatch Namespaces " ,
545552 entries : dispatch_namespaces . map ( ( { binding, namespace, outbound } ) => {
546553 return {
547554 key : binding ,
0 commit comments