wrangler 0.0.0-e043479 → 0.0.0-e0850ad1

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 (154) hide show
  1. package/Cloudflare_CA.pem +18 -0
  2. package/README.md +47 -16
  3. package/bin/wrangler.js +118 -32
  4. package/kv-asset-handler.js +1 -0
  5. package/package.json +148 -78
  6. package/templates/__tests__/pages-dev-util.test.ts +128 -0
  7. package/templates/__tests__/tsconfig-sanity.ts +12 -0
  8. package/templates/__tests__/tsconfig.json +8 -0
  9. package/templates/checked-fetch.js +30 -0
  10. package/templates/facade.d.ts +17 -0
  11. package/templates/gitignore +172 -0
  12. package/templates/init-tests/test-jest-new-worker.js +23 -0
  13. package/templates/init-tests/test-vitest-new-worker.js +24 -0
  14. package/templates/init-tests/test-vitest-new-worker.ts +25 -0
  15. package/templates/middleware/common.ts +67 -0
  16. package/templates/middleware/loader-modules.ts +137 -0
  17. package/templates/middleware/loader-sw.ts +228 -0
  18. package/templates/middleware/middleware-d1-beta.d.ts +3 -0
  19. package/templates/middleware/middleware-miniflare3-json-error.ts +33 -0
  20. package/templates/middleware/middleware-multiworker-dev.d.ts +4 -0
  21. package/templates/middleware/middleware-multiworker-dev.ts +59 -0
  22. package/templates/middleware/middleware-pretty-error.ts +40 -0
  23. package/templates/middleware/middleware-scheduled.ts +15 -0
  24. package/templates/middleware/middleware-serve-static-assets.d.ts +6 -0
  25. package/templates/middleware/middleware-serve-static-assets.ts +56 -0
  26. package/templates/new-worker-scheduled.js +17 -0
  27. package/templates/new-worker-scheduled.ts +32 -0
  28. package/templates/new-worker.js +3 -3
  29. package/templates/new-worker.ts +22 -4
  30. package/templates/no-op-worker.js +10 -0
  31. package/templates/pages-dev-pipeline.ts +31 -0
  32. package/templates/pages-dev-util.ts +55 -0
  33. package/templates/pages-shim.ts +9 -0
  34. package/templates/pages-template-plugin.ts +190 -0
  35. package/templates/pages-template-worker.ts +198 -0
  36. package/templates/tsconfig-sanity.ts +11 -0
  37. package/templates/tsconfig.init.json +105 -0
  38. package/templates/tsconfig.json +6 -103
  39. package/wrangler-dist/cli.d.ts +1743 -0
  40. package/wrangler-dist/cli.js +142279 -130711
  41. package/wrangler-dist/wasm-sync.wasm +0 -0
  42. package/import_meta_url.js +0 -3
  43. package/miniflare-config-stubs/.env.empty +0 -0
  44. package/miniflare-config-stubs/package.empty.json +0 -1
  45. package/miniflare-config-stubs/wrangler.empty.toml +0 -0
  46. package/pages/functions/buildWorker.ts +0 -62
  47. package/pages/functions/filepath-routing.test.ts +0 -123
  48. package/pages/functions/filepath-routing.ts +0 -178
  49. package/pages/functions/identifiers.ts +0 -78
  50. package/pages/functions/routes.ts +0 -151
  51. package/pages/functions/template-worker.ts +0 -130
  52. package/src/__tests__/configuration.test.ts +0 -2186
  53. package/src/__tests__/dev.test.tsx +0 -247
  54. package/src/__tests__/guess-worker-format.test.ts +0 -66
  55. package/src/__tests__/helpers/clipboardy-mock.js +0 -4
  56. package/src/__tests__/helpers/cmd-shim.d.ts +0 -11
  57. package/src/__tests__/helpers/faye-websocket.d.ts +0 -6
  58. package/src/__tests__/helpers/mock-account-id.ts +0 -44
  59. package/src/__tests__/helpers/mock-bin.ts +0 -36
  60. package/src/__tests__/helpers/mock-cfetch.ts +0 -207
  61. package/src/__tests__/helpers/mock-console.ts +0 -70
  62. package/src/__tests__/helpers/mock-dialogs.ts +0 -65
  63. package/src/__tests__/helpers/mock-kv.ts +0 -40
  64. package/src/__tests__/helpers/mock-stdin.ts +0 -103
  65. package/src/__tests__/helpers/mock-user.ts +0 -27
  66. package/src/__tests__/helpers/mock-web-socket.ts +0 -29
  67. package/src/__tests__/helpers/run-in-tmp.ts +0 -29
  68. package/src/__tests__/helpers/run-wrangler.ts +0 -16
  69. package/src/__tests__/helpers/write-wrangler-toml.ts +0 -17
  70. package/src/__tests__/index.test.ts +0 -866
  71. package/src/__tests__/jest.setup.ts +0 -69
  72. package/src/__tests__/kv.test.ts +0 -1408
  73. package/src/__tests__/logout.test.ts +0 -50
  74. package/src/__tests__/package-manager.test.ts +0 -206
  75. package/src/__tests__/parse.test.ts +0 -322
  76. package/src/__tests__/publish.test.ts +0 -2139
  77. package/src/__tests__/r2.test.ts +0 -198
  78. package/src/__tests__/secret.test.ts +0 -425
  79. package/src/__tests__/sentry.test.ts +0 -146
  80. package/src/__tests__/tail.test.ts +0 -564
  81. package/src/__tests__/whoami.test.tsx +0 -86
  82. package/src/api/form_data.ts +0 -217
  83. package/src/api/preview.ts +0 -147
  84. package/src/api/worker.ts +0 -186
  85. package/src/bundle.ts +0 -133
  86. package/src/cfetch/index.ts +0 -104
  87. package/src/cfetch/internal.ts +0 -133
  88. package/src/cli.ts +0 -19
  89. package/src/config/README.md +0 -107
  90. package/src/config/config.ts +0 -270
  91. package/src/config/diagnostics.ts +0 -80
  92. package/src/config/environment.ts +0 -305
  93. package/src/config/index.ts +0 -52
  94. package/src/config/validation-helpers.ts +0 -370
  95. package/src/config/validation.ts +0 -1019
  96. package/src/dev.tsx +0 -960
  97. package/src/dialogs.tsx +0 -77
  98. package/src/entry.ts +0 -57
  99. package/src/environment-variables.ts +0 -33
  100. package/src/guess-worker-format.ts +0 -68
  101. package/src/index.tsx +0 -2302
  102. package/src/inspect.ts +0 -609
  103. package/src/kv.tsx +0 -339
  104. package/src/module-collection.ts +0 -170
  105. package/src/open-in-browser.ts +0 -13
  106. package/src/package-manager.ts +0 -126
  107. package/src/pages.tsx +0 -1045
  108. package/src/parse.ts +0 -183
  109. package/src/paths.ts +0 -26
  110. package/src/proxy.ts +0 -376
  111. package/src/publish.ts +0 -363
  112. package/src/r2.ts +0 -50
  113. package/src/reporting.ts +0 -115
  114. package/src/sites.tsx +0 -238
  115. package/src/tail/filters.ts +0 -279
  116. package/src/tail/index.ts +0 -299
  117. package/src/tail/printing.ts +0 -62
  118. package/src/user.tsx +0 -1063
  119. package/src/whoami.tsx +0 -69
  120. package/templates/static-asset-facade.js +0 -47
  121. package/vendor/@cloudflare/kv-asset-handler/CHANGELOG.md +0 -332
  122. package/vendor/@cloudflare/kv-asset-handler/LICENSE_APACHE +0 -176
  123. package/vendor/@cloudflare/kv-asset-handler/LICENSE_MIT +0 -25
  124. package/vendor/@cloudflare/kv-asset-handler/README.md +0 -245
  125. package/vendor/@cloudflare/kv-asset-handler/dist/index.d.ts +0 -32
  126. package/vendor/@cloudflare/kv-asset-handler/dist/index.js +0 -354
  127. package/vendor/@cloudflare/kv-asset-handler/dist/mocks.d.ts +0 -13
  128. package/vendor/@cloudflare/kv-asset-handler/dist/mocks.js +0 -148
  129. package/vendor/@cloudflare/kv-asset-handler/dist/test/getAssetFromKV.d.ts +0 -1
  130. package/vendor/@cloudflare/kv-asset-handler/dist/test/getAssetFromKV.js +0 -436
  131. package/vendor/@cloudflare/kv-asset-handler/dist/test/mapRequestToAsset.d.ts +0 -1
  132. package/vendor/@cloudflare/kv-asset-handler/dist/test/mapRequestToAsset.js +0 -40
  133. package/vendor/@cloudflare/kv-asset-handler/dist/test/serveSinglePageApp.d.ts +0 -1
  134. package/vendor/@cloudflare/kv-asset-handler/dist/test/serveSinglePageApp.js +0 -42
  135. package/vendor/@cloudflare/kv-asset-handler/dist/types.d.ts +0 -26
  136. package/vendor/@cloudflare/kv-asset-handler/dist/types.js +0 -31
  137. package/vendor/@cloudflare/kv-asset-handler/package.json +0 -52
  138. package/vendor/@cloudflare/kv-asset-handler/src/index.ts +0 -296
  139. package/vendor/@cloudflare/kv-asset-handler/src/mocks.ts +0 -136
  140. package/vendor/@cloudflare/kv-asset-handler/src/test/getAssetFromKV.ts +0 -464
  141. package/vendor/@cloudflare/kv-asset-handler/src/test/mapRequestToAsset.ts +0 -33
  142. package/vendor/@cloudflare/kv-asset-handler/src/test/serveSinglePageApp.ts +0 -42
  143. package/vendor/@cloudflare/kv-asset-handler/src/types.ts +0 -39
  144. package/vendor/wrangler-mime/CHANGELOG.md +0 -289
  145. package/vendor/wrangler-mime/LICENSE +0 -21
  146. package/vendor/wrangler-mime/Mime.js +0 -97
  147. package/vendor/wrangler-mime/README.md +0 -187
  148. package/vendor/wrangler-mime/cli.js +0 -46
  149. package/vendor/wrangler-mime/index.js +0 -4
  150. package/vendor/wrangler-mime/lite.js +0 -4
  151. package/vendor/wrangler-mime/package.json +0 -52
  152. package/vendor/wrangler-mime/types/other.js +0 -1
  153. package/vendor/wrangler-mime/types/standard.js +0 -1
  154. package/wrangler-dist/cli.js.map +0 -7
@@ -1,270 +0,0 @@
1
- import type { Environment, RawEnvironment } from "./environment";
2
-
3
- /**
4
- * This is the static type definition for the configuration object.
5
- *
6
- * It reflects the configuration that you can write in wrangler.toml,
7
- * and optionally augment with arguments passed directly to wrangler.
8
- *
9
- * For more information about the configuration object, see the
10
- * documentation at https://developers.cloudflare.com/workers/cli-wrangler/configuration
11
- *
12
- * Notes:
13
- *
14
- * - Fields that are only specified in `ConfigFields` and not `Environment` can only appear
15
- * in the top level config and should not appear in any environments.
16
- * - All top level fields in config and environments are optional in the wrangler.toml file.
17
- *
18
- * Legend for the annotations:
19
- *
20
- * - `@breaking`: the deprecation/optionality is a breaking change from wrangler 1.
21
- * - `@todo`: there's more work to be done (with details attached).
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
- };
215
- }
216
-
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;
235
- }
236
-
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;
258
-
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;
265
-
266
- /**
267
- * @deprecated This is now defined at the top level `rules` field.
268
- */
269
- rules?: Environment["rules"];
270
- }
@@ -1,80 +0,0 @@
1
- /**
2
- * Diagnostic errors and warnings.
3
- *
4
- * The structure is a tree, where each node can contain zero or more errors, warnings and child diagnostics objects.
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
- */
7
- export class Diagnostics {
8
- errors: string[] = [];
9
- warnings: string[] = [];
10
- children: Diagnostics[] = [];
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) {}
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
- }
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
- }
35
-
36
- /** Render the errors of this and all its children. */
37
- renderErrors(): string {
38
- return this.render("errors");
39
- }
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
- }
49
-
50
- /** Render the warnings of this and all its children. */
51
- renderWarnings(): string {
52
- return this.render("warnings");
53
- }
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
- }
70
- }
71
-
72
- /** Indent all the but the first line by two spaces. */
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");
80
- }
@@ -1,305 +0,0 @@
1
- /**
2
- * The `Environment` interface declares all the configuration fields that
3
- * can be specified for an environment.
4
- *
5
- * This could be the top-level default environment, or a specific named environment.
6
- */
7
- export interface Environment
8
- extends EnvironmentInheritable,
9
- EnvironmentNonInheritable {}
10
-
11
- /**
12
- * The `EnvironmentInheritable` interface declares all the configuration fields for an environment
13
- * that can be inherited (and overridden) from the top-level environment.
14
- */
15
- interface EnvironmentInheritable {
16
- /**
17
- * The name of your worker. Alphanumeric + dashes only.
18
- *
19
- * @inheritable
20
- */
21
- name: string | undefined;
22
-
23
- /**
24
- * This is the ID of the account associated with your zone.
25
- * You might have more than one account, so make sure to use
26
- * the ID of the account associated with the zone/route you
27
- * provide, if you provide one. It can also be specified through
28
- * the CLOUDFLARE_ACCOUNT_ID environment variable.
29
- *
30
- * @inheritable
31
- */
32
- account_id: string | undefined;
33
-
34
- /**
35
- * A date in the form yyyy-mm-dd, which will be used to determine
36
- * which version of the Workers runtime is used.
37
- *
38
- * More details at https://developers.cloudflare.com/workers/platform/compatibility-dates
39
- *
40
- * @inheritable
41
- */
42
- compatibility_date: string | undefined;
43
-
44
- /**
45
- * A list of flags that enable features from upcoming features of
46
- * the Workers runtime, usually used together with compatibility_flags.
47
- *
48
- * More details at https://developers.cloudflare.com/workers/platform/compatibility-dates
49
- *
50
- * @inheritable
51
- */
52
- compatibility_flags: string[];
53
-
54
- /**
55
- * Whether we use <name>.<subdomain>.workers.dev to
56
- * test and deploy your worker.
57
- *
58
- * @default `true` (This is a breaking change from wrangler 1)
59
- * @breaking
60
- * @inheritable
61
- */
62
- workers_dev: boolean;
63
-
64
- /**
65
- * A list of routes that your worker should be published to.
66
- * Only one of `routes` or `route` is required.
67
- *
68
- * Only required when workers_dev is false, and there's no scheduled worker (see `triggers`)
69
- *
70
- * @inheritable
71
- */
72
- routes: string[] | undefined;
73
-
74
- /**
75
- * A route that your worker should be published to. Literally
76
- * the same as routes, but only one.
77
- * Only one of `routes` or `route` is required.
78
- *
79
- * Only required when workers_dev is false, and there's no scheduled worker
80
- *
81
- * @inheritable
82
- */
83
- route: string | undefined;
84
-
85
- /**
86
- * The function to use to replace jsx syntax.
87
- *
88
- * @default `"React.createElement"`
89
- * @inheritable
90
- */
91
- jsx_factory: string;
92
-
93
- /**
94
- * The function to use to replace jsx fragment syntax.
95
- *
96
- * @default `"React.Fragment"`
97
- * @inheritable
98
- */
99
- jsx_fragment: string;
100
-
101
- /**
102
- * "Cron" definitions to trigger a worker's "scheduled" function.
103
- *
104
- * Lets you call workers periodically, much like a cron job.
105
- *
106
- * More details here https://developers.cloudflare.com/workers/platform/cron-triggers
107
- *
108
- * @default `{crons:[]}`
109
- * @inheritable
110
- */
111
- triggers: { crons: string[] };
112
-
113
- /**
114
- * Specifies the Usage Model for your Worker. There are two options -
115
- * [bundled](https://developers.cloudflare.com/workers/platform/limits#bundled-usage-model) and
116
- * [unbound](https://developers.cloudflare.com/workers/platform/limits#unbound-usage-model).
117
- * For newly created Workers, if the Usage Model is omitted
118
- * it will be set to the [default Usage Model set on the account](https://dash.cloudflare.com/?account=workers/default-usage-model).
119
- * For existing Workers, if the Usage Model is omitted, it will be
120
- * set to the Usage Model configured in the dashboard for that Worker.
121
- *
122
- * @inheritable
123
- */
124
- usage_model: undefined | "bundled" | "unbound";
125
-
126
- /**
127
- * An ordered list of rules that define which modules to import,
128
- * and what type to import them as. You will need to specify rules
129
- * to use Text, Data, and CompiledWasm modules, or when you wish to
130
- * have a .js file be treated as an ESModule instead of CommonJS.
131
- *
132
- * @inheritable
133
- */
134
- rules: Rule[];
135
-
136
- /**
137
- * TODO: remove this as it has been deprecated.
138
- *
139
- * This is just here for now because the `route` commands use it.
140
- * So we need to include it in this type so it is available.
141
- */
142
- zone_id?: string;
143
- }
144
-
145
- /**
146
- * The `EnvironmentNonInheritable` interface declares all the configuration fields for an environment
147
- * that cannot be inherited from the top-level environment, and must be defined specifically.
148
- *
149
- * If any of these fields are defined at the top-level then they should also be specifically defined
150
- * for each named environment.
151
- */
152
- interface EnvironmentNonInheritable {
153
- /**
154
- * A map of environment variables to set when deploying your worker.
155
- *
156
- * NOTE: This field is not automatically inherited from the top level environment,
157
- * and so must be specified in every named environment.
158
- *
159
- * @default `{}`
160
- * @nonInheritable
161
- */
162
- vars: { [key: string]: unknown };
163
-
164
- /**
165
- * A list of durable objects that your worker should be bound to.
166
- *
167
- * For more information about Durable Objects, see the documentation at
168
- * https://developers.cloudflare.com/workers/learning/using-durable-objects
169
- *
170
- * NOTE: This field is not automatically inherited from the top level environment,
171
- * and so must be specified in every named environment.
172
- *
173
- * @default `{bindings:[]}`
174
- * @nonInheritable
175
- */
176
- durable_objects: {
177
- bindings: {
178
- /** The name of the binding used to refer to the Durable Object */
179
- name: string;
180
- /** The exported class name of the Durable Object */
181
- class_name: string;
182
- /** The script where the Durable Object is defined (if it's external to this worker) */
183
- script_name?: string;
184
- }[];
185
- };
186
-
187
- /**
188
- * These specify any Workers KV Namespaces you want to
189
- * access from inside your Worker.
190
- *
191
- * To learn more about KV Namespaces,
192
- * see the documentation at https://developers.cloudflare.com/workers/learning/how-kv-works
193
- *
194
- * NOTE: This field is not automatically inherited from the top level environment,
195
- * and so must be specified in every named environment.
196
- *
197
- * @default `[]`
198
- * @nonInheritable
199
- */
200
- kv_namespaces: {
201
- /** The binding name used to refer to the KV Namespace */
202
- binding: string;
203
- /** The ID of the KV namespace */
204
- id: string;
205
- /** The ID of the KV namespace used during `wrangler dev` */
206
- preview_id?: string;
207
- }[];
208
-
209
- /**
210
- * Specifies R2 buckets that are bound to this Worker environment.
211
- *
212
- * NOTE: This field is not automatically inherited from the top level environment,
213
- * and so must be specified in every named environment.
214
- *
215
- * @default `[]`
216
- * @nonInheritable
217
- */
218
- r2_buckets: {
219
- /** The binding name used to refer to the R2 bucket in the worker. */
220
- binding: string;
221
- /** The name of this R2 bucket at the edge. */
222
- bucket_name: string;
223
- /** The preview name of this R2 bucket at the edge. */
224
- preview_bucket_name?: string;
225
- }[];
226
-
227
- /**
228
- * "Unsafe" tables for features that aren't directly supported by wrangler.
229
- *
230
- * NOTE: This field is not automatically inherited from the top level environment,
231
- * and so must be specified in every named environment.
232
- *
233
- * @default `{ bindings: [] }`
234
- * @nonInheritable
235
- */
236
- unsafe: {
237
- /**
238
- * A set of bindings that should be put into a Worker's upload metadata without changes. These
239
- * can be used to implement bindings for features that haven't released and aren't supported
240
- * directly by wrangler or miniflare.
241
- *
242
- * @default []
243
- */
244
- bindings: {
245
- name: string;
246
- type: string;
247
- [key: string]: unknown;
248
- }[];
249
- };
250
- }
251
-
252
- /**
253
- * The environment configuration properties that have been deprecated.
254
- */
255
- interface EnvironmentDeprecated {
256
- /**
257
- * The zone ID of the zone you want to deploy to. You can find this
258
- * in your domain page on the dashboard.
259
- *
260
- * @deprecated This is unnecessary since we can deduce this from routes directly.
261
- */
262
- zone_id?: string;
263
-
264
- /**
265
- * A list of services that your worker should be bound to.
266
- *
267
- * @default `[]`
268
- * @deprecated DO NOT USE. We'd added this to test the new service binding system, but the proper way to test experimental features is to use `unsafe.bindings` configuration.
269
- */
270
- experimental_services?: {
271
- /** The binding name used to refer to the Service */
272
- name: string;
273
- /** The name of the Service being bound */
274
- service: string;
275
- /** The Service's environment */
276
- environment: string;
277
- }[];
278
- }
279
-
280
- /**
281
- * The raw environment configuration that we read from the config file.
282
- *
283
- * All the properties are optional, and will be replaced with defaults in the configuration that
284
- * is used in the rest of the codebase.
285
- */
286
- export type RawEnvironment = Partial<Environment> & EnvironmentDeprecated;
287
-
288
- /**
289
- * A bundling resolver rule, defining the modules type for paths that match the specified globs.
290
- */
291
- export type Rule = {
292
- type: ConfigModuleRuleType;
293
- globs: string[];
294
- fallthrough?: boolean;
295
- };
296
-
297
- /**
298
- * The possible types for a `Rule`.
299
- */
300
- export type ConfigModuleRuleType =
301
- | "ESModule"
302
- | "CommonJS"
303
- | "CompiledWasm"
304
- | "Text"
305
- | "Data";
@@ -1,52 +0,0 @@
1
- import { findUpSync } from "find-up";
2
- import { parseTOML, readFileSync } from "../parse";
3
- import { normalizeAndValidateConfig } from "./validation";
4
- import type { Config, RawConfig } from "./config";
5
-
6
- export type { Config, RawConfig } from "./config";
7
- export type {
8
- Environment,
9
- RawEnvironment,
10
- ConfigModuleRuleType,
11
- } from "./environment";
12
-
13
- /**
14
- * Get the Wrangler configuration; read it from the give `configPath` if available.
15
- */
16
- export function readConfig(configPath?: string): Config {
17
- let rawConfig: RawConfig = {};
18
- if (!configPath) {
19
- configPath = findWranglerToml();
20
- }
21
-
22
- // Load the configuration from disk if available
23
- if (configPath) {
24
- rawConfig = parseTOML(readFileSync(configPath), configPath);
25
- }
26
-
27
- // Process the top-level configuration.
28
- const { config, diagnostics } = normalizeAndValidateConfig(
29
- rawConfig,
30
- configPath
31
- );
32
-
33
- if (diagnostics.hasWarnings()) {
34
- console.warn(diagnostics.renderWarnings());
35
- }
36
- if (diagnostics.hasErrors()) {
37
- throw new Error(diagnostics.renderErrors());
38
- }
39
-
40
- return config;
41
- }
42
-
43
- /**
44
- * Find the wrangler.toml file by searching up the file-system
45
- * from the current working directory.
46
- */
47
- export function findWranglerToml(
48
- referencePath: string = process.cwd()
49
- ): string | undefined {
50
- const configPath = findUpSync("wrangler.toml", { cwd: referencePath });
51
- return configPath;
52
- }