(pagePath: string, code: string)
| 272 | const exampleSlugFromFile = (file: string) => stripExt(path.basename(file)) |
| 273 | |
| 274 | const collectBlocks = async (pagePath: string, code: string) => { |
| 275 | const groupRoot = path.dirname(path.dirname(pagePath)) |
| 276 | const isTsLike = (n: string) => /\.(tsx|ts)$/.test(n) && !n.endsWith('.d.ts') |
| 277 | const seen = new Set<string>() |
| 278 | const queue: string[] = [pagePath] |
| 279 | const rootEntries = await fs.readdir(groupRoot, { withFileTypes: true }) |
| 280 | for (const e of rootEntries) { |
| 281 | if (e.isFile() && isTsLike(e.name)) { |
| 282 | const fp = path.join(groupRoot, e.name) |
| 283 | if (!seen.has(fp)) { |
| 284 | seen.add(fp) |
| 285 | queue.push(fp) |
| 286 | } |
| 287 | } |
| 288 | } |
| 289 | while (queue.length) { |
| 290 | const file = queue.pop()! |
| 291 | const src = file === pagePath ? code : await read(file) |
| 292 | const specs = importSpecifiers(src) |
| 293 | for (const s of specs) { |
| 294 | if (s.startsWith('./') || s.startsWith('../')) { |
| 295 | const p = await resolveLocalPath(file, s) |
| 296 | if (p && p.startsWith(groupRoot) && !seen.has(p)) { |
| 297 | seen.add(p) |
| 298 | queue.push(p) |
| 299 | } |
| 300 | } |
| 301 | } |
| 302 | } |
| 303 | seen.delete(pagePath) |
| 304 | return [...seen] |
| 305 | } |
| 306 | |
| 307 | async function rewritePrivatesToRegistry( |
| 308 | fromFile: string, |
no test coverage detected