cli icon indicating copy to clipboard operation
cli copied to clipboard

Fix empty error banner and prefix theme console command URLs

Open dejmedus opened this issue 7 months ago β€’ 3 comments

Fixes https://github.com/Shopify/developer-tools-team/issues/585

WHY are these changes introduced?

Previously users running theme console commands would be shown an empty banner if they didn't prefix their URL with a / even if the URL was valid.

WHAT is this pull request doing?

  • Appends a forward slash onto URLs that are missing one
  • Instead of displaying an outputInfo message and throwing an AbortSilentError (which cannot provide an error message to the banner) throw an AbortError which can
throw new AbortError('Page not found. Please provide a valid --url value!')
error-banner

How to test your changes?

npm i -g @shopify/[email protected] --@shopify:registry=https://registry.npmjs.org

  • Correct URLs missing a forward slash should not error
    • Run theme console command with a URL that is missing a forward slash shopify theme console --url products/<product-name>
    • Entering product.title in the repl should output <product-name>
  • Incorrect URLs should display a not found error message inside the banner
    • Run theme console command with a URL that does not exist shopify theme console --url products/not-a-product
    • Entering product.title in the repl should output Page not found. Please provide a valid --url value!

Measuring impact

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

  • [x] 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

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

dejmedus avatar May 10 '25 00:05 dejmedus

Coverage report

St.:grey_question:
Category Percentage Covered / Total
🟑 Statements
76.64% (+0.03% πŸ”Ό)
9602/12529
🟑 Branches
71.97% (+0.07% πŸ”Ό)
4751/6601
🟑 Functions 76.56% 2485/3246
🟑 Lines
77.15% (+0.03% πŸ”Ό)
9074/11762

Test suite run success

2271 tests passing in 983 suites.

Report generated by πŸ§ͺjest coverage report action from 9cae395457a4f2df07a22eff52787d686e9b48f5

github-actions[bot] avatar May 10 '25 00:05 github-actions[bot]

/snapit

dejmedus avatar May 10 '25 15:05 dejmedus

🫰✨ Thanks @dejmedus! Your snapshot has been published to npm.

Test the snapshot by installing your package globally:

pnpm i -g @shopify/[email protected]

[!TIP] If you get an ETARGET error, install it with NPM and the flag --@shopify:registry=https://registry.npmjs.org

[!CAUTION] After installing, validate the version by running just shopify in your terminal. If the versions don't match, you might have multiple global instances installed. Use which shopify to find out which one you are running and uninstall it.

github-actions[bot] avatar May 10 '25 15:05 github-actions[bot]