Skip to content

Commit 4e23cab

Browse files
committed
fix tests & remove dev behaviour
1 parent 6ad12e3 commit 4e23cab

File tree

9 files changed

+25
-46
lines changed

9 files changed

+25
-46
lines changed

packages/wrangler/src/__tests__/api/startDevWorker/BundleController.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ function configDefaults(
3535
build: unusable<StartDevWorkerOptions["build"]>(),
3636
legacy: {},
3737
dev: { persist },
38+
userConfigPath: undefined,
3839
...config,
3940
};
4041
}

packages/wrangler/src/__tests__/api/startDevWorker/LocalRuntimeController.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ function configDefaults(
133133
build: unusable<StartDevWorkerOptions["build"]>(),
134134
legacy: {},
135135
dev: { persist: "./persist" },
136+
userConfigPath: undefined,
136137
...config,
137138
};
138139
}

packages/wrangler/src/__tests__/config/configuration.test.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2820,6 +2820,7 @@ describe("normalizeAndValidateConfig()", () => {
28202820
MULTIWORKER: false,
28212821
REMOTE_BINDINGS: false,
28222822
DEPLOY_REMOTE_DIFF_CHECK: false,
2823+
AUTOCREATE_RESOURCES: false,
28232824
},
28242825
() =>
28252826
normalizeAndValidateConfig(
@@ -2977,6 +2978,7 @@ describe("normalizeAndValidateConfig()", () => {
29772978
MULTIWORKER: false,
29782979
REMOTE_BINDINGS: false,
29792980
DEPLOY_REMOTE_DIFF_CHECK: false,
2981+
AUTOCREATE_RESOURCES: false,
29802982
},
29812983
() =>
29822984
normalizeAndValidateConfig(
@@ -3316,6 +3318,7 @@ describe("normalizeAndValidateConfig()", () => {
33163318
MULTIWORKER: false,
33173319
REMOTE_BINDINGS: false,
33183320
DEPLOY_REMOTE_DIFF_CHECK: false,
3321+
AUTOCREATE_RESOURCES: false,
33193322
},
33203323
() =>
33213324
normalizeAndValidateConfig(

packages/wrangler/src/__tests__/dev/remote-bindings.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,6 @@ describe("dev with remote bindings", { sequential: true }, () => {
475475
name: "EMAIL",
476476
remote: true,
477477
remoteProxyConnectionString,
478-
type: "send_email",
479478
},
480479
],
481480
},

packages/wrangler/src/__tests__/experimental-commands-api.test.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@ describe("experimental_getWranglerCommands", () => {
3030
"requiresArg": true,
3131
"type": "string",
3232
},
33+
"experimental-auto-create": Object {
34+
"alias": "x-auto-create",
35+
"default": true,
36+
"describe": "Automatically provision draft bindings with new resources",
37+
"hidden": true,
38+
"type": "boolean",
39+
},
3340
"experimental-provision": Object {
3441
"alias": Array [
3542
"x-provision",

packages/wrangler/src/__tests__/metrics.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,7 @@ describe("metrics", () => {
198198
command: "wrangler docs",
199199
args: {
200200
xRemoteBindings: true,
201+
xAutoCreate: true,
201202
search: ["<REDACTED>"],
202203
},
203204
};

packages/wrangler/src/__tests__/versions/versions.view.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -685,8 +685,8 @@ describe("versions view", () => {
685685
env.AI AI
686686
env.VERSION_METADATA Worker Version Metadata
687687
env.WFP (wfp-namespace) Dispatch Namespace
688-
env.WFP_2 (wfp-namespace) Dispatch Namespace
689-
env.WFP_3 (wfp-namespace) Dispatch Namespace
688+
env.WFP_2 (wfp-namespace (outbound -> outbound-worker)) Dispatch Namespace
689+
env.WFP_3 (wfp-namespace (outbound -> outbound-worker)) Dispatch Namespace
690690
env.MTLS (mtls-id) mTLS Certificate
691691
"
692692
`);

packages/wrangler/src/api/startDevWorker/LocalRuntimeController.ts

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -224,16 +224,6 @@ export class LocalRuntimeController extends RuntimeController {
224224
undefined
225225
: await unwrapHook(data.config.dev.auth);
226226

227-
if (getFlag("RESOURCES_PROVISION") && auth) {
228-
await provisionBindings(
229-
configBundle.bindings,
230-
auth?.accountId,
231-
data.config.name,
232-
getFlag("AUTOCREATE_RESOURCES"),
233-
data.config,
234-
true
235-
);
236-
}
237227
this.#remoteProxySessionData =
238228
await maybeStartOrUpdateRemoteProxySession(
239229
{

packages/wrangler/src/deployment-bundle/bindings.ts

Lines changed: 10 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -461,17 +461,12 @@ export async function provisionBindings(
461461
accountId: string,
462462
scriptName: string,
463463
autoCreate: boolean,
464-
config: Config | StartDevWorkerOptions,
464+
config: Config,
465465
requireRemote = false
466466
): Promise<void> {
467-
const configPath = "configPath" in config ? config.configPath : config.config;
467+
const configPath = config.userConfigPath ?? config.configPath;
468468
const pendingResources = await collectPendingResources(
469-
{
470-
compliance_region:
471-
"compliance_region" in config
472-
? config.compliance_region
473-
: config.complianceRegion,
474-
},
469+
config,
475470
accountId,
476471
scriptName,
477472
bindings,
@@ -496,25 +491,15 @@ export async function provisionBindings(
496491
printable[resource.resourceType].push({ binding: resource.binding });
497492
}
498493

499-
const tailConsumers =
500-
"configPath" in config ? config.tail_consumers : config.tailConsumers;
501-
printBindings(printable, tailConsumers, { provisioning: true });
494+
printBindings(printable, config.tail_consumers, { provisioning: true });
502495
logger.log();
503496

504497
const existingResources: Record<string, NormalisedResourceInfo[]> = {};
505498

506499
for (const resource of pendingResources) {
507500
existingResources[resource.resourceType] ??= await LOADERS[
508501
resource.resourceType
509-
](
510-
{
511-
compliance_region:
512-
"compliance_region" in config
513-
? config.compliance_region
514-
: config.complianceRegion,
515-
},
516-
accountId
517-
);
502+
](config, accountId);
518503

519504
await runProvisioningFlow(
520505
resource,
@@ -534,11 +519,9 @@ export async function provisionBindings(
534519
allChanges.set(resource.binding, resource.handler.binding);
535520
}
536521

537-
for (const resourceType of [
538-
"kv_namespaces",
539-
"r2_buckets",
540-
"d1_databases",
541-
] as const) {
522+
for (const resourceType of Object.keys(
523+
HANDLERS
524+
) as (keyof typeof HANDLERS)[]) {
542525
for (const binding of bindings[resourceType] ?? []) {
543526
patch[resourceType] ??= [];
544527

@@ -565,11 +548,7 @@ export async function provisionBindings(
565548
// portability of the config file, and adds robustness to bindings being renamed.
566549
if (!isNonInteractiveOrCI()) {
567550
try {
568-
await experimental_patchConfig(
569-
config.userConfigPath ?? configPath,
570-
patch,
571-
false
572-
);
551+
await experimental_patchConfig(configPath, patch, false);
573552
logger.log(
574553
"Your Worker was deployed with provisioned resources. We've written the IDs of these resources to your config file, which you can choose to save or discard. Either way future deploys will continue to work."
575554
);
@@ -591,10 +570,8 @@ export async function provisionBindings(
591570
);
592571
logger.log(`🎉 All resources provisioned, continuing with deployment...\n`);
593572

594-
const sendMetrics =
595-
"send_metrics" in config ? config.send_metrics : config.sendMetrics;
596573
metrics.sendMetricsEvent("provision resources", resourceCount, {
597-
sendMetrics,
574+
sendMetrics: config.send_metrics,
598575
});
599576
}
600577
}

0 commit comments

Comments
 (0)