Skip to content

Commit 567e754

Browse files
committed
chore: add clarity and improve logging
1 parent beb8b06 commit 567e754

File tree

5 files changed

+43
-16
lines changed

5 files changed

+43
-16
lines changed

bun.lock

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"name": "pickier",
66
"devDependencies": {
77
"@stacksjs/bumpx": "^0.1.17",
8+
"@stacksjs/clarity": "^0.3.23",
89
"@stacksjs/docs": "^0.70.23",
910
"@stacksjs/eslint-config": "^4.14.0-beta.3",
1011
"@stacksjs/gitlint": "^0.1.5",
@@ -591,6 +592,8 @@
591592

592593
"@stacksjs/clapp": ["@stacksjs/clapp@0.1.16", "", { "bin": { "clapp": "dist/bin/cli.js", "@stacksjs/clapp": "dist/bin/cli.js" } }, "sha512-BDmYu9Rk/HHIVc4vQjgQO6MzXNMJvPG6ZGiiEAPQT8EAidx3/6S6O7kyY2UdfJSksiCd5SKFK+WYd1uAs88BrQ=="],
593594

595+
"@stacksjs/clarity": ["@stacksjs/clarity@0.3.23", "", { "bin": { "clarity": "dist/bin/cli.js" } }, "sha512-qrQjjcXWueBSM1vr1i0OmEMGYtCICVBtNvpVtoMLXIqR+jKAGRUqvguEOwg9vKth6VKMBqJ0FDpukJVJZhKGcg=="],
596+
594597
"@stacksjs/cli": ["@stacksjs/cli@0.70.23", "", {}, "sha512-pbu6xESAtRIppcEQlhmRq0yZa1lnYAwtQHh7DmfDcUgVjvahQGe7PXoX+m2dhdFDRthFIVuLeHvrAf1JYv/JOQ=="],
595598

596599
"@stacksjs/docs": ["@stacksjs/docs@0.70.23", "", { "dependencies": { "@iconify-json/carbon": "^1.2.8", "@shikijs/vitepress-twoslash": "^3.2.1", "@vite-pwa/assets-generator": "^1.0.0", "@vite-pwa/vitepress": "^1.0.0", "unocss": "^66.0.0", "unplugin-icons": "^22.1.0", "unplugin-vue-components": "^28.4.1", "vite-plugin-pwa": "^1.0.0", "vitepress": "1.6.3" } }, "sha512-kRk/aza/wQAAgF0fhUhG8bUHhqk3RnjBkZyoRW0fvYs3dLaAArJYX/uVquZixlQnqgizGeGZT986tEFjs5Ly+A=="],
@@ -1945,7 +1948,7 @@
19451948

19461949
"roarr": ["roarr@2.15.4", "", { "dependencies": { "boolean": "^3.0.1", "detect-node": "^2.0.4", "globalthis": "^1.0.1", "json-stringify-safe": "^5.0.1", "semver-compare": "^1.0.0", "sprintf-js": "^1.1.2" } }, "sha512-CHhPh+UNHD2GTXNYhPWLnU8ONHdI+5DI+4EYIAOaiD63rHeYlZvyh8P+in5999TTSFgUYuKUAjzRI4mdh/p+2A=="],
19471950

1948-
"rollup": ["rollup@2.79.2", "", { "optionalDependencies": { "fsevents": "~2.3.2" }, "bin": { "rollup": "dist/bin/rollup" } }, "sha512-fS6iqSPZDs3dr/y7Od6y5nha8dW1YnbgtsyotCVvoFGKbERG++CVRFv1meyGDE1SNItQA8BrnCw7ScdAhRJ3XQ=="],
1951+
"rollup": ["rollup@4.48.1", "", { "dependencies": { "@types/estree": "1.0.8" }, "optionalDependencies": { "@rollup/rollup-android-arm-eabi": "4.48.1", "@rollup/rollup-android-arm64": "4.48.1", "@rollup/rollup-darwin-arm64": "4.48.1", "@rollup/rollup-darwin-x64": "4.48.1", "@rollup/rollup-freebsd-arm64": "4.48.1", "@rollup/rollup-freebsd-x64": "4.48.1", "@rollup/rollup-linux-arm-gnueabihf": "4.48.1", "@rollup/rollup-linux-arm-musleabihf": "4.48.1", "@rollup/rollup-linux-arm64-gnu": "4.48.1", "@rollup/rollup-linux-arm64-musl": "4.48.1", "@rollup/rollup-linux-loongarch64-gnu": "4.48.1", "@rollup/rollup-linux-ppc64-gnu": "4.48.1", "@rollup/rollup-linux-riscv64-gnu": "4.48.1", "@rollup/rollup-linux-riscv64-musl": "4.48.1", "@rollup/rollup-linux-s390x-gnu": "4.48.1", "@rollup/rollup-linux-x64-gnu": "4.48.1", "@rollup/rollup-linux-x64-musl": "4.48.1", "@rollup/rollup-win32-arm64-msvc": "4.48.1", "@rollup/rollup-win32-ia32-msvc": "4.48.1", "@rollup/rollup-win32-x64-msvc": "4.48.1", "fsevents": "~2.3.2" }, "bin": { "rollup": "dist/bin/rollup" } }, "sha512-jVG20NvbhTYDkGAty2/Yh7HK6/q3DGSRH4o8ALKGArmMuaauM9kLfoMZ+WliPwA5+JHr2lTn3g557FxBV87ifg=="],
19491952

19501953
"run-applescript": ["run-applescript@7.0.0", "", {}, "sha512-9by4Ij99JUr/MCFBUkDKLWK3G9HVXmabKz9U5MlIAIuvuzkiOicRYs8XJLxX+xahD+mLiiCYDqF9dKAgtzKP1A=="],
19511954

@@ -2369,16 +2372,22 @@
23692372

23702373
"@pickier/vscode/@types/bun": ["@types/bun@1.2.20", "", { "dependencies": { "bun-types": "1.2.20" } }, "sha512-dX3RGzQ8+KgmMw7CsW4xT5ITBSCrSbfHc36SNT31EOUg/LA9JWq0VDdEXDRSe1InVWpd2yLUM1FUF/kEOyTzYA=="],
23712374

2375+
"@rollup/plugin-babel/rollup": ["rollup@2.79.2", "", { "optionalDependencies": { "fsevents": "~2.3.2" }, "bin": { "rollup": "dist/bin/rollup" } }, "sha512-fS6iqSPZDs3dr/y7Od6y5nha8dW1YnbgtsyotCVvoFGKbERG++CVRFv1meyGDE1SNItQA8BrnCw7ScdAhRJ3XQ=="],
2376+
23722377
"@rollup/plugin-node-resolve/@rollup/pluginutils": ["@rollup/pluginutils@5.2.0", "", { "dependencies": { "@types/estree": "^1.0.0", "estree-walker": "^2.0.2", "picomatch": "^4.0.2" }, "peerDependencies": { "rollup": "^1.20.0||^2.0.0||^3.0.0||^4.0.0" }, "optionalPeers": ["rollup"] }, "sha512-qWJ2ZTbmumwiLFomfzTyt5Kng4hwPi9rwCYN4SHb6eaRU1KNO4ccxINHr/VhH4GgPlt1XfSTLX2LBTme8ne4Zw=="],
23732378

23742379
"@rollup/plugin-replace/magic-string": ["magic-string@0.25.9", "", { "dependencies": { "sourcemap-codec": "^1.4.8" } }, "sha512-RmF0AsMzgt25qzqqLc1+MbHmhdx0ojF2Fvs4XnOqz2ZOBXzzkEwc/dJQZCYHAn7v1jbVOjAZfK8msRn4BxO4VQ=="],
23752380

2381+
"@rollup/plugin-replace/rollup": ["rollup@2.79.2", "", { "optionalDependencies": { "fsevents": "~2.3.2" }, "bin": { "rollup": "dist/bin/rollup" } }, "sha512-fS6iqSPZDs3dr/y7Od6y5nha8dW1YnbgtsyotCVvoFGKbERG++CVRFv1meyGDE1SNItQA8BrnCw7ScdAhRJ3XQ=="],
2382+
23762383
"@rollup/pluginutils/@types/estree": ["@types/estree@0.0.39", "", {}, "sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw=="],
23772384

23782385
"@rollup/pluginutils/estree-walker": ["estree-walker@1.0.1", "", {}, "sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg=="],
23792386

23802387
"@rollup/pluginutils/picomatch": ["picomatch@2.3.1", "", {}, "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA=="],
23812388

2389+
"@rollup/pluginutils/rollup": ["rollup@2.79.2", "", { "optionalDependencies": { "fsevents": "~2.3.2" }, "bin": { "rollup": "dist/bin/rollup" } }, "sha512-fS6iqSPZDs3dr/y7Od6y5nha8dW1YnbgtsyotCVvoFGKbERG++CVRFv1meyGDE1SNItQA8BrnCw7ScdAhRJ3XQ=="],
2390+
23822391
"@secretlint/formatter/chalk": ["chalk@5.6.0", "", {}, "sha512-46QrSQFyVSEyYAgQ22hQ+zDa60YHA4fBstHmtSApj1Y5vKtG27fWowW03jCk5KcbXEWPZUIR894aARCA/G1kfQ=="],
23832392

23842393
"@shikijs/core/@shikijs/engine-javascript": ["@shikijs/engine-javascript@2.5.0", "", { "dependencies": { "@shikijs/types": "2.5.0", "@shikijs/vscode-textmate": "^10.0.2", "oniguruma-to-es": "^3.1.0" } }, "sha512-VjnOpnQf8WuCEZtNUdjjwGUbtAVKuZkVQ/5cHy/tojVVRIRtlWMYVjyWhxOmIq05AlSOv72z7hRNRGVBgQOl0w=="],
@@ -2545,8 +2554,6 @@
25452554

25462555
"validate-npm-package-license/spdx-expression-parse": ["spdx-expression-parse@3.0.1", "", { "dependencies": { "spdx-exceptions": "^2.1.0", "spdx-license-ids": "^3.0.0" } }, "sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q=="],
25472556

2548-
"vite/rollup": ["rollup@4.48.1", "", { "dependencies": { "@types/estree": "1.0.8" }, "optionalDependencies": { "@rollup/rollup-android-arm-eabi": "4.48.1", "@rollup/rollup-android-arm64": "4.48.1", "@rollup/rollup-darwin-arm64": "4.48.1", "@rollup/rollup-darwin-x64": "4.48.1", "@rollup/rollup-freebsd-arm64": "4.48.1", "@rollup/rollup-freebsd-x64": "4.48.1", "@rollup/rollup-linux-arm-gnueabihf": "4.48.1", "@rollup/rollup-linux-arm-musleabihf": "4.48.1", "@rollup/rollup-linux-arm64-gnu": "4.48.1", "@rollup/rollup-linux-arm64-musl": "4.48.1", "@rollup/rollup-linux-loongarch64-gnu": "4.48.1", "@rollup/rollup-linux-ppc64-gnu": "4.48.1", "@rollup/rollup-linux-riscv64-gnu": "4.48.1", "@rollup/rollup-linux-riscv64-musl": "4.48.1", "@rollup/rollup-linux-s390x-gnu": "4.48.1", "@rollup/rollup-linux-x64-gnu": "4.48.1", "@rollup/rollup-linux-x64-musl": "4.48.1", "@rollup/rollup-win32-arm64-msvc": "4.48.1", "@rollup/rollup-win32-ia32-msvc": "4.48.1", "@rollup/rollup-win32-x64-msvc": "4.48.1", "fsevents": "~2.3.2" }, "bin": { "rollup": "dist/bin/rollup" } }, "sha512-jVG20NvbhTYDkGAty2/Yh7HK6/q3DGSRH4o8ALKGArmMuaauM9kLfoMZ+WliPwA5+JHr2lTn3g557FxBV87ifg=="],
2549-
25502557
"vitepress/shiki": ["shiki@2.5.0", "", { "dependencies": { "@shikijs/core": "2.5.0", "@shikijs/engine-javascript": "2.5.0", "@shikijs/engine-oniguruma": "2.5.0", "@shikijs/langs": "2.5.0", "@shikijs/themes": "2.5.0", "@shikijs/types": "2.5.0", "@shikijs/vscode-textmate": "^10.0.2", "@types/hast": "^3.0.4" } }, "sha512-mI//trrsaiCIPsja5CNfsyNOqgAZUb6VpJA+340toL42UpzQlXpwRV9nch69X6gaUxrr9kaOOa6e3y3uAkGFxQ=="],
25512558

25522559
"which-builtin-type/isarray": ["isarray@2.0.5", "", {}, "sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw=="],
@@ -2555,6 +2562,8 @@
25552562

25562563
"workbox-build/pretty-bytes": ["pretty-bytes@5.6.0", "", {}, "sha512-FFw039TmrBqFK8ma/7OL3sDz/VytdtJr044/QUJtH0wK9lb9jLq9tJyIxUwtQJHwar2BqtiA4iCWSwo9JLkzFg=="],
25572564

2565+
"workbox-build/rollup": ["rollup@2.79.2", "", { "optionalDependencies": { "fsevents": "~2.3.2" }, "bin": { "rollup": "dist/bin/rollup" } }, "sha512-fS6iqSPZDs3dr/y7Od6y5nha8dW1YnbgtsyotCVvoFGKbERG++CVRFv1meyGDE1SNItQA8BrnCw7ScdAhRJ3XQ=="],
2566+
25582567
"wrap-ansi/ansi-styles": ["ansi-styles@6.2.1", "", {}, "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug=="],
25592568

25602569
"wrap-ansi/string-width": ["string-width@5.1.2", "", { "dependencies": { "eastasianwidth": "^0.2.0", "emoji-regex": "^9.2.2", "strip-ansi": "^7.0.1" } }, "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA=="],

clarity.config.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import type { ClarityOptions } from '@stacksjs/clarity'
2+
3+
const config: ClarityOptions = {
4+
verbose: false,
5+
}
6+
7+
export default config

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
},
4040
"devDependencies": {
4141
"@stacksjs/bumpx": "^0.1.17",
42+
"@stacksjs/clarity": "^0.3.23",
4243
"@stacksjs/docs": "^0.70.23",
4344
"@stacksjs/eslint-config": "^4.14.0-beta.3",
4445
"@stacksjs/gitlint": "^0.1.5",

packages/pickier/src/formatter.ts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,15 @@ import { glob as tinyGlob } from 'tinyglobby'
77
import { formatCode } from './format'
88
import { getAllPlugins } from './plugins'
99
import { colors, expandPatterns, loadConfigFromPath, shouldIgnorePath } from './utils'
10+
import { Logger } from '@stacksjs/clarity'
11+
12+
const logger = new Logger('pickier', {
13+
showTags: false
14+
})
1015

1116
function trace(...args: any[]) {
1217
if (process.env.PICKIER_TRACE === '1')
13-
console.log('[pickier:trace]', ...args)
18+
logger.debug('[pickier:trace]', args)
1419
}
1520

1621
async function withTimeout<T>(p: Promise<T>, ms: number, label: string): Promise<T> {
@@ -24,7 +29,7 @@ async function withTimeout<T>(p: Promise<T>, ms: number, label: string): Promise
2429
return res as T
2530
}
2631
catch (e) {
27-
console.error(`[pickier:error] ${label} failed:`, (e as any)?.message || e)
32+
logger.error(`[pickier:error] ${label} failed:`, (e as any)?.message || e)
2833
trace('withTimeout error:', label, e)
2934
throw e
3035
}
@@ -176,7 +181,7 @@ export async function runFormat(globs: string[], options: FormatOptions): Promis
176181
const fmt = formatCode(src, cfg, file)
177182
if (options.check) {
178183
if (fmt !== src) {
179-
console.log(`${relative(process.cwd(), file)} needs formatting`)
184+
logger.debug(`${relative(process.cwd(), file)} needs formatting`)
180185
changed++
181186
}
182187
checked++
@@ -191,15 +196,15 @@ export async function runFormat(globs: string[], options: FormatOptions): Promis
191196
else {
192197
// default to check mode when neither flag specified
193198
if (fmt !== src) {
194-
console.log(`${relative(process.cwd(), file)} needs formatting`)
199+
logger.debug(`${relative(process.cwd(), file)} needs formatting`)
195200
changed++
196201
}
197202
checked++
198203
}
199204
}
200205

201206
if (options.verbose) {
202-
console.log(colors.gray(`Checked ${checked} files, ${changed} changed.`))
207+
logger.debug(colors.gray(`Checked ${checked} files, ${changed} changed.`))
203208
}
204209

205210
// In check mode, non-zero exit when changes are needed; otherwise 0

packages/pickier/src/linter.ts

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,16 @@ import { detectQuoteIssues, hasIndentIssue } from './format'
88
import { formatStylish } from './formatter'
99
import { getAllPlugins } from './plugins'
1010
import { colors, expandPatterns, isCodeFile, loadConfigFromPath, shouldIgnorePath } from './utils'
11+
import { Logger } from '@stacksjs/clarity'
12+
13+
const logger = new Logger('pickier:lint', {
14+
showTags: false
15+
})
1116

1217
function trace(...args: any[]) {
1318
if (process.env.PICKIER_TRACE === '1')
1419

15-
console.error('[pickier:trace]', ...args)
20+
logger.error('[pickier:trace]', args)
1621
}
1722

1823
// Programmatic single-text lint with optional cancellation
@@ -263,7 +268,7 @@ async function withTimeout<T>(p: Promise<T>, ms: number, label: string): Promise
263268
catch (e) {
264269
// Always surface timeouts to stderr so users see an error without enabling trace
265270

266-
console.error(`[pickier:error] ${label} failed:`, (e as any)?.message || e)
271+
logger.error(`[pickier:error] ${label} failed:`, (e as any)?.message || e)
267272
trace('withTimeout error:', label, e)
268273
throw e
269274
}
@@ -748,7 +753,7 @@ export async function runLint(globs: string[], options: LintOptions): Promise<nu
748753
issues = scanContent(file, fixed, cfg)
749754

750755
if (options.dryRun && src !== fixed && (options.verbose || cfg.verbose)) {
751-
console.log(colors.gray(`dry-run: would apply fixes in ${relative(process.cwd(), file)}`))
756+
logger.debug(colors.gray(`dry-run: would apply fixes in ${relative(process.cwd(), file)}`))
752757
}
753758
}
754759

@@ -762,19 +767,19 @@ export async function runLint(globs: string[], options: LintOptions): Promise<nu
762767

763768
const reporter = options.reporter || cfg.lint.reporter
764769
if (reporter === 'json') {
765-
console.log(JSON.stringify({ errors, warnings, issues: allIssues }, null, 2))
770+
logger.debug(JSON.stringify({ errors, warnings, issues: allIssues }, null, 2))
766771
}
767772
else if (reporter === 'compact') {
768773
for (const i of allIssues) {
769-
console.log(`${relative(process.cwd(), i.filePath)}:${i.line}:${i.column} ${i.severity} ${i.ruleId} ${i.message}`)
774+
logger.debug(`${relative(process.cwd(), i.filePath)}:${i.line}:${i.column} ${i.severity} ${i.ruleId} ${i.message}`)
770775
}
771776
}
772777
else if (allIssues.length > 0) {
773-
console.log(formatStylish(allIssues))
778+
logger.debug(formatStylish(allIssues))
774779
}
775780

776781
if (options.verbose || cfg.verbose) {
777-
console.log(colors.gray(`Scanned ${files.length} files, found ${errors} errors and ${warnings} warnings.`))
782+
logger.debug(colors.gray(`Scanned ${files.length} files, found ${errors} errors and ${warnings} warnings.`))
778783
}
779784

780785
const maxWarnings = options.maxWarnings ?? cfg.lint.maxWarnings
@@ -795,7 +800,7 @@ export async function runLint(globs: string[], options: LintOptions): Promise<nu
795800
return 0
796801
}
797802
catch (e: any) {
798-
console.error('[pickier:error] runLint failed:', e?.message || e)
803+
logger.error('[pickier:error] runLint failed:', e?.message || e)
799804
trace('runLint:exception', e)
800805
return 1
801806
}

0 commit comments

Comments
 (0)