wrangler 0.0.0-e7a0cd5b ā 0.0.0-e87ad068
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.
- package/README.md +3 -3
- package/bin/wrangler.js +30 -10
- package/miniflare-dist/index.mjs +254 -128
- package/package.json +27 -19
- package/src/__tests__/api-dev.test.ts +65 -36
- package/src/__tests__/api-devregistry.test.ts +121 -0
- package/src/__tests__/api.test.ts +27 -5
- package/src/__tests__/configuration.test.ts +797 -98
- package/src/__tests__/constellation.test.ts +371 -0
- package/src/__tests__/d1/d1.test.ts +82 -0
- package/src/__tests__/d1/execute.test.ts +66 -0
- package/src/__tests__/d1/migrate.test.ts +257 -0
- package/src/__tests__/d1/splitter.test.ts +255 -0
- package/src/__tests__/delete.test.ts +91 -49
- package/src/__tests__/deployments.test.ts +330 -56
- package/src/__tests__/dev.test.tsx +198 -90
- package/src/__tests__/generate.test.ts +12 -10
- package/src/__tests__/guess-worker-format.test.ts +35 -0
- package/src/__tests__/helpers/end-event-loop.ts +6 -0
- package/src/__tests__/helpers/mock-auth-domain.ts +20 -0
- package/src/__tests__/helpers/mock-console.ts +6 -0
- package/src/__tests__/helpers/mock-dialogs.ts +71 -85
- package/src/__tests__/helpers/mock-get-pages-upload-token.ts +25 -0
- package/src/__tests__/helpers/mock-get-zone-from-host.ts +8 -5
- package/src/__tests__/helpers/mock-known-routes.ts +7 -2
- package/src/__tests__/helpers/mock-kv.ts +29 -16
- package/src/__tests__/helpers/mock-oauth-flow.ts +103 -92
- package/src/__tests__/helpers/mock-process.ts +8 -13
- package/src/__tests__/helpers/mock-set-timeout.ts +16 -0
- package/src/__tests__/helpers/msw/blob-worker.cjs +19 -0
- package/src/__tests__/helpers/msw/handlers/deployments.ts +128 -27
- package/src/__tests__/helpers/msw/handlers/namespaces.ts +18 -41
- package/src/__tests__/helpers/msw/handlers/oauth.ts +13 -18
- package/src/__tests__/helpers/msw/handlers/r2.ts +14 -34
- package/src/__tests__/helpers/msw/handlers/script.ts +9 -28
- package/src/__tests__/helpers/msw/handlers/user.ts +13 -24
- package/src/__tests__/helpers/msw/handlers/zones.ts +6 -8
- package/src/__tests__/helpers/msw/index.ts +32 -1
- package/src/__tests__/helpers/msw/read-file-sync.js +61 -0
- package/src/__tests__/helpers/string-dynamic-values-matcher.ts +28 -0
- package/src/__tests__/helpers/worker-scripts/parent-worker.js +4 -1
- package/src/__tests__/index.test.ts +92 -72
- package/src/__tests__/init.test.ts +1033 -631
- package/src/__tests__/jest.setup.ts +19 -42
- package/src/__tests__/kv.test.ts +355 -231
- package/src/__tests__/logger.test.ts +68 -2
- package/src/__tests__/logout.test.ts +47 -0
- package/src/__tests__/metrics.test.ts +94 -51
- package/src/__tests__/middleware.scheduled.test.ts +42 -32
- package/src/__tests__/middleware.test.ts +212 -122
- package/src/__tests__/mtls-certificates.test.ts +589 -0
- package/src/__tests__/pages/deployment-list.test.ts +80 -0
- package/src/__tests__/pages/functions-build.test.ts +529 -0
- package/src/__tests__/pages/pages.test.ts +81 -0
- package/src/__tests__/pages/project-create.test.ts +63 -0
- package/src/__tests__/pages/project-list.test.ts +110 -0
- package/src/__tests__/pages/project-upload.test.ts +500 -0
- package/src/__tests__/pages/publish.test.ts +2864 -0
- package/src/__tests__/pages-deployment-tail.test.ts +957 -0
- package/src/__tests__/parse.test.ts +106 -0
- package/src/__tests__/publish.test.ts +2227 -1005
- package/src/__tests__/pubsub.test.ts +226 -100
- package/src/__tests__/queues.test.ts +238 -77
- package/src/__tests__/r2.test.ts +55 -57
- package/src/__tests__/secret.test.ts +179 -130
- package/src/__tests__/tail.test.ts +313 -113
- package/src/__tests__/test-old-node-version.js +3 -3
- package/src/__tests__/traverse-module-graph.test.ts +220 -0
- package/src/__tests__/tsconfig-sanity.ts +12 -0
- package/src/__tests__/tsconfig.json +8 -0
- package/src/__tests__/tsconfig.tsbuildinfo +1 -0
- package/src/__tests__/type-generation.test.ts +43 -26
- package/src/__tests__/unstableDev.test.ts +61 -0
- package/src/__tests__/user.test.ts +35 -72
- package/src/__tests__/whoami.test.tsx +8 -114
- package/src/__tests__/worker-namespace.test.ts +83 -69
- package/src/api/dev.ts +180 -60
- package/src/api/index.ts +10 -1
- package/src/api/mtls-certificate.ts +148 -0
- package/src/api/pages/create-worker-bundle-contents.ts +80 -0
- package/src/api/pages/index.ts +5 -0
- package/src/api/pages/publish.tsx +371 -0
- package/src/bundle.ts +315 -148
- package/src/cfetch/index.ts +0 -2
- package/src/cfetch/internal.ts +33 -33
- package/src/cli.ts +4 -4
- package/src/config/config.ts +14 -7
- package/src/config/environment.ts +120 -24
- package/src/config/index.ts +117 -35
- package/src/config/validation-helpers.ts +1 -1
- package/src/config/validation.ts +430 -19
- package/src/constellation/createProject.tsx +51 -0
- package/src/constellation/deleteProject.ts +51 -0
- package/src/constellation/deleteProjectModel.ts +76 -0
- package/src/constellation/index.ts +75 -0
- package/src/constellation/listCatalog.tsx +35 -0
- package/src/constellation/listModel.tsx +49 -0
- package/src/constellation/listProject.tsx +28 -0
- package/src/constellation/listRuntime.tsx +28 -0
- package/src/constellation/options.ts +17 -0
- package/src/constellation/types.ts +17 -0
- package/src/constellation/uploadModel.tsx +84 -0
- package/src/constellation/utils.ts +90 -0
- package/src/create-worker-preview.ts +19 -8
- package/src/create-worker-upload-form.ts +81 -18
- package/src/d1/backups.tsx +47 -46
- package/src/d1/constants.ts +5 -0
- package/src/d1/create.tsx +85 -37
- package/src/d1/{delete.tsx ā delete.ts} +12 -15
- package/src/d1/execute.tsx +228 -156
- package/src/d1/index.ts +31 -7
- package/src/d1/list.tsx +27 -13
- package/src/d1/migrations/apply.tsx +235 -0
- package/src/d1/migrations/create.tsx +79 -0
- package/src/d1/migrations/helpers.ts +171 -0
- package/src/d1/migrations/index.ts +3 -0
- package/src/d1/migrations/list.tsx +95 -0
- package/src/d1/migrations/options.ts +23 -0
- package/src/d1/options.ts +12 -2
- package/src/d1/splitter.ts +161 -0
- package/src/d1/types.ts +32 -0
- package/src/d1/utils.ts +12 -2
- package/src/delete.ts +8 -16
- package/src/deployments.ts +340 -46
- package/src/deprecated/index.ts +8 -302
- package/src/dev/dev.tsx +66 -46
- package/src/dev/local.tsx +339 -104
- package/src/dev/remote.tsx +36 -3
- package/src/dev/start-server.ts +146 -101
- package/src/dev/use-esbuild.ts +82 -56
- package/src/dev/validate-dev-props.ts +9 -0
- package/src/{dev-registry.tsx ā dev-registry.ts} +13 -1
- package/src/dev.tsx +202 -125
- package/src/dialogs.ts +136 -0
- package/src/dispatch-namespace.ts +21 -17
- package/src/docs/helpers.ts +50 -0
- package/src/docs/index.ts +54 -0
- package/src/entry.ts +26 -11
- package/src/environment-variables/factory.ts +89 -0
- package/src/environment-variables/misc-variables.ts +30 -0
- package/src/generate/index.ts +303 -0
- package/src/git-client.ts +15 -4
- package/src/{index.tsx ā index.ts} +148 -63
- package/src/init.ts +301 -197
- package/src/inspect.ts +122 -6
- package/src/jest.d.ts +4 -0
- package/src/kv/helpers.ts +7 -4
- package/src/kv/index.ts +15 -17
- package/src/logger.ts +36 -5
- package/src/metrics/metrics-config.ts +3 -3
- package/src/metrics/send-event.ts +6 -1
- package/src/miniflare-cli/assets.ts +64 -28
- package/src/miniflare-cli/index.ts +6 -9
- package/src/miniflare-cli/tsconfig.json +9 -0
- package/src/miniflare-cli/tsconfig.tsbuildinfo +1 -0
- package/src/miniflare-cli/types.ts +11 -0
- package/src/module-collection.ts +92 -26
- package/src/mtls-certificate/cli.ts +155 -0
- package/src/pages/build.ts +423 -0
- package/src/pages/buildFunctions.ts +140 -0
- package/src/pages/deployment-tails.ts +281 -0
- package/src/pages/deployments.tsx +11 -33
- package/src/pages/{dev.tsx ā dev.ts} +192 -126
- package/src/pages/errors.ts +1 -0
- package/src/pages/functions/buildPlugin.ts +73 -69
- package/src/pages/functions/buildWorker.ts +342 -117
- package/src/pages/functions/tsconfig.json +8 -0
- package/src/pages/functions/tsconfig.tsbuildinfo +1 -0
- package/src/pages/{functions.tsx ā functions.ts} +8 -4
- package/src/pages/{index.tsx ā index.ts} +11 -3
- package/src/pages/projects.tsx +12 -22
- package/src/pages/prompt-select-project.tsx +31 -0
- package/src/pages/publish.tsx +45 -214
- package/src/pages/types.ts +6 -9
- package/src/pages/upload.tsx +58 -14
- package/src/pages/utils.ts +14 -3
- package/src/parse.ts +23 -1
- package/src/paths.ts +1 -1
- package/src/proxy.ts +5 -0
- package/src/publish/index.ts +20 -16
- package/src/publish/publish.ts +81 -48
- package/src/pubsub/{pubsub-commands.tsx ā pubsub-commands.ts} +19 -20
- package/src/queues/cli/commands/consumer/add.ts +24 -24
- package/src/queues/cli/commands/consumer/index.ts +3 -6
- package/src/queues/cli/commands/consumer/remove.ts +11 -18
- package/src/queues/cli/commands/create.ts +8 -8
- package/src/queues/cli/commands/delete.ts +8 -8
- package/src/queues/cli/commands/index.ts +6 -4
- package/src/queues/cli/commands/list.ts +8 -8
- package/src/queues/client.ts +1 -0
- package/src/queues/utils.ts +18 -0
- package/src/r2/constants.ts +4 -0
- package/src/r2/helpers.ts +1 -0
- package/src/r2/index.ts +40 -28
- package/src/secret/index.ts +18 -17
- package/src/{sites.tsx ā sites.ts} +165 -53
- package/src/tail/createTail.ts +103 -3
- package/src/tail/filters.ts +1 -1
- package/src/tail/index.ts +8 -11
- package/src/tail/printing.ts +27 -0
- package/src/traverse-module-graph.ts +54 -0
- package/src/tsconfig-sanity.ts +16 -0
- package/src/type-generation.ts +85 -57
- package/src/user/access.ts +0 -1
- package/src/user/auth-variables.ts +113 -0
- package/src/user/choose-account.tsx +1 -31
- package/src/user/index.ts +0 -1
- package/src/user/{user.tsx ā user.ts} +124 -82
- package/src/utils/render.ts +93 -0
- package/src/{whoami.tsx ā whoami.ts} +37 -71
- package/src/worker.ts +61 -3
- package/src/yargs-types.ts +22 -5
- package/templates/__tests__/tsconfig-sanity.ts +12 -0
- package/templates/__tests__/tsconfig.json +8 -0
- package/templates/__tests__/tsconfig.tsbuildinfo +1 -0
- package/templates/checked-fetch.js +9 -3
- package/templates/d1-beta-facade.js +95 -25
- package/templates/facade.d.ts +14 -0
- package/templates/first-party-worker-module-facade.ts +4 -3
- package/templates/format-dev-errors.ts +8 -6
- package/templates/gitignore +1 -0
- package/templates/init-tests/test-jest-new-worker.js +3 -5
- package/templates/init-tests/test-vitest-new-worker.js +3 -5
- package/templates/init-tests/test-vitest-new-worker.ts +25 -0
- package/templates/middleware/loader-modules.ts +2 -2
- package/templates/middleware/loader-sw.ts +51 -31
- package/templates/middleware/middleware-miniflare3-json-error.ts +32 -0
- package/templates/new-worker.ts +3 -0
- package/templates/pages-dev-pipeline.ts +4 -1
- package/templates/pages-dev-util.ts +4 -1
- package/templates/pages-shim.ts +4 -1
- package/templates/pages-template-plugin.ts +19 -10
- package/templates/serve-static-assets.ts +17 -14
- package/templates/service-bindings-module-facade.js +1 -0
- package/templates/tsconfig-sanity.ts +11 -0
- package/templates/tsconfig.init.json +105 -0
- package/templates/tsconfig.json +5 -103
- package/templates/tsconfig.tsbuildinfo +1 -0
- package/wrangler-dist/cli.d.ts +902 -77
- package/wrangler-dist/cli.js +131685 -140615
- package/wrangler-dist/wasm-sync.wasm +0 -0
- package/src/__tests__/api-devregistry.test.js +0 -57
- package/src/__tests__/d1.test.ts +0 -72
- package/src/__tests__/dialogs.test.tsx +0 -40
- package/src/__tests__/helpers/mock-cfetch.ts +0 -333
- package/src/__tests__/pages.test.ts +0 -2223
- package/src/d1/types.tsx +0 -14
- package/src/dialogs.tsx +0 -163
- package/src/environment-variables.ts +0 -50
- package/src/pages/build.tsx +0 -238
- package/src/user/env-vars.ts +0 -46
- package/templates/experimental-local-cache-stubs.js +0 -27
- /package/src/{bundle-reporter.tsx ā bundle-reporter.ts} +0 -0
- /package/src/dev/{get-local-persistence-path.tsx ā get-local-persistence-path.ts} +0 -0
- /package/src/pages/{hash.tsx ā hash.ts} +0 -0
package/src/dev.tsx
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import path from "node:path";
|
|
2
|
+
import chalk from "chalk";
|
|
2
3
|
import { watch } from "chokidar";
|
|
3
4
|
import getPort from "get-port";
|
|
4
5
|
import { render } from "ink";
|
|
@@ -13,12 +14,11 @@ import { getEntry } from "./entry";
|
|
|
13
14
|
import { logger } from "./logger";
|
|
14
15
|
import * as metrics from "./metrics";
|
|
15
16
|
import { getAssetPaths, getSiteAssetPaths } from "./sites";
|
|
16
|
-
import { getAccountFromCache } from "./user";
|
|
17
|
+
import { getAccountFromCache, loginOrRefreshIfRequired } from "./user";
|
|
17
18
|
import { collectKeyValues } from "./utils/collectKeyValues";
|
|
18
19
|
import { identifyD1BindingsAsBeta } from "./worker";
|
|
19
20
|
import { getHostFromRoute, getZoneForRoute, getZoneIdFromHost } from "./zones";
|
|
20
21
|
import {
|
|
21
|
-
type ConfigPath,
|
|
22
22
|
DEFAULT_INSPECTOR_PORT,
|
|
23
23
|
DEFAULT_LOCAL_PORT,
|
|
24
24
|
getDevCompatibilityDate,
|
|
@@ -28,59 +28,16 @@ import {
|
|
|
28
28
|
printWranglerBanner,
|
|
29
29
|
} from "./index";
|
|
30
30
|
import type { Config, Environment } from "./config";
|
|
31
|
-
import type { Route } from "./config/environment";
|
|
32
|
-
import type {
|
|
33
|
-
import type {
|
|
34
|
-
import type {
|
|
35
|
-
import type {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
bundle?: boolean;
|
|
42
|
-
build?: boolean;
|
|
43
|
-
format?: string;
|
|
44
|
-
env?: string;
|
|
45
|
-
"compatibility-date"?: string;
|
|
46
|
-
"compatibility-flags"?: string[];
|
|
47
|
-
latest?: boolean;
|
|
48
|
-
ip?: string;
|
|
49
|
-
inspect?: boolean;
|
|
50
|
-
port?: number;
|
|
51
|
-
"inspector-port"?: number;
|
|
52
|
-
routes?: string[];
|
|
53
|
-
host?: string;
|
|
54
|
-
"local-protocol"?: "http" | "https";
|
|
55
|
-
"local-upstream"?: string | undefined;
|
|
56
|
-
"experimental-public"?: string;
|
|
57
|
-
public?: string;
|
|
58
|
-
assets?: string;
|
|
59
|
-
site?: string;
|
|
60
|
-
"site-include"?: string[];
|
|
61
|
-
"site-exclude"?: string[];
|
|
62
|
-
"upstream-protocol"?: "http" | "https";
|
|
63
|
-
"jsx-factory"?: string;
|
|
64
|
-
"jsx-fragment"?: string;
|
|
65
|
-
tsconfig?: string;
|
|
66
|
-
local?: boolean;
|
|
67
|
-
"experimental-local"?: boolean;
|
|
68
|
-
minify?: boolean;
|
|
69
|
-
var?: string[];
|
|
70
|
-
define?: string[];
|
|
71
|
-
"node-compat"?: boolean;
|
|
72
|
-
"experimental-enable-local-persistence"?: boolean;
|
|
73
|
-
persist?: boolean;
|
|
74
|
-
"persist-to"?: string;
|
|
75
|
-
"live-reload"?: boolean;
|
|
76
|
-
onReady?: (ip: string, port: number) => void;
|
|
77
|
-
logLevel?: "none" | "info" | "error" | "log" | "warn" | "debug";
|
|
78
|
-
logPrefix?: string;
|
|
79
|
-
showInteractiveDevSession?: boolean;
|
|
80
|
-
"test-scheduled"?: boolean;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
export function devOptions(yargs: Argv<CommonYargsOptions>): Argv<DevArgs> {
|
|
31
|
+
import type { Route, Rule } from "./config/environment";
|
|
32
|
+
import type { LoggerLevel } from "./logger";
|
|
33
|
+
import type { EnablePagesAssetsServiceBindingOptions } from "./miniflare-cli/types";
|
|
34
|
+
import type { CfWorkerInit, CfModule } from "./worker";
|
|
35
|
+
import type {
|
|
36
|
+
CommonYargsArgv,
|
|
37
|
+
StrictYargsOptionsToInterface,
|
|
38
|
+
} from "./yargs-types";
|
|
39
|
+
|
|
40
|
+
export function devOptions(yargs: CommonYargsArgv) {
|
|
84
41
|
return (
|
|
85
42
|
yargs
|
|
86
43
|
.positional("script", {
|
|
@@ -175,6 +132,13 @@ export function devOptions(yargs: Argv<CommonYargsOptions>): Argv<DevArgs> {
|
|
|
175
132
|
type: "string",
|
|
176
133
|
requiresArg: true,
|
|
177
134
|
})
|
|
135
|
+
.option("public", {
|
|
136
|
+
describe: "(Deprecated) Static assets to be served",
|
|
137
|
+
type: "string",
|
|
138
|
+
requiresArg: true,
|
|
139
|
+
deprecated: true,
|
|
140
|
+
hidden: true,
|
|
141
|
+
})
|
|
178
142
|
.option("site", {
|
|
179
143
|
describe: "Root folder of static assets for Workers Sites",
|
|
180
144
|
type: "string",
|
|
@@ -237,11 +201,25 @@ export function devOptions(yargs: Argv<CommonYargsOptions>): Argv<DevArgs> {
|
|
|
237
201
|
type: "boolean",
|
|
238
202
|
default: false,
|
|
239
203
|
})
|
|
204
|
+
.option("experimental-local-remote-kv", {
|
|
205
|
+
describe:
|
|
206
|
+
"Read/write KV data from/to real namespaces on the Cloudflare network",
|
|
207
|
+
type: "boolean",
|
|
208
|
+
default: false,
|
|
209
|
+
})
|
|
240
210
|
.check((argv) => {
|
|
241
211
|
if (argv.local && argv["experimental-local"]) {
|
|
242
212
|
throw new Error(
|
|
243
213
|
"--local and --experimental-local are mutually exclusive. " +
|
|
244
|
-
"Please
|
|
214
|
+
"Please enable one or the other."
|
|
215
|
+
);
|
|
216
|
+
}
|
|
217
|
+
if (
|
|
218
|
+
argv["experimental-local-remote-kv"] &&
|
|
219
|
+
!argv["experimental-local"]
|
|
220
|
+
) {
|
|
221
|
+
throw new Error(
|
|
222
|
+
"--experimental-local-remote-kv requires --experimental-local to be enabled."
|
|
245
223
|
);
|
|
246
224
|
}
|
|
247
225
|
return true;
|
|
@@ -251,7 +229,7 @@ export function devOptions(yargs: Argv<CommonYargsOptions>): Argv<DevArgs> {
|
|
|
251
229
|
type: "boolean",
|
|
252
230
|
})
|
|
253
231
|
.option("node-compat", {
|
|
254
|
-
describe: "Enable
|
|
232
|
+
describe: "Enable Node.js compatibility",
|
|
255
233
|
type: "boolean",
|
|
256
234
|
})
|
|
257
235
|
.option("experimental-enable-local-persistence", {
|
|
@@ -273,11 +251,20 @@ export function devOptions(yargs: Argv<CommonYargsOptions>): Argv<DevArgs> {
|
|
|
273
251
|
requiresArg: true,
|
|
274
252
|
})
|
|
275
253
|
.option("live-reload", {
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
// describe: "Auto reload HTML pages when change is detected",
|
|
254
|
+
describe:
|
|
255
|
+
"Auto reload HTML pages when change is detected in local mode",
|
|
279
256
|
type: "boolean",
|
|
280
257
|
})
|
|
258
|
+
.check((argv) => {
|
|
259
|
+
const local = argv["local"] || argv["experimental-local"];
|
|
260
|
+
if (argv["live-reload"] && !local) {
|
|
261
|
+
throw new Error(
|
|
262
|
+
"--live-reload is only supported in local mode. " +
|
|
263
|
+
"Please enable either --local or --experimental-local."
|
|
264
|
+
);
|
|
265
|
+
}
|
|
266
|
+
return true;
|
|
267
|
+
})
|
|
281
268
|
.option("inspect", {
|
|
282
269
|
describe: "Enable dev tools",
|
|
283
270
|
type: "boolean",
|
|
@@ -297,12 +284,24 @@ export function devOptions(yargs: Argv<CommonYargsOptions>): Argv<DevArgs> {
|
|
|
297
284
|
.option("log-level", {
|
|
298
285
|
choices: ["debug", "info", "log", "warn", "error", "none"] as const,
|
|
299
286
|
describe: "Specify logging level",
|
|
300
|
-
|
|
287
|
+
// Yargs requires this to type log-level properly
|
|
288
|
+
default: "log" as LoggerLevel,
|
|
301
289
|
})
|
|
302
290
|
);
|
|
303
291
|
}
|
|
304
292
|
|
|
305
|
-
|
|
293
|
+
type DevArguments = StrictYargsOptionsToInterface<typeof devOptions>;
|
|
294
|
+
|
|
295
|
+
export async function devHandler(args: DevArguments) {
|
|
296
|
+
if (!(args.local || args.experimentalLocal)) {
|
|
297
|
+
const isLoggedIn = await loginOrRefreshIfRequired();
|
|
298
|
+
if (!isLoggedIn) {
|
|
299
|
+
throw new Error(
|
|
300
|
+
"You must be logged in to use wrangler dev in remote mode. Try logging in, or run wrangler dev --local."
|
|
301
|
+
);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
|
|
306
305
|
let watcher;
|
|
307
306
|
try {
|
|
308
307
|
const devInstance = await startDev(args);
|
|
@@ -335,14 +334,22 @@ export type AdditionalDevProps = {
|
|
|
335
334
|
preview_bucket_name?: string;
|
|
336
335
|
}[];
|
|
337
336
|
d1Databases?: Environment["d1_databases"];
|
|
337
|
+
processEntrypoint?: boolean;
|
|
338
|
+
additionalModules?: CfModule[];
|
|
339
|
+
moduleRoot?: string;
|
|
340
|
+
rules?: Rule[];
|
|
341
|
+
constellation?: Environment["constellation"];
|
|
338
342
|
};
|
|
339
343
|
|
|
340
|
-
type StartDevOptions =
|
|
344
|
+
type StartDevOptions = DevArguments &
|
|
341
345
|
// These options can be passed in directly when called with the `wrangler.dev()` API.
|
|
342
346
|
// They aren't exposed as CLI arguments.
|
|
343
347
|
AdditionalDevProps & {
|
|
344
348
|
forceLocal?: boolean;
|
|
349
|
+
disableDevRegistry?: boolean;
|
|
345
350
|
enablePagesAssetsServiceBinding?: EnablePagesAssetsServiceBindingOptions;
|
|
351
|
+
onReady?: (ip: string, port: number) => void;
|
|
352
|
+
showInteractiveDevSession?: boolean;
|
|
346
353
|
};
|
|
347
354
|
|
|
348
355
|
export async function startDev(args: StartDevOptions) {
|
|
@@ -354,10 +361,19 @@ export async function startDev(args: StartDevOptions) {
|
|
|
354
361
|
}
|
|
355
362
|
await printWranglerBanner();
|
|
356
363
|
|
|
364
|
+
if (args.local && process.platform !== "win32") {
|
|
365
|
+
logger.info(
|
|
366
|
+
chalk.magenta(
|
|
367
|
+
`Want to try out the next version of local mode using the open-source Workers runtime?\nSwitch out --local for ${chalk.bold(
|
|
368
|
+
"--experimental-local"
|
|
369
|
+
)} and let us know what you think at https://discord.gg/cloudflaredev !`
|
|
370
|
+
)
|
|
371
|
+
);
|
|
372
|
+
}
|
|
373
|
+
|
|
357
374
|
const configPath =
|
|
358
|
-
|
|
359
|
-
(
|
|
360
|
-
findWranglerToml(path.dirname(args.script))) as ConfigPath);
|
|
375
|
+
args.config ||
|
|
376
|
+
(args.script && findWranglerToml(path.dirname(args.script)));
|
|
361
377
|
let config = readConfig(configPath, args);
|
|
362
378
|
|
|
363
379
|
if (config.configPath) {
|
|
@@ -376,7 +392,8 @@ export async function startDev(args: StartDevOptions) {
|
|
|
376
392
|
|
|
377
393
|
const {
|
|
378
394
|
entry,
|
|
379
|
-
|
|
395
|
+
legacyNodeCompat,
|
|
396
|
+
nodejsCompat,
|
|
380
397
|
upstreamProtocol,
|
|
381
398
|
zoneId,
|
|
382
399
|
host,
|
|
@@ -385,6 +402,8 @@ export async function startDev(args: StartDevOptions) {
|
|
|
385
402
|
getInspectorPort,
|
|
386
403
|
cliDefines,
|
|
387
404
|
localPersistencePath,
|
|
405
|
+
processEntrypoint,
|
|
406
|
+
additionalModules,
|
|
388
407
|
} = await validateDevServerSettings(args, config);
|
|
389
408
|
|
|
390
409
|
await metrics.sendMetricsEvent(
|
|
@@ -398,7 +417,7 @@ export async function startDev(args: StartDevOptions) {
|
|
|
398
417
|
|
|
399
418
|
// eslint-disable-next-line no-inner-declarations
|
|
400
419
|
async function getDevReactElement(configParam: Config) {
|
|
401
|
-
const { assetPaths, bindings } =
|
|
420
|
+
const { assetPaths, bindings } = getBindingsAndAssetPaths(
|
|
402
421
|
args,
|
|
403
422
|
configParam
|
|
404
423
|
);
|
|
@@ -412,31 +431,36 @@ export async function startDev(args: StartDevOptions) {
|
|
|
412
431
|
zone={zoneId}
|
|
413
432
|
host={host}
|
|
414
433
|
routes={routes}
|
|
415
|
-
|
|
434
|
+
processEntrypoint={processEntrypoint}
|
|
435
|
+
additionalModules={additionalModules}
|
|
436
|
+
rules={args.rules ?? getRules(configParam)}
|
|
416
437
|
legacyEnv={isLegacyEnv(configParam)}
|
|
417
438
|
minify={args.minify ?? configParam.minify}
|
|
418
|
-
|
|
439
|
+
legacyNodeCompat={legacyNodeCompat}
|
|
440
|
+
nodejsCompat={nodejsCompat}
|
|
419
441
|
build={configParam.build || {}}
|
|
420
442
|
define={{ ...configParam.define, ...cliDefines }}
|
|
421
443
|
initialMode={
|
|
422
444
|
args.local || args.experimentalLocal ? "local" : "remote"
|
|
423
445
|
}
|
|
424
|
-
jsxFactory={args
|
|
425
|
-
jsxFragment={args
|
|
446
|
+
jsxFactory={args.jsxFactory || configParam.jsx_factory}
|
|
447
|
+
jsxFragment={args.jsxFragment || configParam.jsx_fragment}
|
|
426
448
|
tsconfig={args.tsconfig ?? configParam.tsconfig}
|
|
427
449
|
upstreamProtocol={upstreamProtocol}
|
|
428
450
|
localProtocol={args.localProtocol || configParam.dev.local_protocol}
|
|
429
|
-
localUpstream={args
|
|
451
|
+
localUpstream={args.localUpstream ?? host}
|
|
430
452
|
localPersistencePath={localPersistencePath}
|
|
431
453
|
liveReload={args.liveReload || false}
|
|
432
454
|
accountId={configParam.account_id || getAccountFromCache()?.id}
|
|
433
455
|
assetPaths={assetPaths}
|
|
434
456
|
assetsConfig={configParam.assets}
|
|
435
|
-
|
|
436
|
-
|
|
457
|
+
initialPort={
|
|
458
|
+
args.port ?? configParam.dev.port ?? (await getLocalPort())
|
|
459
|
+
}
|
|
460
|
+
initialIp={args.ip || configParam.dev.ip}
|
|
437
461
|
inspectorPort={
|
|
438
|
-
args.inspectorPort
|
|
439
|
-
configParam.dev.inspector_port
|
|
462
|
+
args.inspectorPort ??
|
|
463
|
+
configParam.dev.inspector_port ??
|
|
440
464
|
(await getInspectorPort())
|
|
441
465
|
}
|
|
442
466
|
isWorkersSite={Boolean(args.site || configParam.site)}
|
|
@@ -451,7 +475,6 @@ export async function startDev(args: StartDevOptions) {
|
|
|
451
475
|
bindings={bindings}
|
|
452
476
|
crons={configParam.triggers.crons}
|
|
453
477
|
queueConsumers={configParam.queues.consumers}
|
|
454
|
-
logPrefix={args.logPrefix}
|
|
455
478
|
onReady={args.onReady}
|
|
456
479
|
inspect={args.inspect ?? true}
|
|
457
480
|
showInteractiveDevSession={args.showInteractiveDevSession}
|
|
@@ -459,17 +482,35 @@ export async function startDev(args: StartDevOptions) {
|
|
|
459
482
|
enablePagesAssetsServiceBinding={args.enablePagesAssetsServiceBinding}
|
|
460
483
|
firstPartyWorker={configParam.first_party_worker}
|
|
461
484
|
sendMetrics={configParam.send_metrics}
|
|
462
|
-
testScheduled={args
|
|
485
|
+
testScheduled={args.testScheduled}
|
|
463
486
|
experimentalLocal={args.experimentalLocal}
|
|
487
|
+
experimentalLocalRemoteKv={args.experimentalLocalRemoteKv}
|
|
464
488
|
/>
|
|
465
489
|
);
|
|
466
490
|
}
|
|
467
491
|
const devReactElement = render(await getDevReactElement(config));
|
|
492
|
+
|
|
493
|
+
// In the bootstrapper script `bin/wrangler.js`, we open an IPC channel, so
|
|
494
|
+
// IPC messages from this process are propagated through the bootstrapper.
|
|
495
|
+
// Normally, Node's SIGINT handler would close this for us, but interactive
|
|
496
|
+
// mode enables raw mode on stdin which disables the built-in handler. The
|
|
497
|
+
// following line disconnects from the IPC channel when we press `x` or
|
|
498
|
+
// CTRL-C in interactive mode, ensuring no open handles, and allowing for a
|
|
499
|
+
// clean exit. Note, if we called `stop()` using the dev API, we don't want
|
|
500
|
+
// to disconnect here, as the user may still need IPC. We also don't want
|
|
501
|
+
// to disconnect if this file was imported in Jest (not the case with E2E
|
|
502
|
+
// tests), as that would stop communication with the test runner.
|
|
503
|
+
let apiStopped = false;
|
|
504
|
+
void devReactElement.waitUntilExit().then(() => {
|
|
505
|
+
if (!apiStopped && typeof jest === "undefined") process.disconnect?.();
|
|
506
|
+
});
|
|
507
|
+
|
|
468
508
|
rerender = devReactElement.rerender;
|
|
469
509
|
return {
|
|
470
510
|
devReactElement,
|
|
471
511
|
watcher,
|
|
472
512
|
stop: async () => {
|
|
513
|
+
apiStopped = true;
|
|
473
514
|
devReactElement.unmount();
|
|
474
515
|
await watcher?.close();
|
|
475
516
|
},
|
|
@@ -486,14 +527,13 @@ export async function startApiDev(args: StartDevOptions) {
|
|
|
486
527
|
await printWranglerBanner();
|
|
487
528
|
|
|
488
529
|
const configPath =
|
|
489
|
-
|
|
490
|
-
((args.script &&
|
|
491
|
-
findWranglerToml(path.dirname(args.script))) as ConfigPath);
|
|
530
|
+
args.config || (args.script && findWranglerToml(path.dirname(args.script)));
|
|
492
531
|
const config = readConfig(configPath, args);
|
|
493
532
|
|
|
494
533
|
const {
|
|
495
534
|
entry,
|
|
496
|
-
|
|
535
|
+
legacyNodeCompat,
|
|
536
|
+
nodejsCompat,
|
|
497
537
|
upstreamProtocol,
|
|
498
538
|
zoneId,
|
|
499
539
|
host,
|
|
@@ -502,6 +542,8 @@ export async function startApiDev(args: StartDevOptions) {
|
|
|
502
542
|
getInspectorPort,
|
|
503
543
|
cliDefines,
|
|
504
544
|
localPersistencePath,
|
|
545
|
+
processEntrypoint,
|
|
546
|
+
additionalModules,
|
|
505
547
|
} = await validateDevServerSettings(args, config);
|
|
506
548
|
|
|
507
549
|
await metrics.sendMetricsEvent(
|
|
@@ -512,7 +554,7 @@ export async function startApiDev(args: StartDevOptions) {
|
|
|
512
554
|
|
|
513
555
|
// eslint-disable-next-line no-inner-declarations
|
|
514
556
|
async function getDevServer(configParam: Config) {
|
|
515
|
-
const { assetPaths, bindings } =
|
|
557
|
+
const { assetPaths, bindings } = getBindingsAndAssetPaths(
|
|
516
558
|
args,
|
|
517
559
|
configParam
|
|
518
560
|
);
|
|
@@ -529,49 +571,46 @@ export async function startApiDev(args: StartDevOptions) {
|
|
|
529
571
|
zone: zoneId,
|
|
530
572
|
host: host,
|
|
531
573
|
routes: routes,
|
|
532
|
-
|
|
574
|
+
processEntrypoint,
|
|
575
|
+
additionalModules,
|
|
576
|
+
rules: args.rules ?? getRules(configParam),
|
|
533
577
|
legacyEnv: isLegacyEnv(configParam),
|
|
534
578
|
minify: args.minify ?? configParam.minify,
|
|
535
|
-
|
|
579
|
+
legacyNodeCompat,
|
|
580
|
+
nodejsCompat,
|
|
536
581
|
build: configParam.build || {},
|
|
537
582
|
define: { ...config.define, ...cliDefines },
|
|
538
583
|
initialMode: args.local ? "local" : "remote",
|
|
539
|
-
jsxFactory: args
|
|
540
|
-
jsxFragment: args
|
|
584
|
+
jsxFactory: args.jsxFactory ?? configParam.jsx_factory,
|
|
585
|
+
jsxFragment: args.jsxFragment ?? configParam.jsx_fragment,
|
|
541
586
|
tsconfig: args.tsconfig ?? configParam.tsconfig,
|
|
542
587
|
upstreamProtocol: upstreamProtocol,
|
|
543
|
-
localProtocol: args.localProtocol
|
|
544
|
-
localUpstream: args
|
|
588
|
+
localProtocol: args.localProtocol ?? configParam.dev.local_protocol,
|
|
589
|
+
localUpstream: args.localUpstream ?? host,
|
|
545
590
|
localPersistencePath,
|
|
546
|
-
liveReload: args.liveReload
|
|
547
|
-
accountId: configParam.account_id
|
|
591
|
+
liveReload: args.liveReload ?? false,
|
|
592
|
+
accountId: configParam.account_id ?? getAccountFromCache()?.id,
|
|
548
593
|
assetPaths: assetPaths,
|
|
549
594
|
assetsConfig: configParam.assets,
|
|
550
595
|
//port can be 0, which means to use a random port
|
|
551
|
-
port
|
|
552
|
-
|
|
553
|
-
? args.port
|
|
554
|
-
: args.port || configParam.dev.port || (await getLocalPort()),
|
|
555
|
-
ip: args.ip || configParam.dev.ip,
|
|
596
|
+
initialPort: args.port ?? configParam.dev.port ?? (await getLocalPort()),
|
|
597
|
+
initialIp: args.ip ?? configParam.dev.ip,
|
|
556
598
|
inspectorPort:
|
|
557
|
-
args
|
|
558
|
-
configParam.dev.inspector_port
|
|
599
|
+
args.inspectorPort ??
|
|
600
|
+
configParam.dev.inspector_port ??
|
|
559
601
|
(await getInspectorPort()),
|
|
560
602
|
isWorkersSite: Boolean(args.site || configParam.site),
|
|
561
603
|
compatibilityDate: getDevCompatibilityDate(
|
|
562
604
|
config,
|
|
563
605
|
// Only `compatibilityDate` will be set when using `unstable_dev`
|
|
564
|
-
args
|
|
606
|
+
args.compatibilityDate
|
|
565
607
|
),
|
|
566
608
|
compatibilityFlags:
|
|
567
|
-
args
|
|
568
|
-
args.compatibilityFlags ??
|
|
569
|
-
configParam.compatibility_flags,
|
|
609
|
+
args.compatibilityFlags ?? configParam.compatibility_flags,
|
|
570
610
|
usageModel: configParam.usage_model,
|
|
571
611
|
bindings: bindings,
|
|
572
612
|
crons: configParam.triggers.crons,
|
|
573
613
|
queueConsumers: configParam.queues.consumers,
|
|
574
|
-
logPrefix: args.logPrefix,
|
|
575
614
|
onReady: args.onReady,
|
|
576
615
|
inspect: args.inspect ?? true,
|
|
577
616
|
showInteractiveDevSession: args.showInteractiveDevSession,
|
|
@@ -582,6 +621,8 @@ export async function startApiDev(args: StartDevOptions) {
|
|
|
582
621
|
sendMetrics: configParam.send_metrics,
|
|
583
622
|
testScheduled: args.testScheduled,
|
|
584
623
|
experimentalLocal: args.experimentalLocal,
|
|
624
|
+
experimentalLocalRemoteKv: args.experimentalLocalRemoteKv,
|
|
625
|
+
disableDevRegistry: args.disableDevRegistry ?? false,
|
|
585
626
|
});
|
|
586
627
|
}
|
|
587
628
|
|
|
@@ -633,7 +674,7 @@ async function getZoneIdHostAndRoutes(args: StartDevOptions, config: Config) {
|
|
|
633
674
|
args.local = true;
|
|
634
675
|
}
|
|
635
676
|
|
|
636
|
-
if (!args.local) {
|
|
677
|
+
if (!args.local && !args.experimentalLocal) {
|
|
637
678
|
if (host) {
|
|
638
679
|
zoneId = await getZoneIdFromHost(host);
|
|
639
680
|
}
|
|
@@ -659,7 +700,7 @@ async function validateDevServerSettings(
|
|
|
659
700
|
config: Config
|
|
660
701
|
) {
|
|
661
702
|
const entry = await getEntry(
|
|
662
|
-
{ assets: args.assets, script: args.script },
|
|
703
|
+
{ assets: args.assets, script: args.script, moduleRoot: args.moduleRoot },
|
|
663
704
|
config,
|
|
664
705
|
"dev"
|
|
665
706
|
);
|
|
@@ -687,8 +728,7 @@ async function validateDevServerSettings(
|
|
|
687
728
|
"Passing --inspect is unnecessary, now you can always connect to devtools."
|
|
688
729
|
);
|
|
689
730
|
}
|
|
690
|
-
|
|
691
|
-
if (args["experimental-public"]) {
|
|
731
|
+
if (args.experimentalPublic) {
|
|
692
732
|
throw new Error(
|
|
693
733
|
"The --experimental-public field has been renamed to --assets"
|
|
694
734
|
);
|
|
@@ -698,7 +738,7 @@ async function validateDevServerSettings(
|
|
|
698
738
|
throw new Error("The --public field has been renamed to --assets");
|
|
699
739
|
}
|
|
700
740
|
|
|
701
|
-
if ((args.assets
|
|
741
|
+
if ((args.assets ?? config.assets) && (args.site ?? config.site)) {
|
|
702
742
|
throw new Error("Cannot use Assets and Workers Sites in the same Worker.");
|
|
703
743
|
}
|
|
704
744
|
|
|
@@ -708,18 +748,27 @@ async function validateDevServerSettings(
|
|
|
708
748
|
);
|
|
709
749
|
}
|
|
710
750
|
const upstreamProtocol =
|
|
711
|
-
args
|
|
751
|
+
args.upstreamProtocol ?? config.dev.upstream_protocol;
|
|
712
752
|
if (upstreamProtocol === "http") {
|
|
713
753
|
logger.warn(
|
|
714
754
|
"Setting upstream-protocol to http is not currently implemented.\n" +
|
|
715
755
|
"If this is required in your project, please add your use case to the following issue:\n" +
|
|
716
|
-
"https://github.com/cloudflare/
|
|
756
|
+
"https://github.com/cloudflare/workers-sdk/issues/583."
|
|
717
757
|
);
|
|
718
758
|
}
|
|
719
|
-
const
|
|
720
|
-
if (
|
|
759
|
+
const legacyNodeCompat = args.nodeCompat ?? config.node_compat;
|
|
760
|
+
if (legacyNodeCompat) {
|
|
721
761
|
logger.warn(
|
|
722
|
-
"Enabling
|
|
762
|
+
"Enabling Node.js compatibility mode for built-ins and globals. This is experimental and has serious tradeoffs. Please see https://github.com/ionic-team/rollup-plugin-node-polyfills/ for more details."
|
|
763
|
+
);
|
|
764
|
+
}
|
|
765
|
+
|
|
766
|
+
const compatibilityFlags =
|
|
767
|
+
args.compatibilityFlags ?? config.compatibility_flags;
|
|
768
|
+
const nodejsCompat = compatibilityFlags?.includes("nodejs_compat");
|
|
769
|
+
if (legacyNodeCompat && nodejsCompat) {
|
|
770
|
+
throw new Error(
|
|
771
|
+
"The `nodejs_compat` compatibility flag cannot be used in conjunction with the legacy `--node-compat` flag. If you want to use the Workers runtime Node.js compatibility features, please remove the `--node-compat` argument from your CLI command or `node_compat = true` from your config file."
|
|
723
772
|
);
|
|
724
773
|
}
|
|
725
774
|
|
|
@@ -742,7 +791,8 @@ async function validateDevServerSettings(
|
|
|
742
791
|
return {
|
|
743
792
|
entry,
|
|
744
793
|
upstreamProtocol,
|
|
745
|
-
|
|
794
|
+
legacyNodeCompat,
|
|
795
|
+
nodejsCompat,
|
|
746
796
|
getLocalPort,
|
|
747
797
|
getInspectorPort,
|
|
748
798
|
zoneId,
|
|
@@ -750,17 +800,16 @@ async function validateDevServerSettings(
|
|
|
750
800
|
routes,
|
|
751
801
|
cliDefines,
|
|
752
802
|
localPersistencePath,
|
|
803
|
+
processEntrypoint: !!args.processEntrypoint,
|
|
804
|
+
additionalModules: args.additionalModules ?? [],
|
|
753
805
|
};
|
|
754
806
|
}
|
|
755
807
|
|
|
756
|
-
|
|
757
|
-
args: StartDevOptions,
|
|
758
|
-
configParam: Config
|
|
759
|
-
) {
|
|
808
|
+
function getBindingsAndAssetPaths(args: StartDevOptions, configParam: Config) {
|
|
760
809
|
const cliVars = collectKeyValues(args.var);
|
|
761
810
|
|
|
762
811
|
// now log all available bindings into the terminal
|
|
763
|
-
const bindings =
|
|
812
|
+
const bindings = getBindings(configParam, args.env, args.local ?? false, {
|
|
764
813
|
kv: args.kv,
|
|
765
814
|
vars: { ...args.vars, ...cliVars },
|
|
766
815
|
durableObjects: args.durableObjects,
|
|
@@ -787,11 +836,12 @@ async function getBindingsAndAssetPaths(
|
|
|
787
836
|
return { assetPaths, bindings };
|
|
788
837
|
}
|
|
789
838
|
|
|
790
|
-
|
|
839
|
+
function getBindings(
|
|
791
840
|
configParam: Config,
|
|
792
841
|
env: string | undefined,
|
|
842
|
+
local: boolean,
|
|
793
843
|
args: AdditionalDevProps
|
|
794
|
-
):
|
|
844
|
+
): CfWorkerInit["bindings"] {
|
|
795
845
|
const bindings = {
|
|
796
846
|
kv_namespaces: [
|
|
797
847
|
...(configParam.kv_namespaces || []).map(
|
|
@@ -817,14 +867,15 @@ async function getBindings(
|
|
|
817
867
|
),
|
|
818
868
|
...(args.kv || []),
|
|
819
869
|
],
|
|
870
|
+
send_email: configParam.send_email,
|
|
820
871
|
// Use a copy of combinedVars since we're modifying it later
|
|
821
872
|
vars: {
|
|
822
873
|
...getVarsForDev(configParam, env),
|
|
823
874
|
...args.vars,
|
|
824
875
|
},
|
|
825
|
-
metadata_binding: configParam.metadata_binding,
|
|
826
876
|
wasm_modules: configParam.wasm_modules,
|
|
827
877
|
text_blobs: configParam.text_blobs,
|
|
878
|
+
browser: configParam.browser,
|
|
828
879
|
data_blobs: configParam.data_blobs,
|
|
829
880
|
durable_objects: {
|
|
830
881
|
bindings: [
|
|
@@ -856,13 +907,39 @@ async function getBindings(
|
|
|
856
907
|
...(args.r2 || []),
|
|
857
908
|
],
|
|
858
909
|
dispatch_namespaces: configParam.dispatch_namespaces,
|
|
910
|
+
mtls_certificates: configParam.mtls_certificates,
|
|
859
911
|
services: configParam.services,
|
|
860
|
-
|
|
912
|
+
analytics_engine_datasets: configParam.analytics_engine_datasets,
|
|
913
|
+
unsafe: {
|
|
914
|
+
bindings: configParam.unsafe.bindings,
|
|
915
|
+
metadata: configParam.unsafe.metadata,
|
|
916
|
+
},
|
|
861
917
|
logfwdr: configParam.logfwdr,
|
|
862
918
|
d1_databases: identifyD1BindingsAsBeta([
|
|
863
|
-
...configParam.d1_databases
|
|
919
|
+
...(configParam.d1_databases ?? []).map((d1Db) => {
|
|
920
|
+
//in local dev, bindings don't matter
|
|
921
|
+
if (local) {
|
|
922
|
+
return {
|
|
923
|
+
...d1Db,
|
|
924
|
+
database_id: "local",
|
|
925
|
+
};
|
|
926
|
+
}
|
|
927
|
+
// if you have a preview_database_id, we'll use it, but we shouldn't force people to use it.
|
|
928
|
+
if (!d1Db.preview_database_id && !process.env.NO_D1_WARNING) {
|
|
929
|
+
logger.log(
|
|
930
|
+
`--------------------\nš” Recommendation: for development, use a preview D1 database rather than the one you'd use in production.\nš” Create a new D1 database with "wrangler d1 create <name>" and add its id as preview_database_id to the d1_database "${d1Db.binding}" in your wrangler.toml\n--------------------\n`
|
|
931
|
+
);
|
|
932
|
+
}
|
|
933
|
+
return {
|
|
934
|
+
...d1Db,
|
|
935
|
+
database_id: d1Db.preview_database_id
|
|
936
|
+
? d1Db.preview_database_id
|
|
937
|
+
: d1Db.database_id,
|
|
938
|
+
};
|
|
939
|
+
}),
|
|
864
940
|
...(args.d1Databases || []),
|
|
865
941
|
]),
|
|
942
|
+
constellation: configParam.constellation,
|
|
866
943
|
};
|
|
867
944
|
|
|
868
945
|
return bindings;
|