From 0fbfbda4d0fe096eb957400548fac6dfc64fcecb Mon Sep 17 00:00:00 2001 From: Dario Piotrowicz Date: Wed, 11 Dec 2024 10:10:25 +0000 Subject: [PATCH] make the Next.js experimental template use a specific version of the create-next-app cli --- packages/create-cloudflare/src/frameworks/index.ts | 4 +++- packages/create-cloudflare/src/templates.ts | 13 +++++++++---- .../templates-experimental/next/c3.ts | 4 ++++ 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/packages/create-cloudflare/src/frameworks/index.ts b/packages/create-cloudflare/src/frameworks/index.ts index 5ba831072e34..271c6ab732e9 100644 --- a/packages/create-cloudflare/src/frameworks/index.ts +++ b/packages/create-cloudflare/src/frameworks/index.ts @@ -12,7 +12,9 @@ export const getFrameworkCli = (ctx: C3Context, withVersion = true) => { const frameworkCli = ctx.template .frameworkCli as keyof typeof frameworksPackageJson.dependencies; - const version = frameworksPackageJson.dependencies[frameworkCli]; + const version = + ctx.template.frameworkCliVersion ?? + frameworksPackageJson.dependencies[frameworkCli]; return withVersion ? `${frameworkCli}@${version}` : frameworkCli; }; diff --git a/packages/create-cloudflare/src/templates.ts b/packages/create-cloudflare/src/templates.ts index 1679e9068c6f..80b687472f99 100644 --- a/packages/create-cloudflare/src/templates.ts +++ b/packages/create-cloudflare/src/templates.ts @@ -65,16 +65,21 @@ export type TemplateConfig = { * to handle config version skew between different versions of c3 */ configVersion: number; - /** The id by which template is referred to internally and keyed in lookup maps*/ + /** The id by which template is referred to internally and keyed in lookup maps */ id: string; - /** A string that controls how the template is presented to the user in the selection menu*/ + /** A string that controls how the template is presented to the user in the selection menu */ displayName: string; - /** A string that explains what is inside the template, including any resources and how those will be used*/ + /** A string that explains what is inside the template, including any resources and how those will be used */ description?: string; /** The deployment platform for this template */ platform: "workers" | "pages"; - /** The name of the framework cli tool that is used to generate this project or undefined if none. */ + /** The name of the framework cli tool that is used to generate this project or undefined if none */ frameworkCli?: string; + /** + * The version of the framework cli tool to use. + * If omitted the cli version is taken from src/frameworks/package.json, which is the default/standard behavior. + */ + frameworkCliVersion?: string; /** When set to true, hides this template from the selection menu */ hidden?: boolean; /** Specifies a set of files that will be copied to the project directory during creation. diff --git a/packages/create-cloudflare/templates-experimental/next/c3.ts b/packages/create-cloudflare/templates-experimental/next/c3.ts index 94e6274c00e8..91d9dd34fc15 100644 --- a/packages/create-cloudflare/templates-experimental/next/c3.ts +++ b/packages/create-cloudflare/templates-experimental/next/c3.ts @@ -30,6 +30,10 @@ export default { configVersion: 1, id: "next", frameworkCli: "create-next-app", + // TODO: here we need to specify a version of create-next-app which is different from the + // standard one used in the stable Next.js template, that's because our open-next adapter + // is not yet fully ready for Next.js 15, once it is we should remove the following + frameworkCliVersion: "14.2.5", platform: "workers", displayName: "Next (using Node.js compat + Workers Assets)", path: "templates-experimental/next",