diff --git a/.changeset/moody-goats-cry.md b/.changeset/moody-goats-cry.md new file mode 100644 index 000000000000..9d033f4045c0 --- /dev/null +++ b/.changeset/moody-goats-cry.md @@ -0,0 +1,9 @@ +--- +"wrangler": minor +--- + +Adds the `--force-subdomain-deploy` flag to the `wrangler triggers deploy` command. + +Wrangler will sometimes skip the API call if the config file matches +the remote state. The flag lets us skip this behavior, and force the +subdomain deployment. diff --git a/packages/wrangler/src/triggers/deploy.ts b/packages/wrangler/src/triggers/deploy.ts index fbc51905c55b..330a9f567d5b 100644 --- a/packages/wrangler/src/triggers/deploy.ts +++ b/packages/wrangler/src/triggers/deploy.ts @@ -30,6 +30,7 @@ type Props = { legacyEnv: boolean | undefined; dryRun: boolean | undefined; assetsOptions: AssetsOptions | undefined; + forceSubdomainDeploy?: boolean; }; export default async function triggersDeploy( @@ -90,7 +91,8 @@ export default async function triggersDeploy( envName, workerUrl, routes, - deployments + deployments, + props.forceSubdomainDeploy ?? false ); if (!wantWorkersDev && workersDevInSync && routes.length !== 0) { @@ -315,7 +317,8 @@ async function subdomainDeploy( envName: string, workerUrl: string, routes: Route[], - deployments: Array> + deployments: Array>, + forceSubdomainDeploy: boolean ) { const { config } = props; @@ -375,7 +378,7 @@ async function subdomainDeploy( // Update subdomain enablement status if needed. - if (!allInSync) { + if (!allInSync || forceSubdomainDeploy) { await fetchResult(config, `${workerUrl}/subdomain`, { method: "POST", body: JSON.stringify({ diff --git a/packages/wrangler/src/triggers/index.ts b/packages/wrangler/src/triggers/index.ts index 1db699ff78c2..93d1c0455004 100644 --- a/packages/wrangler/src/triggers/index.ts +++ b/packages/wrangler/src/triggers/index.ts @@ -48,6 +48,11 @@ export const triggersDeployCommand = createCommand({ describe: "Use legacy environments", hidden: true, }, + "force-subdomain-deploy": { + type: "boolean", + describe: + "Force deployment of subdomain triggers, even if the they are in sync.", + }, }, behaviour: { warnIfMultipleEnvsConfiguredButNoneSpecified: true, @@ -74,6 +79,7 @@ export const triggersDeployCommand = createCommand({ legacyEnv: isLegacyEnv(config), dryRun: args.dryRun, assetsOptions, + forceSubdomainDeploy: args.forceSubdomainDeploy, }); }, });