( pkgMgr: string, mode: "nextjs" | "react-router" | "qwikcity" )
| 371 | } |
| 372 | |
| 373 | export async function buildREADME( |
| 374 | pkgMgr: string, |
| 375 | mode: "nextjs" | "react-router" | "qwikcity" |
| 376 | ) { |
| 377 | const sortedPaths = Object.values(paths).sort((a, b) => |
| 378 | a.importPath.localeCompare(b.importPath) |
| 379 | ); |
| 380 | |
| 381 | let tasks: string[] = []; |
| 382 | for (const { infoPath, verbs, importKey, pathTemplate } of sortedPaths) { |
| 383 | if (verbs.length > 0) { |
| 384 | for (const verb of verbs) { |
| 385 | tasks.push(`\`${infoPath}\`: Add typing for \`${verb}\``); |
| 386 | tasks.push( |
| 387 | `Convert \`${verb}\` fetch calls to \`${pathTemplate}\` to \`${verb.toLowerCase()}${importKey}(...)\` calls` |
| 388 | ); |
| 389 | } |
| 390 | } else { |
| 391 | tasks.push( |
| 392 | `\`${infoPath}\`: Add search typing to if the page supports search paramaters` |
| 393 | ); |
| 394 | tasks.push( |
| 395 | `Convert \`Link\` components for \`${pathTemplate}\` to \`<${importKey}.Link>\`` |
| 396 | ); |
| 397 | if (infoPath.includes("[")) { |
| 398 | tasks.push( |
| 399 | `Convert \`params\` typing in \`${infoPath.replace( |
| 400 | ".info", |
| 401 | "" |
| 402 | )}\` to \`z.infer<>\`` |
| 403 | ); |
| 404 | } |
| 405 | } |
| 406 | } |
| 407 | |
| 408 | const routes: { |
| 409 | pathTemplate: string; |
| 410 | verb: string; |
| 411 | importKey: string; |
| 412 | usage: string; |
| 413 | }[] = []; |
| 414 | for (const { pathTemplate, verbs, importKey } of sortedPaths) { |
| 415 | if (verbs.length > 0) { |
| 416 | for (const verb of verbs) { |
| 417 | routes.push({ |
| 418 | pathTemplate, |
| 419 | verb, |
| 420 | importKey, |
| 421 | usage: `${verb.toLowerCase()}${importKey}(...)` |
| 422 | }); |
| 423 | } |
| 424 | } else { |
| 425 | routes.push({ |
| 426 | pathTemplate, |
| 427 | verb: "-", |
| 428 | importKey, |
| 429 | usage: `<${importKey}.Link>` |
| 430 | }); |
no test coverage detected