devflare 1.0.0-next.39 → 1.0.0-next.40
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/dist/_chunks/account-BtWcv3X9.js +462 -0
- package/dist/_chunks/account-resources-CsmVowJp.js +159 -0
- package/dist/_chunks/ai-CBEuLdoP.js +322 -0
- package/dist/_chunks/api-TzdliH-6.js +568 -0
- package/dist/_chunks/build-3T6O4uIg.js +24 -0
- package/dist/_chunks/build-artifacts-8TqBSQkG.js +483 -0
- package/dist/_chunks/cli-BTF1X4SG.js +1128 -0
- package/dist/_chunks/cloudflare-BaloqI3H.js +157 -0
- package/dist/_chunks/colors-DiK6wPJ5.js +13 -0
- package/dist/_chunks/command-utils-BsfkmTqh.js +45 -0
- package/dist/_chunks/compiler-uoyAQ8zW.js +424 -0
- package/dist/_chunks/config-D5u-bEkn.js +78 -0
- package/dist/_chunks/config-path-DCPto4XB.js +42 -0
- package/dist/_chunks/context-CX50Y2Kb.js +2250 -0
- package/dist/_chunks/decorators-QmV57ixr.js +19 -0
- package/dist/_chunks/dependencies-C2oxFjU_.js +57 -0
- package/dist/_chunks/deploy-DMTr6JeR.js +915 -0
- package/dist/_chunks/dev-CvRHmRFZ.js +3456 -0
- package/dist/_chunks/doctor-DIG8DoFU.js +219 -0
- package/dist/_chunks/durable-object-DMtH0XYX.js +234 -0
- package/dist/_chunks/env-S0_nMVz1.js +125 -0
- package/dist/_chunks/family-DXC5SdFK.js +143 -0
- package/dist/_chunks/generated-artifacts-dMJY4KAt.js +32 -0
- package/dist/_chunks/glob-CmQOvunB.js +56 -0
- package/dist/_chunks/init-3moXTgpb.js +165 -0
- package/dist/_chunks/loader-DLXO60RO.js +1153 -0
- package/dist/_chunks/local-dev-vars-CTSa-wvF.js +81 -0
- package/dist/_chunks/local-hyperdrive-CJ90j46O.js +119 -0
- package/dist/_chunks/local-media-bindings-DsAW4AMF.js +335 -0
- package/dist/_chunks/local-secrets-DMmEOygL.js +123 -0
- package/dist/_chunks/local-workflow-entrypoints-Wip3o1u8.js +90 -0
- package/dist/_chunks/login-BmnDzDlH.js +51 -0
- package/dist/_chunks/package-metadata-DAuCkyvK.js +39 -0
- package/dist/_chunks/preferences-BKp_7XJx.js +241 -0
- package/dist/_chunks/preview-BhqDmq8I.js +456 -0
- package/dist/_chunks/preview-registry-ClAbLTHH.js +1186 -0
- package/dist/_chunks/preview-resources-DdXj8LMM.js +358 -0
- package/dist/_chunks/previews-Dlr13x5M.js +1134 -0
- package/dist/_chunks/productions-D3AnOHac.js +411 -0
- package/dist/_chunks/ref-CYJNAAe_.js +178 -0
- package/dist/_chunks/remote-CZnP-HLJ.js +79 -0
- package/dist/_chunks/remote-config-D39BY9ji.js +132 -0
- package/dist/_chunks/resolve-package-Y84HB3Nt.js +133 -0
- package/dist/_chunks/rolldown-runtime-CvQ6eiug.js +14 -0
- package/dist/_chunks/routes-C3FqES2W.js +796 -0
- package/dist/_chunks/runtime-FvXvfuZ2.js +550 -0
- package/dist/_chunks/schema-normalization-DWVleVxo.js +477 -0
- package/dist/_chunks/secrets-70eN0Q6C.js +95 -0
- package/dist/_chunks/token-kguIDmej.js +333 -0
- package/dist/_chunks/tokens-iVcgNXi-.js +221 -0
- package/dist/_chunks/types-OrLbzv4I.js +476 -0
- package/dist/_chunks/ui-BUoZApvE.js +103 -0
- package/dist/_chunks/usage-BBTGzjon.js +272 -0
- package/dist/_chunks/vite-CsI0E-uV.js +1235 -0
- package/dist/_chunks/vite-utils-OVLMV605.js +183 -0
- package/dist/_chunks/worker-CS1jgNFE.js +410 -0
- package/dist/_chunks/worker-bundler-dTTnYU3n.js +458 -0
- package/dist/_chunks/worker-entrypoint-CQW77lG8.js +247 -0
- package/dist/_chunks/workerName-CFJsLZA-.js +23 -0
- package/dist/bridge/index.d.ts +6 -6
- package/dist/bridge/miniflare.d.ts +2 -2
- package/dist/bridge/proxy.d.ts +1 -1
- package/dist/bridge/v2/body-streams.d.ts +1 -1
- package/dist/bridge/v2/codec.d.ts +4 -4
- package/dist/bridge/v2/index.d.ts +10 -10
- package/dist/bridge/v2/serialization.d.ts +1 -1
- package/dist/bridge/v2/value-codec.d.ts +1 -1
- package/dist/bridge/v2/value-serialization.d.ts.map +1 -1
- package/dist/bridge/v2/ws-relay.d.ts +3 -3
- package/dist/browser-shim/index.d.ts +2 -2
- package/dist/browser.d.ts +70 -70
- package/dist/browser.js +74 -2462
- package/dist/bundler/do-bundler.d.ts +1 -1
- package/dist/bundler/index.d.ts +3 -3
- package/dist/bundler/rolldown-shared.d.ts +1 -1
- package/dist/bundler/worker-bundler.d.ts +1 -1
- package/dist/cli/build-manifest.d.ts +1 -1
- package/dist/cli/command-utils.d.ts +1 -1
- package/dist/cli/commands/account.d.ts +1 -1
- package/dist/cli/commands/ai.d.ts +1 -1
- package/dist/cli/commands/build-artifacts.d.ts +5 -5
- package/dist/cli/commands/build.d.ts +1 -1
- package/dist/cli/commands/config.d.ts +1 -1
- package/dist/cli/commands/deploy/prepare.d.ts +2 -2
- package/dist/cli/commands/deploy/runtime.d.ts +1 -1
- package/dist/cli/commands/deploy/verification.d.ts +1 -1
- package/dist/cli/commands/deploy.d.ts +1 -1
- package/dist/cli/commands/dev.d.ts +1 -1
- package/dist/cli/commands/doctor.d.ts +1 -1
- package/dist/cli/commands/init.d.ts +1 -1
- package/dist/cli/commands/login.d.ts +1 -1
- package/dist/cli/commands/previews-support/cleanup.d.ts +1 -1
- package/dist/cli/commands/previews-support/family.d.ts +3 -3
- package/dist/cli/commands/previews-support/render.d.ts +3 -3
- package/dist/cli/commands/previews-support/theme.d.ts +2 -2
- package/dist/cli/commands/previews-support/types.d.ts +2 -2
- package/dist/cli/commands/previews.d.ts +1 -1
- package/dist/cli/commands/productions.d.ts +1 -1
- package/dist/cli/commands/remote.d.ts +1 -1
- package/dist/cli/commands/secrets.d.ts +1 -1
- package/dist/cli/commands/token.d.ts +1 -1
- package/dist/cli/commands/type-generation/discovery.d.ts +2 -2
- package/dist/cli/commands/type-generation/generator.d.ts +3 -3
- package/dist/cli/commands/type-generation/models.d.ts +1 -1
- package/dist/cli/commands/types.d.ts +1 -1
- package/dist/cli/commands/worker.d.ts +1 -1
- package/dist/cli/deploy-strategy.d.ts +1 -1
- package/dist/cli/deploy-target.d.ts +1 -1
- package/dist/cli/help-pages/pages/account.d.ts +1 -1
- package/dist/cli/help-pages/pages/core.d.ts +1 -1
- package/dist/cli/help-pages/pages/index.d.ts +1 -1
- package/dist/cli/help-pages/pages/misc.d.ts +1 -1
- package/dist/cli/help-pages/pages/previews.d.ts +1 -1
- package/dist/cli/help-pages/pages/productions.d.ts +1 -1
- package/dist/cli/help-pages/render.d.ts +2 -2
- package/dist/cli/help-pages/shared.d.ts +1 -1
- package/dist/cli/help.d.ts +2 -2
- package/dist/cli/index.js +2 -1383
- package/dist/cli/preview-bindings.d.ts +3 -3
- package/dist/cli/preview.d.ts +1 -1
- package/dist/cli/wrangler-auth.d.ts +1 -1
- package/dist/cloudflare/account-core.d.ts +2 -2
- package/dist/cloudflare/account-resources.d.ts +2 -2
- package/dist/cloudflare/account-status.d.ts +1 -1
- package/dist/cloudflare/account-workers.d.ts +2 -2
- package/dist/cloudflare/account.d.ts +7 -7
- package/dist/cloudflare/auth.d.ts +1 -1
- package/dist/cloudflare/index.d.ts +13 -13
- package/dist/cloudflare/index.js +4 -59
- package/dist/cloudflare/kv-namespace.d.ts +1 -1
- package/dist/cloudflare/preview-registry-cache.d.ts +1 -1
- package/dist/cloudflare/preview-registry-inference.d.ts +2 -2
- package/dist/cloudflare/preview-registry-records.d.ts +3 -3
- package/dist/cloudflare/preview-registry-shape.d.ts +2 -2
- package/dist/cloudflare/preview-registry-store.d.ts +3 -3
- package/dist/cloudflare/preview-registry-transport.d.ts +2 -2
- package/dist/cloudflare/preview-registry-types.d.ts +2 -2
- package/dist/cloudflare/preview-registry.d.ts +5 -5
- package/dist/cloudflare/tokens.d.ts +2 -2
- package/dist/cloudflare/usage.d.ts +2 -2
- package/dist/config/binding-resolution-helpers.d.ts +1 -1
- package/dist/config/compiler/bindings.d.ts +2 -2
- package/dist/config/compiler/core-helpers.d.ts +2 -2
- package/dist/config/compiler/do-workers.d.ts +2 -2
- package/dist/config/compiler/paths.d.ts +1 -1
- package/dist/config/compiler.d.ts +6 -6
- package/dist/config/define.d.ts +2 -2
- package/dist/config/deploy-resources.d.ts +5 -5
- package/dist/config/env-vars.d.ts +1 -1
- package/dist/config/framework-providers.d.ts +1 -1
- package/dist/config/index.d.ts +12 -12
- package/dist/config/loader.d.ts +2 -2
- package/dist/config/local-dev-vars.d.ts +1 -1
- package/dist/config/preview-resources.d.ts +4 -4
- package/dist/config/preview.d.ts +1 -1
- package/dist/config/ref.d.ts +2 -2
- package/dist/config/resolve-phased.d.ts +4 -4
- package/dist/config/resolve.d.ts +1 -1
- package/dist/config/resource-resolution.d.ts +6 -6
- package/dist/config/schema-env.d.ts +20 -20
- package/dist/config/schema-normalization.d.ts +1 -1
- package/dist/config/schema-types-bindings.d.ts +4 -4
- package/dist/config/schema-types-build.d.ts +1 -1
- package/dist/config/schema-types.d.ts +7 -7
- package/dist/config/schema.d.ts +46 -46
- package/dist/config/service-bindings-validation.d.ts +1 -1
- package/dist/config-entry.d.ts +6 -6
- package/dist/config-entry.js +3 -8
- package/dist/decorators/index.d.ts +2 -2
- package/dist/decorators/index.js +2 -9
- package/dist/dev-server/d1-migrations.d.ts +1 -1
- package/dist/dev-server/dev-server-state.d.ts +6 -6
- package/dist/dev-server/gateway-script.d.ts +1 -1
- package/dist/dev-server/index.d.ts +1 -1
- package/dist/dev-server/miniflare-bindings.d.ts +1 -1
- package/dist/dev-server/miniflare-dev-config.d.ts +5 -5
- package/dist/dev-server/miniflare-worker-config.d.ts +3 -3
- package/dist/dev-server/server-startup-helpers.d.ts +6 -6
- package/dist/dev-server/worker-surface-paths.d.ts +2 -2
- package/dist/index.d.ts +8 -8
- package/dist/index.js +9 -22
- package/dist/runtime/context-events.d.ts +1 -1
- package/dist/runtime/context.d.ts +3 -3
- package/dist/runtime/exports.d.ts +2 -2
- package/dist/runtime/index.d.ts +10 -10
- package/dist/runtime/index.js +5 -57
- package/dist/runtime/middleware.d.ts +1 -1
- package/dist/runtime/router/index.d.ts +3 -3
- package/dist/runtime/validation.d.ts +1 -1
- package/dist/secrets/local-secrets.d.ts +1 -1
- package/dist/shims/local-media-bindings.d.ts +1 -1
- package/dist/sveltekit/index.d.ts +1 -1
- package/dist/sveltekit/index.js +327 -9
- package/dist/sveltekit/local-bindings.d.ts +1 -1
- package/dist/sveltekit/platform.d.ts +1 -1
- package/dist/test/binding-hints.d.ts +2 -2
- package/dist/test/cf.d.ts +19 -19
- package/dist/test/index.d.ts +18 -18
- package/dist/test/index.js +4495 -46
- package/dist/test/offline-bindings.d.ts +3 -3
- package/dist/test/resolve-service-bindings.d.ts +1 -1
- package/dist/test/simple-context-bindings.d.ts +1 -1
- package/dist/test/simple-context-durable-objects.d.ts +1 -1
- package/dist/test/simple-context-env.d.ts +2 -2
- package/dist/test/simple-context-handlers.d.ts +2 -2
- package/dist/test/simple-context-lifecycle.d.ts +2 -2
- package/dist/test/simple-context-mfconfig.d.ts +1 -1
- package/dist/test/simple-context-multi-worker.d.ts +2 -2
- package/dist/test/simple-context-runtime.d.ts +1 -1
- package/dist/test/simple-context-startup.d.ts +1 -1
- package/dist/test/simple-context.d.ts +1 -1
- package/dist/test/utilities/env.d.ts +3 -3
- package/dist/test/utilities.d.ts +10 -10
- package/dist/test/worker.d.ts +1 -1
- package/dist/transform/index.d.ts +2 -2
- package/dist/utils/send-email.js +163 -19
- package/dist/vite/config-file.d.ts +2 -2
- package/dist/vite/index.d.ts +3 -3
- package/dist/vite/index.js +2 -31
- package/dist/vite/plugin-config-hook.d.ts +1 -1
- package/dist/vite/plugin-context.d.ts +3 -3
- package/dist/vite/plugin-durable-objects.d.ts +2 -2
- package/dist/vite/plugin-programmatic.d.ts +1 -1
- package/dist/vite/plugin-service-bindings.d.ts +2 -2
- package/dist/vite/plugin.d.ts +3 -3
- package/dist/worker-entry/composed-worker.d.ts +1 -1
- package/dist/worker-entry/routes.d.ts +2 -2
- package/dist/worker-entry/surface-paths.d.ts +1 -1
- package/dist/workflows/local-workflow-entrypoints.d.ts +1 -1
- package/package.json +5 -3
- package/dist/account-4tgh03a8.js +0 -484
- package/dist/ai-r3zqmxan.js +0 -261
- package/dist/api-6z01z734.js +0 -33
- package/dist/build-kw625v84.js +0 -51
- package/dist/config-ghk2bxj3.js +0 -102
- package/dist/deploy-9kee65n9.js +0 -1062
- package/dist/dev-x8zr249a.js +0 -3569
- package/dist/doctor-0ng5qrr1.js +0 -258
- package/dist/durable-object-0ybmg08a.js +0 -13
- package/dist/index-04wh9bxx.js +0 -514
- package/dist/index-0cc05hzv.js +0 -74
- package/dist/index-2yv7w548.js +0 -185
- package/dist/index-37x76zdn.js +0 -4
- package/dist/index-3cpzsr47.js +0 -125
- package/dist/index-3t6rypgc.js +0 -13
- package/dist/index-4mmpccrb.js +0 -309
- package/dist/index-5dkjffqz.js +0 -25
- package/dist/index-5hy7jmv3.js +0 -890
- package/dist/index-627srx16.js +0 -45
- package/dist/index-7m557715.js +0 -283
- package/dist/index-a8pnvg3r.js +0 -52
- package/dist/index-aabgympv.js +0 -39
- package/dist/index-atwc3csp.js +0 -256
- package/dist/index-cv4cvrxe.js +0 -2046
- package/dist/index-h7r11y4a.js +0 -539
- package/dist/index-hvtd936d.js +0 -1229
- package/dist/index-kcp7y951.js +0 -136
- package/dist/index-maw0jjnn.js +0 -147
- package/dist/index-mek9msfv.js +0 -705
- package/dist/index-n4xkaymm.js +0 -236
- package/dist/index-nkk59p3y.js +0 -579
- package/dist/index-phcrvs6d.js +0 -342
- package/dist/index-se4kw8tm.js +0 -460
- package/dist/index-x8s9rwfh.js +0 -2020
- package/dist/index-y7w3x9p1.js +0 -18
- package/dist/index-z9gy8w6b.js +0 -57
- package/dist/index-zdd0d9qa.js +0 -199
- package/dist/init-tb8jqgvr.js +0 -180
- package/dist/login-4h1sfsed.js +0 -75
- package/dist/previews-qr7c5j8h.js +0 -1336
- package/dist/productions-xpmd6bw8.js +0 -505
- package/dist/remote-kqcvhnfx.js +0 -192
- package/dist/secrets-6wbdsdek.js +0 -89
- package/dist/token-yp1qa70y.js +0 -419
- package/dist/types-15yv4cj3.js +0 -701
- package/dist/worker-1yg72jxg.js +0 -510
- package/dist/worker-entrypoint-y8s9kdcx.js +0 -15
package/dist/index-mek9msfv.js
DELETED
|
@@ -1,705 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
browserBindingSchema,
|
|
3
|
-
getSingleBrowserBindingName,
|
|
4
|
-
normalizeArtifactsBinding,
|
|
5
|
-
normalizeCompatibilityFlags,
|
|
6
|
-
normalizeD1Binding,
|
|
7
|
-
normalizeDOBinding,
|
|
8
|
-
normalizeDispatchNamespaceBinding,
|
|
9
|
-
normalizeHyperdriveBinding,
|
|
10
|
-
normalizeImagesBinding,
|
|
11
|
-
normalizeKVBinding,
|
|
12
|
-
normalizeMediaBinding,
|
|
13
|
-
normalizeMtlsCertificateBinding,
|
|
14
|
-
normalizePipelineBinding,
|
|
15
|
-
normalizeSecretsStoreBinding,
|
|
16
|
-
normalizeWorkflowBinding,
|
|
17
|
-
resolveConfigForEnvironment
|
|
18
|
-
} from "./index-x8s9rwfh.js";
|
|
19
|
-
import {
|
|
20
|
-
__require
|
|
21
|
-
} from "./index-37x76zdn.js";
|
|
22
|
-
|
|
23
|
-
// src/config/compiler/paths.ts
|
|
24
|
-
import { basename, isAbsolute, relative, resolve } from "pathe";
|
|
25
|
-
function stringifyConfig(config) {
|
|
26
|
-
const header = `// Generated by devflare — Do not edit directly
|
|
27
|
-
// Edit devflare.config.ts instead
|
|
28
|
-
|
|
29
|
-
`;
|
|
30
|
-
return header + JSON.stringify(config, null, "\t");
|
|
31
|
-
}
|
|
32
|
-
function rebasePathForConfigDir(projectRoot, configDir, pathValue) {
|
|
33
|
-
const absolutePath = isAbsolute(pathValue) ? pathValue : resolve(projectRoot, pathValue);
|
|
34
|
-
return relative(configDir, absolutePath).replace(/\\/g, "/");
|
|
35
|
-
}
|
|
36
|
-
function isLocalContainerPath(pathValue) {
|
|
37
|
-
return pathValue === "Dockerfile" || pathValue.startsWith(".") || pathValue.startsWith("/") || pathValue.startsWith("\\") || isAbsolute(pathValue) || pathValue.endsWith("/Dockerfile") || pathValue.endsWith("\\Dockerfile");
|
|
38
|
-
}
|
|
39
|
-
function pathIsInsideDirectory(directoryPath, candidatePath) {
|
|
40
|
-
const normalizedDirectoryPath = directoryPath.replace(/\\/g, "/");
|
|
41
|
-
const normalizedCandidatePath = candidatePath.replace(/\\/g, "/");
|
|
42
|
-
return normalizedCandidatePath === normalizedDirectoryPath || normalizedCandidatePath.startsWith(`${normalizedDirectoryPath}/`);
|
|
43
|
-
}
|
|
44
|
-
function isolateViteBuildOutputPaths(projectRoot, config) {
|
|
45
|
-
const assetsDirectory = config.assets?.directory;
|
|
46
|
-
if (!assetsDirectory) {
|
|
47
|
-
return config;
|
|
48
|
-
}
|
|
49
|
-
const isolatedAssetsDirectoryPath = resolve(projectRoot, ".devflare", "vite-build-output", basename(assetsDirectory));
|
|
50
|
-
const isolatedAssetsDirectory = relative(projectRoot, isolatedAssetsDirectoryPath).replace(/\\/g, "/");
|
|
51
|
-
const isolatedConfig = {
|
|
52
|
-
...config,
|
|
53
|
-
assets: config.assets ? {
|
|
54
|
-
...config.assets,
|
|
55
|
-
directory: isolatedAssetsDirectory
|
|
56
|
-
} : config.assets
|
|
57
|
-
};
|
|
58
|
-
if (!config.main) {
|
|
59
|
-
return isolatedConfig;
|
|
60
|
-
}
|
|
61
|
-
const originalAssetsDirectoryPath = resolve(projectRoot, assetsDirectory);
|
|
62
|
-
const originalMainEntryPath = resolve(projectRoot, config.main);
|
|
63
|
-
if (!pathIsInsideDirectory(originalAssetsDirectoryPath, originalMainEntryPath)) {
|
|
64
|
-
return isolatedConfig;
|
|
65
|
-
}
|
|
66
|
-
const relativeMainEntryPath = relative(originalAssetsDirectoryPath, originalMainEntryPath);
|
|
67
|
-
const isolatedMainEntryPath = resolve(isolatedAssetsDirectoryPath, relativeMainEntryPath);
|
|
68
|
-
return {
|
|
69
|
-
...isolatedConfig,
|
|
70
|
-
main: relative(projectRoot, isolatedMainEntryPath).replace(/\\/g, "/")
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
function rebaseWranglerConfigPaths(projectRoot, configDir, config) {
|
|
74
|
-
return {
|
|
75
|
-
...config,
|
|
76
|
-
...config.main ? { main: rebasePathForConfigDir(projectRoot, configDir, config.main) } : {},
|
|
77
|
-
...config.assets?.directory ? {
|
|
78
|
-
assets: {
|
|
79
|
-
...config.assets,
|
|
80
|
-
directory: rebasePathForConfigDir(projectRoot, configDir, config.assets.directory)
|
|
81
|
-
}
|
|
82
|
-
} : {},
|
|
83
|
-
...config.containers ? {
|
|
84
|
-
containers: config.containers.map((container) => ({
|
|
85
|
-
...container,
|
|
86
|
-
image: isLocalContainerPath(container.image) ? rebasePathForConfigDir(projectRoot, configDir, container.image) : container.image,
|
|
87
|
-
...container.image_build_context && {
|
|
88
|
-
image_build_context: rebasePathForConfigDir(projectRoot, configDir, container.image_build_context)
|
|
89
|
-
}
|
|
90
|
-
}))
|
|
91
|
-
} : {}
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
async function writeWranglerConfig(cwd, config, filename = "wrangler.jsonc") {
|
|
95
|
-
const { resolve: resolve2 } = await import("pathe");
|
|
96
|
-
const fs = await import("node:fs/promises");
|
|
97
|
-
try {
|
|
98
|
-
await fs.mkdir(cwd, { recursive: true });
|
|
99
|
-
} catch {}
|
|
100
|
-
const content = stringifyConfig(config);
|
|
101
|
-
const wranglerPath = resolve2(cwd, filename);
|
|
102
|
-
await fs.writeFile(wranglerPath, content, "utf-8");
|
|
103
|
-
return wranglerPath;
|
|
104
|
-
}
|
|
105
|
-
async function readWranglerConfig(filePath) {
|
|
106
|
-
const fs = await import("node:fs/promises");
|
|
107
|
-
const { parse } = await import("jsonc-parser");
|
|
108
|
-
const content = await fs.readFile(filePath, "utf-8");
|
|
109
|
-
const parsedConfig = parse(content);
|
|
110
|
-
if (!parsedConfig || typeof parsedConfig !== "object") {
|
|
111
|
-
throw new Error(`Could not parse Wrangler config at ${filePath}.`);
|
|
112
|
-
}
|
|
113
|
-
return parsedConfig;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
// src/config/compiler/bindings.ts
|
|
117
|
-
function getWranglerD1DatabaseBinding(bindingName, bindingConfig, options = {}) {
|
|
118
|
-
const normalized = normalizeD1Binding(bindingConfig);
|
|
119
|
-
if (normalized.databaseId) {
|
|
120
|
-
return {
|
|
121
|
-
binding: bindingName,
|
|
122
|
-
database_id: normalized.databaseId
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
if (options.preserveNamedBindings && normalized.name) {
|
|
126
|
-
return {
|
|
127
|
-
binding: bindingName,
|
|
128
|
-
database_name: normalized.name
|
|
129
|
-
};
|
|
130
|
-
}
|
|
131
|
-
throw new Error(`D1 binding "${bindingName}" is configured by name (${normalized.name}) and must be resolved before compiling Wrangler config. Use loadResolvedConfig() or resolveConfigResources() for build/deploy/automation flows.`);
|
|
132
|
-
}
|
|
133
|
-
function getWranglerKVNamespaceBinding(bindingName, bindingConfig, options = {}) {
|
|
134
|
-
const normalized = normalizeKVBinding(bindingConfig);
|
|
135
|
-
if (normalized.namespaceId) {
|
|
136
|
-
return {
|
|
137
|
-
binding: bindingName,
|
|
138
|
-
id: normalized.namespaceId
|
|
139
|
-
};
|
|
140
|
-
}
|
|
141
|
-
if (options.preserveNamedBindings && normalized.name) {
|
|
142
|
-
return {
|
|
143
|
-
binding: bindingName,
|
|
144
|
-
name: normalized.name
|
|
145
|
-
};
|
|
146
|
-
}
|
|
147
|
-
throw new Error(`KV binding "${bindingName}" is configured by name (${normalized.name}) and must be resolved before compiling Wrangler config. Use loadResolvedConfig() or resolveConfigResources() for build/deploy/automation flows.`);
|
|
148
|
-
}
|
|
149
|
-
function getWranglerHyperdriveBinding(bindingName, bindingConfig, options = {}) {
|
|
150
|
-
const normalized = normalizeHyperdriveBinding(bindingConfig);
|
|
151
|
-
if (normalized.configurationId) {
|
|
152
|
-
return {
|
|
153
|
-
binding: bindingName,
|
|
154
|
-
id: normalized.configurationId,
|
|
155
|
-
...normalized.localConnectionString && {
|
|
156
|
-
localConnectionString: normalized.localConnectionString
|
|
157
|
-
}
|
|
158
|
-
};
|
|
159
|
-
}
|
|
160
|
-
if (options.preserveNamedBindings && normalized.name) {
|
|
161
|
-
return {
|
|
162
|
-
binding: bindingName,
|
|
163
|
-
name: normalized.name,
|
|
164
|
-
...normalized.localConnectionString && {
|
|
165
|
-
localConnectionString: normalized.localConnectionString
|
|
166
|
-
}
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
throw new Error(`Hyperdrive binding "${bindingName}" is configured by name (${normalized.name}) and must be resolved before compiling Wrangler config. Use loadResolvedConfig() or resolveConfigResources() for build/deploy/automation flows.`);
|
|
170
|
-
}
|
|
171
|
-
function getWranglerBrowserBinding(browserBindings) {
|
|
172
|
-
if (!browserBindings) {
|
|
173
|
-
return;
|
|
174
|
-
}
|
|
175
|
-
const parsed = browserBindingSchema.parse(browserBindings);
|
|
176
|
-
const bindingName = getSingleBrowserBindingName(parsed);
|
|
177
|
-
if (!bindingName) {
|
|
178
|
-
return;
|
|
179
|
-
}
|
|
180
|
-
const bindingConfig = parsed[bindingName];
|
|
181
|
-
return {
|
|
182
|
-
binding: bindingName,
|
|
183
|
-
...typeof bindingConfig === "object" && bindingConfig.remote !== undefined && {
|
|
184
|
-
remote: bindingConfig.remote
|
|
185
|
-
}
|
|
186
|
-
};
|
|
187
|
-
}
|
|
188
|
-
function compileBindings(bindings, result, options = {}, defaultSecretsStoreId) {
|
|
189
|
-
if (bindings.kv) {
|
|
190
|
-
result.kv_namespaces = Object.entries(bindings.kv).map(([binding, namespace]) => {
|
|
191
|
-
return getWranglerKVNamespaceBinding(binding, namespace, options);
|
|
192
|
-
});
|
|
193
|
-
}
|
|
194
|
-
if (bindings.d1) {
|
|
195
|
-
result.d1_databases = Object.entries(bindings.d1).map(([binding, database_id]) => {
|
|
196
|
-
return getWranglerD1DatabaseBinding(binding, database_id, options);
|
|
197
|
-
});
|
|
198
|
-
}
|
|
199
|
-
if (bindings.r2) {
|
|
200
|
-
result.r2_buckets = Object.entries(bindings.r2).map(([binding, bucket_name]) => ({
|
|
201
|
-
binding,
|
|
202
|
-
bucket_name
|
|
203
|
-
}));
|
|
204
|
-
}
|
|
205
|
-
if (bindings.durableObjects) {
|
|
206
|
-
result.durable_objects = {
|
|
207
|
-
bindings: Object.entries(bindings.durableObjects).map(([name, config]) => {
|
|
208
|
-
const normalized = normalizeDOBinding(config);
|
|
209
|
-
const binding = {
|
|
210
|
-
name,
|
|
211
|
-
class_name: normalized.className
|
|
212
|
-
};
|
|
213
|
-
if (normalized.kind === "cross-worker" && normalized.scriptName) {
|
|
214
|
-
binding.script_name = normalized.scriptName;
|
|
215
|
-
}
|
|
216
|
-
return binding;
|
|
217
|
-
})
|
|
218
|
-
};
|
|
219
|
-
}
|
|
220
|
-
if (bindings.queues) {
|
|
221
|
-
result.queues = {};
|
|
222
|
-
if (bindings.queues.producers) {
|
|
223
|
-
result.queues.producers = Object.entries(bindings.queues.producers).map(([binding, queue]) => ({ binding, queue }));
|
|
224
|
-
}
|
|
225
|
-
if (bindings.queues.consumers) {
|
|
226
|
-
result.queues.consumers = bindings.queues.consumers.map((consumer) => ({
|
|
227
|
-
queue: consumer.queue,
|
|
228
|
-
...consumer.maxBatchSize && { max_batch_size: consumer.maxBatchSize },
|
|
229
|
-
...consumer.maxBatchTimeout && { max_batch_timeout: consumer.maxBatchTimeout },
|
|
230
|
-
...consumer.maxRetries && { max_retries: consumer.maxRetries },
|
|
231
|
-
...consumer.deadLetterQueue && { dead_letter_queue: consumer.deadLetterQueue },
|
|
232
|
-
...consumer.maxConcurrency && { max_concurrency: consumer.maxConcurrency },
|
|
233
|
-
...consumer.retryDelay && { retry_delay: consumer.retryDelay }
|
|
234
|
-
}));
|
|
235
|
-
}
|
|
236
|
-
}
|
|
237
|
-
if (bindings.rateLimits) {
|
|
238
|
-
result.ratelimits = Object.entries(bindings.rateLimits).map(([name, config]) => ({
|
|
239
|
-
name,
|
|
240
|
-
namespace_id: config.namespaceId,
|
|
241
|
-
simple: {
|
|
242
|
-
limit: config.simple.limit,
|
|
243
|
-
period: config.simple.period
|
|
244
|
-
}
|
|
245
|
-
}));
|
|
246
|
-
}
|
|
247
|
-
if (bindings.versionMetadata) {
|
|
248
|
-
result.version_metadata = {
|
|
249
|
-
binding: bindings.versionMetadata.binding
|
|
250
|
-
};
|
|
251
|
-
}
|
|
252
|
-
if (bindings.workerLoaders) {
|
|
253
|
-
result.worker_loaders = Object.keys(bindings.workerLoaders).map((binding) => ({ binding }));
|
|
254
|
-
}
|
|
255
|
-
if (bindings.mtlsCertificates) {
|
|
256
|
-
result.mtls_certificates = Object.entries(bindings.mtlsCertificates).map(([binding, config]) => {
|
|
257
|
-
const normalized = normalizeMtlsCertificateBinding(config);
|
|
258
|
-
return {
|
|
259
|
-
binding,
|
|
260
|
-
certificate_id: normalized.certificateId,
|
|
261
|
-
...normalized.remote !== undefined && { remote: normalized.remote }
|
|
262
|
-
};
|
|
263
|
-
});
|
|
264
|
-
}
|
|
265
|
-
if (bindings.dispatchNamespaces) {
|
|
266
|
-
result.dispatch_namespaces = Object.entries(bindings.dispatchNamespaces).map(([binding, config]) => {
|
|
267
|
-
const normalized = normalizeDispatchNamespaceBinding(config);
|
|
268
|
-
return {
|
|
269
|
-
binding,
|
|
270
|
-
namespace: normalized.namespace,
|
|
271
|
-
...normalized.outbound && { outbound: normalized.outbound },
|
|
272
|
-
...normalized.remote !== undefined && { remote: normalized.remote }
|
|
273
|
-
};
|
|
274
|
-
});
|
|
275
|
-
}
|
|
276
|
-
if (bindings.workflows) {
|
|
277
|
-
result.workflows = Object.entries(bindings.workflows).map(([binding, config]) => {
|
|
278
|
-
const normalized = normalizeWorkflowBinding(config);
|
|
279
|
-
return {
|
|
280
|
-
binding,
|
|
281
|
-
name: normalized.name,
|
|
282
|
-
class_name: normalized.className,
|
|
283
|
-
...normalized.scriptName && { script_name: normalized.scriptName },
|
|
284
|
-
...normalized.remote !== undefined && { remote: normalized.remote },
|
|
285
|
-
...normalized.limits && { limits: normalized.limits }
|
|
286
|
-
};
|
|
287
|
-
});
|
|
288
|
-
}
|
|
289
|
-
if (bindings.pipelines) {
|
|
290
|
-
result.pipelines = Object.entries(bindings.pipelines).map(([binding, config]) => {
|
|
291
|
-
const normalized = normalizePipelineBinding(config);
|
|
292
|
-
return {
|
|
293
|
-
binding,
|
|
294
|
-
pipeline: normalized.pipeline,
|
|
295
|
-
...normalized.remote !== undefined && { remote: normalized.remote }
|
|
296
|
-
};
|
|
297
|
-
});
|
|
298
|
-
}
|
|
299
|
-
if (bindings.images) {
|
|
300
|
-
const [entry] = Object.entries(bindings.images);
|
|
301
|
-
if (entry) {
|
|
302
|
-
const [binding, config] = entry;
|
|
303
|
-
const normalized = normalizeImagesBinding(binding, config);
|
|
304
|
-
result.images = {
|
|
305
|
-
binding: normalized.binding,
|
|
306
|
-
...normalized.remote !== undefined && { remote: normalized.remote }
|
|
307
|
-
};
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
if (bindings.media) {
|
|
311
|
-
const [entry] = Object.entries(bindings.media);
|
|
312
|
-
if (entry) {
|
|
313
|
-
const [binding, config] = entry;
|
|
314
|
-
const normalized = normalizeMediaBinding(binding, config);
|
|
315
|
-
result.media = {
|
|
316
|
-
binding: normalized.binding,
|
|
317
|
-
...normalized.remote !== undefined && { remote: normalized.remote }
|
|
318
|
-
};
|
|
319
|
-
}
|
|
320
|
-
}
|
|
321
|
-
if (bindings.artifacts) {
|
|
322
|
-
result.artifacts = Object.entries(bindings.artifacts).map(([binding, config]) => {
|
|
323
|
-
const normalized = normalizeArtifactsBinding(config);
|
|
324
|
-
return {
|
|
325
|
-
binding,
|
|
326
|
-
namespace: normalized.namespace,
|
|
327
|
-
...normalized.remote !== undefined && { remote: normalized.remote }
|
|
328
|
-
};
|
|
329
|
-
});
|
|
330
|
-
}
|
|
331
|
-
if (bindings.secretsStore) {
|
|
332
|
-
result.secrets_store_secrets = Object.entries(bindings.secretsStore).map(([binding, config]) => {
|
|
333
|
-
const normalized = normalizeSecretsStoreBinding(config, defaultSecretsStoreId, binding);
|
|
334
|
-
return {
|
|
335
|
-
binding,
|
|
336
|
-
store_id: normalized.storeId,
|
|
337
|
-
secret_name: normalized.secretName
|
|
338
|
-
};
|
|
339
|
-
});
|
|
340
|
-
}
|
|
341
|
-
if (bindings.services) {
|
|
342
|
-
result.services = Object.entries(bindings.services).map(([binding, config]) => ({
|
|
343
|
-
binding,
|
|
344
|
-
service: config.service,
|
|
345
|
-
...config.entrypoint && { entrypoint: config.entrypoint },
|
|
346
|
-
...config.environment && { environment: config.environment }
|
|
347
|
-
}));
|
|
348
|
-
}
|
|
349
|
-
if (bindings.ai?.binding) {
|
|
350
|
-
result.ai = {
|
|
351
|
-
binding: bindings.ai.binding,
|
|
352
|
-
...bindings.ai.remote !== undefined && { remote: bindings.ai.remote },
|
|
353
|
-
...bindings.ai.staging !== undefined && { staging: bindings.ai.staging }
|
|
354
|
-
};
|
|
355
|
-
}
|
|
356
|
-
if (bindings.aiSearchNamespaces) {
|
|
357
|
-
result.ai_search_namespaces = Object.entries(bindings.aiSearchNamespaces).map(([binding, config]) => ({
|
|
358
|
-
binding,
|
|
359
|
-
namespace: config.namespace,
|
|
360
|
-
...config.remote !== undefined && { remote: config.remote }
|
|
361
|
-
}));
|
|
362
|
-
}
|
|
363
|
-
if (bindings.aiSearch) {
|
|
364
|
-
result.ai_search = Object.entries(bindings.aiSearch).map(([binding, config]) => ({
|
|
365
|
-
binding,
|
|
366
|
-
instance_name: config.instanceName,
|
|
367
|
-
...config.remote !== undefined && { remote: config.remote }
|
|
368
|
-
}));
|
|
369
|
-
}
|
|
370
|
-
if (bindings.vectorize) {
|
|
371
|
-
result.vectorize = Object.entries(bindings.vectorize).map(([binding, config]) => ({
|
|
372
|
-
binding,
|
|
373
|
-
index_name: config.indexName,
|
|
374
|
-
...config.remote !== undefined && { remote: config.remote }
|
|
375
|
-
}));
|
|
376
|
-
}
|
|
377
|
-
if (bindings.hyperdrive) {
|
|
378
|
-
result.hyperdrive = Object.entries(bindings.hyperdrive).map(([binding, config]) => {
|
|
379
|
-
return getWranglerHyperdriveBinding(binding, config, options);
|
|
380
|
-
});
|
|
381
|
-
}
|
|
382
|
-
const browserBinding = getWranglerBrowserBinding(bindings.browser);
|
|
383
|
-
if (browserBinding) {
|
|
384
|
-
result.browser = browserBinding;
|
|
385
|
-
}
|
|
386
|
-
if (bindings.analyticsEngine) {
|
|
387
|
-
result.analytics_engine_datasets = Object.entries(bindings.analyticsEngine).map(([binding, config]) => ({
|
|
388
|
-
binding,
|
|
389
|
-
dataset: config.dataset
|
|
390
|
-
}));
|
|
391
|
-
}
|
|
392
|
-
if (bindings.sendEmail) {
|
|
393
|
-
result.send_email = Object.entries(bindings.sendEmail).map(([name, config]) => ({
|
|
394
|
-
name,
|
|
395
|
-
...config.destinationAddress && {
|
|
396
|
-
destination_address: config.destinationAddress
|
|
397
|
-
},
|
|
398
|
-
...config.allowedDestinationAddresses && {
|
|
399
|
-
allowed_destination_addresses: config.allowedDestinationAddresses
|
|
400
|
-
},
|
|
401
|
-
...config.allowedSenderAddresses && {
|
|
402
|
-
allowed_sender_addresses: config.allowedSenderAddresses
|
|
403
|
-
}
|
|
404
|
-
}));
|
|
405
|
-
}
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
// src/config/compiler/core-helpers.ts
|
|
409
|
-
function compileWranglerMigrations(migrations) {
|
|
410
|
-
return migrations.map((migration) => ({
|
|
411
|
-
tag: migration.tag,
|
|
412
|
-
...migration.new_classes && { new_classes: migration.new_classes },
|
|
413
|
-
...migration.renamed_classes && {
|
|
414
|
-
renamed_classes: migration.renamed_classes.map((renamedClass) => ({
|
|
415
|
-
from: renamedClass.from,
|
|
416
|
-
to: renamedClass.to
|
|
417
|
-
}))
|
|
418
|
-
},
|
|
419
|
-
...migration.deleted_classes && { deleted_classes: migration.deleted_classes },
|
|
420
|
-
...migration.new_sqlite_classes && { new_sqlite_classes: migration.new_sqlite_classes }
|
|
421
|
-
}));
|
|
422
|
-
}
|
|
423
|
-
function compileModuleOptions(config, result) {
|
|
424
|
-
if (config.rules && config.rules.length > 0) {
|
|
425
|
-
result.rules = config.rules;
|
|
426
|
-
}
|
|
427
|
-
if (config.findAdditionalModules !== undefined) {
|
|
428
|
-
result.find_additional_modules = config.findAdditionalModules;
|
|
429
|
-
}
|
|
430
|
-
if (config.baseDir) {
|
|
431
|
-
result.base_dir = config.baseDir;
|
|
432
|
-
}
|
|
433
|
-
if (config.preserveFileNames !== undefined) {
|
|
434
|
-
result.preserve_file_names = config.preserveFileNames;
|
|
435
|
-
}
|
|
436
|
-
if (config.logpush !== undefined) {
|
|
437
|
-
result.logpush = config.logpush;
|
|
438
|
-
}
|
|
439
|
-
if (config.uploadSourceMaps !== undefined) {
|
|
440
|
-
result.upload_source_maps = config.uploadSourceMaps;
|
|
441
|
-
}
|
|
442
|
-
if (config.keepVars !== undefined) {
|
|
443
|
-
result.keep_vars = config.keepVars;
|
|
444
|
-
}
|
|
445
|
-
}
|
|
446
|
-
function compileContainers(config, result) {
|
|
447
|
-
if (!config.containers || config.containers.length === 0) {
|
|
448
|
-
return;
|
|
449
|
-
}
|
|
450
|
-
result.containers = config.containers.map((container) => ({
|
|
451
|
-
class_name: container.className,
|
|
452
|
-
image: container.image,
|
|
453
|
-
...container.maxInstances !== undefined && { max_instances: container.maxInstances },
|
|
454
|
-
...container.instanceType && { instance_type: container.instanceType },
|
|
455
|
-
...container.name && { name: container.name },
|
|
456
|
-
...container.imageBuildContext && { image_build_context: container.imageBuildContext },
|
|
457
|
-
...container.imageVars && { image_vars: container.imageVars },
|
|
458
|
-
...container.rolloutActiveGracePeriod !== undefined && {
|
|
459
|
-
rollout_active_grace_period: container.rolloutActiveGracePeriod
|
|
460
|
-
},
|
|
461
|
-
...container.rolloutStepPercentage !== undefined && {
|
|
462
|
-
rollout_step_percentage: container.rolloutStepPercentage
|
|
463
|
-
}
|
|
464
|
-
}));
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
// src/config/local-dev-vars.ts
|
|
468
|
-
import { readFile } from "node:fs/promises";
|
|
469
|
-
import { resolve as resolve2 } from "pathe";
|
|
470
|
-
function parseEnvValue(value) {
|
|
471
|
-
const trimmed = value.trim();
|
|
472
|
-
const quote = trimmed[0];
|
|
473
|
-
if ((quote === '"' || quote === "'" || quote === "`") && trimmed.endsWith(quote) && trimmed.length >= 2) {
|
|
474
|
-
const inner = trimmed.slice(1, -1);
|
|
475
|
-
return quote === '"' ? inner.replace(/\\n/g, `
|
|
476
|
-
`).replace(/\\r/g, "\r").replace(/\\t/g, "\t").replace(/\\"/g, '"').replace(/\\\\/g, "\\") : inner;
|
|
477
|
-
}
|
|
478
|
-
const commentIndex = trimmed.search(/\s+#/);
|
|
479
|
-
return (commentIndex >= 0 ? trimmed.slice(0, commentIndex) : trimmed).trimEnd();
|
|
480
|
-
}
|
|
481
|
-
function parseEnvFile(contents) {
|
|
482
|
-
const vars = {};
|
|
483
|
-
for (const line of contents.split(/\r?\n/)) {
|
|
484
|
-
const trimmed = line.trim();
|
|
485
|
-
if (!trimmed || trimmed.startsWith("#")) {
|
|
486
|
-
continue;
|
|
487
|
-
}
|
|
488
|
-
const assignment = trimmed.startsWith("export ") ? trimmed.slice("export ".length).trimStart() : trimmed;
|
|
489
|
-
const equalsIndex = assignment.indexOf("=");
|
|
490
|
-
if (equalsIndex <= 0) {
|
|
491
|
-
continue;
|
|
492
|
-
}
|
|
493
|
-
const key = assignment.slice(0, equalsIndex).trim();
|
|
494
|
-
if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(key)) {
|
|
495
|
-
continue;
|
|
496
|
-
}
|
|
497
|
-
vars[key] = parseEnvValue(assignment.slice(equalsIndex + 1));
|
|
498
|
-
}
|
|
499
|
-
return vars;
|
|
500
|
-
}
|
|
501
|
-
async function readOptionalEnvFile(filePath) {
|
|
502
|
-
try {
|
|
503
|
-
return parseEnvFile(await readFile(filePath, "utf8"));
|
|
504
|
-
} catch (error) {
|
|
505
|
-
if (error.code === "ENOENT") {
|
|
506
|
-
return null;
|
|
507
|
-
}
|
|
508
|
-
throw error;
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
async function loadWranglerCompatibleLocalVars(cwd, environment) {
|
|
512
|
-
const environmentDevVars = environment ? await readOptionalEnvFile(resolve2(cwd, `.dev.vars.${environment}`)) : null;
|
|
513
|
-
if (environmentDevVars) {
|
|
514
|
-
return environmentDevVars;
|
|
515
|
-
}
|
|
516
|
-
const devVars = await readOptionalEnvFile(resolve2(cwd, ".dev.vars"));
|
|
517
|
-
if (devVars) {
|
|
518
|
-
return devVars;
|
|
519
|
-
}
|
|
520
|
-
const envFiles = [
|
|
521
|
-
".env",
|
|
522
|
-
".env.local",
|
|
523
|
-
...environment ? [`.env.${environment}`, `.env.${environment}.local`] : []
|
|
524
|
-
];
|
|
525
|
-
const merged = {};
|
|
526
|
-
for (const fileName of envFiles) {
|
|
527
|
-
const values = await readOptionalEnvFile(resolve2(cwd, fileName));
|
|
528
|
-
if (values) {
|
|
529
|
-
Object.assign(merged, values);
|
|
530
|
-
}
|
|
531
|
-
}
|
|
532
|
-
return merged;
|
|
533
|
-
}
|
|
534
|
-
function toWranglerSecretsConfig(secrets) {
|
|
535
|
-
if (!secrets) {
|
|
536
|
-
return;
|
|
537
|
-
}
|
|
538
|
-
const required = Object.entries(secrets).filter(([, config]) => config.required !== false).map(([name]) => name).sort();
|
|
539
|
-
return required.length > 0 ? { required } : undefined;
|
|
540
|
-
}
|
|
541
|
-
async function loadLocalDevVars(options) {
|
|
542
|
-
const activeEnvironment = options.environment ?? process.env.CLOUDFLARE_ENV;
|
|
543
|
-
const localVars = await loadWranglerCompatibleLocalVars(options.cwd, activeEnvironment);
|
|
544
|
-
const secretNames = toWranglerSecretsConfig(options.secrets)?.required;
|
|
545
|
-
const filteredLocalVars = secretNames ? Object.fromEntries(Object.entries(localVars).filter(([name]) => secretNames.includes(name))) : localVars;
|
|
546
|
-
return {
|
|
547
|
-
...options.vars ?? {},
|
|
548
|
-
...filteredLocalVars
|
|
549
|
-
};
|
|
550
|
-
}
|
|
551
|
-
async function applyLocalDevVarsToConfig(config, options) {
|
|
552
|
-
const vars = await loadLocalDevVars({
|
|
553
|
-
...options,
|
|
554
|
-
vars: config.vars,
|
|
555
|
-
secrets: config.secrets
|
|
556
|
-
});
|
|
557
|
-
if (Object.keys(vars).length === 0) {
|
|
558
|
-
return config;
|
|
559
|
-
}
|
|
560
|
-
return {
|
|
561
|
-
...config,
|
|
562
|
-
vars
|
|
563
|
-
};
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
// src/config/compiler.ts
|
|
567
|
-
function compileConfig(config, environment) {
|
|
568
|
-
return compileConfigInternal(config, environment);
|
|
569
|
-
}
|
|
570
|
-
function compileBuildConfig(config, environment, options = {}) {
|
|
571
|
-
return compileConfigInternal(config, environment, {
|
|
572
|
-
preserveNamedBindings: true,
|
|
573
|
-
alreadyResolved: options.alreadyResolved
|
|
574
|
-
});
|
|
575
|
-
}
|
|
576
|
-
function compileConfigInternal(config, environment, options = {}) {
|
|
577
|
-
const resolvedConfig = options.alreadyResolved ? config : resolveConfigForEnvironment(config, environment);
|
|
578
|
-
const mergedConfig = {
|
|
579
|
-
...resolvedConfig,
|
|
580
|
-
compatibilityFlags: normalizeCompatibilityFlags(resolvedConfig.compatibilityFlags)
|
|
581
|
-
};
|
|
582
|
-
const result = {
|
|
583
|
-
name: mergedConfig.name,
|
|
584
|
-
compatibility_date: mergedConfig.compatibilityDate,
|
|
585
|
-
preview_urls: true,
|
|
586
|
-
workers_dev: true
|
|
587
|
-
};
|
|
588
|
-
if (mergedConfig.accountId) {
|
|
589
|
-
result.account_id = mergedConfig.accountId;
|
|
590
|
-
}
|
|
591
|
-
const mainEntry = mergedConfig.files?.fetch;
|
|
592
|
-
if (typeof mainEntry === "string") {
|
|
593
|
-
result.main = mainEntry;
|
|
594
|
-
}
|
|
595
|
-
compileModuleOptions(mergedConfig, result);
|
|
596
|
-
if (mergedConfig.compatibilityFlags && mergedConfig.compatibilityFlags.length > 0) {
|
|
597
|
-
result.compatibility_flags = mergedConfig.compatibilityFlags;
|
|
598
|
-
}
|
|
599
|
-
if (mergedConfig.bindings) {
|
|
600
|
-
compileBindings(mergedConfig.bindings, result, options, mergedConfig.secretsStoreId);
|
|
601
|
-
}
|
|
602
|
-
if (mergedConfig.triggers?.crons && mergedConfig.triggers.crons.length > 0) {
|
|
603
|
-
result.triggers = { crons: mergedConfig.triggers.crons };
|
|
604
|
-
}
|
|
605
|
-
if (mergedConfig.tailConsumers && mergedConfig.tailConsumers.length > 0) {
|
|
606
|
-
result.tail_consumers = mergedConfig.tailConsumers.map((consumer) => typeof consumer === "string" ? { service: consumer } : {
|
|
607
|
-
service: consumer.service,
|
|
608
|
-
...consumer.environment && { environment: consumer.environment }
|
|
609
|
-
});
|
|
610
|
-
}
|
|
611
|
-
if (mergedConfig.vars && Object.keys(mergedConfig.vars).length > 0) {
|
|
612
|
-
result.vars = mergedConfig.vars;
|
|
613
|
-
}
|
|
614
|
-
const secrets = toWranglerSecretsConfig(mergedConfig.secrets);
|
|
615
|
-
if (secrets) {
|
|
616
|
-
result.secrets = secrets;
|
|
617
|
-
}
|
|
618
|
-
if (mergedConfig.routes && mergedConfig.routes.length > 0) {
|
|
619
|
-
result.routes = mergedConfig.routes.map((route) => ({
|
|
620
|
-
pattern: route.pattern,
|
|
621
|
-
...route.zone_name && { zone_name: route.zone_name },
|
|
622
|
-
...route.zone_id && { zone_id: route.zone_id },
|
|
623
|
-
...route.custom_domain !== undefined && { custom_domain: route.custom_domain }
|
|
624
|
-
}));
|
|
625
|
-
}
|
|
626
|
-
if (mergedConfig.assets?.directory) {
|
|
627
|
-
result.assets = {
|
|
628
|
-
directory: mergedConfig.assets.directory,
|
|
629
|
-
...mergedConfig.assets.binding && { binding: mergedConfig.assets.binding },
|
|
630
|
-
...mergedConfig.assets.html_handling && {
|
|
631
|
-
html_handling: mergedConfig.assets.html_handling
|
|
632
|
-
},
|
|
633
|
-
...mergedConfig.assets.not_found_handling && {
|
|
634
|
-
not_found_handling: mergedConfig.assets.not_found_handling
|
|
635
|
-
},
|
|
636
|
-
...mergedConfig.assets.run_worker_first !== undefined && {
|
|
637
|
-
run_worker_first: mergedConfig.assets.run_worker_first
|
|
638
|
-
}
|
|
639
|
-
};
|
|
640
|
-
}
|
|
641
|
-
if (mergedConfig.placement) {
|
|
642
|
-
result.placement = mergedConfig.placement;
|
|
643
|
-
}
|
|
644
|
-
if (mergedConfig.observability) {
|
|
645
|
-
result.observability = mergedConfig.observability;
|
|
646
|
-
}
|
|
647
|
-
if (mergedConfig.limits) {
|
|
648
|
-
result.limits = mergedConfig.limits;
|
|
649
|
-
}
|
|
650
|
-
compileContainers(mergedConfig, result);
|
|
651
|
-
if (mergedConfig.migrations && mergedConfig.migrations.length > 0) {
|
|
652
|
-
result.migrations = compileWranglerMigrations(mergedConfig.migrations);
|
|
653
|
-
}
|
|
654
|
-
if (mergedConfig.wrangler?.passthrough) {
|
|
655
|
-
Object.assign(result, mergedConfig.wrangler.passthrough);
|
|
656
|
-
}
|
|
657
|
-
return result;
|
|
658
|
-
}
|
|
659
|
-
function compileToProgrammaticConfig(config, environment, options = {}) {
|
|
660
|
-
return options.preserveNamedBindings ? compileBuildConfig(config, environment) : compileConfig(config, environment);
|
|
661
|
-
}
|
|
662
|
-
// src/config/service-bindings-validation.ts
|
|
663
|
-
class ServiceBindingValidationError extends Error {
|
|
664
|
-
code = "SERVICE_BINDING_VALIDATION_ERROR";
|
|
665
|
-
missing;
|
|
666
|
-
constructor(missing, accountId) {
|
|
667
|
-
super(`Service binding(s) reference worker(s) that do not exist in Cloudflare account ${accountId}: ` + missing.join(", ") + `. Check the 'services' map in devflare.config.ts for typos or deploy the target worker(s) first.`);
|
|
668
|
-
this.name = "ServiceBindingValidationError";
|
|
669
|
-
this.missing = missing;
|
|
670
|
-
}
|
|
671
|
-
}
|
|
672
|
-
function collectReferencedServiceNames(config) {
|
|
673
|
-
const services = config.bindings?.services;
|
|
674
|
-
if (!services) {
|
|
675
|
-
return [];
|
|
676
|
-
}
|
|
677
|
-
const names = new Set;
|
|
678
|
-
for (const binding of Object.values(services)) {
|
|
679
|
-
if (binding && typeof binding === "object" && typeof binding.service === "string") {
|
|
680
|
-
const name = binding.service.trim();
|
|
681
|
-
if (name.length > 0) {
|
|
682
|
-
names.add(name);
|
|
683
|
-
}
|
|
684
|
-
}
|
|
685
|
-
}
|
|
686
|
-
return [...names];
|
|
687
|
-
}
|
|
688
|
-
async function validateServiceBindings(config, accountId, options) {
|
|
689
|
-
const referenced = collectReferencedServiceNames(config);
|
|
690
|
-
if (referenced.length === 0) {
|
|
691
|
-
return;
|
|
692
|
-
}
|
|
693
|
-
const selfName = options.selfWorkerName?.trim();
|
|
694
|
-
const toValidate = selfName ? referenced.filter((name) => name !== selfName) : referenced;
|
|
695
|
-
if (toValidate.length === 0) {
|
|
696
|
-
return;
|
|
697
|
-
}
|
|
698
|
-
const workers = await options.listWorkers(accountId);
|
|
699
|
-
const workerNames = new Set(workers.map((worker) => worker.name));
|
|
700
|
-
const missing = toValidate.filter((name) => !workerNames.has(name));
|
|
701
|
-
if (missing.length > 0) {
|
|
702
|
-
throw new ServiceBindingValidationError(missing, accountId);
|
|
703
|
-
}
|
|
704
|
-
}
|
|
705
|
-
export { applyLocalDevVarsToConfig, stringifyConfig, isolateViteBuildOutputPaths, rebaseWranglerConfigPaths, writeWranglerConfig, readWranglerConfig, compileConfig, compileBuildConfig, compileToProgrammaticConfig, ServiceBindingValidationError, validateServiceBindings };
|