Skip to content

Commit 9a0aa59

Browse files
committed
build: package stats
1 parent 1dafb6e commit 9a0aa59

5 files changed

Lines changed: 47 additions & 31 deletions

File tree

package.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
"test:ui": "vitest --ui",
3333
"test:watch": "vitest watch",
3434
"test:coverage": "vitest run --coverage",
35-
"build": "tsup",
35+
"build": "tsup && size-limit dist/index.js && cloc src",
3636
"build:watch": "tsup --watch",
3737
"build:docs": "npm run build && typedoc"
3838
},
@@ -48,9 +48,12 @@
4848
"@types/node": "^20.12.7",
4949
"@vitest/coverage-istanbul": "^3.2.4",
5050
"@vitest/ui": "3.2.4",
51+
"cloc": "^2.6.0-cloc",
5152
"cross-env": "^10.1.0",
5253
"husky": "^9.0.11",
5354
"lint-staged": "^16.2.4",
55+
"size-limit": "^11.2.0",
56+
"size-limit-preset-node-lib": "^0.4.0",
5457
"ts-node": "^10.9.2",
5558
"tsup": "^8.5.0",
5659
"typedoc": "~0.26.11",

test/core/PaletteError.spec.ts

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,12 @@ test('PaletteError.palette - should return a Chalk instance with specified style
2222
expect(result).toBe(expected);
2323
});
2424

25-
test(
26-
'PaletteError.palette - should return a Chalk instance with default style if styles parameter is not a string',
27-
() => {
28-
const paletteError = new PaletteError('');
29-
const result = paletteError.palette(undefined, chalk);
30-
const expected = chalk;
31-
expect(result).toBe(expected);
32-
}
33-
);
25+
test('PaletteError.palette - should return a Chalk instance with default style if styles parameter is not a string', () => {
26+
const paletteError = new PaletteError('');
27+
const result = paletteError.palette(undefined, chalk);
28+
const expected = chalk;
29+
expect(result).toBe(expected);
30+
});
3431

3532
test('PaletteError.padding - should add padding around the provided content', () => {
3633
const content = 'Test content';

test/core/PrintError.spec.ts

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,14 @@ test('PrintError.opening - should generate correct opening part of error stack t
2020
const errorMessage = 'Test error message';
2121
const printError = new PrintError(errorMessage);
2222
const opening = printError['opening']();
23-
const expectedPrefix = printError['highlight']('red', printError['divide'](process.stdout?.columns - 20));
24-
const expectedSuffix = printError['highlight']('red', printError['divide'](process.stdout?.columns - 20));
23+
const expectedPrefix = printError['highlight'](
24+
'red',
25+
printError['divide'](process.stdout?.columns - 20),
26+
);
27+
const expectedSuffix = printError['highlight'](
28+
'red',
29+
printError['divide'](process.stdout?.columns - 20),
30+
);
2531
expect(opening).toContain(errorMessage);
2632
expect(opening).toContain(expectedPrefix);
2733
expect(opening).toContain(expectedSuffix);
@@ -31,8 +37,14 @@ test('PrintError.closing - should generate correct closing part of error stack t
3137
const errorMessage = 'Test error message';
3238
const printError = new PrintError(errorMessage);
3339
const closing = printError['closing']();
34-
const expectedPrefix = printError['highlight']('red', printError['divide'](process.stdout?.columns - 21));
35-
const expectedSuffix = printError['highlight']('red', printError['divide'](1));
40+
const expectedPrefix = printError['highlight'](
41+
'red',
42+
printError['divide'](process.stdout?.columns - 21),
43+
);
44+
const expectedSuffix = printError['highlight'](
45+
'red',
46+
printError['divide'](1),
47+
);
3648
expect(closing).toContain(printError.constructor.name);
3749
expect(closing).toContain(expectedPrefix);
3850
expect(closing).toContain(expectedSuffix);
@@ -42,13 +54,14 @@ test('PrintError.print - should generate correct trace information', () => {
4254
const printError = new PrintError('');
4355
const track: TraceOption[] = [
4456
{
45-
original: 'at exampleFunction (/path/to/example-package/example.js:10:1)',
57+
original:
58+
'at exampleFunction (/path/to/example-package/example.js:10:1)',
4659
file: 'example.js',
4760
line: 10,
4861
col: 1,
4962
name: 'exampleFunction',
5063
packageName: 'example-package',
51-
address: '/path/to/example-package/example.js'
64+
address: '/path/to/example-package/example.js',
5265
},
5366
{
5467
original: 'at anotherFunction (/path/to/current/another.js:20:2)',
@@ -57,8 +70,8 @@ test('PrintError.print - should generate correct trace information', () => {
5770
col: 2,
5871
name: 'anotherFunction',
5972
packageName: '[current]',
60-
address: '/path/to/current/another.js'
61-
}
73+
address: '/path/to/current/another.js',
74+
},
6275
];
6376

6477
const expected =

test/core/TraceError.spec.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ test('trace - should return correct anonymous trace options array', () => {
2323
file: 'file.js',
2424
line: 1,
2525
col: 2,
26-
packageName: '[current]'
26+
packageName: '[current]',
2727
},
2828
{
2929
original: 'at example/file.js:3:4',
@@ -32,8 +32,8 @@ test('trace - should return correct anonymous trace options array', () => {
3232
file: 'file.js',
3333
line: 3,
3434
col: 4,
35-
packageName: '[current]'
36-
}
35+
packageName: '[current]',
36+
},
3737
];
3838
expect(result).toEqual(expected);
3939
});
@@ -52,8 +52,8 @@ test('trace - should return correct partial trace options array', () => {
5252
file: undefined,
5353
line: undefined,
5454
col: undefined,
55-
packageName: '[current]'
56-
}
55+
packageName: '[current]',
56+
},
5757
];
5858
expect(result).toEqual(expected);
5959
});
@@ -93,16 +93,17 @@ test('trace - should return correct trace options array', () => {
9393
file: 'file.js',
9494
line: 123,
9595
col: 456,
96-
packageName: '[current]'
96+
packageName: '[current]',
9797
},
9898
{
99-
original: 'at eval (eval at <anonymous> (example/file.js:789:101112), <anonymous>:1:2)',
99+
original:
100+
'at eval (eval at <anonymous> (example/file.js:789:101112), <anonymous>:1:2)',
100101
name: 'eval',
101102
address: 'example/file.js:789:101112',
102103
file: 'file.js',
103104
line: 789,
104105
col: 101112,
105-
packageName: '[current]'
106+
packageName: '[current]',
106107
},
107108
{
108109
original: 'at Object.<anonymous> (example/file.js:171819:20)',
@@ -111,7 +112,7 @@ test('trace - should return correct trace options array', () => {
111112
file: 'file.js',
112113
line: 171819,
113114
col: 20,
114-
packageName: '[current]'
115+
packageName: '[current]',
115116
},
116117
{
117118
original: 'at Object.<anonymous> (example/file.js:212223:24)',
@@ -120,8 +121,8 @@ test('trace - should return correct trace options array', () => {
120121
file: 'file.js',
121122
line: 212223,
122123
col: 24,
123-
packageName: '[current]'
124-
}
124+
packageName: '[current]',
125+
},
125126
];
126127
expect(result).toEqual(expected);
127128
});

test/helpers/get-address.spec.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ test('getAddress - should return empty string if no parentheses are found', () =
1616
});
1717

1818
test('getAddress - should return empty string if parentheses are not closed', () => {
19-
const text = 'This is a test string with an open parenthesis ( but no closing parenthesis';
19+
const text =
20+
'This is a test string with an open parenthesis ( but no closing parenthesis';
2021
const result = getAddress(text);
2122
const expected = '';
2223
expect(result).toBe(expected);
@@ -38,7 +39,8 @@ test('getAddress - should return the content within the last set of parentheses'
3839
});
3940

4041
test('getAddress - should handle nested parentheses and return the content within the outermost set', () => {
41-
const text = 'This is a test string with (nested (parentheses) within parentheses)';
42+
const text =
43+
'This is a test string with (nested (parentheses) within parentheses)';
4244
const result = getAddress(text);
4345
const expected = 'parentheses';
4446
expect(result).toBe(expected);

0 commit comments

Comments
 (0)