blitz icon indicating copy to clipboard operation
blitz copied to clipboard

Update codemod to show details on how to fix & continue when error

Open dillondotzip opened this issue 2 years ago • 1 comments

What do you want and why?

During the codemod if there is an error, we don't show enough relevant information on how to fix & continue. Currently this is all the user sees when something fails:

@blitzjs/codemod upgrade-legacy
✔ Successfully ran move the config from blitz.config.ts to next.config.js
✔ Successfully ran update dependencies in package.json
✔ Successfully ran update project's imports
✖ update NextJS' default imports
SyntaxError: /Users/dillonraphael/Desktop/flightcontrol/packages/flightdeck/app/core/components/ErrorComponent.tsx: Identifier 'ErrorComponent' has already been declared. (9:6)

   7 | }
   8 |
>  9 | class ErrorComponent extends DefaultErrorComponent<ExtraProps> {
     |       ^
  10 |   render() {
  11 |     const {statusCode, hasGetInitialPropsRun, err} = this.props
  12 |     if (!hasGetInitialPropsRun && err) {

Possible implementation(s)

@blitzjs/codemod upgrade-legacy
✔ Successfully ran move the config from blitz.config.ts to next.config.js
✔ Successfully ran update dependencies in package.json
✔ Successfully ran update project's imports
✖ update NextJS' default imports
SyntaxError: /Users/dillonraphael/Desktop/flightcontrol/packages/flightdeck/app/core/components/ErrorComponent.tsx: Identifier 'ErrorComponent' has already been declared. (9:6)

   7 | }
   8 |
>  9 | class ErrorComponent extends DefaultErrorComponent<ExtraProps> {
     |       ^
  10 |   render() {
  11 |     const {statusCode, hasGetInitialPropsRun, err} = this.props
  12 |     if (!hasGetInitialPropsRun && err) {

Don't panic, go to the file with the error & manually fix it. Then run the codemod again. It will continue where it left off.

dillondotzip avatar Jul 21 '22 13:07 dillondotzip

We could have each step documented (we kinda do, but it's not 1-1 with codemod) and put a link to the docs in the error message so that people will know exactly what and how they should manually update.

beerose avatar Jul 25 '22 10:07 beerose