Skip to content
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

[Themes] theme dev - unify asset upload error reporting #5209

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

jamesmengo
Copy link
Contributor

@jamesmengo jamesmengo commented Jan 15, 2025

WHY are these changes introduced?

Improves consistency of how we surface asset upload errors to the user

The theme dev command uploads in two places

  1. Initial startup / upload
  2. When the file system detects a local change

The way we report these errors were different, leading to a disjointed visual experience
This PR unifies the way those errors are rendered to the terminal.

This also makes it easier for us to revisit whether we want to render this, or just call outputWarn. Personally, I feel like this adds noise to the terminal but I wanted to keep this change insulated for the moment. Consistency is more important in the short term.

WHAT is this pull request doing?

BEFORE
image

AFTER
image

How to test your changes?

  1. Setup - ensure that you have a theme with existing errors (e.g. invalid liquid, etc)
  2. Build and run this branch's theme dev command
  3. You should see asset upload errors being output to terminal
  4. Apply a breaking change to a file in your theme
  5. You should see output similar to 3

Post-release steps

Measuring impact

How do we know this change was effective? Please choose one:

  • n/a - this doesn't need measurement, e.g. a linting rule or a bug-fix
  • Existing analytics will cater for this addition
  • PR includes analytics changes to measure impact

Checklist

  • I've considered possible cross-platform impacts (Mac, Linux, Windows)
  • I've considered possible documentation changes

Copy link
Contributor

github-actions bot commented Jan 15, 2025

Coverage report

St.
Category Percentage Covered / Total
🟡 Statements
75.16% (-0.08% 🔻)
8893/11832
🟡 Branches
70.28% (-0.12% 🔻)
4342/6178
🟡 Functions 75.06% 2326/3099
🟡 Lines
75.71% (-0.08% 🔻)
8408/11105
Show files with reduced coverage 🔻
St.
File Statements Branches Functions Lines
🔴
... / dev.ts
19.53% (-0.15% 🔻)
14.93% (-0.46% 🔻)
24.39%
20.34% (-0.17% 🔻)
🟢
... / app-event-watcher.ts
93.83% (-1.23% 🔻)
86.49% 90.48% 98.61%
🟢
... / Dev.tsx
93.1% (-0.96% 🔻)
77.78% (-1.91% 🔻)
90.91% (-1.09% 🔻)
93.9% (-0.78% 🔻)
🔴
... / developer-platform-client.ts
55.88% (-8.63% 🔻)
42.86% (-23.81% 🔻)
70% (-10% 🔻)
55.56% (-15.28% 🔻)
🟢
... / session.ts
83.01% (-6.59% 🔻)
72.73% (-4.45% 🔻)
92.86% (+1.19% 🔼)
82.76% (-6.22% 🔻)

Test suite run success

2007 tests passing in 906 suites.

Report generated by 🧪jest coverage report action from 454ca51

@jamesmengo jamesmengo force-pushed the jm/01-15-unify_asset_upload_error_reporting branch from 1447d8a to 5ac4ebb Compare January 15, 2025 22:40
@jamesmengo jamesmengo closed this Jan 15, 2025
@jamesmengo jamesmengo force-pushed the jm/01-15-unify_asset_upload_error_reporting branch from 5ac4ebb to 3c10c59 Compare January 15, 2025 22:40
@jamesmengo jamesmengo reopened this Jan 15, 2025
@jamesmengo jamesmengo changed the title Unify asset upload error reporting [Themes] theme dev - unify asset upload error reporting Jan 15, 2025
@jamesmengo jamesmengo force-pushed the jm/01-15-unify_asset_upload_error_reporting branch from 9cf51e3 to 7446211 Compare January 15, 2025 22:50
@jamesmengo jamesmengo self-assigned this Jan 15, 2025
@jamesmengo jamesmengo marked this pull request as ready for review January 15, 2025 22:50
@jamesmengo jamesmengo requested review from a team as code owners January 15, 2025 22:50

This comment has been minimized.

@jamesmengo jamesmengo force-pushed the jm/01-15-unify_asset_upload_error_reporting branch from 7446211 to f997b11 Compare January 15, 2025 22:51
outputWarn(`Failed to upload file ${key}:`)
outputInfo(`${errorMessage}`)
outputNewline()
const errorMessage = result.errors?.asset?.map((err) => `-${err}`).join('\n') ?? 'File upload failed'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're in here modifying this code... could we render all of the failed uploads in a single error? Something that looks like:

╭─ failure ────────────────────────────────────────────────────────────────────╮
│                                                                              │
│  Failed to upload files:                                                     │
│                                                                              │
│    • snippets/foo.liquid
|      Some reason for the error                                               │
│                                                                              │
│    • snippets/foo.liquid
|      Some reason for the error                                               │
│                                                                              │
│    • snippets/foo.liquid
|      Some reason for the error                                               │
│                                                                              │
╰──────────────────────────────────────────────────────────────────────────────╯

What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, though I would prefer to do that outside of this issue since I have am making this quick change to build on top of it.

I am also adding an uploadErrors map on top of this that will enable us to go in the direction you're suggesting!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need uploadErrors for this since we already have the results in uploadResults here but I'm happy enough to push my suggestion off into a follow up.

outputWarn(`Failed to upload file ${key}:`)
outputInfo(`${errorMessage}`)
outputNewline()
const errorMessage = result.errors?.asset?.map((err) => `-${err}`).join('\n') ?? 'File upload failed'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need uploadErrors for this since we already have the results in uploadResults here but I'm happy enough to push my suggestion off into a follow up.

Co-authored-by: Gray Gilmore <graygilmore@gmail.com>
@jamesmengo jamesmengo force-pushed the jm/01-15-unify_asset_upload_error_reporting branch from bdd01e4 to 4d5dfae Compare January 16, 2025 19:09
Co-authored-by: Fran Dios <fran.dios@shopify.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: @shopify/theme @shopify/theme package issues
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants