mirror of
https://github.com/shishantbiswas/bknd.git
synced 2026-03-16 04:27:21 +00:00
fix: fix wrangler platform proxy handling
Modified the external dependencies in the build configuration to include "bknd" and its submodules. Added a new asynchronous function to handle platform proxy options, improving error handling for the "wrangler" import and providing clearer logging for version resolution. Additionally, ensured that the schema manager skips processing for tables without names.
This commit is contained in:
@@ -18,6 +18,27 @@ export type WithPlatformProxyOptions = {
|
||||
proxyOptions?: GetPlatformProxyOptions;
|
||||
};
|
||||
|
||||
async function getPlatformProxy(opts?: GetPlatformProxyOptions) {
|
||||
try {
|
||||
const { version } = await import("wrangler/package.json", { with: { type: "json" } });
|
||||
$console.log("Using wrangler version", version);
|
||||
const { getPlatformProxy } = await import("wrangler");
|
||||
return getPlatformProxy(opts);
|
||||
} catch (e) {
|
||||
$console.error("Failed to import wrangler", String(e));
|
||||
const resolved = import.meta.resolve("wrangler");
|
||||
$console.log("Wrangler resolved to", resolved);
|
||||
const file = resolved?.split("/").pop();
|
||||
if (file?.endsWith(".json")) {
|
||||
$console.error(
|
||||
"You have a `wrangler.json` in your current directory. Please change to .jsonc or .toml",
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
process.exit(1);
|
||||
}
|
||||
|
||||
export function withPlatformProxy<Env extends CloudflareEnv>(
|
||||
config: CloudflareBkndConfig<Env> = {},
|
||||
opts?: WithPlatformProxyOptions,
|
||||
@@ -31,7 +52,6 @@ export function withPlatformProxy<Env extends CloudflareEnv>(
|
||||
async function getEnv(env?: Env): Promise<Env> {
|
||||
if (use_proxy) {
|
||||
if (!proxy) {
|
||||
const getPlatformProxy = await import("wrangler").then((mod) => mod.getPlatformProxy);
|
||||
proxy = await getPlatformProxy(opts?.proxyOptions);
|
||||
process.on("exit", () => {
|
||||
proxy?.dispose();
|
||||
|
||||
Reference in New Issue
Block a user