Instructions for migration from 0.11 now use npx cmd for codemod.

This commit is contained in:
Martin Sosic 2024-02-13 20:03:41 +01:00
parent 7ff1d06976
commit aeefab519d

View File

@ -176,15 +176,21 @@ directory `foo`, you should:
- `foo/src/server/tsconfig.json` - A new version of this file already exists at the top level.
- `foo/src/shared/tsconfig.json` - A new version of this file already exists at the top level.
- `foo/src/client/public` - You've moved all the files from this directory in step 5.
8. Update all the `@wasp` imports in your JS/TS source files (i.e., the `foo/src` directory).
8. Update all the `@wasp` imports in your JS(X)/TS(X) source files in the `src/` dir.
The easiest way to get this done is by using the tool that we prepared
specifically for this purpose: [wasp-codemod](https://github.com/wasp-lang/wasp-codemod).
For this, we prepared a special script that will rewrite these imports automatically for you.
Clone the `wasp-codemod` repo and look at the `README.md` for instructions. Shortly, you will want to go into the `wasp-codemod` repo dir, run `npm install` in it and then `npm run imports-0-11 -- <path-to-your-wasp-project-src-dir>` (e.g. `npm run imports-0-11 -- ../foo/src`). When it is done, we suggest checking the changes it did, in case some kind of manual intervention is needed.
Before doing this step, as the script will modify your JS(X)/TS(X) files in place, we advise commiting
all changes you have so far, so you can then both easily inspect the import rewrites that our
script did (with `git diff`) and also revert them if something went wrong.
To run the import-rewriting script, make sure you are in the root dir of your wasp project, and then run
```
npx jscodeshift@0.15.1 -t https://raw.githubusercontent.com/wasp-lang/wasp-codemod/main/src/transforms/imports-from-0-11-to-0-12.ts --extensions=js,ts,jsx,tsx src/
```
Then, check the changes it did, in case some kind of manual intervention is needed (in which case you should see TODO comments generated by the script).
**NOTE:** Running this command will modify your JS/TS files in place!
Alternatively, you can find all the mappings of old imports to the new ones in [this table](https://docs.google.com/spreadsheets/d/1QW-_16KRGTOaKXx9NYUtjk6m2TQ0nUMOA74hBthTH3g/edit#gid=1725669920) and use it to fix some/all of them manually.
9. Replace the Wasp file in `foo` (i.e., `main.wasp`) with the Wasp file from `foo_old`
10. Change the Wasp version field in your Wasp file (now residing in `foo`) to `"^0.12.0"`.