mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-02-25 15:24:03 +08:00
* split ts files * packages * nomore workspace? * blah * build, exports * declaration * blargh * turrrrbo * fix fontawesome paths * allow file in eslint, fix ts errors * optimise package, update tsconfig * fix ts * update turbo config * eslint split * fix imports * fix types * lock * add turbo task * script * test task * pretty scripts * update prettier ignore * no cache for tests * lint task * turbo * no out * depend on env * fix mono breaking things * odl * fix version dependency of mongodb-memory-server * Revert "fix version dependency of mongodb-memory-server" This reverts commit52ffac47b1
. * update vitest-mongodb * release scripts * update ci * update dev script * ignore issues around firebase config * add check ts tasks * import isaxioserror * shared types package * replace tsnodedev with tsx * fix import * shared types * module * backend imports * declaration * node version * test code * assert json * verbatim * type * lodash * ts ver * fix fix fix? * remove assert * remove module and resolution * cleanup * tsconfig * fix frontend * remove unecessary props * more unused * remove skiplib * declaration map, dev script * remove install scripts * fix regex * move shared types to package * dont include shared types * remove path * update scripts * test code * test code * fix backend types * fully fix backend * fix frontend d.ts * add .js to imports * remove module * revert add .js * update tsconfig * use bundler module resolution * almost all frontend types * mooore * date fns * fix backend docker * fix ape keys * fix type * clean rimraf type * fix shared-types in workspace * fix import resolving * fix docker builds * ignore type problems on slim-select until new version is released * turrrrbo * fix npm ci * fix lint task * expose env variables needed by frontend build * fix dependencies * package-lock * backend watch ts and lint * add fe and be build scripts to root * fix dev not building packages * shared-types missing eslint * move shared types back to dev-deps * add packages to labeler * add packages step to ci * typo * filter update * remove concurrently from root * add scripts * abbreviate * rename * yeet * fixed path * test pkg * consistent ordering * rename * Revert "backend imports" This reverts commitd715198829
. * fix missing imports, remove last .js * remove test package --------- Co-authored-by: Christian Fehmer <cfe@sexy-developer.com>
61 lines
1.6 KiB
TypeScript
61 lines
1.6 KiB
TypeScript
import * as fs from "fs";
|
|
import * as path from "path";
|
|
import { fileURLToPath } from "url";
|
|
import Fonts from "../static/fonts/_list.json";
|
|
import subsetFont from "subset-font";
|
|
|
|
const __filename = fileURLToPath(import.meta.url);
|
|
const __dirname = path.dirname(__filename);
|
|
|
|
export async function generatePreviewFonts(
|
|
debug: boolean = false
|
|
): Promise<void> {
|
|
const srcDir = __dirname + "/../static/webfonts";
|
|
const targetDir = __dirname + "/../static/webfonts-preview";
|
|
fs.mkdirSync(targetDir, { recursive: true });
|
|
|
|
const srcFiles = fs.readdirSync(srcDir);
|
|
|
|
for (const font of Fonts) {
|
|
if (font.systemFont) continue;
|
|
|
|
const display = (font.display ?? font.name) + "Fontfamily";
|
|
|
|
const fileNames = srcFiles.filter((it) =>
|
|
it.startsWith(font.name.replaceAll(" ", "") + "-")
|
|
);
|
|
|
|
if (fileNames.length !== 1)
|
|
throw new Error(
|
|
`cannot find font file for ${font.name}. Candidates: ${fileNames}`
|
|
);
|
|
const fileName = fileNames[0];
|
|
|
|
await generateSubset(
|
|
srcDir + "/" + fileName,
|
|
targetDir + "/" + fileName,
|
|
display
|
|
);
|
|
if (debug) {
|
|
console.log(
|
|
`Processing ${font.name} with file ${fileName} to display "${display}".`
|
|
);
|
|
}
|
|
}
|
|
}
|
|
|
|
async function generateSubset(
|
|
source: string,
|
|
target: string,
|
|
name: string
|
|
): Promise<void> {
|
|
const font = fs.readFileSync(source);
|
|
const subset = await subsetFont(font, name, {
|
|
targetFormat: "woff2",
|
|
});
|
|
fs.writeFileSync(target, subset);
|
|
}
|
|
//detect if we run this as a main
|
|
if (import.meta.url.endsWith(process.argv[1] as string)) {
|
|
void generatePreviewFonts(true);
|
|
}
|