(input: Info)
| 128 | } |
| 129 | |
| 130 | export async function discover(input: Info) { |
| 131 | if (input.vcs !== "git") return |
| 132 | if (input.icon?.url) return |
| 133 | const glob = new Bun.Glob("**/{favicon}.{ico,png,svg,jpg,jpeg,webp}") |
| 134 | const matches = await Array.fromAsync( |
| 135 | glob.scan({ |
| 136 | cwd: input.worktree, |
| 137 | absolute: true, |
| 138 | onlyFiles: true, |
| 139 | followSymlinks: false, |
| 140 | dot: false, |
| 141 | }), |
| 142 | ) |
| 143 | const shortest = matches.sort((a, b) => a.length - b.length)[0] |
| 144 | if (!shortest) return |
| 145 | const file = Bun.file(shortest) |
| 146 | const buffer = await file.arrayBuffer() |
| 147 | const base64 = Buffer.from(buffer).toString("base64") |
| 148 | const mime = file.type || "image/png" |
| 149 | const url = `data:${mime};base64,${base64}` |
| 150 | await update({ |
| 151 | projectID: input.id, |
| 152 | icon: { |
| 153 | url, |
| 154 | }, |
| 155 | }) |
| 156 | return |
| 157 | } |
| 158 | |
| 159 | async function migrateFromGlobal(newProjectID: string, worktree: string) { |
| 160 | const globalProject = await Storage.read<Info>(["project", "global"]).catch(() => undefined) |
no test coverage detected