-
Notifications
You must be signed in to change notification settings - Fork 2
/
twrp.ts
50 lines (49 loc) · 1.65 KB
/
twrp.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import metadata from "https://esm.sh/markdown-yaml-metadata-parser";
export async function twrp() {
const twrpDir = "ota/twrp";
// const oems = [...Deno.readDirSync(`${twrpDir}`)].filter((x) =>
// x.name.startsWith("_")
// ).map((x) => x.name.replace("_", ""));
// console.log(oems);
const twrps: Record<string, any>[] = [];
await Promise.all(
[...Deno.readDirSync(twrpDir)]
.filter((x) => x.isDirectory)
.filter((x) => x.name.startsWith("_"))
.map(async (x) => {
// console.log(x);
await Promise.all(
[...Deno.readDirSync(`${twrpDir}/${x.name}`)].map(async (device) => {
//@ts-ignore -
const data: Record<string, string> = metadata(
await Deno.readTextFile(`${twrpDir}/${x.name}/${device.name}`),
).metadata;
//TODO FIGUERE OUT HOW TO MAKE download urls - etc
// console.log(
// `https://twrp.me/${x.name.replace('_', '')}/${
// data.downloadfolder
// }.html`
// );
// console.log('E');
for (const codename of (data.codename?.split?.(/,|&|\//) || [])) {
twrps.push({
codename: codename.trim(),
brand: data.oem,
name: data.title,
recovery: {
id: "twrp",
xdathread: data.xdathread,
maintainer: data.maintainer,
},
});
}
// console.log(data);
// console.log(data.codename);
}),
);
}),
);
return twrps;
}
await twrp();
// console.log(await twrp());