Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
"compatibility_flags": ["nodejs_compat"],
"assets": {
"directory": ".open-next/assets",
"binding": "ASSETS"
}
"binding": "ASSETS",
},
}
File renamed without changes.
11 changes: 3 additions & 8 deletions packages/cloudflare/src/cli/build/utils/create-config-files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,11 @@ import type { ProjectOptions } from "../../project-options.js";
import { askConfirmation } from "../../utils/ask-confirmation.js";

/**
* Creates a `wrangler.json` file for the user if a wrangler config file doesn't already exist,
* Creates a `wrangler.jsonc` 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
*/
export async function createWranglerConfigIfNotExistent(projectOpts: ProjectOptions): Promise<void> {
Expand All @@ -41,7 +36,7 @@ export async function createWranglerConfigIfNotExistent(projectOpts: ProjectOpti
return;
}

let wranglerConfig = readFileSync(join(getPackageTemplatesDirPath(), "wrangler.json"), "utf8");
let wranglerConfig = readFileSync(join(getPackageTemplatesDirPath(), "wrangler.jsonc"), "utf8");

const appName = getAppNameFromPackageJson(projectOpts.sourceDir) ?? "app-name";
if (appName) {
Expand All @@ -56,7 +51,7 @@ export async function createWranglerConfigIfNotExistent(projectOpts: ProjectOpti
);
}

writeFileSync(join(projectOpts.sourceDir, "wrangler.json"), wranglerConfig);
writeFileSync(join(projectOpts.sourceDir, "wrangler.jsonc"), wranglerConfig);
}

function getAppNameFromPackageJson(sourceDir: string): string | undefined {
Expand Down