wrangler 0.0.0-e043479 → 0.0.0-e09abbc

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 (208) hide show
  1. package/Cloudflare_CA.pem +18 -0
  2. package/README.md +33 -14
  3. package/bin/wrangler.js +160 -28
  4. package/kv-asset-handler.js +1 -0
  5. package/miniflare-dist/index.mjs +5354 -0
  6. package/package.json +166 -136
  7. package/src/__tests__/config-cache-without-cache-dir.test.ts +38 -0
  8. package/src/__tests__/config-cache.test.ts +42 -0
  9. package/src/__tests__/configuration.test.ts +3942 -2178
  10. package/src/__tests__/dev.test.tsx +1191 -235
  11. package/src/__tests__/guess-worker-format.test.ts +76 -57
  12. package/src/__tests__/helpers/cmd-shim.d.ts +6 -6
  13. package/src/__tests__/helpers/mock-account-id.ts +26 -22
  14. package/src/__tests__/helpers/mock-bin.ts +20 -20
  15. package/src/__tests__/helpers/mock-cfetch.ts +96 -92
  16. package/src/__tests__/helpers/mock-console.ts +59 -32
  17. package/src/__tests__/helpers/mock-dialogs.ts +121 -33
  18. package/src/__tests__/helpers/mock-http-server.ts +46 -0
  19. package/src/__tests__/helpers/mock-istty.ts +74 -0
  20. package/src/__tests__/helpers/mock-kv.ts +28 -35
  21. package/src/__tests__/helpers/mock-oauth-flow.ts +250 -0
  22. package/src/__tests__/helpers/mock-process.ts +39 -0
  23. package/src/__tests__/helpers/mock-stdin.ts +82 -77
  24. package/src/__tests__/helpers/mock-web-socket.ts +21 -21
  25. package/src/__tests__/helpers/run-in-tmp.ts +29 -20
  26. package/src/__tests__/helpers/run-wrangler.ts +8 -8
  27. package/src/__tests__/helpers/write-worker-source.ts +31 -0
  28. package/src/__tests__/helpers/write-wrangler-toml.ts +9 -9
  29. package/src/__tests__/https-options.test.ts +163 -0
  30. package/src/__tests__/index.test.ts +246 -850
  31. package/src/__tests__/init.test.ts +1992 -0
  32. package/src/__tests__/jest.setup.ts +85 -34
  33. package/src/__tests__/kv.test.ts +1402 -1139
  34. package/src/__tests__/logger.test.ts +141 -0
  35. package/src/__tests__/metrics.test.ts +445 -0
  36. package/src/__tests__/package-manager.test.ts +312 -165
  37. package/src/__tests__/pages.test.ts +1261 -0
  38. package/src/__tests__/parse.test.ts +253 -245
  39. package/src/__tests__/publish.test.ts +6611 -2079
  40. package/src/__tests__/pubsub.test.ts +367 -0
  41. package/src/__tests__/r2.test.ts +184 -149
  42. package/src/__tests__/route.test.ts +45 -0
  43. package/src/__tests__/secret.test.ts +474 -407
  44. package/src/__tests__/tail.test.ts +565 -431
  45. package/src/__tests__/test-old-node-version.js +31 -0
  46. package/src/__tests__/user.test.ts +143 -0
  47. package/src/__tests__/whoami.test.tsx +219 -75
  48. package/src/__tests__/worker-namespace.test.ts +327 -0
  49. package/src/abort.d.ts +3 -0
  50. package/src/api/dev.ts +86 -0
  51. package/src/api/index.ts +1 -0
  52. package/src/bundle-reporter.tsx +29 -0
  53. package/src/bundle.ts +196 -93
  54. package/src/cfetch/index.ts +83 -66
  55. package/src/cfetch/internal.ts +100 -84
  56. package/src/cli.ts +22 -14
  57. package/src/config/README.md +7 -7
  58. package/src/config/config.ts +223 -242
  59. package/src/config/diagnostics.ts +61 -61
  60. package/src/config/environment.ts +404 -256
  61. package/src/config/index.ts +218 -32
  62. package/src/config/validation-helpers.ts +436 -222
  63. package/src/config/validation.ts +1642 -907
  64. package/src/config-cache.ts +84 -0
  65. package/src/create-worker-preview.ts +255 -0
  66. package/src/create-worker-upload-form.ts +263 -0
  67. package/src/dev/dev-vars.ts +36 -0
  68. package/src/dev/dev.tsx +452 -0
  69. package/src/dev/local.tsx +373 -0
  70. package/src/dev/remote.tsx +386 -0
  71. package/src/dev/use-esbuild.ts +150 -0
  72. package/src/dev.tsx +576 -943
  73. package/src/dialogs.tsx +115 -57
  74. package/src/durable.ts +102 -0
  75. package/src/entry.ts +308 -37
  76. package/src/environment-variables.ts +25 -23
  77. package/src/errors.ts +11 -0
  78. package/src/faye-websocket.d.ts +6 -0
  79. package/src/generate.ts +33 -0
  80. package/src/git-client.ts +42 -0
  81. package/src/global-wrangler-config-path.ts +26 -0
  82. package/src/https-options.ts +127 -0
  83. package/src/index.tsx +1910 -2241
  84. package/src/init.ts +549 -0
  85. package/src/inspect.ts +603 -550
  86. package/src/intl-polyfill.d.ts +139 -0
  87. package/src/is-interactive.ts +12 -0
  88. package/src/kv.ts +430 -0
  89. package/src/logger.ts +73 -0
  90. package/src/metrics/index.ts +4 -0
  91. package/src/metrics/is-ci.ts +14 -0
  92. package/src/metrics/metrics-config.ts +239 -0
  93. package/src/metrics/metrics-dispatcher.ts +95 -0
  94. package/src/metrics/send-event.ts +92 -0
  95. package/src/miniflare-cli/README.md +30 -0
  96. package/src/miniflare-cli/assets.ts +543 -0
  97. package/src/miniflare-cli/enum-keys.ts +17 -0
  98. package/src/miniflare-cli/index.ts +85 -0
  99. package/src/miniflare-cli/request-context.ts +40 -0
  100. package/src/module-collection.ts +234 -146
  101. package/src/open-in-browser.ts +10 -6
  102. package/src/package-manager.ts +183 -90
  103. package/src/pages/build.tsx +204 -0
  104. package/src/pages/constants.ts +7 -0
  105. package/src/pages/deployments.tsx +106 -0
  106. package/src/pages/dev.tsx +401 -0
  107. package/src/pages/functions/buildPlugin.ts +105 -0
  108. package/src/pages/functions/buildWorker.ts +151 -0
  109. package/src/pages/functions/filepath-routing.test.ts +234 -0
  110. package/src/pages/functions/filepath-routing.ts +189 -0
  111. package/src/pages/functions/identifiers.ts +78 -0
  112. package/src/pages/functions/routes.ts +151 -0
  113. package/src/pages/index.tsx +84 -0
  114. package/src/pages/projects.tsx +163 -0
  115. package/src/pages/publish.tsx +338 -0
  116. package/src/pages/types.ts +40 -0
  117. package/src/pages/upload.tsx +396 -0
  118. package/src/pages/utils.ts +12 -0
  119. package/src/parse.ts +224 -121
  120. package/src/paths.ts +6 -6
  121. package/src/preview.ts +31 -0
  122. package/src/proxy.ts +413 -313
  123. package/src/publish.ts +773 -343
  124. package/src/pubsub/index.ts +286 -0
  125. package/src/pubsub/pubsub-commands.tsx +623 -0
  126. package/src/r2.ts +19 -19
  127. package/src/selfsigned.d.ts +29 -0
  128. package/src/sites.tsx +285 -151
  129. package/src/tail/filters.ts +108 -108
  130. package/src/tail/index.ts +217 -217
  131. package/src/tail/printing.ts +51 -46
  132. package/src/update-check.ts +19 -0
  133. package/src/user/choose-account.tsx +69 -0
  134. package/src/user/env-vars.ts +46 -0
  135. package/src/user/generate-auth-url.ts +33 -0
  136. package/src/user/generate-random-state.ts +16 -0
  137. package/src/user/index.ts +3 -0
  138. package/src/user/user.tsx +1171 -0
  139. package/src/whoami.tsx +63 -41
  140. package/src/worker-namespace.ts +206 -0
  141. package/src/worker.ts +191 -0
  142. package/src/zones.ts +76 -0
  143. package/templates/checked-fetch.js +17 -0
  144. package/templates/gitignore +171 -0
  145. package/templates/new-worker-scheduled.js +17 -0
  146. package/templates/new-worker-scheduled.ts +32 -0
  147. package/templates/new-worker.js +3 -3
  148. package/templates/new-worker.ts +18 -3
  149. package/templates/no-op-worker.js +10 -0
  150. package/templates/pages-shim.ts +9 -0
  151. package/templates/pages-template-plugin.ts +155 -0
  152. package/templates/pages-template-worker.ts +161 -0
  153. package/templates/static-asset-facade.js +38 -36
  154. package/templates/tsconfig.json +95 -95
  155. package/wrangler-dist/cli.d.ts +327 -0
  156. package/wrangler-dist/cli.js +94947 -111199
  157. package/pages/functions/buildWorker.ts +0 -62
  158. package/pages/functions/filepath-routing.test.ts +0 -123
  159. package/pages/functions/filepath-routing.ts +0 -178
  160. package/pages/functions/identifiers.ts +0 -78
  161. package/pages/functions/routes.ts +0 -151
  162. package/pages/functions/template-worker.ts +0 -130
  163. package/src/__tests__/helpers/faye-websocket.d.ts +0 -6
  164. package/src/__tests__/helpers/mock-user.ts +0 -27
  165. package/src/__tests__/logout.test.ts +0 -50
  166. package/src/__tests__/sentry.test.ts +0 -146
  167. package/src/api/form_data.ts +0 -217
  168. package/src/api/preview.ts +0 -147
  169. package/src/api/worker.ts +0 -186
  170. package/src/guess-worker-format.ts +0 -68
  171. package/src/kv.tsx +0 -339
  172. package/src/pages.tsx +0 -1045
  173. package/src/reporting.ts +0 -115
  174. package/src/user.tsx +0 -1063
  175. package/vendor/@cloudflare/kv-asset-handler/CHANGELOG.md +0 -332
  176. package/vendor/@cloudflare/kv-asset-handler/LICENSE_APACHE +0 -176
  177. package/vendor/@cloudflare/kv-asset-handler/LICENSE_MIT +0 -25
  178. package/vendor/@cloudflare/kv-asset-handler/README.md +0 -245
  179. package/vendor/@cloudflare/kv-asset-handler/dist/index.d.ts +0 -32
  180. package/vendor/@cloudflare/kv-asset-handler/dist/index.js +0 -354
  181. package/vendor/@cloudflare/kv-asset-handler/dist/mocks.d.ts +0 -13
  182. package/vendor/@cloudflare/kv-asset-handler/dist/mocks.js +0 -148
  183. package/vendor/@cloudflare/kv-asset-handler/dist/test/getAssetFromKV.d.ts +0 -1
  184. package/vendor/@cloudflare/kv-asset-handler/dist/test/getAssetFromKV.js +0 -436
  185. package/vendor/@cloudflare/kv-asset-handler/dist/test/mapRequestToAsset.d.ts +0 -1
  186. package/vendor/@cloudflare/kv-asset-handler/dist/test/mapRequestToAsset.js +0 -40
  187. package/vendor/@cloudflare/kv-asset-handler/dist/test/serveSinglePageApp.d.ts +0 -1
  188. package/vendor/@cloudflare/kv-asset-handler/dist/test/serveSinglePageApp.js +0 -42
  189. package/vendor/@cloudflare/kv-asset-handler/dist/types.d.ts +0 -26
  190. package/vendor/@cloudflare/kv-asset-handler/dist/types.js +0 -31
  191. package/vendor/@cloudflare/kv-asset-handler/package.json +0 -52
  192. package/vendor/@cloudflare/kv-asset-handler/src/index.ts +0 -296
  193. package/vendor/@cloudflare/kv-asset-handler/src/mocks.ts +0 -136
  194. package/vendor/@cloudflare/kv-asset-handler/src/test/getAssetFromKV.ts +0 -464
  195. package/vendor/@cloudflare/kv-asset-handler/src/test/mapRequestToAsset.ts +0 -33
  196. package/vendor/@cloudflare/kv-asset-handler/src/test/serveSinglePageApp.ts +0 -42
  197. package/vendor/@cloudflare/kv-asset-handler/src/types.ts +0 -39
  198. package/vendor/wrangler-mime/CHANGELOG.md +0 -289
  199. package/vendor/wrangler-mime/LICENSE +0 -21
  200. package/vendor/wrangler-mime/Mime.js +0 -97
  201. package/vendor/wrangler-mime/README.md +0 -187
  202. package/vendor/wrangler-mime/cli.js +0 -46
  203. package/vendor/wrangler-mime/index.js +0 -4
  204. package/vendor/wrangler-mime/lite.js +0 -4
  205. package/vendor/wrangler-mime/package.json +0 -52
  206. package/vendor/wrangler-mime/types/other.js +0 -1
  207. package/vendor/wrangler-mime/types/standard.js +0 -1
  208. package/wrangler-dist/cli.js.map +0 -7
@@ -3,7 +3,7 @@ import type { Environment, RawEnvironment } from "./environment";
3
3
  /**
4
4
  * This is the static type definition for the configuration object.
5
5
  *
6
- * It reflects the configuration that you can write in wrangler.toml,
6
+ * It reflects a normalized and validated version of the configuration that you can write in wrangler.toml,
7
7
  * and optionally augment with arguments passed directly to wrangler.
8
8
  *
9
9
  * For more information about the configuration object, see the
@@ -20,251 +20,232 @@ import type { Environment, RawEnvironment } from "./environment";
20
20
  * - `@breaking`: the deprecation/optionality is a breaking change from wrangler 1.
21
21
  * - `@todo`: there's more work to be done (with details attached).
22
22
  */
23
- export type Config = ConfigFields<Environment> & Environment;
24
-
25
- export type RawConfig = Partial<ConfigFields<RawEnvironment>> &
26
- RawEnvironment &
27
- DeprecatedConfigFields;
28
-
29
- export interface ConfigFields<Env extends RawEnvironment> {
30
- configPath: string | undefined;
31
-
32
- /**
33
- * The entrypoint/path to the JavaScript file that will be executed.
34
- */
35
- main: string | undefined;
36
-
37
- /**
38
- * A boolean to enable "legacy" style wrangler environments (from wrangler 1).
39
- * These have been superseded by Services, but there may be projects that won't
40
- * (or can't) use them. If you're using a legacy environment, you can set this
41
- * to `true` to enable it.
42
- */
43
- legacy_env: boolean;
44
-
45
- /**
46
- * The `env` section defines overrides for the configuration for different environments.
47
- *
48
- * All environment fields can be specified at the top level of the config indicating the default environment settings.
49
- *
50
- * - Some fields are inherited and overridable in each environment.
51
- * - But some are not inherited and must be explicitly specified in every environment, if they are specified at the top level.
52
- *
53
- * For more information, see the documentation at https://developers.cloudflare.com/workers/cli-wrangler/configuration#environments
54
- *
55
- * @default `{}`
56
- */
57
- env: {
58
- [envName: string]: Env;
59
- };
60
-
61
- /**
62
- * Options to configure the development server that your worker will use.
63
- *
64
- * @default `{}`
65
- */
66
- dev: {
67
- /**
68
- * IP address for the local dev server to listen on,
69
- *
70
- * @default `127.0.0.1`
71
- * @todo this needs to be implemented
72
- */
73
- ip?: string;
74
-
75
- /**
76
- * Port for the local dev server to listen on
77
- *
78
- * @default `8787`
79
- */
80
- port?: number;
81
-
82
- /**
83
- * Protocol that local wrangler dev server listens to requests on.
84
- *
85
- * @default `http`
86
- * @todo this needs to be implemented
87
- */
88
- local_protocol?: string;
89
-
90
- /**
91
- * Protocol that wrangler dev forwards requests on
92
- *
93
- * @default `https`
94
- * @todo this needs to be implemented
95
- */
96
- upstream_protocol?: string;
97
-
98
- /**
99
- * Host to forward requests to, defaults to the zone of project
100
- */
101
- host?: string;
102
- };
103
-
104
- /**
105
- * A list of migrations that should be uploaded with your Worker.
106
- *
107
- * These define changes in your Durable Object declarations.
108
- *
109
- * More details at https://developers.cloudflare.com/workers/learning/using-durable-objects#configuring-durable-object-classes-with-migrations
110
- *
111
- * @default `[]`
112
- */
113
- migrations: {
114
- /** A unique identifier for this migration. */
115
- tag: string;
116
- /** The new Durable Objects being defined. */
117
- new_classes?: string[];
118
- /** The Durable Objects being renamed. */
119
- renamed_classes?: {
120
- from: string;
121
- to: string;
122
- }[];
123
- /** The Durable Objects being removed. */
124
- deleted_classes?: string[];
125
- }[];
126
-
127
- /**
128
- * The definition of a Worker Site, a feature that lets you upload
129
- * static assets with your Worker.
130
- *
131
- * More details at https://developers.cloudflare.com/workers/platform/sites
132
- */
133
- site:
134
- | {
135
- /**
136
- * The directory containing your static assets.
137
- *
138
- * It must be a path relative to your wrangler.toml file.
139
- * Example: bucket = "./public"
140
- *
141
- * If there is a `site` field then it must contain this `bucket` field.
142
- */
143
- bucket: string;
144
-
145
- /**
146
- * The location of your Worker script.
147
- *
148
- * @deprecated DO NOT use this (it's a holdover from wrangler 1.x). Either use the top level `main` field, or pass the path to your entry file as a command line argument.
149
- * @breaking
150
- */
151
- "entry-point"?: string;
152
-
153
- /**
154
- * An exclusive list of .gitignore-style patterns that match file
155
- * or directory names from your bucket location. Only matched
156
- * items will be uploaded. Example: include = ["upload_dir"]
157
- *
158
- * @optional
159
- * @default `[]`
160
- */
161
- include?: string[];
162
-
163
- /**
164
- * A list of .gitignore-style patterns that match files or
165
- * directories in your bucket that should be excluded from
166
- * uploads. Example: exclude = ["ignore_dir"]
167
- *
168
- * @optional
169
- * @default `[]`
170
- */
171
- exclude?: string[];
172
- }
173
- | undefined;
174
-
175
- /**
176
- * A list of wasm modules that your worker should be bound to. This is
177
- * the "legacy" way of binding to a wasm module. ES module workers should
178
- * do proper module imports.
179
- */
180
- wasm_modules:
181
- | {
182
- [key: string]: string;
183
- }
184
- | undefined;
185
-
186
- /**
187
- * A list of text files that your worker should be bound to. This is
188
- * the "legacy" way of binding to a text file. ES module workers should
189
- * do proper module imports.
190
- */
191
- text_blobs:
192
- | {
193
- [key: string]: string;
194
- }
195
- | undefined;
196
-
197
- /**
198
- * Configures a custom build step to be run by Wrangler when building your Worker.
199
- *
200
- * Refer to the [custom builds documentation](https://developers.cloudflare.com/workers/cli-wrangler/configuration#build)
201
- * for more details.
202
- *
203
- * @default {}
204
- */
205
- build: {
206
- /** The command used to build your Worker. On Linux and macOS, the command is executed in the `sh` shell and the `cmd` shell for Windows. The `&&` and `||` shell operators may be used. */
207
- command?: string;
208
- /** The directory in which the command is executed. */
209
- cwd?: string;
210
- /** The directory to watch for changes while using wrangler dev, defaults to the current working directory */
211
- watch_dir?: string;
212
- /** Deprecated field previously used to configure the build and upload of the script. */
213
- upload?: DeprecatedUpload;
214
- };
23
+ export type Config = ConfigFields<DevConfig> & Environment;
24
+
25
+ export type RawConfig = Partial<ConfigFields<RawDevConfig>> &
26
+ RawEnvironment &
27
+ DeprecatedConfigFields &
28
+ EnvironmentMap;
29
+
30
+ export interface ConfigFields<Dev extends RawDevConfig> {
31
+ configPath: string | undefined;
32
+
33
+ /**
34
+ * A boolean to enable "legacy" style wrangler environments (from wrangler 1).
35
+ * These have been superseded by Services, but there may be projects that won't
36
+ * (or can't) use them. If you're using a legacy environment, you can set this
37
+ * to `true` to enable it.
38
+ */
39
+ legacy_env: boolean;
40
+
41
+ /**
42
+ * Whether Wrangler should send usage metrics to Cloudflare for this project.
43
+ *
44
+ * When defined this will override any user settings.
45
+ * Otherwise, Wrangler will use the user's preference.
46
+ */
47
+ send_metrics: boolean | undefined;
48
+
49
+ /**
50
+ * Options to configure the development server that your worker will use.
51
+ */
52
+ dev: Dev;
53
+
54
+ /**
55
+ * A list of migrations that should be uploaded with your Worker.
56
+ *
57
+ * These define changes in your Durable Object declarations.
58
+ *
59
+ * More details at https://developers.cloudflare.com/workers/learning/using-durable-objects#configuring-durable-object-classes-with-migrations
60
+ *
61
+ * @default `[]`
62
+ */
63
+ migrations: {
64
+ /** A unique identifier for this migration. */
65
+ tag: string;
66
+ /** The new Durable Objects being defined. */
67
+ new_classes?: string[];
68
+ /** The Durable Objects being renamed. */
69
+ renamed_classes?: {
70
+ from: string;
71
+ to: string;
72
+ }[];
73
+ /** The Durable Objects being removed. */
74
+ deleted_classes?: string[];
75
+ }[];
76
+
77
+ /**
78
+ * The definition of a Worker Site, a feature that lets you upload
79
+ * static assets with your Worker.
80
+ *
81
+ * More details at https://developers.cloudflare.com/workers/platform/sites
82
+ */
83
+ site:
84
+ | {
85
+ /**
86
+ * The directory containing your static assets.
87
+ *
88
+ * It must be a path relative to your wrangler.toml file.
89
+ * Example: bucket = "./public"
90
+ *
91
+ * If there is a `site` field then it must contain this `bucket` field.
92
+ */
93
+ bucket: string;
94
+
95
+ /**
96
+ * The location of your Worker script.
97
+ *
98
+ * @deprecated DO NOT use this (it's a holdover from wrangler 1.x). Either use the top level `main` field, or pass the path to your entry file as a command line argument.
99
+ * @breaking
100
+ */
101
+ "entry-point"?: string;
102
+
103
+ /**
104
+ * An exclusive list of .gitignore-style patterns that match file
105
+ * or directory names from your bucket location. Only matched
106
+ * items will be uploaded. Example: include = ["upload_dir"]
107
+ *
108
+ * @optional
109
+ * @default `[]`
110
+ */
111
+ include?: string[];
112
+
113
+ /**
114
+ * A list of .gitignore-style patterns that match files or
115
+ * directories in your bucket that should be excluded from
116
+ * uploads. Example: exclude = ["ignore_dir"]
117
+ *
118
+ * @optional
119
+ * @default `[]`
120
+ */
121
+ exclude?: string[];
122
+ }
123
+ | undefined;
124
+
125
+ /**
126
+ * Serve a folder of static assets with your Worker, without any additional code.
127
+ * This can either be a string, or an object with additional config fields.
128
+ */
129
+ assets:
130
+ | string
131
+ | { bucket: string; include: string[]; exclude: string[] }
132
+ | undefined;
133
+
134
+ /**
135
+ * A list of wasm modules that your worker should be bound to. This is
136
+ * the "legacy" way of binding to a wasm module. ES module workers should
137
+ * do proper module imports.
138
+ */
139
+ wasm_modules:
140
+ | {
141
+ [key: string]: string;
142
+ }
143
+ | undefined;
144
+
145
+ /**
146
+ * A list of text files that your worker should be bound to. This is
147
+ * the "legacy" way of binding to a text file. ES module workers should
148
+ * do proper module imports.
149
+ */
150
+ text_blobs:
151
+ | {
152
+ [key: string]: string;
153
+ }
154
+ | undefined;
155
+
156
+ /**
157
+ * A list of data files that your worker should be bound to. This is
158
+ * the "legacy" way of binding to a data file. ES module workers should
159
+ * do proper module imports.
160
+ */
161
+ data_blobs:
162
+ | {
163
+ [key: string]: string;
164
+ }
165
+ | undefined;
215
166
  }
216
167
 
217
- export interface DeprecatedConfigFields {
218
- /**
219
- * The project "type". A holdover from wrangler 1.x.
220
- * Valid values were "webpack", "javascript", and "rust".
221
- *
222
- * @deprecated DO NOT USE THIS. Most common features now work out of the box with wrangler, including modules, jsx, typescript, etc. If you need anything more, use a custom build.
223
- * @breaking
224
- */
225
- type?: "webpack" | "javascript" | "rust";
226
-
227
- /**
228
- * Path to the webpack config to use when building your worker.
229
- * A holdover from wrangler 1.x, used with `type: "webpack"`.
230
- *
231
- * @deprecated DO NOT USE THIS. Most common features now work out of the box with wrangler, including modules, jsx, typescript, etc. If you need anything more, use a custom build.
232
- * @breaking
233
- */
234
- webpack_config?: string;
168
+ export interface DevConfig {
169
+ /**
170
+ * IP address for the local dev server to listen on,
171
+ *
172
+ * @default `localhost`
173
+ */
174
+ ip: string;
175
+
176
+ /**
177
+ * Port for the local dev server to listen on
178
+ *
179
+ * @default `8787`
180
+ */
181
+ port: number | undefined;
182
+
183
+ /**
184
+ * Protocol that local wrangler dev server listens to requests on.
185
+ *
186
+ * @default `http`
187
+ */
188
+ local_protocol: "http" | "https";
189
+
190
+ /**
191
+ * Protocol that wrangler dev forwards requests on
192
+ *
193
+ * Setting this to `http` is not currently implemented.
194
+ * See https://github.com/cloudflare/wrangler2/issues/583
195
+ *
196
+ * @default `https`
197
+ * @todo this needs to be implemented https://github.com/cloudflare/wrangler2/issues/583
198
+ */
199
+ upstream_protocol: "https" | "http";
200
+
201
+ /**
202
+ * Host to forward requests to, defaults to the host of the first route of project
203
+ */
204
+ host: string | undefined;
235
205
  }
236
206
 
237
- /**
238
- * Deprecated upload configuration.
239
- */
240
- export interface DeprecatedUpload {
241
- /**
242
- * The format of the Worker script.
243
- *
244
- * @deprecated We infer the format automatically now.
245
- */
246
- format?: "modules" | "service-worker";
247
-
248
- /**
249
- * The directory you wish to upload your worker from,
250
- * relative to the wrangler.toml file.
251
- *
252
- * Defaults to the directory containing the wrangler.toml file.
253
- *
254
- * @deprecated
255
- * @breaking In wrangler 1, this defaults to ./dist, whereas in wrangler 2 it defaults to ./
256
- */
257
- dir?: string;
207
+ export type RawDevConfig = Partial<DevConfig>;
258
208
 
259
- /**
260
- * The path to the Worker script, relative to `upload.dir`.
261
- *
262
- * @deprecated This will be replaced by a command line argument.
263
- */
264
- main?: string;
209
+ export interface DeprecatedConfigFields {
210
+ /**
211
+ * The project "type". A holdover from wrangler 1.x.
212
+ * Valid values were "webpack", "javascript", and "rust".
213
+ *
214
+ * @deprecated DO NOT USE THIS. Most common features now work out of the box with wrangler, including modules, jsx, typescript, etc. If you need anything more, use a custom build.
215
+ * @breaking
216
+ */
217
+ type?: "webpack" | "javascript" | "rust";
218
+
219
+ /**
220
+ * Path to the webpack config to use when building your worker.
221
+ * A holdover from wrangler 1.x, used with `type: "webpack"`.
222
+ *
223
+ * @deprecated DO NOT USE THIS. Most common features now work out of the box with wrangler, including modules, jsx, typescript, etc. If you need anything more, use a custom build.
224
+ * @breaking
225
+ */
226
+ webpack_config?: string;
227
+
228
+ /**
229
+ * Configuration only used by a standalone use of the miniflare binary.
230
+ * @deprecated
231
+ */
232
+ miniflare?: unknown;
233
+ }
265
234
 
266
- /**
267
- * @deprecated This is now defined at the top level `rules` field.
268
- */
269
- rules?: Environment["rules"];
235
+ interface EnvironmentMap {
236
+ /**
237
+ * The `env` section defines overrides for the configuration for different environments.
238
+ *
239
+ * All environment fields can be specified at the top level of the config indicating the default environment settings.
240
+ *
241
+ * - Some fields are inherited and overridable in each environment.
242
+ * - But some are not inherited and must be explicitly specified in every environment, if they are specified at the top level.
243
+ *
244
+ * For more information, see the documentation at https://developers.cloudflare.com/workers/cli-wrangler/configuration#environments
245
+ *
246
+ * @default `{}`
247
+ */
248
+ env?: {
249
+ [envName: string]: RawEnvironment;
250
+ };
270
251
  }
@@ -5,76 +5,76 @@
5
5
  * You can check whether the overall tree has errors or warnings, and you can render a string representation of the errors or warnings.
6
6
  */
7
7
  export class Diagnostics {
8
- errors: string[] = [];
9
- warnings: string[] = [];
10
- children: Diagnostics[] = [];
8
+ errors: string[] = [];
9
+ warnings: string[] = [];
10
+ children: Diagnostics[] = [];
11
11
 
12
- /**
13
- * Create a new Diagnostics object.
14
- * @param description A general description of this collection of messages.
15
- */
16
- constructor(public description: string) {}
12
+ /**
13
+ * Create a new Diagnostics object.
14
+ * @param description A general description of this collection of messages.
15
+ */
16
+ constructor(public description: string) {}
17
17
 
18
- /**
19
- * Merge the given `diagnostics` into this as a child.
20
- */
21
- addChild(diagnostics: Diagnostics): void {
22
- if (diagnostics.hasErrors() || diagnostics.hasWarnings()) {
23
- this.children.push(diagnostics);
24
- }
25
- }
18
+ /**
19
+ * Merge the given `diagnostics` into this as a child.
20
+ */
21
+ addChild(diagnostics: Diagnostics): void {
22
+ if (diagnostics.hasErrors() || diagnostics.hasWarnings()) {
23
+ this.children.push(diagnostics);
24
+ }
25
+ }
26
26
 
27
- /** Does this or any of its children have errors. */
28
- hasErrors(): boolean {
29
- if (this.errors.length > 0) {
30
- return true;
31
- } else {
32
- return this.children.some((child) => child.hasErrors());
33
- }
34
- }
27
+ /** Does this or any of its children have errors. */
28
+ hasErrors(): boolean {
29
+ if (this.errors.length > 0) {
30
+ return true;
31
+ } else {
32
+ return this.children.some((child) => child.hasErrors());
33
+ }
34
+ }
35
35
 
36
- /** Render the errors of this and all its children. */
37
- renderErrors(): string {
38
- return this.render("errors");
39
- }
36
+ /** Render the errors of this and all its children. */
37
+ renderErrors(): string {
38
+ return this.render("errors");
39
+ }
40
40
 
41
- /** Does this or any of its children have warnings. */
42
- hasWarnings(): boolean {
43
- if (this.warnings.length > 0) {
44
- return true;
45
- } else {
46
- return this.children.some((child) => child.hasWarnings());
47
- }
48
- }
41
+ /** Does this or any of its children have warnings. */
42
+ hasWarnings(): boolean {
43
+ if (this.warnings.length > 0) {
44
+ return true;
45
+ } else {
46
+ return this.children.some((child) => child.hasWarnings());
47
+ }
48
+ }
49
49
 
50
- /** Render the warnings of this and all its children. */
51
- renderWarnings(): string {
52
- return this.render("warnings");
53
- }
50
+ /** Render the warnings of this and all its children. */
51
+ renderWarnings(): string {
52
+ return this.render("warnings");
53
+ }
54
54
 
55
- private render(field: "errors" | "warnings"): string {
56
- const hasMethod = field === "errors" ? "hasErrors" : "hasWarnings";
57
- return indentText(
58
- `${this.description}\n` +
59
- // Output all the fields (errors or warnings) at this level
60
- this[field].map((message) => `- ${indentText(message)}`).join("\n") +
61
- // Output all the child diagnostics at the next level
62
- this.children
63
- .map((child) =>
64
- child[hasMethod]() ? "\n- " + child.render(field) : ""
65
- )
66
- .filter((output) => output !== "")
67
- .join("\n")
68
- );
69
- }
55
+ private render(field: "errors" | "warnings"): string {
56
+ const hasMethod = field === "errors" ? "hasErrors" : "hasWarnings";
57
+ return indentText(
58
+ `${this.description}\n` +
59
+ // Output all the fields (errors or warnings) at this level
60
+ this[field].map((message) => `- ${indentText(message)}`).join("\n") +
61
+ // Output all the child diagnostics at the next level
62
+ this.children
63
+ .map((child) =>
64
+ child[hasMethod]() ? "\n- " + child.render(field) : ""
65
+ )
66
+ .filter((output) => output !== "")
67
+ .join("\n")
68
+ );
69
+ }
70
70
  }
71
71
 
72
72
  /** Indent all the but the first line by two spaces. */
73
73
  function indentText(str: string): string {
74
- return str
75
- .split("\n")
76
- .map((line, index) =>
77
- (index === 0 ? line : ` ${line}`).replace(/^\s*$/, "")
78
- )
79
- .join("\n");
74
+ return str
75
+ .split("\n")
76
+ .map((line, index) =>
77
+ (index === 0 ? line : ` ${line}`).replace(/^\s*$/, "")
78
+ )
79
+ .join("\n");
80
80
  }