Skip to content

Commit 9571d15

Browse files
authored
Add types for cds.utils.colors (#263)
1 parent 5088c75 commit 9571d15

File tree

3 files changed

+67
-1
lines changed

3 files changed

+67
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/).
99
### Added
1010
- `cds.app` typed as express.js application
1111
- `cds.cli` CLI arguments
12-
- `cds.requires` types for MTX services.
12+
- `cds.requires` types for MTX services
13+
- `cds.utils.colors` types
1314

1415
### Changed
1516
- Most `cds.requires` entries are now optionals.

apis/utils.d.ts

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,4 +87,57 @@ declare const utils: {
8787
* @see https://cap.cloud.sap/docs/node.js/cds-utils#async-rm-path
8888
*/
8989
rm: (...path: string[]) => Promise<ReturnType<typeof fs.promises.rm>>,
90+
91+
/**
92+
* @since 8.3.0
93+
* @see https://cap.cloud.sap/docs/node.js/cds-utils#colors
94+
*/
95+
colors: {
96+
enabled: boolean,
97+
RESET: '\x1b[0m',
98+
BOLD: '\x1b[1m' | '',
99+
BRIGHT: '\x1b[1m' | '',
100+
DIMMED: '\x1b[2m' | '',
101+
ITALIC: '\x1b[3m' | '',
102+
UNDER: '\x1b[4m' | '',
103+
BLINK: '\x1b[5m' | '',
104+
FLASH: '\x1b[6m' | '',
105+
INVERT: '\x1b[7m' | '',
106+
BLACK: '\x1b[30m' | '',
107+
RED: '\x1b[31m' | '',
108+
GREEN: '\x1b[32m' | '',
109+
YELLOW: '\x1b[33m' | '',
110+
BLUE: '\x1b[34m' | '',
111+
PINK: '\x1b[35m' | '',
112+
CYAN: '\x1b[36m' | '',
113+
LIGHT_GRAY: '\x1b[37m' | '',
114+
DEFAULT: '\x1b[39m' | '',
115+
GRAY: '\x1b[90m' | '',
116+
LIGHT_RED: '\x1b[91m' | '',
117+
LIGHT_GREEN: '\x1b[92m' | '',
118+
LIGHT_YELLOW: '\x1b[93m' | '',
119+
LIGHT_BLUE: '\x1b[94m' | '',
120+
LIGHT_PINK: '\x1b[95m' | '',
121+
LIGHT_CYAN: '\x1b[96m' | '',
122+
WHITE: '\x1b[97m' | '',
123+
bg: {
124+
BLACK: '\x1b[40m' | '',
125+
RED: '\x1b[41m' | '',
126+
GREEN: '\x1b[42m' | '',
127+
YELLOW: '\x1b[43m' | '',
128+
BLUE: '\x1b[44m' | '',
129+
PINK: '\x1b[45m' | '',
130+
CYAN: '\x1b[46m' | '',
131+
WHITE: '\x1b[47m' | '',
132+
DEFAULT: '\x1b[49m' | '',
133+
LIGHT_GRAY: '\x1b[100m' | '',
134+
LIGHT_RED: '\x1b[101m' | '',
135+
LIGHT_GREEN: '\x1b[102m' | '',
136+
LIGHT_YELLOW: '\x1b[103m' | '',
137+
LIGHT_BLUE: '\x1b[104m' | '',
138+
LIGHT_PINK: '\x1b[105m' | '',
139+
LIGHT_CYAN: '\x1b[106m' | '',
140+
LIGHT_WHITE: '\x1b[107m' | '',
141+
},
142+
},
90143
}

test/typescript/apis/project/cds-utils.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,15 @@ await rimraf('dist/db/data')
3636
const { rm } = cds.utils
3737
await rm('dist','db','data')
3838
await rm('dist/db/data')
39+
40+
const { colors } = cds.utils
41+
const {
42+
enabled,
43+
RESET, BOLD, BRIGHT, DIMMED, ITALIC, UNDER, BLINK, FLASH, INVERT,
44+
BLACK, RED, GREEN, YELLOW, BLUE, PINK, CYAN, LIGHT_GRAY, DEFAULT, GRAY, LIGHT_RED, LIGHT_GREEN, LIGHT_YELLOW, LIGHT_BLUE, LIGHT_PINK, LIGHT_CYAN, WHITE,
45+
bg
46+
} = colors
47+
enabled;
48+
RESET; BOLD; BRIGHT; DIMMED; ITALIC; UNDER; BLINK; FLASH; INVERT;
49+
BLACK; RED; GREEN; YELLOW; BLUE; PINK; CYAN; LIGHT_GRAY; DEFAULT; GRAY; LIGHT_RED; LIGHT_GREEN; LIGHT_YELLOW; LIGHT_BLUE; LIGHT_PINK; LIGHT_CYAN; WHITE;
50+
bg.BLACK; bg.RED; bg.GREEN; bg.YELLOW; bg.BLUE; bg.PINK; bg.CYAN; bg.WHITE; bg.DEFAULT; bg.LIGHT_GRAY; bg.LIGHT_RED; bg.LIGHT_GREEN; bg.LIGHT_YELLOW; bg.LIGHT_BLUE; bg.LIGHT_PINK; bg.LIGHT_CYAN; bg.LIGHT_WHITE

0 commit comments

Comments
 (0)