Skip to content

Commit d017499

Browse files
fix(plugin-multi-tenant): rm chalk dep (#14003)
Fixes #13957 Removes chalk usage and replaces it with a simplified chalk helper since the usage is so low here.
1 parent 2ce6e13 commit d017499

File tree

2 files changed

+37
-1
lines changed

2 files changed

+37
-1
lines changed

packages/plugin-multi-tenant/src/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import { translations } from './translations/index.js'
1616
import { addCollectionAccess } from './utilities/addCollectionAccess.js'
1717
import { addFilterOptionsToFields } from './utilities/addFilterOptionsToFields.js'
1818
import { combineFilters } from './utilities/combineFilters.js'
19+
import { miniChalk } from './utilities/miniChalk.js'
1920

2021
export const multiTenantPlugin =
2122
<ConfigType>(pluginConfig: MultiTenantPluginConfig<ConfigType>) =>
@@ -434,7 +435,7 @@ export const multiTenantPlugin =
434435
)
435436
// eslint-disable-next-line no-console
436437
console.error(
437-
chalk.yellow.bold('WARNING (plugin-multi-tenant)'),
438+
miniChalk.yellowBold('WARNING (plugin-multi-tenant)'),
438439
'missing collections',
439440
missingSlugs,
440441
'try placing the multi-tenant plugin after other plugins.',
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
const codes = {
2+
blue: '\x1b[34m',
3+
bold: '\x1b[1m',
4+
cyan: '\x1b[36m',
5+
dim: '\x1b[2m',
6+
green: '\x1b[32m',
7+
magenta: '\x1b[35m',
8+
red: '\x1b[31m',
9+
reset: '\x1b[0m',
10+
underline: '\x1b[4m',
11+
white: '\x1b[37m',
12+
yellow: '\x1b[33m',
13+
}
14+
15+
function colorize(str: string, ...styles: (keyof typeof codes)[]) {
16+
const start = styles.map((s) => codes[s] || '').join('')
17+
return `${start}${str}${codes.reset}`
18+
}
19+
20+
export const miniChalk = {
21+
blue: (str: string) => colorize(str, 'blue'),
22+
bold: (str: string) => colorize(str, 'bold'),
23+
cyan: (str: string) => colorize(str, 'cyan'),
24+
dim: (str: string) => colorize(str, 'dim'),
25+
green: (str: string) => colorize(str, 'green'),
26+
magenta: (str: string) => colorize(str, 'magenta'),
27+
red: (str: string) => colorize(str, 'red'),
28+
underline: (str: string) => colorize(str, 'underline'),
29+
white: (str: string) => colorize(str, 'white'),
30+
yellow: (str: string) => colorize(str, 'yellow'),
31+
32+
// combos
33+
redBold: (str: string) => colorize(str, 'red', 'bold'),
34+
yellowBold: (str: string) => colorize(str, 'yellow', 'bold'),
35+
}

0 commit comments

Comments
 (0)