From 1a43d87db93356209d359b941f08b8f92d1ed60f Mon Sep 17 00:00:00 2001 From: Dario Piotrowicz Date: Thu, 2 Jan 2025 16:03:33 +0100 Subject: [PATCH 01/12] create a wrangler.toml file for the user in case one is not already present --- .changeset/lazy-balloons-report.md | 5 ++ packages/cloudflare/src/cli/build/index.ts | 80 ++++++++++++++++++- .../templates/defaults/wrangler.toml | 7 ++ 3 files changed, 91 insertions(+), 1 deletion(-) create mode 100644 .changeset/lazy-balloons-report.md create mode 100644 packages/cloudflare/templates/defaults/wrangler.toml diff --git a/.changeset/lazy-balloons-report.md b/.changeset/lazy-balloons-report.md new file mode 100644 index 000000000..be5783dfe --- /dev/null +++ b/.changeset/lazy-balloons-report.md @@ -0,0 +1,5 @@ +--- +"@opennextjs/cloudflare": patch +--- + +create a wrangler.toml file for the user in case one is not already presentwq diff --git a/packages/cloudflare/src/cli/build/index.ts b/packages/cloudflare/src/cli/build/index.ts index 925841e54..aa33c68d3 100644 --- a/packages/cloudflare/src/cli/build/index.ts +++ b/packages/cloudflare/src/cli/build/index.ts @@ -1,4 +1,4 @@ -import { cpSync, existsSync } from "node:fs"; +import { cpSync, existsSync, readFileSync, writeFileSync } from "node:fs"; import { createRequire } from "node:module"; import { dirname, join } from "node:path"; @@ -37,6 +37,8 @@ export async function build(projectOpts: ProjectOptions): Promise { const require = createRequire(import.meta.url); const openNextDistDir = dirname(require.resolve("@opennextjs/aws/index.js")); + await createWranglerTomlIfNotExistent(projectOpts); + await createOpenNextConfigIfNotExistent(projectOpts); const { config, buildDir } = await compileOpenNextConfig(baseDir); @@ -178,3 +180,79 @@ function ensureCloudflareConfig(config: OpenNextConfig) { ); } } + +/** + * Creates a `wrangler.toml` file for the user if it doesn't exist, but only after asking for the user's confirmation. + * + * If the user refuses an error is thrown (since the file is mandatory). + * + * @param projectOpts The options for the project + */ +async function createWranglerTomlIfNotExistent(projectOpts: ProjectOptions): Promise { + const wranglerTomlPath = join(projectOpts.sourceDir, "wrangler.toml"); + + if (!existsSync(wranglerTomlPath)) { + const answer = await askConfirmation("Missing required `wrangler.toml` file, do you want to create one?"); + + if (!answer) { + throw new Error("The `wrangler.toml` file is required, aborting!"); + } + + const wranglerTomlTemplate = readFileSync( + join(getPackageTemplatesDirPath(), "defaults", "wrangler.toml"), + "utf8" + ); + let wranglerTomlContent = wranglerTomlTemplate; + + const appName = getAppNameFromPackageJson(projectOpts.sourceDir) ?? "app-name"; + if (appName) { + wranglerTomlContent = wranglerTomlContent.replace( + '"app-name"', + JSON.stringify(appName.replaceAll("_", "-")) + ); + } + + const compatDate = await getLatestCompatDate(); + if (compatDate) { + wranglerTomlContent = wranglerTomlContent.replace( + /compatibility_date = "\d{4}-\d{2}-\d{2}"/, + `compatibility_date = ${JSON.stringify(compatDate)}` + ); + } + + writeFileSync(wranglerTomlPath, wranglerTomlContent); + } +} + +function getAppNameFromPackageJson(sourceDir: string): string | undefined { + try { + const packageJsonStr = readFileSync(join(sourceDir, "package.json"), "utf8"); + const packageJson: Record = JSON.parse(packageJsonStr); + if (typeof packageJson.name === "string") return packageJson.name; + } catch { + /* empty */ + } +} + +export async function getLatestCompatDate(): Promise { + try { + const resp = await fetch(`https://registry.npmjs.org/workerd`); + const latestWorkerdVersion = ( + (await resp.json()) as { + "dist-tags": { latest: string }; + } + )["dist-tags"].latest; + + // The format of the workerd version is `major.yyyymmdd.patch`. + const match = latestWorkerdVersion.match(/\d+\.(\d{4})(\d{2})(\d{2})\.\d+/); + + if (match) { + const [, year, month, date] = match ?? []; + const compatDate = `${year}-${month}-${date}`; + + return compatDate; + } + } catch { + /* empty */ + } +} diff --git a/packages/cloudflare/templates/defaults/wrangler.toml b/packages/cloudflare/templates/defaults/wrangler.toml new file mode 100644 index 000000000..29db9605a --- /dev/null +++ b/packages/cloudflare/templates/defaults/wrangler.toml @@ -0,0 +1,7 @@ +main = ".open-next/worker.js" +name = "app-name" + +compatibility_date = "2024-12-30" +compatibility_flags = ["nodejs_compat"] + +assets = { directory = ".open-next/assets", binding = "ASSETS" } From a28f9976a7c6344ad4788bdb7ca91fa5e9eb5ed5 Mon Sep 17 00:00:00 2001 From: Dario Piotrowicz Date: Thu, 2 Jan 2025 16:56:56 +0100 Subject: [PATCH 02/12] fixup! create a wrangler.toml file for the user in case one is not already present remove unnecessary nullish operator --- packages/cloudflare/src/cli/build/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/cloudflare/src/cli/build/index.ts b/packages/cloudflare/src/cli/build/index.ts index aa33c68d3..2e837356a 100644 --- a/packages/cloudflare/src/cli/build/index.ts +++ b/packages/cloudflare/src/cli/build/index.ts @@ -247,7 +247,7 @@ export async function getLatestCompatDate(): Promise { const match = latestWorkerdVersion.match(/\d+\.(\d{4})(\d{2})(\d{2})\.\d+/); if (match) { - const [, year, month, date] = match ?? []; + const [, year, month, date] = match; const compatDate = `${year}-${month}-${date}`; return compatDate; From 1aa668e2344c4e17775f738649f0b87f87830094 Mon Sep 17 00:00:00 2001 From: Dario Piotrowicz Date: Thu, 2 Jan 2025 17:12:19 +0100 Subject: [PATCH 03/12] fixup! create a wrangler.toml file for the user in case one is not already present create a jsonc file instead of a toml one and check existence of any wrangler config file --- packages/cloudflare/src/cli/build/index.ts | 67 ++++++++++--------- .../templates/defaults/wrangler.jsonc | 12 ++++ .../templates/defaults/wrangler.toml | 7 -- 3 files changed, 49 insertions(+), 37 deletions(-) create mode 100644 packages/cloudflare/templates/defaults/wrangler.jsonc delete mode 100644 packages/cloudflare/templates/defaults/wrangler.toml diff --git a/packages/cloudflare/src/cli/build/index.ts b/packages/cloudflare/src/cli/build/index.ts index 2e837356a..b19684613 100644 --- a/packages/cloudflare/src/cli/build/index.ts +++ b/packages/cloudflare/src/cli/build/index.ts @@ -37,7 +37,7 @@ export async function build(projectOpts: ProjectOptions): Promise { const require = createRequire(import.meta.url); const openNextDistDir = dirname(require.resolve("@opennextjs/aws/index.js")); - await createWranglerTomlIfNotExistent(projectOpts); + await createWranglerConfigIfNotExistent(projectOpts); await createOpenNextConfigIfNotExistent(projectOpts); @@ -182,46 +182,53 @@ function ensureCloudflareConfig(config: OpenNextConfig) { } /** - * Creates a `wrangler.toml` file for the user if it doesn't exist, but only after asking for the user's confirmation. + * Creates a `wrangler.jsonc` file for the user if it doesn't exist, but only after asking for the user's confirmation. * * If the user refuses an error is thrown (since the file is mandatory). * * @param projectOpts The options for the project */ -async function createWranglerTomlIfNotExistent(projectOpts: ProjectOptions): Promise { - const wranglerTomlPath = join(projectOpts.sourceDir, "wrangler.toml"); +async function createWranglerConfigIfNotExistent(projectOpts: ProjectOptions): Promise { + const possibleExts = ["toml", "json", "jsonc"]; + + const wranglerConfigFileExists = possibleExts.some((ext) => + existsSync(join(projectOpts.sourceDir, `wrangler.${ext}`)) + ); + if (wranglerConfigFileExists) { + return; + } - if (!existsSync(wranglerTomlPath)) { - const answer = await askConfirmation("Missing required `wrangler.toml` file, do you want to create one?"); + const wranglerConfigPath = join(projectOpts.sourceDir, "wrangler.jsonc"); - if (!answer) { - throw new Error("The `wrangler.toml` file is required, aborting!"); - } + const answer = await askConfirmation("Missing required Wrangler config file, do you want to create one?"); - const wranglerTomlTemplate = readFileSync( - join(getPackageTemplatesDirPath(), "defaults", "wrangler.toml"), - "utf8" - ); - let wranglerTomlContent = wranglerTomlTemplate; - - const appName = getAppNameFromPackageJson(projectOpts.sourceDir) ?? "app-name"; - if (appName) { - wranglerTomlContent = wranglerTomlContent.replace( - '"app-name"', - JSON.stringify(appName.replaceAll("_", "-")) - ); - } + if (!answer) { + console.warn("No Wrangler config file created"); + } - const compatDate = await getLatestCompatDate(); - if (compatDate) { - wranglerTomlContent = wranglerTomlContent.replace( - /compatibility_date = "\d{4}-\d{2}-\d{2}"/, - `compatibility_date = ${JSON.stringify(compatDate)}` - ); - } + const wranglerConfigTemplate = readFileSync( + join(getPackageTemplatesDirPath(), "defaults", "wrangler.jsonc"), + "utf8" + ); + let wranglerConfigContent = wranglerConfigTemplate; + + const appName = getAppNameFromPackageJson(projectOpts.sourceDir) ?? "app-name"; + if (appName) { + wranglerConfigContent = wranglerConfigContent.replace( + '"app-name"', + JSON.stringify(appName.replaceAll("_", "-")) + ); + } - writeFileSync(wranglerTomlPath, wranglerTomlContent); + const compatDate = await getLatestCompatDate(); + if (compatDate) { + wranglerConfigContent = wranglerConfigContent.replace( + /"compatibility_date": "\d{4}-\d{2}-\d{2}"/, + `"compatibility_date": ${JSON.stringify(compatDate)}` + ); } + + writeFileSync(wranglerConfigPath, wranglerConfigContent); } function getAppNameFromPackageJson(sourceDir: string): string | undefined { diff --git a/packages/cloudflare/templates/defaults/wrangler.jsonc b/packages/cloudflare/templates/defaults/wrangler.jsonc new file mode 100644 index 000000000..e6852356f --- /dev/null +++ b/packages/cloudflare/templates/defaults/wrangler.jsonc @@ -0,0 +1,12 @@ +{ + "main": ".open-next/worker.js", + "name": "app-name", + "compatibility_date": "2024-12-30", + "compatibility_flags": [ + "nodejs_compat" + ], + "assets": { + "directory": ".open-next/assets", + "binding": "ASSETS" + } +} \ No newline at end of file diff --git a/packages/cloudflare/templates/defaults/wrangler.toml b/packages/cloudflare/templates/defaults/wrangler.toml deleted file mode 100644 index 29db9605a..000000000 --- a/packages/cloudflare/templates/defaults/wrangler.toml +++ /dev/null @@ -1,7 +0,0 @@ -main = ".open-next/worker.js" -name = "app-name" - -compatibility_date = "2024-12-30" -compatibility_flags = ["nodejs_compat"] - -assets = { directory = ".open-next/assets", binding = "ASSETS" } From bb30c393f9135d29a896262c6d60c20b93a0b1eb Mon Sep 17 00:00:00 2001 From: Dario Piotrowicz Date: Thu, 2 Jan 2025 17:15:23 +0100 Subject: [PATCH 04/12] fixup! create a wrangler.toml file for the user in case one is not already present add a comment for the cache kv binding --- packages/cloudflare/templates/defaults/wrangler.jsonc | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/cloudflare/templates/defaults/wrangler.jsonc b/packages/cloudflare/templates/defaults/wrangler.jsonc index e6852356f..b60620fb1 100644 --- a/packages/cloudflare/templates/defaults/wrangler.jsonc +++ b/packages/cloudflare/templates/defaults/wrangler.jsonc @@ -8,5 +8,13 @@ "assets": { "directory": ".open-next/assets", "binding": "ASSETS" - } + }, + "kv_namespaces": [ + // Create a KV binding with the binding name "NEXT_CACHE_WORKERS_KV" + // to enable the KV based caching: + // { + // "binding": "NEXT_CACHE_WORKERS_KV", + // "id": "" + // } + ] } \ No newline at end of file From 5046cb076bd6823e920167695e13033e567ae46d Mon Sep 17 00:00:00 2001 From: Dario Piotrowicz Date: Thu, 2 Jan 2025 17:19:23 +0100 Subject: [PATCH 05/12] fixup! create a wrangler.toml file for the user in case one is not already present fix jsonc prettier formatting --- packages/cloudflare/templates/defaults/wrangler.jsonc | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/packages/cloudflare/templates/defaults/wrangler.jsonc b/packages/cloudflare/templates/defaults/wrangler.jsonc index b60620fb1..c25ff3d30 100644 --- a/packages/cloudflare/templates/defaults/wrangler.jsonc +++ b/packages/cloudflare/templates/defaults/wrangler.jsonc @@ -2,12 +2,10 @@ "main": ".open-next/worker.js", "name": "app-name", "compatibility_date": "2024-12-30", - "compatibility_flags": [ - "nodejs_compat" - ], + "compatibility_flags": ["nodejs_compat"], "assets": { "directory": ".open-next/assets", - "binding": "ASSETS" + "binding": "ASSETS", }, "kv_namespaces": [ // Create a KV binding with the binding name "NEXT_CACHE_WORKERS_KV" @@ -16,5 +14,5 @@ // "binding": "NEXT_CACHE_WORKERS_KV", // "id": "" // } - ] -} \ No newline at end of file + ], +} From 5d1d2c92b878d3106327b30d76ae78af34ae4818 Mon Sep 17 00:00:00 2001 From: Dario Piotrowicz Date: Thu, 2 Jan 2025 17:49:58 +0100 Subject: [PATCH 06/12] fixup! create a wrangler.toml file for the user in case one is not already present fix broken logic and add way to opt out of wrangler config check --- packages/cloudflare/env.d.ts | 1 + packages/cloudflare/src/cli/args.ts | 10 +++++++++- packages/cloudflare/src/cli/build/index.ts | 17 +++++++++++++---- packages/cloudflare/src/cli/config.ts | 2 ++ packages/cloudflare/src/cli/index.ts | 3 ++- 5 files changed, 27 insertions(+), 6 deletions(-) diff --git a/packages/cloudflare/env.d.ts b/packages/cloudflare/env.d.ts index 8303fb30c..f7dbe9690 100644 --- a/packages/cloudflare/env.d.ts +++ b/packages/cloudflare/env.d.ts @@ -3,6 +3,7 @@ declare global { interface ProcessEnv { __NEXT_PRIVATE_STANDALONE_CONFIG?: string; SKIP_NEXT_APP_BUILD?: string; + SKIP_WRANGLER_CONFIG_CHECK?: string; NEXT_PRIVATE_DEBUG_CACHE?: string; OPEN_NEXT_ORIGIN: string; NODE_ENV?: string; diff --git a/packages/cloudflare/src/cli/args.ts b/packages/cloudflare/src/cli/args.ts index 3dd226b9d..f64d0d731 100644 --- a/packages/cloudflare/src/cli/args.ts +++ b/packages/cloudflare/src/cli/args.ts @@ -4,10 +4,11 @@ import { parseArgs } from "node:util"; export function getArgs(): { skipNextBuild: boolean; + skipWranglerConfigCheck: boolean; outputDir?: string; minify: boolean; } { - const { skipBuild, output, noMinify } = parseArgs({ + const { skipBuild, skipWranglerConfigCheck, output, noMinify } = parseArgs({ options: { skipBuild: { type: "boolean", @@ -22,6 +23,10 @@ export function getArgs(): { type: "boolean", default: false, }, + skipWranglerConfigCheck: { + type: "boolean", + default: false, + }, }, allowPositionals: false, }).values; @@ -35,6 +40,9 @@ export function getArgs(): { return { outputDir, skipNextBuild: skipBuild || ["1", "true", "yes"].includes(String(process.env.SKIP_NEXT_APP_BUILD)), + skipWranglerConfigCheck: + skipWranglerConfigCheck || + ["1", "true", "yes"].includes(String(process.env.SKIP_WRANGLER_CONFIG_CHECK)), minify: !noMinify, }; } diff --git a/packages/cloudflare/src/cli/build/index.ts b/packages/cloudflare/src/cli/build/index.ts index b19684613..182074aed 100644 --- a/packages/cloudflare/src/cli/build/index.ts +++ b/packages/cloudflare/src/cli/build/index.ts @@ -37,8 +37,6 @@ export async function build(projectOpts: ProjectOptions): Promise { const require = createRequire(import.meta.url); const openNextDistDir = dirname(require.resolve("@opennextjs/aws/index.js")); - await createWranglerConfigIfNotExistent(projectOpts); - await createOpenNextConfigIfNotExistent(projectOpts); const { config, buildDir } = await compileOpenNextConfig(baseDir); @@ -103,6 +101,10 @@ export async function build(projectOpts: ProjectOptions): Promise { // TODO: rely on options only. await bundleServer(projConfig, options); + if (!projectOpts.skipWranglerConfigCheck) { + await createWranglerConfigIfNotExistent(projectOpts); + } + logger.info("OpenNext build complete."); } @@ -200,10 +202,17 @@ async function createWranglerConfigIfNotExistent(projectOpts: ProjectOptions): P const wranglerConfigPath = join(projectOpts.sourceDir, "wrangler.jsonc"); - const answer = await askConfirmation("Missing required Wrangler config file, do you want to create one?"); + const answer = await askConfirmation( + "No `wrangler.(toml|json|jsonc)` config file found, do you want to create one?" + ); if (!answer) { - console.warn("No Wrangler config file created"); + console.warn( + "No Wrangler config file created" + + "\n" + + "(to avoid this check use the `--skipWranglerConfigCheck` flag or set a `SKIP_WRANGLER_CONFIG_CHECK` environment variable to `yes`)" + ); + return; } const wranglerConfigTemplate = readFileSync( diff --git a/packages/cloudflare/src/cli/config.ts b/packages/cloudflare/src/cli/config.ts index e08889948..6f0884f22 100644 --- a/packages/cloudflare/src/cli/config.ts +++ b/packages/cloudflare/src/cli/config.ts @@ -114,6 +114,8 @@ export type ProjectOptions = { outputDir: string; // Whether the Next.js build should be skipped (i.e. if the `.next` dir is already built) skipNextBuild: boolean; + // Whether the check to see if a wrangler config file exists should be skipped + skipWranglerConfigCheck: boolean; // Whether minification of the worker should be enabled minify: boolean; }; diff --git a/packages/cloudflare/src/cli/index.ts b/packages/cloudflare/src/cli/index.ts index 1993389ac..74d96f344 100644 --- a/packages/cloudflare/src/cli/index.ts +++ b/packages/cloudflare/src/cli/index.ts @@ -6,11 +6,12 @@ import { build } from "./build/index.js"; const nextAppDir = process.cwd(); -const { skipNextBuild, outputDir, minify } = getArgs(); +const { skipNextBuild, skipWranglerConfigCheck, outputDir, minify } = getArgs(); await build({ sourceDir: nextAppDir, outputDir: resolve(outputDir ?? nextAppDir, ".open-next"), skipNextBuild, + skipWranglerConfigCheck, minify, }); From 45e4ce1a04ed2c1674893f263c44202dc30bf16e Mon Sep 17 00:00:00 2001 From: Dario Piotrowicz Date: Thu, 2 Jan 2025 17:53:19 +0100 Subject: [PATCH 07/12] fixup! create a wrangler.toml file for the user in case one is not already present fix typo and update changeset --- .changeset/lazy-balloons-report.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/.changeset/lazy-balloons-report.md b/.changeset/lazy-balloons-report.md index be5783dfe..8eb35e172 100644 --- a/.changeset/lazy-balloons-report.md +++ b/.changeset/lazy-balloons-report.md @@ -2,4 +2,8 @@ "@opennextjs/cloudflare": patch --- -create a wrangler.toml file for the user in case one is not already presentwq +checks and creates a wrangler.jsonc file for the user in case one 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 +want to use custom names for their config files) From 360fc222348df93c19fc874f95b7d2354aeed38d Mon Sep 17 00:00:00 2001 From: Dario Piotrowicz Date: Thu, 2 Jan 2025 17:56:11 +0100 Subject: [PATCH 08/12] fixup! create a wrangler.toml file for the user in case one is not already present update changeset --- .changeset/lazy-balloons-report.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/lazy-balloons-report.md b/.changeset/lazy-balloons-report.md index 8eb35e172..f19894233 100644 --- a/.changeset/lazy-balloons-report.md +++ b/.changeset/lazy-balloons-report.md @@ -2,7 +2,7 @@ "@opennextjs/cloudflare": patch --- -checks and creates a wrangler.jsonc file for the user in case one wrangler.(toml|json|jsonc) file is not already present +checks and creates a `wrangler.jsonc` 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 From ffbc477842fbe29b8c051d8a8aab52cfa546292c Mon Sep 17 00:00:00 2001 From: Dario Piotrowicz Date: Thu, 2 Jan 2025 17:56:24 +0100 Subject: [PATCH 09/12] fixup! create a wrangler.toml file for the user in case one is not already present update changeset --- .changeset/lazy-balloons-report.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/lazy-balloons-report.md b/.changeset/lazy-balloons-report.md index f19894233..34081b4ce 100644 --- a/.changeset/lazy-balloons-report.md +++ b/.changeset/lazy-balloons-report.md @@ -2,7 +2,7 @@ "@opennextjs/cloudflare": patch --- -checks and creates a `wrangler.jsonc` file for the user in case a `wrangler.(toml|json|jsonc)` file is not already present +check and create a `wrangler.jsonc` 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 From b6964c192d874503b2136f83205b4abaf1e673e8 Mon Sep 17 00:00:00 2001 From: Dario Piotrowicz Date: Thu, 2 Jan 2025 18:19:25 +0100 Subject: [PATCH 10/12] fixup! create a wrangler.toml file for the user in case one is not already present update outdated code comment --- packages/cloudflare/src/cli/build/index.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/cloudflare/src/cli/build/index.ts b/packages/cloudflare/src/cli/build/index.ts index 182074aed..ee169dc0f 100644 --- a/packages/cloudflare/src/cli/build/index.ts +++ b/packages/cloudflare/src/cli/build/index.ts @@ -184,9 +184,10 @@ function ensureCloudflareConfig(config: OpenNextConfig) { } /** - * Creates a `wrangler.jsonc` file for the user if it doesn't exist, but only after asking for the user's confirmation. + * 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 an error is thrown (since the file is mandatory). + * If the user refuses a warning is shown (which offers ways to opt out of this check to the user). * * @param projectOpts The options for the project */ From 4ed2a26729d4cd07d1cceed88fef42408d79ca36 Mon Sep 17 00:00:00 2001 From: Dario Piotrowicz Date: Thu, 2 Jan 2025 19:21:01 +0100 Subject: [PATCH 11/12] fixup! create a wrangler.toml file for the user in case one is not already present update changeset --- .changeset/lazy-balloons-report.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.changeset/lazy-balloons-report.md b/.changeset/lazy-balloons-report.md index 34081b4ce..72a7a1334 100644 --- a/.changeset/lazy-balloons-report.md +++ b/.changeset/lazy-balloons-report.md @@ -6,4 +6,4 @@ check and create a `wrangler.jsonc` file for the user in case a `wrangler.(toml| 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 -want to use custom names for their config files) +want to use custom locations for their config files) From 470f24bf7a80c6fe2bb514add1210e75eb0007db Mon Sep 17 00:00:00 2001 From: Dario Piotrowicz Date: Thu, 2 Jan 2025 19:33:37 +0100 Subject: [PATCH 12/12] fixup! create a wrangler.toml file for the user in case one is not already present remove wrangler.jsonc problematic trailing commas --- .prettierrc | 11 ++++++++++- packages/cloudflare/templates/defaults/wrangler.jsonc | 4 ++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.prettierrc b/.prettierrc index 0adf1369d..3c424851a 100644 --- a/.prettierrc +++ b/.prettierrc @@ -4,5 +4,14 @@ "semi": true, "useTabs": false, "tabWidth": 2, - "trailingComma": "es5" + "trailingComma": "es5", + "overrides": [ + { + "// comment": "wrangler doesn't seem to accept wrangler.jsonc with trailing commas", + "files": ["**/wrangler.jsonc"], + "options": { + "trailingComma": "none" + } + } + ] } diff --git a/packages/cloudflare/templates/defaults/wrangler.jsonc b/packages/cloudflare/templates/defaults/wrangler.jsonc index c25ff3d30..40ab59b9c 100644 --- a/packages/cloudflare/templates/defaults/wrangler.jsonc +++ b/packages/cloudflare/templates/defaults/wrangler.jsonc @@ -5,7 +5,7 @@ "compatibility_flags": ["nodejs_compat"], "assets": { "directory": ".open-next/assets", - "binding": "ASSETS", + "binding": "ASSETS" }, "kv_namespaces": [ // Create a KV binding with the binding name "NEXT_CACHE_WORKERS_KV" @@ -14,5 +14,5 @@ // "binding": "NEXT_CACHE_WORKERS_KV", // "id": "" // } - ], + ] }