wrangler 3.63.1 → 3.64.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": "3.63.1",
3
+ "version": "3.64.0",
4
4
  "description": "Command-line interface for all things Cloudflare Workers",
5
5
  "keywords": [
6
6
  "wrangler",
@@ -153,8 +153,8 @@
153
153
  "yoga-layout": "file:../../vendor/yoga-layout-2.0.0-beta.1.tgz",
154
154
  "@cloudflare/cli": "1.1.1",
155
155
  "@cloudflare/eslint-config-worker": "1.1.0",
156
- "@cloudflare/pages-shared": "^0.11.46",
157
- "@cloudflare/workers-tsconfig": "0.0.0"
156
+ "@cloudflare/workers-tsconfig": "0.0.0",
157
+ "@cloudflare/pages-shared": "^0.11.46"
158
158
  },
159
159
  "peerDependencies": {
160
160
  "@cloudflare/workers-types": "^4.20240620.0"
@@ -1,105 +1,22 @@
1
1
  {
2
2
  "compilerOptions": {
3
- /* Visit https://aka.ms/tsconfig.json to read more about this file */
4
-
5
- /* Projects */
6
- // "incremental": true, /* Enable incremental compilation */
7
- // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */
8
- // "tsBuildInfoFile": "./", /* Specify the folder for .tsbuildinfo incremental compilation files. */
9
- // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects */
10
- // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */
11
- // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */
12
-
13
- /* Language and Environment */
14
3
  "target": "es2021" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */,
15
4
  "lib": [
16
5
  "es2021"
17
6
  ] /* Specify a set of bundled library declaration files that describe the target runtime environment. */,
18
7
  "jsx": "react-jsx" /* Specify what JSX code is generated. */,
19
- // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */
20
- // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */
21
- // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h' */
22
- // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */
23
- // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx*`.` */
24
- // "reactNamespace": "", /* Specify the object invoked for `createElement`. This only applies when targeting `react` JSX emit. */
25
- // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */
26
- // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */
27
-
28
- /* Modules */
29
- "module": "es2022" /* Specify what module code is generated. */,
30
- // "rootDir": "./", /* Specify the root folder within your source files. */
31
- "moduleResolution": "node" /* Specify how TypeScript looks up a file from a given module specifier. */,
32
- // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
33
- // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
34
- // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
35
- // "typeRoots": [], /* Specify multiple folders that act like `./node_modules/@types`. */
8
+ "module": "ESNext" /* Specify what module code is generated. */,
9
+ "moduleResolution": "Bundler" /* Specify how TypeScript looks up a file from a given module specifier. */,
36
10
  "types": [
37
11
  "@cloudflare/workers-types"
38
12
  ] /* Specify type package names to be included without being referenced in a source file. */,
39
- // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */
40
13
  "resolveJsonModule": true /* Enable importing .json files */,
41
- // "noResolve": true, /* Disallow `import`s, `require`s or `<reference>`s from expanding the number of files TypeScript should add to a project. */
42
-
43
- /* JavaScript Support */
44
14
  "allowJs": true /* Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files. */,
45
- "checkJs": false /* Enable error reporting in type-checked JavaScript files. */,
46
- // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from `node_modules`. Only applicable with `allowJs`. */
47
-
48
- /* Emit */
49
- // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */
50
- // "declarationMap": true, /* Create sourcemaps for d.ts files. */
51
- // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */
52
- // "sourceMap": true, /* Create source map files for emitted JavaScript files. */
53
- // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If `declaration` is true, also designates a file that bundles all .d.ts output. */
54
- // "outDir": "./", /* Specify an output folder for all emitted files. */
55
- // "removeComments": true, /* Disable emitting comments. */
56
15
  "noEmit": true /* Disable emitting files from a compilation. */,
57
- // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */
58
- // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types */
59
- // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */
60
- // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */
61
- // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */
62
- // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */
63
- // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */
64
- // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */
65
- // "newLine": "crlf", /* Set the newline character for emitting files. */
66
- // "stripInternal": true, /* Disable emitting declarations that have `@internal` in their JSDoc comments. */
67
- // "noEmitHelpers": true, /* Disable generating custom helper functions like `__extends` in compiled output. */
68
- // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */
69
- // "preserveConstEnums": true, /* Disable erasing `const enum` declarations in generated code. */
70
- // "declarationDir": "./", /* Specify the output directory for generated declaration files. */
71
- // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */
72
-
73
- /* Interop Constraints */
74
16
  "isolatedModules": true /* Ensure that each file can be safely transpiled without relying on other imports. */,
75
17
  "allowSyntheticDefaultImports": true /* Allow 'import x from y' when a module doesn't have a default export. */,
76
- // "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables `allowSyntheticDefaultImports` for type compatibility. */,
77
- // "preserveSymlinks": true, /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */
78
- "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */,
79
-
80
- /* Type Checking */
81
18
  "strict": true /* Enable all strict type-checking options. */,
82
- // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied `any` type.. */
83
- // "strictNullChecks": true, /* When type checking, take into account `null` and `undefined`. */
84
- // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */
85
- // "strictBindCallApply": true, /* Check that the arguments for `bind`, `call`, and `apply` methods match the original function. */
86
- // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */
87
- // "noImplicitThis": true, /* Enable error reporting when `this` is given the type `any`. */
88
- // "useUnknownInCatchVariables": true, /* Type catch clause variables as 'unknown' instead of 'any'. */
89
- // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */
90
- // "noUnusedLocals": true, /* Enable error reporting when a local variables aren't read. */
91
- // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read */
92
- // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */
93
- // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */
94
- // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */
95
- // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */
96
- // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */
97
- // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type */
98
- // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */
99
- // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */
100
-
101
- /* Completeness */
102
- // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */
19
+ "noUncheckedIndexedAccess": true,
103
20
  "skipLibCheck": true /* Skip type checking all .d.ts files. */
104
21
  }
105
22
  }
@@ -100903,21 +100903,89 @@ var require_has_property_descriptors = __commonJS({
100903
100903
  }
100904
100904
  });
100905
100905
 
100906
- // ../../node_modules/.pnpm/define-properties@1.2.0/node_modules/define-properties/index.js
100906
+ // ../../node_modules/.pnpm/gopd@1.0.1/node_modules/gopd/index.js
100907
+ var require_gopd = __commonJS({
100908
+ "../../node_modules/.pnpm/gopd@1.0.1/node_modules/gopd/index.js"(exports2, module3) {
100909
+ "use strict";
100910
+ init_import_meta_url();
100911
+ var GetIntrinsic = require_get_intrinsic();
100912
+ var $gOPD = GetIntrinsic("%Object.getOwnPropertyDescriptor%", true);
100913
+ if ($gOPD) {
100914
+ try {
100915
+ $gOPD([], "length");
100916
+ } catch (e3) {
100917
+ $gOPD = null;
100918
+ }
100919
+ }
100920
+ module3.exports = $gOPD;
100921
+ }
100922
+ });
100923
+
100924
+ // ../../node_modules/.pnpm/define-data-property@1.1.0/node_modules/define-data-property/index.js
100925
+ var require_define_data_property = __commonJS({
100926
+ "../../node_modules/.pnpm/define-data-property@1.1.0/node_modules/define-data-property/index.js"(exports2, module3) {
100927
+ "use strict";
100928
+ init_import_meta_url();
100929
+ var hasPropertyDescriptors = require_has_property_descriptors()();
100930
+ var GetIntrinsic = require_get_intrinsic();
100931
+ var $defineProperty = hasPropertyDescriptors && GetIntrinsic("%Object.defineProperty%", true);
100932
+ var $SyntaxError = GetIntrinsic("%SyntaxError%");
100933
+ var $TypeError = GetIntrinsic("%TypeError%");
100934
+ var gopd = require_gopd();
100935
+ module3.exports = /* @__PURE__ */ __name(function defineDataProperty(obj, property, value) {
100936
+ if (!obj || typeof obj !== "object" && typeof obj !== "function") {
100937
+ throw new $TypeError("`obj` must be an object or a function`");
100938
+ }
100939
+ if (typeof property !== "string" && typeof property !== "symbol") {
100940
+ throw new $TypeError("`property` must be a string or a symbol`");
100941
+ }
100942
+ if (arguments.length > 3 && typeof arguments[3] !== "boolean" && arguments[3] !== null) {
100943
+ throw new $TypeError("`nonEnumerable`, if provided, must be a boolean or null");
100944
+ }
100945
+ if (arguments.length > 4 && typeof arguments[4] !== "boolean" && arguments[4] !== null) {
100946
+ throw new $TypeError("`nonWritable`, if provided, must be a boolean or null");
100947
+ }
100948
+ if (arguments.length > 5 && typeof arguments[5] !== "boolean" && arguments[5] !== null) {
100949
+ throw new $TypeError("`nonConfigurable`, if provided, must be a boolean or null");
100950
+ }
100951
+ if (arguments.length > 6 && typeof arguments[6] !== "boolean") {
100952
+ throw new $TypeError("`loose`, if provided, must be a boolean");
100953
+ }
100954
+ var nonEnumerable = arguments.length > 3 ? arguments[3] : null;
100955
+ var nonWritable = arguments.length > 4 ? arguments[4] : null;
100956
+ var nonConfigurable = arguments.length > 5 ? arguments[5] : null;
100957
+ var loose = arguments.length > 6 ? arguments[6] : false;
100958
+ var desc = !!gopd && gopd(obj, property);
100959
+ if ($defineProperty) {
100960
+ $defineProperty(obj, property, {
100961
+ configurable: nonConfigurable === null && desc ? desc.configurable : !nonConfigurable,
100962
+ enumerable: nonEnumerable === null && desc ? desc.enumerable : !nonEnumerable,
100963
+ value,
100964
+ writable: nonWritable === null && desc ? desc.writable : !nonWritable
100965
+ });
100966
+ } else if (loose || !nonEnumerable && !nonWritable && !nonConfigurable) {
100967
+ obj[property] = value;
100968
+ } else {
100969
+ throw new $SyntaxError("This environment does not support defining a property as non-configurable, non-writable, or non-enumerable.");
100970
+ }
100971
+ }, "defineDataProperty");
100972
+ }
100973
+ });
100974
+
100975
+ // ../../node_modules/.pnpm/define-properties@1.2.1/node_modules/define-properties/index.js
100907
100976
  var require_define_properties = __commonJS({
100908
- "../../node_modules/.pnpm/define-properties@1.2.0/node_modules/define-properties/index.js"(exports2, module3) {
100977
+ "../../node_modules/.pnpm/define-properties@1.2.1/node_modules/define-properties/index.js"(exports2, module3) {
100909
100978
  "use strict";
100910
100979
  init_import_meta_url();
100911
100980
  var keys = require_object_keys();
100912
100981
  var hasSymbols = typeof Symbol === "function" && typeof Symbol("foo") === "symbol";
100913
100982
  var toStr = Object.prototype.toString;
100914
100983
  var concat = Array.prototype.concat;
100915
- var origDefineProperty = Object.defineProperty;
100984
+ var defineDataProperty = require_define_data_property();
100916
100985
  var isFunction2 = /* @__PURE__ */ __name(function(fn2) {
100917
100986
  return typeof fn2 === "function" && toStr.call(fn2) === "[object Function]";
100918
100987
  }, "isFunction");
100919
- var hasPropertyDescriptors = require_has_property_descriptors()();
100920
- var supportsDescriptors = origDefineProperty && hasPropertyDescriptors;
100988
+ var supportsDescriptors = require_has_property_descriptors()();
100921
100989
  var defineProperty2 = /* @__PURE__ */ __name(function(object, name, value, predicate) {
100922
100990
  if (name in object) {
100923
100991
  if (predicate === true) {
@@ -100929,14 +100997,9 @@ var require_define_properties = __commonJS({
100929
100997
  }
100930
100998
  }
100931
100999
  if (supportsDescriptors) {
100932
- origDefineProperty(object, name, {
100933
- configurable: true,
100934
- enumerable: false,
100935
- value,
100936
- writable: true
100937
- });
101000
+ defineDataProperty(object, name, value, true);
100938
101001
  } else {
100939
- object[name] = value;
101002
+ defineDataProperty(object, name, value);
100940
101003
  }
100941
101004
  }, "defineProperty");
100942
101005
  var defineProperties = /* @__PURE__ */ __name(function(object, map) {
@@ -152612,7 +152675,7 @@ init_import_meta_url();
152612
152675
  init_import_meta_url();
152613
152676
 
152614
152677
  // package.json
152615
- var version = "3.63.1";
152678
+ var version = "3.64.0";
152616
152679
  var package_default = {
152617
152680
  name: "wrangler",
152618
152681
  version,
@@ -155032,6 +155095,13 @@ async function loginOrRefreshIfRequired(props) {
155032
155095
  }
155033
155096
  __name(loginOrRefreshIfRequired, "loginOrRefreshIfRequired");
155034
155097
  async function login(props = { browser: true }) {
155098
+ const authFromEnv = getAuthFromEnv();
155099
+ if (authFromEnv) {
155100
+ logger.error(
155101
+ "You are logged in with an API Token. Unset the CLOUDFLARE_API_TOKEN in the environment to log in via OAuth."
155102
+ );
155103
+ return false;
155104
+ }
155035
155105
  logger.log("Attempting to login via OAuth...");
155036
155106
  const urlToOpen = await getAuthURL(props?.scopes);
155037
155107
  let server;
@@ -155149,6 +155219,13 @@ async function refreshToken() {
155149
155219
  }
155150
155220
  __name(refreshToken, "refreshToken");
155151
155221
  async function logout() {
155222
+ const authFromEnv = getAuthFromEnv();
155223
+ if (authFromEnv) {
155224
+ logger.log(
155225
+ "You are logged in with an API Token. Unset the CLOUDFLARE_API_TOKEN in the environment to log out."
155226
+ );
155227
+ return;
155228
+ }
155152
155229
  if (!LocalState.accessToken) {
155153
155230
  if (!LocalState.refreshToken) {
155154
155231
  logger.log("Not logged in, exiting...");
@@ -185593,24 +185670,40 @@ init_import_meta_url();
185593
185670
  var import_fs9 = require("fs");
185594
185671
  var import_promises20 = require("node:fs/promises");
185595
185672
  var import_toml4 = __toESM(require_toml());
185596
- async function toEnvironment(project, accountId) {
185673
+ var import_miniflare11 = require("miniflare");
185674
+ async function toEnvironment(deploymentConfig, accountId) {
185597
185675
  const configObj = {};
185598
- configObj.compatibility_date = project.compatibility_date ?? (/* @__PURE__ */ new Date()).toISOString().substring(0, 10);
185599
- if (project.compatibility_flags?.length) {
185600
- configObj.compatibility_flags = project.compatibility_flags;
185676
+ configObj.compatibility_date = deploymentConfig.compatibility_date ?? (/* @__PURE__ */ new Date()).toISOString().substring(0, 10);
185677
+ if (deploymentConfig.always_use_latest_compatibility_date) {
185678
+ configObj.compatibility_date = import_miniflare11.supportedCompatibilityDate;
185601
185679
  }
185602
- for (const [name, envVar] of Object.entries(project.env_vars ?? {})) {
185680
+ if (deploymentConfig.compatibility_flags?.length) {
185681
+ configObj.compatibility_flags = deploymentConfig.compatibility_flags;
185682
+ }
185683
+ if (deploymentConfig.placement) {
185684
+ configObj.placement = deploymentConfig.placement;
185685
+ } else {
185686
+ configObj.placement = { mode: "off" };
185687
+ }
185688
+ if (deploymentConfig.limits) {
185689
+ configObj.limits = deploymentConfig.limits;
185690
+ }
185691
+ for (const [name, envVar] of Object.entries(
185692
+ deploymentConfig.env_vars ?? {}
185693
+ )) {
185603
185694
  if (envVar?.value && envVar?.type == "plain_text") {
185604
185695
  configObj.vars ??= {};
185605
185696
  configObj.vars[name] = envVar?.value;
185606
185697
  }
185607
185698
  }
185608
- for (const [name, namespace] of Object.entries(project.kv_namespaces ?? {})) {
185699
+ for (const [name, namespace] of Object.entries(
185700
+ deploymentConfig.kv_namespaces ?? {}
185701
+ )) {
185609
185702
  configObj.kv_namespaces ??= [];
185610
185703
  configObj.kv_namespaces.push({ id: namespace.namespace_id, binding: name });
185611
185704
  }
185612
185705
  for (const [name, ns] of Object.entries(
185613
- project.durable_object_namespaces ?? {}
185706
+ deploymentConfig.durable_object_namespaces ?? {}
185614
185707
  )) {
185615
185708
  configObj.durable_objects ??= { bindings: [] };
185616
185709
  if (ns.class_name && ns.class_name !== "") {
@@ -185632,7 +185725,9 @@ async function toEnvironment(project, accountId) {
185632
185725
  });
185633
185726
  }
185634
185727
  }
185635
- for (const [name, namespace] of Object.entries(project.d1_databases ?? {})) {
185728
+ for (const [name, namespace] of Object.entries(
185729
+ deploymentConfig.d1_databases ?? {}
185730
+ )) {
185636
185731
  configObj.d1_databases ??= [];
185637
185732
  configObj.d1_databases.push({
185638
185733
  database_id: namespace.id,
@@ -185640,7 +185735,9 @@ async function toEnvironment(project, accountId) {
185640
185735
  database_name: name
185641
185736
  });
185642
185737
  }
185643
- for (const [name, bucket] of Object.entries(project.r2_buckets ?? {})) {
185738
+ for (const [name, bucket] of Object.entries(
185739
+ deploymentConfig.r2_buckets ?? {}
185740
+ )) {
185644
185741
  configObj.r2_buckets ??= [];
185645
185742
  configObj.r2_buckets.push({
185646
185743
  bucket_name: bucket.name,
@@ -185648,7 +185745,7 @@ async function toEnvironment(project, accountId) {
185648
185745
  });
185649
185746
  }
185650
185747
  for (const [name, { service, environment }] of Object.entries(
185651
- project.services ?? {}
185748
+ deploymentConfig.services ?? {}
185652
185749
  )) {
185653
185750
  configObj.services ??= [];
185654
185751
  configObj.services.push({
@@ -185657,7 +185754,9 @@ async function toEnvironment(project, accountId) {
185657
185754
  environment
185658
185755
  });
185659
185756
  }
185660
- for (const [name, queue] of Object.entries(project.queue_producers ?? {})) {
185757
+ for (const [name, queue] of Object.entries(
185758
+ deploymentConfig.queue_producers ?? {}
185759
+ )) {
185661
185760
  configObj.queues ??= { producers: [] };
185662
185761
  configObj.queues?.producers?.push({
185663
185762
  binding: name,
@@ -185665,7 +185764,7 @@ async function toEnvironment(project, accountId) {
185665
185764
  });
185666
185765
  }
185667
185766
  for (const [name, { dataset }] of Object.entries(
185668
- project.analytics_engine_datasets ?? {}
185767
+ deploymentConfig.analytics_engine_datasets ?? {}
185669
185768
  )) {
185670
185769
  configObj.analytics_engine_datasets ??= [];
185671
185770
  configObj.analytics_engine_datasets.push({
@@ -185673,36 +185772,70 @@ async function toEnvironment(project, accountId) {
185673
185772
  dataset
185674
185773
  });
185675
185774
  }
185676
- for (const [name] of Object.entries(project.ai_bindings ?? {})) {
185775
+ for (const [name] of Object.entries(deploymentConfig.ai_bindings ?? {})) {
185677
185776
  configObj.ai = { binding: name };
185678
185777
  }
185679
185778
  return configObj;
185680
185779
  }
185681
185780
  __name(toEnvironment, "toEnvironment");
185682
185781
  async function writeWranglerToml(toml) {
185782
+ let tomlString = import_toml4.default.stringify(toml);
185783
+ tomlString = tomlString.split("\n").map((line) => line.trimStart()).join("\n");
185683
185784
  await (0, import_promises20.writeFile)(
185684
185785
  "wrangler.toml",
185685
- [
185686
- `# Generated by Wrangler on ${/* @__PURE__ */ new Date()}`,
185687
- import_toml4.default.stringify(toml)
185688
- ].join("\n")
185786
+ `# Generated by Wrangler on ${/* @__PURE__ */ new Date()}
185787
+ ${tomlString}`
185689
185788
  );
185690
185789
  }
185691
185790
  __name(writeWranglerToml, "writeWranglerToml");
185791
+ function simplifyEnvironments(preview, production) {
185792
+ const topLevel = { ...preview };
185793
+ if (preview.compatibility_date === production.compatibility_date) {
185794
+ delete production.compatibility_date;
185795
+ delete preview.compatibility_date;
185796
+ }
185797
+ if (JSON.stringify(preview.compatibility_flags) === JSON.stringify(production.compatibility_flags)) {
185798
+ delete production.compatibility_flags;
185799
+ delete preview.compatibility_date;
185800
+ }
185801
+ if (JSON.stringify(preview.placement) === JSON.stringify(production.placement)) {
185802
+ delete production.placement;
185803
+ delete preview.placement;
185804
+ if (topLevel.placement?.mode === "off") {
185805
+ delete topLevel.placement;
185806
+ }
185807
+ }
185808
+ if (JSON.stringify(preview.limits) === JSON.stringify(production.limits)) {
185809
+ delete production.limits;
185810
+ delete preview.limits;
185811
+ return { topLevel, production };
185812
+ } else if (preview.limits && !production.limits) {
185813
+ delete topLevel.limits;
185814
+ return { topLevel, production, preview };
185815
+ }
185816
+ return { topLevel, production };
185817
+ }
185818
+ __name(simplifyEnvironments, "simplifyEnvironments");
185692
185819
  async function downloadProject(accountId, projectName) {
185693
185820
  const project = await fetchResult(
185694
185821
  `/accounts/${accountId}/pages/projects/${projectName}`
185695
185822
  );
185696
185823
  logger.debug(JSON.stringify(project, null, 2));
185824
+ const { topLevel, preview, production } = simplifyEnvironments(
185825
+ await toEnvironment(project.deployment_configs.preview, accountId),
185826
+ await toEnvironment(project.deployment_configs.production, accountId)
185827
+ );
185697
185828
  return {
185698
185829
  name: project.name,
185699
185830
  pages_build_output_dir: project.build_config.destination_dir,
185700
- ...await toEnvironment(project.deployment_configs.preview, accountId),
185701
- env: {
185702
- production: await toEnvironment(
185703
- project.deployment_configs.production,
185704
- accountId
185705
- )
185831
+ ...topLevel,
185832
+ ...{
185833
+ env: preview ? {
185834
+ preview,
185835
+ production
185836
+ } : {
185837
+ production
185838
+ }
185706
185839
  }
185707
185840
  };
185708
185841
  }
@@ -187467,7 +187600,7 @@ var MAX_UPLOAD_SIZE = 300 * 1024 * 1024;
187467
187600
 
187468
187601
  // src/r2/helpers.ts
187469
187602
  init_import_meta_url();
187470
- var import_miniflare11 = require("miniflare");
187603
+ var import_miniflare12 = require("miniflare");
187471
187604
  async function listR2Buckets(accountId, jurisdiction) {
187472
187605
  const headers = {};
187473
187606
  if (jurisdiction !== void 0) {
@@ -187594,7 +187727,7 @@ __name(deleteR2Object, "deleteR2Object");
187594
187727
  async function usingLocalBucket(persistTo, configPath, bucketName, closure) {
187595
187728
  const persist = getLocalPersistencePath(persistTo, configPath);
187596
187729
  const persistOptions = buildPersistOptions(persist);
187597
- const mf = new import_miniflare11.Miniflare({
187730
+ const mf = new import_miniflare12.Miniflare({
187598
187731
  modules: true,
187599
187732
  // TODO(soon): import `reduceError()` from `miniflare:shared`
187600
187733
  script: `
@@ -187766,6 +187899,10 @@ async function deleteEventNotificationConfig(config, apiCredentials, accountId,
187766
187899
  );
187767
187900
  }
187768
187901
  __name(deleteEventNotificationConfig, "deleteEventNotificationConfig");
187902
+ function isValidR2BucketName(name) {
187903
+ return typeof name === "string" && /^[a-zA-Z][a-zA-Z0-9-]*$/.test(name);
187904
+ }
187905
+ __name(isValidR2BucketName, "isValidR2BucketName");
187769
187906
 
187770
187907
  // src/r2/notification.ts
187771
187908
  init_import_meta_url();
@@ -188484,6 +188621,11 @@ ${key} is ${prettyBytes(objectSize, {
188484
188621
  },
188485
188622
  async (args) => {
188486
188623
  await printWranglerBanner();
188624
+ if (!isValidR2BucketName(args.name)) {
188625
+ throw new CommandLineArgsError(
188626
+ `The bucket name "${args.name}" is invalid. Bucket names can only have alphanumeric and - characters.`
188627
+ );
188628
+ }
188487
188629
  const config = readConfig(args.config, args);
188488
188630
  const accountId = await requireAuth(config);
188489
188631
  let fullBucketName = `${args.name}`;
@@ -201947,6 +202089,11 @@ async function whoami() {
201947
202089
  `\u{1F44B} You are logged in with an ${user.authType}. Unable to retrieve email for this user. Are you missing the \`User->User Details->Read\` permission?`
201948
202090
  );
201949
202091
  }
202092
+ if (user.authType === "API Token") {
202093
+ logger.log(
202094
+ "\u2139\uFE0F The API Token is read from the CLOUDFLARE_API_TOKEN in your environment."
202095
+ );
202096
+ }
201950
202097
  logger.table(
201951
202098
  user.accounts.map((account) => ({
201952
202099
  "Account Name": account.name,
@@ -204720,7 +204867,7 @@ var import_node_http3 = require("node:http");
204720
204867
  var import_node_http22 = require("node:http2");
204721
204868
  var import_node_https = __toESM(require("node:https"));
204722
204869
  var import_http_terminator2 = __toESM(require_src5());
204723
- var import_miniflare14 = require("miniflare");
204870
+ var import_miniflare15 = require("miniflare");
204724
204871
  var import_react2 = __toESM(require_react());
204725
204872
  var import_serve_static = __toESM(require_serve_static());
204726
204873
 
@@ -204728,7 +204875,7 @@ var import_serve_static = __toESM(require_serve_static());
204728
204875
  init_import_meta_url();
204729
204876
  var fs25 = __toESM(require("node:fs"));
204730
204877
  var path61 = __toESM(require("node:path"));
204731
- var import_miniflare13 = require("miniflare");
204878
+ var import_miniflare14 = require("miniflare");
204732
204879
  var CERT_EXPIRY_DAYS = 30;
204733
204880
  var ONE_DAY_IN_MS = 864e5;
204734
204881
  function getHttpsOptions(customHttpsKeyPath, customHttpsCertPath) {
@@ -204822,7 +204969,7 @@ function generateCertificate() {
204822
204969
  name: "subjectAltName",
204823
204970
  altNames: [
204824
204971
  { type: 2, value: "localhost" },
204825
- ...(0, import_miniflare13.getAccessibleHosts)(false).map((ip2) => ({ type: 7, ip: ip2 }))
204972
+ ...(0, import_miniflare14.getAccessibleHosts)(false).map((ip2) => ({ type: 7, ip: ip2 }))
204826
204973
  ]
204827
204974
  }
204828
204975
  ]
@@ -204933,7 +205080,7 @@ async function startPreviewServer({
204933
205080
  logger.log(`\u2B23 Listening at ${localProtocol}://${ip2}:${usedPort}`);
204934
205081
  const accessibleHosts = [];
204935
205082
  if (ip2 === "::" || ip2 === "*" || ip2 === "0.0.0.0") {
204936
- accessibleHosts.push(...(0, import_miniflare14.getAccessibleHosts)(true));
205083
+ accessibleHosts.push(...(0, import_miniflare15.getAccessibleHosts)(true));
204937
205084
  if (ip2 !== "0.0.0.0") {
204938
205085
  accessibleHosts.push("localhost");
204939
205086
  accessibleHosts.push("[::1]");
@@ -206760,7 +206907,7 @@ init_import_meta_url();
206760
206907
  // src/cli-hotkeys.ts
206761
206908
  init_import_meta_url();
206762
206909
  var import_readline2 = __toESM(require("readline"));
206763
- var import_miniflare15 = require("miniflare");
206910
+ var import_miniflare16 = require("miniflare");
206764
206911
 
206765
206912
  // src/utils/onKeyPress.ts
206766
206913
  init_import_meta_url();
@@ -206840,16 +206987,16 @@ function cli_hotkeys_default(options29) {
206840
206987
  __name(printInstructions, "printInstructions");
206841
206988
  Logger.registerBeforeLogHook(clearPreviousInstructions);
206842
206989
  Logger.registerAfterLogHook(printInstructions);
206843
- import_miniflare15.Log.unstable_registerBeforeLogHook(clearPreviousInstructions);
206844
- import_miniflare15.Log.unstable_registerAfterLogHook(printInstructions);
206990
+ import_miniflare16.Log.unstable_registerBeforeLogHook(clearPreviousInstructions);
206991
+ import_miniflare16.Log.unstable_registerAfterLogHook(printInstructions);
206845
206992
  printInstructions();
206846
206993
  return () => {
206847
206994
  unregisterKeyPress();
206848
206995
  clearPreviousInstructions();
206849
206996
  Logger.registerBeforeLogHook(void 0);
206850
206997
  Logger.registerAfterLogHook(void 0);
206851
- import_miniflare15.Log.unstable_registerBeforeLogHook(void 0);
206852
- import_miniflare15.Log.unstable_registerAfterLogHook(void 0);
206998
+ import_miniflare16.Log.unstable_registerBeforeLogHook(void 0);
206999
+ import_miniflare16.Log.unstable_registerAfterLogHook(void 0);
206853
207000
  };
206854
207001
  }
206855
207002
  __name(cli_hotkeys_default, "default");
@@ -209258,7 +209405,7 @@ __name(ConfigController, "ConfigController");
209258
209405
  init_import_meta_url();
209259
209406
  var import_node_crypto8 = require("node:crypto");
209260
209407
  var import_promises24 = require("node:fs/promises");
209261
- var import_miniflare17 = require("miniflare");
209408
+ var import_miniflare18 = require("miniflare");
209262
209409
  async function getBinaryFileContents2(file) {
209263
209410
  if ("contents" in file) {
209264
209411
  if (file.contents instanceof Buffer) {
@@ -209368,7 +209515,7 @@ var LocalRuntimeController = class extends RuntimeController {
209368
209515
  // `buildMiniflareOptions()` is asynchronous, meaning if multiple bundle
209369
209516
  // updates were submitted, the second may apply before the first. Therefore,
209370
209517
  // wrap updates in a mutex, so they're always applied in invocation order.
209371
- #mutex = new import_miniflare17.Mutex();
209518
+ #mutex = new import_miniflare18.Mutex();
209372
209519
  #mf;
209373
209520
  onBundleStart(_3) {
209374
209521
  }
@@ -209381,7 +209528,7 @@ var LocalRuntimeController = class extends RuntimeController {
209381
209528
  );
209382
209529
  if (this.#mf === void 0) {
209383
209530
  logger.log(source_default.dim("\u2394 Starting local server..."));
209384
- this.#mf = new import_miniflare17.Miniflare(options29);
209531
+ this.#mf = new import_miniflare18.Miniflare(options29);
209385
209532
  } else {
209386
209533
  logger.log(source_default.dim("\u2394 Reloading local server..."));
209387
209534
  await this.#mf.setOptions(options29);
@@ -209482,7 +209629,7 @@ var import_node_assert23 = __toESM(require("node:assert"));
209482
209629
  var import_node_crypto9 = require("node:crypto");
209483
209630
  var import_node_events4 = __toESM(require("node:events"));
209484
209631
  var import_node_path65 = __toESM(require("node:path"));
209485
- var import_miniflare18 = require("miniflare");
209632
+ var import_miniflare19 = require("miniflare");
209486
209633
 
209487
209634
  // embed-worker:/home/runner/work/workers-sdk/workers-sdk/packages/wrangler/templates/startDevWorker/InspectorProxyWorker.ts
209488
209635
  init_import_meta_url();
@@ -209537,7 +209684,7 @@ var ProxyController = class extends Controller {
209537
209684
  PROXY_CONTROLLER: async (req) => {
209538
209685
  const message = await req.json();
209539
209686
  this.onProxyWorkerMessage(message);
209540
- return new import_miniflare18.Response(null, { status: 204 });
209687
+ return new import_miniflare19.Response(null, { status: 204 });
209541
209688
  }
209542
209689
  },
209543
209690
  bindings: {
@@ -209594,7 +209741,7 @@ var ProxyController = class extends Controller {
209594
209741
  proxyWorkerOptions
209595
209742
  );
209596
209743
  const willInstantiateMiniflareInstance = !this.proxyWorker || proxyWorkerOptionsChanged;
209597
- this.proxyWorker ??= new import_miniflare18.Miniflare(proxyWorkerOptions);
209744
+ this.proxyWorker ??= new import_miniflare19.Miniflare(proxyWorkerOptions);
209598
209745
  this.proxyWorkerOptions = proxyWorkerOptions;
209599
209746
  if (proxyWorkerOptionsChanged) {
209600
209747
  logger.debug("ProxyWorker miniflare options changed, reinstantiating...");
@@ -209667,7 +209814,7 @@ var ProxyController = class extends Controller {
209667
209814
  this.inspectorProxyWorkerWebSocket?.resolve(webSocket);
209668
209815
  return webSocket;
209669
209816
  }
209670
- runtimeMessageMutex = new import_miniflare18.Mutex();
209817
+ runtimeMessageMutex = new import_miniflare19.Mutex();
209671
209818
  async sendMessageToProxyWorker(message, retries = 3) {
209672
209819
  if (this._torndown) {
209673
209820
  return;
@@ -209822,15 +209969,15 @@ var ProxyController = class extends Controller {
209822
209969
  );
209823
209970
  }
209824
209971
  if (maybeContents === void 0) {
209825
- return new import_miniflare18.Response(null, { status: 404 });
209972
+ return new import_miniflare19.Response(null, { status: 404 });
209826
209973
  }
209827
- return new import_miniflare18.Response(maybeContents);
209974
+ return new import_miniflare19.Response(maybeContents);
209828
209975
  }
209829
209976
  default:
209830
209977
  assertNever(message);
209831
- return new import_miniflare18.Response(null, { status: 404 });
209978
+ return new import_miniflare19.Response(null, { status: 404 });
209832
209979
  }
209833
- return new import_miniflare18.Response(null, { status: 204 });
209980
+ return new import_miniflare19.Response(null, { status: 204 });
209834
209981
  }
209835
209982
  _torndown = false;
209836
209983
  async teardown() {
@@ -209883,7 +210030,7 @@ var ProxyController = class extends Controller {
209883
210030
  __name(ProxyController, "ProxyController");
209884
210031
  var ProxyControllerLogger = class extends WranglerLog {
209885
210032
  log(message) {
209886
- if (message.includes("/cdn-cgi/") && this.level < import_miniflare18.LogLevel.DEBUG) {
210033
+ if (message.includes("/cdn-cgi/") && this.level < import_miniflare19.LogLevel.DEBUG) {
209887
210034
  return;
209888
210035
  }
209889
210036
  super.log(message);
@@ -209904,7 +210051,7 @@ __name(didMiniflareOptionsChange, "didMiniflareOptionsChange");
209904
210051
 
209905
210052
  // src/api/startDevWorker/RemoteRuntimeController.ts
209906
210053
  init_import_meta_url();
209907
- var import_miniflare20 = require("miniflare");
210054
+ var import_miniflare21 = require("miniflare");
209908
210055
 
209909
210056
  // src/api/startDevWorker/NotImplementedError.ts
209910
210057
  init_import_meta_url();
@@ -209930,7 +210077,7 @@ __name(notImplemented, "notImplemented");
209930
210077
  var RemoteRuntimeController = class extends RuntimeController {
209931
210078
  #abortController = new AbortController();
209932
210079
  #currentBundleId = 0;
209933
- #mutex = new import_miniflare20.Mutex();
210080
+ #mutex = new import_miniflare21.Mutex();
209934
210081
  #session;
209935
210082
  async #previewSession(props) {
209936
210083
  try {
@@ -210311,7 +210458,7 @@ init_import_meta_url();
210311
210458
 
210312
210459
  // src/api/integrations/platform/index.ts
210313
210460
  init_import_meta_url();
210314
- var import_miniflare22 = require("miniflare");
210461
+ var import_miniflare23 = require("miniflare");
210315
210462
 
210316
210463
  // src/api/integrations/platform/caches.ts
210317
210464
  init_import_meta_url();
@@ -210358,15 +210505,21 @@ init_import_meta_url();
210358
210505
  var ExecutionContext = class {
210359
210506
  // eslint-disable-next-line @typescript-eslint/no-explicit-any, unused-imports/no-unused-vars
210360
210507
  waitUntil(promise) {
210508
+ if (!(this instanceof ExecutionContext)) {
210509
+ throw new Error("Illegal invocation");
210510
+ }
210361
210511
  }
210362
210512
  passThroughOnException() {
210513
+ if (!(this instanceof ExecutionContext)) {
210514
+ throw new Error("Illegal invocation");
210515
+ }
210363
210516
  }
210364
210517
  };
210365
210518
  __name(ExecutionContext, "ExecutionContext");
210366
210519
 
210367
210520
  // src/api/integrations/platform/services.ts
210368
210521
  init_import_meta_url();
210369
- var import_miniflare21 = require("miniflare");
210522
+ var import_miniflare22 = require("miniflare");
210370
210523
  var import_undici27 = __toESM(require_undici());
210371
210524
  async function getServiceBindings(services = []) {
210372
210525
  if (services.length === 0) {
@@ -210418,9 +210571,9 @@ function getServiceBindingProxyFetch({
210418
210571
  try {
210419
210572
  const resp = await (0, import_undici27.fetch)(newUrl, request3);
210420
210573
  const respBody = await resp.arrayBuffer();
210421
- return new import_miniflare21.Response(respBody, resp);
210574
+ return new import_miniflare22.Response(respBody, resp);
210422
210575
  } catch {
210423
- return new import_miniflare21.Response(
210576
+ return new import_miniflare22.Response(
210424
210577
  `Error: Unable to fetch from external service (${serviceName} bound with ${bindingName} binding), please make sure that the service is still running with \`wrangler dev\``,
210425
210578
  { status: 500 }
210426
210579
  );
@@ -210452,7 +210605,7 @@ async function getPlatformProxy(options29 = {}) {
210452
210605
  },
210453
210606
  () => getMiniflareOptionsFromConfig(rawConfig, env7, options29)
210454
210607
  );
210455
- const mf = new import_miniflare22.Miniflare({
210608
+ const mf = new import_miniflare23.Miniflare({
210456
210609
  script: "",
210457
210610
  modules: true,
210458
210611
  ...miniflareOptions
@@ -210558,7 +210711,7 @@ function unstable_getMiniflareWorkerOptions(configPath, env7) {
210558
210711
  if (bindings.services !== void 0) {
210559
210712
  bindingOptions.serviceBindings = Object.fromEntries(
210560
210713
  bindings.services.map((binding) => {
210561
- const name = binding.service === config.name ? import_miniflare22.kCurrentWorker : binding.service;
210714
+ const name = binding.service === config.name ? import_miniflare23.kCurrentWorker : binding.service;
210562
210715
  return [binding.binding, { name, entrypoint: binding.entrypoint }];
210563
210716
  })
210564
210717
  );