Fix empty error banner and prefix theme console command URLs
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
outputInfomessage and throwing anAbortSilentError(which cannot provide an error message to the banner) throw anAbortErrorwhich can
throw new AbortError('Page not found. Please provide a valid --url value!')
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.titlein the repl should output<product-name>
- Run theme console command with a URL that is missing a forward slash
- Incorrect URLs should display a
not founderror 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.titlein the repl should outputPage not found. Please provide a valid --url value!
- Run theme console command with a URL that does not exist
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
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
/snapit
π«°β¨ 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
ETARGETerror, install it with NPM and the flag--@shopify:registry=https://registry.npmjs.org
[!CAUTION] After installing, validate the version by running just
shopifyin your terminal. If the versions don't match, you might have multiple global instances installed. Usewhich shopifyto find out which one you are running and uninstall it.