From 19076c9b0b3f61f86359bdfcadad879a218ed97d Mon Sep 17 00:00:00 2001 From: bholmesdev Date: Tue, 5 Apr 2022 10:41:21 -0400 Subject: [PATCH 1/5] feat: human-readable error on bad site or base --- packages/integrations/netlify/src/index.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/packages/integrations/netlify/src/index.ts b/packages/integrations/netlify/src/index.ts index e7fb72633b89..f77690d5c70c 100644 --- a/packages/integrations/netlify/src/index.ts +++ b/packages/integrations/netlify/src/index.ts @@ -28,7 +28,15 @@ function netlifyFunctions({ dist }: NetlifyFunctionsOptions = {}): AstroIntegrat } }, 'astro:config:done': ({ config, setAdapter }) => { - setAdapter(getAdapter(new URL(config.base, config.site).toString())); + let site = null; + try { + site = new URL(config.base, config.site); + } catch { + throw new Error( + 'The Netlify adapter requires a deployment URL. Ensure a "site" is specified either in your astro.config or in the Netlify adapter configuration options. If you provided a "base" in your astro.config, ensure it is a valid path.' + ); + } + setAdapter(getAdapter(site.toString())); _config = config; }, 'astro:build:start': async ({ buildConfig }) => { From fd13fbe4e0ca91e8d9e3b2a58e2db7d1fdedf803 Mon Sep 17 00:00:00 2001 From: bholmesdev Date: Tue, 5 Apr 2022 10:50:06 -0400 Subject: [PATCH 2/5] fix: human-readable error should have 1 config option --- packages/integrations/netlify/src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/netlify/src/index.ts b/packages/integrations/netlify/src/index.ts index f77690d5c70c..181303e33a8d 100644 --- a/packages/integrations/netlify/src/index.ts +++ b/packages/integrations/netlify/src/index.ts @@ -33,7 +33,7 @@ function netlifyFunctions({ dist }: NetlifyFunctionsOptions = {}): AstroIntegrat site = new URL(config.base, config.site); } catch { throw new Error( - 'The Netlify adapter requires a deployment URL. Ensure a "site" is specified either in your astro.config or in the Netlify adapter configuration options. If you provided a "base" in your astro.config, ensure it is a valid path.' + 'The Netlify adapter requires a deployment URL. Ensure a "site" is specified in your astro.config. If you provided a "base" in your astro.config, ensure it is a valid path.' ); } setAdapter(getAdapter(site.toString())); From 7664442afa869c9159f3cdf8a76f2584728fcaa2 Mon Sep 17 00:00:00 2001 From: bholmesdev Date: Tue, 5 Apr 2022 10:50:11 -0400 Subject: [PATCH 3/5] docs: update README --- packages/integrations/netlify/readme.md | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/packages/integrations/netlify/readme.md b/packages/integrations/netlify/readme.md index 24fdb51877af..588b4786a222 100644 --- a/packages/integrations/netlify/readme.md +++ b/packages/integrations/netlify/readme.md @@ -2,14 +2,18 @@ Deploy your server-side rendered (SSR) Astro app to [Netlify](https://www.netlify.com/). -Use this adapter in your Astro configuration file: +Use this adapter in your Astro configuration file, alongside a valid deployment URL: ```js import { defineConfig } from 'astro/config'; import netlify from '@astrojs/netlify/functions'; export default defineConfig({ - adapter: netlify() + adapter: netlify(), + // Where your Netlify app will be deployed. + // Feel free to use an example URL (i.e. http://example.com) + // to test local builds, in case you aren't deploying yet! + site: 'https://my-production-url.netlify.app', }); ``` @@ -23,7 +27,9 @@ netlify deploy ## Configuration -The output folder is configuration with the `dist` property when creating the adapter. +### dist + +We build to a `netlify` directory at the base of your project. To change this, use the `dist` option: ```js import { defineConfig } from 'astro/config'; From cc672805923b78c1546342a21b7e9fface3224c1 Mon Sep 17 00:00:00 2001 From: bholmesdev Date: Tue, 5 Apr 2022 10:51:01 -0400 Subject: [PATCH 4/5] chore: changeset --- .changeset/angry-suits-thank.md | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 .changeset/angry-suits-thank.md diff --git a/.changeset/angry-suits-thank.md b/.changeset/angry-suits-thank.md new file mode 100644 index 000000000000..8c99427301f1 --- /dev/null +++ b/.changeset/angry-suits-thank.md @@ -0,0 +1,5 @@ +--- +'@astrojs/netlify': patch +--- + +Add human-readable error when a site is not provided in your astro.config From 67d92bc6f0d8d537e9e7cfcc8f119a7ddc7446eb Mon Sep 17 00:00:00 2001 From: bholmesdev Date: Tue, 5 Apr 2022 10:58:08 -0400 Subject: [PATCH 5/5] docs: mention localhost for testing via netlify CLI --- packages/integrations/netlify/readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/integrations/netlify/readme.md b/packages/integrations/netlify/readme.md index 588b4786a222..3e9d7879b00b 100644 --- a/packages/integrations/netlify/readme.md +++ b/packages/integrations/netlify/readme.md @@ -11,8 +11,8 @@ import netlify from '@astrojs/netlify/functions'; export default defineConfig({ adapter: netlify(), // Where your Netlify app will be deployed. - // Feel free to use an example URL (i.e. http://example.com) - // to test local builds, in case you aren't deploying yet! + // Feel free to use a local URL (i.e. http://localhost:8080) + // to test local builds via the netlify CLI site: 'https://my-production-url.netlify.app', }); ```