wrangler 2.0.26 → 2.0.29

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/bin/wrangler.js +1 -1
  2. package/miniflare-dist/index.mjs +54 -46
  3. package/package.json +6 -4
  4. package/src/__tests__/api-dev.test.ts +19 -0
  5. package/src/__tests__/configuration.test.ts +33 -29
  6. package/src/__tests__/dev.test.tsx +8 -6
  7. package/src/__tests__/generate.test.ts +2 -4
  8. package/src/__tests__/helpers/hello-world-worker.js +5 -0
  9. package/src/__tests__/helpers/mock-get-zone-from-host.ts +8 -0
  10. package/src/__tests__/helpers/mock-known-routes.ts +7 -0
  11. package/src/__tests__/index.test.ts +30 -30
  12. package/src/__tests__/jest.setup.ts +17 -0
  13. package/src/__tests__/metrics.test.ts +1 -1
  14. package/src/__tests__/pages.test.ts +829 -103
  15. package/src/__tests__/paths.test.ts +17 -0
  16. package/src/__tests__/publish.test.ts +59 -18
  17. package/src/__tests__/r2.test.ts +4 -3
  18. package/src/__tests__/tail.test.ts +34 -0
  19. package/src/__tests__/test-old-node-version.js +3 -3
  20. package/src/__tests__/user.test.ts +11 -0
  21. package/src/__tests__/worker-namespace.test.ts +37 -35
  22. package/src/api/dev.ts +74 -28
  23. package/src/bundle.ts +14 -11
  24. package/src/cfetch/internal.ts +81 -3
  25. package/src/cli.ts +1 -1
  26. package/src/config/environment.ts +1 -1
  27. package/src/config/index.ts +4 -4
  28. package/src/config/validation-helpers.ts +19 -6
  29. package/src/config/validation.ts +11 -5
  30. package/src/config-cache.ts +2 -1
  31. package/src/create-worker-upload-form.ts +29 -26
  32. package/src/dev/local.tsx +317 -169
  33. package/src/dev/remote.tsx +10 -1
  34. package/src/dev/start-server.ts +412 -0
  35. package/src/dev.tsx +341 -157
  36. package/src/{worker-namespace.ts → dispatch-namespace.ts} +18 -18
  37. package/src/entry.ts +2 -1
  38. package/src/generate.ts +1 -1
  39. package/src/index.tsx +54 -8
  40. package/src/init.ts +5 -5
  41. package/src/{metrics/is-ci.ts → is-ci.ts} +0 -0
  42. package/src/metrics/metrics-config.ts +1 -1
  43. package/src/metrics/send-event.ts +6 -5
  44. package/src/miniflare-cli/assets.ts +4 -65
  45. package/src/miniflare-cli/index.ts +36 -32
  46. package/src/pages/constants.ts +3 -0
  47. package/src/pages/dev.tsx +10 -15
  48. package/src/pages/functions/buildPlugin.ts +2 -1
  49. package/src/pages/functions/buildWorker.ts +2 -1
  50. package/src/pages/functions/routes-transformation.test.ts +12 -1
  51. package/src/pages/functions/routes-transformation.ts +7 -1
  52. package/src/pages/publish.tsx +82 -38
  53. package/src/paths.ts +20 -1
  54. package/src/proxy.ts +10 -0
  55. package/src/publish.ts +19 -4
  56. package/src/r2.ts +4 -4
  57. package/src/user/user.tsx +6 -4
  58. package/src/whoami.tsx +5 -5
  59. package/src/worker.ts +10 -9
  60. package/src/zones.ts +91 -0
  61. package/wrangler-dist/cli.d.ts +22 -8
  62. package/wrangler-dist/cli.js +7757 -2315
package/src/dev.tsx CHANGED
@@ -8,6 +8,7 @@ import { findWranglerToml, printBindings, readConfig } from "./config";
8
8
  import Dev from "./dev/dev";
9
9
  import { getVarsForDev } from "./dev/dev-vars";
10
10
 
11
+ import { startDevServer } from "./dev/start-server";
11
12
  import { getEntry } from "./entry";
12
13
  import { logger } from "./logger";
13
14
  import * as metrics from "./metrics";
@@ -63,6 +64,8 @@ interface DevArgs {
63
64
  tsconfig?: string;
64
65
  local?: boolean;
65
66
  minify?: boolean;
67
+ var?: string[];
68
+ define?: string[];
66
69
  "node-compat"?: boolean;
67
70
  "experimental-enable-local-persistence"?: boolean;
68
71
  "live-reload"?: boolean;
@@ -129,7 +132,6 @@ export function devOptions(yargs: Argv): Argv<DevArgs> {
129
132
  .option("ip", {
130
133
  describe: "IP address to listen on",
131
134
  type: "string",
132
- default: "0.0.0.0",
133
135
  })
134
136
  .option("port", {
135
137
  describe: "Port to listen on",
@@ -196,6 +198,19 @@ export function devOptions(yargs: Argv): Argv<DevArgs> {
196
198
  describe: "Protocol to forward requests to host on, defaults to https.",
197
199
  choices: ["http", "https"] as const,
198
200
  })
201
+ .option("var", {
202
+ describe:
203
+ "A key-value pair to be injected into the script as a variable",
204
+ type: "string",
205
+ requiresArg: true,
206
+ array: true,
207
+ })
208
+ .option("define", {
209
+ describe: "A key-value pair to be substituted in the script",
210
+ type: "string",
211
+ requiresArg: true,
212
+ array: true,
213
+ })
199
214
  .option("jsx-factory", {
200
215
  describe: "The function that is called for each JSX element",
201
216
  type: "string",
@@ -319,11 +334,17 @@ export async function startDev(args: StartDevOptions) {
319
334
  });
320
335
  }
321
336
 
322
- const entry = await getEntry(
323
- { assets: args.assets, script: args.script },
324
- config,
325
- "dev"
326
- );
337
+ const {
338
+ entry,
339
+ nodeCompat,
340
+ upstreamProtocol,
341
+ zoneId,
342
+ host,
343
+ routes,
344
+ getLocalPort,
345
+ getInspectorPort,
346
+ cliDefines,
347
+ } = await validateDevServerSettings(args, config);
327
348
 
328
349
  await metrics.sendMetricsEvent(
329
350
  "run dev",
@@ -334,182 +355,60 @@ export async function startDev(args: StartDevOptions) {
334
355
  { sendMetrics: config.send_metrics, offline: args.local }
335
356
  );
336
357
 
337
- if (config.services && config.services.length > 0) {
338
- logger.warn(
339
- `This worker is bound to live services: ${config.services
340
- .map(
341
- (service) =>
342
- `${service.binding} (${service.service}${
343
- service.environment ? `@${service.environment}` : ""
344
- })`
345
- )
346
- .join(", ")}`
347
- );
348
- }
349
-
350
- if (args.inspect) {
351
- //devtools are enabled by default, but we still need to disable them if the caller doesn't want them
352
- logger.warn(
353
- "Passing --inspect is unnecessary, now you can always connect to devtools."
354
- );
355
- }
356
-
357
- if (args["experimental-public"]) {
358
- throw new Error(
359
- "The --experimental-public field has been renamed to --assets"
360
- );
361
- }
362
-
363
- if (args.public) {
364
- throw new Error("The --public field has been renamed to --assets");
365
- }
366
-
367
- if ((args.assets || config.assets) && (args.site || config.site)) {
368
- throw new Error(
369
- "Cannot use Assets and Workers Sites in the same Worker."
370
- );
371
- }
372
-
373
- if (args.assets) {
374
- logger.warn(
375
- "The --assets argument is experimental and may change or break at any time"
376
- );
377
- }
378
-
379
- const upstreamProtocol =
380
- args["upstream-protocol"] || config.dev.upstream_protocol;
381
- if (upstreamProtocol === "http") {
382
- logger.warn(
383
- "Setting upstream-protocol to http is not currently implemented.\n" +
384
- "If this is required in your project, please add your use case to the following issue:\n" +
385
- "https://github.com/cloudflare/wrangler2/issues/583."
386
- );
387
- }
388
-
389
- // TODO: if worker_dev = false and no routes, then error (only for dev)
390
-
391
- // Compute zone info from the `host` and `route` args and config;
392
- let host = args.host || config.dev.host;
393
- let zoneId: string | undefined;
394
- const routes: Route[] | undefined =
395
- args.routes || (config.route && [config.route]) || config.routes;
396
-
397
- if (args.forceLocal) {
398
- args.local = true;
399
- }
400
-
401
- if (!args.local) {
402
- if (host) {
403
- zoneId = await getZoneIdFromHost(host);
404
- }
405
- if (!zoneId && routes) {
406
- const firstRoute = routes[0];
407
- const zone = await getZoneForRoute(firstRoute);
408
- if (zone) {
409
- zoneId = zone.id;
410
- host = zone.host;
411
- }
412
- }
413
- } else if (!host) {
414
- if (routes) {
415
- const firstRoute = routes[0];
416
- host = getHostFromRoute(firstRoute);
417
- }
418
- }
419
-
420
- const nodeCompat = args.nodeCompat ?? config.node_compat;
421
- if (nodeCompat) {
422
- logger.warn(
423
- "Enabling node.js compatibility mode for built-ins and globals. This is experimental and has serious tradeoffs. Please see https://github.com/ionic-team/rollup-plugin-node-polyfills/ for more details."
424
- );
425
- }
426
-
427
- const getLocalPort = memoizeGetPort(DEFAULT_LOCAL_PORT);
428
- const getInspectorPort = memoizeGetPort(DEFAULT_INSPECTOR_PORT);
429
-
430
358
  // eslint-disable-next-line no-inner-declarations
431
359
  async function getDevReactElement(configParam: Config) {
432
- // now log all available bindings into the terminal
433
- const bindings = await getBindings(configParam, {
434
- kv: args.kv,
435
- vars: args.vars,
436
- durableObjects: args.durableObjects,
437
- r2: args.r2,
438
- });
439
-
440
- // mask anything that was overridden in .dev.vars
441
- // so that we don't log potential secrets into the terminal
442
- const maskedVars = { ...bindings.vars };
443
- for (const key of Object.keys(maskedVars)) {
444
- if (maskedVars[key] !== configParam.vars[key]) {
445
- // This means it was overridden in .dev.vars
446
- // so let's mask it
447
- maskedVars[key] = "(hidden)";
448
- }
449
- }
450
-
451
- printBindings({
452
- ...bindings,
453
- vars: maskedVars,
454
- });
455
-
456
- const assetPaths =
457
- args.assets || config.assets
458
- ? getAssetPaths(config, args.assets)
459
- : getSiteAssetPaths(
460
- config,
461
- args.site,
462
- args.siteInclude,
463
- args.siteExclude
464
- );
360
+ const { assetPaths, bindings } = await getBindingsAndAssetPaths(
361
+ args,
362
+ configParam
363
+ );
465
364
 
466
365
  return (
467
366
  <Dev
468
- name={getScriptName({ name: args.name, env: args.env }, config)}
469
- noBundle={!(args.bundle ?? !config.no_bundle)}
367
+ name={getScriptName({ name: args.name, env: args.env }, configParam)}
368
+ noBundle={!(args.bundle ?? !configParam.no_bundle)}
470
369
  entry={entry}
471
370
  env={args.env}
472
371
  zone={zoneId}
473
372
  host={host}
474
373
  routes={routes}
475
- rules={getRules(config)}
476
- legacyEnv={isLegacyEnv(config)}
477
- minify={args.minify ?? config.minify}
374
+ rules={getRules(configParam)}
375
+ legacyEnv={isLegacyEnv(configParam)}
376
+ minify={args.minify ?? configParam.minify}
478
377
  nodeCompat={nodeCompat}
479
- build={config.build || {}}
480
- define={config.define}
378
+ build={configParam.build || {}}
379
+ define={{ ...configParam.define, ...cliDefines }}
481
380
  initialMode={args.local ? "local" : "remote"}
482
- jsxFactory={args["jsx-factory"] || config.jsx_factory}
483
- jsxFragment={args["jsx-fragment"] || config.jsx_fragment}
484
- tsconfig={args.tsconfig ?? config.tsconfig}
381
+ jsxFactory={args["jsx-factory"] || configParam.jsx_factory}
382
+ jsxFragment={args["jsx-fragment"] || configParam.jsx_fragment}
383
+ tsconfig={args.tsconfig ?? configParam.tsconfig}
485
384
  upstreamProtocol={upstreamProtocol}
486
- localProtocol={args.localProtocol || config.dev.local_protocol}
385
+ localProtocol={args.localProtocol || configParam.dev.local_protocol}
487
386
  localUpstream={args["local-upstream"] || host}
488
387
  enableLocalPersistence={
489
388
  args.experimentalEnableLocalPersistence || false
490
389
  }
491
390
  liveReload={args.liveReload || false}
492
- accountId={config.account_id || getAccountFromCache()?.id}
391
+ accountId={configParam.account_id || getAccountFromCache()?.id}
493
392
  assetPaths={assetPaths}
494
- assetsConfig={config.assets}
495
- port={args.port || config.dev.port || (await getLocalPort())}
496
- ip={args.ip || config.dev.ip}
393
+ assetsConfig={configParam.assets}
394
+ port={args.port || configParam.dev.port || (await getLocalPort())}
395
+ ip={args.ip || configParam.dev.ip}
497
396
  inspectorPort={
498
397
  args.inspectorPort ||
499
- config.dev.inspector_port ||
398
+ configParam.dev.inspector_port ||
500
399
  (await getInspectorPort())
501
400
  }
502
- isWorkersSite={Boolean(args.site || config.site)}
401
+ isWorkersSite={Boolean(args.site || configParam.site)}
503
402
  compatibilityDate={getDevCompatibilityDate(
504
- config,
403
+ configParam,
505
404
  args.compatibilityDate
506
405
  )}
507
406
  compatibilityFlags={
508
- args.compatibilityFlags || config.compatibility_flags
407
+ args.compatibilityFlags || configParam.compatibility_flags
509
408
  }
510
- usageModel={config.usage_model}
409
+ usageModel={configParam.usage_model}
511
410
  bindings={bindings}
512
- crons={config.triggers.crons}
411
+ crons={configParam.triggers.crons}
513
412
  logLevel={args.logLevel}
514
413
  logPrefix={args.logPrefix}
515
414
  onReady={args.onReady}
@@ -517,8 +416,8 @@ export async function startDev(args: StartDevOptions) {
517
416
  showInteractiveDevSession={args.showInteractiveDevSession}
518
417
  forceLocal={args.forceLocal}
519
418
  enablePagesAssetsServiceBinding={args.enablePagesAssetsServiceBinding}
520
- firstPartyWorker={config.first_party_worker}
521
- sendMetrics={config.send_metrics}
419
+ firstPartyWorker={configParam.first_party_worker}
420
+ sendMetrics={configParam.send_metrics}
522
421
  />
523
422
  );
524
423
  }
@@ -532,7 +431,6 @@ export async function startDev(args: StartDevOptions) {
532
431
  await watcher?.close();
533
432
  },
534
433
  fetch: async (init?: RequestInit) => {
535
- //TODO: we are not guaranteed to be assigned this port, we should fix this ASAP
536
434
  const port = args.port || config.dev.port || (await getLocalPort());
537
435
  const address = args.ip || config.dev.ip || "localhost";
538
436
 
@@ -544,6 +442,116 @@ export async function startDev(args: StartDevOptions) {
544
442
  }
545
443
  }
546
444
 
445
+ export async function startApiDev(args: StartDevOptions) {
446
+ if (args.logLevel) {
447
+ // we don't define a "none" logLevel, so "error" will do for now.
448
+ logger.loggerLevel = args.logLevel === "none" ? "error" : args.logLevel;
449
+ }
450
+ await printWranglerBanner();
451
+
452
+ const configPath =
453
+ (args.config as ConfigPath) ||
454
+ ((args.script &&
455
+ findWranglerToml(path.dirname(args.script))) as ConfigPath);
456
+ const config = readConfig(configPath, args);
457
+
458
+ const {
459
+ entry,
460
+ nodeCompat,
461
+ upstreamProtocol,
462
+ zoneId,
463
+ host,
464
+ routes,
465
+ getLocalPort,
466
+ getInspectorPort,
467
+ cliDefines,
468
+ } = await validateDevServerSettings(args, config);
469
+
470
+ await metrics.sendMetricsEvent(
471
+ "run dev (api)",
472
+ { local: args.local },
473
+ { sendMetrics: config.send_metrics, offline: args.local }
474
+ );
475
+
476
+ // eslint-disable-next-line no-inner-declarations
477
+ async function getDevServer(configParam: Config) {
478
+ const { assetPaths, bindings } = await getBindingsAndAssetPaths(
479
+ args,
480
+ configParam
481
+ );
482
+
483
+ return await startDevServer({
484
+ name: getScriptName({ name: args.name, env: args.env }, configParam),
485
+ noBundle: !(args.bundle ?? !configParam.no_bundle),
486
+ entry: entry,
487
+ env: args.env,
488
+ zone: zoneId,
489
+ host: host,
490
+ routes: routes,
491
+ rules: getRules(configParam),
492
+ legacyEnv: isLegacyEnv(configParam),
493
+ minify: args.minify ?? configParam.minify,
494
+ nodeCompat: nodeCompat,
495
+ build: configParam.build || {},
496
+ define: { ...config.define, ...cliDefines },
497
+ initialMode: args.local ? "local" : "remote",
498
+ jsxFactory: args["jsx-factory"] || configParam.jsx_factory,
499
+ jsxFragment: args["jsx-fragment"] || configParam.jsx_fragment,
500
+ tsconfig: args.tsconfig ?? configParam.tsconfig,
501
+ upstreamProtocol: upstreamProtocol,
502
+ localProtocol: args.localProtocol || configParam.dev.local_protocol,
503
+ localUpstream: args["local-upstream"] || host,
504
+ enableLocalPersistence: args.experimentalEnableLocalPersistence || false,
505
+ liveReload: args.liveReload || false,
506
+ accountId: configParam.account_id || getAccountFromCache()?.id,
507
+ assetPaths: assetPaths,
508
+ assetsConfig: configParam.assets,
509
+ port: args.port || configParam.dev.port || (await getLocalPort()),
510
+ ip: args.ip || configParam.dev.ip,
511
+ inspectorPort:
512
+ args["inspector-port"] ||
513
+ configParam.dev.inspector_port ||
514
+ (await getInspectorPort()),
515
+ isWorkersSite: Boolean(args.site || configParam.site),
516
+ compatibilityDate: getDevCompatibilityDate(
517
+ config,
518
+ args["compatibility-date"]
519
+ ),
520
+ compatibilityFlags:
521
+ args["compatibility-flags"] || configParam.compatibility_flags,
522
+ usageModel: configParam.usage_model,
523
+ bindings: bindings,
524
+ crons: configParam.triggers.crons,
525
+ logLevel: args.logLevel,
526
+ logPrefix: args.logPrefix,
527
+ onReady: args.onReady,
528
+ inspect: args.inspect ?? true,
529
+ showInteractiveDevSession: args.showInteractiveDevSession,
530
+ forceLocal: args.forceLocal,
531
+ enablePagesAssetsServiceBinding: args.enablePagesAssetsServiceBinding,
532
+ local: true,
533
+ firstPartyWorker: undefined,
534
+ sendMetrics: undefined,
535
+ });
536
+ }
537
+
538
+ const devServer = await getDevServer(config);
539
+ if (!devServer) {
540
+ throw logger.error("Failed to start dev server.");
541
+ }
542
+
543
+ return {
544
+ stop: async () => {
545
+ await devServer.stop();
546
+ },
547
+ fetch: async (init?: RequestInit) => {
548
+ const port = args.port || config.dev.port || (await getLocalPort());
549
+ const address = args.ip || config.dev.ip || "localhost";
550
+
551
+ return await fetch(`http://${address}:${port}/`, init);
552
+ },
553
+ };
554
+ }
547
555
  /**
548
556
  * Avoiding calling `getPort()` multiple times by memoizing the first result.
549
557
  */
@@ -553,6 +561,182 @@ function memoizeGetPort(defaultPort: number) {
553
561
  return portValue || (portValue = await getPort({ port: defaultPort }));
554
562
  };
555
563
  }
564
+ /**
565
+ * mask anything that was overridden in .dev.vars
566
+ * so that we don't log potential secrets into the terminal
567
+ */
568
+ function maskVars(bindings: CfWorkerInit["bindings"], configParam: Config) {
569
+ const maskedVars = { ...bindings.vars };
570
+ for (const key of Object.keys(maskedVars)) {
571
+ if (maskedVars[key] !== configParam.vars[key]) {
572
+ // This means it was overridden in .dev.vars
573
+ // so let's mask it
574
+ maskedVars[key] = "(hidden)";
575
+ }
576
+ }
577
+ return maskedVars;
578
+ }
579
+
580
+ async function getZoneIdHostAndRoutes(args: StartDevOptions, config: Config) {
581
+ // TODO: if worker_dev = false and no routes, then error (only for dev)
582
+ // Compute zone info from the `host` and `route` args and config;
583
+ let host = args.host || config.dev.host;
584
+ let zoneId: string | undefined;
585
+ const routes: Route[] | undefined =
586
+ args.routes || (config.route && [config.route]) || config.routes;
587
+
588
+ if (args.forceLocal) {
589
+ args.local = true;
590
+ }
591
+
592
+ if (!args.local) {
593
+ if (host) {
594
+ zoneId = await getZoneIdFromHost(host);
595
+ }
596
+ if (!zoneId && routes) {
597
+ const firstRoute = routes[0];
598
+ const zone = await getZoneForRoute(firstRoute);
599
+ if (zone) {
600
+ zoneId = zone.id;
601
+ host = zone.host;
602
+ }
603
+ }
604
+ } else if (!host) {
605
+ if (routes) {
606
+ const firstRoute = routes[0];
607
+ host = getHostFromRoute(firstRoute);
608
+ }
609
+ }
610
+ return { host, routes, zoneId };
611
+ }
612
+
613
+ async function validateDevServerSettings(
614
+ args: StartDevOptions,
615
+ config: Config
616
+ ) {
617
+ const entry = await getEntry(
618
+ { assets: args.assets, script: args.script },
619
+ config,
620
+ "dev"
621
+ );
622
+
623
+ const { zoneId, host, routes } = await getZoneIdHostAndRoutes(args, config);
624
+ const getLocalPort = memoizeGetPort(DEFAULT_LOCAL_PORT);
625
+ const getInspectorPort = memoizeGetPort(DEFAULT_INSPECTOR_PORT);
626
+
627
+ if (config.services && config.services.length > 0) {
628
+ logger.warn(
629
+ `This worker is bound to live services: ${config.services
630
+ .map(
631
+ (service) =>
632
+ `${service.binding} (${service.service}${
633
+ service.environment ? `@${service.environment}` : ""
634
+ })`
635
+ )
636
+ .join(", ")}`
637
+ );
638
+ }
639
+
640
+ if (args.inspect) {
641
+ //devtools are enabled by default, but we still need to disable them if the caller doesn't want them
642
+ logger.warn(
643
+ "Passing --inspect is unnecessary, now you can always connect to devtools."
644
+ );
645
+ }
646
+
647
+ if (args["experimental-public"]) {
648
+ throw new Error(
649
+ "The --experimental-public field has been renamed to --assets"
650
+ );
651
+ }
652
+
653
+ if (args.public) {
654
+ throw new Error("The --public field has been renamed to --assets");
655
+ }
656
+
657
+ if ((args.assets || config.assets) && (args.site || config.site)) {
658
+ throw new Error("Cannot use Assets and Workers Sites in the same Worker.");
659
+ }
660
+
661
+ if (args.assets) {
662
+ logger.warn(
663
+ "The --assets argument is experimental and may change or break at any time"
664
+ );
665
+ }
666
+
667
+ const upstreamProtocol =
668
+ args["upstream-protocol"] || config.dev.upstream_protocol;
669
+ if (upstreamProtocol === "http") {
670
+ logger.warn(
671
+ "Setting upstream-protocol to http is not currently implemented.\n" +
672
+ "If this is required in your project, please add your use case to the following issue:\n" +
673
+ "https://github.com/cloudflare/wrangler2/issues/583."
674
+ );
675
+ }
676
+ const nodeCompat = args.nodeCompat ?? config.node_compat;
677
+ if (nodeCompat) {
678
+ logger.warn(
679
+ "Enabling node.js compatibility mode for built-ins and globals. This is experimental and has serious tradeoffs. Please see https://github.com/ionic-team/rollup-plugin-node-polyfills/ for more details."
680
+ );
681
+ }
682
+
683
+ const cliDefines =
684
+ args.define?.reduce<Record<string, string>>((collectDefines, d) => {
685
+ const [key, ...value] = d.split(":");
686
+ collectDefines[key] = value.join("");
687
+ return collectDefines;
688
+ }, {}) || {};
689
+
690
+ return {
691
+ entry,
692
+ upstreamProtocol,
693
+ nodeCompat,
694
+ getLocalPort,
695
+ getInspectorPort,
696
+ zoneId,
697
+ host,
698
+ routes,
699
+ cliDefines,
700
+ };
701
+ }
702
+
703
+ async function getBindingsAndAssetPaths(
704
+ args: StartDevOptions,
705
+ configParam: Config
706
+ ) {
707
+ const cliVars =
708
+ args.var?.reduce<Record<string, string>>((collectVars, v) => {
709
+ const [key, ...value] = v.split(":");
710
+ collectVars[key] = value.join("");
711
+ return collectVars;
712
+ }, {}) || {};
713
+
714
+ // now log all available bindings into the terminal
715
+ const bindings = await getBindings(configParam, {
716
+ kv: args.kv,
717
+ vars: { ...args.vars, ...cliVars },
718
+ durableObjects: args.durableObjects,
719
+ r2: args.r2,
720
+ });
721
+
722
+ const maskedVars = maskVars(bindings, configParam);
723
+
724
+ printBindings({
725
+ ...bindings,
726
+ vars: maskedVars,
727
+ });
728
+
729
+ const assetPaths =
730
+ args.assets || configParam.assets
731
+ ? getAssetPaths(configParam, args.assets)
732
+ : getSiteAssetPaths(
733
+ configParam,
734
+ args.site,
735
+ args.siteInclude,
736
+ args.siteExclude
737
+ );
738
+ return { assetPaths, bindings };
739
+ }
556
740
 
557
741
  async function getBindings(
558
742
  configParam: Config,
@@ -615,7 +799,7 @@ async function getBindings(
615
799
  ) || []),
616
800
  ...(args.r2 || []),
617
801
  ],
618
- worker_namespaces: configParam.worker_namespaces,
802
+ dispatch_namespaces: configParam.dispatch_namespaces,
619
803
  services: configParam.services,
620
804
  unsafe: configParam.unsafe?.bindings,
621
805
  logfwdr: configParam.logfwdr,