Skip to content

Commit

Permalink
fix(deps): migrate to gfm v6
Browse files Browse the repository at this point in the history
  • Loading branch information
ayuhito committed Dec 29, 2024
1 parent 96d9c1c commit e95b964
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 22 deletions.
2 changes: 2 additions & 0 deletions .mise.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[tools]
bun = "latest"
Binary file modified bun.lockb
Binary file not shown.
23 changes: 11 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,24 @@
"type": "module",
"private": true,
"scripts": {
"algolia": "tsx scripts/algolia.ts",
"check-duplicates": "tsx scripts/check-duplicates.ts",
"fontlist": "tsx scripts/fontlist.ts",
"gfm-metadata": "tsx scripts/gfm-metadata.ts",
"metadata": "tsx scripts/metadata.ts",
"algolia": "bun run scripts/algolia.ts",
"check-duplicates": "bun run scripts/check-duplicates.ts",
"fontlist": "bun run scripts/fontlist.ts",
"gfm-metadata": "bun run scripts/gfm-metadata.ts",
"metadata": "bun run scripts/metadata.ts",
"test": "fontsource create-verify --all"
},
"author": "Ayuhito <hello@ayuhito.com>",
"license": "MIT",
"dependencies": {
"@fontsource-utils/cli": "0.4.2",
"@fontsource-utils/cli": "0.5.0",
"@fontsource-utils/publish": "^0.3.0",
"@types/node": "^20.12.7",
"algoliasearch": "^4.23.3",
"consola": "^3.2.3",
"google-font-metadata": "^5.2.1",
"@types/node": "^22.10.2",
"algoliasearch": "4",
"consola": "^3.3.3",
"google-font-metadata": "^6.0.0",
"json-stringify-pretty-compact": "^4.0.0",
"pathe": "^1.1.2",
"tsx": "^4.7.2"
"pathe": "^1.1.2"
},
"homepage": "https://fontsource.org",
"repository": {
Expand Down
19 changes: 9 additions & 10 deletions scripts/algolia.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import algoliasearch from 'algoliasearch';
import metadataImport from '../metadata/fontsource.json';
import algoliasearch from "algoliasearch";
import metadataImport from "../metadata/fontsource.json";

interface AlgoliaMetadata {
objectID: string;
Expand All @@ -15,8 +15,7 @@ interface AlgoliaMetadata {
randomIndex: number;
}

// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const client = algoliasearch('WNATE69PVR', process.env.ALGOLIA_ADMIN_KEY!);
const client = algoliasearch("WNATE69PVR", process.env.ALGOLIA_ADMIN_KEY ?? "");

const shuffleArray = (size: number) => {
// Generate array of numbers from 0 to size
Expand All @@ -40,9 +39,9 @@ const updateAlgoliaIndex = async (force?: boolean) => {
// as Algolia does not support random sorting natively
const randomIndexArr = shuffleArray(list.length);

const statsResp = await fetch('https://api.fontsource.org/v1/stats');
const statsResp = await fetch("https://api.fontsource.org/v1/stats");
if (!statsResp.ok) {
throw new Error('Failed to fetch stats');
throw new Error("Failed to fetch stats");
}
const stats = (await statsResp.json()) as Record<
string,
Expand All @@ -66,7 +65,7 @@ const updateAlgoliaIndex = async (force?: boolean) => {
variable: Boolean(metadata.variable),
// Algolia sorts date using a unix timestamp instead
lastModified: Math.floor(
new Date(metadata.lastModified).getTime() / 1000
new Date(metadata.lastModified).getTime() / 1000,
),
downloadMonth: stats[id]?.total.npmDownloadMonthly ?? 0,
randomIndex: randomIndexArr[index],
Expand All @@ -76,13 +75,13 @@ const updateAlgoliaIndex = async (force?: boolean) => {
index++;
}

const searchIndex = client.initIndex('prod_NAME');
const searchIndex = client.initIndex("prod_NAME");
if (force) {
await searchIndex.replaceAllObjects(indexArray);
console.log('Replaced Algolia index');
console.log("Replaced Algolia index");
} else {
await searchIndex.saveObjects(indexArray);
console.log('Updated Algolia index');
console.log("Updated Algolia index");
}
} catch (error) {
console.error(error);
Expand Down

0 comments on commit e95b964

Please sign in to comment.