diff --git a/package.json b/package.json index a0e7d20..b9c76ef 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "@unocss/reset": "^0.62.4", "cheerio": "^1.0.0", "clsx": "^2.1.1", + "consola": "^3.2.3", "dayjs": "^1.11.13", "db0": "npm:@ourongxing/db0@latest", "fast-xml-parser": "^4.5.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index ca0ca45..2575234 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -41,6 +41,9 @@ importers: clsx: specifier: ^2.1.1 version: 2.1.1 + consola: + specifier: ^3.2.3 + version: 3.2.3 dayjs: specifier: ^1.11.13 version: 1.11.13 @@ -3339,7 +3342,6 @@ packages: libsql@0.4.5: resolution: {integrity: sha512-sorTJV6PNt94Wap27Sai5gtVLIea4Otb2LUiAUyr3p6BPOScGMKGt5F1b5X/XgkNtcsDKeX5qfeBDj+PdShclQ==} - cpu: [x64, arm64, wasm32] os: [darwin, linux, win32] lines-and-columns@1.2.4: diff --git a/scripts/favicon.ts b/scripts/favicon.ts index 5f5c724..45c0bc7 100644 --- a/scripts/favicon.ts +++ b/scripts/favicon.ts @@ -3,6 +3,7 @@ import { fileURLToPath } from "node:url" import { join } from "node:path" import { Buffer } from "node:buffer" import { getLogos } from "favicons-scraper" +import { consola } from "consola" import { sources } from "../shared/data" const projectDir = fileURLToPath(new URL("..", import.meta.url)) @@ -16,9 +17,9 @@ async function downloadImage(url: string, outputPath: string, id: string) { const image = await (await fetch(url)).arrayBuffer() fs.writeFileSync(outputPath, Buffer.from(image)) - console.log(`${id}: downloaded successfully.`) + consola.success(`${id}: downloaded successfully.`) } catch (error) { - console.error(`${id}: error downloading the image. `, error) + consola.error(`${id}: error downloading the image. `, error) } } @@ -28,7 +29,7 @@ async function main() { try { const icon = join(iconsDir, `${id.split("-")[0]}.png`) if (fs.existsSync(icon)) { - console.log(`${id}: icon exists. skip.`) + consola.info(`${id}: icon exists. skip.`) return } if (!source.home) return @@ -37,7 +38,7 @@ async function main() { await downloadImage(res[0].src, icon, id) } } catch (e) { - console.error(id, "\n", e) + consola.error(id, "\n", e) } }), )