wrangler 2.1.0 → 2.1.3

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.
@@ -94180,6 +94180,7 @@ var require_get_intrinsic = __commonJS({
94180
94180
  var $spliceApply = bind.call(Function.apply, Array.prototype.splice);
94181
94181
  var $replace = bind.call(Function.call, String.prototype.replace);
94182
94182
  var $strSlice = bind.call(Function.call, String.prototype.slice);
94183
+ var $exec = bind.call(Function.call, RegExp.prototype.exec);
94183
94184
  var rePropName = /[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g;
94184
94185
  var reEscapeChar = /\\(\\)?/g;
94185
94186
  var stringToPath = function stringToPath2(string) {
@@ -94226,6 +94227,9 @@ var require_get_intrinsic = __commonJS({
94226
94227
  if (arguments.length > 1 && typeof allowMissing !== "boolean") {
94227
94228
  throw new $TypeError('"allowMissing" argument must be a boolean');
94228
94229
  }
94230
+ if ($exec(/^%?[^%]*%?$/g, name) === null) {
94231
+ throw new $SyntaxError("`%` may not be present anywhere but at the beginning and end of the intrinsic name");
94232
+ }
94229
94233
  var parts = stringToPath(name);
94230
94234
  var intrinsicBaseName = parts.length > 0 ? parts[0] : "";
94231
94235
  var intrinsic = getBaseIntrinsic("%" + intrinsicBaseName + "%", allowMissing);
@@ -94406,8 +94410,9 @@ var require_object_inspect = __commonJS({
94406
94410
  }
94407
94411
  return $replace.call(str, sepRegex, "$&_");
94408
94412
  }
94409
- var inspectCustom = require_util_inspect().custom;
94410
- var inspectSymbol = inspectCustom && isSymbol(inspectCustom) ? inspectCustom : null;
94413
+ var utilInspect2 = require_util_inspect();
94414
+ var inspectCustom = utilInspect2.custom;
94415
+ var inspectSymbol = isSymbol(inspectCustom) ? inspectCustom : null;
94411
94416
  module2.exports = function inspect_(obj, options, depth, seen) {
94412
94417
  var opts = options || {};
94413
94418
  if (has(opts, "quoteStyle") && (opts.quoteStyle !== "single" && opts.quoteStyle !== "double")) {
@@ -94479,7 +94484,7 @@ var require_object_inspect = __commonJS({
94479
94484
  }
94480
94485
  return inspect_(value, opts, depth + 1, seen);
94481
94486
  }
94482
- if (typeof obj === "function") {
94487
+ if (typeof obj === "function" && !isRegExp(obj)) {
94483
94488
  var name = nameOf(obj);
94484
94489
  var keys = arrObjKeys(obj, inspect2);
94485
94490
  return "[Function" + (name ? ": " + name : " (anonymous)") + "]" + (keys.length > 0 ? " { " + $join.call(keys, ", ") + " }" : "");
@@ -94513,7 +94518,7 @@ var require_object_inspect = __commonJS({
94513
94518
  }
94514
94519
  if (isError(obj)) {
94515
94520
  var parts = arrObjKeys(obj, inspect2);
94516
- if ("cause" in obj && !isEnumerable.call(obj, "cause")) {
94521
+ if (!("cause" in Error.prototype) && "cause" in obj && !isEnumerable.call(obj, "cause")) {
94517
94522
  return "{ [" + String(obj) + "] " + $join.call($concat.call("[cause]: " + inspect2(obj.cause), parts), ", ") + " }";
94518
94523
  }
94519
94524
  if (parts.length === 0) {
@@ -94522,8 +94527,8 @@ var require_object_inspect = __commonJS({
94522
94527
  return "{ [" + String(obj) + "] " + $join.call(parts, ", ") + " }";
94523
94528
  }
94524
94529
  if (typeof obj === "object" && customInspect) {
94525
- if (inspectSymbol && typeof obj[inspectSymbol] === "function") {
94526
- return obj[inspectSymbol]();
94530
+ if (inspectSymbol && typeof obj[inspectSymbol] === "function" && utilInspect2) {
94531
+ return utilInspect2(obj, { depth: maxDepth - depth });
94527
94532
  } else if (customInspect !== "symbol" && typeof obj.inspect === "function") {
94528
94533
  return obj.inspect();
94529
94534
  }
@@ -113039,6 +113044,38 @@ var require_object_keys = __commonJS({
113039
113044
  }
113040
113045
  });
113041
113046
 
113047
+ // ../../node_modules/has-property-descriptors/index.js
113048
+ var require_has_property_descriptors = __commonJS({
113049
+ "../../node_modules/has-property-descriptors/index.js"(exports2, module2) {
113050
+ "use strict";
113051
+ init_import_meta_url();
113052
+ var GetIntrinsic = require_get_intrinsic();
113053
+ var $defineProperty = GetIntrinsic("%Object.defineProperty%", true);
113054
+ var hasPropertyDescriptors = function hasPropertyDescriptors2() {
113055
+ if ($defineProperty) {
113056
+ try {
113057
+ $defineProperty({}, "a", { value: 1 });
113058
+ return true;
113059
+ } catch (e2) {
113060
+ return false;
113061
+ }
113062
+ }
113063
+ return false;
113064
+ };
113065
+ hasPropertyDescriptors.hasArrayLengthDefineBug = function hasArrayLengthDefineBug() {
113066
+ if (!hasPropertyDescriptors()) {
113067
+ return null;
113068
+ }
113069
+ try {
113070
+ return $defineProperty([], "length", { value: 1 }).length !== 1;
113071
+ } catch (e2) {
113072
+ return true;
113073
+ }
113074
+ };
113075
+ module2.exports = hasPropertyDescriptors;
113076
+ }
113077
+ });
113078
+
113042
113079
  // ../../node_modules/define-properties/index.js
113043
113080
  var require_define_properties = __commonJS({
113044
113081
  "../../node_modules/define-properties/index.js"(exports2, module2) {
@@ -113052,19 +113089,8 @@ var require_define_properties = __commonJS({
113052
113089
  var isFunction2 = function(fn) {
113053
113090
  return typeof fn === "function" && toStr.call(fn) === "[object Function]";
113054
113091
  };
113055
- var arePropertyDescriptorsSupported = function() {
113056
- var obj = {};
113057
- try {
113058
- origDefineProperty(obj, "x", { enumerable: false, value: obj });
113059
- for (var _2 in obj) {
113060
- return false;
113061
- }
113062
- return obj.x === obj;
113063
- } catch (e2) {
113064
- return false;
113065
- }
113066
- };
113067
- var supportsDescriptors = origDefineProperty && arePropertyDescriptorsSupported();
113092
+ var hasPropertyDescriptors = require_has_property_descriptors()();
113093
+ var supportsDescriptors = origDefineProperty && hasPropertyDescriptors;
113068
113094
  var defineProperty2 = function(object, name, value, predicate) {
113069
113095
  if (name in object && (!isFunction2(predicate) || !predicate())) {
113070
113096
  return;
@@ -138648,7 +138674,7 @@ var import_websocket_server = __toESM(require_websocket_server2(), 1);
138648
138674
  var wrapper_default = import_websocket.default;
138649
138675
 
138650
138676
  // package.json
138651
- var version = "2.1.0";
138677
+ var version = "2.1.3";
138652
138678
  var package_default = {
138653
138679
  name: "wrangler",
138654
138680
  version,
@@ -138799,6 +138825,7 @@ var package_default = {
138799
138825
  "jest-fetch-mock": "^3.0.3",
138800
138826
  "jest-websocket-mock": "^2.3.0",
138801
138827
  mime: "^3.0.0",
138828
+ msw: "^0.47.1",
138802
138829
  open: "^8.4.0",
138803
138830
  "p-queue": "^7.2.0",
138804
138831
  "pretty-bytes": "^6.0.0",
@@ -139913,7 +139940,7 @@ function useLocalWorker({
139913
139940
  port,
139914
139941
  inspectorPort,
139915
139942
  rules,
139916
- enableLocalPersistence,
139943
+ localPersistencePath,
139917
139944
  liveReload,
139918
139945
  ip,
139919
139946
  crons,
@@ -139928,7 +139955,6 @@ function useLocalWorker({
139928
139955
  const local = (0, import_react3.useRef)();
139929
139956
  const removeSignalExitListener = (0, import_react3.useRef)();
139930
139957
  const [inspectorUrl, setInspectorUrl] = (0, import_react3.useState)();
139931
- const localPersistencePath = enableLocalPersistence ? import_node_path13.default.join(process.cwd(), "wrangler-local-state") : null;
139932
139958
  (0, import_react3.useEffect)(() => {
139933
139959
  if (bindings.services && bindings.services.length > 0) {
139934
139960
  logger.warn(
@@ -143166,7 +143192,7 @@ function DevSession(props) {
143166
143192
  ip: props.ip,
143167
143193
  rules: props.rules,
143168
143194
  inspectorPort: props.inspectorPort,
143169
- enableLocalPersistence: props.enableLocalPersistence,
143195
+ localPersistencePath: props.localPersistencePath,
143170
143196
  liveReload: props.liveReload,
143171
143197
  crons: props.crons,
143172
143198
  localProtocol: props.localProtocol,
@@ -143449,7 +143475,7 @@ async function startDevServer(props) {
143449
143475
  ip: props.ip,
143450
143476
  rules: props.rules,
143451
143477
  inspectorPort: props.inspectorPort,
143452
- enableLocalPersistence: props.enableLocalPersistence,
143478
+ localPersistencePath: props.localPersistencePath,
143453
143479
  liveReload: props.liveReload,
143454
143480
  crons: props.crons,
143455
143481
  localProtocol: props.localProtocol,
@@ -143549,7 +143575,7 @@ async function startLocalServer({
143549
143575
  port,
143550
143576
  inspectorPort,
143551
143577
  rules,
143552
- enableLocalPersistence,
143578
+ localPersistencePath,
143553
143579
  liveReload,
143554
143580
  ip,
143555
143581
  crons,
@@ -143567,7 +143593,6 @@ async function startLocalServer({
143567
143593
  const setInspectorUrl = (url3) => {
143568
143594
  inspectorUrl = url3;
143569
143595
  };
143570
- const localPersistencePath = enableLocalPersistence ? path20.join(process.cwd(), "wrangler-local-state") : null;
143571
143596
  const abortController = new AbortController();
143572
143597
  async function startLocalWorker() {
143573
143598
  if (!bundle || !format4)
@@ -143823,6 +143848,8 @@ async function fromDashMessagePrompt(deploySource) {
143823
143848
  `You are about to publish a Workers Service that was last published via the Cloudflare Dashboard.
143824
143849
  Edits that have been made via the dashboard will be overridden by your local code and config.`
143825
143850
  );
143851
+ if (!isInteractive() || CI.isCI())
143852
+ return true;
143826
143853
  return await confirm("Would you like to continue?");
143827
143854
  }
143828
143855
  }
@@ -149699,9 +149726,19 @@ function Options2(yargs) {
149699
149726
  choices: ["http", "https"]
149700
149727
  },
149701
149728
  "experimental-enable-local-persistence": {
149729
+ describe: "Enable persistence for local mode (deprecated, use --persist)",
149702
149730
  type: "boolean",
149703
- default: false,
149704
- describe: "Enable persistence for this session (only for local mode)"
149731
+ deprecated: true,
149732
+ hidden: true
149733
+ },
149734
+ persist: {
149735
+ describe: "Enable persistence for local mode, using default path: .wrangler/state",
149736
+ type: "boolean"
149737
+ },
149738
+ "persist-to": {
149739
+ describe: "Specify directory to use for local persistence (implies --persist)",
149740
+ type: "string",
149741
+ requiresArg: true
149705
149742
  },
149706
149743
  "node-compat": {
149707
149744
  describe: "Enable node.js compatibility",
@@ -149732,7 +149769,9 @@ var Handler2 = async ({
149732
149769
  r2: r2s = [],
149733
149770
  "live-reload": liveReload,
149734
149771
  "local-protocol": localProtocol,
149735
- "experimental-enable-local-persistence": experimentalEnableLocalPersistence,
149772
+ experimentalEnableLocalPersistence,
149773
+ persist,
149774
+ persistTo,
149736
149775
  "node-compat": nodeCompat,
149737
149776
  config,
149738
149777
  _: [_pages, _dev, ...remaining]
@@ -149763,6 +149802,13 @@ var Handler2 = async ({
149763
149802
  } else {
149764
149803
  directory = (0, import_node_path26.resolve)(directory);
149765
149804
  }
149805
+ if (experimentalEnableLocalPersistence) {
149806
+ logger.warn(
149807
+ `--experimental-enable-local-persistence is deprecated.
149808
+ Move any existing data to .wrangler/state and use --persist, or
149809
+ use --persist-to=./wrangler-local-state to keep using the old path.`
149810
+ );
149811
+ }
149766
149812
  let scriptReadyResolve;
149767
149813
  const scriptReadyPromise = new Promise(
149768
149814
  (promiseResolve) => scriptReadyResolve = promiseResolve
@@ -149901,7 +149947,8 @@ var Handler2 = async ({
149901
149947
  directory
149902
149948
  },
149903
149949
  forceLocal: true,
149904
- experimentalEnableLocalPersistence,
149950
+ persist,
149951
+ persistTo,
149905
149952
  showInteractiveDevSession: void 0,
149906
149953
  inspect: true,
149907
149954
  logLevel: "error",
@@ -151529,14 +151576,20 @@ Update them to point to this script instead?`;
151529
151576
  async function publish(props) {
151530
151577
  const { config, accountId, name } = props;
151531
151578
  if (accountId && name) {
151532
- const serviceMetaData = await fetchResult(
151533
- `/accounts/${accountId}/workers/services/${name}`
151534
- );
151535
- const { default_environment } = serviceMetaData;
151536
- if (await fromDashMessagePrompt(
151537
- default_environment.script.last_deployed_from
151538
- ) === false)
151539
- return;
151579
+ try {
151580
+ const serviceMetaData = await fetchResult(
151581
+ `/accounts/${accountId}/workers/services/${name}`
151582
+ );
151583
+ const { default_environment } = serviceMetaData;
151584
+ if (await fromDashMessagePrompt(
151585
+ default_environment.script.last_deployed_from
151586
+ ) === false)
151587
+ return;
151588
+ } catch (e2) {
151589
+ if (e2.code !== 10090) {
151590
+ logger.error(e2);
151591
+ }
151592
+ }
151540
151593
  }
151541
151594
  if (!(props.compatibilityDate || config.compatibility_date)) {
151542
151595
  const compatibilityDateStr = `${new Date().getFullYear()}-${(new Date().getMonth() + 1 + "").padStart(2, "0")}-${(new Date().getDate() + "").padStart(2, "0")}`;
@@ -153741,6 +153794,77 @@ ${shouldDo}`);
153741
153794
  );
153742
153795
  }
153743
153796
  );
153797
+ wrangler.command(
153798
+ "secret:bulk <json>",
153799
+ "\u{1F5C4}\uFE0F Bulk upload secrets for a Worker",
153800
+ (yargs) => {
153801
+ return yargs.positional("json", {
153802
+ describe: `The JSON file of key-value pairs to upload, in form {"key": value, ...}`,
153803
+ type: "string",
153804
+ demandOption: "true"
153805
+ }).option("name", {
153806
+ describe: "Name of the Worker",
153807
+ type: "string",
153808
+ requiresArg: true
153809
+ }).option("env", {
153810
+ type: "string",
153811
+ requiresArg: true,
153812
+ describe: "Binds the secret to the Worker of the specific environment.",
153813
+ alias: "e"
153814
+ });
153815
+ },
153816
+ async (secretBulkArgs) => {
153817
+ await printWranglerBanner();
153818
+ const config = readConfig(
153819
+ secretBulkArgs.config,
153820
+ secretBulkArgs
153821
+ );
153822
+ const scriptName = getLegacyScriptName(secretBulkArgs, config);
153823
+ if (!scriptName) {
153824
+ throw new Error(
153825
+ "Required Worker name missing. Please specify the Worker name in wrangler.toml, or pass it as an argument with `--name <worker-name>`"
153826
+ );
153827
+ }
153828
+ const accountId = await requireAuth(config);
153829
+ logger.log(
153830
+ `\u{1F300} Creating the secrets for the Worker "${scriptName}" ${secretBulkArgs.env && !isLegacyEnv(config) ? `(${secretBulkArgs.env})` : ""}`
153831
+ );
153832
+ const jsonFilePath = import_node_path32.default.resolve(secretBulkArgs.json);
153833
+ const content = parseJSON(
153834
+ readFileSync5(jsonFilePath),
153835
+ jsonFilePath
153836
+ );
153837
+ for (const key2 in content) {
153838
+ if (typeof content[key2] !== "string") {
153839
+ throw new Error(
153840
+ `The value for ${key2} in ${jsonFilePath} is not a string.`
153841
+ );
153842
+ }
153843
+ }
153844
+ const url3 = !secretBulkArgs.env || isLegacyEnv(config) ? `/accounts/${accountId}/workers/scripts/${scriptName}/secrets` : `/accounts/${accountId}/workers/services/${scriptName}/environments/${secretBulkArgs.env}/secrets`;
153845
+ await Promise.allSettled(
153846
+ Object.entries(content).map(async ([key2, value]) => {
153847
+ return fetchResult(url3, {
153848
+ method: "PUT",
153849
+ headers: { "Content-Type": "application/json" },
153850
+ body: JSON.stringify({
153851
+ name: key2,
153852
+ text: value,
153853
+ type: "secret_text"
153854
+ })
153855
+ }).then(() => {
153856
+ logger.log(`\u2728 Successfully created secret for key: ${key2}`);
153857
+ }).catch((e2) => {
153858
+ logger.error(
153859
+ `\u{1F6A8} Error uploading secret for key: ${key2}:
153860
+ ${e2.message}`
153861
+ );
153862
+ });
153863
+ })
153864
+ );
153865
+ return logger.log("\u2728 Finished processing secrets JSON file");
153866
+ }
153867
+ );
153744
153868
  wrangler.command(
153745
153869
  "kv:namespace",
153746
153870
  "\u{1F5C2}\uFE0F Interact with your Workers KV Namespaces",
@@ -154744,8 +154868,17 @@ function devOptions(yargs) {
154744
154868
  describe: "Enable node.js compatibility",
154745
154869
  type: "boolean"
154746
154870
  }).option("experimental-enable-local-persistence", {
154747
- describe: "Enable persistence for this session (only for local mode)",
154871
+ describe: "Enable persistence for local mode (deprecated, use --persist)",
154872
+ type: "boolean",
154873
+ deprecated: true,
154874
+ hidden: true
154875
+ }).option("persist", {
154876
+ describe: "Enable persistence for local mode, using default path: .wrangler/state",
154748
154877
  type: "boolean"
154878
+ }).option("persist-to", {
154879
+ describe: "Specify directory to use for local persistence (implies --persist)",
154880
+ type: "string",
154881
+ requiresArg: true
154749
154882
  }).option("live-reload", {
154750
154883
  hidden: true,
154751
154884
  type: "boolean"
@@ -154800,7 +154933,8 @@ async function startDev(args) {
154800
154933
  routes,
154801
154934
  getLocalPort,
154802
154935
  getInspectorPort,
154803
- cliDefines
154936
+ cliDefines,
154937
+ localPersistencePath
154804
154938
  } = await validateDevServerSettings(args, config);
154805
154939
  await sendMetricsEvent(
154806
154940
  "run dev",
@@ -154836,7 +154970,7 @@ async function startDev(args) {
154836
154970
  upstreamProtocol,
154837
154971
  localProtocol: args.localProtocol || configParam.dev.local_protocol,
154838
154972
  localUpstream: args["local-upstream"] || host,
154839
- enableLocalPersistence: args.experimentalEnableLocalPersistence || false,
154973
+ localPersistencePath,
154840
154974
  liveReload: args.liveReload || false,
154841
154975
  accountId: configParam.account_id || getAccountFromCache()?.id,
154842
154976
  assetPaths,
@@ -154894,7 +155028,8 @@ async function startApiDev(args) {
154894
155028
  routes,
154895
155029
  getLocalPort,
154896
155030
  getInspectorPort,
154897
- cliDefines
155031
+ cliDefines,
155032
+ localPersistencePath
154898
155033
  } = await validateDevServerSettings(args, config);
154899
155034
  await sendMetricsEvent(
154900
155035
  "run dev (api)",
@@ -154927,7 +155062,7 @@ async function startApiDev(args) {
154927
155062
  upstreamProtocol,
154928
155063
  localProtocol: args.localProtocol || configParam.dev.local_protocol,
154929
155064
  localUpstream: args["local-upstream"] || host,
154930
- enableLocalPersistence: args.experimentalEnableLocalPersistence || false,
155065
+ localPersistencePath,
154931
155066
  liveReload: args.liveReload || false,
154932
155067
  accountId: configParam.account_id || getAccountFromCache()?.id,
154933
155068
  assetPaths,
@@ -155057,6 +155192,14 @@ async function validateDevServerSettings(args, config) {
155057
155192
  "Enabling node.js compatibility mode for built-ins and globals. This is experimental and has serious tradeoffs. Please see https://github.com/ionic-team/rollup-plugin-node-polyfills/ for more details."
155058
155193
  );
155059
155194
  }
155195
+ if (args.experimentalEnableLocalPersistence) {
155196
+ logger.warn(
155197
+ `--experimental-enable-local-persistence is deprecated.
155198
+ Move any existing data to .wrangler/state and use --persist, or
155199
+ use --persist-to=./wrangler-local-state to keep using the old path.`
155200
+ );
155201
+ }
155202
+ const localPersistencePath = args.persistTo ? import_node_path33.default.resolve(process.cwd(), args.persistTo) : args.persist ? import_node_path33.default.resolve(config.configPath || process.cwd(), ".wrangler/state") : null;
155060
155203
  const cliDefines = args.define?.reduce((collectDefines, d) => {
155061
155204
  const [key2, ...value] = d.split(":");
155062
155205
  collectDefines[key2] = value.join("");
@@ -155071,7 +155214,8 @@ async function validateDevServerSettings(args, config) {
155071
155214
  zoneId,
155072
155215
  host,
155073
155216
  routes,
155074
- cliDefines
155217
+ cliDefines,
155218
+ localPersistencePath
155075
155219
  };
155076
155220
  }
155077
155221
  async function getBindingsAndAssetPaths(args, configParam) {