Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migration progress script #150

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion apps/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
"lint": "eslint . --ignore-path .gitignore",
"lint:fix": "eslint . --ext .ts,.js,.tsx,.jsx --fix",
"lint:report": "eslint . --format json --output-file ../../lint-results/web.json",
"check-changed-files": "ts-node scripts/ts-check-changed-files.ts"
"check-changed-files": "ts-node scripts/ts-check-changed-files.ts",
"show-migration-progress": "ts-node scripts/show-migration-progress.ts"
},
"engines": {
"node": "18",
Expand Down
44 changes: 44 additions & 0 deletions apps/web/scripts/show-migration-progress.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import { glob } from "glob";
import { posix } from "path";

const run = async () => {
const legacyPagePaths = await glob("pages/**/*.{ts,tsx}", {
ignore: "pages/api/**",
});
const legacyPageCount = legacyPagePaths.length;

const map: Map<string, string | null> = new Map(legacyPagePaths.map((path) => [path.split(".")[0], null]));

const futurePagePaths = await glob("app/future/**/page.tsx");
const futurePageCount = futurePagePaths.length;

for (const futurePagePath of futurePagePaths) {
const pathWithoutSharedLayout = futurePagePath
.split(posix.sep)
.filter((segment) => !segment.startsWith("("))
.slice(2, -1)
.join(posix.sep);
const legacyPath = ["pages", pathWithoutSharedLayout].join(posix.sep);

[legacyPath, `${legacyPath}/index`].forEach((path) => {
if (map.has(path)) {
map.set(path, futurePagePath);
}
});
}

const data = Array.from(map.entries())
.map(([legacyPagePath, futurePagePath]) => ({
legacyPagePath,
futurePagePath,
migrated: futurePagePath !== null,
}))
.sort((a) => {
return a.migrated ? -1 : 1;
});

console.log(`Migrated: ${futurePageCount} / ${legacyPageCount}`);
console.table(data);
};

run();
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@
"c8": "^7.13.0",
"checkly": "latest",
"dotenv-checker": "^1.1.5",
"glob": "^10.3.10",
"husky": "^8.0.0",
"i18n-unused": "^0.13.0",
"jest-diff": "^29.5.0",
Expand Down
Loading
Loading