styled-components-to-stylex-codemod 0.0.7 → 0.0.10
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/README.md +82 -58
- package/dist/index.d.mts +1 -1
- package/dist/index.mjs +76 -21
- package/dist/logger-BLeJjMzG.mjs +306 -0
- package/dist/logger-DC-1uogs.d.mts +452 -0
- package/dist/transform.d.mts +1 -2
- package/dist/transform.mjs +18194 -7713
- package/package.json +37 -29
- package/dist/logger-BS4Evg0n.d.mts +0 -175
- package/dist/logger-Dlnt1fYP.mjs +0 -156
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "styled-components-to-stylex-codemod",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10",
|
|
4
4
|
"description": "Codemod to transform styled-components to StyleX",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"codemod",
|
|
@@ -30,43 +30,46 @@
|
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
32
|
"jscodeshift": "^17.3.0",
|
|
33
|
+
"postcss-selector-parser": "^7.1.1",
|
|
33
34
|
"postcss-value-parser": "^4.2.0",
|
|
34
|
-
"stylis": "^4.3.
|
|
35
|
+
"stylis": "^4.3.6"
|
|
35
36
|
},
|
|
36
37
|
"devDependencies": {
|
|
37
38
|
"@codemirror/lang-javascript": "^6.2.4",
|
|
38
39
|
"@emotion/is-prop-valid": "^1.4.0",
|
|
39
|
-
"@storybook/react": "^10.
|
|
40
|
-
"@
|
|
41
|
-
"@stylexjs/babel-plugin": "^0.17.4",
|
|
40
|
+
"@storybook/react-vite": "^10.2.7",
|
|
41
|
+
"@stylexjs/babel-plugin": "^0.17.5",
|
|
42
42
|
"@stylexjs/eslint-plugin": "^0.17.5",
|
|
43
|
-
"@stylexjs/stylex": "^0.17.
|
|
44
|
-
"@stylexjs/unplugin": "^0.17.
|
|
43
|
+
"@stylexjs/stylex": "^0.17.5",
|
|
44
|
+
"@stylexjs/unplugin": "^0.17.5",
|
|
45
45
|
"@types/jscodeshift": "^17.3.0",
|
|
46
|
-
"@types/node": "^25.
|
|
47
|
-
"@types/react": "^19.2.
|
|
46
|
+
"@types/node": "^25.2.1",
|
|
47
|
+
"@types/react": "^19.2.13",
|
|
48
48
|
"@types/react-dom": "^19.2.3",
|
|
49
|
-
"@types/stylis": "^4.2.
|
|
50
|
-
"@typescript-eslint/parser": "^8.
|
|
49
|
+
"@types/stylis": "^4.2.7",
|
|
50
|
+
"@typescript-eslint/parser": "^8.54.0",
|
|
51
51
|
"@uiw/react-codemirror": "^4.25.4",
|
|
52
|
-
"@vitejs/plugin-react": "^5.1.
|
|
53
|
-
"@vitest/coverage-v8": "^4.0.
|
|
52
|
+
"@vitejs/plugin-react": "^5.1.3",
|
|
53
|
+
"@vitest/coverage-v8": "^4.0.18",
|
|
54
54
|
"assert": "^2.1.0",
|
|
55
|
+
"concurrently": "^9.2.1",
|
|
55
56
|
"eslint": "^9.39.2",
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"oxlint
|
|
57
|
+
"eslint-plugin-storybook": "10.2.7",
|
|
58
|
+
"knip": "^5.83.1",
|
|
59
|
+
"lefthook": "^2.1.0",
|
|
60
|
+
"oxfmt": "^0.28.0",
|
|
61
|
+
"oxlint": "^1.43.0",
|
|
62
|
+
"oxlint-tsgolint": "^0.11.4",
|
|
61
63
|
"path-browserify": "^1.0.1",
|
|
62
|
-
"react": "^19.2.
|
|
63
|
-
"react-dom": "^19.2.
|
|
64
|
-
"
|
|
65
|
-
"
|
|
66
|
-
"
|
|
64
|
+
"react": "^19.2.4",
|
|
65
|
+
"react-dom": "^19.2.4",
|
|
66
|
+
"react-select": "^5.10.2",
|
|
67
|
+
"storybook": "^10.2.7",
|
|
68
|
+
"styled-components": "^6.3.8",
|
|
69
|
+
"tsdown": "^0.20.3",
|
|
67
70
|
"typescript": "^5.9.3",
|
|
68
|
-
"vite": "^7.3.
|
|
69
|
-
"vitest": "^4.0.
|
|
71
|
+
"vite": "^7.3.1",
|
|
72
|
+
"vitest": "^4.0.18"
|
|
70
73
|
},
|
|
71
74
|
"engines": {
|
|
72
75
|
"node": ">=22.20",
|
|
@@ -78,15 +81,20 @@
|
|
|
78
81
|
"test": "vitest",
|
|
79
82
|
"test:run": "vitest run",
|
|
80
83
|
"test:coverage": "vitest run --coverage",
|
|
81
|
-
"
|
|
82
|
-
"
|
|
84
|
+
"format": "oxfmt",
|
|
85
|
+
"format:check": "oxfmt --check",
|
|
86
|
+
"lint": "concurrently 'pnpm:lint:oxlint' 'pnpm:lint:eslint'",
|
|
87
|
+
"lint:oxlint": "oxlint --type-aware --deny-warnings",
|
|
88
|
+
"lint:eslint": "eslint . --cache --max-warnings=0 --no-warn-ignored",
|
|
83
89
|
"typecheck:src": "tsc --noEmit",
|
|
84
90
|
"typecheck:fixtures": "tsc -p test-cases/tsconfig.json --noEmit",
|
|
85
91
|
"typecheck:playground": "tsc -p playground/tsconfig.json --noEmit",
|
|
86
|
-
"typecheck": "
|
|
87
|
-
"
|
|
92
|
+
"typecheck": "concurrently 'pnpm:typecheck:*'",
|
|
93
|
+
"check": "concurrently 'pnpm:lint' 'pnpm:typecheck' 'pnpm:test:run' 'pnpm:knip' 'pnpm:storybook:build' 'pnpm:build' 'pnpm:format:check'",
|
|
94
|
+
"ci": "pnpm lint && pnpm typecheck && pnpm test:run && pnpm knip && pnpm storybook:build && pnpm build && pnpm format:check",
|
|
88
95
|
"knip": "knip",
|
|
89
96
|
"storybook": "storybook dev -p 6006",
|
|
97
|
+
"storybook:build": "storybook build",
|
|
90
98
|
"playground": "vite --config playground/vite.config.ts",
|
|
91
99
|
"build:playground": "vite build --config playground/vite.config.ts"
|
|
92
100
|
}
|
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
//#region src/adapter.d.ts
|
|
2
|
-
/**
|
|
3
|
-
* Adapter - Single user entry point for customizing the codemod.
|
|
4
|
-
*/
|
|
5
|
-
type ResolveContext = {
|
|
6
|
-
kind: "theme";
|
|
7
|
-
path: string;
|
|
8
|
-
} | {
|
|
9
|
-
kind: "cssVariable";
|
|
10
|
-
name: string;
|
|
11
|
-
fallback?: string;
|
|
12
|
-
definedValue?: string;
|
|
13
|
-
} | {
|
|
14
|
-
kind: "call";
|
|
15
|
-
/**
|
|
16
|
-
* Absolute path of the file currently being transformed.
|
|
17
|
-
* Useful for adapter logic that wants to branch by caller file.
|
|
18
|
-
*/
|
|
19
|
-
callSiteFilePath: string;
|
|
20
|
-
/**
|
|
21
|
-
* Imported name when the callee is a named import (including aliases).
|
|
22
|
-
* Example: `import { transitionSpeed as ts } ...; ts("x")` -> "transitionSpeed"
|
|
23
|
-
*/
|
|
24
|
-
calleeImportedName: string;
|
|
25
|
-
/**
|
|
26
|
-
* Import source for this call: either an absolute file path (relative imports)
|
|
27
|
-
* or the module specifier (package imports).
|
|
28
|
-
*/
|
|
29
|
-
calleeSource: {
|
|
30
|
-
kind: "absolutePath";
|
|
31
|
-
value: string;
|
|
32
|
-
} | {
|
|
33
|
-
kind: "specifier";
|
|
34
|
-
value: string;
|
|
35
|
-
};
|
|
36
|
-
/**
|
|
37
|
-
* Call arguments (only literals are surfaced precisely; everything else is `unknown`).
|
|
38
|
-
*/
|
|
39
|
-
args: Array<{
|
|
40
|
-
kind: "literal";
|
|
41
|
-
value: string | number | boolean | null;
|
|
42
|
-
} | {
|
|
43
|
-
kind: "unknown";
|
|
44
|
-
}>;
|
|
45
|
-
};
|
|
46
|
-
type ResolveResult = {
|
|
47
|
-
/**
|
|
48
|
-
* JS expression string to inline into generated output.
|
|
49
|
-
* Example: `vars.spacingSm` or `calcVars.baseSize`
|
|
50
|
-
*/
|
|
51
|
-
expr: string;
|
|
52
|
-
/**
|
|
53
|
-
* Import statements required by `expr`.
|
|
54
|
-
* These are rendered and merged into the file by the codemod.
|
|
55
|
-
*/
|
|
56
|
-
imports: ImportSpec[];
|
|
57
|
-
/**
|
|
58
|
-
* If true, the transformer should drop the corresponding `--name: ...` definition
|
|
59
|
-
* from the emitted style object (useful when replacing with StyleX vars).
|
|
60
|
-
*/
|
|
61
|
-
dropDefinition?: boolean;
|
|
62
|
-
};
|
|
63
|
-
type ImportSource = {
|
|
64
|
-
kind: "absolutePath";
|
|
65
|
-
value: string;
|
|
66
|
-
} | {
|
|
67
|
-
kind: "specifier";
|
|
68
|
-
value: string;
|
|
69
|
-
};
|
|
70
|
-
type ImportSpec = {
|
|
71
|
-
from: ImportSource;
|
|
72
|
-
names: Array<{
|
|
73
|
-
imported: string;
|
|
74
|
-
local?: string;
|
|
75
|
-
}>;
|
|
76
|
-
};
|
|
77
|
-
interface ExternalStylesContext {
|
|
78
|
-
/** Absolute path of the file being transformed */
|
|
79
|
-
filePath: string;
|
|
80
|
-
/** Local name of the styled component */
|
|
81
|
-
componentName: string;
|
|
82
|
-
/** The export name (may differ from componentName for renamed exports) */
|
|
83
|
-
exportName: string;
|
|
84
|
-
/** Whether it's a default export */
|
|
85
|
-
isDefaultExport: boolean;
|
|
86
|
-
}
|
|
87
|
-
/**
|
|
88
|
-
* Configuration for a custom style merger function that combines stylex.props()
|
|
89
|
-
* results with external className/style props.
|
|
90
|
-
*
|
|
91
|
-
* When configured, generates cleaner output:
|
|
92
|
-
* `{...stylexProps(styles.foo, className, style)}`
|
|
93
|
-
* instead of the verbose pattern:
|
|
94
|
-
* `{...sx} className={[sx.className, className].filter(Boolean).join(" ")} style={{...sx.style, ...style}}`
|
|
95
|
-
*/
|
|
96
|
-
interface StyleMergerConfig {
|
|
97
|
-
/**
|
|
98
|
-
* Function name to use for merging (e.g., "stylexProps" or "mergeStylexProps").
|
|
99
|
-
*/
|
|
100
|
-
functionName: string;
|
|
101
|
-
/**
|
|
102
|
-
* Import source for the merger function.
|
|
103
|
-
* Example: `{ kind: "specifier", value: "@company/ui-utils" }`
|
|
104
|
-
*/
|
|
105
|
-
importSource: ImportSource;
|
|
106
|
-
}
|
|
107
|
-
interface Adapter {
|
|
108
|
-
/** Unified resolver for theme paths + CSS variables. Return null to leave unresolved. */
|
|
109
|
-
resolveValue: (context: ResolveContext) => ResolveResult | null;
|
|
110
|
-
/**
|
|
111
|
-
* Called for exported styled components to determine if they should support
|
|
112
|
-
* external className/style extension. Return true to generate wrapper with
|
|
113
|
-
* className/style/rest merging.
|
|
114
|
-
*/
|
|
115
|
-
shouldSupportExternalStyling: (context: ExternalStylesContext) => boolean;
|
|
116
|
-
/**
|
|
117
|
-
* Custom merger function for className/style combining.
|
|
118
|
-
* When provided, generates cleaner output using this function instead of
|
|
119
|
-
* the verbose className/style merging pattern.
|
|
120
|
-
* Set to `null` to use the verbose pattern (default).
|
|
121
|
-
*
|
|
122
|
-
* Expected merger function signature:
|
|
123
|
-
* ```typescript
|
|
124
|
-
* function merger(
|
|
125
|
-
* styles: StyleXStyles | StyleXStyles[],
|
|
126
|
-
* className?: string,
|
|
127
|
-
* style?: React.CSSProperties
|
|
128
|
-
* ): { className?: string; style?: React.CSSProperties }
|
|
129
|
-
* ```
|
|
130
|
-
*/
|
|
131
|
-
styleMerger: StyleMergerConfig | null;
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* Helper for nicer user authoring + type inference.
|
|
135
|
-
*
|
|
136
|
-
* Usage:
|
|
137
|
-
* export default defineAdapter({
|
|
138
|
-
* resolveValue(ctx) {
|
|
139
|
-
* if (ctx.kind === "theme") {
|
|
140
|
-
* return {
|
|
141
|
-
* expr: `tokens.${ctx.path}`,
|
|
142
|
-
* imports: [
|
|
143
|
-
* { from: { kind: "specifier", value: "./tokens" }, names: [{ imported: "tokens" }] },
|
|
144
|
-
* ],
|
|
145
|
-
* };
|
|
146
|
-
* }
|
|
147
|
-
* return null;
|
|
148
|
-
* },
|
|
149
|
-
*
|
|
150
|
-
* // Enable className/style/rest support for exported components
|
|
151
|
-
* shouldSupportExternalStyling(ctx) {
|
|
152
|
-
* // Example: Enable for all exported components in a shared components folder
|
|
153
|
-
* return ctx.filePath.includes("/shared/components/");
|
|
154
|
-
* },
|
|
155
|
-
* });
|
|
156
|
-
*/
|
|
157
|
-
declare function defineAdapter(adapter: Adapter): Adapter;
|
|
158
|
-
//#endregion
|
|
159
|
-
//#region src/internal/logger.d.ts
|
|
160
|
-
type Severity = "info" | "warning" | "error";
|
|
161
|
-
interface WarningLog {
|
|
162
|
-
severity: Severity;
|
|
163
|
-
type: "unsupported-feature" | "dynamic-node";
|
|
164
|
-
message: string;
|
|
165
|
-
loc?: {
|
|
166
|
-
line: number;
|
|
167
|
-
column: number;
|
|
168
|
-
};
|
|
169
|
-
context?: unknown;
|
|
170
|
-
}
|
|
171
|
-
interface CollectedWarning extends WarningLog {
|
|
172
|
-
filePath: string;
|
|
173
|
-
}
|
|
174
|
-
//#endregion
|
|
175
|
-
export { defineAdapter as i, WarningLog as n, Adapter as r, CollectedWarning as t };
|
package/dist/logger-Dlnt1fYP.mjs
DELETED
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
//#region src/internal/public-api-validation.ts
|
|
2
|
-
function describeValue(value) {
|
|
3
|
-
if (value === null) return "null";
|
|
4
|
-
if (value === void 0) return "undefined";
|
|
5
|
-
if (Array.isArray(value)) return `Array(${value.length})`;
|
|
6
|
-
if (typeof value === "string") return `"${value}"`;
|
|
7
|
-
if (typeof value === "number" || typeof value === "boolean") return String(value);
|
|
8
|
-
if (typeof value === "bigint") return value.toString();
|
|
9
|
-
if (typeof value === "symbol") return value.description ? `Symbol(${value.description})` : "Symbol()";
|
|
10
|
-
if (typeof value === "function") return "[Function]";
|
|
11
|
-
if (typeof value === "object") {
|
|
12
|
-
const ctor = value?.constructor?.name ?? "Object";
|
|
13
|
-
let keys = [];
|
|
14
|
-
try {
|
|
15
|
-
keys = Object.keys(value);
|
|
16
|
-
} catch {}
|
|
17
|
-
const preview = keys.slice(0, 5).join(", ");
|
|
18
|
-
const suffix = keys.length > 5 ? ", ..." : "";
|
|
19
|
-
return keys.length ? `${ctor} { ${preview}${suffix} }` : ctor;
|
|
20
|
-
}
|
|
21
|
-
return "[Unknown]";
|
|
22
|
-
}
|
|
23
|
-
function assertValidAdapter(candidate, where) {
|
|
24
|
-
const obj = candidate;
|
|
25
|
-
const resolveValue = obj?.resolveValue;
|
|
26
|
-
const shouldSupportExternalStyling = obj?.shouldSupportExternalStyling;
|
|
27
|
-
if (!candidate || typeof candidate !== "object") throw new Error([
|
|
28
|
-
`${where}: expected an adapter object.`,
|
|
29
|
-
`Received: ${describeValue(candidate)}`,
|
|
30
|
-
"",
|
|
31
|
-
"Adapter requirements:",
|
|
32
|
-
" - adapter.resolveValue(context) is required",
|
|
33
|
-
" - adapter.shouldSupportExternalStyling(context) is required",
|
|
34
|
-
"",
|
|
35
|
-
"resolveValue(context) is called with one of these shapes:",
|
|
36
|
-
" - { kind: \"theme\", path }",
|
|
37
|
-
" - { kind: \"cssVariable\", name, fallback?, definedValue? }",
|
|
38
|
-
" - { kind: \"call\", callSiteFilePath, calleeImportedName, calleeSource, args }",
|
|
39
|
-
"",
|
|
40
|
-
`Docs/examples: ${ADAPTER_DOCS_URL}`
|
|
41
|
-
].join("\n"));
|
|
42
|
-
if (typeof resolveValue !== "function") throw new Error([
|
|
43
|
-
`${where}: adapter.resolveValue must be a function.`,
|
|
44
|
-
`Received: resolveValue=${describeValue(resolveValue)}`,
|
|
45
|
-
"",
|
|
46
|
-
"Adapter shape:",
|
|
47
|
-
" {",
|
|
48
|
-
" resolveValue(context) { return { expr: string, imports: ImportSpec[] } | null }",
|
|
49
|
-
" }",
|
|
50
|
-
"",
|
|
51
|
-
`Docs/examples: ${ADAPTER_DOCS_URL}`
|
|
52
|
-
].join("\n"));
|
|
53
|
-
if (typeof shouldSupportExternalStyling !== "function") throw new Error([`${where}: adapter.shouldSupportExternalStyling must be a function.`, `Received: shouldSupportExternalStyling=${describeValue(shouldSupportExternalStyling)}`].join("\n"));
|
|
54
|
-
const styleMerger = obj?.styleMerger;
|
|
55
|
-
if (styleMerger !== null && styleMerger !== void 0) {
|
|
56
|
-
if (typeof styleMerger !== "object") throw new Error([
|
|
57
|
-
`${where}: adapter.styleMerger must be null or an object.`,
|
|
58
|
-
`Received: styleMerger=${describeValue(styleMerger)}`,
|
|
59
|
-
"",
|
|
60
|
-
"Expected shape:",
|
|
61
|
-
" {",
|
|
62
|
-
" functionName: \"stylexProps\",",
|
|
63
|
-
" importSource: { kind: \"specifier\", value: \"@company/ui-utils\" }",
|
|
64
|
-
" }"
|
|
65
|
-
].join("\n"));
|
|
66
|
-
const { functionName, importSource } = styleMerger;
|
|
67
|
-
if (typeof functionName !== "string" || !functionName.trim()) throw new Error([`${where}: adapter.styleMerger.functionName must be a non-empty string.`, `Received: functionName=${describeValue(functionName)}`].join("\n"));
|
|
68
|
-
if (!importSource || typeof importSource !== "object") throw new Error([
|
|
69
|
-
`${where}: adapter.styleMerger.importSource must be an object.`,
|
|
70
|
-
`Received: importSource=${describeValue(importSource)}`,
|
|
71
|
-
"",
|
|
72
|
-
"Expected shape:",
|
|
73
|
-
" { kind: \"specifier\", value: \"@company/ui-utils\" }",
|
|
74
|
-
" or",
|
|
75
|
-
" { kind: \"absolutePath\", value: \"/path/to/module.ts\" }"
|
|
76
|
-
].join("\n"));
|
|
77
|
-
const { kind, value } = importSource;
|
|
78
|
-
if (kind !== "specifier" && kind !== "absolutePath") throw new Error([`${where}: adapter.styleMerger.importSource.kind must be "specifier" or "absolutePath".`, `Received: kind=${describeValue(kind)}`].join("\n"));
|
|
79
|
-
if (typeof value !== "string" || !value.trim()) throw new Error([`${where}: adapter.styleMerger.importSource.value must be a non-empty string.`, `Received: value=${describeValue(value)}`].join("\n"));
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
const ADAPTER_DOCS_URL = `https://github.com/skovhus/styled-components-to-stylex-codemod#adapter`;
|
|
83
|
-
|
|
84
|
-
//#endregion
|
|
85
|
-
//#region src/internal/logger.ts
|
|
86
|
-
var Logger = class Logger {
|
|
87
|
-
static flushWarnings() {
|
|
88
|
-
const result = collected;
|
|
89
|
-
collected = [];
|
|
90
|
-
return result;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Log a warning message to stderr.
|
|
94
|
-
* All codemod warnings go through this so tests can mock it.
|
|
95
|
-
*/
|
|
96
|
-
static warn(message, context) {
|
|
97
|
-
Logger.writeWithSpacing(message, context);
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Log an error message to stderr.
|
|
101
|
-
*/
|
|
102
|
-
static error(message, context) {
|
|
103
|
-
Logger.writeWithSpacing(`${Logger.colorizeErrorLabel("Error")} ${message}`, context);
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* Log transform warnings to stderr and collect them.
|
|
107
|
-
*/
|
|
108
|
-
static logWarnings(warnings, filePath) {
|
|
109
|
-
for (const warning of warnings) {
|
|
110
|
-
collected.push({
|
|
111
|
-
...warning,
|
|
112
|
-
filePath
|
|
113
|
-
});
|
|
114
|
-
const location = warning.loc ? `${filePath}:${warning.loc.line}:${warning.loc.column}` : `${filePath}`;
|
|
115
|
-
const label = Logger.colorizeSeverityLabel(warning.severity);
|
|
116
|
-
Logger.writeWithSpacing(`${label} ${location}\n${warning.message}`, warning.context);
|
|
117
|
-
}
|
|
118
|
-
}
|
|
119
|
-
static writeWithSpacing(message, context) {
|
|
120
|
-
const trimmed = message.replace(/\s+$/u, "");
|
|
121
|
-
const serialized = Logger.formatContext(context);
|
|
122
|
-
process.stderr.write(`${trimmed}${serialized ? `\n${serialized}` : ""}\n\n`);
|
|
123
|
-
}
|
|
124
|
-
static colorizeSeverityLabel(severity) {
|
|
125
|
-
if (severity === "error") return Logger.colorizeErrorLabel("Error");
|
|
126
|
-
if (severity === "info") return Logger.colorizeInfoLabel("Info");
|
|
127
|
-
return Logger.colorizeWarnLabel("Warning");
|
|
128
|
-
}
|
|
129
|
-
static colorizeWarnLabel(label) {
|
|
130
|
-
if (!process.stderr.isTTY) return label;
|
|
131
|
-
return `${WARN_BG_COLOR}${WARN_TEXT_COLOR}${label}${RESET_COLOR}`;
|
|
132
|
-
}
|
|
133
|
-
static colorizeErrorLabel(label) {
|
|
134
|
-
if (!process.stderr.isTTY) return label;
|
|
135
|
-
return `${ERROR_BG_COLOR}${ERROR_TEXT_COLOR}${label}${RESET_COLOR}`;
|
|
136
|
-
}
|
|
137
|
-
static colorizeInfoLabel(label) {
|
|
138
|
-
if (!process.stderr.isTTY) return label;
|
|
139
|
-
return `${INFO_BG_COLOR}${INFO_TEXT_COLOR}${label}${RESET_COLOR}`;
|
|
140
|
-
}
|
|
141
|
-
static formatContext(context) {
|
|
142
|
-
if (typeof context === "undefined") return null;
|
|
143
|
-
return JSON.stringify(context, null, 2);
|
|
144
|
-
}
|
|
145
|
-
};
|
|
146
|
-
let collected = [];
|
|
147
|
-
const WARN_BG_COLOR = "\x1B[43m";
|
|
148
|
-
const WARN_TEXT_COLOR = "\x1B[30m";
|
|
149
|
-
const ERROR_BG_COLOR = "\x1B[41m";
|
|
150
|
-
const ERROR_TEXT_COLOR = "\x1B[37m";
|
|
151
|
-
const INFO_BG_COLOR = "\x1B[44m";
|
|
152
|
-
const INFO_TEXT_COLOR = "\x1B[37m";
|
|
153
|
-
const RESET_COLOR = "\x1B[0m";
|
|
154
|
-
|
|
155
|
-
//#endregion
|
|
156
|
-
export { assertValidAdapter as n, describeValue as r, Logger as t };
|