wrangler 0.0.0-e151223 → 0.0.0-e29a241

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 (92) hide show
  1. package/miniflare-dist/index.mjs +79 -0
  2. package/miniflare-dist/index.mjs.map +7 -0
  3. package/package.json +29 -13
  4. package/pages/functions/filepath-routing.test.ts +212 -36
  5. package/pages/functions/filepath-routing.ts +69 -119
  6. package/pages/functions/routes.ts +8 -17
  7. package/pages/functions/template-worker.ts +3 -9
  8. package/src/__tests__/configuration.test.ts +2754 -0
  9. package/src/__tests__/dev.test.tsx +488 -63
  10. package/src/__tests__/dev2.test.tsx +154 -0
  11. package/src/__tests__/guess-worker-format.test.ts +58 -0
  12. package/src/__tests__/helpers/cmd-shim.d.ts +11 -0
  13. package/src/__tests__/helpers/faye-websocket.d.ts +6 -0
  14. package/src/__tests__/helpers/mock-account-id.ts +26 -8
  15. package/src/__tests__/helpers/mock-bin.ts +36 -0
  16. package/src/__tests__/helpers/mock-cfetch.ts +44 -10
  17. package/src/__tests__/helpers/mock-console.ts +21 -7
  18. package/src/__tests__/helpers/mock-kv.ts +9 -16
  19. package/src/__tests__/helpers/mock-stdin.ts +103 -0
  20. package/src/__tests__/helpers/mock-web-socket.ts +29 -0
  21. package/src/__tests__/helpers/run-in-tmp.ts +3 -0
  22. package/src/__tests__/helpers/run-wrangler.ts +5 -3
  23. package/src/__tests__/helpers/write-wrangler-toml.ts +17 -0
  24. package/src/__tests__/https-options.test.ts +127 -0
  25. package/src/__tests__/index.test.ts +617 -32
  26. package/src/__tests__/jest.setup.ts +41 -6
  27. package/src/__tests__/kv.test.ts +455 -222
  28. package/src/__tests__/logout.test.ts +15 -13
  29. package/src/__tests__/package-manager.test.ts +206 -0
  30. package/src/__tests__/pages.test.ts +44 -0
  31. package/src/__tests__/parse.test.ts +322 -0
  32. package/src/__tests__/publish.test.ts +1919 -437
  33. package/src/__tests__/r2.test.ts +198 -0
  34. package/src/__tests__/route.test.ts +45 -0
  35. package/src/__tests__/secret.test.ts +301 -86
  36. package/src/__tests__/sentry.test.ts +146 -0
  37. package/src/__tests__/tail.test.ts +564 -0
  38. package/src/__tests__/whoami.test.tsx +21 -7
  39. package/src/bundle.ts +142 -0
  40. package/src/cfetch/index.ts +9 -16
  41. package/src/cfetch/internal.ts +89 -22
  42. package/src/cli.ts +10 -0
  43. package/src/config/README.md +107 -0
  44. package/src/config/config.ts +274 -0
  45. package/src/config/diagnostics.ts +80 -0
  46. package/src/config/environment.ts +310 -0
  47. package/src/config/index.ts +56 -0
  48. package/src/config/validation-helpers.ts +486 -0
  49. package/src/config/validation.ts +1096 -0
  50. package/src/{api/preview.ts → create-worker-preview.ts} +59 -21
  51. package/src/create-worker-upload-form.ts +217 -0
  52. package/src/dev/dev.tsx +364 -0
  53. package/src/dev/local.tsx +226 -0
  54. package/src/dev/remote.tsx +203 -0
  55. package/src/dev/use-esbuild.ts +100 -0
  56. package/src/entry.ts +208 -0
  57. package/src/environment-variables.ts +33 -0
  58. package/src/https-options.ts +122 -0
  59. package/src/index.tsx +1079 -766
  60. package/src/inspect.ts +25 -4
  61. package/src/{kv.tsx → kv.ts} +104 -61
  62. package/src/miniflare-cli/README.md +30 -0
  63. package/src/miniflare-cli/enum-keys.ts +17 -0
  64. package/src/miniflare-cli/index.ts +37 -0
  65. package/src/module-collection.ts +226 -31
  66. package/src/open-in-browser.ts +25 -0
  67. package/src/package-manager.ts +126 -0
  68. package/src/pages.tsx +11 -11
  69. package/src/parse.ts +183 -0
  70. package/src/proxy.ts +115 -45
  71. package/src/publish.ts +265 -328
  72. package/src/r2.ts +50 -0
  73. package/src/reporting.ts +131 -0
  74. package/src/selfsigned.d.ts +29 -0
  75. package/src/sites.tsx +83 -43
  76. package/src/tail/filters.ts +279 -0
  77. package/src/tail/index.ts +299 -0
  78. package/src/tail/printing.ts +62 -0
  79. package/src/user.tsx +223 -124
  80. package/src/{api/worker.ts → worker.ts} +44 -36
  81. package/templates/new-worker.js +15 -0
  82. package/templates/new-worker.ts +15 -0
  83. package/{static-asset-facade.js → templates/static-asset-facade.js} +0 -0
  84. package/templates/tsconfig.json +105 -0
  85. package/wrangler-dist/cli.js +60837 -43876
  86. package/wrangler-dist/cli.js.map +3 -3
  87. package/src/__tests__/helpers/mock-user.ts +0 -27
  88. package/src/api/form_data.ts +0 -134
  89. package/src/config.ts +0 -641
  90. package/src/dev.tsx +0 -834
  91. package/src/npm-installer.ts +0 -20
  92. package/src/tail.tsx +0 -73
@@ -1,7 +1,19 @@
1
1
  import fetchMock from "jest-fetch-mock";
2
- import { fetchInternal } from "../cfetch/internal";
2
+ import {
3
+ fetchInternal,
4
+ fetchKVGetValue,
5
+ getCloudflareAPIBaseURL,
6
+ } from "../cfetch/internal";
3
7
  import { confirm, prompt } from "../dialogs";
4
- import { mockFetchInternal } from "./helpers/mock-cfetch";
8
+ import { mockFetchInternal, mockFetchKVGetValue } from "./helpers/mock-cfetch";
9
+ import { MockWebSocket } from "./helpers/mock-web-socket";
10
+
11
+ jest.mock("ws", () => {
12
+ return {
13
+ __esModule: true,
14
+ default: MockWebSocket,
15
+ };
16
+ });
5
17
 
6
18
  jest.mock("undici", () => {
7
19
  return {
@@ -9,26 +21,49 @@ jest.mock("undici", () => {
9
21
  fetch: jest.requireActual("jest-fetch-mock"),
10
22
  };
11
23
  });
24
+
25
+ // Outside of the Sentry tests themselves, we mock Sentry to ensure that it doesn't actually send any data and
26
+ // that it doesn't interfere with the rest of the tests.
27
+ jest.mock("../reporting");
28
+
12
29
  fetchMock.doMock(() => {
13
30
  // Any un-mocked fetches should throw
14
31
  throw new Error("Unexpected fetch request");
15
32
  });
16
33
 
34
+ jest.mock("../package-manager");
35
+
17
36
  jest.mock("../cfetch/internal");
18
37
  (fetchInternal as jest.Mock).mockImplementation(mockFetchInternal);
38
+ (fetchKVGetValue as jest.Mock).mockImplementation(mockFetchKVGetValue);
39
+ (getCloudflareAPIBaseURL as jest.Mock).mockReturnValue(
40
+ "https://api.cloudflare.com/client/v4"
41
+ );
19
42
 
20
43
  jest.mock("../dialogs");
21
44
 
22
45
  // By default (if not configured by mockConfirm()) calls to `confirm()` should throw.
23
- (confirm as jest.Mock).mockImplementation(() => {
46
+ (confirm as jest.Mock).mockImplementation((text: string) => {
24
47
  throw new Error(
25
- "Unexpected call to `confirm()`. You should use `mockConfirm()` to mock calls to `confirm()` with expectations. Search the codebase for `mockConfirm` to learn more."
48
+ `Unexpected call to \`confirm("${text}")\`.\nYou should use \`mockConfirm()\` to mock calls to \`confirm()\` with expectations. Search the codebase for \`mockConfirm\` to learn more.`
26
49
  );
27
50
  });
28
51
 
29
52
  // By default (if not configured by mockPrompt()) calls to `prompt()` should throw.
30
- (prompt as jest.Mock).mockImplementation(() => {
53
+ (prompt as jest.Mock).mockImplementation((text: string) => {
31
54
  throw new Error(
32
- "Unexpected call to `prompt()`. You should use `mockPrompt()` to mock calls to `prompt()` with expectations. Search the codebase for `mockPrompt` to learn more."
55
+ `Unexpected call to \`prompt(${text}, ...)\`.\nYou should use \`mockPrompt()\` to mock calls to \`prompt()\` with expectations. Search the codebase for \`mockPrompt\` to learn more.`
33
56
  );
34
57
  });
58
+
59
+ jest.mock("../dev/dev", () => {
60
+ const { useApp } = jest.requireActual("ink");
61
+ const { useEffect } = jest.requireActual("react");
62
+ return jest.fn().mockImplementation(() => {
63
+ const { exit } = useApp();
64
+ useEffect(() => {
65
+ exit();
66
+ });
67
+ return null;
68
+ });
69
+ });