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
@@ -1,310 +1,16 @@
1
- import fs from "node:fs";
2
- import path from "node:path";
3
1
  import { DeprecationError } from "../errors";
4
- import { cloneIntoDirectory, initializeGit } from "../git-client";
5
- import {
6
- CommandLineArgsError,
7
- createCLIParser,
8
- printWranglerBanner,
9
- } from "../index";
10
- import { initHandler } from "../init";
2
+ import { createCLIParser } from "../index";
11
3
  import { logger } from "../logger";
12
4
  import { formatMessage } from "../parse";
13
5
  import type {
14
- CommonYargsOptions,
15
- YargsOptionsToInterface,
6
+ CommonYargsArgv,
7
+ StrictYargsOptionsToInterface,
16
8
  } from "../yargs-types";
17
- import type { Argv, ArgumentsCamelCase, BuilderCallback } from "yargs";
18
9
 
19
- // https://github.com/cloudflare/wrangler/blob/master/src/cli/mod.rs#L106-L123
20
- interface GenerateArgs {
21
- name?: string;
22
- template?: string;
23
- type?: string;
24
- site?: boolean;
25
- }
26
-
27
- export function generateOptions(yargs: Argv<CommonYargsOptions>) {
28
- return yargs
29
- .positional("name", {
30
- describe: "Name of the Workers project",
31
- type: "string",
32
- })
33
- .positional("template", {
34
- type: "string",
35
- describe: "The URL of a GitHub template",
36
- })
37
- .option("type", {
38
- alias: "t",
39
- type: "string",
40
- hidden: true,
41
- deprecated: true,
42
- })
43
- .option("site", {
44
- alias: "s",
45
- type: "boolean",
46
- hidden: true,
47
- deprecated: true,
48
- });
49
- }
50
-
51
- export async function generateHandler({
52
- // somehow, `init` marks name as required but then also runs fine
53
- // with the name omitted, and then substitutes it at runtime with ""
54
- name = "",
55
- template,
56
- type,
57
- site,
58
- ...args
59
- }: ArgumentsCamelCase<GenerateArgs>) {
60
- // delegate to `wrangler init` if no template is specified
61
- if (template === undefined) {
62
- return initHandler({ name, ...args });
63
- }
64
-
65
- // print down here cuz `init` prints it own its own
66
- await printWranglerBanner();
67
-
68
- if (type) {
69
- let message = "The --type option is no longer supported.";
70
- if (args.type === "webpack") {
71
- message +=
72
- "\nIf you wish to use webpack then you will need to create a custom build.";
73
- // TODO: Add a link to docs
74
- }
75
- throw new CommandLineArgsError(message);
76
- }
77
-
78
- if (isRemote(name)) {
79
- [template, name] = [name, template];
80
- }
81
-
82
- const creationDirectory = generateWorkerDirectoryName(name);
83
-
84
- if (site) {
85
- const gitDirectory =
86
- creationDirectory !== process.cwd()
87
- ? path.basename(creationDirectory)
88
- : "my-site";
89
- const message =
90
- "The --site option is no longer supported.\n" +
91
- "If you wish to create a brand new Worker Sites project then clone the `worker-sites-template` starter repository:\n\n" +
92
- "```\n" +
93
- `git clone --depth=1 --branch=wrangler2 https://github.com/cloudflare/worker-sites-template ${gitDirectory}\n` +
94
- `cd ${gitDirectory}\n` +
95
- "```\n\n" +
96
- "Find out more about how to create and maintain Sites projects at https://developers.cloudflare.com/workers/platform/sites.\n" +
97
- "Have you considered using Cloudflare Pages instead? See https://pages.cloudflare.com/.";
98
- throw new CommandLineArgsError(message);
99
- }
100
-
101
- logger.log(
102
- `Creating a worker in ${path.basename(creationDirectory)} from ${template}`
103
- );
104
-
105
- const { remote, subdirectory } = parseTemplatePath(template);
106
-
107
- await cloneIntoDirectory(remote, creationDirectory, subdirectory);
108
- await initializeGit(creationDirectory);
109
-
110
- logger.log("✨ Success!");
111
- }
112
-
113
- /**
114
- * Creates a path based on the current working directory and a worker name.
115
- * Automatically increments a counter when searching for an available directory.
116
- *
117
- * Running `wrangler generate worker https://some-git-repo` in a directory
118
- * with the structure:
119
- * ```
120
- * - workers
121
- * |
122
- * | - worker
123
- * | | - wrangler.toml
124
- * | | ...
125
- * |
126
- * | - worker-1
127
- * | | - wrangler.toml
128
- * | | ...
129
- * ```
130
- *
131
- * will result in a new worker called `worker-2` being generated.
132
- *
133
- * @param workerName the name of the generated worker
134
- * @returns an absolute path to the directory to generate the worker into
135
- */
136
- function generateWorkerDirectoryName(workerName: string): string {
137
- let workerDirectoryPath = path.resolve(process.cwd(), workerName);
138
- let i = 1;
139
-
140
- while (fs.existsSync(workerDirectoryPath)) {
141
- workerDirectoryPath = path.resolve(process.cwd(), `${workerName}-${i}`);
142
- i++;
143
- }
144
-
145
- return workerDirectoryPath;
146
- }
147
-
148
- /**
149
- * Checks if an arg is a template, which can be useful if the order
150
- * of template & worker name args is switched
151
- *
152
- * @param arg a template to generate from, or a folder to generate into
153
- * @returns true if the given arg was remote (a template)
154
- */
155
- function isRemote(arg: string) {
156
- return /^(https?|ftps?|file|git|ssh):\/\//.test(arg) || arg.includes(":");
157
- }
158
-
159
- /**
160
- * unreadable regex basically copied from degit. i put some named capture groups in,
161
- * but uhh...there's not much to do short of using pomsky or some other tool.
162
- *
163
- * notably: this only supports `https://` and `git@` urls,
164
- * and is missing support for:
165
- * - `http`
166
- * - `ftp(s)`
167
- * - `file`
168
- * - `ssh`
169
- */
170
- const TEMPLATE_REGEX =
171
- /^(?:(?:https:\/\/)?(?<httpsUrl>[^:/]+\.[^:/]+)\/|git@(?<gitUrl>[^:/]+)[:/]|(?<shorthandUrl>[^/]+):)?(?<user>[^/\s]+)\/(?<repository>[^/\s#]+)(?:(?<subdirectoryPath>(?:\/[^/\s#]+)+))?(?:\/)?(?:#(?<tag>.+))?/;
172
-
173
- // there are a few URL formats we support:
174
- // - `user/repo` -> assume github, use "https://github.com/user/repo.git"
175
- // - `https://<httpsUrl>
176
- // - `git@<gitUrl>`
177
- // - `(bb|bitbucket|gh|github|gl|gitlab):user/repo` -> parse shorthand into https url
178
-
179
- /**
180
- * There's no URL, so assume a github repo
181
- */
182
- type NoUrl = {
183
- httpsUrl: undefined;
184
- gitUrl: undefined;
185
- shorthandUrl: undefined;
186
- };
187
-
188
- /**
189
- * A https url (e.g. https://bitbucket.org/user/repo)
190
- */
191
- type HttpsUrl = Omit<NoUrl, "httpsUrl"> & { httpsUrl: string };
192
-
193
- /**
194
- * A git url (e.g. git@gitlab.com:user/repo)
195
- */
196
- type GitUrl = Omit<NoUrl, "gitUrl"> & { gitUrl: string };
197
-
198
- /**
199
- * A shorthand url (e.g. github:user/repo)
200
- */
201
- type ShorthandUrl = Omit<NoUrl, "shorthandUrl"> & { shorthandUrl: string };
202
-
203
- /**
204
- * Union of all possible URL groups. Exactly one will be present, the rest
205
- * will be `undefined`.
206
- */
207
- type TemplateRegexUrlGroup = NoUrl | HttpsUrl | GitUrl | ShorthandUrl;
208
-
209
- /**
210
- * Possible matches of `TEMPLATE_REGEX` against a passed-in template arg
211
- */
212
- type TemplateRegexGroups = {
213
- /** The user the repo is under */
214
- user: string;
215
-
216
- /** The repo name */
217
- repository: string;
218
-
219
- /** Optional, path to subdirectory containing template. Begins with `/` */
220
- subdirectoryPath?: string;
221
-
222
- /** Optional tag (or branch, etc.) to clone */
223
- tag?: string;
224
- } & TemplateRegexUrlGroup;
225
-
226
- /**
227
- * Parses a regex match on any of the URL groups into a URL base
228
- *
229
- * @param urlGroup a regex hit for a URL of any sort
230
- * @returns the protocol and domain name of the url to clone from
231
- */
232
- function toUrlBase({ httpsUrl, gitUrl, shorthandUrl }: TemplateRegexUrlGroup) {
233
- if (httpsUrl !== undefined) {
234
- return `https://${httpsUrl}`;
235
- }
236
-
237
- if (gitUrl !== undefined) {
238
- return `git@${gitUrl}`;
239
- }
240
-
241
- if (shorthandUrl !== undefined) {
242
- switch (shorthandUrl) {
243
- case "github":
244
- case "gh":
245
- return "https://github.com";
246
- case "gitlab":
247
- case "gl":
248
- return "https://gitlab.com";
249
- case "bitbucket":
250
- case "bb":
251
- return "https://bitbucket.org";
252
- default:
253
- throw new Error(
254
- `Unable to parse shorthand ${shorthandUrl}. Supported options are "bitbucket" ("bb"), "github" ("gh"), and "gitlab" ("gl")`
255
- );
256
- }
257
- }
258
-
259
- return "https://github.com";
260
- }
261
-
262
- /**
263
- * Parses a template string (e.g. "user/repo", "github:user/repo/path/to/subdirectory")
264
- * into a remote URL to clone from and an optional subdirectory to filter for
265
- *
266
- * @param templatePath the template string to parse
267
- * @returns an object containing the remote url and an optional subdirectory to clone
268
- */
269
- function parseTemplatePath(templatePath: string): {
270
- remote: string;
271
- subdirectory?: string;
272
- } {
273
- if (!templatePath.includes("/")) {
274
- // template is a cloudflare canonical template, it doesn't include a slash in the name
275
- return {
276
- remote: "https://github.com/cloudflare/templates.git",
277
- subdirectory: templatePath,
278
- };
279
- }
280
-
281
- const groups = TEMPLATE_REGEX.exec(templatePath)?.groups as unknown as
282
- | TemplateRegexGroups
283
- | undefined;
284
-
285
- if (!groups) {
286
- throw new Error(`Unable to parse ${templatePath} as a template`);
287
- }
288
-
289
- const { user, repository, subdirectoryPath, tag, ...urlGroups } = groups;
290
-
291
- const urlBase = toUrlBase(urlGroups);
292
- const isHttp = urlBase.startsWith("http");
293
-
294
- const remote = `${urlBase}${isHttp ? "/" : ":"}${user}/${repository}.git${
295
- tag ? `#${tag}` : ""
296
- }`;
297
-
298
- // remove starting /
299
- const subdirectory = subdirectoryPath?.slice(1);
300
-
301
- return { remote, subdirectory };
302
- }
303
-
304
- export function buildOptions(yargs: Argv<CommonYargsOptions>) {
10
+ export function buildOptions(yargs: CommonYargsArgv) {
305
11
  return yargs;
306
12
  }
307
- type BuildArgs = YargsOptionsToInterface<typeof buildOptions>;
13
+ type BuildArgs = StrictYargsOptionsToInterface<typeof buildOptions>;
308
14
  export async function buildHandler(buildArgs: BuildArgs) {
309
15
  // "[DEPRECATED] 🦀 Build your project (if applicable)",
310
16
 
@@ -340,7 +46,7 @@ export const configHandler = () => {
340
46
  );
341
47
  };
342
48
 
343
- export function previewOptions(yargs: Argv<CommonYargsOptions>) {
49
+ export function previewOptions(yargs: CommonYargsArgv) {
344
50
  return yargs
345
51
  .positional("method", {
346
52
  type: "string",
@@ -364,7 +70,7 @@ export function previewHandler() {
364
70
  );
365
71
  }
366
72
 
367
- export const route: BuilderCallback<unknown, unknown> = (routeYargs: Argv) => {
73
+ export const route = (routeYargs: CommonYargsArgv) => {
368
74
  return routeYargs
369
75
  .command(
370
76
  "list",
@@ -427,7 +133,7 @@ export const routeHandler = () => {
427
133
  throw new DeprecationError(`${deprecationNotice}\n${shouldDo}`);
428
134
  };
429
135
 
430
- export const subdomainOptions = (yargs: Argv<CommonYargsOptions>) => {
136
+ export const subdomainOptions = (yargs: CommonYargsArgv) => {
431
137
  return yargs.positional("name", { type: "string" });
432
138
  };
433
139
 
package/src/dev/dev.tsx CHANGED
@@ -28,7 +28,7 @@ import type { Config } from "../config";
28
28
  import type { Route } from "../config/environment";
29
29
  import type { WorkerRegistry } from "../dev-registry";
30
30
  import type { Entry } from "../entry";
31
- import type { EnablePagesAssetsServiceBindingOptions } from "../miniflare-cli";
31
+ import type { EnablePagesAssetsServiceBindingOptions } from "../miniflare-cli/types";
32
32
  import type { AssetPaths } from "../sites";
33
33
  import type { CfWorkerInit } from "../worker";
34
34
 
@@ -55,7 +55,7 @@ function useDevRegistry(
55
55
 
56
56
  const interval =
57
57
  // TODO: enable this for remote mode as well
58
- // https://github.com/cloudflare/wrangler2/issues/1182
58
+ // https://github.com/cloudflare/workers-sdk/issues/1182
59
59
  mode === "local"
60
60
  ? setInterval(() => {
61
61
  getBoundRegisteredWorkers({
@@ -116,6 +116,7 @@ export type DevProps = {
116
116
  initialPort: number;
117
117
  initialIp: string;
118
118
  inspectorPort: number;
119
+ processEntrypoint: boolean;
119
120
  rules: Config["rules"];
120
121
  accountId: string | undefined;
121
122
  initialMode: "local" | "remote";
@@ -138,7 +139,8 @@ export type DevProps = {
138
139
  compatibilityFlags: string[] | undefined;
139
140
  usageModel: "bundled" | "unbound" | undefined;
140
141
  minify: boolean | undefined;
141
- nodeCompat: boolean | undefined;
142
+ legacyNodeCompat: boolean | undefined;
143
+ nodejsCompat: boolean | undefined;
142
144
  build: Config["build"];
143
145
  env: string | undefined;
144
146
  legacyEnv: boolean;
@@ -146,7 +148,6 @@ export type DevProps = {
146
148
  host: string | undefined;
147
149
  routes: Route[] | undefined;
148
150
  inspect: boolean;
149
- logPrefix?: string;
150
151
  onReady: ((ip: string, port: number) => void) | undefined;
151
152
  showInteractiveDevSession: boolean | undefined;
152
153
  forceLocal: boolean | undefined;
@@ -187,6 +188,7 @@ function InteractiveDevSession(props: DevProps) {
187
188
  inspect: props.inspect,
188
189
  localProtocol: props.localProtocol,
189
190
  forceLocal: props.forceLocal,
191
+ worker: props.name,
190
192
  });
191
193
 
192
194
  ip = props.initialIp;
@@ -249,20 +251,6 @@ function DevSession(props: DevSessionProps) {
249
251
  () => props.bindings.d1_databases?.map((db) => db.binding),
250
252
  [props.bindings.d1_databases]
251
253
  );
252
- const everyD1BindingHasPreview = props.bindings.d1_databases?.every(
253
- (binding) => binding.preview_database_id
254
- );
255
- if (
256
- betaD1Shims &&
257
- betaD1Shims.length > 0 &&
258
- !(props.local || everyD1BindingHasPreview)
259
- ) {
260
- handleError(
261
- new Error(
262
- "D1 bindings require dev --local or preview_database_id for now"
263
- )
264
- );
265
- }
266
254
 
267
255
  // If we are using d1 bindings, and are not bundling the worker
268
256
  // we should error here as the d1 shim won't be added
@@ -285,6 +273,7 @@ function DevSession(props: DevSessionProps) {
285
273
  entry: props.entry,
286
274
  destination: directory,
287
275
  jsxFactory: props.jsxFactory,
276
+ processEntrypoint: props.processEntrypoint,
288
277
  rules: props.rules,
289
278
  jsxFragment: props.jsxFragment,
290
279
  serveAssetsFromWorker: Boolean(
@@ -292,7 +281,8 @@ function DevSession(props: DevSessionProps) {
292
281
  ),
293
282
  tsconfig: props.tsconfig,
294
283
  minify: props.minify,
295
- nodeCompat: props.nodeCompat,
284
+ legacyNodeCompat: props.legacyNodeCompat,
285
+ nodejsCompat: props.nodejsCompat,
296
286
  betaD1Shims,
297
287
  define: props.define,
298
288
  noBundle: props.noBundle,
@@ -355,13 +345,13 @@ function DevSession(props: DevSessionProps) {
355
345
  queueConsumers={props.queueConsumers}
356
346
  localProtocol={props.localProtocol}
357
347
  localUpstream={props.localUpstream}
358
- logPrefix={props.logPrefix}
359
348
  inspect={props.inspect}
360
349
  onReady={announceAndOnReady}
361
350
  enablePagesAssetsServiceBinding={props.enablePagesAssetsServiceBinding}
362
351
  experimentalLocal={props.experimentalLocal}
363
352
  accountId={props.accountId}
364
353
  experimentalLocalRemoteKv={props.experimentalLocalRemoteKv}
354
+ sourceMapPath={bundle?.sourceMapPath}
365
355
  />
366
356
  ) : (
367
357
  <Remote
@@ -441,7 +431,7 @@ function useCustomBuild(expectedEntry: Entry, build: Config["build"]): void {
441
431
  }
442
432
 
443
433
  return () => {
444
- watcher?.close();
434
+ void watcher?.close();
445
435
  };
446
436
  }, [build, expectedEntry]);
447
437
  }
@@ -540,6 +530,7 @@ function useHotkeys(props: {
540
530
  inspect: boolean;
541
531
  localProtocol: "http" | "https";
542
532
  forceLocal: boolean | undefined;
533
+ worker: string | undefined;
543
534
  }) {
544
535
  const { initial, inspectorPort, inspect, localProtocol, forceLocal } = props;
545
536
  // UGH, we should put port in context instead
@@ -572,7 +563,7 @@ function useHotkeys(props: {
572
563
  // toggle inspector
573
564
  case "d": {
574
565
  if (inspect) {
575
- await openInspector(inspectorPort);
566
+ await openInspector(inspectorPort, props.worker);
576
567
  }
577
568
  break;
578
569
  }