mirror of
https://github.com/ourongxing/newsnow.git
synced 2025-01-19 11:19:14 +08:00
feat: logger
This commit is contained in:
parent
a03907d331
commit
a4cf74b9d8
@ -25,6 +25,7 @@
|
|||||||
"@unocss/reset": "^0.62.4",
|
"@unocss/reset": "^0.62.4",
|
||||||
"cheerio": "^1.0.0",
|
"cheerio": "^1.0.0",
|
||||||
"clsx": "^2.1.1",
|
"clsx": "^2.1.1",
|
||||||
|
"consola": "^3.2.3",
|
||||||
"dayjs": "^1.11.13",
|
"dayjs": "^1.11.13",
|
||||||
"db0": "npm:@ourongxing/db0@latest",
|
"db0": "npm:@ourongxing/db0@latest",
|
||||||
"fast-xml-parser": "^4.5.0",
|
"fast-xml-parser": "^4.5.0",
|
||||||
|
4
pnpm-lock.yaml
generated
4
pnpm-lock.yaml
generated
@ -41,6 +41,9 @@ importers:
|
|||||||
clsx:
|
clsx:
|
||||||
specifier: ^2.1.1
|
specifier: ^2.1.1
|
||||||
version: 2.1.1
|
version: 2.1.1
|
||||||
|
consola:
|
||||||
|
specifier: ^3.2.3
|
||||||
|
version: 3.2.3
|
||||||
dayjs:
|
dayjs:
|
||||||
specifier: ^1.11.13
|
specifier: ^1.11.13
|
||||||
version: 1.11.13
|
version: 1.11.13
|
||||||
@ -3339,7 +3342,6 @@ packages:
|
|||||||
|
|
||||||
libsql@0.4.5:
|
libsql@0.4.5:
|
||||||
resolution: {integrity: sha512-sorTJV6PNt94Wap27Sai5gtVLIea4Otb2LUiAUyr3p6BPOScGMKGt5F1b5X/XgkNtcsDKeX5qfeBDj+PdShclQ==}
|
resolution: {integrity: sha512-sorTJV6PNt94Wap27Sai5gtVLIea4Otb2LUiAUyr3p6BPOScGMKGt5F1b5X/XgkNtcsDKeX5qfeBDj+PdShclQ==}
|
||||||
cpu: [x64, arm64, wasm32]
|
|
||||||
os: [darwin, linux, win32]
|
os: [darwin, linux, win32]
|
||||||
|
|
||||||
lines-and-columns@1.2.4:
|
lines-and-columns@1.2.4:
|
||||||
|
@ -3,6 +3,7 @@ import { fileURLToPath } from "node:url"
|
|||||||
import { join } from "node:path"
|
import { join } from "node:path"
|
||||||
import { Buffer } from "node:buffer"
|
import { Buffer } from "node:buffer"
|
||||||
import { getLogos } from "favicons-scraper"
|
import { getLogos } from "favicons-scraper"
|
||||||
|
import { consola } from "consola"
|
||||||
import { sources } from "../shared/data"
|
import { sources } from "../shared/data"
|
||||||
|
|
||||||
const projectDir = fileURLToPath(new URL("..", import.meta.url))
|
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()
|
const image = await (await fetch(url)).arrayBuffer()
|
||||||
fs.writeFileSync(outputPath, Buffer.from(image))
|
fs.writeFileSync(outputPath, Buffer.from(image))
|
||||||
console.log(`${id}: downloaded successfully.`)
|
consola.success(`${id}: downloaded successfully.`)
|
||||||
} catch (error) {
|
} 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 {
|
try {
|
||||||
const icon = join(iconsDir, `${id.split("-")[0]}.png`)
|
const icon = join(iconsDir, `${id.split("-")[0]}.png`)
|
||||||
if (fs.existsSync(icon)) {
|
if (fs.existsSync(icon)) {
|
||||||
console.log(`${id}: icon exists. skip.`)
|
consola.info(`${id}: icon exists. skip.`)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (!source.home) return
|
if (!source.home) return
|
||||||
@ -37,7 +38,7 @@ async function main() {
|
|||||||
await downloadImage(res[0].src, icon, id)
|
await downloadImage(res[0].src, icon, id)
|
||||||
}
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(id, "\n", e)
|
consola.error(id, "\n", e)
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user