-
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
145 additions
and
136 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { join } from "node:path"; | ||
import { readdir, rm } from "node:fs/promises"; | ||
|
||
console.log("Starting..."); | ||
|
||
const processStart = performance.now(); | ||
|
||
const { list } = (await Bun.file(join("iconpacks", "list.json")).json()) as { | ||
list: { | ||
id: string; | ||
load: string; | ||
suffix: string; | ||
}[]; | ||
}; | ||
const hashes: Record< | ||
string, | ||
{ | ||
hash: string; | ||
size: number; | ||
} | ||
> = {}; | ||
|
||
for (const ic of list) { | ||
const start = performance.now(); | ||
const [user, repo, branch, ...rawPath] = (ic.load as string) | ||
.split("/") | ||
.slice(3); | ||
const path = rawPath.join("/"); | ||
|
||
const raw = await fetch( | ||
`https://api.github.com/repos/${user}/${repo}/git/trees/${branch}?recursive=1`, | ||
).then((x) => x.json()); | ||
const files = (raw.tree as any[]) | ||
.filter((x) => x.type === "blob") | ||
.filter( | ||
(x) => | ||
x.path.startsWith(path) && | ||
["png", "jpg", "webm", "lottie"].some((ext) => | ||
x.path.endsWith(`${ic.suffix}.${ext}`), | ||
), | ||
) | ||
.map((x) => ({ | ||
size: x.size, | ||
path: x.path.split("/").slice(path.length).join("/"), | ||
})) | ||
.filter((x) => x.path.length > 0); | ||
|
||
hashes[ic.id] = { | ||
hash: raw.sha, | ||
size: files.reduce((a, b) => a + b.size, 0), | ||
}; | ||
await Bun.write( | ||
join("../trees", `${ic.id}.txt`), | ||
files.map((x) => x.path).join("\n"), | ||
); | ||
|
||
console.log( | ||
`Parsed "${ic.id}" [${(performance.now() - start).toFixed(1)}ms]`, | ||
); | ||
} | ||
|
||
for (const f of ( | ||
await readdir("../trees", { | ||
withFileTypes: true, | ||
}) | ||
).filter((x) => x.isFile() && !list.some((y) => x.name === `${y.id}.txt`))) | ||
await rm(join("../trees", f.name)); | ||
|
||
await Bun.write(join("../trees", "_hashes.txt"), JSON.stringify(hashes)); | ||
|
||
console.log(`\nDone [${(performance.now() - processStart).toFixed(1)}ms]`); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
import { join } from "node:path"; | ||
|
||
const processStart = performance.now(); | ||
|
||
const template = await Bun.file( | ||
join(".github/scripts/list_iconpacks", "template.md"), | ||
).text(); | ||
const { list } = (await Bun.file(join("iconpacks", "list.json")).json()) as { | ||
list: { | ||
name: string; | ||
description: string; | ||
credits: { | ||
authors: { id: string; name: string }[]; | ||
sources: string[]; | ||
}; | ||
load: string; | ||
suffix: string; | ||
}[]; | ||
}; | ||
|
||
const packs: string[] = []; | ||
for (const pack of list) { | ||
const authors = pack.credits.authors.map((a) => | ||
a.id ? `[@${a.name}](https://discord.com/users/${a.id})` : `**${a.name}**`, | ||
); | ||
const sources = pack.credits.sources.map((x) => `[${x}](${x})`); | ||
|
||
packs.push( | ||
[ | ||
`### ${pack.name} <img src="${pack.load}design/components/Icon/native/redesign/generated/images/BellIcon${pack.suffix}.png" alt="Preview for ${pack.name}" width=24 height=24 />\n`, | ||
`${pack.description} `, | ||
`Created by: ${ | ||
authors.length > 1 | ||
? `${authors.slice(0, -1).join(", ")} and ${ | ||
authors[authors.length - 1] | ||
}` | ||
: authors.join(", ") | ||
} `, | ||
sources.length === 1 | ||
? `Assets from: ${sources[0]} ` | ||
: sources.length > 1 | ||
? `Assets from:\n\n${sources.map((x) => `- ${x}`).join("\n")} ` | ||
: "", | ||
].join("\n"), | ||
); | ||
} | ||
|
||
await Bun.write( | ||
join("docs", "ICONPACKS.md"), | ||
template.replace(/{{}}/g, packs.join("\n\n")), | ||
); | ||
|
||
console.log(`\nDone [${(performance.now() - processStart).toFixed(1)}ms]`); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters