From 2fedacf4d20fd00d49094f2e53f9c2580eb9145c Mon Sep 17 00:00:00 2001 From: Louis DeScioli Date: Tue, 15 Mar 2022 00:57:45 -0500 Subject: [PATCH 1/4] fix: print full publish dir path when build not found --- src/helpers/verification.ts | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/helpers/verification.ts b/src/helpers/verification.ts index caa91fbdbf..b879a65486 100644 --- a/src/helpers/verification.ts +++ b/src/helpers/verification.ts @@ -68,10 +68,7 @@ export const checkNextSiteHasBuilt = ({ : `In most cases it should be set to ".next", unless you have chosen a custom "distDir" in your Next config.` return failBuild(outdent` - The directory "${path.relative( - process.cwd(), - publish, - )}" does not contain a Next.js production build. Perhaps the build command was not run, or you specified the wrong publish directory. + The directory "${publish}" does not contain a Next.js production build. Perhaps the build command was not run, or you specified the wrong publish directory. ${outWarning} If you are using "next export" then you should set the environment variable NETLIFY_NEXT_PLUGIN_SKIP to "true". `) @@ -93,7 +90,7 @@ export const checkForRootPublish = ({ }): void | never => { if (path.resolve(publish) === path.resolve('.')) { failBuild(outdent` - Your publish directory is pointing to the base directory of your site. This is not supported for Next.js sites, and is probably a mistake. + Your publish directory is pointing to the base directory of your site. This is not supported for Next.js sites, and is probably a mistake. In most cases it should be set to ".next", unless you have chosen a custom "distDir" in your Next config, or the Next site is in a subdirectory. `) } From 56bb235140214de0d1a714eb017ddfed544d4fc5 Mon Sep 17 00:00:00 2001 From: Louis DeScioli Date: Tue, 15 Mar 2022 08:42:33 -0500 Subject: [PATCH 2/4] fix: resolve PUBLISH_DIR instead of join with cwd --- src/helpers/functions.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/helpers/functions.ts b/src/helpers/functions.ts index 0e92fa28dc..34d40190fb 100644 --- a/src/helpers/functions.ts +++ b/src/helpers/functions.ts @@ -2,7 +2,7 @@ import { NetlifyConfig, NetlifyPluginConstants } from '@netlify/build' import bridgeFile from '@vercel/node-bridge' import { copyFile, ensureDir, writeFile, writeJSON } from 'fs-extra' import type { ImageConfigComplete } from 'next/dist/server/image-config' -import { join, relative } from 'pathe' +import { join, relative, resolve } from 'pathe' import { HANDLER_FUNCTION_NAME, ODB_FUNCTION_NAME, IMAGE_FUNCTION_NAME, DEFAULT_FUNCTIONS_SRC } from '../constants' import { getHandler } from '../templates/getHandler' @@ -14,7 +14,7 @@ export const generateFunctions = async ( ): Promise => { const functionsDir = INTERNAL_FUNCTIONS_SRC || FUNCTIONS_SRC const functionDir = join(process.cwd(), functionsDir, HANDLER_FUNCTION_NAME) - const publishDir = relative(functionDir, join(process.cwd(), PUBLISH_DIR)) + const publishDir = relative(functionDir, resolve(PUBLISH_DIR)) const writeHandler = async (func: string, isODB: boolean) => { const handlerSource = await getHandler({ isODB, publishDir, appDir: relative(functionDir, appDir) }) From 07e8b2d157af4a487ee1bce2702ce7685c084947 Mon Sep 17 00:00:00 2001 From: Matt Kane Date: Wed, 16 Mar 2022 15:19:57 +0000 Subject: [PATCH 3/4] chore: snapidoo --- test/__snapshots__/index.js.snap | 36 ++++++++++++++++---------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/test/__snapshots__/index.js.snap b/test/__snapshots__/index.js.snap index e0f7b4c0a8..3de962a1c9 100644 --- a/test/__snapshots__/index.js.snap +++ b/test/__snapshots__/index.js.snap @@ -641,109 +641,109 @@ Array [ }, Object { "force": true, - "from": "/_next/data/build-id/en/getStaticProps/with-revalidate.json", + "from": "/_next/data/build-id/en/getStaticProps/withRevalidate/withFallback/1.json", "status": 200, "to": "/.netlify/builders/___netlify-odb-handler", }, Object { "force": true, - "from": "/getStaticProps/with-revalidate", + "from": "/getStaticProps/withRevalidate/withFallback/1", "status": 200, "to": "/.netlify/builders/___netlify-odb-handler", }, Object { "force": true, - "from": "/_next/data/build-id/es/getStaticProps/with-revalidate.json", + "from": "/_next/data/build-id/en/getStaticProps/withRevalidate/withFallback/2.json", "status": 200, "to": "/.netlify/builders/___netlify-odb-handler", }, Object { "force": true, - "from": "/es/getStaticProps/with-revalidate", + "from": "/getStaticProps/withRevalidate/withFallback/2", "status": 200, "to": "/.netlify/builders/___netlify-odb-handler", }, Object { "force": true, - "from": "/_next/data/build-id/fr/getStaticProps/with-revalidate.json", + "from": "/_next/data/build-id/en/getStaticProps/withRevalidate/1.json", "status": 200, "to": "/.netlify/builders/___netlify-odb-handler", }, Object { "force": true, - "from": "/fr/getStaticProps/with-revalidate", + "from": "/getStaticProps/withRevalidate/1", "status": 200, "to": "/.netlify/builders/___netlify-odb-handler", }, Object { "force": true, - "from": "/_next/data/build-id/en/getStaticProps/withRevalidate/1.json", + "from": "/_next/data/build-id/en/getStaticProps/withRevalidate/2.json", "status": 200, "to": "/.netlify/builders/___netlify-odb-handler", }, Object { "force": true, - "from": "/getStaticProps/withRevalidate/1", + "from": "/getStaticProps/withRevalidate/2", "status": 200, "to": "/.netlify/builders/___netlify-odb-handler", }, Object { "force": true, - "from": "/_next/data/build-id/en/getStaticProps/withRevalidate/2.json", + "from": "/_next/data/build-id/en/getStaticProps/withRevalidate/withFallbackBlocking/1.json", "status": 200, "to": "/.netlify/builders/___netlify-odb-handler", }, Object { "force": true, - "from": "/getStaticProps/withRevalidate/2", + "from": "/getStaticProps/withRevalidate/withFallbackBlocking/1", "status": 200, "to": "/.netlify/builders/___netlify-odb-handler", }, Object { "force": true, - "from": "/_next/data/build-id/en/getStaticProps/withRevalidate/withFallback/1.json", + "from": "/_next/data/build-id/en/getStaticProps/withRevalidate/withFallbackBlocking/2.json", "status": 200, "to": "/.netlify/builders/___netlify-odb-handler", }, Object { "force": true, - "from": "/getStaticProps/withRevalidate/withFallback/1", + "from": "/getStaticProps/withRevalidate/withFallbackBlocking/2", "status": 200, "to": "/.netlify/builders/___netlify-odb-handler", }, Object { "force": true, - "from": "/_next/data/build-id/en/getStaticProps/withRevalidate/withFallback/2.json", + "from": "/_next/data/build-id/en/getStaticProps/with-revalidate.json", "status": 200, "to": "/.netlify/builders/___netlify-odb-handler", }, Object { "force": true, - "from": "/getStaticProps/withRevalidate/withFallback/2", + "from": "/getStaticProps/with-revalidate", "status": 200, "to": "/.netlify/builders/___netlify-odb-handler", }, Object { "force": true, - "from": "/_next/data/build-id/en/getStaticProps/withRevalidate/withFallbackBlocking/1.json", + "from": "/_next/data/build-id/es/getStaticProps/with-revalidate.json", "status": 200, "to": "/.netlify/builders/___netlify-odb-handler", }, Object { "force": true, - "from": "/getStaticProps/withRevalidate/withFallbackBlocking/1", + "from": "/es/getStaticProps/with-revalidate", "status": 200, "to": "/.netlify/builders/___netlify-odb-handler", }, Object { "force": true, - "from": "/_next/data/build-id/en/getStaticProps/withRevalidate/withFallbackBlocking/2.json", + "from": "/_next/data/build-id/fr/getStaticProps/with-revalidate.json", "status": 200, "to": "/.netlify/builders/___netlify-odb-handler", }, Object { "force": true, - "from": "/getStaticProps/withRevalidate/withFallbackBlocking/2", + "from": "/fr/getStaticProps/with-revalidate", "status": 200, "to": "/.netlify/builders/___netlify-odb-handler", }, From 12ea7defe7330a5fef86d054f9e4594ec1b56cc5 Mon Sep 17 00:00:00 2001 From: Matt Kane Date: Wed, 16 Mar 2022 15:46:01 +0000 Subject: [PATCH 4/4] chore: snapshot --- test/__snapshots__/index.js.snap | 36 ++++++++++++++++---------------- 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/test/__snapshots__/index.js.snap b/test/__snapshots__/index.js.snap index 3de962a1c9..684d1c9397 100644 --- a/test/__snapshots__/index.js.snap +++ b/test/__snapshots__/index.js.snap @@ -641,109 +641,109 @@ Array [ }, Object { "force": true, - "from": "/_next/data/build-id/en/getStaticProps/withRevalidate/withFallback/1.json", + "from": "/_next/data/build-id/en/getStaticProps/with-revalidate.json", "status": 200, "to": "/.netlify/builders/___netlify-odb-handler", }, Object { "force": true, - "from": "/getStaticProps/withRevalidate/withFallback/1", + "from": "/getStaticProps/with-revalidate", "status": 200, "to": "/.netlify/builders/___netlify-odb-handler", }, Object { "force": true, - "from": "/_next/data/build-id/en/getStaticProps/withRevalidate/withFallback/2.json", + "from": "/_next/data/build-id/es/getStaticProps/with-revalidate.json", "status": 200, "to": "/.netlify/builders/___netlify-odb-handler", }, Object { "force": true, - "from": "/getStaticProps/withRevalidate/withFallback/2", + "from": "/es/getStaticProps/with-revalidate", "status": 200, "to": "/.netlify/builders/___netlify-odb-handler", }, Object { "force": true, - "from": "/_next/data/build-id/en/getStaticProps/withRevalidate/1.json", + "from": "/_next/data/build-id/fr/getStaticProps/with-revalidate.json", "status": 200, "to": "/.netlify/builders/___netlify-odb-handler", }, Object { "force": true, - "from": "/getStaticProps/withRevalidate/1", + "from": "/fr/getStaticProps/with-revalidate", "status": 200, "to": "/.netlify/builders/___netlify-odb-handler", }, Object { "force": true, - "from": "/_next/data/build-id/en/getStaticProps/withRevalidate/2.json", + "from": "/_next/data/build-id/en/getStaticProps/withRevalidate/withFallback/1.json", "status": 200, "to": "/.netlify/builders/___netlify-odb-handler", }, Object { "force": true, - "from": "/getStaticProps/withRevalidate/2", + "from": "/getStaticProps/withRevalidate/withFallback/1", "status": 200, "to": "/.netlify/builders/___netlify-odb-handler", }, Object { "force": true, - "from": "/_next/data/build-id/en/getStaticProps/withRevalidate/withFallbackBlocking/1.json", + "from": "/_next/data/build-id/en/getStaticProps/withRevalidate/withFallback/2.json", "status": 200, "to": "/.netlify/builders/___netlify-odb-handler", }, Object { "force": true, - "from": "/getStaticProps/withRevalidate/withFallbackBlocking/1", + "from": "/getStaticProps/withRevalidate/withFallback/2", "status": 200, "to": "/.netlify/builders/___netlify-odb-handler", }, Object { "force": true, - "from": "/_next/data/build-id/en/getStaticProps/withRevalidate/withFallbackBlocking/2.json", + "from": "/_next/data/build-id/en/getStaticProps/withRevalidate/withFallbackBlocking/1.json", "status": 200, "to": "/.netlify/builders/___netlify-odb-handler", }, Object { "force": true, - "from": "/getStaticProps/withRevalidate/withFallbackBlocking/2", + "from": "/getStaticProps/withRevalidate/withFallbackBlocking/1", "status": 200, "to": "/.netlify/builders/___netlify-odb-handler", }, Object { "force": true, - "from": "/_next/data/build-id/en/getStaticProps/with-revalidate.json", + "from": "/_next/data/build-id/en/getStaticProps/withRevalidate/withFallbackBlocking/2.json", "status": 200, "to": "/.netlify/builders/___netlify-odb-handler", }, Object { "force": true, - "from": "/getStaticProps/with-revalidate", + "from": "/getStaticProps/withRevalidate/withFallbackBlocking/2", "status": 200, "to": "/.netlify/builders/___netlify-odb-handler", }, Object { "force": true, - "from": "/_next/data/build-id/es/getStaticProps/with-revalidate.json", + "from": "/_next/data/build-id/en/getStaticProps/withRevalidate/1.json", "status": 200, "to": "/.netlify/builders/___netlify-odb-handler", }, Object { "force": true, - "from": "/es/getStaticProps/with-revalidate", + "from": "/getStaticProps/withRevalidate/1", "status": 200, "to": "/.netlify/builders/___netlify-odb-handler", }, Object { "force": true, - "from": "/_next/data/build-id/fr/getStaticProps/with-revalidate.json", + "from": "/_next/data/build-id/en/getStaticProps/withRevalidate/2.json", "status": 200, "to": "/.netlify/builders/___netlify-odb-handler", }, Object { "force": true, - "from": "/fr/getStaticProps/with-revalidate", + "from": "/getStaticProps/withRevalidate/2", "status": 200, "to": "/.netlify/builders/___netlify-odb-handler", },