Skip to content

Commit ceeb7d7

Browse files
committed
feat(reporters): BaseReporter, FancyReporter
Signed-off-by: Lexus Drumgold <[email protected]>
1 parent b477834 commit ceeb7d7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1995
-199
lines changed

.cspell.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,15 @@
3030
"patches/",
3131
"yarn.lock"
3232
],
33-
"ignoreRegExpList": [],
33+
"ignoreRegExpList": ["ansi"],
3434
"ignoreWords": [],
3535
"language": "en-US",
36-
"patterns": [],
36+
"patterns": [
37+
{
38+
"name": "ansi",
39+
"pattern": "/(\\\\u001b)(8|7|H|>|\\[(\\?\\d+(h|l)|[0-2]?(K|J)|\\d*(A|B|C|D\\D|E|F|G|g|i|m|n|S|s|T|u)|1000D\\d+|\\d*;\\d*(f|H|r|m)|\\d+;\\d+;\\d+m))/gi"
40+
}
41+
],
3742
"readonly": true,
3843
"useGitignore": true,
3944
"usePnP": false,

__fixtures__/date.mts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* @file Fixtures - date
3+
* @module fixtures/date
4+
*/
5+
6+
/**
7+
* Fixture date.
8+
*
9+
* @const {Date} date
10+
*/
11+
const date: Date = new Date(2025, 1, 2)
12+
13+
export default date

__fixtures__/error.mts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/**
2+
* @file Fixtures - error
3+
* @module fixtures/error
4+
*/
5+
6+
import pathe from '@flex-development/pathe'
7+
import { dedent } from 'ts-dedent'
8+
9+
/**
10+
* URL of current working directory.
11+
*
12+
* @const {URL} cwd
13+
*/
14+
const cwd: URL = pathe.pathToFileURL(pathe.cwd())
15+
16+
/**
17+
* Fixture error.
18+
*
19+
* @const {Error} error
20+
*/
21+
const error: Error = new Error('This is an example error. Everything is fine!')
22+
23+
error.stack = dedent`
24+
${error.name}: ${error.message}
25+
at ${cwd.pathname}/__fixtures__/error.mts:21:22
26+
at VitestExecutor.runModule (${cwd.href}/node_modules/vite-node/dist/client.mjs:399:5)
27+
at VitestExecutor.directRequest (${cwd.href}/node_modules/vite-node/dist/client.mjs:381:5)
28+
at VitestExecutor.cachedRequest (${cwd.href}/node_modules/vite-node/dist/client.mjs:206:14)
29+
at VitestExecutor.dependencyRequest (${cwd.href}/node_modules/vite-node/dist/client.mjs:259:12)
30+
at ${cwd.pathname}/src/reporters/__tests__/fancy.reporter.functional.spec.mts:9:1
31+
at VitestExecutor.runModule (${cwd.href}/node_modules/vite-node/dist/client.mjs:399:5)
32+
at VitestExecutor.directRequest (${cwd.href}/node_modules/vite-node/dist/client.mjs:381:5)
33+
at VitestExecutor.cachedRequest (${cwd.href}/node_modules/vite-node/dist/client.mjs:206:14)
34+
at VitestExecutor.executeId (${cwd.href}/node_modules/vite-node/dist/client.mjs:173:12)
35+
`
36+
37+
export default error

package.json

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,14 @@
4545
"./reporters": {
4646
"log": "./src/reporters/index.mts",
4747
"default": "./dist/reporters/index.mjs"
48-
},
49-
"./utils": {
50-
"log": "./src/utils/index.mts",
51-
"default": "./dist/utils/index.mjs"
5248
}
5349
},
5450
"imports": {
5551
"#enums/*": {
5652
"log": "./src/enums/*.mts",
5753
"default": "./dist/enums/*.mjs"
5854
},
55+
"#fixtures/*": "./__fixtures__/*.mts",
5956
"#interfaces/*": {
6057
"log": "./src/interfaces/*.mts",
6158
"default": "./dist/interfaces/*.d.mts"
@@ -133,10 +130,12 @@
133130
},
134131
"dependencies": {
135132
"@flex-development/colors": "1.0.1",
133+
"@flex-development/pathe": "4.0.1",
136134
"@flex-development/tutils": "6.0.0-alpha.25",
137135
"devlop": "1.1.0",
138136
"is-unicode-supported": "2.1.0",
139-
"node-inspect-extracted": "3.0.2"
137+
"node-inspect-extracted": "3.0.2",
138+
"string-width": "7.2.0"
140139
},
141140
"devDependencies": {
142141
"@arethetypeswrong/cli": "0.17.3",
@@ -145,20 +144,20 @@
145144
"@eslint/js": "9.19.0",
146145
"@flex-development/commitlint-config": "1.0.1",
147146
"@flex-development/grease": "3.0.0-alpha.9",
148-
"@flex-development/pathe": "4.0.1",
149147
"@stylistic/eslint-plugin": "3.0.1",
150148
"@tsconfig/strictest": "2.0.5",
151149
"@types/eslint": "9.6.1",
152150
"@types/eslint__js": "8.42.3",
153151
"@types/is-ci": "3.0.4",
154-
"@types/node": "22.10.10",
152+
"@types/node": "22.13.1",
155153
"@types/node-notifier": "8.0.5",
156154
"@types/unist": "3.0.3",
157155
"@typescript-eslint/eslint-plugin": "8.23.0",
158156
"@typescript-eslint/parser": "8.23.0",
159157
"@vates/toggle-scripts": "1.0.0",
160158
"@vitest/coverage-v8": "3.0.5",
161159
"@vitest/ui": "3.0.5",
160+
"consola": "3.4.0",
162161
"cross-env": "7.0.3",
163162
"cspell": "8.17.3",
164163
"dprint": "0.49.0",
@@ -258,7 +257,6 @@
258257
"typescript": "5.7.3",
259258
"typescript-eslint": "8.23.0",
260259
"unified": "11.0.5",
261-
"unist-util-size": "4.0.0",
262260
"vfile": "6.0.3",
263261
"vitest": "3.0.5",
264262
"yaml-eslint-parser": "1.2.3"

src/__tests__/logger.spec.mts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ describe('unit:logger', () => {
2626
expect(subject).to.have.property('format').satisfy(isObjectPlain)
2727
expect(subject).to.have.property('level', logLevels.info)
2828
expect(subject).to.have.property('levels', logLevels)
29-
expect(subject).to.have.property('reporters').be.instanceof(Set).and.empty
29+
expect(subject).to.have.property('reporters').be.instanceof(Set)
30+
expect(subject).to.have.nested.property('reporters.size', 1)
3031
expect(subject).to.have.property('stderr', process.stderr)
3132
expect(subject).to.have.property('stdout', process.stdout)
3233
expect(subject).to.have.property('types').with.keys(types)

src/enums/log-levels.mts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,14 @@ import type { LogLevel } from '@flex-development/log'
1515
const logLevels = Object.freeze({
1616
silent: -1,
1717
error: 0,
18+
fatal: 0,
1819
warn: 1,
1920
log: 2,
21+
fail: 3,
2022
info: 3,
23+
ready: 3,
24+
start: 3,
25+
success: 3,
2126
debug: 4,
2227
trace: 5,
2328
verbose: 999

src/enums/log-types.mts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ enum logTypes {
1616
debug = 'debug',
1717
error = 'error',
1818
fail = 'fail',
19+
fatal = 'fatal',
1920
info = 'info',
2021
inspect = 'inspect',
2122
log = 'log',

src/interfaces/__tests__/input-log-object.spec-d.mts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import type TestSubject from '#interfaces/input-log-object'
77
import type { Color } from '@flex-development/colors'
88
import type {
99
LogFormatOptions,
10-
LogLevel,
10+
LogLevelOption,
1111
LogType
1212
} from '@flex-development/log'
1313
import type { Nilable } from '@flex-development/tutils'
@@ -49,16 +49,16 @@ describe('unit-d:interfaces/InputLogObject', () => {
4949
.toEqualTypeOf<Nilable<string>>()
5050
})
5151

52-
it('should match [level?: LogLevel | null | undefined]', () => {
52+
it('should match [level?: LogLevelOption | null | undefined]', () => {
5353
expectTypeOf<TestSubject>()
5454
.toHaveProperty('level')
55-
.toEqualTypeOf<Nilable<LogLevel>>()
55+
.toEqualTypeOf<Nilable<LogLevelOption>>()
5656
})
5757

58-
it('should match [message?: string | null | undefined]', () => {
58+
it('should match [message?: unknown]', () => {
5959
expectTypeOf<TestSubject>()
6060
.toHaveProperty('message')
61-
.toEqualTypeOf<Nilable<string>>()
61+
.toEqualTypeOf<unknown>()
6262
})
6363

6464
it('should match [stack?: string | null | undefined]', () => {
@@ -67,6 +67,12 @@ describe('unit-d:interfaces/InputLogObject', () => {
6767
.toEqualTypeOf<Nilable<string>>()
6868
})
6969

70+
it('should match [tag?: string | null | undefined]', () => {
71+
expectTypeOf<TestSubject>()
72+
.toHaveProperty('tag')
73+
.toEqualTypeOf<Nilable<string>>()
74+
})
75+
7076
it('should match [type?: LogType | null | undefined]', () => {
7177
expectTypeOf<TestSubject>()
7278
.toHaveProperty('type')

src/interfaces/__tests__/log-format-options.spec-d.mts

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,17 @@
44
*/
55

66
import type TestSubject from '#interfaces/log-format-options'
7-
import type { Nilable, Optional } from '@flex-development/tutils'
7+
import type { InspectOptions } from '@flex-development/log'
8+
import type { Nilable } from '@flex-development/tutils'
89

910
describe('unit-d:interfaces/LogFormatOptions', () => {
10-
it('should match [colors?: boolean | null | undefined]', () => {
11+
it('should extend InspectOptions', () => {
12+
expectTypeOf<TestSubject>().toMatchTypeOf<InspectOptions>()
13+
})
14+
15+
it('should match [badge?: boolean | null | undefined]', () => {
1116
expectTypeOf<TestSubject>()
12-
.toHaveProperty('colors')
17+
.toHaveProperty('badge')
1318
.toEqualTypeOf<Nilable<boolean>>()
1419
})
1520

@@ -19,10 +24,10 @@ describe('unit-d:interfaces/LogFormatOptions', () => {
1924
.toEqualTypeOf<Nilable<number>>()
2025
})
2126

22-
it('should match [date?: boolean | undefined]', () => {
27+
it('should match [date?: boolean | null | undefined]', () => {
2328
expectTypeOf<TestSubject>()
2429
.toHaveProperty('date')
25-
.toEqualTypeOf<Optional<boolean>>()
30+
.toEqualTypeOf<Nilable<boolean>>()
2631
})
2732

2833
it('should match [icon?: boolean | null | undefined]', () => {

src/interfaces/__tests__/log-level-map.spec-d.mts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ describe('unit-d:interfaces/LogLevelMap', () => {
1414
expectTypeOf<TestSubject>().toHaveProperty('error').toEqualTypeOf<0>()
1515
})
1616

17+
it('should match [fail: 3]', () => {
18+
expectTypeOf<TestSubject>().toHaveProperty('fail').toEqualTypeOf<3>()
19+
})
20+
21+
it('should match [fatal: 0]', () => {
22+
expectTypeOf<TestSubject>().toHaveProperty('fatal').toEqualTypeOf<0>()
23+
})
24+
1725
it('should match [info: 3]', () => {
1826
expectTypeOf<TestSubject>().toHaveProperty('info').toEqualTypeOf<3>()
1927
})
@@ -22,10 +30,22 @@ describe('unit-d:interfaces/LogLevelMap', () => {
2230
expectTypeOf<TestSubject>().toHaveProperty('log').toEqualTypeOf<2>()
2331
})
2432

33+
it('should match [ready: 3]', () => {
34+
expectTypeOf<TestSubject>().toHaveProperty('ready').toEqualTypeOf<3>()
35+
})
36+
2537
it('should match [silent: -1]', () => {
2638
expectTypeOf<TestSubject>().toHaveProperty('silent').toEqualTypeOf<-1>()
2739
})
2840

41+
it('should match [start: 3]', () => {
42+
expectTypeOf<TestSubject>().toHaveProperty('start').toEqualTypeOf<3>()
43+
})
44+
45+
it('should match [success: 3]', () => {
46+
expectTypeOf<TestSubject>().toHaveProperty('success').toEqualTypeOf<3>()
47+
})
48+
2949
it('should match [trace: 5]', () => {
3050
expectTypeOf<TestSubject>().toHaveProperty('trace').toEqualTypeOf<5>()
3151
})

0 commit comments

Comments
 (0)