perf(cli): replace debug with obug (#3019)

* perf: replace debug with obug

* upgrade obug v2
This commit is contained in:
Kevin Deng 2025-11-21 12:40:48 +08:00 committed by GitHub
parent dddfe12274
commit f70331b08e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 24 additions and 12 deletions

View File

@ -66,10 +66,10 @@
"@octokit/rest": "^22.0.1",
"clipanion": "^4.0.0-rc.4",
"colorette": "^2.0.20",
"debug": "^4.4.3",
"emnapi": "^1.7.0",
"es-toolkit": "^1.41.0",
"js-yaml": "^4.1.0",
"obug": "^2.0.0",
"semver": "^7.7.3",
"typanion": "^3.14.0"
},
@ -77,7 +77,6 @@
"@emnapi/runtime": "^1.7.0",
"@oxc-node/core": "^0.0.34",
"@std/toml": "npm:@jsr/std__toml@^1.0.11",
"@types/debug": "^4.1.12",
"@types/inquirer": "^9.0.9",
"@types/js-yaml": "^4.0.9",
"@types/node": "^24.10.0",

View File

@ -1,12 +1,7 @@
import * as colors from 'colorette'
import rawDebug from 'debug'
import { createDebug } from 'obug'
// debug('%i', 'This is an info')
rawDebug.formatters.i = (v) => {
return colors.green(v)
}
declare module 'debug' {
declare module 'obug' {
interface Debugger {
info: typeof console.error
warn: typeof console.error
@ -15,7 +10,14 @@ declare module 'debug' {
}
export const debugFactory = (namespace: string) => {
const debug = rawDebug(`napi:${namespace}`)
const debug = createDebug(`napi:${namespace}`, {
formatters: {
// debug('%i', 'This is an info')
i(v) {
return colors.green(v)
},
},
})
debug.info = (...args: any[]) =>
console.error(colors.black(colors.bgGreen(' INFO ')), ...args)

View File

@ -1132,7 +1132,6 @@ __metadata:
"@octokit/rest": "npm:^22.0.1"
"@oxc-node/core": "npm:^0.0.34"
"@std/toml": "npm:@jsr/std__toml@^1.0.11"
"@types/debug": "npm:^4.1.12"
"@types/inquirer": "npm:^9.0.9"
"@types/js-yaml": "npm:^4.0.9"
"@types/node": "npm:^24.10.0"
@ -1140,12 +1139,12 @@ __metadata:
ava: "npm:^6.4.1"
clipanion: "npm:^4.0.0-rc.4"
colorette: "npm:^2.0.20"
debug: "npm:^4.4.3"
emnapi: "npm:^1.7.0"
empathic: "npm:^2.0.0"
env-paths: "npm:^3.0.0"
es-toolkit: "npm:^1.41.0"
js-yaml: "npm:^4.1.0"
obug: "npm:^2.0.0"
prettier: "npm:^3.6.2"
semver: "npm:^7.7.3"
tsdown: "npm:^0.16.1"
@ -10089,6 +10088,18 @@ __metadata:
languageName: node
linkType: hard
"obug@npm:^2.0.0":
version: 2.0.0
resolution: "obug@npm:2.0.0"
peerDependencies:
ms: ^2.0.0
peerDependenciesMeta:
ms:
optional: true
checksum: 10c0/6508c9e1bdeebfd940e13bd974833c3ed176fb07828b1e7aea5e51fcae3498ce8b4f1f7a7871fd4953a3e5ba445c9cd2824ccdf2488af7ee0f68dbecca29bf75
languageName: node
linkType: hard
"once@npm:^1.3.1, once@npm:^1.4.0":
version: 1.4.0
resolution: "once@npm:1.4.0"