wrangler 0.0.0-e98613f8 → 0.0.0-e9a45766c

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (244) hide show
  1. package/README.md +10 -4
  2. package/bin/wrangler.js +10 -2
  3. package/miniflare-dist/index.mjs +257 -132
  4. package/package.json +26 -19
  5. package/src/__tests__/api-dev.test.ts +65 -36
  6. package/src/__tests__/api-devregistry.test.ts +121 -0
  7. package/src/__tests__/api.test.ts +27 -5
  8. package/src/__tests__/configuration.test.ts +575 -39
  9. package/src/__tests__/constellation.test.ts +371 -0
  10. package/src/__tests__/d1/d1.test.ts +82 -0
  11. package/src/__tests__/d1/execute.test.ts +66 -0
  12. package/src/__tests__/d1/migrate.test.ts +257 -0
  13. package/src/__tests__/d1/splitter.test.ts +255 -0
  14. package/src/__tests__/delete.test.ts +11 -2
  15. package/src/__tests__/deployments.test.ts +330 -52
  16. package/src/__tests__/dev.test.tsx +146 -82
  17. package/src/__tests__/generate.test.ts +10 -8
  18. package/src/__tests__/guess-worker-format.test.ts +35 -0
  19. package/src/__tests__/helpers/end-event-loop.ts +6 -0
  20. package/src/__tests__/helpers/mock-auth-domain.ts +20 -0
  21. package/src/__tests__/helpers/mock-console.ts +6 -0
  22. package/src/__tests__/helpers/mock-dialogs.ts +71 -85
  23. package/src/__tests__/helpers/mock-get-pages-upload-token.ts +25 -0
  24. package/src/__tests__/helpers/mock-get-zone-from-host.ts +8 -5
  25. package/src/__tests__/helpers/mock-known-routes.ts +7 -2
  26. package/src/__tests__/helpers/mock-kv.ts +29 -16
  27. package/src/__tests__/helpers/mock-oauth-flow.ts +99 -92
  28. package/src/__tests__/helpers/mock-process.ts +8 -13
  29. package/src/__tests__/helpers/mock-set-timeout.ts +16 -0
  30. package/src/__tests__/helpers/msw/blob-worker.cjs +19 -0
  31. package/src/__tests__/helpers/msw/handlers/deployments.ts +127 -26
  32. package/src/__tests__/helpers/msw/handlers/namespaces.ts +18 -41
  33. package/src/__tests__/helpers/msw/handlers/r2.ts +14 -34
  34. package/src/__tests__/helpers/msw/handlers/script.ts +9 -28
  35. package/src/__tests__/helpers/msw/handlers/user.ts +13 -24
  36. package/src/__tests__/helpers/msw/handlers/zones.ts +6 -8
  37. package/src/__tests__/helpers/msw/index.ts +32 -1
  38. package/src/__tests__/helpers/msw/read-file-sync.js +61 -0
  39. package/src/__tests__/helpers/string-dynamic-values-matcher.ts +28 -0
  40. package/src/__tests__/helpers/worker-scripts/parent-worker.js +4 -1
  41. package/src/__tests__/index.test.ts +92 -74
  42. package/src/__tests__/init.test.ts +909 -628
  43. package/src/__tests__/jest.setup.ts +19 -42
  44. package/src/__tests__/kv.test.ts +355 -231
  45. package/src/__tests__/logger.test.ts +68 -2
  46. package/src/__tests__/logout.test.ts +1 -1
  47. package/src/__tests__/metrics.test.ts +93 -50
  48. package/src/__tests__/middleware.scheduled.test.ts +42 -32
  49. package/src/__tests__/middleware.test.ts +212 -122
  50. package/src/__tests__/mtls-certificates.test.ts +589 -0
  51. package/src/__tests__/pages/deployment-list.test.ts +80 -0
  52. package/src/__tests__/pages/functions-build.test.ts +528 -0
  53. package/src/__tests__/pages/pages.test.ts +81 -0
  54. package/src/__tests__/pages/project-create.test.ts +63 -0
  55. package/src/__tests__/pages/project-list.test.ts +110 -0
  56. package/src/__tests__/pages/project-upload.test.ts +500 -0
  57. package/src/__tests__/pages/publish.test.ts +2864 -0
  58. package/src/__tests__/pages-deployment-tail.test.ts +239 -102
  59. package/src/__tests__/parse.test.ts +106 -0
  60. package/src/__tests__/publish.test.ts +2218 -1002
  61. package/src/__tests__/pubsub.test.ts +226 -100
  62. package/src/__tests__/queues.test.ts +42 -32
  63. package/src/__tests__/r2.test.ts +37 -56
  64. package/src/__tests__/secret.test.ts +179 -130
  65. package/src/__tests__/tail.test.ts +113 -23
  66. package/src/__tests__/test-old-node-version.js +3 -3
  67. package/src/__tests__/traverse-module-graph.test.ts +220 -0
  68. package/src/__tests__/tsconfig-sanity.ts +12 -0
  69. package/src/__tests__/tsconfig.json +8 -0
  70. package/src/__tests__/tsconfig.tsbuildinfo +1 -0
  71. package/src/__tests__/type-generation.test.ts +8 -0
  72. package/src/__tests__/user.test.ts +7 -18
  73. package/src/__tests__/whoami.test.tsx +8 -114
  74. package/src/__tests__/worker-namespace.test.ts +83 -69
  75. package/src/api/dev.ts +172 -61
  76. package/src/api/index.ts +10 -1
  77. package/src/api/mtls-certificate.ts +148 -0
  78. package/src/api/pages/create-worker-bundle-contents.ts +77 -0
  79. package/src/api/pages/index.ts +5 -0
  80. package/src/api/pages/publish.tsx +371 -0
  81. package/src/bundle.ts +139 -33
  82. package/src/cfetch/index.ts +0 -2
  83. package/src/cfetch/internal.ts +16 -21
  84. package/src/cli.ts +4 -4
  85. package/src/config/config.ts +14 -7
  86. package/src/config/environment.ts +80 -16
  87. package/src/config/index.ts +99 -30
  88. package/src/config/validation-helpers.ts +1 -1
  89. package/src/config/validation.ts +275 -9
  90. package/src/constellation/createProject.tsx +51 -0
  91. package/src/constellation/deleteProject.ts +51 -0
  92. package/src/constellation/deleteProjectModel.ts +68 -0
  93. package/src/constellation/index.ts +75 -0
  94. package/src/constellation/listCatalog.tsx +35 -0
  95. package/src/constellation/listModel.tsx +41 -0
  96. package/src/constellation/listProject.tsx +28 -0
  97. package/src/constellation/listRuntime.tsx +28 -0
  98. package/src/constellation/options.ts +17 -0
  99. package/src/constellation/types.ts +17 -0
  100. package/src/constellation/uploadModel.tsx +64 -0
  101. package/src/constellation/utils.ts +90 -0
  102. package/src/create-worker-preview.ts +19 -8
  103. package/src/create-worker-upload-form.ts +52 -5
  104. package/src/d1/backups.tsx +40 -44
  105. package/src/d1/create.tsx +50 -43
  106. package/src/d1/{delete.tsx → delete.ts} +8 -11
  107. package/src/d1/execute.tsx +171 -166
  108. package/src/d1/index.ts +5 -6
  109. package/src/d1/list.tsx +27 -13
  110. package/src/d1/migrations/apply.tsx +92 -64
  111. package/src/d1/migrations/create.tsx +31 -29
  112. package/src/d1/migrations/helpers.ts +66 -44
  113. package/src/d1/migrations/list.tsx +47 -31
  114. package/src/d1/migrations/options.ts +7 -2
  115. package/src/d1/options.ts +3 -3
  116. package/src/d1/splitter.ts +161 -0
  117. package/src/d1/{types.tsx → types.ts} +1 -0
  118. package/src/d1/utils.ts +2 -1
  119. package/src/delete.ts +8 -16
  120. package/src/deployments.ts +333 -42
  121. package/src/deprecated/index.ts +8 -302
  122. package/src/dev/dev.tsx +13 -22
  123. package/src/dev/local.tsx +131 -69
  124. package/src/dev/remote.tsx +35 -3
  125. package/src/dev/start-server.ts +83 -77
  126. package/src/dev/use-esbuild.ts +63 -52
  127. package/src/dev/validate-dev-props.ts +9 -0
  128. package/src/{dev-registry.tsx → dev-registry.ts} +9 -8
  129. package/src/dev.tsx +131 -110
  130. package/src/dialogs.ts +136 -0
  131. package/src/dispatch-namespace.ts +21 -17
  132. package/src/docs/helpers.ts +50 -0
  133. package/src/docs/index.ts +54 -0
  134. package/src/entry.ts +26 -11
  135. package/src/environment-variables/factory.ts +89 -0
  136. package/src/environment-variables/misc-variables.ts +30 -0
  137. package/src/generate/index.ts +298 -0
  138. package/src/{index.tsx → index.ts} +137 -56
  139. package/src/init.ts +254 -187
  140. package/src/inspect.ts +170 -9
  141. package/src/jest.d.ts +4 -0
  142. package/src/kv/helpers.ts +7 -4
  143. package/src/kv/index.ts +15 -17
  144. package/src/logger.ts +36 -5
  145. package/src/metrics/metrics-config.ts +1 -1
  146. package/src/metrics/send-event.ts +4 -1
  147. package/src/miniflare-cli/assets.ts +66 -31
  148. package/src/miniflare-cli/index.ts +5 -8
  149. package/src/miniflare-cli/tsconfig.json +9 -0
  150. package/src/miniflare-cli/tsconfig.tsbuildinfo +1 -0
  151. package/src/miniflare-cli/types.ts +11 -0
  152. package/src/module-collection.ts +92 -26
  153. package/src/mtls-certificate/cli.ts +155 -0
  154. package/src/pages/build.ts +423 -0
  155. package/src/pages/buildFunctions.ts +140 -0
  156. package/src/pages/{deployment-tails.tsx → deployment-tails.ts} +7 -10
  157. package/src/pages/deployments.tsx +9 -9
  158. package/src/pages/{dev.tsx → dev.ts} +167 -139
  159. package/src/pages/errors.ts +1 -0
  160. package/src/pages/functions/buildPlugin.ts +61 -54
  161. package/src/pages/functions/buildWorker.ts +217 -33
  162. package/src/pages/functions/tsconfig.json +8 -0
  163. package/src/pages/functions/tsconfig.tsbuildinfo +1 -0
  164. package/src/pages/{functions.tsx → functions.ts} +8 -4
  165. package/src/pages/{index.tsx → index.ts} +3 -3
  166. package/src/pages/projects.tsx +12 -22
  167. package/src/pages/publish.tsx +43 -227
  168. package/src/pages/types.ts +5 -0
  169. package/src/pages/upload.tsx +57 -14
  170. package/src/pages/utils.ts +1 -1
  171. package/src/parse.ts +23 -1
  172. package/src/paths.ts +1 -1
  173. package/src/publish/index.ts +20 -16
  174. package/src/publish/publish.ts +76 -46
  175. package/src/pubsub/{pubsub-commands.tsx → pubsub-commands.ts} +19 -20
  176. package/src/queues/cli/commands/consumer/add.ts +24 -24
  177. package/src/queues/cli/commands/consumer/index.ts +3 -6
  178. package/src/queues/cli/commands/consumer/remove.ts +11 -18
  179. package/src/queues/cli/commands/create.ts +8 -8
  180. package/src/queues/cli/commands/delete.ts +8 -8
  181. package/src/queues/cli/commands/index.ts +3 -4
  182. package/src/queues/cli/commands/list.ts +8 -8
  183. package/src/queues/client.ts +1 -0
  184. package/src/r2/helpers.ts +1 -0
  185. package/src/r2/index.ts +28 -28
  186. package/src/secret/index.ts +15 -16
  187. package/src/{sites.tsx → sites.ts} +165 -53
  188. package/src/tail/createTail.ts +37 -1
  189. package/src/tail/filters.ts +1 -1
  190. package/src/tail/index.ts +8 -11
  191. package/src/tail/printing.ts +25 -0
  192. package/src/traverse-module-graph.ts +54 -0
  193. package/src/tsconfig-sanity.ts +16 -0
  194. package/src/type-generation.ts +11 -3
  195. package/src/user/access.ts +0 -1
  196. package/src/user/auth-variables.ts +113 -0
  197. package/src/user/choose-account.tsx +1 -31
  198. package/src/user/index.ts +0 -1
  199. package/src/user/{user.tsx → user.ts} +114 -77
  200. package/src/utils/render.ts +93 -0
  201. package/src/{whoami.tsx → whoami.ts} +37 -71
  202. package/src/worker.ts +35 -1
  203. package/src/yargs-types.ts +18 -5
  204. package/templates/__tests__/tsconfig-sanity.ts +12 -0
  205. package/templates/__tests__/tsconfig.json +8 -0
  206. package/templates/__tests__/tsconfig.tsbuildinfo +1 -0
  207. package/templates/checked-fetch.js +9 -3
  208. package/templates/d1-beta-facade.js +42 -3
  209. package/templates/facade.d.ts +14 -0
  210. package/templates/first-party-worker-module-facade.ts +4 -3
  211. package/templates/format-dev-errors.ts +8 -6
  212. package/templates/gitignore +1 -0
  213. package/templates/init-tests/test-jest-new-worker.js +3 -5
  214. package/templates/init-tests/test-vitest-new-worker.js +3 -5
  215. package/templates/init-tests/test-vitest-new-worker.ts +25 -0
  216. package/templates/middleware/loader-modules.ts +2 -2
  217. package/templates/middleware/loader-sw.ts +6 -0
  218. package/templates/middleware/middleware-miniflare3-json-error.ts +17 -5
  219. package/templates/new-worker.ts +3 -0
  220. package/templates/pages-dev-pipeline.ts +4 -1
  221. package/templates/pages-shim.ts +4 -1
  222. package/templates/pages-template-plugin.ts +19 -10
  223. package/templates/serve-static-assets.ts +17 -14
  224. package/templates/service-bindings-module-facade.js +1 -0
  225. package/templates/tsconfig-sanity.ts +11 -0
  226. package/templates/tsconfig.init.json +105 -0
  227. package/templates/tsconfig.json +5 -103
  228. package/templates/tsconfig.tsbuildinfo +1 -0
  229. package/wrangler-dist/cli.d.ts +871 -73
  230. package/wrangler-dist/cli.js +80512 -90686
  231. package/wrangler-dist/wasm-sync.wasm +0 -0
  232. package/src/__tests__/api-devregistry.test.js +0 -56
  233. package/src/__tests__/d1.test.ts +0 -80
  234. package/src/__tests__/dialogs.test.tsx +0 -40
  235. package/src/__tests__/helpers/mock-cfetch.ts +0 -333
  236. package/src/__tests__/pages.test.ts +0 -2442
  237. package/src/dialogs.tsx +0 -168
  238. package/src/environment-variables.ts +0 -50
  239. package/src/pages/build.tsx +0 -270
  240. package/src/user/env-vars.ts +0 -46
  241. /package/src/{bundle-reporter.tsx → bundle-reporter.ts} +0 -0
  242. /package/src/d1/migrations/{index.tsx → index.ts} +0 -0
  243. /package/src/dev/{get-local-persistence-path.tsx → get-local-persistence-path.ts} +0 -0
  244. /package/src/pages/{hash.tsx → hash.ts} +0 -0
@@ -128,23 +128,45 @@ var init_environment_polyfills = __esm({
128
128
  }
129
129
  });
130
130
 
131
+ // ../pages-shared/environment-polyfills/miniflare-tre.ts
132
+ var miniflare_tre_exports = {};
133
+ __export(miniflare_tre_exports, {
134
+ default: () => miniflare_tre_default
135
+ });
136
+ var miniflare_tre_default;
137
+ var init_miniflare_tre = __esm({
138
+ "../pages-shared/environment-polyfills/miniflare-tre.ts"() {
139
+ init_environment_polyfills();
140
+ miniflare_tre_default = async () => {
141
+ const mf = await import("@miniflare/tre");
142
+ polyfill({
143
+ fetch: mf.fetch,
144
+ Headers: mf.Headers,
145
+ Request: mf.Request,
146
+ Response: mf.Response
147
+ });
148
+ };
149
+ }
150
+ });
151
+
131
152
  // ../pages-shared/environment-polyfills/miniflare.ts
132
153
  var miniflare_exports = {};
133
- import {
134
- fetch as miniflareFetch,
135
- Headers as MiniflareHeaders,
136
- Request as MiniflareRequest,
137
- Response as MiniflareResponse
138
- } from "@miniflare/core";
154
+ __export(miniflare_exports, {
155
+ default: () => miniflare_default
156
+ });
157
+ var miniflare_default;
139
158
  var init_miniflare = __esm({
140
159
  "../pages-shared/environment-polyfills/miniflare.ts"() {
141
160
  init_environment_polyfills();
142
- polyfill({
143
- fetch: miniflareFetch,
144
- Headers: MiniflareHeaders,
145
- Request: MiniflareRequest,
146
- Response: MiniflareResponse
147
- });
161
+ miniflare_default = async () => {
162
+ const mf = await import("@miniflare/core");
163
+ polyfill({
164
+ fetch: mf.fetch,
165
+ Headers: mf.Headers,
166
+ Request: mf.Request,
167
+ Response: mf.Response
168
+ });
169
+ };
148
170
  }
149
171
  });
150
172
 
@@ -157,6 +179,9 @@ function mergeHeaders(base, extra) {
157
179
  ...Object.fromEntries(extra.entries())
158
180
  });
159
181
  }
182
+ function stripLeadingDoubleSlashes(location) {
183
+ return location.replace(/^(\/|%2F|%2f|%5C|%5c|%09|\s|\\)+(.*)/, "/$2");
184
+ }
160
185
  var OkResponse, MovedPermanentlyResponse, FoundResponse, NotModifiedResponse, PermanentRedirectResponse, NotFoundResponse, MethodNotAllowedResponse, NotAcceptableResponse, InternalServerErrorResponse, SeeOtherResponse, TemporaryRedirectResponse;
161
186
  var init_responses = __esm({
162
187
  "../pages-shared/asset-server/responses.ts"() {
@@ -170,7 +195,12 @@ var init_responses = __esm({
170
195
  }
171
196
  };
172
197
  MovedPermanentlyResponse = class extends Response {
173
- constructor(location, init) {
198
+ constructor(location, init, {
199
+ preventLeadingDoubleSlash = true
200
+ } = {
201
+ preventLeadingDoubleSlash: true
202
+ }) {
203
+ location = preventLeadingDoubleSlash ? stripLeadingDoubleSlashes(location) : location;
174
204
  super(`Redirecting to ${location}`, {
175
205
  ...init,
176
206
  status: 301,
@@ -182,7 +212,12 @@ var init_responses = __esm({
182
212
  }
183
213
  };
184
214
  FoundResponse = class extends Response {
185
- constructor(location, init) {
215
+ constructor(location, init, {
216
+ preventLeadingDoubleSlash = true
217
+ } = {
218
+ preventLeadingDoubleSlash: true
219
+ }) {
220
+ location = preventLeadingDoubleSlash ? stripLeadingDoubleSlashes(location) : location;
186
221
  super(`Redirecting to ${location}`, {
187
222
  ...init,
188
223
  status: 302,
@@ -202,7 +237,12 @@ var init_responses = __esm({
202
237
  }
203
238
  };
204
239
  PermanentRedirectResponse = class extends Response {
205
- constructor(location, init) {
240
+ constructor(location, init, {
241
+ preventLeadingDoubleSlash = true
242
+ } = {
243
+ preventLeadingDoubleSlash: true
244
+ }) {
245
+ location = preventLeadingDoubleSlash ? stripLeadingDoubleSlashes(location) : location;
206
246
  super(void 0, {
207
247
  ...init,
208
248
  status: 308,
@@ -256,7 +296,12 @@ ${err.stack}`;
256
296
  }
257
297
  };
258
298
  SeeOtherResponse = class extends Response {
259
- constructor(location, init) {
299
+ constructor(location, init, {
300
+ preventLeadingDoubleSlash = true
301
+ } = {
302
+ preventLeadingDoubleSlash: true
303
+ }) {
304
+ location = preventLeadingDoubleSlash ? stripLeadingDoubleSlashes(location) : location;
260
305
  super(`Redirecting to ${location}`, {
261
306
  ...init,
262
307
  status: 303,
@@ -266,7 +311,12 @@ ${err.stack}`;
266
311
  }
267
312
  };
268
313
  TemporaryRedirectResponse = class extends Response {
269
- constructor(location, init) {
314
+ constructor(location, init, {
315
+ preventLeadingDoubleSlash = true
316
+ } = {
317
+ preventLeadingDoubleSlash: true
318
+ }) {
319
+ location = preventLeadingDoubleSlash ? stripLeadingDoubleSlashes(location) : location;
270
320
  super(`Redirecting to ${location}`, {
271
321
  ...init,
272
322
  status: 307,
@@ -409,21 +459,35 @@ async function generateHandler({
409
459
  async function generateResponse() {
410
460
  const match = staticRedirectsMatcher() || generateRedirectsMatcher()({ request })[0];
411
461
  if (match) {
412
- const { status, to } = match;
413
- const destination = new URL(to, request.url);
414
- const location = destination.origin === new URL(request.url).origin ? `${destination.pathname}${destination.search || search}${destination.hash}` : `${destination.href}${destination.search ? "" : search}${destination.hash}`;
415
- switch (status) {
416
- case 301:
417
- return new MovedPermanentlyResponse(location);
418
- case 303:
419
- return new SeeOtherResponse(location);
420
- case 307:
421
- return new TemporaryRedirectResponse(location);
422
- case 308:
423
- return new PermanentRedirectResponse(location);
424
- case 302:
425
- default:
426
- return new FoundResponse(location);
462
+ if (match.status === 200) {
463
+ pathname = new URL(match.to, request.url).pathname;
464
+ } else {
465
+ const { status, to } = match;
466
+ const destination = new URL(to, request.url);
467
+ const location = destination.origin === new URL(request.url).origin ? `${destination.pathname}${destination.search || search}${destination.hash}` : `${destination.href}${destination.search ? "" : search}${destination.hash}`;
468
+ switch (status) {
469
+ case 301:
470
+ return new MovedPermanentlyResponse(location, void 0, {
471
+ preventLeadingDoubleSlash: false
472
+ });
473
+ case 303:
474
+ return new SeeOtherResponse(location, void 0, {
475
+ preventLeadingDoubleSlash: false
476
+ });
477
+ case 307:
478
+ return new TemporaryRedirectResponse(location, void 0, {
479
+ preventLeadingDoubleSlash: false
480
+ });
481
+ case 308:
482
+ return new PermanentRedirectResponse(location, void 0, {
483
+ preventLeadingDoubleSlash: false
484
+ });
485
+ case 302:
486
+ default:
487
+ return new FoundResponse(location, void 0, {
488
+ preventLeadingDoubleSlash: false
489
+ });
490
+ }
427
491
  }
428
492
  }
429
493
  if (!request.method.match(/^(get|head)$/i)) {
@@ -652,7 +716,7 @@ async function generateHandler({
652
716
  return new HTMLRewriter().on("body", {
653
717
  element(e) {
654
718
  e.append(
655
- `<!-- Cloudflare Pages Analytics --><script defer src='https://static.cloudflareinsights.com/beacon.min.js' data-cf-beacon='{"token": "${metadata.analytics?.token}"}'><\/script><!-- Cloudflare Pages Analytics -->`,
719
+ `<!-- Cloudflare Pages Analytics --><script defer src='https://static.cloudflareinsights.com/beacon.min.js' data-cf-beacon='{"token": "${metadata.analytics?.token}"}'></script><!-- Cloudflare Pages Analytics -->`,
656
720
  { html: true }
657
721
  );
658
722
  }
@@ -740,23 +804,23 @@ var init_handler = __esm({
740
804
  });
741
805
 
742
806
  // src/miniflare-cli/index.ts
743
- import { fetch } from "@miniflare/core";
744
807
  import {
745
808
  DurableObjectNamespace,
746
809
  DurableObjectStub
747
810
  } from "@miniflare/durable-objects";
811
+ import { upgradingFetch } from "@miniflare/web-sockets";
748
812
  import {
749
813
  Log as MiniflareLog,
750
814
  LogLevel as MiniflareLogLevel,
751
815
  Miniflare,
752
- Request as MiniflareRequest3,
753
- Response as MiniflareResponse3
816
+ Request as MiniflareRequest,
817
+ Response as MiniflareResponse
754
818
  } from "miniflare";
755
819
 
756
820
  // ../../node_modules/yargs/lib/platform-shims/esm.mjs
757
821
  import { notStrictEqual, strictEqual } from "assert";
758
822
 
759
- // ../../node_modules/cliui/build/lib/index.js
823
+ // ../../node_modules/yargs/node_modules/cliui/build/lib/index.js
760
824
  var align = {
761
825
  right: alignRight,
762
826
  center: alignCenter
@@ -767,9 +831,9 @@ var bottom = 2;
767
831
  var left = 3;
768
832
  var UI = class {
769
833
  constructor(opts) {
770
- var _a;
834
+ var _a2;
771
835
  this.width = opts.width;
772
- this.wrap = (_a = opts.wrap) !== null && _a !== void 0 ? _a : true;
836
+ this.wrap = (_a2 = opts.wrap) !== null && _a2 !== void 0 ? _a2 : true;
773
837
  this.rows = [];
774
838
  }
775
839
  span(...args) {
@@ -1010,7 +1074,7 @@ function cliui(opts, _mixin) {
1010
1074
  });
1011
1075
  }
1012
1076
 
1013
- // ../../node_modules/cliui/build/lib/string-utils.js
1077
+ // ../../node_modules/yargs/node_modules/cliui/build/lib/string-utils.js
1014
1078
  var ansi = new RegExp("\x1B(?:\\[(?:\\d+[ABCDEFGJKSTm]|\\d+;\\d+[Hfm]|\\d+;\\d+;\\d+m|6n|s|u|\\?25[lh])|\\w)", "g");
1015
1079
  function stripAnsi(str) {
1016
1080
  return str.replace(ansi, "");
@@ -1031,7 +1095,7 @@ function wrap(str, width) {
1031
1095
  return wrapped;
1032
1096
  }
1033
1097
 
1034
- // ../../node_modules/cliui/index.mjs
1098
+ // ../../node_modules/yargs/node_modules/cliui/index.mjs
1035
1099
  function ui(opts) {
1036
1100
  return cliui(opts, {
1037
1101
  stringWidth: (str) => {
@@ -1322,9 +1386,9 @@ var YargsParser = class {
1322
1386
  let m;
1323
1387
  let next;
1324
1388
  let value;
1325
- if (arg !== "--" && isUnknownOptionAsArg(arg)) {
1389
+ if (arg !== "--" && /^-/.test(arg) && isUnknownOptionAsArg(arg)) {
1326
1390
  pushPositional(arg);
1327
- } else if (truncatedArg.match(/---+(=|$)/)) {
1391
+ } else if (truncatedArg.match(/^---+(=|$)/)) {
1328
1392
  pushPositional(arg);
1329
1393
  continue;
1330
1394
  } else if (arg.match(/^--.+=/) || !configuration["short-option-groups"] && arg.match(/^-.+=/)) {
@@ -2007,9 +2071,13 @@ function stripQuotes(val) {
2007
2071
 
2008
2072
  // ../../node_modules/yargs/node_modules/yargs-parser/build/lib/index.js
2009
2073
  import { readFileSync } from "fs";
2074
+ var _a;
2075
+ var _b;
2076
+ var _c;
2010
2077
  var minNodeVersion = process && process.env && process.env.YARGS_MIN_NODE_VERSION ? Number(process.env.YARGS_MIN_NODE_VERSION) : 12;
2011
- if (process && process.version) {
2012
- const major = Number(process.version.match(/v([^.]+)/)[1]);
2078
+ 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);
2079
+ if (nodeVersion) {
2080
+ const major = Number(nodeVersion.match(/^([^.]+)/)[1]);
2013
2081
  if (major < minNodeVersion) {
2014
2082
  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`);
2015
2083
  }
@@ -2072,7 +2140,9 @@ var YError = class extends Error {
2072
2140
  constructor(msg) {
2073
2141
  super(msg || "yargs error");
2074
2142
  this.name = "YError";
2075
- Error.captureStackTrace(this, YError);
2143
+ if (Error.captureStackTrace) {
2144
+ Error.captureStackTrace(this, YError);
2145
+ }
2076
2146
  }
2077
2147
  };
2078
2148
 
@@ -2272,7 +2342,7 @@ try {
2272
2342
  } catch (e) {
2273
2343
  __dirname = process.cwd();
2274
2344
  }
2275
- var mainFilename = __dirname.split("node_modules")[0];
2345
+ var mainFilename = __dirname.substring(0, __dirname.lastIndexOf("node_modules"));
2276
2346
  var esm_default = {
2277
2347
  assert: {
2278
2348
  notStrictEqual,
@@ -2657,6 +2727,7 @@ var CommandInstance = class {
2657
2727
  const builder = commandHandler.builder;
2658
2728
  let innerYargs = yargs;
2659
2729
  if (isCommandBuilderCallback(builder)) {
2730
+ yargs.getInternalMethods().getUsageInstance().freeze();
2660
2731
  const builderOutput = builder(yargs.getInternalMethods().reset(aliases), helpOrVersionSet);
2661
2732
  if (isPromise(builderOutput)) {
2662
2733
  return builderOutput.then((output) => {
@@ -2665,6 +2736,7 @@ var CommandInstance = class {
2665
2736
  });
2666
2737
  }
2667
2738
  } else if (isCommandBuilderOptionDefinitions(builder)) {
2739
+ yargs.getInternalMethods().getUsageInstance().freeze();
2668
2740
  innerYargs = yargs.getInternalMethods().reset(aliases);
2669
2741
  Object.keys(commandHandler.builder).forEach((key) => {
2670
2742
  innerYargs.option(key, builder[key]);
@@ -2698,15 +2770,7 @@ var CommandInstance = class {
2698
2770
  pc.push(c);
2699
2771
  return `$0 ${pc.join(" ")}`;
2700
2772
  }
2701
- applyMiddlewareAndGetResult(isDefaultCommand, commandHandler, innerArgv, currentContext, helpOnly, aliases, yargs) {
2702
- let positionalMap = {};
2703
- if (helpOnly)
2704
- return innerArgv;
2705
- if (!yargs.getInternalMethods().getHasOutput()) {
2706
- positionalMap = this.populatePositionals(commandHandler, innerArgv, currentContext, yargs);
2707
- }
2708
- const middlewares = this.globalMiddleware.getMiddleware().slice(0).concat(commandHandler.middlewares);
2709
- innerArgv = applyMiddleware(innerArgv, yargs, middlewares, true);
2773
+ handleValidationAndGetResult(isDefaultCommand, commandHandler, innerArgv, currentContext, aliases, yargs, middlewares, positionalMap) {
2710
2774
  if (!yargs.getInternalMethods().getHasOutput()) {
2711
2775
  const validation2 = yargs.getInternalMethods().runValidation(aliases, positionalMap, yargs.parsed.error, isDefaultCommand);
2712
2776
  innerArgv = maybeAsyncResult(innerArgv, (result) => {
@@ -2741,6 +2805,17 @@ var CommandInstance = class {
2741
2805
  }
2742
2806
  return innerArgv;
2743
2807
  }
2808
+ applyMiddlewareAndGetResult(isDefaultCommand, commandHandler, innerArgv, currentContext, helpOnly, aliases, yargs) {
2809
+ let positionalMap = {};
2810
+ if (helpOnly)
2811
+ return innerArgv;
2812
+ if (!yargs.getInternalMethods().getHasOutput()) {
2813
+ positionalMap = this.populatePositionals(commandHandler, innerArgv, currentContext, yargs);
2814
+ }
2815
+ const middlewares = this.globalMiddleware.getMiddleware().slice(0).concat(commandHandler.middlewares);
2816
+ const maybePromiseArgv = applyMiddleware(innerArgv, yargs, middlewares, true);
2817
+ 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);
2818
+ }
2744
2819
  populatePositionals(commandHandler, argv, context, yargs) {
2745
2820
  argv._ = argv._.slice(context.commands.length);
2746
2821
  const demanded = commandHandler.demanded.slice(0);
@@ -2827,12 +2902,11 @@ var CommandInstance = class {
2827
2902
  Object.keys(positionalMap).forEach((key) => {
2828
2903
  positionalKeys.push(...parsed.aliases[key]);
2829
2904
  });
2830
- const defaults = yargs.getOptions().default;
2831
2905
  Object.keys(parsed.argv).forEach((key) => {
2832
2906
  if (positionalKeys.includes(key)) {
2833
2907
  if (!positionalMap[key])
2834
2908
  positionalMap[key] = parsed.argv[key];
2835
- 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]))) {
2909
+ 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]))) {
2836
2910
  argv[key] = [].concat(argv[key], parsed.argv[key]);
2837
2911
  } else {
2838
2912
  argv[key] = parsed.argv[key];
@@ -2841,6 +2915,14 @@ var CommandInstance = class {
2841
2915
  });
2842
2916
  }
2843
2917
  }
2918
+ isDefaulted(yargs, key) {
2919
+ const { default: defaults } = yargs.getOptions();
2920
+ return Object.prototype.hasOwnProperty.call(defaults, key) || Object.prototype.hasOwnProperty.call(defaults, this.shim.Parser.camelCase(key));
2921
+ }
2922
+ isInConfigs(yargs, key) {
2923
+ const { configObjects } = yargs.getOptions();
2924
+ return configObjects.some((c) => Object.prototype.hasOwnProperty.call(c, key)) || configObjects.some((c) => Object.prototype.hasOwnProperty.call(c, this.shim.Parser.camelCase(key)));
2925
+ }
2844
2926
  runDefaultBuilderOn(yargs) {
2845
2927
  if (!this.defaultCommand)
2846
2928
  return;
@@ -3068,13 +3150,16 @@ function usage(yargs, shim3) {
3068
3150
  wrapSet = true;
3069
3151
  wrap2 = cols;
3070
3152
  };
3071
- function getWrap() {
3153
+ self.getWrap = () => {
3154
+ if (shim3.getEnv("YARGS_DISABLE_WRAP")) {
3155
+ return null;
3156
+ }
3072
3157
  if (!wrapSet) {
3073
3158
  wrap2 = windowWidth();
3074
3159
  wrapSet = true;
3075
3160
  }
3076
3161
  return wrap2;
3077
- }
3162
+ };
3078
3163
  const deferY18nLookupPrefix = "__yargsString__:";
3079
3164
  self.deferY18nLookup = (str) => deferY18nLookupPrefix + str;
3080
3165
  self.help = function help() {
@@ -3098,7 +3183,7 @@ function usage(yargs, shim3) {
3098
3183
  acc[key] = true;
3099
3184
  return acc;
3100
3185
  }, {}));
3101
- const theWrap = getWrap();
3186
+ const theWrap = self.getWrap();
3102
3187
  const ui2 = shim3.cliui({
3103
3188
  width: theWrap,
3104
3189
  wrap: !!theWrap
@@ -3238,7 +3323,8 @@ function usage(yargs, shim3) {
3238
3323
  padding: [0, 2, 0, 2 + getIndentation(kswitch)],
3239
3324
  width: maxWidth(switches, theWrap) + 4
3240
3325
  }, desc);
3241
- if (extra)
3326
+ const shouldHideOptionExtras = yargs.getInternalMethods().getUsageConfiguration()["hide-types"] === true;
3327
+ if (extra && !shouldHideOptionExtras)
3242
3328
  ui2.div({ text: extra, padding: [0, 0, 0, 2], align: "right" });
3243
3329
  else
3244
3330
  ui2.div();
@@ -3499,7 +3585,7 @@ var completionZshTemplate = `#compdef {{app_name}}
3499
3585
  # yargs command completion script
3500
3586
  #
3501
3587
  # Installation: {{app_path}} {{completion_command}} >> ~/.zshrc
3502
- # or {{app_path}} {{completion_command}} >> ~/.zsh_profile on OSX.
3588
+ # or {{app_path}} {{completion_command}} >> ~/.zprofile on OSX.
3503
3589
  #
3504
3590
  _{{app_name}}_yargs_completions()
3505
3591
  {
@@ -3517,7 +3603,7 @@ compdef _{{app_name}}_yargs_completions {{app_name}}
3517
3603
  // ../../node_modules/yargs/build/lib/completion.js
3518
3604
  var Completion = class {
3519
3605
  constructor(yargs, usage2, command2, shim3) {
3520
- var _a, _b, _c;
3606
+ var _a2, _b2, _c2;
3521
3607
  this.yargs = yargs;
3522
3608
  this.usage = usage2;
3523
3609
  this.command = command2;
@@ -3526,7 +3612,7 @@ var Completion = class {
3526
3612
  this.aliases = null;
3527
3613
  this.customCompletionFunction = null;
3528
3614
  this.indexAfterLastReset = 0;
3529
- 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;
3615
+ 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;
3530
3616
  }
3531
3617
  defaultCompletion(args, argv, current, done) {
3532
3618
  const handlers = this.command.getCommandHandlers();
@@ -3571,7 +3657,7 @@ var Completion = class {
3571
3657
  Object.keys(options.key).forEach((key) => {
3572
3658
  const negable = !!options.configuration["boolean-negation"] && options.boolean.includes(key);
3573
3659
  const isPositionalKey = positionalKeys.includes(key);
3574
- if (!isPositionalKey && !options.hiddenOptions.includes(key) && !this.argsContainKey(args, argv, key, negable)) {
3660
+ if (!isPositionalKey && !options.hiddenOptions.includes(key) && !this.argsContainKey(args, key, negable)) {
3575
3661
  this.completeOptionKey(key, completions, current);
3576
3662
  if (negable && !!options.default[key])
3577
3663
  this.completeOptionKey(`no-${key}`, completions, current);
@@ -3636,20 +3722,22 @@ var Completion = class {
3636
3722
  const choices = this.getPreviousArgChoices(args);
3637
3723
  return choices !== void 0 && choices.length > 0;
3638
3724
  }
3639
- argsContainKey(args, argv, key, negable) {
3640
- if (args.indexOf(`--${key}`) !== -1)
3725
+ argsContainKey(args, key, negable) {
3726
+ const argsContains = (s) => args.indexOf((/^[^0-9]$/.test(s) ? "-" : "--") + s) !== -1;
3727
+ if (argsContains(key))
3641
3728
  return true;
3642
- if (negable && args.indexOf(`--no-${key}`) !== -1)
3729
+ if (negable && argsContains(`no-${key}`))
3643
3730
  return true;
3644
3731
  if (this.aliases) {
3645
3732
  for (const alias of this.aliases[key]) {
3646
- if (argv[alias] !== void 0)
3733
+ if (argsContains(alias))
3647
3734
  return true;
3648
3735
  }
3649
3736
  }
3650
3737
  return false;
3651
3738
  }
3652
3739
  completeOptionKey(key, completions, current) {
3740
+ var _a2, _b2, _c2;
3653
3741
  const descs = this.usage.getDescriptions();
3654
3742
  const startsByTwoDashes = (s) => /^--/.test(s);
3655
3743
  const isShortOption = (s) => /^[^0-9]$/.test(s);
@@ -3657,8 +3745,13 @@ var Completion = class {
3657
3745
  if (!this.zshShell) {
3658
3746
  completions.push(dashes + key);
3659
3747
  } else {
3660
- const desc = descs[key] || "";
3661
- completions.push(dashes + `${key.replace(/:/g, "\\:")}:${desc.replace("__yargsString__:", "")}`);
3748
+ const aliasKey = (_a2 = this === null || this === void 0 ? void 0 : this.aliases) === null || _a2 === void 0 ? void 0 : _a2[key].find((alias) => {
3749
+ const desc2 = descs[alias];
3750
+ return typeof desc2 === "string" && desc2.length > 0;
3751
+ });
3752
+ const descFromAlias = aliasKey ? descs[aliasKey] : void 0;
3753
+ const desc = (_c2 = (_b2 = descs[key]) !== null && _b2 !== void 0 ? _b2 : descFromAlias) !== null && _c2 !== void 0 ? _c2 : "";
3754
+ completions.push(dashes + `${key.replace(/:/g, "\\:")}:${desc.replace("__yargsString__:", "").replace(/(\r\n|\n|\r)/gm, " ")}`);
3662
3755
  }
3663
3756
  }
3664
3757
  customCompletion(args, argv, current, done) {
@@ -3803,7 +3896,7 @@ ${customMsgs.join("\n")}` : "";
3803
3896
  }
3804
3897
  };
3805
3898
  self.unknownArguments = function unknownArguments(argv, aliases, positionalMap, isDefaultCommand, checkPositionals = true) {
3806
- var _a;
3899
+ var _a2;
3807
3900
  const commandKeys = yargs.getInternalMethods().getCommandInstance().getCommands();
3808
3901
  const unknown = [];
3809
3902
  const currentContext = yargs.getInternalMethods().getContext();
@@ -3821,7 +3914,7 @@ ${customMsgs.join("\n")}` : "";
3821
3914
  }
3822
3915
  if (checkPositionals) {
3823
3916
  const demandedCommands = yargs.getDemandedCommands();
3824
- const maxNonOptDemanded = ((_a = demandedCommands._) === null || _a === void 0 ? void 0 : _a.max) || 0;
3917
+ const maxNonOptDemanded = ((_a2 = demandedCommands._) === null || _a2 === void 0 ? void 0 : _a2.max) || 0;
3825
3918
  const expected = currentContext.commands.length + maxNonOptDemanded;
3826
3919
  if (expected < argv._.length) {
3827
3920
  argv._.slice(expected).forEach((key) => {
@@ -4121,6 +4214,7 @@ var _YargsInstance_strict;
4121
4214
  var _YargsInstance_strictCommands;
4122
4215
  var _YargsInstance_strictOptions;
4123
4216
  var _YargsInstance_usage;
4217
+ var _YargsInstance_usageConfig;
4124
4218
  var _YargsInstance_versionOpt;
4125
4219
  var _YargsInstance_validation;
4126
4220
  function YargsFactory(_shim) {
@@ -4144,6 +4238,7 @@ var kEmitWarning = Symbol("emitWarning");
4144
4238
  var kFreeze = Symbol("freeze");
4145
4239
  var kGetDollarZero = Symbol("getDollarZero");
4146
4240
  var kGetParserConfiguration = Symbol("getParserConfiguration");
4241
+ var kGetUsageConfiguration = Symbol("getUsageConfiguration");
4147
4242
  var kGuessLocale = Symbol("guessLocale");
4148
4243
  var kGuessVersion = Symbol("guessVersion");
4149
4244
  var kParsePositionalNumbers = Symbol("parsePositionalNumbers");
@@ -4208,6 +4303,7 @@ var YargsInstance = class {
4208
4303
  _YargsInstance_strictCommands.set(this, false);
4209
4304
  _YargsInstance_strictOptions.set(this, false);
4210
4305
  _YargsInstance_usage.set(this, void 0);
4306
+ _YargsInstance_usageConfig.set(this, {});
4211
4307
  _YargsInstance_versionOpt.set(this, null);
4212
4308
  _YargsInstance_validation.set(this, void 0);
4213
4309
  __classPrivateFieldSet(this, _YargsInstance_shim, shim3, "f");
@@ -4317,7 +4413,7 @@ var YargsInstance = class {
4317
4413
  __classPrivateFieldGet(this, _YargsInstance_options, "f").key[keys] = true;
4318
4414
  __classPrivateFieldGet(this, _YargsInstance_globalMiddleware, "f").addCoerceMiddleware((argv, yargs) => {
4319
4415
  let aliases;
4320
- const shouldCoerce = Object.hasOwnProperty.call(argv, keys);
4416
+ const shouldCoerce = Object.prototype.hasOwnProperty.call(argv, keys);
4321
4417
  if (!shouldCoerce) {
4322
4418
  return argv;
4323
4419
  }
@@ -4528,12 +4624,12 @@ var YargsInstance = class {
4528
4624
  async getCompletion(args, done) {
4529
4625
  argsert("<array> [function]", [args, done], arguments.length);
4530
4626
  if (!done) {
4531
- return new Promise((resolve5, reject) => {
4627
+ return new Promise((resolve6, reject) => {
4532
4628
  __classPrivateFieldGet(this, _YargsInstance_completion, "f").getCompletion(args, (err, completions) => {
4533
4629
  if (err)
4534
4630
  reject(err);
4535
4631
  else
4536
- resolve5(completions);
4632
+ resolve6(completions);
4537
4633
  });
4538
4634
  });
4539
4635
  } else {
@@ -4632,7 +4728,7 @@ var YargsInstance = class {
4632
4728
  }
4633
4729
  locale(locale) {
4634
4730
  argsert("[string]", [locale], arguments.length);
4635
- if (!locale) {
4731
+ if (locale === void 0) {
4636
4732
  this[kGuessLocale]();
4637
4733
  return __classPrivateFieldGet(this, _YargsInstance_shim, "f").y18n.getLocale();
4638
4734
  }
@@ -4754,7 +4850,10 @@ var YargsInstance = class {
4754
4850
  this.skipValidation(key);
4755
4851
  }
4756
4852
  const desc = opt.describe || opt.description || opt.desc;
4757
- this.describe(key, desc);
4853
+ const descriptions = __classPrivateFieldGet(this, _YargsInstance_usage, "f").getDescriptions();
4854
+ if (!Object.prototype.hasOwnProperty.call(descriptions, key) || typeof desc === "string") {
4855
+ this.describe(key, desc);
4856
+ }
4758
4857
  if (opt.hidden) {
4759
4858
  this.hide(key);
4760
4859
  }
@@ -4995,6 +5094,11 @@ var YargsInstance = class {
4995
5094
  return this;
4996
5095
  }
4997
5096
  }
5097
+ usageConfiguration(config) {
5098
+ argsert("<object>", [config], arguments.length);
5099
+ __classPrivateFieldSet(this, _YargsInstance_usageConfig, config, "f");
5100
+ return this;
5101
+ }
4998
5102
  version(opt, msg, ver) {
4999
5103
  const defaultVersionOpt = "version";
5000
5104
  argsert("[boolean|string] [string] [string]", [opt, msg, ver], arguments.length);
@@ -5028,7 +5132,7 @@ var YargsInstance = class {
5028
5132
  __classPrivateFieldGet(this, _YargsInstance_usage, "f").wrap(cols);
5029
5133
  return this;
5030
5134
  }
5031
- [(_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) {
5135
+ [(_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) {
5032
5136
  if (!argv._ || !argv["--"])
5033
5137
  return argv;
5034
5138
  argv._.push.apply(argv._, argv["--"]);
@@ -5120,6 +5224,9 @@ var YargsInstance = class {
5120
5224
  [kGetParserConfiguration]() {
5121
5225
  return __classPrivateFieldGet(this, _YargsInstance_parserConfig, "f");
5122
5226
  }
5227
+ [kGetUsageConfiguration]() {
5228
+ return __classPrivateFieldGet(this, _YargsInstance_usageConfig, "f");
5229
+ }
5123
5230
  [kGuessLocale]() {
5124
5231
  if (!__classPrivateFieldGet(this, _YargsInstance_detectLocale, "f"))
5125
5232
  return;
@@ -5203,20 +5310,20 @@ var YargsInstance = class {
5203
5310
  return this;
5204
5311
  }
5205
5312
  [kUnfreeze]() {
5206
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
5313
+ var _a2, _b2, _c2, _d, _e, _f, _g, _h, _j, _k, _l, _m;
5207
5314
  const frozen = __classPrivateFieldGet(this, _YargsInstance_frozens, "f").pop();
5208
5315
  assertNotStrictEqual(frozen, void 0, __classPrivateFieldGet(this, _YargsInstance_shim, "f"));
5209
5316
  let configObjects;
5210
- _a = this, _b = this, _c = this, _d = this, _e = this, _f = this, _g = this, _h = this, _j = this, _k = this, _l = this, _m = this, {
5317
+ _a2 = this, _b2 = this, _c2 = this, _d = this, _e = this, _f = this, _g = this, _h = this, _j = this, _k = this, _l = this, _m = this, {
5211
5318
  options: { set value(_o) {
5212
- __classPrivateFieldSet(_a, _YargsInstance_options, _o, "f");
5319
+ __classPrivateFieldSet(_a2, _YargsInstance_options, _o, "f");
5213
5320
  } }.value,
5214
5321
  configObjects,
5215
5322
  exitProcess: { set value(_o) {
5216
- __classPrivateFieldSet(_b, _YargsInstance_exitProcess, _o, "f");
5323
+ __classPrivateFieldSet(_b2, _YargsInstance_exitProcess, _o, "f");
5217
5324
  } }.value,
5218
5325
  groups: { set value(_o) {
5219
- __classPrivateFieldSet(_c, _YargsInstance_groups, _o, "f");
5326
+ __classPrivateFieldSet(_c2, _YargsInstance_groups, _o, "f");
5220
5327
  } }.value,
5221
5328
  output: { set value(_o) {
5222
5329
  __classPrivateFieldSet(_d, _YargsInstance_output, _o, "f");
@@ -5267,6 +5374,7 @@ var YargsInstance = class {
5267
5374
  getLoggerInstance: this[kGetLoggerInstance].bind(this),
5268
5375
  getParseContext: this[kGetParseContext].bind(this),
5269
5376
  getParserConfiguration: this[kGetParserConfiguration].bind(this),
5377
+ getUsageConfiguration: this[kGetUsageConfiguration].bind(this),
5270
5378
  getUsageInstance: this[kGetUsageInstance].bind(this),
5271
5379
  getValidationInstance: this[kGetValidationInstance].bind(this),
5272
5380
  hasParseCallback: this[kHasParseCallback].bind(this),
@@ -5570,13 +5678,13 @@ var FatalError = class extends Error {
5570
5678
 
5571
5679
  // src/miniflare-cli/assets.ts
5572
5680
  import { existsSync, lstatSync, readFileSync as readFileSync5 } from "node:fs";
5573
- import { join } from "node:path";
5681
+ import { join, resolve as resolve5 } from "node:path";
5574
5682
 
5575
5683
  // ../pages-shared/metadata-generator/constants.ts
5576
5684
  var REDIRECTS_VERSION = 1;
5577
5685
  var HEADERS_VERSION = 2;
5578
5686
  var ANALYTICS_VERSION = 1;
5579
- var PERMITTED_STATUS_CODES = /* @__PURE__ */ new Set([301, 302, 303, 307, 308]);
5687
+ var PERMITTED_STATUS_CODES = /* @__PURE__ */ new Set([200, 301, 302, 303, 307, 308]);
5580
5688
  var HEADER_SEPARATOR = ":";
5581
5689
  var MAX_LINE_LENGTH = 2e3;
5582
5690
  var MAX_HEADER_RULES = 100;
@@ -5632,7 +5740,11 @@ function constructRedirects({
5632
5740
  for (const rule of redirects.rules) {
5633
5741
  if (!rule.from.match(SPLAT_REGEX) && !rule.from.match(PLACEHOLDER_REGEX)) {
5634
5742
  if (canCreateStaticRule) {
5635
- staticRedirects[rule.from] = { status: rule.status, to: rule.to };
5743
+ staticRedirects[rule.from] = {
5744
+ status: rule.status,
5745
+ to: rule.to,
5746
+ lineNumber: rule.lineNumber
5747
+ };
5636
5748
  continue;
5637
5749
  } else {
5638
5750
  logger(
@@ -5743,6 +5855,10 @@ var validateUrl = (token, onlyRelative = false, includeSearch = false, includeHa
5743
5855
  onlyRelative ? "URLs should begin with a forward-slash." : 'URLs should either be relative (e.g. begin with a forward-slash), or use HTTPS (e.g. begin with "https://").'
5744
5856
  ];
5745
5857
  };
5858
+ function urlHasHost(token) {
5859
+ const host = URL_REGEX.exec(token);
5860
+ return Boolean(host && host.groups && host.groups.host);
5861
+ }
5746
5862
 
5747
5863
  // ../pages-shared/metadata-generator/parseHeaders.ts
5748
5864
  var LINE_IS_PROBABLY_A_PATH = new RegExp(/^([^\s]+:\/\/|^\/)/);
@@ -5951,7 +6067,15 @@ function parseRedirects(input) {
5951
6067
  invalid.push({
5952
6068
  line,
5953
6069
  lineNumber: i + 1,
5954
- message: `Valid status codes are 301, 302 (default), 303, 307, or 308. Got ${str_status}.`
6070
+ message: `Valid status codes are 200, 301, 302 (default), 303, 307, or 308. Got ${str_status}.`
6071
+ });
6072
+ continue;
6073
+ }
6074
+ if (/\/\*?$/.test(from) && /\/index(.html)?$/.test(to) && !urlHasHost(to)) {
6075
+ invalid.push({
6076
+ line,
6077
+ lineNumber: i + 1,
6078
+ message: "Infinite loop detected in this rule and has been ignored. This will cause a redirect to strip `.html` or `/index` and end up triggering this rule again. Please fix or remove this rule to silence this warning."
5955
6079
  });
5956
6080
  continue;
5957
6081
  }
@@ -5964,6 +6088,16 @@ function parseRedirects(input) {
5964
6088
  continue;
5965
6089
  }
5966
6090
  seen_paths.add(from);
6091
+ if (status === 200) {
6092
+ if (urlHasHost(to)) {
6093
+ invalid.push({
6094
+ line,
6095
+ lineNumber: i + 1,
6096
+ message: `Proxy (200) redirects can only point to relative paths. Got ${to}`
6097
+ });
6098
+ continue;
6099
+ }
6100
+ }
5967
6101
  rules.push({ from, to, status, lineNumber: i + 1 });
5968
6102
  }
5969
6103
  return {
@@ -5974,14 +6108,9 @@ function parseRedirects(input) {
5974
6108
 
5975
6109
  // src/miniflare-cli/assets.ts
5976
6110
  var import_mime = __toESM(require_mime());
5977
- import {
5978
- Response as MiniflareResponse2,
5979
- Request as MiniflareRequest2
5980
- } from "@miniflare/core";
5981
- import { upgradingFetch as miniflareFetch2 } from "@miniflare/web-sockets";
5982
6111
  import { watch } from "chokidar";
5983
6112
 
5984
- // src/pages/hash.tsx
6113
+ // src/pages/hash.ts
5985
6114
  import { readFileSync as readFileSync4 } from "node:fs";
5986
6115
  import { extname as extname2 } from "node:path";
5987
6116
  import { hash as blake3hash } from "blake3-wasm";
@@ -5994,33 +6123,34 @@ var hashFile = (filepath) => {
5994
6123
 
5995
6124
  // src/miniflare-cli/assets.ts
5996
6125
  async function generateASSETSBinding(options) {
5997
- const assetsFetch = options.directory !== void 0 ? await generateAssetsFetch(options.directory, options.log) : invalidAssetsFetch;
6126
+ const assetsFetch = options.directory !== void 0 ? await generateAssetsFetch(options.directory, options.log, options.tre) : invalidAssetsFetch;
6127
+ const miniflare = options.tre ? await import("@miniflare/tre") : await import("@miniflare/core");
6128
+ const Request = miniflare.Request;
6129
+ const Response2 = miniflare.Response;
6130
+ const fetch = options.tre ? miniflare.fetch : (await import("@miniflare/web-sockets")).upgradingFetch;
5998
6131
  return async function(miniflareRequest) {
5999
6132
  if (options.proxyPort) {
6000
6133
  try {
6001
6134
  const url = new URL(miniflareRequest.url);
6002
6135
  url.host = `localhost:${options.proxyPort}`;
6003
- const proxyRequest = new MiniflareRequest2(url, miniflareRequest);
6136
+ const proxyRequest = new Request(url, miniflareRequest);
6004
6137
  if (proxyRequest.headers.get("Upgrade") === "websocket") {
6005
6138
  proxyRequest.headers.delete("Sec-WebSocket-Accept");
6006
6139
  proxyRequest.headers.delete("Sec-WebSocket-Key");
6007
6140
  }
6008
- return await miniflareFetch2(proxyRequest);
6141
+ return await fetch(proxyRequest);
6009
6142
  } catch (thrown) {
6010
6143
  options.log.error(new Error(`Could not proxy request: ${thrown}`));
6011
- return new MiniflareResponse2(
6012
- `[wrangler] Could not proxy request: ${thrown}`,
6013
- {
6014
- status: 502
6015
- }
6016
- );
6144
+ return new Response2(`[wrangler] Could not proxy request: ${thrown}`, {
6145
+ status: 502
6146
+ });
6017
6147
  }
6018
6148
  } else {
6019
6149
  try {
6020
6150
  return await assetsFetch(miniflareRequest);
6021
6151
  } catch (thrown) {
6022
6152
  options.log.error(new Error(`Could not serve static asset: ${thrown}`));
6023
- return new MiniflareResponse2(
6153
+ return new Response2(
6024
6154
  `[wrangler] Could not serve static asset: ${thrown}`,
6025
6155
  { status: 502 }
6026
6156
  );
@@ -6028,8 +6158,12 @@ async function generateASSETSBinding(options) {
6028
6158
  }
6029
6159
  };
6030
6160
  }
6031
- async function generateAssetsFetch(directory, log) {
6032
- await Promise.resolve().then(() => (init_miniflare(), miniflare_exports));
6161
+ async function generateAssetsFetch(directory, log, tre) {
6162
+ directory = resolve5(directory);
6163
+ const polyfill2 = tre ? (await Promise.resolve().then(() => (init_miniflare_tre(), miniflare_tre_exports))).default : (await Promise.resolve().then(() => (init_miniflare(), miniflare_exports))).default;
6164
+ await polyfill2();
6165
+ const miniflare = tre ? await import("@miniflare/tre") : await import("@miniflare/core");
6166
+ const Request = miniflare.Request;
6033
6167
  const { generateHandler: generateHandler2, parseQualityWeightedList: parseQualityWeightedList2 } = await Promise.resolve().then(() => (init_handler(), handler_exports));
6034
6168
  const headersFile = join(directory, "_headers");
6035
6169
  const redirectsFile = join(directory, "_redirects");
@@ -6082,7 +6216,10 @@ async function generateAssetsFetch(directory, log) {
6082
6216
  xServerEnvHeader: "dev",
6083
6217
  logError: console.error,
6084
6218
  findAssetEntryForPath: async (path) => {
6085
- const filepath = join(directory, path);
6219
+ const filepath = resolve5(join(directory, path));
6220
+ if (!filepath.startsWith(directory)) {
6221
+ return null;
6222
+ }
6086
6223
  if (existsSync(filepath) && lstatSync(filepath).isFile() && !ignoredFiles.includes(filepath)) {
6087
6224
  const hash = hashFile(filepath);
6088
6225
  assetKeyEntryMap.set(hash, filepath);
@@ -6110,7 +6247,7 @@ async function generateAssetsFetch(directory, log) {
6110
6247
  const filepath = assetKeyEntryMap.get(assetKey);
6111
6248
  if (!filepath) {
6112
6249
  throw new Error(
6113
- "Could not fetch asset. Please file an issue on GitHub (https://github.com/cloudflare/wrangler2/issues/new/choose) with reproduction steps."
6250
+ "Could not fetch asset. Please file an issue on GitHub (https://github.com/cloudflare/workers-sdk/issues/new/choose) with reproduction steps."
6114
6251
  );
6115
6252
  }
6116
6253
  const body = readFileSync5(filepath);
@@ -6123,7 +6260,7 @@ async function generateAssetsFetch(directory, log) {
6123
6260
  });
6124
6261
  };
6125
6262
  return async (input, init) => {
6126
- const request = new MiniflareRequest2(input, init);
6263
+ const request = new Request(input, init);
6127
6264
  return await generateResponse(request);
6128
6265
  };
6129
6266
  }
@@ -6171,7 +6308,7 @@ async function main() {
6171
6308
  if (logLevelString === "LOG")
6172
6309
  logLevelString = "INFO";
6173
6310
  const logLevel = MiniflareLogLevel[logLevelString];
6174
- config.log = logLevel === MiniflareLogLevel.NONE ? new MiniflareNoOpLog() : new MiniflareLog(logLevel, config.logOptions);
6311
+ config.log = logLevel === MiniflareLogLevel.NONE ? new MiniflareNoOpLog() : new MiniflareLog(logLevel);
6175
6312
  if (logLevel === MiniflareLogLevel.DEBUG) {
6176
6313
  console.log("MINIFLARE OPTIONS:\n", JSON.stringify(config, null, 2));
6177
6314
  }
@@ -6191,12 +6328,12 @@ async function main() {
6191
6328
  namespace.get = (id) => {
6192
6329
  const stub = new DurableObjectStub(factory, id);
6193
6330
  stub.fetch = (...reqArgs) => {
6194
- const requestFromArgs = new MiniflareRequest3(...reqArgs);
6331
+ const requestFromArgs = new MiniflareRequest(...reqArgs);
6195
6332
  const url = new URL(requestFromArgs.url);
6196
6333
  url.host = host;
6197
6334
  if (port !== void 0)
6198
6335
  url.port = port.toString();
6199
- const request = new MiniflareRequest3(
6336
+ const request = new MiniflareRequest(
6200
6337
  url.toString(),
6201
6338
  requestFromArgs
6202
6339
  );
@@ -6205,7 +6342,7 @@ async function main() {
6205
6342
  "x-miniflare-durable-object-id",
6206
6343
  id.toString()
6207
6344
  );
6208
- return fetch(request);
6345
+ return upgradingFetch(request);
6209
6346
  };
6210
6347
  return stub;
6211
6348
  };
@@ -6229,7 +6366,8 @@ async function main() {
6229
6366
  const options = {
6230
6367
  log: config.log,
6231
6368
  proxyPort: opts.proxyPort,
6232
- directory: opts.directory
6369
+ directory: opts.directory,
6370
+ tre: false
6233
6371
  };
6234
6372
  config.serviceBindings = {
6235
6373
  ...config.serviceBindings,
@@ -6255,7 +6393,7 @@ async function main() {
6255
6393
  }`,
6256
6394
  serviceBindings: {
6257
6395
  DO: async (request) => {
6258
- request = new MiniflareRequest3(request);
6396
+ request = new MiniflareRequest(request);
6259
6397
  const name = request.headers.get("x-miniflare-durable-object-name");
6260
6398
  const idString = request.headers.get(
6261
6399
  "x-miniflare-durable-object-id"
@@ -6263,7 +6401,7 @@ async function main() {
6263
6401
  request.headers.delete("x-miniflare-durable-object-name");
6264
6402
  request.headers.delete("x-miniflare-durable-object-id");
6265
6403
  if (!name || !idString) {
6266
- return new MiniflareResponse3(
6404
+ return new MiniflareResponse(
6267
6405
  "[durable-object-proxy-err] Missing `x-miniflare-durable-object-name` or `x-miniflare-durable-object-id` headers.",
6268
6406
  { status: 400 }
6269
6407
  );
@@ -6271,14 +6409,14 @@ async function main() {
6271
6409
  const namespace = await mf?.getDurableObjectNamespace(name);
6272
6410
  const id = namespace?.idFromString(idString);
6273
6411
  if (!id) {
6274
- return new MiniflareResponse3(
6412
+ return new MiniflareResponse(
6275
6413
  "[durable-object-proxy-err] Could not generate an ID. Possibly due to a mismatched DO name and ID?",
6276
6414
  { status: 500 }
6277
6415
  );
6278
6416
  }
6279
6417
  const stub = namespace?.get(id);
6280
6418
  if (!stub) {
6281
- return new MiniflareResponse3(
6419
+ return new MiniflareResponse(
6282
6420
  "[durable-object-proxy-err] Could not generate a stub. Possibly due to a mismatched DO name and ID?",
6283
6421
  { status: 500 }
6284
6422
  );
@@ -6306,16 +6444,3 @@ async function main() {
6306
6444
  }
6307
6445
  }
6308
6446
  await main();
6309
- /**
6310
- * @fileoverview Main entrypoint for libraries using yargs-parser in Node.js
6311
- * CJS and ESM environments.
6312
- *
6313
- * @license
6314
- * Copyright (c) 2016, Contributors
6315
- * SPDX-License-Identifier: ISC
6316
- */
6317
- /**
6318
- * @license
6319
- * Copyright (c) 2016, Contributors
6320
- * SPDX-License-Identifier: ISC
6321
- */