Skip to content

Commit 0c655c3

Browse files
authored
refactor: do not create a wrangler config when a custom one is passed (#948)
1 parent 98f0dd3 commit 0c655c3

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

.changeset/thick-seas-walk.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@opennextjs/cloudflare": patch
3+
---
4+
5+
refactor: do not create a wrangler config when a custom one is passed

packages/cloudflare/src/cli/build/build.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ import { compileInit } from "./open-next/compile-init.js";
1717
import { compileSkewProtection } from "./open-next/compile-skew-protection.js";
1818
import { compileDurableObjects } from "./open-next/compileDurableObjects.js";
1919
import { createServerBundle } from "./open-next/createServerBundle.js";
20-
import { createWranglerConfigIfNotExistent } from "./utils/index.js";
2120
import { getVersion } from "./utils/version.js";
2221

2322
/**
@@ -87,10 +86,6 @@ export async function build(
8786

8887
await bundleServer(options, projectOpts);
8988

90-
if (!projectOpts.skipWranglerConfigCheck) {
91-
await createWranglerConfigIfNotExistent(projectOpts);
92-
}
93-
9489
logger.info("OpenNext build complete.");
9590
}
9691

packages/cloudflare/src/cli/commands/build.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type yargs from "yargs";
22

33
import { build as buildImpl } from "../build/build.js";
4+
import { createWranglerConfigIfNotExistent } from "../build/utils/index.js";
45
import type { WithWranglerArgs } from "./utils.js";
56
import {
67
compileConfig,
@@ -30,14 +31,18 @@ async function buildCommand(
3031
const { config, buildDir } = await compileConfig(args.openNextConfigPath);
3132
const options = getNormalizedOptions(config, buildDir);
3233

34+
const projectOpts = { ...args, minify: !args.noMinify, sourceDir: nextAppDir };
35+
36+
// Ask whether a `wrangler.jsonc` should be created when no config file exists.
37+
// Note: We don't ask when a custom config file is specified via `--config`
38+
// nor when `--skipWranglerConfigCheck` is used.
39+
if (!projectOpts.wranglerConfigPath && !args.skipWranglerConfigCheck) {
40+
await createWranglerConfigIfNotExistent(projectOpts);
41+
}
42+
3343
const wranglerConfig = readWranglerConfig(args);
3444

35-
await buildImpl(
36-
options,
37-
config,
38-
{ ...args, minify: !args.noMinify, sourceDir: nextAppDir },
39-
wranglerConfig
40-
);
45+
await buildImpl(options, config, projectOpts, wranglerConfig);
4146
}
4247

4348
/**

0 commit comments

Comments
 (0)