move more things into containers-shared for cf - #15512
Conversation
|
@cloudflare/autoconfig
@cloudflare/build-output-utils
@cloudflare/codemods
@cloudflare/config
create-cloudflare
@cloudflare/deploy-helpers
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-functions
@cloudflare/pages-shared
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-plugin
@cloudflare/workers-auth
@cloudflare/workers-editor-shared
@cloudflare/workers-utils
wrangler
commit: |
| async function runPreviewContainerOperation<T>( | ||
| options: { quiet: boolean }, | ||
| operation: () => Promise<T> | ||
| ): Promise<T> { | ||
| initContainersSharedContext({ | ||
| logger: options.quiet ? quietLogger : logger, | ||
| fetchResult, | ||
| }); | ||
|
|
||
| if (!options.quiet) { | ||
| return operation(); | ||
| } | ||
|
|
||
| // Building and applying containers prints progress to stdout, the same stream | ||
| // that carries the `--json` payload. Keep both logging surfaces quiet while | ||
| // stdout has to stay machine-readable. | ||
| const previousLogLevel = getLogLevel(); | ||
| setLogLevel("error"); | ||
| try { | ||
| return await operation(); | ||
| } finally { | ||
| setLogLevel(previousLogLevel); | ||
| initContainersSharedContext({ logger, fetchResult }); | ||
| } |
There was a problem hiding this comment.
P1: Keep generated client debug output out of preview --json. verifyContainersScope() initializes OpenAPI.LOGGER to the normal Wrangler logger during preparation, but this later quiet path only changes the containers context and the CLI-helper log level. With WRANGLER_LOG=debug, ApplicationsService logs request and response details to stdout before the JSON result. The previous runWithLogLevel("warn") scope suppressed this.
| async function runPreviewContainerOperation<T>( | |
| options: { quiet: boolean }, | |
| operation: () => Promise<T> | |
| ): Promise<T> { | |
| initContainersSharedContext({ | |
| logger: options.quiet ? quietLogger : logger, | |
| fetchResult, | |
| }); | |
| if (!options.quiet) { | |
| return operation(); | |
| } | |
| // Building and applying containers prints progress to stdout, the same stream | |
| // that carries the `--json` payload. Keep both logging surfaces quiet while | |
| // stdout has to stay machine-readable. | |
| const previousLogLevel = getLogLevel(); | |
| setLogLevel("error"); | |
| try { | |
| return await operation(); | |
| } finally { | |
| setLogLevel(previousLogLevel); | |
| initContainersSharedContext({ logger, fetchResult }); | |
| } | |
| async function runPreviewContainerOperation<T>( | |
| options: { quiet: boolean }, | |
| operation: () => Promise<T> | |
| ): Promise<T> { | |
| const containersLogger = options.quiet ? quietLogger : logger; | |
| initContainersSharedContext({ | |
| logger: containersLogger, | |
| fetchResult, | |
| }); | |
| if (!options.quiet) { | |
| return operation(); | |
| } | |
| const { OpenAPI } = await import("@cloudflare/containers-shared"); | |
| const previousOpenApiLogger = OpenAPI.LOGGER; | |
| OpenAPI.LOGGER = { | |
| ...quietLogger, | |
| debugWithSanitization() {}, | |
| }; | |
| // Building and applying containers prints progress to stdout, the same stream | |
| // that carries the `--json` payload. Keep both logging surfaces quiet while | |
| // stdout has to stay machine-readable. | |
| const previousLogLevel = getLogLevel(); | |
| setLogLevel("error"); | |
| try { | |
| return await operation(); | |
| } finally { | |
| setLogLevel(previousLogLevel); | |
| OpenAPI.LOGGER = previousOpenApiLogger; | |
| initContainersSharedContext({ logger, fetchResult }); | |
| } | |
| } |
|
I'm Bonk, and I've done a quick review of your PR. Moves container build, deployment, and preview logic into
|
Also:
move container build earlier
A picture of a cute animal (not mandatory, but encouraged)