diff --git a/.changeset/lazy-balloons-report.md b/.changeset/lazy-balloons-report.md index 72a7a133..9c6bbd6c 100644 --- a/.changeset/lazy-balloons-report.md +++ b/.changeset/lazy-balloons-report.md @@ -2,7 +2,7 @@ "@opennextjs/cloudflare": patch --- -check and create a `wrangler.jsonc` file for the user in case a `wrangler.(toml|json|jsonc)` file is not already present +check and create a `wrangler.json` file for the user in case a `wrangler.(toml|json|jsonc)` file is not already present also introduce a new `--skipWranglerConfigCheck` cli flag and a `SKIP_WRANGLER_CONFIG_CHECK` environment variable that allows users to opt out of the above check (since developers might diff --git a/packages/cloudflare/src/cli/build/index.ts b/packages/cloudflare/src/cli/build/index.ts index ee169dc0..6d96aa49 100644 --- a/packages/cloudflare/src/cli/build/index.ts +++ b/packages/cloudflare/src/cli/build/index.ts @@ -184,11 +184,16 @@ function ensureCloudflareConfig(config: OpenNextConfig) { } /** - * Creates a `wrangler.jsonc` file for the user if a wrangler config file doesn't already exist, + * Creates a `wrangler.json` file for the user if a wrangler config file doesn't already exist, * but only after asking for the user's confirmation. * * If the user refuses a warning is shown (which offers ways to opt out of this check to the user). * + * Note: we generate a wrangler.json file with comments instead of using the jsonc extension, + * we decided to do that since json is more common than jsonc, wrangler also parses + * them in the same way and we also expect developers to associate `wrangler.json` + * files to the jsonc language + * * @param projectOpts The options for the project */ async function createWranglerConfigIfNotExistent(projectOpts: ProjectOptions): Promise { @@ -201,8 +206,6 @@ async function createWranglerConfigIfNotExistent(projectOpts: ProjectOptions): P return; } - const wranglerConfigPath = join(projectOpts.sourceDir, "wrangler.jsonc"); - const answer = await askConfirmation( "No `wrangler.(toml|json|jsonc)` config file found, do you want to create one?" ); @@ -238,7 +241,7 @@ async function createWranglerConfigIfNotExistent(projectOpts: ProjectOptions): P ); } - writeFileSync(wranglerConfigPath, wranglerConfigContent); + writeFileSync(join(projectOpts.sourceDir, "wrangler.json"), wranglerConfigContent); } function getAppNameFromPackageJson(sourceDir: string): string | undefined {