(home: string)
| 85 | |
| 86 | /** Enumerate imported bundle ids (newest-first by directory mtime). */ |
| 87 | export async function listImportedIds(home: string): Promise<string[]> { |
| 88 | const root = importedRootOf(home); |
| 89 | let entries: import('node:fs').Dirent[]; |
| 90 | try { |
| 91 | entries = await readdir(root, { withFileTypes: true }); |
| 92 | } catch { |
| 93 | return []; |
| 94 | } |
| 95 | const ids = entries |
| 96 | .filter((e) => e.isDirectory() && isImportId(e.name)) |
| 97 | .map((e) => e.name); |
| 98 | const withMtime = await Promise.all( |
| 99 | ids.map(async (id) => { |
| 100 | const mtime = await stat(join(root, id)).then((s) => s.mtimeMs).catch(() => 0); |
| 101 | return { id, mtime }; |
| 102 | }), |
| 103 | ); |
| 104 | return withMtime.toSorted((a, b) => b.mtime - a.mtime).map((x) => x.id); |
| 105 | } |
| 106 | |
| 107 | export async function readImportMeta(home: string, importId: string): Promise<ImportInfo | null> { |
| 108 | try { |
no test coverage detected