wrangler 4.136.0 → 4.136.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +5 -5
  2. package/wrangler-dist/cli.js +101 -50
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wrangler",
3
- "version": "4.136.0",
3
+ "version": "4.136.1",
4
4
  "description": "Command-line interface for all things Cloudflare Workers",
5
5
  "keywords": [
6
6
  "assembly",
@@ -73,7 +73,7 @@
73
73
  "unenv": "2.0.0-rc.24",
74
74
  "workerd": "1.20260921.1",
75
75
  "@cloudflare/kv-asset-handler": "0.5.0",
76
- "@cloudflare/unenv-preset": "2.16.1",
76
+ "@cloudflare/unenv-preset": "2.16.2",
77
77
  "miniflare": "5.20260921.0-alpha"
78
78
  },
79
79
  "devDependencies": {
@@ -164,18 +164,18 @@
164
164
  "@cloudflare/autoconfig": "0.6.0",
165
165
  "@cloudflare/build-output-utils": "0.7.0",
166
166
  "@cloudflare/cli-shared-helpers": "0.1.35",
167
+ "@cloudflare/config": "0.16.0",
167
168
  "@cloudflare/containers-shared": "0.18.0",
168
169
  "@cloudflare/deploy-helpers": "0.14.0",
169
170
  "@cloudflare/pages-functions": "0.1.0",
170
- "@cloudflare/pages-shared": "^0.13.186",
171
- "@cloudflare/config": "0.16.0",
172
171
  "@cloudflare/remote-bindings": "0.0.29",
172
+ "@cloudflare/pages-shared": "^0.13.186",
173
173
  "@cloudflare/runtime-types": "0.0.31",
174
174
  "@cloudflare/shared-ast-primitives": "1.1.0",
175
175
  "@cloudflare/workers-auth": "0.7.4",
176
176
  "@cloudflare/workers-shared": "0.19.9",
177
- "@cloudflare/workers-tsconfig": "0.0.0",
178
177
  "@cloudflare/workers-utils": "0.41.0",
178
+ "@cloudflare/workers-tsconfig": "0.0.0",
179
179
  "@cloudflare/workflows-shared": "0.14.0"
180
180
  },
181
181
  "peerDependencies": {
@@ -62207,6 +62207,7 @@ var init_esm2 = __esm({
62207
62207
  // ../deploy-helpers/src/shared/context.ts
62208
62208
  function initDeployHelpersContext(ctx) {
62209
62209
  logger = ctx.logger;
62210
+ createCloudflareClient = ctx.createCloudflareClient;
62210
62211
  fetchResult = ctx.fetchResult;
62211
62212
  fetchListResult = ctx.fetchListResult;
62212
62213
  fetchPagedListResult = ctx.fetchPagedListResult;
@@ -62215,7 +62216,7 @@ function initDeployHelpersContext(ctx) {
62215
62216
  prompt = ctx.prompt;
62216
62217
  select = ctx.select;
62217
62218
  }
62218
- var logger, fetchResult, fetchListResult, fetchPagedListResult, confirm, prompt, select;
62219
+ var logger, createCloudflareClient, fetchResult, fetchListResult, fetchPagedListResult, confirm, prompt, select;
62219
62220
  var init_context = __esm({
62220
62221
  "../deploy-helpers/src/shared/context.ts"() {
62221
62222
  init_import_meta_url();
@@ -62228,7 +62229,7 @@ var name, version2;
62228
62229
  var init_package = __esm({
62229
62230
  "package.json"() {
62230
62231
  name = "wrangler";
62231
- version2 = "4.136.0";
62232
+ version2 = "4.136.1";
62232
62233
  }
62233
62234
  });
62234
62235
 
@@ -134947,7 +134948,7 @@ async function logResponse(response) {
134947
134948
  logger2.debugWithSanitization("RESPONSE:", jsonText);
134948
134949
  logger2.debug("-- END CF API RESPONSE");
134949
134950
  }
134950
- function createCloudflareClient(complianceConfig) {
134951
+ function createCloudflareClient2(complianceConfig) {
134951
134952
  return new cloudflare_default({
134952
134953
  fetch: /* @__PURE__ */ __name(async (url4, init4) => {
134953
134954
  const request4 = new import_undici4.Request(url4, { ...init4, duplex: "half" });
@@ -135122,7 +135123,7 @@ var init_internal = __esm({
135122
135123
  init_user3();
135123
135124
  __name(logRequest, "logRequest");
135124
135125
  __name(logResponse, "logResponse");
135125
- __name(createCloudflareClient, "createCloudflareClient");
135126
+ __name(createCloudflareClient2, "createCloudflareClient");
135126
135127
  __name(performApiFetch, "performApiFetch");
135127
135128
  __name(fetchInternal, "fetchInternal");
135128
135129
  __name(cloneHeaders2, "cloneHeaders");
@@ -135269,6 +135270,7 @@ var init_cfetch2 = __esm({
135269
135270
  function initApiDeployHelpersContext() {
135270
135271
  initDeployHelpersContext({
135271
135272
  logger: logger2,
135273
+ createCloudflareClient: createCloudflareClient2,
135272
135274
  fetchResult: fetchResult2,
135273
135275
  fetchListResult: fetchListResult2,
135274
135276
  fetchPagedListResult: fetchPagedListResult2,
@@ -135283,6 +135285,7 @@ var init_deploy_helpers_context = __esm({
135283
135285
  init_import_meta_url();
135284
135286
  init_context();
135285
135287
  init_cfetch2();
135288
+ init_internal();
135286
135289
  init_dialogs();
135287
135290
  init_logger2();
135288
135291
  __name(initApiDeployHelpersContext, "initApiDeployHelpersContext");
@@ -155050,6 +155053,17 @@ function toValidSubdomain(input) {
155050
155053
  return subdomain || "my-worker";
155051
155054
  }
155052
155055
  async function getWorkersDevSubdomain(complianceConfig, accountId, options = {}) {
155056
+ const result = await getWorkersDevSubdomainInternal(
155057
+ complianceConfig,
155058
+ accountId,
155059
+ options
155060
+ );
155061
+ if ("unauthorizedError" in result) {
155062
+ throw result.unauthorizedError;
155063
+ }
155064
+ return result.subdomain;
155065
+ }
155066
+ async function getWorkersDevSubdomainInternal(complianceConfig, accountId, options) {
155053
155067
  const {
155054
155068
  abortSignal,
155055
155069
  autoRegisterSubdomain,
@@ -155064,40 +155078,67 @@ async function getWorkersDevSubdomain(complianceConfig, accountId, options = {})
155064
155078
  void 0,
155065
155079
  abortSignal
155066
155080
  );
155067
- return `${subdomain}${getComplianceRegionSubdomain(complianceConfig)}.workers.dev`;
155081
+ return {
155082
+ subdomain: `${subdomain}${getComplianceRegionSubdomain(complianceConfig)}.workers.dev`
155083
+ };
155068
155084
  } catch (e11) {
155085
+ if (e11 instanceof APIError && e11.code === 1e4) {
155086
+ return { unauthorizedError: e11 };
155087
+ }
155069
155088
  const error53 = e11;
155070
155089
  if (typeof error53 !== "object" || !error53 || error53.code !== 10007) {
155071
155090
  throw e11;
155072
155091
  }
155073
- logger.warn(getRegistrationWarning(registrationContext));
155074
- if (autoRegisterSubdomain) {
155075
- return await registerSubdomain(
155092
+ }
155093
+ logger.warn(getRegistrationWarning(registrationContext));
155094
+ if (autoRegisterSubdomain) {
155095
+ return {
155096
+ subdomain: await registerSubdomain(
155076
155097
  complianceConfig,
155077
155098
  accountId,
155078
155099
  configPath,
155079
155100
  registrationContext,
155080
155101
  autoRegisterSubdomain
155081
- );
155082
- }
155083
- const wantsToRegister = await confirm(
155084
- "Would you like to register a workers.dev subdomain now?",
155085
- { fallbackValue: false }
155102
+ )
155103
+ };
155104
+ }
155105
+ const wantsToRegister = await confirm(
155106
+ "Would you like to register a workers.dev subdomain now?",
155107
+ { fallbackValue: false }
155108
+ );
155109
+ if (!wantsToRegister) {
155110
+ throw getRegistrationDeclinedError(
155111
+ registrationContext,
155112
+ accountId,
155113
+ configPath
155086
155114
  );
155087
- if (!wantsToRegister) {
155088
- throw getRegistrationDeclinedError(
155089
- registrationContext,
155090
- accountId,
155091
- configPath
155092
- );
155093
- }
155094
- return await registerSubdomain(
155115
+ }
155116
+ return {
155117
+ subdomain: await registerSubdomain(
155095
155118
  complianceConfig,
155096
155119
  accountId,
155097
155120
  configPath,
155098
155121
  registrationContext
155099
- );
155100
- }
155122
+ )
155123
+ };
155124
+ }
155125
+ async function getWorkersDevSubdomainIfAccessible(complianceConfig, accountId, options = {}) {
155126
+ const result = await getWorkersDevSubdomainInternal(
155127
+ complianceConfig,
155128
+ accountId,
155129
+ options
155130
+ );
155131
+ return "unauthorizedError" in result ? void 0 : result.subdomain;
155132
+ }
155133
+ async function getWorkerSubdomain(complianceConfig, accountId, workerName) {
155134
+ const worker = await createCloudflareClient(
155135
+ complianceConfig
155136
+ ).workers.beta.workers.get(workerName, { account_id: accountId });
155137
+ return {
155138
+ ...worker.subdomain,
155139
+ enabled: worker.subdomain.enabled ?? false,
155140
+ previews_enabled: worker.subdomain.previews_enabled ?? false
155141
+ };
155101
155142
  }
155102
155143
  function getRegistrationWarning(registrationContext) {
155103
155144
  switch (registrationContext) {
@@ -155250,6 +155291,9 @@ var init_subdomain2 = __esm({
155250
155291
  init_context();
155251
155292
  __name(toValidSubdomain, "toValidSubdomain");
155252
155293
  __name(getWorkersDevSubdomain, "getWorkersDevSubdomain");
155294
+ __name(getWorkersDevSubdomainInternal, "getWorkersDevSubdomainInternal");
155295
+ __name(getWorkersDevSubdomainIfAccessible, "getWorkersDevSubdomainIfAccessible");
155296
+ __name(getWorkerSubdomain, "getWorkerSubdomain");
155253
155297
  __name(getRegistrationWarning, "getRegistrationWarning");
155254
155298
  __name(getRegistrationDeclinedError, "getRegistrationDeclinedError");
155255
155299
  __name(registerSubdomain, "registerSubdomain");
@@ -155701,8 +155745,7 @@ function getSubdomainValuesAPIMock(config_workers_dev, config_preview_urls, rout
155701
155745
  preview_urls
155702
155746
  };
155703
155747
  }
155704
- async function validateSubdomainMixedState(props, accountId, scriptName, before, after, firstDeploy) {
155705
- const { config: config2 } = props;
155748
+ async function validateSubdomainMixedState(scriptName, before, after, previewURLSuffix, firstDeploy) {
155706
155749
  const changed = after.workers_dev !== before.workers_dev || after.preview_urls !== before.preview_urls;
155707
155750
  if (!changed) {
155708
155751
  return after;
@@ -155719,10 +155762,7 @@ async function validateSubdomainMixedState(props, accountId, scriptName, before,
155719
155762
  if (after.workers_dev === after.preview_urls) {
155720
155763
  return after;
155721
155764
  }
155722
- const userSubdomain = await getWorkersDevSubdomain(config2, accountId, {
155723
- configPath: config2.configPath
155724
- });
155725
- const previewUrl = `https://<VERSION_PREFIX>-${scriptName}.${userSubdomain}`;
155765
+ const previewUrl = previewURLSuffix ? `https://<VERSION_PREFIX>${previewURLSuffix}` : `https://<VERSION_PREFIX>-${scriptName}.<YOUR_SUBDOMAIN>.workers.dev`;
155726
155766
  if (!after.workers_dev && after.preview_urls) {
155727
155767
  logger.warn(
155728
155768
  [
@@ -155750,14 +155790,17 @@ async function validateSubdomainMixedState(props, accountId, scriptName, before,
155750
155790
  async function subdomainDeploy(props, accountId, scriptName, workerUrl, routes, deployments, firstDeploy) {
155751
155791
  const { config: config2 } = props;
155752
155792
  const { workers_dev: wantWorkersDev, preview_urls: wantPreviews } = getSubdomainValues(config2.workers_dev, config2.preview_urls, routes);
155793
+ const before = await getWorkerSubdomain(config2, accountId, scriptName);
155753
155794
  if (wantWorkersDev) {
155754
- const userSubdomain = await getWorkersDevSubdomain(config2, accountId, {
155795
+ const workersDevHostname = before.url ? new URL(before.url).hostname : `${scriptName}.${await getWorkersDevSubdomain(config2, accountId, {
155755
155796
  configPath: config2.configPath
155756
- });
155757
- const workersDevURL = `${scriptName}.${userSubdomain}`;
155758
- deployments.push(Promise.resolve({ targets: [workersDevURL] }));
155797
+ })}`;
155798
+ deployments.push(
155799
+ Promise.resolve({
155800
+ targets: [workersDevHostname]
155801
+ })
155802
+ );
155759
155803
  }
155760
- const before = await fetchResult(config2, `${workerUrl}/subdomain`);
155761
155804
  const after = await retryOnAPIFailure(
155762
155805
  async () => fetchResult(config2, `${workerUrl}/subdomain`, {
155763
155806
  method: "POST",
@@ -155803,11 +155846,10 @@ async function subdomainDeploy(props, accountId, scriptName, workerUrl, routes,
155803
155846
  );
155804
155847
  }
155805
155848
  await validateSubdomainMixedState(
155806
- props,
155807
- accountId,
155808
155849
  scriptName,
155809
155850
  { workers_dev: before.enabled, preview_urls: before.previews_enabled },
155810
155851
  { workers_dev: after.enabled, preview_urls: after.previews_enabled },
155852
+ before.preview_url_suffix,
155811
155853
  firstDeploy
155812
155854
  );
155813
155855
  return {
@@ -170640,7 +170682,7 @@ Edits that have been made via the script API will be overridden by your local co
170640
170682
  );
170641
170683
  const wantsWorkersDev = props.command === "deploy" && props.dispatchNamespace === void 0 && getSubdomainValues(config2.workers_dev, config2.preview_urls, props.routes).workers_dev;
170642
170684
  if (!workerExists && wantsWorkersDev) {
170643
- await getWorkersDevSubdomain(config2, accountId, {
170685
+ await getWorkersDevSubdomainIfAccessible(config2, accountId, {
170644
170686
  autoRegisterSubdomain: props.autoRegisterWorkersDevSubdomain,
170645
170687
  configPath: config2.configPath
170646
170688
  });
@@ -171580,16 +171622,17 @@ async function uploadWorkerVersion(props, config2, buildResult, callbacks) {
171580
171622
  let versionPreviewUrl = void 0;
171581
171623
  let versionPreviewAliasUrl = void 0;
171582
171624
  if (versionId && hasPreview) {
171583
- const { previews_enabled: previews_available_on_subdomain } = await fetchResult(config2, `${workerUrl}/subdomain`);
171584
- if (previews_available_on_subdomain) {
171585
- const userSubdomain = await getWorkersDevSubdomain(config2, accountId, {
171586
- configPath: config2.configPath
171587
- });
171625
+ const workerSubdomain = await getWorkerSubdomain(
171626
+ config2,
171627
+ accountId,
171628
+ workerName
171629
+ );
171630
+ if (workerSubdomain.previews_enabled && workerSubdomain.preview_url_suffix) {
171588
171631
  const shortVersion = versionId.slice(0, 8);
171589
- versionPreviewUrl = `https://${shortVersion}-${workerName}.${userSubdomain}`;
171632
+ versionPreviewUrl = `https://${shortVersion}${workerSubdomain.preview_url_suffix}`;
171590
171633
  logger.log(`Version Preview URL: ${versionPreviewUrl}`);
171591
171634
  if (props.previewAlias) {
171592
- versionPreviewAliasUrl = `https://${props.previewAlias}-${workerName}.${userSubdomain}`;
171635
+ versionPreviewAliasUrl = `https://${props.previewAlias}${workerSubdomain.preview_url_suffix}`;
171593
171636
  logger.log(`Version Preview Alias URL: ${versionPreviewAliasUrl}`);
171594
171637
  }
171595
171638
  }
@@ -225395,6 +225438,7 @@ function createHandler2(def, argv) {
225395
225438
  try {
225396
225439
  initDeployHelpersContext({
225397
225440
  logger: logger2,
225441
+ createCloudflareClient: createCloudflareClient2,
225398
225442
  fetchResult: fetchResult2,
225399
225443
  fetchListResult: fetchListResult2,
225400
225444
  fetchPagedListResult: fetchPagedListResult2,
@@ -225404,7 +225448,7 @@ function createHandler2(def, argv) {
225404
225448
  select: select2
225405
225449
  });
225406
225450
  const result = await def.handler(args, {
225407
- sdk: createCloudflareClient(config2),
225451
+ sdk: createCloudflareClient2(config2),
225408
225452
  config: config2,
225409
225453
  errors: { UserError, FatalError },
225410
225454
  logger: logger2,
@@ -295412,6 +295456,7 @@ async function runPagesToWorkersDeploy(delegation) {
295412
295456
  await run(experimentalFlags, async () => {
295413
295457
  initDeployHelpersContext({
295414
295458
  logger: logger2,
295459
+ createCloudflareClient: createCloudflareClient2,
295415
295460
  fetchResult: fetchResult2,
295416
295461
  fetchListResult: fetchListResult2,
295417
295462
  fetchPagedListResult: fetchPagedListResult2,
@@ -295445,6 +295490,7 @@ var init_run_workers_deploy = __esm({
295445
295490
  init_import_meta_url();
295446
295491
  init_context();
295447
295492
  init_cfetch2();
295493
+ init_internal();
295448
295494
  init_config6();
295449
295495
  init_deploy3();
295450
295496
  init_dialogs();
@@ -337128,17 +337174,20 @@ async function ensurePreviewsConfig(accountId, args, config2) {
337128
337174
  ...selectedConversion.blockingDeploymentMessages
337129
337175
  ])
337130
337176
  ];
337131
- if (!hasPreviewBase && containsGeneratedPlaceholder(proposedConfig)) {
337132
- conversionMessages.push(
337133
- "Replace each <REPLACE_ME> placeholder with a Preview-safe value. Do not use production resources unless you intend for this Preview to access them."
337134
- );
337135
- }
337136
337177
  const hasEmptyProposedConfig = Object.keys(proposedConfig).length === 0;
337137
337178
  const hasBlockingDeploymentMessages = selectedConversion.blockingDeploymentMessages.length > 0;
337138
337179
  const missingPreviewsConfigParagraphs = [
337139
337180
  hasEmptyProposedConfig && conversionMessages.length === 0 ? "Your Wrangler configuration is missing a `previews` block to run this command. Add the following to your configuration file:" : hasEmptyProposedConfig || hasBlockingDeploymentMessages ? "Your Wrangler configuration needs a `previews` block to run this command. Add the following to your configuration file:" : "Your Wrangler configuration is missing a `previews` block. Add the following to your configuration file:",
337140
337181
  formattedProposedConfig
337141
337182
  ];
337183
+ if (!hasPreviewBase && containsGeneratedPlaceholder(proposedConfig)) {
337184
+ const replacementMessage = "Replace each <REPLACE_ME> placeholder with a Preview-safe value. Do not use production resources unless you intend for this Preview to access them.";
337185
+ missingPreviewsConfigParagraphs.push(`
337186
+ ${replacementMessage}`);
337187
+ if (args.json) {
337188
+ conversionMessages.push(replacementMessage);
337189
+ }
337190
+ }
337142
337191
  if (hasEmptyProposedConfig && conversionMessages.length === 0) {
337143
337192
  missingPreviewsConfigParagraphs.push(
337144
337193
  "To create or update a Preview with `npx wrangler preview`, your Wrangler configuration must include a `previews` block. The block can be empty. Assets, compatibility settings, migrations, and placement stay at the top level and do not need to be added to `previews`.\nLearn more: https://developers.cloudflare.com/workers/previews/configuration/#wrangler-configuration-file"
@@ -358695,6 +358744,7 @@ var init_DevEnv = __esm({
358695
358744
  init_context();
358696
358745
  init_src();
358697
358746
  init_cfetch2();
358747
+ init_internal();
358698
358748
  init_build_failures();
358699
358749
  init_dialogs();
358700
358750
  init_logger2();
@@ -358714,6 +358764,7 @@ var init_DevEnv = __esm({
358714
358764
  async startWorker(options) {
358715
358765
  initDeployHelpersContext({
358716
358766
  logger: logger2,
358767
+ createCloudflareClient: createCloudflareClient2,
358717
358768
  fetchResult: fetchResult2,
358718
358769
  fetchListResult: fetchListResult2,
358719
358770
  fetchPagedListResult: fetchPagedListResult2,