-
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
Clarify and reduce Cloudflare adapter integration logs noise #13817
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 14 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
8288710
Clarify and reduce Cloudflare integration logs
yanthomasdev f592fa3
Simplify log
yanthomasdev 6b36145
Move enabling sessions log to only show in build
yanthomasdev 6247780
Use double quotes instead
yanthomasdev ce490e2
Add option to suppress adapter feature support log
yanthomasdev ec46803
Add fixture to test option
yanthomasdev 908afe9
Add changeset
yanthomasdev e5f74a0
Merge branch 'main' into cloudflare-log-improv
yanthomasdev 628a0ce
Merge branch 'cloudflare-log-improv' into suppress-supported-features…
yanthomasdev 7fbd8a6
Apply suggestions from code review
yanthomasdev d30ad27
Merge branch 'main' into suppress-supported-features-log-option
ascorbic 7c8d997
Use `suppress` option instead of hack
yanthomasdev ba9360a
Create fast-planets-shout.md
yanthomasdev ca703e1
Update .changeset/fast-planets-shout.md
yanthomasdev 3191a96
Merge branch 'main' into cloudflare-log-improv
ascorbic File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,23 @@ | ||
| --- | ||
| "astro": minor | ||
| --- | ||
|
|
||
| Adds an option for integration authors to suppress adapter warning/errors in `supportedAstroFeatures`. This is useful when either an warning/error isn't applicable in a specific context or the default one might conflict and confuse users. | ||
|
|
||
| To do so, you can add `suppress: "all"` (to suppress both the default and custom message) or `suppress: "default"` (to only suppress the default one): | ||
| ```ts | ||
| setAdapter({ | ||
| name: 'my-astro-integration', | ||
| supportedAstroFeatures: { | ||
| staticOutput: "stable", | ||
| hybridOutput: "stable", | ||
| sharpImageService: { | ||
| support: "limited", | ||
| message: "The sharp image service isn't available in the deploy environment, but will be used by prerendered pages on build.", | ||
| suppress: "default", | ||
| }, | ||
| } | ||
| }) | ||
| ``` | ||
|
|
||
| For more information, see the [Adapter API reference docs](https://docs.astro.build/en/reference/adapter-reference/#astro-features). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| --- | ||
| "@astrojs/cloudflare": patch | ||
| --- | ||
|
|
||
| Clarifies and reduces a few logs when starting the dev server with `@astrojs/cloudflare`. | ||
|
|
||
| Warnings about sharp support will now be suppressed when you have explicitly set an `imageService` option. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
packages/astro/test/fixtures/feature-support-message-suppresion/astro.config.mjs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| import { defineConfig } from 'astro/config'; | ||
| export default defineConfig({ | ||
| integrations: [ | ||
| { | ||
| name: 'astro-test-feature-support-message-suppression', | ||
| hooks: { | ||
| 'astro:config:done': ({ setAdapter }) => { | ||
| setAdapter({ | ||
| name: 'astro-test-feature-support-message-suppression', | ||
| supportedAstroFeatures: { | ||
| staticOutput: "stable", | ||
| hybridOutput: "stable", | ||
| serverOutput: { | ||
| support: "experimental", | ||
| message: "This should be logged.", | ||
| suppress: "default", | ||
| }, | ||
| sharpImageService: { | ||
| support: 'limited', | ||
| message: 'This shouldn\'t be logged.', | ||
| suppress: "all", | ||
| }, | ||
| } | ||
| }) | ||
| }, | ||
| }, | ||
| }, | ||
| ], | ||
| }); |
15 changes: 15 additions & 0 deletions
15
packages/astro/test/fixtures/feature-support-message-suppresion/package.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| { | ||
| "name": "@test/feature-support-message-suppresion", | ||
| "type": "module", | ||
| "version": "0.0.1", | ||
| "private": true, | ||
| "scripts": { | ||
| "dev": "astro dev", | ||
| "build": "astro build", | ||
| "preview": "astro preview", | ||
| "astro": "astro" | ||
| }, | ||
| "dependencies": { | ||
| "astro": "workspace:*" | ||
| } | ||
| } |
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,8 +1,10 @@ | ||
| import type { AstroConfig, AstroIntegrationLogger, HookParameters } from 'astro'; | ||
| import { passthroughImageService, sharpImageService } from 'astro/config'; | ||
|
|
||
| export type ImageService = 'passthrough' | 'cloudflare' | 'compile' | 'custom'; | ||
|
|
||
| export function setImageConfig( | ||
| service: string, | ||
| service: ImageService, | ||
| config: AstroConfig['image'], | ||
| command: HookParameters<'astro:config:setup'>['command'], | ||
| logger: AstroIntegrationLogger, | ||
|
|
@@ -35,7 +37,7 @@ export function setImageConfig( | |
| default: | ||
| if (config.service.entrypoint === 'astro/assets/services/sharp') { | ||
| logger.warn( | ||
| `The current configuration does not support image optimization. To allow your project to build with the original, unoptimized images, the image service has been automatically switched to the 'noop' option. See https://docs.astro.build/en/reference/configuration-reference/#imageservice`, | ||
| `The current configuration does not support image optimization. To allow your project to build with the original, unoptimized images, the image service has been automatically switched to the 'passthrough' option. See https://docs.astro.build/en/reference/configuration-reference/#imageservice`, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A bit of an extra, the option name itself is not |
||
| ); | ||
| return { ...config, service: passthroughImageService() }; | ||
| } | ||
|
|
||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.