From f7399c7a3124da52d9affe82f677300adb4d04fa Mon Sep 17 00:00:00 2001 From: Xavier Rutayisire Date: Mon, 30 Oct 2023 10:29:30 +0100 Subject: [PATCH] feat(Next): Support Next.js 14 --- cypress-setup.sh | 2 +- packages/adapter-next/package.json | 2 +- packages/init/src/lib/framework.ts | 12 ++++++------ ...eMachineInitProcess-detectEnvironment.test.ts | 16 ++++++++-------- .../src/legacyMigrations/detectFramework.ts | 8 ++++---- yarn.lock | 2 +- 6 files changed, 21 insertions(+), 21 deletions(-) diff --git a/cypress-setup.sh b/cypress-setup.sh index eab1408fcd..c702fc82aa 100755 --- a/cypress-setup.sh +++ b/cypress-setup.sh @@ -26,7 +26,7 @@ else fi rm -rf e2e-projects/cypress-next-app \ -&& yarn dlx --quiet create-next-app@13.5.4 --app --eslint --import-alias '@/*' --no-src-dir --tailwind --typescript --use-npm e2e-projects/cypress-next-app \ +&& yarn dlx --quiet create-next-app@latest --app --eslint --import-alias '@/*' --no-src-dir --tailwind --typescript --use-npm e2e-projects/cypress-next-app \ && yarn dlx --quiet vite-node ./cypress/plugins/addAuth.ts -- ${EMAIL} ${PASSWORD} ${PRISMIC_URL} \ && yarn dlx --quiet vite-node ./cypress/plugins/createRepo.ts -- "${_PRISMIC_REPO}" "${PASSWORD}" "${PRISMIC_URL}" \ && yarn workspaces foreach --include '{@slicemachine/adapter-next,@slicemachine/init,@slicemachine/manager,@slicemachine/plugin-kit,slice-machine-ui,start-slicemachine}' --topological --verbose pack --out "${THIS_DIR}"/e2e-projects/cypress-next-app/%s-%v.tgz \ diff --git a/packages/adapter-next/package.json b/packages/adapter-next/package.json index 6d60e24f7d..841a1b8934 100644 --- a/packages/adapter-next/package.json +++ b/packages/adapter-next/package.json @@ -97,7 +97,7 @@ "vitest": "0.32.0" }, "peerDependencies": { - "next": "^11 || ^12 || ^13", + "next": ">=11.0.0", "react": "^17 || ^18" }, "engines": { diff --git a/packages/init/src/lib/framework.ts b/packages/init/src/lib/framework.ts index 892f6604e7..21ba5b0587 100644 --- a/packages/init/src/lib/framework.ts +++ b/packages/init/src/lib/framework.ts @@ -16,7 +16,7 @@ export type Framework = { * Framework 's id sent to Segment from Slice Machine */ sliceMachineTelemetryID: - | "next-11-13" + | "next" | "nuxt-2" | "nuxt-3" | "sveltekit-1" @@ -97,14 +97,14 @@ export const FRAMEWORKS: Record = { "@slicemachine/adapter-nuxt": isPrerelease ? "alpha" : "latest", }, }, - "next-11-13": { - name: "Next.js 11-13", - sliceMachineTelemetryID: "next-11-13", + next: { + name: "Next.js", + sliceMachineTelemetryID: "next", wroomTelemetryID: "next", - prismicDocumentation: "https://prismic.dev/init/next-11-13", + prismicDocumentation: "https://prismic.dev/init/next", adapterName: "@slicemachine/adapter-next", compatibility: { - next: "^11.0.0 || ^12.0.0 || ^13.0.0", + next: ">=11.0.0", }, devDependencies: { ...DEFAULT_DEV_DEPENDENCIES, diff --git a/packages/init/test/SliceMachineInitProcess-detectEnvironment.test.ts b/packages/init/test/SliceMachineInitProcess-detectEnvironment.test.ts index cb283324e8..ab08446944 100644 --- a/packages/init/test/SliceMachineInitProcess-detectEnvironment.test.ts +++ b/packages/init/test/SliceMachineInitProcess-detectEnvironment.test.ts @@ -35,15 +35,15 @@ it("detects framework, starter and package manager", async () => { "framework": { "adapterName": "@slicemachine/adapter-next", "compatibility": { - "next": "^11.0.0 || ^12.0.0 || ^13.0.0", + "next": ">=11.0.0", }, "devDependencies": { "@slicemachine/adapter-next": "latest", "slice-machine-ui": "latest", }, - "name": "Next.js 11-13", - "prismicDocumentation": "https://prismic.dev/init/next-11-13", - "sliceMachineTelemetryID": "next-11-13", + "name": "Next.js", + "prismicDocumentation": "https://prismic.dev/init/next", + "sliceMachineTelemetryID": "next", "wroomTelemetryID": "next", }, "packageManager": "npm", @@ -82,15 +82,15 @@ it("assumes unconventional tags match semver range when detecting framework", as "framework": { "adapterName": "@slicemachine/adapter-next", "compatibility": { - "next": "^11.0.0 || ^12.0.0 || ^13.0.0", + "next": ">=11.0.0", }, "devDependencies": { "@slicemachine/adapter-next": "latest", "slice-machine-ui": "latest", }, - "name": "Next.js 11-13", - "prismicDocumentation": "https://prismic.dev/init/next-11-13", - "sliceMachineTelemetryID": "next-11-13", + "name": "Next.js", + "prismicDocumentation": "https://prismic.dev/init/next", + "sliceMachineTelemetryID": "next", "wroomTelemetryID": "next", }, "packageManager": "npm", diff --git a/packages/start-slicemachine/src/legacyMigrations/detectFramework.ts b/packages/start-slicemachine/src/legacyMigrations/detectFramework.ts index d4d1d6d76e..0ec26ec57a 100644 --- a/packages/start-slicemachine/src/legacyMigrations/detectFramework.ts +++ b/packages/start-slicemachine/src/legacyMigrations/detectFramework.ts @@ -58,22 +58,22 @@ export const FRAMEWORKS: Record = { }, }, previousNext: { - name: "Next.js 11-13 (legacy)", + name: "Next.js (legacy)", adapterName: "@slicemachine/adapter-next", adapterVersion: "latest", runProjectInitHook: true, compatibility: { - next: "^11.0.0 || ^12.0.0 || ^13.0.0", + next: ">=11.0.0", "prismic-reactjs": "*", }, }, next: { - name: "Next.js 11-13", + name: "Next.js", adapterName: "@slicemachine/adapter-next", adapterVersion: "latest", runProjectInitHook: false, compatibility: { - next: "^11.0.0 || ^12.0.0 || ^13.0.0", + next: ">=11.0.0", }, }, } as const; diff --git a/yarn.lock b/yarn.lock index 9c4419ed3b..5911c78dc2 100644 --- a/yarn.lock +++ b/yarn.lock @@ -8196,7 +8196,7 @@ __metadata: vite-plugin-sdk: 0.1.1 vitest: 0.32.0 peerDependencies: - next: ^11 || ^12 || ^13 + next: ">=11.0.0" react: ^17 || ^18 languageName: unknown linkType: soft