@bluelovers/jest-config 1.0.15 → 1.0.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/src/print.ts ADDED
@@ -0,0 +1,73 @@
1
+ import { applyStyleBorderless, Table } from '@yarn-tool/table';
2
+ import { TableConstructorOptions } from 'cli-table3';
3
+ import { InitialOptionsTsJest } from 'ts-jest';
4
+ import { console } from 'debug-color2';
5
+ import { inspect } from 'util';
6
+ import { name as jName, version as jVersion } from '../package.json';
7
+
8
+ export function _newTableBorderless(options?: TableConstructorOptions)
9
+ {
10
+ let table = new Table({
11
+ colAligns: ['right', 'left'],
12
+ //colAligns: ['left', 'center', 'center', 'center'],
13
+ chars: {
14
+ top: '',
15
+ 'top-mid': '',
16
+ 'top-left': '',
17
+ 'top-right': '',
18
+ bottom: '',
19
+ 'bottom-mid': '',
20
+ 'bottom-left': '',
21
+ 'bottom-right': '',
22
+ left: '',
23
+ 'left-mid': '',
24
+ mid: '',
25
+ 'mid-mid': '',
26
+ right: '',
27
+ 'right-mid': '',
28
+ middle: '',
29
+ },
30
+ ...options,
31
+ });
32
+
33
+ table = applyStyleBorderless(table);
34
+
35
+ return table;
36
+ }
37
+
38
+ export interface IOptionsPrintJestConfigInfo
39
+ {
40
+ cwd?: string;
41
+ file?: string;
42
+ }
43
+
44
+ export function printJestConfigInfo(jestConfig: InitialOptionsTsJest, options?: IOptionsPrintJestConfigInfo)
45
+ {
46
+ const table = _newTableBorderless();
47
+
48
+ options ??= {};
49
+ // @ts-ignore
50
+ jestConfig ??= {};
51
+
52
+ table.push([`${jName}:`, jVersion]);
53
+ table.push([`process.versions.node:`, process.versions.node]);
54
+ table.push(['cwd:', options.cwd ?? process.cwd()]);
55
+
56
+ options.file?.length && table.push(['file:', options.file]);
57
+
58
+ jestConfig.cacheDirectory?.length && table.push(['cacheDirectory:', jestConfig.cacheDirectory]);
59
+
60
+ jestConfig.rootDir?.length && table.push(['rootDir:', jestConfig.rootDir]);
61
+ jestConfig.roots?.length && table.push(['roots:', inspect(jestConfig.roots)]);
62
+
63
+ jestConfig.preset?.length && table.push(['preset:', jestConfig.preset]);
64
+
65
+ jestConfig.transform && table.push(['transform:', inspect(jestConfig.transform, {
66
+ depth: 3
67
+ })]);
68
+
69
+ console.gray.log('─'.repeat(20));
70
+ console.log(`jest.config`);
71
+ console.log(table.toString());
72
+ console.gray.log('─'.repeat(20));
73
+ }