| 1 | export async function updateJsrPackageExportsToAll( |
| 2 | absPath: string, |
| 3 | p: progress.Ref, |
| 4 | ) { |
| 5 | using _ = p.start("update deno.json"); |
| 6 | const manifestPath = path.join(absPath, "deno.json"); |
| 7 | const deno = JSON.parse( |
| 8 | await fs.readFile(manifestPath, "utf-8"), |
| 9 | ); |
| 10 | const newExports: Record<string, string> = {}; |
| 11 | for (const subPath of await fs.readdir(absPath, { recursive: true })) { |
| 12 | if (!subPath.match(/\.tsx?$/)) continue; |
| 13 | if (subPath.startsWith("examples") || subPath.match(/\.(test|sample)\.tsx?$/)) continue; |
| 14 | if (subPath.startsWith("dist")) continue; |
| 15 | newExports["./" + subPath.replace(/\.tsx?$/, "")] = "./" + subPath; |
| 16 | } |
| 17 | deno.exports = Object.fromEntries( |
| 18 | Object.entries(newExports).sort(([a], [b]) => a.localeCompare(b)), |
| 19 | ) as typeof deno.exports; |
| 20 | await fs.writeFile(manifestPath, JSON.stringify(deno, null, 2)); |
| 21 | } |
| 22 | |
| 23 | export async function main() { |
| 24 | const main = path.resolve("./lib"); |
| 25 | await updateJsrPackageExportsToAll(main, progress); |
| 26 | } |
| 27 | |
| 28 | import * as progress from "@clo/lib/progress"; |
| 29 | import * as fs from "node:fs/promises"; |
| 30 | import * as path from "node:path"; |