wrangler 2.14.0 → 2.15.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.
@@ -441,11 +441,7 @@ async function generateHandler({
441
441
  async function generateResponse() {
442
442
  const match = staticRedirectsMatcher() || generateRedirectsMatcher()({ request })[0];
443
443
  if (match) {
444
- if (match.status === 200) {
445
- pathname = new URL(match.to, request.url).pathname;
446
- } else {
447
- return getResponseFromMatch(match, url);
448
- }
444
+ return getResponseFromMatch(match, url);
449
445
  }
450
446
  if (!request.method.match(/^(get|head)$/i)) {
451
447
  return new MethodNotAllowedResponse();
@@ -783,11 +779,11 @@ var init_handler = __esm({
783
779
  });
784
780
 
785
781
  // src/miniflare-cli/index.ts
786
- import { fetch } from "@miniflare/core";
787
782
  import {
788
783
  DurableObjectNamespace,
789
784
  DurableObjectStub
790
785
  } from "@miniflare/durable-objects";
786
+ import { upgradingFetch } from "@miniflare/web-sockets";
791
787
  import {
792
788
  Log as MiniflareLog,
793
789
  LogLevel as MiniflareLogLevel,
@@ -799,7 +795,7 @@ import {
799
795
  // ../../node_modules/yargs/lib/platform-shims/esm.mjs
800
796
  import { notStrictEqual, strictEqual } from "assert";
801
797
 
802
- // ../../node_modules/cliui/build/lib/index.js
798
+ // ../../node_modules/yargs/node_modules/cliui/build/lib/index.js
803
799
  var align = {
804
800
  right: alignRight,
805
801
  center: alignCenter
@@ -810,9 +806,9 @@ var bottom = 2;
810
806
  var left = 3;
811
807
  var UI = class {
812
808
  constructor(opts) {
813
- var _a;
809
+ var _a2;
814
810
  this.width = opts.width;
815
- this.wrap = (_a = opts.wrap) !== null && _a !== void 0 ? _a : true;
811
+ this.wrap = (_a2 = opts.wrap) !== null && _a2 !== void 0 ? _a2 : true;
816
812
  this.rows = [];
817
813
  }
818
814
  span(...args) {
@@ -1053,7 +1049,7 @@ function cliui(opts, _mixin) {
1053
1049
  });
1054
1050
  }
1055
1051
 
1056
- // ../../node_modules/cliui/build/lib/string-utils.js
1052
+ // ../../node_modules/yargs/node_modules/cliui/build/lib/string-utils.js
1057
1053
  var ansi = new RegExp("\x1B(?:\\[(?:\\d+[ABCDEFGJKSTm]|\\d+;\\d+[Hfm]|\\d+;\\d+;\\d+m|6n|s|u|\\?25[lh])|\\w)", "g");
1058
1054
  function stripAnsi(str) {
1059
1055
  return str.replace(ansi, "");
@@ -1074,7 +1070,7 @@ function wrap(str, width) {
1074
1070
  return wrapped;
1075
1071
  }
1076
1072
 
1077
- // ../../node_modules/cliui/index.mjs
1073
+ // ../../node_modules/yargs/node_modules/cliui/index.mjs
1078
1074
  function ui(opts) {
1079
1075
  return cliui(opts, {
1080
1076
  stringWidth: (str) => {
@@ -1365,9 +1361,9 @@ var YargsParser = class {
1365
1361
  let m;
1366
1362
  let next;
1367
1363
  let value;
1368
- if (arg !== "--" && isUnknownOptionAsArg(arg)) {
1364
+ if (arg !== "--" && /^-/.test(arg) && isUnknownOptionAsArg(arg)) {
1369
1365
  pushPositional(arg);
1370
- } else if (truncatedArg.match(/---+(=|$)/)) {
1366
+ } else if (truncatedArg.match(/^---+(=|$)/)) {
1371
1367
  pushPositional(arg);
1372
1368
  continue;
1373
1369
  } else if (arg.match(/^--.+=/) || !configuration["short-option-groups"] && arg.match(/^-.+=/)) {
@@ -2050,9 +2046,13 @@ function stripQuotes(val) {
2050
2046
 
2051
2047
  // ../../node_modules/yargs/node_modules/yargs-parser/build/lib/index.js
2052
2048
  import { readFileSync } from "fs";
2049
+ var _a;
2050
+ var _b;
2051
+ var _c;
2053
2052
  var minNodeVersion = process && process.env && process.env.YARGS_MIN_NODE_VERSION ? Number(process.env.YARGS_MIN_NODE_VERSION) : 12;
2054
- if (process && process.version) {
2055
- const major = Number(process.version.match(/v([^.]+)/)[1]);
2053
+ var nodeVersion = (_b = (_a = process === null || process === void 0 ? void 0 : process.versions) === null || _a === void 0 ? void 0 : _a.node) !== null && _b !== void 0 ? _b : (_c = process === null || process === void 0 ? void 0 : process.version) === null || _c === void 0 ? void 0 : _c.slice(1);
2054
+ if (nodeVersion) {
2055
+ const major = Number(nodeVersion.match(/^([^.]+)/)[1]);
2056
2056
  if (major < minNodeVersion) {
2057
2057
  throw Error(`yargs parser supports a minimum Node.js version of ${minNodeVersion}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`);
2058
2058
  }
@@ -2115,7 +2115,9 @@ var YError = class extends Error {
2115
2115
  constructor(msg) {
2116
2116
  super(msg || "yargs error");
2117
2117
  this.name = "YError";
2118
- Error.captureStackTrace(this, YError);
2118
+ if (Error.captureStackTrace) {
2119
+ Error.captureStackTrace(this, YError);
2120
+ }
2119
2121
  }
2120
2122
  };
2121
2123
 
@@ -2315,7 +2317,7 @@ try {
2315
2317
  } catch (e) {
2316
2318
  __dirname = process.cwd();
2317
2319
  }
2318
- var mainFilename = __dirname.split("node_modules")[0];
2320
+ var mainFilename = __dirname.substring(0, __dirname.lastIndexOf("node_modules"));
2319
2321
  var esm_default = {
2320
2322
  assert: {
2321
2323
  notStrictEqual,
@@ -2700,6 +2702,7 @@ var CommandInstance = class {
2700
2702
  const builder = commandHandler.builder;
2701
2703
  let innerYargs = yargs;
2702
2704
  if (isCommandBuilderCallback(builder)) {
2705
+ yargs.getInternalMethods().getUsageInstance().freeze();
2703
2706
  const builderOutput = builder(yargs.getInternalMethods().reset(aliases), helpOrVersionSet);
2704
2707
  if (isPromise(builderOutput)) {
2705
2708
  return builderOutput.then((output) => {
@@ -2708,6 +2711,7 @@ var CommandInstance = class {
2708
2711
  });
2709
2712
  }
2710
2713
  } else if (isCommandBuilderOptionDefinitions(builder)) {
2714
+ yargs.getInternalMethods().getUsageInstance().freeze();
2711
2715
  innerYargs = yargs.getInternalMethods().reset(aliases);
2712
2716
  Object.keys(commandHandler.builder).forEach((key) => {
2713
2717
  innerYargs.option(key, builder[key]);
@@ -2741,15 +2745,7 @@ var CommandInstance = class {
2741
2745
  pc.push(c);
2742
2746
  return `$0 ${pc.join(" ")}`;
2743
2747
  }
2744
- applyMiddlewareAndGetResult(isDefaultCommand, commandHandler, innerArgv, currentContext, helpOnly, aliases, yargs) {
2745
- let positionalMap = {};
2746
- if (helpOnly)
2747
- return innerArgv;
2748
- if (!yargs.getInternalMethods().getHasOutput()) {
2749
- positionalMap = this.populatePositionals(commandHandler, innerArgv, currentContext, yargs);
2750
- }
2751
- const middlewares = this.globalMiddleware.getMiddleware().slice(0).concat(commandHandler.middlewares);
2752
- innerArgv = applyMiddleware(innerArgv, yargs, middlewares, true);
2748
+ handleValidationAndGetResult(isDefaultCommand, commandHandler, innerArgv, currentContext, aliases, yargs, middlewares, positionalMap) {
2753
2749
  if (!yargs.getInternalMethods().getHasOutput()) {
2754
2750
  const validation2 = yargs.getInternalMethods().runValidation(aliases, positionalMap, yargs.parsed.error, isDefaultCommand);
2755
2751
  innerArgv = maybeAsyncResult(innerArgv, (result) => {
@@ -2784,6 +2780,17 @@ var CommandInstance = class {
2784
2780
  }
2785
2781
  return innerArgv;
2786
2782
  }
2783
+ applyMiddlewareAndGetResult(isDefaultCommand, commandHandler, innerArgv, currentContext, helpOnly, aliases, yargs) {
2784
+ let positionalMap = {};
2785
+ if (helpOnly)
2786
+ return innerArgv;
2787
+ if (!yargs.getInternalMethods().getHasOutput()) {
2788
+ positionalMap = this.populatePositionals(commandHandler, innerArgv, currentContext, yargs);
2789
+ }
2790
+ const middlewares = this.globalMiddleware.getMiddleware().slice(0).concat(commandHandler.middlewares);
2791
+ const maybePromiseArgv = applyMiddleware(innerArgv, yargs, middlewares, true);
2792
+ return isPromise(maybePromiseArgv) ? maybePromiseArgv.then((resolvedInnerArgv) => this.handleValidationAndGetResult(isDefaultCommand, commandHandler, resolvedInnerArgv, currentContext, aliases, yargs, middlewares, positionalMap)) : this.handleValidationAndGetResult(isDefaultCommand, commandHandler, maybePromiseArgv, currentContext, aliases, yargs, middlewares, positionalMap);
2793
+ }
2787
2794
  populatePositionals(commandHandler, argv, context, yargs) {
2788
2795
  argv._ = argv._.slice(context.commands.length);
2789
2796
  const demanded = commandHandler.demanded.slice(0);
@@ -2870,12 +2877,11 @@ var CommandInstance = class {
2870
2877
  Object.keys(positionalMap).forEach((key) => {
2871
2878
  positionalKeys.push(...parsed.aliases[key]);
2872
2879
  });
2873
- const defaults = yargs.getOptions().default;
2874
2880
  Object.keys(parsed.argv).forEach((key) => {
2875
2881
  if (positionalKeys.includes(key)) {
2876
2882
  if (!positionalMap[key])
2877
2883
  positionalMap[key] = parsed.argv[key];
2878
- if (!Object.hasOwnProperty.call(defaults, key) && Object.hasOwnProperty.call(argv, key) && Object.hasOwnProperty.call(parsed.argv, key) && (Array.isArray(argv[key]) || Array.isArray(parsed.argv[key]))) {
2884
+ if (!this.isInConfigs(yargs, key) && !this.isDefaulted(yargs, key) && Object.prototype.hasOwnProperty.call(argv, key) && Object.prototype.hasOwnProperty.call(parsed.argv, key) && (Array.isArray(argv[key]) || Array.isArray(parsed.argv[key]))) {
2879
2885
  argv[key] = [].concat(argv[key], parsed.argv[key]);
2880
2886
  } else {
2881
2887
  argv[key] = parsed.argv[key];
@@ -2884,6 +2890,14 @@ var CommandInstance = class {
2884
2890
  });
2885
2891
  }
2886
2892
  }
2893
+ isDefaulted(yargs, key) {
2894
+ const { default: defaults } = yargs.getOptions();
2895
+ return Object.prototype.hasOwnProperty.call(defaults, key) || Object.prototype.hasOwnProperty.call(defaults, this.shim.Parser.camelCase(key));
2896
+ }
2897
+ isInConfigs(yargs, key) {
2898
+ const { configObjects } = yargs.getOptions();
2899
+ return configObjects.some((c) => Object.prototype.hasOwnProperty.call(c, key)) || configObjects.some((c) => Object.prototype.hasOwnProperty.call(c, this.shim.Parser.camelCase(key)));
2900
+ }
2887
2901
  runDefaultBuilderOn(yargs) {
2888
2902
  if (!this.defaultCommand)
2889
2903
  return;
@@ -3111,13 +3125,16 @@ function usage(yargs, shim3) {
3111
3125
  wrapSet = true;
3112
3126
  wrap2 = cols;
3113
3127
  };
3114
- function getWrap() {
3128
+ self.getWrap = () => {
3129
+ if (shim3.getEnv("YARGS_DISABLE_WRAP")) {
3130
+ return null;
3131
+ }
3115
3132
  if (!wrapSet) {
3116
3133
  wrap2 = windowWidth();
3117
3134
  wrapSet = true;
3118
3135
  }
3119
3136
  return wrap2;
3120
- }
3137
+ };
3121
3138
  const deferY18nLookupPrefix = "__yargsString__:";
3122
3139
  self.deferY18nLookup = (str) => deferY18nLookupPrefix + str;
3123
3140
  self.help = function help() {
@@ -3141,7 +3158,7 @@ function usage(yargs, shim3) {
3141
3158
  acc[key] = true;
3142
3159
  return acc;
3143
3160
  }, {}));
3144
- const theWrap = getWrap();
3161
+ const theWrap = self.getWrap();
3145
3162
  const ui2 = shim3.cliui({
3146
3163
  width: theWrap,
3147
3164
  wrap: !!theWrap
@@ -3281,7 +3298,8 @@ function usage(yargs, shim3) {
3281
3298
  padding: [0, 2, 0, 2 + getIndentation(kswitch)],
3282
3299
  width: maxWidth(switches, theWrap) + 4
3283
3300
  }, desc);
3284
- if (extra)
3301
+ const shouldHideOptionExtras = yargs.getInternalMethods().getUsageConfiguration()["hide-types"] === true;
3302
+ if (extra && !shouldHideOptionExtras)
3285
3303
  ui2.div({ text: extra, padding: [0, 0, 0, 2], align: "right" });
3286
3304
  else
3287
3305
  ui2.div();
@@ -3542,7 +3560,7 @@ var completionZshTemplate = `#compdef {{app_name}}
3542
3560
  # yargs command completion script
3543
3561
  #
3544
3562
  # Installation: {{app_path}} {{completion_command}} >> ~/.zshrc
3545
- # or {{app_path}} {{completion_command}} >> ~/.zsh_profile on OSX.
3563
+ # or {{app_path}} {{completion_command}} >> ~/.zprofile on OSX.
3546
3564
  #
3547
3565
  _{{app_name}}_yargs_completions()
3548
3566
  {
@@ -3560,7 +3578,7 @@ compdef _{{app_name}}_yargs_completions {{app_name}}
3560
3578
  // ../../node_modules/yargs/build/lib/completion.js
3561
3579
  var Completion = class {
3562
3580
  constructor(yargs, usage2, command2, shim3) {
3563
- var _a, _b, _c;
3581
+ var _a2, _b2, _c2;
3564
3582
  this.yargs = yargs;
3565
3583
  this.usage = usage2;
3566
3584
  this.command = command2;
@@ -3569,7 +3587,7 @@ var Completion = class {
3569
3587
  this.aliases = null;
3570
3588
  this.customCompletionFunction = null;
3571
3589
  this.indexAfterLastReset = 0;
3572
- this.zshShell = (_c = ((_a = this.shim.getEnv("SHELL")) === null || _a === void 0 ? void 0 : _a.includes("zsh")) || ((_b = this.shim.getEnv("ZSH_NAME")) === null || _b === void 0 ? void 0 : _b.includes("zsh"))) !== null && _c !== void 0 ? _c : false;
3590
+ this.zshShell = (_c2 = ((_a2 = this.shim.getEnv("SHELL")) === null || _a2 === void 0 ? void 0 : _a2.includes("zsh")) || ((_b2 = this.shim.getEnv("ZSH_NAME")) === null || _b2 === void 0 ? void 0 : _b2.includes("zsh"))) !== null && _c2 !== void 0 ? _c2 : false;
3573
3591
  }
3574
3592
  defaultCompletion(args, argv, current, done) {
3575
3593
  const handlers = this.command.getCommandHandlers();
@@ -3614,7 +3632,7 @@ var Completion = class {
3614
3632
  Object.keys(options.key).forEach((key) => {
3615
3633
  const negable = !!options.configuration["boolean-negation"] && options.boolean.includes(key);
3616
3634
  const isPositionalKey = positionalKeys.includes(key);
3617
- if (!isPositionalKey && !options.hiddenOptions.includes(key) && !this.argsContainKey(args, argv, key, negable)) {
3635
+ if (!isPositionalKey && !options.hiddenOptions.includes(key) && !this.argsContainKey(args, key, negable)) {
3618
3636
  this.completeOptionKey(key, completions, current);
3619
3637
  if (negable && !!options.default[key])
3620
3638
  this.completeOptionKey(`no-${key}`, completions, current);
@@ -3679,20 +3697,22 @@ var Completion = class {
3679
3697
  const choices = this.getPreviousArgChoices(args);
3680
3698
  return choices !== void 0 && choices.length > 0;
3681
3699
  }
3682
- argsContainKey(args, argv, key, negable) {
3683
- if (args.indexOf(`--${key}`) !== -1)
3700
+ argsContainKey(args, key, negable) {
3701
+ const argsContains = (s) => args.indexOf((/^[^0-9]$/.test(s) ? "-" : "--") + s) !== -1;
3702
+ if (argsContains(key))
3684
3703
  return true;
3685
- if (negable && args.indexOf(`--no-${key}`) !== -1)
3704
+ if (negable && argsContains(`no-${key}`))
3686
3705
  return true;
3687
3706
  if (this.aliases) {
3688
3707
  for (const alias of this.aliases[key]) {
3689
- if (argv[alias] !== void 0)
3708
+ if (argsContains(alias))
3690
3709
  return true;
3691
3710
  }
3692
3711
  }
3693
3712
  return false;
3694
3713
  }
3695
3714
  completeOptionKey(key, completions, current) {
3715
+ var _a2, _b2, _c2;
3696
3716
  const descs = this.usage.getDescriptions();
3697
3717
  const startsByTwoDashes = (s) => /^--/.test(s);
3698
3718
  const isShortOption = (s) => /^[^0-9]$/.test(s);
@@ -3700,8 +3720,13 @@ var Completion = class {
3700
3720
  if (!this.zshShell) {
3701
3721
  completions.push(dashes + key);
3702
3722
  } else {
3703
- const desc = descs[key] || "";
3704
- completions.push(dashes + `${key.replace(/:/g, "\\:")}:${desc.replace("__yargsString__:", "")}`);
3723
+ const aliasKey = (_a2 = this === null || this === void 0 ? void 0 : this.aliases) === null || _a2 === void 0 ? void 0 : _a2[key].find((alias) => {
3724
+ const desc2 = descs[alias];
3725
+ return typeof desc2 === "string" && desc2.length > 0;
3726
+ });
3727
+ const descFromAlias = aliasKey ? descs[aliasKey] : void 0;
3728
+ const desc = (_c2 = (_b2 = descs[key]) !== null && _b2 !== void 0 ? _b2 : descFromAlias) !== null && _c2 !== void 0 ? _c2 : "";
3729
+ completions.push(dashes + `${key.replace(/:/g, "\\:")}:${desc.replace("__yargsString__:", "").replace(/(\r\n|\n|\r)/gm, " ")}`);
3705
3730
  }
3706
3731
  }
3707
3732
  customCompletion(args, argv, current, done) {
@@ -3846,7 +3871,7 @@ ${customMsgs.join("\n")}` : "";
3846
3871
  }
3847
3872
  };
3848
3873
  self.unknownArguments = function unknownArguments(argv, aliases, positionalMap, isDefaultCommand, checkPositionals = true) {
3849
- var _a;
3874
+ var _a2;
3850
3875
  const commandKeys = yargs.getInternalMethods().getCommandInstance().getCommands();
3851
3876
  const unknown = [];
3852
3877
  const currentContext = yargs.getInternalMethods().getContext();
@@ -3864,7 +3889,7 @@ ${customMsgs.join("\n")}` : "";
3864
3889
  }
3865
3890
  if (checkPositionals) {
3866
3891
  const demandedCommands = yargs.getDemandedCommands();
3867
- const maxNonOptDemanded = ((_a = demandedCommands._) === null || _a === void 0 ? void 0 : _a.max) || 0;
3892
+ const maxNonOptDemanded = ((_a2 = demandedCommands._) === null || _a2 === void 0 ? void 0 : _a2.max) || 0;
3868
3893
  const expected = currentContext.commands.length + maxNonOptDemanded;
3869
3894
  if (expected < argv._.length) {
3870
3895
  argv._.slice(expected).forEach((key) => {
@@ -4164,6 +4189,7 @@ var _YargsInstance_strict;
4164
4189
  var _YargsInstance_strictCommands;
4165
4190
  var _YargsInstance_strictOptions;
4166
4191
  var _YargsInstance_usage;
4192
+ var _YargsInstance_usageConfig;
4167
4193
  var _YargsInstance_versionOpt;
4168
4194
  var _YargsInstance_validation;
4169
4195
  function YargsFactory(_shim) {
@@ -4187,6 +4213,7 @@ var kEmitWarning = Symbol("emitWarning");
4187
4213
  var kFreeze = Symbol("freeze");
4188
4214
  var kGetDollarZero = Symbol("getDollarZero");
4189
4215
  var kGetParserConfiguration = Symbol("getParserConfiguration");
4216
+ var kGetUsageConfiguration = Symbol("getUsageConfiguration");
4190
4217
  var kGuessLocale = Symbol("guessLocale");
4191
4218
  var kGuessVersion = Symbol("guessVersion");
4192
4219
  var kParsePositionalNumbers = Symbol("parsePositionalNumbers");
@@ -4251,6 +4278,7 @@ var YargsInstance = class {
4251
4278
  _YargsInstance_strictCommands.set(this, false);
4252
4279
  _YargsInstance_strictOptions.set(this, false);
4253
4280
  _YargsInstance_usage.set(this, void 0);
4281
+ _YargsInstance_usageConfig.set(this, {});
4254
4282
  _YargsInstance_versionOpt.set(this, null);
4255
4283
  _YargsInstance_validation.set(this, void 0);
4256
4284
  __classPrivateFieldSet(this, _YargsInstance_shim, shim3, "f");
@@ -4360,7 +4388,7 @@ var YargsInstance = class {
4360
4388
  __classPrivateFieldGet(this, _YargsInstance_options, "f").key[keys] = true;
4361
4389
  __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").addCoerceMiddleware((argv, yargs) => {
4362
4390
  let aliases;
4363
- const shouldCoerce = Object.hasOwnProperty.call(argv, keys);
4391
+ const shouldCoerce = Object.prototype.hasOwnProperty.call(argv, keys);
4364
4392
  if (!shouldCoerce) {
4365
4393
  return argv;
4366
4394
  }
@@ -4675,7 +4703,7 @@ var YargsInstance = class {
4675
4703
  }
4676
4704
  locale(locale) {
4677
4705
  argsert("[string]", [locale], arguments.length);
4678
- if (!locale) {
4706
+ if (locale === void 0) {
4679
4707
  this[kGuessLocale]();
4680
4708
  return __classPrivateFieldGet(this, _YargsInstance_shim, "f").y18n.getLocale();
4681
4709
  }
@@ -4797,7 +4825,10 @@ var YargsInstance = class {
4797
4825
  this.skipValidation(key);
4798
4826
  }
4799
4827
  const desc = opt.describe || opt.description || opt.desc;
4800
- this.describe(key, desc);
4828
+ const descriptions = __classPrivateFieldGet(this, _YargsInstance_usage, "f").getDescriptions();
4829
+ if (!Object.prototype.hasOwnProperty.call(descriptions, key) || typeof desc === "string") {
4830
+ this.describe(key, desc);
4831
+ }
4801
4832
  if (opt.hidden) {
4802
4833
  this.hide(key);
4803
4834
  }
@@ -5038,6 +5069,11 @@ var YargsInstance = class {
5038
5069
  return this;
5039
5070
  }
5040
5071
  }
5072
+ usageConfiguration(config) {
5073
+ argsert("<object>", [config], arguments.length);
5074
+ __classPrivateFieldSet(this, _YargsInstance_usageConfig, config, "f");
5075
+ return this;
5076
+ }
5041
5077
  version(opt, msg, ver) {
5042
5078
  const defaultVersionOpt = "version";
5043
5079
  argsert("[boolean|string] [string] [string]", [opt, msg, ver], arguments.length);
@@ -5071,7 +5107,7 @@ var YargsInstance = class {
5071
5107
  __classPrivateFieldGet(this, _YargsInstance_usage, "f").wrap(cols);
5072
5108
  return this;
5073
5109
  }
5074
- [(_YargsInstance_command = /* @__PURE__ */ new WeakMap(), _YargsInstance_cwd = /* @__PURE__ */ new WeakMap(), _YargsInstance_context = /* @__PURE__ */ new WeakMap(), _YargsInstance_completion = /* @__PURE__ */ new WeakMap(), _YargsInstance_completionCommand = /* @__PURE__ */ new WeakMap(), _YargsInstance_defaultShowHiddenOpt = /* @__PURE__ */ new WeakMap(), _YargsInstance_exitError = /* @__PURE__ */ new WeakMap(), _YargsInstance_detectLocale = /* @__PURE__ */ new WeakMap(), _YargsInstance_emittedWarnings = /* @__PURE__ */ new WeakMap(), _YargsInstance_exitProcess = /* @__PURE__ */ new WeakMap(), _YargsInstance_frozens = /* @__PURE__ */ new WeakMap(), _YargsInstance_globalMiddleware = /* @__PURE__ */ new WeakMap(), _YargsInstance_groups = /* @__PURE__ */ new WeakMap(), _YargsInstance_hasOutput = /* @__PURE__ */ new WeakMap(), _YargsInstance_helpOpt = /* @__PURE__ */ new WeakMap(), _YargsInstance_isGlobalContext = /* @__PURE__ */ new WeakMap(), _YargsInstance_logger = /* @__PURE__ */ new WeakMap(), _YargsInstance_output = /* @__PURE__ */ new WeakMap(), _YargsInstance_options = /* @__PURE__ */ new WeakMap(), _YargsInstance_parentRequire = /* @__PURE__ */ new WeakMap(), _YargsInstance_parserConfig = /* @__PURE__ */ new WeakMap(), _YargsInstance_parseFn = /* @__PURE__ */ new WeakMap(), _YargsInstance_parseContext = /* @__PURE__ */ new WeakMap(), _YargsInstance_pkgs = /* @__PURE__ */ new WeakMap(), _YargsInstance_preservedGroups = /* @__PURE__ */ new WeakMap(), _YargsInstance_processArgs = /* @__PURE__ */ new WeakMap(), _YargsInstance_recommendCommands = /* @__PURE__ */ new WeakMap(), _YargsInstance_shim = /* @__PURE__ */ new WeakMap(), _YargsInstance_strict = /* @__PURE__ */ new WeakMap(), _YargsInstance_strictCommands = /* @__PURE__ */ new WeakMap(), _YargsInstance_strictOptions = /* @__PURE__ */ new WeakMap(), _YargsInstance_usage = /* @__PURE__ */ new WeakMap(), _YargsInstance_versionOpt = /* @__PURE__ */ new WeakMap(), _YargsInstance_validation = /* @__PURE__ */ new WeakMap(), kCopyDoubleDash)](argv) {
5110
+ [(_YargsInstance_command = /* @__PURE__ */ new WeakMap(), _YargsInstance_cwd = /* @__PURE__ */ new WeakMap(), _YargsInstance_context = /* @__PURE__ */ new WeakMap(), _YargsInstance_completion = /* @__PURE__ */ new WeakMap(), _YargsInstance_completionCommand = /* @__PURE__ */ new WeakMap(), _YargsInstance_defaultShowHiddenOpt = /* @__PURE__ */ new WeakMap(), _YargsInstance_exitError = /* @__PURE__ */ new WeakMap(), _YargsInstance_detectLocale = /* @__PURE__ */ new WeakMap(), _YargsInstance_emittedWarnings = /* @__PURE__ */ new WeakMap(), _YargsInstance_exitProcess = /* @__PURE__ */ new WeakMap(), _YargsInstance_frozens = /* @__PURE__ */ new WeakMap(), _YargsInstance_globalMiddleware = /* @__PURE__ */ new WeakMap(), _YargsInstance_groups = /* @__PURE__ */ new WeakMap(), _YargsInstance_hasOutput = /* @__PURE__ */ new WeakMap(), _YargsInstance_helpOpt = /* @__PURE__ */ new WeakMap(), _YargsInstance_isGlobalContext = /* @__PURE__ */ new WeakMap(), _YargsInstance_logger = /* @__PURE__ */ new WeakMap(), _YargsInstance_output = /* @__PURE__ */ new WeakMap(), _YargsInstance_options = /* @__PURE__ */ new WeakMap(), _YargsInstance_parentRequire = /* @__PURE__ */ new WeakMap(), _YargsInstance_parserConfig = /* @__PURE__ */ new WeakMap(), _YargsInstance_parseFn = /* @__PURE__ */ new WeakMap(), _YargsInstance_parseContext = /* @__PURE__ */ new WeakMap(), _YargsInstance_pkgs = /* @__PURE__ */ new WeakMap(), _YargsInstance_preservedGroups = /* @__PURE__ */ new WeakMap(), _YargsInstance_processArgs = /* @__PURE__ */ new WeakMap(), _YargsInstance_recommendCommands = /* @__PURE__ */ new WeakMap(), _YargsInstance_shim = /* @__PURE__ */ new WeakMap(), _YargsInstance_strict = /* @__PURE__ */ new WeakMap(), _YargsInstance_strictCommands = /* @__PURE__ */ new WeakMap(), _YargsInstance_strictOptions = /* @__PURE__ */ new WeakMap(), _YargsInstance_usage = /* @__PURE__ */ new WeakMap(), _YargsInstance_usageConfig = /* @__PURE__ */ new WeakMap(), _YargsInstance_versionOpt = /* @__PURE__ */ new WeakMap(), _YargsInstance_validation = /* @__PURE__ */ new WeakMap(), kCopyDoubleDash)](argv) {
5075
5111
  if (!argv._ || !argv["--"])
5076
5112
  return argv;
5077
5113
  argv._.push.apply(argv._, argv["--"]);
@@ -5163,6 +5199,9 @@ var YargsInstance = class {
5163
5199
  [kGetParserConfiguration]() {
5164
5200
  return __classPrivateFieldGet(this, _YargsInstance_parserConfig, "f");
5165
5201
  }
5202
+ [kGetUsageConfiguration]() {
5203
+ return __classPrivateFieldGet(this, _YargsInstance_usageConfig, "f");
5204
+ }
5166
5205
  [kGuessLocale]() {
5167
5206
  if (!__classPrivateFieldGet(this, _YargsInstance_detectLocale, "f"))
5168
5207
  return;
@@ -5246,20 +5285,20 @@ var YargsInstance = class {
5246
5285
  return this;
5247
5286
  }
5248
5287
  [kUnfreeze]() {
5249
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
5288
+ var _a2, _b2, _c2, _d, _e, _f, _g, _h, _j, _k, _l, _m;
5250
5289
  const frozen = __classPrivateFieldGet(this, _YargsInstance_frozens, "f").pop();
5251
5290
  assertNotStrictEqual(frozen, void 0, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
5252
5291
  let configObjects;
5253
- _a = this, _b = this, _c = this, _d = this, _e = this, _f = this, _g = this, _h = this, _j = this, _k = this, _l = this, _m = this, {
5292
+ _a2 = this, _b2 = this, _c2 = this, _d = this, _e = this, _f = this, _g = this, _h = this, _j = this, _k = this, _l = this, _m = this, {
5254
5293
  options: { set value(_o) {
5255
- __classPrivateFieldSet(_a, _YargsInstance_options, _o, "f");
5294
+ __classPrivateFieldSet(_a2, _YargsInstance_options, _o, "f");
5256
5295
  } }.value,
5257
5296
  configObjects,
5258
5297
  exitProcess: { set value(_o) {
5259
- __classPrivateFieldSet(_b, _YargsInstance_exitProcess, _o, "f");
5298
+ __classPrivateFieldSet(_b2, _YargsInstance_exitProcess, _o, "f");
5260
5299
  } }.value,
5261
5300
  groups: { set value(_o) {
5262
- __classPrivateFieldSet(_c, _YargsInstance_groups, _o, "f");
5301
+ __classPrivateFieldSet(_c2, _YargsInstance_groups, _o, "f");
5263
5302
  } }.value,
5264
5303
  output: { set value(_o) {
5265
5304
  __classPrivateFieldSet(_d, _YargsInstance_output, _o, "f");
@@ -5310,6 +5349,7 @@ var YargsInstance = class {
5310
5349
  getLoggerInstance: this[kGetLoggerInstance].bind(this),
5311
5350
  getParseContext: this[kGetParseContext].bind(this),
5312
5351
  getParserConfiguration: this[kGetParserConfiguration].bind(this),
5352
+ getUsageConfiguration: this[kGetUsageConfiguration].bind(this),
5313
5353
  getUsageInstance: this[kGetUsageInstance].bind(this),
5314
5354
  getValidationInstance: this[kGetValidationInstance].bind(this),
5315
5355
  hasParseCallback: this[kHasParseCallback].bind(this),
@@ -5619,7 +5659,7 @@ import { join } from "node:path";
5619
5659
  var REDIRECTS_VERSION = 1;
5620
5660
  var HEADERS_VERSION = 2;
5621
5661
  var ANALYTICS_VERSION = 1;
5622
- var PERMITTED_STATUS_CODES = /* @__PURE__ */ new Set([200, 301, 302, 303, 307, 308]);
5662
+ var PERMITTED_STATUS_CODES = /* @__PURE__ */ new Set([301, 302, 303, 307, 308]);
5623
5663
  var HEADER_SEPARATOR = ":";
5624
5664
  var MAX_LINE_LENGTH = 2e3;
5625
5665
  var MAX_HEADER_RULES = 100;
@@ -5998,7 +6038,7 @@ function parseRedirects(input) {
5998
6038
  invalid.push({
5999
6039
  line,
6000
6040
  lineNumber: i + 1,
6001
- message: `Valid status codes are 200, 301, 302 (default), 303, 307, or 308. Got ${str_status}.`
6041
+ message: `Valid status codes are 301, 302 (default), 303, 307, or 308. Got ${str_status}.`
6002
6042
  });
6003
6043
  continue;
6004
6044
  }
@@ -6011,19 +6051,6 @@ function parseRedirects(input) {
6011
6051
  continue;
6012
6052
  }
6013
6053
  seen_paths.add(from);
6014
- if (status === 200) {
6015
- const [proxyTo, error] = validateUrl(to, true, true, true);
6016
- if (error) {
6017
- invalid.push({
6018
- line,
6019
- lineNumber: i + 1,
6020
- message: `Proxy (200) redirects can only point to relative paths. Got ${to}`
6021
- });
6022
- continue;
6023
- }
6024
- rules.push({ from, to: proxyTo, status, lineNumber: i + 1 });
6025
- continue;
6026
- }
6027
6054
  rules.push({ from, to, status, lineNumber: i + 1 });
6028
6055
  }
6029
6056
  return {
@@ -6053,7 +6080,7 @@ async function generateASSETSBinding(options) {
6053
6080
  const miniflare = options.tre ? await import("@miniflare/tre") : await import("@miniflare/core");
6054
6081
  const Request = miniflare.Request;
6055
6082
  const Response2 = miniflare.Response;
6056
- const fetch2 = options.tre ? miniflare.fetch : (await import("@miniflare/web-sockets")).upgradingFetch;
6083
+ const fetch = options.tre ? miniflare.fetch : (await import("@miniflare/web-sockets")).upgradingFetch;
6057
6084
  return async function(miniflareRequest) {
6058
6085
  if (options.proxyPort) {
6059
6086
  try {
@@ -6064,7 +6091,7 @@ async function generateASSETSBinding(options) {
6064
6091
  proxyRequest.headers.delete("Sec-WebSocket-Accept");
6065
6092
  proxyRequest.headers.delete("Sec-WebSocket-Key");
6066
6093
  }
6067
- return await fetch2(proxyRequest);
6094
+ return await fetch(proxyRequest);
6068
6095
  } catch (thrown) {
6069
6096
  options.log.error(new Error(`Could not proxy request: ${thrown}`));
6070
6097
  return new Response2(`[wrangler] Could not proxy request: ${thrown}`, {
@@ -6264,7 +6291,7 @@ async function main() {
6264
6291
  "x-miniflare-durable-object-id",
6265
6292
  id.toString()
6266
6293
  );
6267
- return fetch(request);
6294
+ return upgradingFetch(request);
6268
6295
  };
6269
6296
  return stub;
6270
6297
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wrangler",
3
- "version": "2.14.0",
3
+ "version": "2.15.1",
4
4
  "description": "Command-line interface for all things Cloudflare Workers",
5
5
  "keywords": [
6
6
  "wrangler",
@@ -107,7 +107,7 @@ describe("generate", () => {
107
107
  });
108
108
 
109
109
  describe("cloning", () => {
110
- it.skip("clones a cloudflare template with sparse checkouts", async () => {
110
+ it("clones a cloudflare template with sparse checkouts", async () => {
111
111
  await expect(
112
112
  runWrangler("generate my-worker worker-typescript")
113
113
  ).resolves.toBeUndefined();
@@ -116,10 +116,9 @@ describe("generate", () => {
116
116
  ".git": expect.any(Object),
117
117
  ".gitignore": expect.any(String),
118
118
  "README.md": expect.stringContaining("Template: worker-typescript"),
119
- "jest.config.json": expect.any(String),
120
119
  "package.json": expect.stringContaining("@cloudflare/workers-types"),
121
- src: expect.objectContaining({ "index.ts": expect.any(String) }),
122
- test: expect.objectContaining({
120
+ src: expect.objectContaining({
121
+ "index.ts": expect.any(String),
123
122
  "index.test.ts": expect.any(String),
124
123
  }),
125
124
  "tsconfig.json": expect.any(String),
@@ -1,10 +1,11 @@
1
- import { logger } from "../logger";
1
+ import { Logger } from "../logger";
2
2
  import { mockConsoleMethods } from "./helpers/mock-console";
3
3
 
4
4
  describe("logger", () => {
5
5
  const std = mockConsoleMethods();
6
6
 
7
7
  it("should add colored markers to error and warning messages", () => {
8
+ const logger = new Logger();
8
9
  logger.loggerLevel = "debug";
9
10
  logger.debug("This is a debug message");
10
11
  logger.log("This is a log message");
@@ -27,6 +28,7 @@ describe("logger", () => {
27
28
 
28
29
  describe("loggerLevel=debug", () => {
29
30
  it("should render messages that are at or above the log level set in the logger", () => {
31
+ const logger = new Logger();
30
32
  logger.loggerLevel = "debug";
31
33
  logger.debug("This is a debug message");
32
34
  logger.log("This is a log message");
@@ -50,6 +52,7 @@ describe("logger", () => {
50
52
 
51
53
  describe("loggerLevel=log", () => {
52
54
  it("should render messages that are at or above the log level set in the logger", () => {
55
+ const logger = new Logger();
53
56
  logger.loggerLevel = "log";
54
57
  logger.debug("This is a debug message");
55
58
  logger.log("This is a log message");
@@ -73,6 +76,7 @@ describe("logger", () => {
73
76
 
74
77
  describe("loggerLevel=warn", () => {
75
78
  it("should render messages that are at or above the log level set in the logger", () => {
79
+ const logger = new Logger();
76
80
  logger.loggerLevel = "warn";
77
81
  logger.debug("This is a debug message");
78
82
  logger.log("This is a log message");
@@ -96,6 +100,7 @@ describe("logger", () => {
96
100
 
97
101
  describe("loggerLevel=error", () => {
98
102
  it("should render messages that are at or above the log level set in the logger", () => {
103
+ const logger = new Logger();
99
104
  logger.loggerLevel = "error";
100
105
  logger.debug("This is a debug message");
101
106
  logger.log("This is a log message");
@@ -122,7 +127,7 @@ describe("logger", () => {
122
127
  });
123
128
 
124
129
  it("should render messages that are at or above the log level set in the env var", () => {
125
- logger.loggerLevel = "error";
130
+ const logger = new Logger();
126
131
  logger.debug("This is a debug message");
127
132
  logger.log("This is a log message");
128
133
  logger.warn("This is a warn message");
@@ -138,4 +143,65 @@ describe("logger", () => {
138
143
  `);
139
144
  });
140
145
  });
146
+
147
+ describe("loggerLevelFromEnvVar case-insensitive", () => {
148
+ beforeEach(() => {
149
+ process.env.WRANGLER_LOG = "wARn";
150
+ });
151
+ afterEach(() => {
152
+ process.env.WRANGLER_LOG = undefined;
153
+ });
154
+
155
+ it("should render messages that are at or above the log level set in the env var", () => {
156
+ const logger = new Logger();
157
+ logger.debug("This is a debug message");
158
+ logger.log("This is a log message");
159
+ logger.warn("This is a warn message");
160
+ logger.error("This is a error message");
161
+
162
+ expect(std.debug).toMatchInlineSnapshot(`""`);
163
+ expect(std.out).toMatchInlineSnapshot(`""`);
164
+ expect(std.warn).toMatchInlineSnapshot(`
165
+ "▲ [WARNING] This is a warn message
166
+
167
+ "
168
+ `);
169
+ expect(std.err).toMatchInlineSnapshot(`
170
+ "X [ERROR] This is a error message
171
+
172
+ "
173
+ `);
174
+ });
175
+ });
176
+
177
+ describe("loggerLevelFromEnvVar falls back to log on invalid level", () => {
178
+ beforeEach(() => {
179
+ process.env.WRANGLER_LOG = "everything";
180
+ });
181
+ afterEach(() => {
182
+ process.env.WRANGLER_LOG = undefined;
183
+ });
184
+
185
+ it("should render messages that are at or above the log level set in the env var", () => {
186
+ const logger = new Logger();
187
+ logger.debug("This is a debug message");
188
+ logger.log("This is a log message");
189
+ logger.warn("This is a warn message");
190
+ logger.error("This is a error message");
191
+
192
+ expect(std.debug).toMatchInlineSnapshot(`""`);
193
+ expect(std.out).toMatchInlineSnapshot(`"This is a log message"`);
194
+ expect(std.warn).toMatchInlineSnapshot(`
195
+ "Unrecognised WRANGLER_LOG value \\"everything\\", expected \\"none\\" | \\"error\\" | \\"warn\\" | \\"info\\" | \\"log\\" | \\"debug\\", defaulting to \\"log\\"...
196
+ ▲ [WARNING] This is a warn message
197
+
198
+ "
199
+ `);
200
+ expect(std.err).toMatchInlineSnapshot(`
201
+ "X [ERROR] This is a error message
202
+
203
+ "
204
+ `);
205
+ });
206
+ });
141
207
  });