diff --git a/packages/build/src/log/logger.ts b/packages/build/src/log/logger.ts index 1aa33cad9f..b9dad99ec4 100644 --- a/packages/build/src/log/logger.ts +++ b/packages/build/src/log/logger.ts @@ -3,6 +3,8 @@ import { createWriteStream } from 'fs' import figures from 'figures' import indentString from 'indent-string' +import type { SystemLogger } from '../plugins_core/types.js' + import { getHeader } from './header.js' import { OutputFlusher } from './output_flusher.js' import { serializeArray, serializeObject } from './serialize.js' @@ -162,7 +164,7 @@ export const getSystemLogger = function ( debug: boolean, /** A system log file descriptor, if non is provided it will be a noop logger */ systemLogFile?: number, -): (...args: any[]) => void { +): SystemLogger { // If the `debug` flag is used, we return a function that pipes system logs // to the regular logger, as the intention is for them to end up in stdout. if (debug) { diff --git a/packages/build/src/plugins_core/blobs_upload/index.ts b/packages/build/src/plugins_core/blobs_upload/index.ts index f9fc5e9619..74c36b08ab 100644 --- a/packages/build/src/plugins_core/blobs_upload/index.ts +++ b/packages/build/src/plugins_core/blobs_upload/index.ts @@ -4,18 +4,17 @@ import { getDeployStore } from '@netlify/blobs' import pMap from 'p-map' import semver from 'semver' -import { log, logError } from '../../log/logger.js' +import { logError } from '../../log/logger.js' import { getFileWithMetadata, getKeysToUpload, scanForBlobs } from '../../utils/blobs.js' import { type CoreStep, type CoreStepCondition, type CoreStepFunction } from '../types.js' const coreStep: CoreStepFunction = async function ({ - debug, logs, deployId, buildDir, - quiet, packagePath, constants: { SITE_ID, NETLIFY_API_TOKEN, NETLIFY_API_HOST }, + systemLog, }) { // This should never happen due to the condition check if (!deployId || !NETLIFY_API_TOKEN) { @@ -41,9 +40,8 @@ const coreStep: CoreStepFunction = async function ({ // We checked earlier, but let's be extra safe if (blobs === null) { - if (!quiet) { - log(logs, 'No blobs to upload to deploy store.') - } + systemLog('No blobs to upload to deploy store.') + return {} } @@ -57,23 +55,19 @@ const coreStep: CoreStepFunction = async function ({ const keys = await getKeysToUpload(blobs.directory) if (keys.length === 0) { - if (!quiet) { - log(logs, 'No blobs to upload to deploy store.') - } + systemLog('No blobs to upload to deploy store.') + return {} } - if (!quiet) { - log(logs, `Uploading ${keys.length} blobs to deploy store...`) - } + systemLog(`Uploading ${keys.length} blobs to deploy store`) try { await pMap( keys, async (key: string) => { - if (debug && !quiet) { - log(logs, `- Uploading blob ${key}`, { indent: true }) - } + systemLog(`Uploading blob ${key}`) + const { data, metadata } = await getFileWithMetadata(blobs.directory, key) await blobStore.set(key, data, { metadata }) }, @@ -85,9 +79,7 @@ const coreStep: CoreStepFunction = async function ({ throw new Error(`Failed while uploading blobs to deploy store`) } - if (!quiet) { - log(logs, `Done uploading blobs to deploy store.`) - } + systemLog(`Done uploading blobs to deploy store.`) return {} } diff --git a/packages/build/src/plugins_core/types.ts b/packages/build/src/plugins_core/types.ts index 83e4a9c30c..470a4ce39d 100644 --- a/packages/build/src/plugins_core/types.ts +++ b/packages/build/src/plugins_core/types.ts @@ -21,9 +21,8 @@ export type CoreStepFunctionArgs = { quiet?: boolean debug?: boolean logs?: BufferedLogs - systemLog?: (message: unknown) => void + systemLog: SystemLogger edgeFunctionsBootstrapURL?: string - // systemLog(...args: any[]): void featureFlags?: Record netlifyConfig: NetlifyConfig