Skip to content

Instantly share code, notes, and snippets.

@smucode
Created July 9, 2023 09:46
Show Gist options
  • Select an option

  • Save smucode/06886e2f76d8f1e70a6917344836a756 to your computer and use it in GitHub Desktop.

Select an option

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
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