wrangler 4.36.0 → 4.37.0

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wrangler",
3
- "version": "4.36.0",
3
+ "version": "4.37.0",
4
4
  "description": "Command-line interface for all things Cloudflare Workers",
5
5
  "keywords": [
6
6
  "wrangler",
@@ -56,8 +56,8 @@
56
56
  "unenv": "2.0.0-rc.21",
57
57
  "workerd": "1.20250906.0",
58
58
  "@cloudflare/kv-asset-handler": "0.4.0",
59
- "miniflare": "4.20250906.1",
60
- "@cloudflare/unenv-preset": "2.7.3"
59
+ "@cloudflare/unenv-preset": "2.7.3",
60
+ "miniflare": "4.20250906.2"
61
61
  },
62
62
  "devDependencies": {
63
63
  "@aws-sdk/client-s3": "^3.721.0",
@@ -141,7 +141,7 @@
141
141
  "@cloudflare/cli": "1.1.2",
142
142
  "@cloudflare/containers-shared": "0.2.10",
143
143
  "@cloudflare/eslint-config-shared": "1.1.0",
144
- "@cloudflare/pages-shared": "^0.13.70",
144
+ "@cloudflare/pages-shared": "^0.13.71",
145
145
  "@cloudflare/workers-shared": "0.18.8",
146
146
  "@cloudflare/workers-tsconfig": "0.0.0"
147
147
  },
@@ -1469,6 +1469,10 @@ interface ComputedFields {
1469
1469
  * It can be useful to know what the top-level name was before the flattening.
1470
1470
  */
1471
1471
  topLevelName: string | undefined;
1472
+ /** A list of environment names declared in the raw configuration. */
1473
+ definedEnvironments: string[] | undefined;
1474
+ /** The name of the environment being targeted. */
1475
+ targetEnvironment: string | undefined;
1472
1476
  }
1473
1477
  interface ConfigFields<Dev extends RawDevConfig> {
1474
1478
  /**
@@ -93256,7 +93256,7 @@ var name, version;
93256
93256
  var init_package = __esm({
93257
93257
  "package.json"() {
93258
93258
  name = "wrangler";
93259
- version = "4.36.0";
93259
+ version = "4.37.0";
93260
93260
  }
93261
93261
  });
93262
93262
 
@@ -102252,6 +102252,9 @@ function findRedirectedWranglerConfig(cwd2, userConfigPath) {
102252
102252
  return redirectedConfigPath;
102253
102253
  }
102254
102254
  }
102255
+ function isRedirectedRawConfig(rawConfig, configPath, userConfigPath) {
102256
+ return configPath !== void 0 && configPath !== userConfigPath;
102257
+ }
102255
102258
  var import_node_fs5, import_node_path7;
102256
102259
  var init_config_helpers = __esm({
102257
102260
  "src/config/config-helpers.ts"() {
@@ -102266,6 +102269,7 @@ var init_config_helpers = __esm({
102266
102269
  __name(resolveWranglerConfigPath, "resolveWranglerConfigPath");
102267
102270
  __name(findWranglerConfig, "findWranglerConfig");
102268
102271
  __name(findRedirectedWranglerConfig, "findRedirectedWranglerConfig");
102272
+ __name(isRedirectedRawConfig, "isRedirectedRawConfig");
102269
102273
  }
102270
102274
  });
102271
102275
 
@@ -103107,16 +103111,18 @@ async function disableR2Catalog(complianceConfig, accountId, bucketName) {
103107
103111
  }
103108
103112
  );
103109
103113
  }
103110
- async function enableR2CatalogCompaction(complianceConfig, accountId, bucketName, namespace, tableName) {
103114
+ async function enableR2CatalogCompaction(complianceConfig, accountId, bucketName, targetSizeMb) {
103115
+ const config = {
103116
+ state: "enabled",
103117
+ targetSizeMb
103118
+ };
103111
103119
  return await fetchResult(
103112
103120
  complianceConfig,
103113
- `/accounts/${accountId}/r2-catalog/${bucketName}/namespaces/${namespace}/tables/${tableName}/maintenance-configs`,
103121
+ `/accounts/${accountId}/r2-catalog/${bucketName}/maintenance-configs`,
103114
103122
  {
103115
103123
  method: "POST",
103116
103124
  body: JSON.stringify({
103117
- configuration_type: "compaction",
103118
- configuration: {},
103119
- state: "enabled"
103125
+ compaction: config
103120
103126
  }),
103121
103127
  headers: {
103122
103128
  "Content-Type": "application/json"
@@ -103124,14 +103130,32 @@ async function enableR2CatalogCompaction(complianceConfig, accountId, bucketName
103124
103130
  }
103125
103131
  );
103126
103132
  }
103127
- async function disableR2CatalogCompaction(complianceConfig, accountId, bucketName, namespace, tableName) {
103133
+ async function disableR2CatalogCompaction(complianceConfig, accountId, bucketName) {
103134
+ const config = {
103135
+ state: "disabled"
103136
+ };
103128
103137
  return await fetchResult(
103129
103138
  complianceConfig,
103130
- `/accounts/${accountId}/r2-catalog/${bucketName}/namespaces/${namespace}/tables/${tableName}/maintenance-configs/compaction`,
103139
+ `/accounts/${accountId}/r2-catalog/${bucketName}/maintenance-configs`,
103131
103140
  {
103132
- method: "PUT",
103141
+ method: "POST",
103133
103142
  body: JSON.stringify({
103134
- state: "disabled"
103143
+ compaction: config
103144
+ }),
103145
+ headers: {
103146
+ "Content-Type": "application/json"
103147
+ }
103148
+ }
103149
+ );
103150
+ }
103151
+ async function upsertR2DataCatalogCredential(complianceConfig, accountId, bucketName, token) {
103152
+ return await fetchResult(
103153
+ complianceConfig,
103154
+ `/accounts/${accountId}/r2-catalog/${bucketName}/credential`,
103155
+ {
103156
+ method: "POST",
103157
+ body: JSON.stringify({
103158
+ token
103135
103159
  }),
103136
103160
  headers: {
103137
103161
  "Content-Type": "application/json"
@@ -103675,6 +103699,7 @@ var init_helpers = __esm({
103675
103699
  __name(disableR2Catalog, "disableR2Catalog");
103676
103700
  __name(enableR2CatalogCompaction, "enableR2CatalogCompaction");
103677
103701
  __name(disableR2CatalogCompaction, "disableR2CatalogCompaction");
103702
+ __name(upsertR2DataCatalogCredential, "upsertR2DataCatalogCredential");
103678
103703
  actionsForEventCategories = {
103679
103704
  "object-create": ["PutObject", "CompleteMultipartUpload", "CopyObject"],
103680
103705
  "object-delete": ["DeleteObject", "LifecycleDeletion"]
@@ -104186,7 +104211,11 @@ function normalizeAndValidateConfig(rawConfig, configPath, userConfigPath, args,
104186
104211
  isDispatchNamespace,
104187
104212
  preserveOriginalMain
104188
104213
  );
104189
- const isRedirectedConfig = configPath && configPath !== userConfigPath;
104214
+ const isRedirectedConfig = isRedirectedRawConfig(
104215
+ rawConfig,
104216
+ configPath,
104217
+ userConfigPath
104218
+ );
104190
104219
  const definedEnvironments = Object.keys(rawConfig.env ?? {});
104191
104220
  if (isRedirectedConfig && definedEnvironments.length > 0) {
104192
104221
  diagnostics.errors.push(
@@ -104265,6 +104294,8 @@ Consider adding an environment configuration section to the ${configFileName(con
104265
104294
  configPath,
104266
104295
  userConfigPath,
104267
104296
  topLevelName: rawConfig.name,
104297
+ definedEnvironments: isRedirectedConfig ? rawConfig.definedEnvironments : definedEnvironments,
104298
+ targetEnvironment: isRedirectedConfig ? rawConfig.targetEnvironment : envName,
104268
104299
  pages_build_output_dir: normalizeAndValidatePagesBuildOutputDir(
104269
104300
  configPath,
104270
104301
  rawConfig.pages_build_output_dir
@@ -105685,6 +105716,7 @@ var init_validation = __esm({
105685
105716
  init_experimental_flags();
105686
105717
  init_helpers();
105687
105718
  init_print_bindings();
105719
+ init_config_helpers();
105688
105720
  init_diagnostics2();
105689
105721
  init_validation_helpers();
105690
105722
  init_config5();
@@ -107485,6 +107517,8 @@ var init_config4 = __esm({
107485
107517
  configPath: void 0,
107486
107518
  userConfigPath: void 0,
107487
107519
  topLevelName: void 0,
107520
+ definedEnvironments: void 0,
107521
+ targetEnvironment: void 0,
107488
107522
  /*====================================================*/
107489
107523
  /* Fields supported by both Workers & Pages */
107490
107524
  /*====================================================*/
@@ -107713,7 +107747,9 @@ var init_validation_pages = __esm({
107713
107747
  // normalizeAndValidateConfig() sets these values
107714
107748
  "configPath",
107715
107749
  "userConfigPath",
107716
- "topLevelName"
107750
+ "topLevelName",
107751
+ "definedEnvironments",
107752
+ "targetEnvironment"
107717
107753
  ];
107718
107754
  __name(validatePagesConfig, "validatePagesConfig");
107719
107755
  __name(validateMainField, "validateMainField");
@@ -119815,6 +119851,21 @@ function buildMiniflareBindingOptions(config, remoteProxyConnectionString, remot
119815
119851
  };
119816
119852
  }
119817
119853
  }
119854
+ const additionalUnboundDurableObjects = [];
119855
+ for (const [className, useSQLite] of classNameToUseSQLite) {
119856
+ if (!durableObjects.find((d7) => d7.class_name === className)) {
119857
+ additionalUnboundDurableObjects.push({
119858
+ className,
119859
+ scriptName: void 0,
119860
+ useSQLite,
119861
+ container: config.containerDOClassNames?.size && config.enableContainers ? getImageNameFromDOClassName({
119862
+ doClassName: className,
119863
+ containerDOClassNames: config.containerDOClassNames,
119864
+ containerBuildId: config.containerBuildId
119865
+ }) : void 0
119866
+ });
119867
+ }
119868
+ }
119818
119869
  const bindingOptions = {
119819
119870
  bindings: {
119820
119871
  ...bindings.vars,
@@ -119944,6 +119995,7 @@ function buildMiniflareBindingOptions(config, remoteProxyConnectionString, remot
119944
119995
  }
119945
119996
  )
119946
119997
  ),
119998
+ additionalUnboundDurableObjects,
119947
119999
  ratelimits: Object.fromEntries([
119948
120000
  ...bindings.unsafe?.bindings?.filter((b7) => b7.type == "ratelimit").map(ratelimitEntry) ?? [],
119949
120001
  ...bindings.ratelimits?.map((r8) => [
@@ -132191,6 +132243,54 @@ var init_durable = __esm({
132191
132243
  }
132192
132244
  });
132193
132245
 
132246
+ // src/environments/index.ts
132247
+ function hasDefinedEnvironments(config) {
132248
+ return isLegacyEnv(config) && Boolean(config.definedEnvironments?.length);
132249
+ }
132250
+ async function applyServiceAndEnvironmentTags(config, accountId, scriptName, tags) {
132251
+ tags ??= [];
132252
+ const env6 = config.targetEnvironment;
132253
+ const serviceTag = `${SERVICE_TAG_PREFIX}${config.topLevelName}`;
132254
+ const environmentTag = env6 ? `${ENVIRONMENT_TAG_PREFIX}${env6}` : null;
132255
+ const hasMissingServiceTag = !tags.includes(serviceTag);
132256
+ const hasMissingOrStaleEnvironmentTag = environmentTag ? !tags.includes(environmentTag) : tags.some((tag) => tag.startsWith(ENVIRONMENT_TAG_PREFIX));
132257
+ if (hasMissingServiceTag || hasMissingOrStaleEnvironmentTag) {
132258
+ const nextTags = tags.filter(
132259
+ (tag) => !tag.startsWith(SERVICE_TAG_PREFIX) && !tag.startsWith(ENVIRONMENT_TAG_PREFIX)
132260
+ ).concat([serviceTag]);
132261
+ if (environmentTag) {
132262
+ nextTags.push(environmentTag);
132263
+ }
132264
+ try {
132265
+ return await patchNonVersionedScriptSettings(
132266
+ config,
132267
+ accountId,
132268
+ scriptName,
132269
+ {
132270
+ tags: nextTags
132271
+ }
132272
+ );
132273
+ } catch {
132274
+ logger.warn(
132275
+ "Could not apply service and environment tags. This Worker will not appear grouped together with its sibling environments in the Cloudflare dashboard."
132276
+ );
132277
+ }
132278
+ }
132279
+ }
132280
+ var SERVICE_TAG_PREFIX, ENVIRONMENT_TAG_PREFIX;
132281
+ var init_environments = __esm({
132282
+ "src/environments/index.ts"() {
132283
+ init_import_meta_url();
132284
+ init_logger();
132285
+ init_isLegacyEnv();
132286
+ init_api();
132287
+ SERVICE_TAG_PREFIX = "cf:service=";
132288
+ ENVIRONMENT_TAG_PREFIX = "cf:environment=";
132289
+ __name(hasDefinedEnvironments, "hasDefinedEnvironments");
132290
+ __name(applyServiceAndEnvironmentTags, "applyServiceAndEnvironmentTags");
132291
+ }
132292
+ });
132293
+
132194
132294
  // ../../node_modules/.pnpm/xxhash-wasm@1.0.1/node_modules/xxhash-wasm/esm/xxhash-wasm.js
132195
132295
  async function e2() {
132196
132296
  const { instance: { exports: { mem: e8, xxh32: n7, xxh64: r8, init32: i6, update32: o6, digest32: h7, init64: s6, update64: u6, digest64: g7 } } } = await WebAssembly.instantiate(t2);
@@ -194620,69 +194720,65 @@ For more details, refer to: https://developers.cloudflare.com/r2/api/s3/tokens/`
194620
194720
  });
194621
194721
  r2BucketCatalogCompactionNamespace = createNamespace({
194622
194722
  metadata: {
194623
- description: "Manage compaction maintenance for tables in your R2 data catalog",
194624
- status: "private-beta",
194723
+ description: "Control settings for automatic file compaction maintenance jobs for your R2 data catalog",
194724
+ status: "open-beta",
194625
194725
  owner: "Product: R2 Data Catalog"
194626
194726
  }
194627
194727
  });
194628
194728
  r2BucketCatalogCompactionEnableCommand = createCommand({
194629
194729
  metadata: {
194630
- description: "Enable compaction maintenance for a table in the R2 data catalog",
194631
- status: "private-beta",
194730
+ description: "Enable automatic file compaction for your R2 data catalog",
194731
+ status: "open-beta",
194632
194732
  owner: "Product: R2 Data Catalog"
194633
194733
  },
194634
194734
  positionalArgs: ["bucket"],
194635
194735
  args: {
194636
194736
  bucket: {
194637
- describe: "The name of the bucket",
194737
+ describe: "The name of the bucket which contains the catalog",
194638
194738
  type: "string",
194639
194739
  demandOption: true
194640
194740
  },
194641
- table: {
194642
- describe: "The name of the table to enable compaction for",
194643
- type: "string",
194644
- demandOption: true
194741
+ targetSizeMb: {
194742
+ describe: "The target size for compacted files (allowed values: 64, 128, 256, 512)",
194743
+ type: "number",
194744
+ demandOption: false,
194745
+ default: 128
194645
194746
  },
194646
- namespace: {
194647
- describe: "The namespace containing the table",
194648
- type: "string",
194649
- demandOption: true
194747
+ token: {
194748
+ describe: "A cloudflare api token with access to R2 and R2 Data Catalog which will be used to read/write files for compaction.",
194749
+ demandOption: true,
194750
+ type: "string"
194650
194751
  }
194651
194752
  },
194652
194753
  async handler(args, { config }) {
194653
194754
  const accountId = await requireAuth(config);
194755
+ await upsertR2DataCatalogCredential(
194756
+ config,
194757
+ accountId,
194758
+ args.bucket,
194759
+ args.token
194760
+ );
194654
194761
  await enableR2CatalogCompaction(
194655
194762
  config,
194656
194763
  accountId,
194657
194764
  args.bucket,
194658
- args.namespace,
194659
- args.table
194765
+ args.targetSizeMb
194660
194766
  );
194661
194767
  logger.log(
194662
- `\u2728 Successfully enabled compaction maintenance for table '${args.table}' in namespace '${args.namespace}' of bucket '${args.bucket}'.`
194768
+ `\u2728 Successfully enabled file compaction for the data catalog for bucket '${args.bucket}'.`
194663
194769
  );
194664
194770
  }
194665
194771
  });
194666
194772
  r2BucketCatalogCompactionDisableCommand = createCommand({
194667
194773
  metadata: {
194668
- description: "Disable compaction maintenance for a table in the R2 data catalog",
194669
- status: "private-beta",
194774
+ description: "Disable automatic file compaction for your R2 data catalog",
194775
+ status: "open-beta",
194670
194776
  owner: "Product: R2 Data Catalog"
194671
194777
  },
194672
194778
  positionalArgs: ["bucket"],
194673
194779
  args: {
194674
194780
  bucket: {
194675
- describe: "The name of the bucket",
194676
- type: "string",
194677
- demandOption: true
194678
- },
194679
- table: {
194680
- describe: "The name of the table to disable compaction for",
194681
- type: "string",
194682
- demandOption: true
194683
- },
194684
- namespace: {
194685
- describe: "The namespace containing the table",
194781
+ describe: "The name of the bucket which contains the catalog",
194686
194782
  type: "string",
194687
194783
  demandOption: true
194688
194784
  }
@@ -194690,21 +194786,15 @@ For more details, refer to: https://developers.cloudflare.com/r2/api/s3/tokens/`
194690
194786
  async handler(args, { config }) {
194691
194787
  const accountId = await requireAuth(config);
194692
194788
  const confirmedDisable = await confirm(
194693
- `Are you sure you want to disable compaction maintenance for table '${args.table}' in namespace '${args.namespace}' of bucket '${args.bucket}'?`
194789
+ `Are you sure you want to disable file compaction for the data catalog for bucket '${args.bucket}'?`
194694
194790
  );
194695
194791
  if (!confirmedDisable) {
194696
194792
  logger.log("Disable cancelled.");
194697
194793
  return;
194698
194794
  }
194699
- await disableR2CatalogCompaction(
194700
- config,
194701
- accountId,
194702
- args.bucket,
194703
- args.namespace,
194704
- args.table
194705
- );
194795
+ await disableR2CatalogCompaction(config, accountId, args.bucket);
194706
194796
  logger.log(
194707
- `Successfully disabled compaction maintenance for table '${args.table}' in namespace '${args.namespace}' of bucket '${args.bucket}'.`
194797
+ `Successfully disabled file compaction for the data catalog for bucket '${args.bucket}'.`
194708
194798
  );
194709
194799
  }
194710
194800
  });
@@ -213003,6 +213093,7 @@ async function versionsUpload(props) {
213003
213093
  const { config, accountId, name: name2 } = props;
213004
213094
  let versionId = null;
213005
213095
  let workerTag = null;
213096
+ let tags = null;
213006
213097
  if (accountId && name2) {
213007
213098
  try {
213008
213099
  const {
@@ -213013,6 +213104,7 @@ async function versionsUpload(props) {
213013
213104
  // TODO(consider): should this be a /versions endpoint?
213014
213105
  );
213015
213106
  workerTag = script.tag;
213107
+ tags = script.tags;
213016
213108
  if (script.last_deployed_from === "dash") {
213017
213109
  logger.warn(
213018
213110
  `You are about to upload a Worker Version that was last published via the Cloudflare Dashboard.
@@ -213318,6 +213410,14 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
213318
213410
  }
213319
213411
  throw err;
213320
213412
  }
213413
+ if (hasDefinedEnvironments(config)) {
213414
+ await applyServiceAndEnvironmentTags(
213415
+ config,
213416
+ accountId,
213417
+ scriptName,
213418
+ tags
213419
+ );
213420
+ }
213321
213421
  }
213322
213422
  if (props.outFile) {
213323
213423
  (0, import_node_fs33.mkdirSync)(import_node_path55.default.dirname(props.outFile), { recursive: true });
@@ -213453,6 +213553,7 @@ var init_upload5 = __esm({
213453
213553
  init_dialogs();
213454
213554
  init_durable();
213455
213555
  init_misc_variables();
213556
+ init_environments();
213456
213557
  init_errors();
213457
213558
  init_experimental_flags();
213458
213559
  init_logger();
@@ -220255,6 +220356,7 @@ async function deploy(props) {
220255
220356
  const { config, accountId, name: name2, entry } = props;
220256
220357
  let workerTag = null;
220257
220358
  let versionId = null;
220359
+ let tags = null;
220258
220360
  let workerExists = true;
220259
220361
  const domainRoutes = (props.domains || []).map((domain2) => ({
220260
220362
  pattern: domain2,
@@ -220269,6 +220371,7 @@ async function deploy(props) {
220269
220371
  default_environment: { script }
220270
220372
  } = serviceMetaData;
220271
220373
  workerTag = script.tag;
220374
+ tags = script.tags;
220272
220375
  if (script.last_deployed_from === "dash") {
220273
220376
  let configDiff;
220274
220377
  if (getFlag("DEPLOY_REMOTE_DIFF_CHECK")) {
@@ -220705,6 +220808,14 @@ See https://developers.cloudflare.com/workers/platform/compatibility-dates for m
220705
220808
  )
220706
220809
  );
220707
220810
  }
220811
+ if (hasDefinedEnvironments(config)) {
220812
+ await applyServiceAndEnvironmentTags(
220813
+ config,
220814
+ accountId,
220815
+ scriptName,
220816
+ tags
220817
+ );
220818
+ }
220708
220819
  if (result.startup_time_ms) {
220709
220820
  logger.log("Worker Startup Time:", result.startup_time_ms, "ms");
220710
220821
  }
@@ -221061,6 +221172,7 @@ var init_deploy8 = __esm({
221061
221172
  init_dialogs();
221062
221173
  init_durable();
221063
221174
  init_misc_variables();
221175
+ init_environments();
221064
221176
  init_errors();
221065
221177
  init_experimental_flags();
221066
221178
  init_logger();