diff --git a/.changeset/three-carpets-smile.md b/.changeset/three-carpets-smile.md new file mode 100644 index 000000000000..63e4c7c51759 --- /dev/null +++ b/.changeset/three-carpets-smile.md @@ -0,0 +1,5 @@ +--- +"wrangler": patch +--- + +Allows uploads with both cron triggers and smart placement enabled diff --git a/packages/wrangler/src/__tests__/configuration.test.ts b/packages/wrangler/src/__tests__/configuration.test.ts index bd40c85fd690..1630a49a5721 100644 --- a/packages/wrangler/src/__tests__/configuration.test.ts +++ b/packages/wrangler/src/__tests__/configuration.test.ts @@ -963,7 +963,7 @@ describe("normalizeAndValidateConfig()", () => { first_party_worker: true, logpush: true, placement: { - mode: "off", + mode: "smart", }, }; @@ -4791,60 +4791,6 @@ describe("normalizeAndValidateConfig()", () => { }); }); - describe("[placement]", () => { - it("should error if both placement and triggers are configured", () => { - const { diagnostics } = normalizeAndValidateConfig( - { - triggers: { - crons: [1111], - }, - placement: { mode: "smart" }, - } as unknown as RawConfig, - undefined, - { env: undefined } - ); - - expect(diagnostics.hasWarnings()).toBe(false); - expect(diagnostics.renderErrors()).toMatchInlineSnapshot(` - "Processing wrangler configuration: - - You cannot configure both [triggers] and [placement] in your wrangler.toml. Placement is not supported with cron triggers." - `); - }); - it("should not error if triggers are configured and placement is set off", () => { - const { diagnostics } = normalizeAndValidateConfig( - { - triggers: { - crons: [1111], - }, - placement: { mode: "off" }, - } as unknown as RawConfig, - undefined, - { env: undefined } - ); - - expect(diagnostics.hasWarnings()).toBe(false); - expect(diagnostics.hasErrors()).toBe(false); - }); - it("should not error if placement is configured and triggers is empty array", () => { - const expectedConfig: RawEnvironment = { - triggers: { crons: [] }, - placement: { - mode: "smart", - }, - }; - const { config, diagnostics } = normalizeAndValidateConfig( - expectedConfig, - undefined, - { env: undefined } - ); - - expect(config).toEqual(expect.objectContaining({ ...expectedConfig })); - - expect(diagnostics.hasWarnings()).toBe(false); - expect(diagnostics.hasErrors()).toBe(false); - }); - }); - describe("(deprecated)", () => { it("should remove and warn about deprecated properties", () => { const environment: RawEnvironment = { diff --git a/packages/wrangler/src/config/validation-helpers.ts b/packages/wrangler/src/config/validation-helpers.ts index a2b72c7be0ca..59db902f2001 100644 --- a/packages/wrangler/src/config/validation-helpers.ts +++ b/packages/wrangler/src/config/validation-helpers.ts @@ -533,27 +533,6 @@ export const validateAdditionalProperties = ( return true; }; -/** - * Add a diagnostic error for any configurations that include both cron triggers and smart placement - */ -export const validateSmartPlacementConfig = ( - diagnostics: Diagnostics, - placement: { mode: "off" | "smart" } | undefined, - triggers: - | { - crons: string[]; - } - | undefined -): boolean => { - if (placement?.mode === "smart" && !!triggers?.crons?.length) { - diagnostics.errors.push( - `You cannot configure both [triggers] and [placement] in your wrangler.toml. Placement is not supported with cron triggers.` - ); - return false; - } - return true; -}; - /** * Get the names of the bindings collection in `value`. * diff --git a/packages/wrangler/src/config/validation.ts b/packages/wrangler/src/config/validation.ts index 8c0d21394e5c..d7fea0f07a3b 100644 --- a/packages/wrangler/src/config/validation.ts +++ b/packages/wrangler/src/config/validation.ts @@ -26,7 +26,6 @@ import { appendEnvName, getBindingNames, isValidName, - validateSmartPlacementConfig, } from "./validation-helpers"; import type { Config, DevConfig, RawConfig, RawDevConfig } from "./config"; import type { @@ -238,8 +237,6 @@ export function normalizeAndValidateConfig( [...Object.keys(config), "env"] ); - validateSmartPlacementConfig(diagnostics, config.placement, config.triggers); - experimental(diagnostics, rawConfig, "assets"); return { config, diagnostics };