Created
July 9, 2023 09:46
-
-
Save smucode/06886e2f76d8f1e70a6917344836a756 to your computer and use it in GitHub Desktop.
Migrate from remix.run v1 to v2 route convention. Just needed to fix up imports, npm run build, and rename the root index.tsx to _index.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const fs = require("fs"); | |
| const rootPath = "./app/routes"; | |
| function migrate(path) { | |
| fs.readdirSync(path).forEach((file) => { | |
| const filePath = `${path}/${file}`; | |
| const stat = fs.statSync(filePath); | |
| if (stat.isDirectory()) { | |
| migrate(filePath); | |
| } else { | |
| if (file.endsWith(".ts") || file.endsWith(".tsx")) { | |
| const targetPath = filePath | |
| .replace(rootPath + "/", "") | |
| .replace("/index.", "/_index.") | |
| .replace(/\//g, "."); | |
| fs.renameSync(filePath, `${rootPath}/${targetPath}`); | |
| } | |
| } | |
| }); | |
| } | |
| migrate(rootPath); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment