Skip to content

Commit 962f91d

Browse files
committed
feat: add wrangler triggers deploy --force-subdomain-deploy flag
Wrangler will sometimes skip the API call if the config file matches the remote state. However, we need to be able to force it in some cases.
1 parent dceb550 commit 962f91d

File tree

3 files changed

+21
-3
lines changed

3 files changed

+21
-3
lines changed

.changeset/moody-goats-cry.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
---
2+
"wrangler": minor
3+
---
4+
5+
Adds the `--force-subdomain-deploy` flag to the `wrangler triggers deploy` command.
6+
7+
Wrangler will sometimes skip the API call if the config file matches
8+
the remote state. The flag lets us skip this behavior, and force the
9+
subdomain deployment.

packages/wrangler/src/triggers/deploy.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ type Props = {
3030
legacyEnv: boolean | undefined;
3131
dryRun: boolean | undefined;
3232
assetsOptions: AssetsOptions | undefined;
33+
forceSubdomainDeploy?: boolean;
3334
};
3435

3536
export default async function triggersDeploy(
@@ -90,7 +91,8 @@ export default async function triggersDeploy(
9091
envName,
9192
workerUrl,
9293
routes,
93-
deployments
94+
deployments,
95+
props.forceSubdomainDeploy ?? false
9496
);
9597

9698
if (!wantWorkersDev && workersDevInSync && routes.length !== 0) {
@@ -315,7 +317,8 @@ async function subdomainDeploy(
315317
envName: string,
316318
workerUrl: string,
317319
routes: Route[],
318-
deployments: Array<Promise<string[]>>
320+
deployments: Array<Promise<string[]>>,
321+
forceSubdomainDeploy: boolean
319322
) {
320323
const { config } = props;
321324

@@ -375,7 +378,7 @@ async function subdomainDeploy(
375378

376379
// Update subdomain enablement status if needed.
377380

378-
if (!allInSync) {
381+
if (!allInSync || forceSubdomainDeploy) {
379382
await fetchResult(config, `${workerUrl}/subdomain`, {
380383
method: "POST",
381384
body: JSON.stringify({

packages/wrangler/src/triggers/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,11 @@ export const triggersDeployCommand = createCommand({
4848
describe: "Use legacy environments",
4949
hidden: true,
5050
},
51+
"force-subdomain-deploy": {
52+
type: "boolean",
53+
describe:
54+
"Force deployment of subdomain triggers, even if the they are in sync.",
55+
},
5156
},
5257
behaviour: {
5358
warnIfMultipleEnvsConfiguredButNoneSpecified: true,
@@ -74,6 +79,7 @@ export const triggersDeployCommand = createCommand({
7479
legacyEnv: isLegacyEnv(config),
7580
dryRun: args.dryRun,
7681
assetsOptions,
82+
forceSubdomainDeploy: args.forceSubdomainDeploy,
7783
});
7884
},
7985
});

0 commit comments

Comments
 (0)