wrangler 0.0.0-ecc8b172 → 0.0.0-ecded1af1

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 (250) hide show
  1. package/README.md +17 -19
  2. package/bin/wrangler.js +24 -93
  3. package/config-schema.json +3115 -0
  4. package/package.json +197 -190
  5. package/templates/__tests__/pages-dev-util.test.ts +128 -0
  6. package/templates/__tests__/tsconfig-sanity.ts +12 -0
  7. package/templates/__tests__/tsconfig.json +8 -0
  8. package/templates/checked-fetch.js +19 -6
  9. package/templates/facade.d.ts +19 -0
  10. package/templates/gitignore +2 -3
  11. package/templates/init-tests/test-jest-new-worker.js +3 -5
  12. package/templates/init-tests/test-vitest-new-worker.js +4 -6
  13. package/templates/init-tests/test-vitest-new-worker.ts +25 -0
  14. package/templates/middleware/common.ts +9 -4
  15. package/templates/middleware/loader-modules.ts +94 -44
  16. package/templates/middleware/loader-sw.ts +48 -32
  17. package/templates/middleware/middleware-ensure-req-body-drained.ts +18 -0
  18. package/templates/middleware/middleware-miniflare3-json-error.ts +32 -0
  19. package/templates/middleware/middleware-mock-analytics-engine.d.ts +3 -0
  20. package/templates/middleware/middleware-mock-analytics-engine.ts +30 -0
  21. package/templates/middleware/middleware-scheduled.ts +15 -1
  22. package/templates/middleware/middleware-serve-static-assets.d.ts +6 -0
  23. package/templates/middleware/middleware-serve-static-assets.ts +56 -0
  24. package/templates/modules-watch-stub.js +4 -0
  25. package/templates/new-worker-scheduled.ts +1 -1
  26. package/templates/new-worker.ts +4 -1
  27. package/templates/pages-dev-pipeline.ts +10 -13
  28. package/templates/pages-dev-util.ts +55 -0
  29. package/templates/pages-shim.ts +1 -1
  30. package/templates/pages-template-plugin.ts +37 -14
  31. package/templates/pages-template-worker.ts +33 -7
  32. package/templates/startDevWorker/InspectorProxyWorker.ts +664 -0
  33. package/templates/startDevWorker/ProxyWorker.ts +336 -0
  34. package/templates/tsconfig-sanity.ts +11 -0
  35. package/templates/tsconfig.init.json +22 -0
  36. package/templates/tsconfig.json +5 -102
  37. package/wrangler-dist/InspectorProxyWorker.js +464 -0
  38. package/wrangler-dist/InspectorProxyWorker.js.map +6 -0
  39. package/wrangler-dist/ProxyWorker.js +241 -0
  40. package/wrangler-dist/ProxyWorker.js.map +6 -0
  41. package/wrangler-dist/cli.d.ts +26095 -471
  42. package/wrangler-dist/cli.js +178062 -122008
  43. package/wrangler-dist/wasm-sync.wasm +0 -0
  44. package/Cloudflare_CA.pem +0 -18
  45. package/import_meta_url.js +0 -3
  46. package/miniflare-config-stubs/.env.empty +0 -0
  47. package/miniflare-config-stubs/package.empty.json +0 -1
  48. package/miniflare-config-stubs/wrangler.empty.toml +0 -0
  49. package/miniflare-dist/index.mjs +0 -6310
  50. package/src/__tests__/api-dev.test.ts +0 -209
  51. package/src/__tests__/api-devregistry.test.js +0 -56
  52. package/src/__tests__/api.test.ts +0 -80
  53. package/src/__tests__/config-cache-without-cache-dir.test.ts +0 -38
  54. package/src/__tests__/config-cache.test.ts +0 -42
  55. package/src/__tests__/configuration.test.ts +0 -3864
  56. package/src/__tests__/d1.test.ts +0 -70
  57. package/src/__tests__/delete.test.ts +0 -116
  58. package/src/__tests__/dev.test.tsx +0 -1357
  59. package/src/__tests__/dialogs.test.tsx +0 -40
  60. package/src/__tests__/generate.test.ts +0 -235
  61. package/src/__tests__/get-host-from-url.test.ts +0 -16
  62. package/src/__tests__/guess-worker-format.test.ts +0 -85
  63. package/src/__tests__/helpers/clipboardy-mock.js +0 -4
  64. package/src/__tests__/helpers/cmd-shim.d.ts +0 -11
  65. package/src/__tests__/helpers/mock-account-id.ts +0 -48
  66. package/src/__tests__/helpers/mock-bin.ts +0 -36
  67. package/src/__tests__/helpers/mock-cfetch.ts +0 -333
  68. package/src/__tests__/helpers/mock-console.ts +0 -106
  69. package/src/__tests__/helpers/mock-dialogs.ts +0 -153
  70. package/src/__tests__/helpers/mock-get-zone-from-host.ts +0 -8
  71. package/src/__tests__/helpers/mock-http-server.ts +0 -46
  72. package/src/__tests__/helpers/mock-istty.ts +0 -74
  73. package/src/__tests__/helpers/mock-known-routes.ts +0 -7
  74. package/src/__tests__/helpers/mock-kv.ts +0 -33
  75. package/src/__tests__/helpers/mock-oauth-flow.ts +0 -252
  76. package/src/__tests__/helpers/mock-process.ts +0 -39
  77. package/src/__tests__/helpers/mock-stdin.ts +0 -108
  78. package/src/__tests__/helpers/mock-web-socket.ts +0 -29
  79. package/src/__tests__/helpers/msw/handlers/namespaces.ts +0 -104
  80. package/src/__tests__/helpers/msw/handlers/oauth.ts +0 -36
  81. package/src/__tests__/helpers/msw/handlers/r2.ts +0 -80
  82. package/src/__tests__/helpers/msw/handlers/script.ts +0 -75
  83. package/src/__tests__/helpers/msw/handlers/user.ts +0 -63
  84. package/src/__tests__/helpers/msw/index.ts +0 -15
  85. package/src/__tests__/helpers/run-in-tmp.ts +0 -38
  86. package/src/__tests__/helpers/run-wrangler.ts +0 -16
  87. package/src/__tests__/helpers/worker-scripts/child-wrangler.toml +0 -1
  88. package/src/__tests__/helpers/worker-scripts/hello-world-worker.js +0 -5
  89. package/src/__tests__/helpers/worker-scripts/hello-world-wrangler.toml +0 -1
  90. package/src/__tests__/helpers/worker-scripts/parent-worker.js +0 -8
  91. package/src/__tests__/helpers/worker-scripts/parent-wrangler.toml +0 -5
  92. package/src/__tests__/helpers/write-worker-source.ts +0 -31
  93. package/src/__tests__/helpers/write-wrangler-toml.ts +0 -17
  94. package/src/__tests__/https-options.test.ts +0 -163
  95. package/src/__tests__/index.test.ts +0 -251
  96. package/src/__tests__/init.test.ts +0 -2816
  97. package/src/__tests__/jest.setup.ts +0 -191
  98. package/src/__tests__/kv.test.ts +0 -1675
  99. package/src/__tests__/logger.test.ts +0 -141
  100. package/src/__tests__/metrics.test.ts +0 -450
  101. package/src/__tests__/middleware.scheduled.test.ts +0 -135
  102. package/src/__tests__/middleware.test.ts +0 -726
  103. package/src/__tests__/package-manager.test.ts +0 -353
  104. package/src/__tests__/pages.test.ts +0 -2111
  105. package/src/__tests__/parse.test.ts +0 -330
  106. package/src/__tests__/paths.test.ts +0 -39
  107. package/src/__tests__/publish.test.ts +0 -7119
  108. package/src/__tests__/pubsub.test.ts +0 -367
  109. package/src/__tests__/r2.test.ts +0 -371
  110. package/src/__tests__/route.test.ts +0 -45
  111. package/src/__tests__/secret.test.ts +0 -644
  112. package/src/__tests__/tail.test.ts +0 -800
  113. package/src/__tests__/test-old-node-version.js +0 -31
  114. package/src/__tests__/user.test.ts +0 -155
  115. package/src/__tests__/utils-collectKeyValues.test.ts +0 -47
  116. package/src/__tests__/validate-dev-props.test.ts +0 -56
  117. package/src/__tests__/version.test.ts +0 -35
  118. package/src/__tests__/whoami.test.tsx +0 -278
  119. package/src/__tests__/worker-namespace.test.ts +0 -321
  120. package/src/abort.d.ts +0 -3
  121. package/src/api/dev.ts +0 -208
  122. package/src/api/index.ts +0 -2
  123. package/src/bundle-reporter.tsx +0 -29
  124. package/src/bundle.ts +0 -756
  125. package/src/cfetch/index.ts +0 -160
  126. package/src/cfetch/internal.ts +0 -263
  127. package/src/cli.ts +0 -29
  128. package/src/config/README.md +0 -107
  129. package/src/config/config.ts +0 -275
  130. package/src/config/diagnostics.ts +0 -80
  131. package/src/config/environment.ts +0 -505
  132. package/src/config/index.ts +0 -293
  133. package/src/config/validation-helpers.ts +0 -597
  134. package/src/config/validation.ts +0 -1930
  135. package/src/config-cache.ts +0 -85
  136. package/src/create-worker-preview.ts +0 -275
  137. package/src/create-worker-upload-form.ts +0 -301
  138. package/src/d1/backups.tsx +0 -212
  139. package/src/d1/create.tsx +0 -54
  140. package/src/d1/delete.tsx +0 -56
  141. package/src/d1/execute.tsx +0 -294
  142. package/src/d1/formatTimeAgo.ts +0 -14
  143. package/src/d1/index.ts +0 -75
  144. package/src/d1/list.tsx +0 -48
  145. package/src/d1/options.ts +0 -12
  146. package/src/d1/types.tsx +0 -14
  147. package/src/d1/utils.ts +0 -39
  148. package/src/delete.ts +0 -86
  149. package/src/deprecated/index.ts +0 -453
  150. package/src/dev/dev-vars.ts +0 -36
  151. package/src/dev/dev.tsx +0 -575
  152. package/src/dev/get-local-persistence-path.tsx +0 -31
  153. package/src/dev/local.tsx +0 -686
  154. package/src/dev/remote.tsx +0 -601
  155. package/src/dev/start-server.ts +0 -506
  156. package/src/dev/use-esbuild.ts +0 -197
  157. package/src/dev/validate-dev-props.ts +0 -31
  158. package/src/dev-registry.tsx +0 -201
  159. package/src/dev.tsx +0 -865
  160. package/src/dialogs.tsx +0 -163
  161. package/src/dispatch-namespace.ts +0 -206
  162. package/src/durable.ts +0 -102
  163. package/src/entry.ts +0 -329
  164. package/src/environment-variables.ts +0 -50
  165. package/src/errors.ts +0 -11
  166. package/src/git-client.ts +0 -124
  167. package/src/global-wrangler-config-path.ts +0 -26
  168. package/src/https-options.ts +0 -127
  169. package/src/index.tsx +0 -582
  170. package/src/init.ts +0 -970
  171. package/src/inspect.ts +0 -747
  172. package/src/intl-polyfill.d.ts +0 -139
  173. package/src/is-ci.ts +0 -14
  174. package/src/is-interactive.ts +0 -12
  175. package/src/kv/helpers.ts +0 -430
  176. package/src/kv/index.ts +0 -645
  177. package/src/logger.ts +0 -80
  178. package/src/metrics/index.ts +0 -5
  179. package/src/metrics/metrics-config.ts +0 -239
  180. package/src/metrics/metrics-dispatcher.ts +0 -96
  181. package/src/metrics/metrics-usage-headers.ts +0 -24
  182. package/src/metrics/send-event.ts +0 -94
  183. package/src/miniflare-cli/README.md +0 -30
  184. package/src/miniflare-cli/assets.ts +0 -215
  185. package/src/miniflare-cli/index.ts +0 -208
  186. package/src/miniflare-cli/request-context.ts +0 -40
  187. package/src/module-collection.ts +0 -267
  188. package/src/open-in-browser.ts +0 -17
  189. package/src/package-manager.ts +0 -219
  190. package/src/pages/build.tsx +0 -238
  191. package/src/pages/constants.ts +0 -16
  192. package/src/pages/deployments.tsx +0 -106
  193. package/src/pages/dev.tsx +0 -689
  194. package/src/pages/errors.ts +0 -66
  195. package/src/pages/functions/buildPlugin.ts +0 -110
  196. package/src/pages/functions/buildWorker.ts +0 -156
  197. package/src/pages/functions/filepath-routing.test.ts +0 -234
  198. package/src/pages/functions/filepath-routing.ts +0 -189
  199. package/src/pages/functions/identifiers.ts +0 -78
  200. package/src/pages/functions/routes-consolidation.test.ts +0 -250
  201. package/src/pages/functions/routes-consolidation.ts +0 -73
  202. package/src/pages/functions/routes-transformation.test.ts +0 -282
  203. package/src/pages/functions/routes-transformation.ts +0 -115
  204. package/src/pages/functions/routes-validation.test.ts +0 -403
  205. package/src/pages/functions/routes-validation.ts +0 -202
  206. package/src/pages/functions/routes.ts +0 -151
  207. package/src/pages/functions.tsx +0 -82
  208. package/src/pages/hash.tsx +0 -13
  209. package/src/pages/index.tsx +0 -94
  210. package/src/pages/projects.tsx +0 -169
  211. package/src/pages/publish.tsx +0 -436
  212. package/src/pages/types.ts +0 -49
  213. package/src/pages/upload.tsx +0 -398
  214. package/src/pages/utils.ts +0 -12
  215. package/src/parse.ts +0 -286
  216. package/src/paths.ts +0 -71
  217. package/src/proxy.ts +0 -657
  218. package/src/publish/index.ts +0 -267
  219. package/src/publish/publish.ts +0 -913
  220. package/src/pubsub/index.ts +0 -286
  221. package/src/pubsub/pubsub-commands.tsx +0 -623
  222. package/src/r2/helpers.ts +0 -131
  223. package/src/r2/index.ts +0 -277
  224. package/src/routes.ts +0 -140
  225. package/src/secret/index.ts +0 -403
  226. package/src/selfsigned.d.ts +0 -29
  227. package/src/sites.tsx +0 -372
  228. package/src/tail/createTail.ts +0 -315
  229. package/src/tail/filters.ts +0 -277
  230. package/src/tail/index.ts +0 -217
  231. package/src/tail/printing.ts +0 -107
  232. package/src/update-check.ts +0 -19
  233. package/src/user/choose-account.tsx +0 -69
  234. package/src/user/env-vars.ts +0 -46
  235. package/src/user/generate-auth-url.ts +0 -33
  236. package/src/user/generate-random-state.ts +0 -16
  237. package/src/user/index.ts +0 -3
  238. package/src/user/user.tsx +0 -1192
  239. package/src/utils/collectKeyValues.ts +0 -14
  240. package/src/whoami.tsx +0 -169
  241. package/src/worker.ts +0 -234
  242. package/src/yargs-types.ts +0 -7
  243. package/src/zones.ts +0 -165
  244. package/templates/d1-beta-facade.js +0 -174
  245. package/templates/experimental-local-cache-stubs.js +0 -27
  246. package/templates/first-party-worker-module-facade.ts +0 -18
  247. package/templates/format-dev-errors.ts +0 -32
  248. package/templates/serve-static-assets.ts +0 -63
  249. package/templates/service-bindings-module-facade.js +0 -54
  250. package/templates/service-bindings-sw-facade.js +0 -42
@@ -1,321 +0,0 @@
1
- import { rest } from "msw";
2
- import { mockAccountId, mockApiToken } from "./helpers/mock-account-id";
3
- import { mockConsoleMethods } from "./helpers/mock-console";
4
- import { msw, mswSuccessNamespacesHandlers } from "./helpers/msw";
5
- import { runInTempDir } from "./helpers/run-in-tmp";
6
- import { runWrangler } from "./helpers/run-wrangler";
7
-
8
- describe("dispatch-namespace", () => {
9
- const std = mockConsoleMethods();
10
- beforeEach(() => msw.use(...mswSuccessNamespacesHandlers));
11
-
12
- runInTempDir();
13
- mockAccountId();
14
- mockApiToken();
15
-
16
- it("should should display a list of available subcommands, for dispatch-namespace with no subcommand", async () => {
17
- await runWrangler("dispatch-namespace");
18
-
19
- // wait a tick for the help menu to be printed
20
- await new Promise((resolve) => setImmediate(resolve));
21
-
22
- expect(std).toMatchInlineSnapshot(`
23
- Object {
24
- "debug": "",
25
- "err": "",
26
- "out": "wrangler dispatch-namespace
27
-
28
- 📦 Interact with a dispatch namespace
29
-
30
- Commands:
31
- wrangler dispatch-namespace list List all dispatch namespaces
32
- wrangler dispatch-namespace get <name> Get information about a dispatch namespace
33
- wrangler dispatch-namespace create <name> Create a dispatch namespace
34
- wrangler dispatch-namespace delete <name> Delete a dispatch namespace
35
- wrangler dispatch-namespace rename <old-name> <new-name> Rename a dispatch namespace
36
-
37
- Flags:
38
- -c, --config Path to .toml configuration file [string]
39
- -h, --help Show help [boolean]
40
- -v, --version Show version number [boolean]",
41
- "warn": "",
42
- }
43
- `);
44
- });
45
-
46
- describe("create namespace", () => {
47
- const namespaceName = "my-namespace";
48
- let counter = 0;
49
- msw.use(
50
- rest.post(
51
- "/accounts/:accountId/workers/dispatch/namespaces/:namespaceNameParam",
52
- (req, res, cxt) => {
53
- counter++;
54
- const { namespaceNameParam } = req.params;
55
- expect(counter).toBe(1);
56
- expect(namespaceNameParam).toBe(namespaceName);
57
- return res.once(
58
- cxt.status(200),
59
- cxt.json({
60
- namespace_id: "some-namespace-id",
61
- namespace_name: "namespace-name",
62
- created_on: "2022-06-29T14:30:08.16152Z",
63
- created_by: "1fc1df98cc4420fe00367c3ab68c1639",
64
- modified_on: "2022-06-29T14:30:08.16152Z",
65
- modified_by: "1fc1df98cc4420fe00367c3ab68c1639",
66
- })
67
- );
68
- }
69
- )
70
- );
71
-
72
- it("should display help for create", async () => {
73
- await expect(
74
- runWrangler("dispatch-namespace create")
75
- ).rejects.toThrowErrorMatchingInlineSnapshot(
76
- `"Not enough non-option arguments: got 0, need at least 1"`
77
- );
78
-
79
- expect(std.out).toMatchInlineSnapshot(`
80
- "
81
- wrangler dispatch-namespace create <name>
82
-
83
- Create a dispatch namespace
84
-
85
- Positionals:
86
- name Name of the dispatch namespace [string] [required]
87
-
88
- Flags:
89
- -c, --config Path to .toml configuration file [string]
90
- -h, --help Show help [boolean]
91
- -v, --version Show version number [boolean]"
92
- `);
93
- });
94
-
95
- it("should attempt to create the given namespace", async () => {
96
- await runWrangler(`dispatch-namespace create ${namespaceName}`);
97
-
98
- expect(std.out).toMatchInlineSnapshot(
99
- `"Created dispatch namespace \\"my-namespace\\" with ID \\"some-namespace-id\\""`
100
- );
101
- });
102
- });
103
-
104
- describe("delete namespace", () => {
105
- const namespaceName = "my-namespace";
106
- let counter = 0;
107
- msw.use(
108
- rest.delete(
109
- "/accounts/:accountId/workers/dispatch/namespaces/:namespaceNameParam",
110
- (req, res, cxt) => {
111
- counter++;
112
- const { namespaceNameParam } = req.params;
113
- expect(counter).toBe(1);
114
- expect(namespaceNameParam).toBe(namespaceName);
115
- return res.once(cxt.status(200), cxt.json(null));
116
- }
117
- )
118
- );
119
-
120
- it("should display help for delete", async () => {
121
- await expect(
122
- runWrangler("dispatch-namespace create")
123
- ).rejects.toThrowErrorMatchingInlineSnapshot(
124
- `"Not enough non-option arguments: got 0, need at least 1"`
125
- );
126
-
127
- expect(std.out).toMatchInlineSnapshot(`
128
- "
129
- wrangler dispatch-namespace create <name>
130
-
131
- Create a dispatch namespace
132
-
133
- Positionals:
134
- name Name of the dispatch namespace [string] [required]
135
-
136
- Flags:
137
- -c, --config Path to .toml configuration file [string]
138
- -h, --help Show help [boolean]
139
- -v, --version Show version number [boolean]"
140
- `);
141
- });
142
-
143
- it("should try to delete the given namespace", async () => {
144
- await runWrangler(`dispatch-namespace delete ${namespaceName}`);
145
-
146
- expect(std.out).toMatchInlineSnapshot(
147
- `"Deleted dispatch namespace \\"my-namespace\\""`
148
- );
149
- });
150
- });
151
-
152
- describe("get namespace", () => {
153
- const namespaceName = "my-namespace";
154
- let counter = 0;
155
- msw.use(
156
- rest.get(
157
- "/accounts/:accountId/workers/dispatch/namespaces/:namespaceNameParam",
158
- (req, res, cxt) => {
159
- counter++;
160
- const { namespaceNameParam } = req.params;
161
- expect(counter).toBe(1);
162
- expect(namespaceNameParam).toBe(namespaceName);
163
- return res.once(
164
- cxt.status(200),
165
- cxt.json({
166
- namespace_id: "some-namespace-id",
167
- namespace_name: "namespace-name",
168
- created_on: "2022-06-29T14:30:08.16152Z",
169
- created_by: "1fc1df98cc4420fe00367c3ab68c1639",
170
- modified_on: "2022-06-29T14:30:08.16152Z",
171
- modified_by: "1fc1df98cc4420fe00367c3ab68c1639",
172
- })
173
- );
174
- }
175
- )
176
- );
177
-
178
- it("should display help for get", async () => {
179
- await expect(
180
- runWrangler("dispatch-namespace get")
181
- ).rejects.toThrowErrorMatchingInlineSnapshot(
182
- `"Not enough non-option arguments: got 0, need at least 1"`
183
- );
184
-
185
- expect(std.out).toMatchInlineSnapshot(`
186
- "
187
- wrangler dispatch-namespace get <name>
188
-
189
- Get information about a dispatch namespace
190
-
191
- Positionals:
192
- name Name of the dispatch namespace [string] [required]
193
-
194
- Flags:
195
- -c, --config Path to .toml configuration file [string]
196
- -h, --help Show help [boolean]
197
- -v, --version Show version number [boolean]"
198
- `);
199
- });
200
-
201
- it("should attempt to get info for the given namespace", async () => {
202
- await runWrangler(`dispatch-namespace get ${namespaceName}`);
203
-
204
- expect(std.out).toMatchInlineSnapshot(`
205
- "{
206
- namespace_id: 'some-namespace-id',
207
- namespace_name: 'namespace-name',
208
- created_on: '2022-06-29T14:30:08.16152Z',
209
- created_by: '1fc1df98cc4420fe00367c3ab68c1639',
210
- modified_on: '2022-06-29T14:30:08.16152Z',
211
- modified_by: '1fc1df98cc4420fe00367c3ab68c1639'
212
- }"
213
- `);
214
- });
215
- });
216
-
217
- describe("list namespaces", () => {
218
- const namespaceName = "my-namespace";
219
- let counter = 0;
220
- msw.use(
221
- rest.get(
222
- "/accounts/:accountId/workers/dispatch/namespaces/:namespaceNameParam",
223
- (req, res, cxt) => {
224
- counter++;
225
- const { namespaceNameParam } = req.params;
226
- expect(counter).toBe(1);
227
- expect(namespaceNameParam).toBe(namespaceName);
228
- return res.once(
229
- cxt.status(200),
230
- cxt.json({
231
- namespace_id: "some-namespace-id",
232
- namespace_name: "namespace-name",
233
- created_on: "2022-06-29T14:30:08.16152Z",
234
- created_by: "1fc1df98cc4420fe00367c3ab68c1639",
235
- modified_on: "2022-06-29T14:30:08.16152Z",
236
- modified_by: "1fc1df98cc4420fe00367c3ab68c1639",
237
- })
238
- );
239
- }
240
- )
241
- );
242
-
243
- it("should list all namespaces", async () => {
244
- await runWrangler("dispatch-namespace list");
245
- expect(std.out).toMatchInlineSnapshot(`
246
- "[
247
- {
248
- namespace_id: 'some-namespace-id',
249
- namespace_name: 'namespace-name',
250
- created_on: '2022-06-29T14:30:08.16152Z',
251
- created_by: '1fc1df98cc4420fe00367c3ab68c1639',
252
- modified_on: '2022-06-29T14:30:08.16152Z',
253
- modified_by: '1fc1df98cc4420fe00367c3ab68c1639'
254
- }
255
- ]"
256
- `);
257
- });
258
- });
259
-
260
- describe("rename namespace", () => {
261
- const namespaceName = "my-namespace";
262
- let counter = 0;
263
- msw.use(
264
- rest.put(
265
- "/accounts/:accountId/workers/dispatch/namespaces/:namespaceNameParam",
266
- (req, res, cxt) => {
267
- counter++;
268
- const { namespaceNameParam } = req.params;
269
- expect(counter).toBe(1);
270
- expect(namespaceNameParam).toBe(namespaceName);
271
- return res.once(
272
- cxt.status(200),
273
- cxt.json({
274
- namespace_id: "some-namespace-id",
275
- namespace_name: "namespace-name",
276
- created_on: "2022-06-29T14:30:08.16152Z",
277
- created_by: "1fc1df98cc4420fe00367c3ab68c1639",
278
- modified_on: "2022-06-29T14:30:08.16152Z",
279
- modified_by: "1fc1df98cc4420fe00367c3ab68c1639",
280
- })
281
- );
282
- }
283
- )
284
- );
285
-
286
- it("should display help for rename", async () => {
287
- await expect(
288
- runWrangler("dispatch-namespace rename")
289
- ).rejects.toThrowErrorMatchingInlineSnapshot(
290
- `"Not enough non-option arguments: got 0, need at least 2"`
291
- );
292
-
293
- expect(std.out).toMatchInlineSnapshot(`
294
- "
295
- wrangler dispatch-namespace rename <old-name> <new-name>
296
-
297
- Rename a dispatch namespace
298
-
299
- Positionals:
300
- old-name Name of the dispatch namespace [string] [required]
301
- new-name New name of the dispatch namespace [string] [required]
302
-
303
- Flags:
304
- -c, --config Path to .toml configuration file [string]
305
- -h, --help Show help [boolean]
306
- -v, --version Show version number [boolean]"
307
- `);
308
- });
309
-
310
- it("should attempt to rename the given namespace", async () => {
311
- const newName = "new-namespace";
312
- await runWrangler(
313
- `dispatch-namespace rename ${namespaceName} ${newName}`
314
- );
315
-
316
- expect(std.out).toMatchInlineSnapshot(
317
- `"Renamed dispatch namespace \\"my-namespace\\" to \\"new-namespace\\""`
318
- );
319
- });
320
- });
321
- });
package/src/abort.d.ts DELETED
@@ -1,3 +0,0 @@
1
- declare interface AbortSignal {
2
- addEventListener(event: "abort", handler: () => void);
3
- }
package/src/api/dev.ts DELETED
@@ -1,208 +0,0 @@
1
- import { fetch, Request } from "undici";
2
- import { startApiDev, startDev } from "../dev";
3
- import { logger } from "../logger";
4
-
5
- import type { Environment } from "../config";
6
- import type { EnablePagesAssetsServiceBindingOptions } from "../miniflare-cli";
7
- import type { RequestInit, Response, RequestInfo } from "undici";
8
-
9
- interface DevOptions {
10
- config?: string;
11
- env?: string;
12
- ip?: string;
13
- port?: number;
14
- bundle?: boolean;
15
- inspectorPort?: number;
16
- localProtocol?: "http" | "https";
17
- assets?: string;
18
- site?: string;
19
- siteInclude?: string[];
20
- siteExclude?: string[];
21
- nodeCompat?: boolean;
22
- compatibilityDate?: string;
23
- compatibilityFlags?: string[];
24
- persist?: boolean;
25
- persistTo?: string;
26
- liveReload?: boolean;
27
- watch?: boolean;
28
- vars?: {
29
- [key: string]: unknown;
30
- };
31
- kv?: {
32
- binding: string;
33
- id: string;
34
- preview_id?: string;
35
- }[];
36
- durableObjects?: {
37
- name: string;
38
- class_name: string;
39
- script_name?: string | undefined;
40
- environment?: string | undefined;
41
- }[];
42
- r2?: {
43
- binding: string;
44
- bucket_name: string;
45
- preview_bucket_name?: string;
46
- }[];
47
- d1Databases?: Environment["d1_databases"];
48
- showInteractiveDevSession?: boolean;
49
- logLevel?: "none" | "info" | "error" | "log" | "warn" | "debug";
50
- logPrefix?: string;
51
- inspect?: boolean;
52
- local?: boolean;
53
- forceLocal?: boolean;
54
- enablePagesAssetsServiceBinding?: EnablePagesAssetsServiceBindingOptions;
55
- _?: (string | number)[]; //yargs wants this
56
- $0?: string; //yargs wants this
57
- testScheduled?: boolean;
58
- experimentalLocal?: boolean;
59
- }
60
-
61
- interface DevApiOptions {
62
- testMode?: boolean;
63
- disableExperimentalWarning?: boolean;
64
- }
65
-
66
- export interface UnstableDevWorker {
67
- port: number;
68
- address: string;
69
- stop: () => Promise<void>;
70
- fetch: (input?: RequestInfo, init?: RequestInit) => Promise<Response>;
71
- waitUntilExit: () => Promise<void>;
72
- }
73
- /**
74
- * unstable_dev starts a wrangler dev server, and returns a promise that resolves with utility functions to interact with it.
75
- */
76
- export async function unstable_dev(
77
- script: string,
78
- options?: DevOptions,
79
- apiOptions?: DevApiOptions
80
- ): Promise<UnstableDevWorker> {
81
- const { testMode = true, disableExperimentalWarning = false } =
82
- apiOptions || {};
83
- if (!disableExperimentalWarning) {
84
- logger.warn(
85
- `unstable_dev() is experimental\nunstable_dev()'s behaviour will likely change in future releases`
86
- );
87
- }
88
- let readyPort: number;
89
- let readyAddress: string;
90
- //due to Pages adoption of unstable_dev, we can't *just* disable rebuilds and watching. instead, we'll have two versions of startDev, which will converge.
91
- if (testMode) {
92
- //in testMode, we can run multiple wranglers in parallel, but rebuilds might not work out of the box
93
- return new Promise<UnstableDevWorker>((resolve) => {
94
- //lmao
95
- return new Promise<Awaited<ReturnType<typeof startApiDev>>>((ready) => {
96
- // once the devServer is ready for requests, we resolve the inner promise
97
- // (where we've named the resolve function "ready")
98
- const devServer = startApiDev({
99
- script: script,
100
- inspect: false,
101
- logLevel: "none",
102
- showInteractiveDevSession: false,
103
- _: [],
104
- $0: "",
105
- port: options?.port ?? 0,
106
- local: true,
107
- ...options,
108
- onReady: (address, port) => {
109
- readyPort = port;
110
- readyAddress = address;
111
- ready(devServer);
112
- },
113
- });
114
- }).then((devServer) => {
115
- // now that the inner promise has resolved, we can resolve the outer promise
116
- // with an object that lets you fetch and stop the dev server
117
- resolve({
118
- port: readyPort,
119
- address: readyAddress,
120
- stop: devServer.stop,
121
- fetch: async (input?: RequestInfo, init?: RequestInit) => {
122
- return await fetch(
123
- ...parseRequestInput(
124
- readyAddress,
125
- readyPort,
126
- input,
127
- init,
128
- options?.localProtocol
129
- )
130
- );
131
- },
132
- //no-op, does nothing in tests
133
- waitUntilExit: async () => {
134
- return;
135
- },
136
- });
137
- });
138
- });
139
- } else {
140
- //outside of test mode, rebuilds work fine, but only one instance of wrangler will work at a time
141
-
142
- return new Promise<UnstableDevWorker>((resolve) => {
143
- //lmao
144
- return new Promise<Awaited<ReturnType<typeof startDev>>>((ready) => {
145
- const devServer = startDev({
146
- script: script,
147
- inspect: false,
148
- showInteractiveDevSession: false,
149
- _: [],
150
- $0: "",
151
- local: true,
152
- ...options,
153
- onReady: (address, port) => {
154
- readyPort = port;
155
- readyAddress = address;
156
- ready(devServer);
157
- },
158
- });
159
- }).then((devServer) => {
160
- resolve({
161
- port: readyPort,
162
- address: readyAddress,
163
- stop: devServer.stop,
164
- fetch: async (input?: RequestInfo, init?: RequestInit) => {
165
- return await fetch(
166
- ...parseRequestInput(
167
- readyAddress,
168
- readyPort,
169
- input,
170
- init,
171
- options?.localProtocol
172
- )
173
- );
174
- },
175
- waitUntilExit: devServer.devReactElement.waitUntilExit,
176
- });
177
- });
178
- });
179
- }
180
- }
181
-
182
- export function parseRequestInput(
183
- readyAddress: string,
184
- readyPort: number,
185
- input?: RequestInfo,
186
- init?: RequestInit,
187
- protocol: "http" | "https" = "http"
188
- ): [RequestInfo, RequestInit | undefined] {
189
- if (input instanceof Request) {
190
- return [input, undefined];
191
- } else if (input instanceof URL) {
192
- input = `${protocol}://${readyAddress}:${readyPort}${input.pathname}`;
193
- } else if (typeof input === "string") {
194
- try {
195
- // Want to strip the URL to only get the pathname, but the user could pass in only the pathname
196
- // Will error if we try and pass "/something" into new URL("/something")
197
- input = `${protocol}://${readyAddress}:${readyPort}${
198
- new URL(input).pathname
199
- }`;
200
- } catch {
201
- input = `${protocol}://${readyAddress}:${readyPort}${input}`;
202
- }
203
- } else {
204
- input = `${protocol}://${readyAddress}:${readyPort}`;
205
- }
206
-
207
- return [input, init];
208
- }
package/src/api/index.ts DELETED
@@ -1,2 +0,0 @@
1
- export { unstable_dev } from "./dev";
2
- export type { UnstableDevWorker } from "./dev";
@@ -1,29 +0,0 @@
1
- import { Blob } from "node:buffer";
2
- import { gzipSync } from "node:zlib";
3
- import { logger } from "./logger";
4
- import type { CfModule } from "./worker";
5
-
6
- async function getSize(modules: CfModule[]) {
7
- const gzipSize = gzipSync(
8
- await new Blob(modules.map((file) => file.content)).arrayBuffer()
9
- ).byteLength;
10
- const aggregateSize = new Blob(modules.map((file) => file.content)).size;
11
-
12
- return { size: aggregateSize, gzipSize };
13
- }
14
-
15
- export async function printBundleSize(
16
- main: {
17
- name: string;
18
- content: string;
19
- },
20
- modules: CfModule[]
21
- ) {
22
- const { size, gzipSize } = await getSize([...modules, main]);
23
-
24
- const bundleReport = `${(size / 1024).toFixed(2)} KiB / gzip: ${(
25
- gzipSize / 1024
26
- ).toFixed(2)} KiB`;
27
-
28
- logger.log(`Total Upload: ${bundleReport}`);
29
- }