V0.5.0.1
This commit is contained in:
1 parent
bc9c88a548
commit
2cb9ce64cb
32 files changed
+2233
-47
No files matched your search
@@ -0,0 +1,29 @@
|
||||
const fs = require('fs');
|
||||
|
||||
const paths = [
|
||||
'src/app/horaires/train/[trainNumber]/page.tsx',
|
||||
'src/app/[region]/horaires/train/[trainNumber]/page.tsx',
|
||||
'src/app/se-deplacer/horaires/train/[trainNumber]/page.tsx',
|
||||
'src/app/[region]/se-deplacer/horaires/train/[trainNumber]/page.tsx'
|
||||
];
|
||||
|
||||
paths.forEach(p => {
|
||||
if (fs.existsSync(p)) {
|
||||
let content = fs.readFileSync(p, 'utf8');
|
||||
|
||||
// Check if searchParams is already included
|
||||
if (!content.includes('searchParams')) {
|
||||
content = content.replace(/params: Promise<\{([\s\S]*?)\}>;/, 'params: Promise<{$1}>;\n searchParams?: Promise<{ [key: string]: string | string[] | undefined }>;');
|
||||
content = content.replace(/export default async function (.*)\(\{ params \}: (.*)\) \{/, 'export default async function $1({ params, searchParams }: $2) {');
|
||||
content = content.replace(/const \{ (.*) \} = await params;/, 'const { $1 } = await params;\n const resolvedSearchParams = searchParams ? await searchParams : {};\n const dateStr = typeof resolvedSearchParams.date === \'string\' ? resolvedSearchParams.date : undefined;');
|
||||
content = content.replace(/<TrainDetailsClient (.*) \/>/, '<TrainDetailsClient $1 dateStr={dateStr} />');
|
||||
|
||||
fs.writeFileSync(p, content);
|
||||
console.log(`Updated ${p}`);
|
||||
} else {
|
||||
console.log(`Already has searchParams ${p}`);
|
||||
}
|
||||
} else {
|
||||
console.log(`Not found: ${p}`);
|
||||
}
|
||||
});
|
||||
Reference in new issue
Block a user