wrangler 2.6.2 → 2.7.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.
Files changed (128) hide show
  1. package/bin/wrangler.js +9 -1
  2. package/miniflare-dist/index.mjs +1 -1
  3. package/package.json +12 -10
  4. package/src/__tests__/api-dev.test.ts +65 -36
  5. package/src/__tests__/api-devregistry.test.js +14 -6
  6. package/src/__tests__/configuration.test.ts +2 -31
  7. package/src/__tests__/{d1.test.ts → d1/d1.test.ts} +48 -5
  8. package/src/__tests__/d1/splitter.test.ts +255 -0
  9. package/src/__tests__/delete.test.ts +5 -2
  10. package/src/__tests__/deployments.test.ts +20 -6
  11. package/src/__tests__/dev.test.tsx +52 -19
  12. package/src/__tests__/generate.test.ts +7 -4
  13. package/src/__tests__/helpers/mock-auth-domain.ts +20 -0
  14. package/src/__tests__/helpers/mock-cfetch.ts +2 -57
  15. package/src/__tests__/helpers/mock-dialogs.ts +70 -86
  16. package/src/__tests__/helpers/mock-oauth-flow.ts +64 -49
  17. package/src/__tests__/helpers/mock-process.ts +8 -13
  18. package/src/__tests__/helpers/msw/blob-worker.cjs +19 -0
  19. package/src/__tests__/helpers/msw/read-file-sync.js +61 -0
  20. package/src/__tests__/index.test.ts +46 -44
  21. package/src/__tests__/init.test.ts +761 -537
  22. package/src/__tests__/jest.setup.ts +20 -24
  23. package/src/__tests__/kv.test.ts +286 -173
  24. package/src/__tests__/logout.test.ts +1 -1
  25. package/src/__tests__/metrics.test.ts +5 -7
  26. package/src/__tests__/middleware.scheduled.test.ts +40 -30
  27. package/src/__tests__/middleware.test.ts +144 -120
  28. package/src/__tests__/pages.test.ts +1617 -1161
  29. package/src/__tests__/publish.test.ts +174 -125
  30. package/src/__tests__/r2.test.ts +2 -2
  31. package/src/__tests__/secret.test.ts +183 -126
  32. package/src/__tests__/tail.test.ts +6 -0
  33. package/src/__tests__/tsconfig-sanity.ts +12 -0
  34. package/src/__tests__/tsconfig.json +8 -0
  35. package/src/__tests__/tsconfig.tsbuildinfo +1 -0
  36. package/src/__tests__/whoami.test.tsx +1 -96
  37. package/src/api/dev.ts +90 -41
  38. package/src/api/index.ts +1 -1
  39. package/src/{bundle-reporter.tsx → bundle-reporter.ts} +0 -0
  40. package/src/cfetch/index.ts +0 -2
  41. package/src/cfetch/internal.ts +6 -15
  42. package/src/cli.ts +2 -2
  43. package/src/config/validation.ts +1 -2
  44. package/src/create-worker-upload-form.ts +2 -2
  45. package/src/d1/{delete.tsx → delete.ts} +0 -0
  46. package/src/d1/execute.tsx +8 -37
  47. package/src/d1/migrations/apply.tsx +29 -19
  48. package/src/d1/migrations/{index.tsx → index.ts} +0 -0
  49. package/src/d1/splitter.ts +161 -0
  50. package/src/d1/{types.tsx → types.ts} +0 -0
  51. package/src/delete.ts +3 -8
  52. package/src/deployments.ts +6 -0
  53. package/src/deprecated/index.ts +2 -295
  54. package/src/dev/dev.tsx +2 -2
  55. package/src/dev/{get-local-persistence-path.tsx → get-local-persistence-path.ts} +0 -0
  56. package/src/dev/local.tsx +16 -4
  57. package/src/dev/remote.tsx +28 -1
  58. package/src/dev/start-server.ts +19 -11
  59. package/src/dev/use-esbuild.ts +1 -1
  60. package/src/{dev-registry.tsx → dev-registry.ts} +0 -0
  61. package/src/dev.tsx +21 -2
  62. package/src/dialogs.ts +136 -0
  63. package/src/dispatch-namespace.ts +1 -1
  64. package/src/docs/index.ts +3 -0
  65. package/src/environment-variables/factory.ts +88 -0
  66. package/src/environment-variables/misc-variables.ts +30 -0
  67. package/src/generate/index.ts +300 -0
  68. package/src/{index.tsx → index.ts} +10 -13
  69. package/src/init.ts +92 -52
  70. package/src/jest.d.ts +4 -0
  71. package/src/logger.ts +15 -3
  72. package/src/metrics/metrics-config.ts +1 -1
  73. package/src/miniflare-cli/assets.ts +4 -0
  74. package/src/miniflare-cli/index.ts +1 -5
  75. package/src/miniflare-cli/tsconfig.json +9 -0
  76. package/src/miniflare-cli/tsconfig.tsbuildinfo +1 -0
  77. package/src/miniflare-cli/types.ts +11 -0
  78. package/src/pages/{build.tsx → build.ts} +0 -0
  79. package/src/pages/{deployment-tails.tsx → deployment-tails.ts} +0 -0
  80. package/src/pages/{dev.tsx → dev.ts} +53 -55
  81. package/src/pages/functions/buildWorker.ts +1 -1
  82. package/src/pages/functions/tsconfig.json +8 -0
  83. package/src/pages/functions/tsconfig.tsbuildinfo +1 -0
  84. package/src/pages/{functions.tsx → functions.ts} +0 -0
  85. package/src/pages/{hash.tsx → hash.ts} +0 -0
  86. package/src/pages/{index.tsx → index.ts} +0 -0
  87. package/src/pages/projects.tsx +3 -5
  88. package/src/pages/publish.tsx +5 -4
  89. package/src/pages/upload.tsx +1 -1
  90. package/src/publish/publish.ts +9 -7
  91. package/src/pubsub/{pubsub-commands.tsx → pubsub-commands.ts} +1 -1
  92. package/src/secret/index.ts +1 -1
  93. package/src/{sites.tsx → sites.ts} +0 -0
  94. package/src/tail/index.ts +2 -3
  95. package/src/tsconfig-sanity.ts +16 -0
  96. package/src/user/access.ts +0 -1
  97. package/src/user/auth-variables.ts +113 -0
  98. package/src/user/choose-account.tsx +1 -31
  99. package/src/user/index.ts +0 -1
  100. package/src/user/{user.tsx → user.ts} +107 -73
  101. package/src/{whoami.tsx → whoami.ts} +37 -71
  102. package/templates/__tests__/tsconfig-sanity.ts +12 -0
  103. package/templates/__tests__/tsconfig.json +8 -0
  104. package/templates/__tests__/tsconfig.tsbuildinfo +1 -0
  105. package/templates/d1-beta-facade.js +36 -0
  106. package/templates/facade.d.ts +14 -0
  107. package/templates/first-party-worker-module-facade.ts +4 -3
  108. package/templates/format-dev-errors.ts +7 -6
  109. package/templates/init-tests/test-jest-new-worker.js +3 -5
  110. package/templates/init-tests/test-vitest-new-worker.js +3 -5
  111. package/templates/init-tests/test-vitest-new-worker.ts +25 -0
  112. package/templates/middleware/loader-modules.ts +0 -2
  113. package/templates/middleware/loader-sw.ts +6 -0
  114. package/templates/pages-dev-pipeline.ts +4 -1
  115. package/templates/pages-shim.ts +4 -1
  116. package/templates/pages-template-plugin.ts +12 -7
  117. package/templates/serve-static-assets.ts +16 -14
  118. package/templates/tsconfig-sanity.ts +11 -0
  119. package/templates/tsconfig.init.json +106 -0
  120. package/templates/tsconfig.json +5 -103
  121. package/templates/tsconfig.tsbuildinfo +1 -0
  122. package/wrangler-dist/cli.d.ts +58 -60
  123. package/wrangler-dist/cli.js +34447 -55514
  124. package/wrangler-dist/wasm-sync.wasm +0 -0
  125. package/src/__tests__/dialogs.test.tsx +0 -40
  126. package/src/dialogs.tsx +0 -168
  127. package/src/environment-variables.ts +0 -50
  128. package/src/user/env-vars.ts +0 -46
@@ -4,14 +4,10 @@ import {
4
4
  fetchInternal,
5
5
  fetchKVGetValue,
6
6
  fetchR2Objects,
7
- getCloudflareAPIBaseURL,
8
7
  performApiFetch,
9
8
  } from "../cfetch/internal";
10
- import { confirm, prompt } from "../dialogs";
11
9
  import {
12
- mockFetchDashScript,
13
10
  mockFetchInternal,
14
- mockFetchKVGetValue,
15
11
  mockFetchR2Objects,
16
12
  mockPerformApiFetch,
17
13
  } from "./helpers/mock-cfetch";
@@ -31,6 +27,9 @@ import { msw } from "./helpers/msw";
31
27
  global as unknown as { __RELATIVE_PACKAGE_PATH__: string }
32
28
  ).__RELATIVE_PACKAGE_PATH__ = "..";
33
29
 
30
+ // Set `LC_ALL` to fix the language as English for the messages thrown by Yargs.
31
+ process.env.LC_ALL = "en";
32
+
34
33
  // Mock out getPort since we don't actually care about what ports are open in unit tests.
35
34
  jest.mock("get-port", () => {
36
35
  return {
@@ -91,31 +90,16 @@ afterEach(() => {
91
90
  afterAll(() => msw.close());
92
91
 
93
92
  jest.mock("../cfetch/internal");
93
+ (fetchDashboardScript as jest.Mock).mockImplementation(
94
+ jest.requireActual("../cfetch/internal")["fetchDashboardScript"]
95
+ );
94
96
  (fetchInternal as jest.Mock).mockImplementation(mockFetchInternal);
95
- (fetchKVGetValue as jest.Mock).mockImplementation(mockFetchKVGetValue);
96
- (getCloudflareAPIBaseURL as jest.Mock).mockReturnValue(
97
- "https://api.cloudflare.com/client/v4"
97
+ (fetchKVGetValue as jest.Mock).mockImplementation(
98
+ jest.requireActual("../cfetch/internal").fetchKVGetValue
98
99
  );
99
100
  (fetchR2Objects as jest.Mock).mockImplementation(mockFetchR2Objects);
100
- (fetchDashboardScript as jest.Mock).mockImplementation(mockFetchDashScript);
101
101
  (performApiFetch as jest.Mock).mockImplementation(mockPerformApiFetch);
102
102
 
103
- jest.mock("../dialogs");
104
-
105
- // By default (if not configured by mockConfirm()) calls to `confirm()` should throw.
106
- (confirm as jest.Mock).mockImplementation((text: string) => {
107
- throw new Error(
108
- `Unexpected call to \`confirm("${text}")\`.\nYou should use \`mockConfirm()\` to mock calls to \`confirm()\` with expectations. Search the codebase for \`mockConfirm\` to learn more.`
109
- );
110
- });
111
-
112
- // By default (if not configured by mockPrompt()) calls to `prompt()` should throw.
113
- (prompt as jest.Mock).mockImplementation((text: string) => {
114
- throw new Error(
115
- `Unexpected call to \`prompt(${text}, ...)\`.\nYou should use \`mockPrompt()\` to mock calls to \`prompt()\` with expectations. Search the codebase for \`mockPrompt\` to learn more.`
116
- );
117
- });
118
-
119
103
  jest.mock("../dev/dev", () => {
120
104
  const { useApp } = jest.requireActual("ink");
121
105
  const { useEffect } = jest.requireActual("react");
@@ -200,3 +184,15 @@ jest.mock("../metrics/metrics-config", () => {
200
184
  };
201
185
  return fakeModule;
202
186
  });
187
+ jest.mock("prompts", () => {
188
+ return {
189
+ __esModule: true,
190
+ default: jest.fn((...args) => {
191
+ throw new Error(
192
+ `Unexpected call to \`prompts("${JSON.stringify(
193
+ args
194
+ )}")\`.\nYou should use \`mockConfirm()/mockSelect()/mockPrompt()\` to mock calls to \`confirm()\` with expectations.`
195
+ );
196
+ }),
197
+ };
198
+ });