From 6380277a7a3b858f20ec8287014fb69820c28daa Mon Sep 17 00:00:00 2001 From: James Meng Date: Wed, 15 Jan 2025 14:43:28 -0800 Subject: [PATCH 1/3] Unify how asset upload errors are rendered --- .changeset/stupid-phones-try.md | 5 +++++ packages/theme/src/cli/utilities/theme-uploader.ts | 10 ++++------ 2 files changed, 9 insertions(+), 6 deletions(-) create mode 100644 .changeset/stupid-phones-try.md diff --git a/.changeset/stupid-phones-try.md b/.changeset/stupid-phones-try.md new file mode 100644 index 00000000000..555d5d0cf88 --- /dev/null +++ b/.changeset/stupid-phones-try.md @@ -0,0 +1,5 @@ +--- +'@shopify/theme': minor +--- + +Unify how asset upload errors are reported in the `theme dev` command diff --git a/packages/theme/src/cli/utilities/theme-uploader.ts b/packages/theme/src/cli/utilities/theme-uploader.ts index 1069696561f..a259f17dda2 100644 --- a/packages/theme/src/cli/utilities/theme-uploader.ts +++ b/packages/theme/src/cli/utilities/theme-uploader.ts @@ -1,12 +1,12 @@ import {partitionThemeFiles} from './theme-fs.js' import {rejectGeneratedStaticAssets} from './asset-checksum.js' import {renderTasksToStdErr} from './theme-ui.js' -import {createSyncingCatchError} from './errors.js' +import {createSyncingCatchError, renderThrownError} from './errors.js' import {AdminSession} from '@shopify/cli-kit/node/session' import {Result, Checksum, Theme, ThemeFileSystem} from '@shopify/cli-kit/node/themes/types' import {AssetParams, bulkUploadThemeAssets, deleteThemeAsset} from '@shopify/cli-kit/node/themes/api' import {Task} from '@shopify/cli-kit/node/ui' -import {outputDebug, outputInfo, outputNewline, outputWarn} from '@shopify/cli-kit/node/output' +import {outputDebug} from '@shopify/cli-kit/node/output' interface UploadOptions { nodelete?: boolean @@ -432,10 +432,8 @@ async function handleFailedUploads( function reportFailedUploads(uploadResults: Map) { for (const [key, result] of uploadResults.entries()) { if (!result.success) { - const errorMessage = result.errors?.asset?.map((err) => `-${err}`).join('\n') - outputWarn(`Failed to upload file ${key}:`) - outputInfo(`${errorMessage}`) - outputNewline() + const errorMessage = result.errors?.asset?.map((err) => `-${err}`).join('\n') ?? 'File upload failed' + renderThrownError(key, new Error(errorMessage)) } } } From 58d3ee827befba3529331223d3cd3ced693c1b8c Mon Sep 17 00:00:00 2001 From: James Meng <35415298+jamesmengo@users.noreply.github.com> Date: Thu, 16 Jan 2025 11:08:20 -0800 Subject: [PATCH 2/3] Remove dash from error message Co-authored-by: Gray Gilmore --- packages/theme/src/cli/utilities/theme-uploader.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/theme/src/cli/utilities/theme-uploader.ts b/packages/theme/src/cli/utilities/theme-uploader.ts index a259f17dda2..a675831172a 100644 --- a/packages/theme/src/cli/utilities/theme-uploader.ts +++ b/packages/theme/src/cli/utilities/theme-uploader.ts @@ -432,7 +432,7 @@ async function handleFailedUploads( function reportFailedUploads(uploadResults: Map) { for (const [key, result] of uploadResults.entries()) { if (!result.success) { - const errorMessage = result.errors?.asset?.map((err) => `-${err}`).join('\n') ?? 'File upload failed' + const errorMessage = result.errors?.asset?.map((err) => err).join('\n') ?? 'File upload failed' renderThrownError(key, new Error(errorMessage)) } } From 0971b54f0b38e8abc71a6998140f8b151eac4cd4 Mon Sep 17 00:00:00 2001 From: James Meng <35415298+jamesmengo@users.noreply.github.com> Date: Thu, 16 Jan 2025 11:18:01 -0800 Subject: [PATCH 3/3] Remove unnecessary map Co-authored-by: Fran Dios --- packages/theme/src/cli/utilities/theme-uploader.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/theme/src/cli/utilities/theme-uploader.ts b/packages/theme/src/cli/utilities/theme-uploader.ts index a675831172a..d2e9c6e2c7d 100644 --- a/packages/theme/src/cli/utilities/theme-uploader.ts +++ b/packages/theme/src/cli/utilities/theme-uploader.ts @@ -432,7 +432,7 @@ async function handleFailedUploads( function reportFailedUploads(uploadResults: Map) { for (const [key, result] of uploadResults.entries()) { if (!result.success) { - const errorMessage = result.errors?.asset?.map((err) => err).join('\n') ?? 'File upload failed' + const errorMessage = result.errors?.asset?.join('\n') ?? 'File upload failed' renderThrownError(key, new Error(errorMessage)) } }