Skip to content

Commit c4c8ff6

Browse files
gate new deploy remote diff check
1 parent 9674185 commit c4c8ff6

File tree

10 files changed

+37
-19
lines changed

10 files changed

+37
-19
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2656,6 +2656,7 @@ describe("normalizeAndValidateConfig()", () => {
26562656
RESOURCES_PROVISION: true,
26572657
MULTIWORKER: false,
26582658
REMOTE_BINDINGS: false,
2659+
DEPLOY_REMOTE_DIFF_CHECK: false,
26592660
},
26602661
() =>
26612662
normalizeAndValidateConfig(
@@ -2812,6 +2813,7 @@ describe("normalizeAndValidateConfig()", () => {
28122813
RESOURCES_PROVISION: true,
28132814
MULTIWORKER: false,
28142815
REMOTE_BINDINGS: false,
2816+
DEPLOY_REMOTE_DIFF_CHECK: false,
28152817
},
28162818
() =>
28172819
normalizeAndValidateConfig(
@@ -3150,6 +3152,7 @@ describe("normalizeAndValidateConfig()", () => {
31503152
RESOURCES_PROVISION: true,
31513153
MULTIWORKER: false,
31523154
REMOTE_BINDINGS: false,
3155+
DEPLOY_REMOTE_DIFF_CHECK: false,
31533156
},
31543157
() =>
31553158
normalizeAndValidateConfig(

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13006,7 +13006,7 @@ export default{
1300613006
result: true,
1300713007
});
1300813008

13009-
await runWrangler("deploy");
13009+
await runWrangler("deploy --x-remote-diff-check");
1301013010

1301113011
expect(normalizeLogWithConfigDiff(std.warn)).toMatchInlineSnapshot(`
1301213012
"▲ [WARNING] Your local configuration differs from the remote configuration of your Worker set via the Cloudflare Dashboard:
@@ -13068,7 +13068,7 @@ export default{
1306813068
result: true,
1306913069
});
1307013070

13071-
await runWrangler("deploy");
13071+
await runWrangler("deploy --x-remote-diff-check");
1307213072

1307313073
// Note: we display the toml config diff in json format since code-wise we'd have to convert the rawConfig to toml
1307413074
// to be able to show toml content/diffs, that combined with the fact that json(c) config files are the

packages/wrangler/src/api/dev.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ export async function unstable_dev(
239239
MULTIWORKER: false,
240240
RESOURCES_PROVISION: false,
241241
REMOTE_BINDINGS: false,
242+
DEPLOY_REMOTE_DIFF_CHECK: false,
242243
},
243244
() => startDev(devOptions)
244245
);

packages/wrangler/src/core/register-yargs-command.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ function createHandler(def: CommandDefinition, commandName: string) {
156156
MULTIWORKER: false,
157157
RESOURCES_PROVISION: args.experimentalProvision ?? false,
158158
REMOTE_BINDINGS: args.experimentalRemoteBindings ?? false,
159+
DEPLOY_REMOTE_DIFF_CHECK: false,
159160
};
160161

161162
await run(experimentalFlags, () => {

packages/wrangler/src/deploy/deploy.ts

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -379,24 +379,26 @@ export default async function deploy(props: Props): Promise<{
379379
workerTag = script.tag;
380380

381381
if (script.last_deployed_from === "dash") {
382-
const remoteWorkerConfig = await downloadWorkerConfig(
383-
accountId,
384-
name,
385-
entry.file,
386-
serviceMetaData.default_environment.environment
387-
);
388-
389382
let configDiff: ReturnType<typeof getRemoteConfigDiff> | undefined;
390-
let rawConfig: RawConfig | undefined;
391-
if (config.configPath) {
392-
try {
393-
rawConfig = parseRawConfigFile(config.configPath);
394-
} catch {
395-
// We were unable to either read the file so the more comprehensive diffing just won't kick in
396-
// (but a warning with a confirmation prompt will still be shown to the user)
397-
}
398-
if (rawConfig) {
399-
configDiff = getRemoteConfigDiff(remoteWorkerConfig, rawConfig);
383+
if (getFlag("DEPLOY_REMOTE_DIFF_CHECK")) {
384+
const remoteWorkerConfig = await downloadWorkerConfig(
385+
accountId,
386+
name,
387+
entry.file,
388+
serviceMetaData.default_environment.environment
389+
);
390+
391+
let rawConfig: RawConfig | undefined;
392+
if (config.configPath) {
393+
try {
394+
rawConfig = parseRawConfigFile(config.configPath);
395+
} catch {
396+
// We were unable to either read the file so the more comprehensive diffing just won't kick in
397+
// (but a warning with a confirmation prompt will still be shown to the user)
398+
}
399+
if (rawConfig) {
400+
configDiff = getRemoteConfigDiff(remoteWorkerConfig, rawConfig);
401+
}
400402
}
401403
}
402404

packages/wrangler/src/deploy/index.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,13 +226,20 @@ export const deployCommand = createCommand({
226226
hidden: true,
227227
alias: "x-auto-create",
228228
},
229+
"experimental-deploy-remote-diff-check": {
230+
describe: `Experimental: Enable The Deployment Remote Diff check`,
231+
type: "boolean",
232+
hidden: true,
233+
alias: ["x-remote-diff-check"],
234+
},
229235
},
230236
behaviour: {
231237
useConfigRedirectIfAvailable: true,
232238
overrideExperimentalFlags: (args) => ({
233239
MULTIWORKER: false,
234240
RESOURCES_PROVISION: args.experimentalProvision ?? false,
235241
REMOTE_BINDINGS: args.experimentalRemoteBindings ?? false,
242+
DEPLOY_REMOTE_DIFF_CHECK: args.experimentalDeployRemoteDiffCheck ?? false,
236243
}),
237244
warnIfMultipleEnvsConfiguredButNoneSpecified: true,
238245
},

packages/wrangler/src/dev.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ export const dev = createCommand({
6969
MULTIWORKER: Array.isArray(args.config),
7070
RESOURCES_PROVISION: args.experimentalProvision ?? false,
7171
REMOTE_BINDINGS: args.experimentalRemoteBindings ?? false,
72+
DEPLOY_REMOTE_DIFF_CHECK: false,
7273
}),
7374
},
7475
metadata: {

packages/wrangler/src/experimental-flags.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ export type ExperimentalFlags = {
55
MULTIWORKER: boolean;
66
RESOURCES_PROVISION: boolean;
77
REMOTE_BINDINGS: boolean;
8+
DEPLOY_REMOTE_DIFF_CHECK: boolean;
89
};
910

1011
const flags = new AsyncLocalStorage<ExperimentalFlags>();

packages/wrangler/src/pages/dev.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -885,6 +885,7 @@ export const pagesDevCommand = createCommand({
885885
MULTIWORKER: Array.isArray(args.config),
886886
RESOURCES_PROVISION: false,
887887
REMOTE_BINDINGS: false,
888+
DEPLOY_REMOTE_DIFF_CHECK: false,
888889
},
889890
() =>
890891
startDev({

packages/wrangler/src/versions/upload.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ export const versionsUploadCommand = createCommand({
264264
MULTIWORKER: false,
265265
RESOURCES_PROVISION: args.experimentalProvision ?? false,
266266
REMOTE_BINDINGS: args.experimentalRemoteBindings ?? false,
267+
DEPLOY_REMOTE_DIFF_CHECK: false,
267268
}),
268269
warnIfMultipleEnvsConfiguredButNoneSpecified: true,
269270
},

0 commit comments

Comments
 (0)