@buoy-design/core 0.1.1 → 0.1.2
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/dist/analysis/audit.d.ts +47 -0
- package/dist/analysis/audit.d.ts.map +1 -0
- package/dist/analysis/audit.js +168 -0
- package/dist/analysis/audit.js.map +1 -0
- package/dist/analysis/index.d.ts +1 -0
- package/dist/analysis/index.d.ts.map +1 -1
- package/dist/analysis/index.js +2 -0
- package/dist/analysis/index.js.map +1 -1
- package/dist/analysis/semantic-diff.d.ts.map +1 -1
- package/dist/analysis/semantic-diff.js +2 -1
- package/dist/analysis/semantic-diff.js.map +1 -1
- package/dist/analysis/token-suggestions.d.ts +8 -1
- package/dist/analysis/token-suggestions.d.ts.map +1 -1
- package/dist/analysis/token-suggestions.js +116 -10
- package/dist/analysis/token-suggestions.js.map +1 -1
- package/dist/extraction/css-parser.d.ts +51 -0
- package/dist/extraction/css-parser.d.ts.map +1 -0
- package/dist/extraction/css-parser.js +303 -0
- package/dist/extraction/css-parser.js.map +1 -0
- package/dist/extraction/index.d.ts +2 -0
- package/dist/extraction/index.d.ts.map +1 -0
- package/dist/extraction/index.js +2 -0
- package/dist/extraction/index.js.map +1 -0
- package/dist/graph/builder.d.ts +118 -0
- package/dist/graph/builder.d.ts.map +1 -0
- package/dist/graph/builder.js +328 -0
- package/dist/graph/builder.js.map +1 -0
- package/dist/graph/collectors/git.d.ts +90 -0
- package/dist/graph/collectors/git.d.ts.map +1 -0
- package/dist/graph/collectors/git.js +253 -0
- package/dist/graph/collectors/git.js.map +1 -0
- package/dist/graph/collectors/imports.d.ts +55 -0
- package/dist/graph/collectors/imports.d.ts.map +1 -0
- package/dist/graph/collectors/imports.js +230 -0
- package/dist/graph/collectors/imports.js.map +1 -0
- package/dist/graph/collectors/index.d.ts +9 -0
- package/dist/graph/collectors/index.d.ts.map +1 -0
- package/dist/graph/collectors/index.js +12 -0
- package/dist/graph/collectors/index.js.map +1 -0
- package/dist/graph/collectors/usages.d.ts +68 -0
- package/dist/graph/collectors/usages.d.ts.map +1 -0
- package/dist/graph/collectors/usages.js +244 -0
- package/dist/graph/collectors/usages.js.map +1 -0
- package/dist/graph/index.d.ts +11 -0
- package/dist/graph/index.d.ts.map +1 -0
- package/dist/graph/index.js +29 -0
- package/dist/graph/index.js.map +1 -0
- package/dist/graph/queries.d.ts +81 -0
- package/dist/graph/queries.d.ts.map +1 -0
- package/dist/graph/queries.js +379 -0
- package/dist/graph/queries.js.map +1 -0
- package/dist/graph/types.d.ts +135 -0
- package/dist/graph/types.d.ts.map +1 -0
- package/dist/graph/types.js +8 -0
- package/dist/graph/types.js.map +1 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -0
- package/dist/index.js.map +1 -1
- package/dist/models/drift.d.ts +6 -0
- package/dist/models/drift.d.ts.map +1 -1
- package/dist/models/drift.js +17 -0
- package/dist/models/drift.js.map +1 -1
- package/dist/models/index.d.ts +3 -3
- package/dist/models/index.d.ts.map +1 -1
- package/dist/models/index.js +2 -2
- package/dist/models/index.js.map +1 -1
- package/dist/models/token.d.ts +57 -0
- package/dist/models/token.d.ts.map +1 -1
- package/dist/models/token.js +9 -0
- package/dist/models/token.js.map +1 -1
- package/dist/tokenization/generator.d.ts +49 -0
- package/dist/tokenization/generator.d.ts.map +1 -0
- package/dist/tokenization/generator.js +886 -0
- package/dist/tokenization/generator.js.map +1 -0
- package/dist/tokenization/index.d.ts +2 -0
- package/dist/tokenization/index.d.ts.map +1 -0
- package/dist/tokenization/index.js +2 -0
- package/dist/tokenization/index.js.map +1 -0
- package/dist/tokens/comparison.d.ts +30 -0
- package/dist/tokens/comparison.d.ts.map +1 -0
- package/dist/tokens/comparison.js +142 -0
- package/dist/tokens/comparison.js.map +1 -0
- package/dist/tokens/index.d.ts +3 -0
- package/dist/tokens/index.d.ts.map +1 -0
- package/dist/tokens/index.js +5 -0
- package/dist/tokens/index.js.map +1 -0
- package/dist/tokens/parser.d.ts +11 -0
- package/dist/tokens/parser.d.ts.map +1 -0
- package/dist/tokens/parser.js +268 -0
- package/dist/tokens/parser.js.map +1 -0
- package/package.json +12 -8
- package/LICENSE +0 -21
- package/dist/analysis/semantic-diff.test.d.ts +0 -2
- package/dist/analysis/semantic-diff.test.d.ts.map +0 -1
- package/dist/analysis/semantic-diff.test.js +0 -188
- package/dist/analysis/semantic-diff.test.js.map +0 -1
- package/dist/models/component.test.d.ts +0 -2
- package/dist/models/component.test.d.ts.map +0 -1
- package/dist/models/component.test.js +0 -55
- package/dist/models/component.test.js.map +0 -1
- package/dist/models/drift.test.d.ts +0 -2
- package/dist/models/drift.test.d.ts.map +0 -1
- package/dist/models/drift.test.js +0 -38
- package/dist/models/drift.test.js.map +0 -1
- package/dist/models/token.test.d.ts +0 -2
- package/dist/models/token.test.d.ts.map +0 -1
- package/dist/models/token.test.js +0 -168
- package/dist/models/token.test.js.map +0 -1
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Usage Collector
|
|
3
|
+
*
|
|
4
|
+
* Finds where tokens and components are used across the codebase.
|
|
5
|
+
* Detects CSS variables, Tailwind classes, and hardcoded values.
|
|
6
|
+
*/
|
|
7
|
+
export type UsageType = 'css-var' | 'tailwind' | 'js-import' | 'hardcoded' | 'scss-var';
|
|
8
|
+
export interface TokenUsage {
|
|
9
|
+
tokenName: string;
|
|
10
|
+
filePath: string;
|
|
11
|
+
lineNumber: number;
|
|
12
|
+
columnNumber: number;
|
|
13
|
+
usageType: UsageType;
|
|
14
|
+
context: string;
|
|
15
|
+
rawValue?: string;
|
|
16
|
+
}
|
|
17
|
+
export interface ComponentUsage {
|
|
18
|
+
componentName: string;
|
|
19
|
+
filePath: string;
|
|
20
|
+
lineNumber: number;
|
|
21
|
+
propsUsed: string[];
|
|
22
|
+
hasChildren: boolean;
|
|
23
|
+
context: string;
|
|
24
|
+
}
|
|
25
|
+
export interface UsageCollectorOptions {
|
|
26
|
+
/** Root directory to scan */
|
|
27
|
+
projectRoot: string;
|
|
28
|
+
/** File patterns to include */
|
|
29
|
+
include?: string[];
|
|
30
|
+
/** File patterns to exclude */
|
|
31
|
+
exclude?: string[];
|
|
32
|
+
/** Known token names to match against */
|
|
33
|
+
knownTokens?: string[];
|
|
34
|
+
/** Known component names to match against */
|
|
35
|
+
knownComponents?: string[];
|
|
36
|
+
}
|
|
37
|
+
export interface UsageCollectorResult {
|
|
38
|
+
tokenUsages: TokenUsage[];
|
|
39
|
+
componentUsages: ComponentUsage[];
|
|
40
|
+
hardcodedValues: TokenUsage[];
|
|
41
|
+
stats: {
|
|
42
|
+
filesScanned: number;
|
|
43
|
+
tokenUsagesFound: number;
|
|
44
|
+
componentUsagesFound: number;
|
|
45
|
+
hardcodedValuesFound: number;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Collect token and component usages from the codebase
|
|
50
|
+
*/
|
|
51
|
+
export declare function collectUsages(options: UsageCollectorOptions): Promise<UsageCollectorResult>;
|
|
52
|
+
/**
|
|
53
|
+
* Find all hardcoded color values in the codebase
|
|
54
|
+
*/
|
|
55
|
+
export declare function findHardcodedColors(projectRoot: string): Promise<TokenUsage[]>;
|
|
56
|
+
/**
|
|
57
|
+
* Find all CSS variable usages
|
|
58
|
+
*/
|
|
59
|
+
export declare function findCSSVariableUsages(projectRoot: string): Promise<TokenUsage[]>;
|
|
60
|
+
/**
|
|
61
|
+
* Find usages of a specific token
|
|
62
|
+
*/
|
|
63
|
+
export declare function findTokenUsagesInFiles(projectRoot: string, tokenName: string): Promise<TokenUsage[]>;
|
|
64
|
+
/**
|
|
65
|
+
* Find usages of a specific component
|
|
66
|
+
*/
|
|
67
|
+
export declare function findComponentUsagesInFiles(projectRoot: string, componentName: string): Promise<ComponentUsage[]>;
|
|
68
|
+
//# sourceMappingURL=usages.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usages.d.ts","sourceRoot":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;GAEG;AACH,wBAAsB,aAAa,CACjC,OAAO,EAAE,qBAAqB,GAC7B,OAAO,CAAC,oBAAoB,CAAC,CAiI/B;AA4JD;;GAEG;AACH,wBAAsB,mBAAmB,CACvC,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,UAAU,EAAE,CAAC,CAQvB;AAED;;GAEG;AACH,wBAAsB,qBAAqB,CACzC,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,UAAU,EAAE,CAAC,CAGvB;AAED;;GAEG;AACH,wBAAsB,sBAAsB,CAC1C,WAAW,EAAE,MAAM,EACnB,SAAS,EAAE,MAAM,GAChB,OAAO,CAAC,UAAU,EAAE,CAAC,CAMvB;AAED;;GAEG;AACH,wBAAsB,0BAA0B,CAC9C,WAAW,EAAE,MAAM,EACnB,aAAa,EAAE,MAAM,GACpB,OAAO,CAAC,cAAc,EAAE,CAAC,CAM3B"}
|
|
@@ -0,0 +1,244 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Usage Collector
|
|
3
|
+
*
|
|
4
|
+
* Finds where tokens and components are used across the codebase.
|
|
5
|
+
* Detects CSS variables, Tailwind classes, and hardcoded values.
|
|
6
|
+
*/
|
|
7
|
+
import { readFile } from 'fs/promises';
|
|
8
|
+
import { glob } from 'glob';
|
|
9
|
+
import { join } from 'path';
|
|
10
|
+
// ============================================================================
|
|
11
|
+
// Patterns
|
|
12
|
+
// ============================================================================
|
|
13
|
+
// CSS variable usage: var(--name) or var(--name, fallback)
|
|
14
|
+
const CSS_VAR_PATTERN = /var\(\s*--([a-zA-Z0-9_-]+)(?:\s*,\s*[^)]+)?\s*\)/g;
|
|
15
|
+
// SCSS variable usage: $name
|
|
16
|
+
const SCSS_VAR_PATTERN = /\$([a-zA-Z][a-zA-Z0-9_-]*)/g;
|
|
17
|
+
// Tailwind arbitrary value: [#fff] or [16px]
|
|
18
|
+
const TAILWIND_ARBITRARY_PATTERN = /(?:bg|text|border|ring|shadow|fill|stroke)-\[([^\]]+)\]/g;
|
|
19
|
+
// Hardcoded hex colors: #fff, #ffffff, #ffffffff
|
|
20
|
+
const HEX_COLOR_PATTERN = /#([0-9a-fA-F]{3,8})\b/g;
|
|
21
|
+
// Hardcoded RGB/RGBA: rgb(255, 255, 255), rgba(0, 0, 0, 0.5)
|
|
22
|
+
const RGB_PATTERN = /rgba?\(\s*\d+\s*,\s*\d+\s*,\s*\d+(?:\s*,\s*[\d.]+)?\s*\)/g;
|
|
23
|
+
// Hardcoded HSL: hsl(0, 0%, 100%), hsla(0, 0%, 0%, 0.5)
|
|
24
|
+
const HSL_PATTERN = /hsla?\(\s*\d+\s*,\s*[\d.]+%\s*,\s*[\d.]+%(?:\s*,\s*[\d.]+)?\s*\)/g;
|
|
25
|
+
// JSX component usage: <ComponentName ... />
|
|
26
|
+
const JSX_COMPONENT_PATTERN = /<([A-Z][a-zA-Z0-9]*)\s*(?:[^>]*?)(?:\/>|>)/g;
|
|
27
|
+
// ============================================================================
|
|
28
|
+
// Collector
|
|
29
|
+
// ============================================================================
|
|
30
|
+
/**
|
|
31
|
+
* Collect token and component usages from the codebase
|
|
32
|
+
*/
|
|
33
|
+
export async function collectUsages(options) {
|
|
34
|
+
const { projectRoot, include = ['**/*.{ts,tsx,js,jsx,vue,svelte,css,scss,sass,less}'], exclude = ['**/node_modules/**', '**/dist/**', '**/build/**', '**/.next/**'], } = options;
|
|
35
|
+
// Find all matching files
|
|
36
|
+
const files = await glob(include, {
|
|
37
|
+
cwd: projectRoot,
|
|
38
|
+
ignore: exclude,
|
|
39
|
+
absolute: false,
|
|
40
|
+
});
|
|
41
|
+
const tokenUsages = [];
|
|
42
|
+
const componentUsages = [];
|
|
43
|
+
const hardcodedValues = [];
|
|
44
|
+
for (const file of files) {
|
|
45
|
+
const fullPath = join(projectRoot, file);
|
|
46
|
+
let content;
|
|
47
|
+
try {
|
|
48
|
+
content = await readFile(fullPath, 'utf-8');
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
continue;
|
|
52
|
+
}
|
|
53
|
+
const lines = content.split('\n');
|
|
54
|
+
// Collect CSS variable usages
|
|
55
|
+
collectPatternUsages(content, lines, file, CSS_VAR_PATTERN, 'css-var', tokenUsages);
|
|
56
|
+
// Collect SCSS variable usages
|
|
57
|
+
if (file.endsWith('.scss') || file.endsWith('.sass')) {
|
|
58
|
+
collectPatternUsages(content, lines, file, SCSS_VAR_PATTERN, 'scss-var', tokenUsages);
|
|
59
|
+
}
|
|
60
|
+
// Collect hardcoded colors
|
|
61
|
+
collectPatternUsages(content, lines, file, HEX_COLOR_PATTERN, 'hardcoded', hardcodedValues, true);
|
|
62
|
+
collectPatternUsages(content, lines, file, RGB_PATTERN, 'hardcoded', hardcodedValues, true);
|
|
63
|
+
collectPatternUsages(content, lines, file, HSL_PATTERN, 'hardcoded', hardcodedValues, true);
|
|
64
|
+
// Collect Tailwind arbitrary values
|
|
65
|
+
collectPatternUsages(content, lines, file, TAILWIND_ARBITRARY_PATTERN, 'tailwind', hardcodedValues, true);
|
|
66
|
+
// Collect component usages (JSX files only)
|
|
67
|
+
if (file.endsWith('.tsx') || file.endsWith('.jsx') || file.endsWith('.vue')) {
|
|
68
|
+
collectComponentUsages(content, lines, file, componentUsages, options.knownComponents);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
// Filter to known tokens if provided
|
|
72
|
+
let filteredTokenUsages = tokenUsages;
|
|
73
|
+
if (options.knownTokens && options.knownTokens.length > 0) {
|
|
74
|
+
const knownSet = new Set(options.knownTokens.map(t => t.toLowerCase()));
|
|
75
|
+
filteredTokenUsages = tokenUsages.filter(u => knownSet.has(u.tokenName.toLowerCase()));
|
|
76
|
+
}
|
|
77
|
+
// Filter to known components if provided
|
|
78
|
+
let filteredComponentUsages = componentUsages;
|
|
79
|
+
if (options.knownComponents && options.knownComponents.length > 0) {
|
|
80
|
+
const knownSet = new Set(options.knownComponents);
|
|
81
|
+
filteredComponentUsages = componentUsages.filter(u => knownSet.has(u.componentName));
|
|
82
|
+
}
|
|
83
|
+
return {
|
|
84
|
+
tokenUsages: filteredTokenUsages,
|
|
85
|
+
componentUsages: filteredComponentUsages,
|
|
86
|
+
hardcodedValues,
|
|
87
|
+
stats: {
|
|
88
|
+
filesScanned: files.length,
|
|
89
|
+
tokenUsagesFound: filteredTokenUsages.length,
|
|
90
|
+
componentUsagesFound: filteredComponentUsages.length,
|
|
91
|
+
hardcodedValuesFound: hardcodedValues.length,
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
// ============================================================================
|
|
96
|
+
// Helpers
|
|
97
|
+
// ============================================================================
|
|
98
|
+
function collectPatternUsages(content, lines, filePath, pattern, usageType, usages, storeRawValue = false) {
|
|
99
|
+
// Reset pattern state
|
|
100
|
+
pattern.lastIndex = 0;
|
|
101
|
+
let match;
|
|
102
|
+
while ((match = pattern.exec(content)) !== null) {
|
|
103
|
+
const { lineNumber, columnNumber } = getPosition(content, match.index);
|
|
104
|
+
const line = lines[lineNumber - 1] ?? '';
|
|
105
|
+
// Skip if in a comment
|
|
106
|
+
if (isInComment(line, columnNumber))
|
|
107
|
+
continue;
|
|
108
|
+
// Get context (surrounding lines)
|
|
109
|
+
const contextStart = Math.max(0, lineNumber - 2);
|
|
110
|
+
const contextEnd = Math.min(lines.length, lineNumber + 1);
|
|
111
|
+
const context = lines.slice(contextStart, contextEnd).join('\n');
|
|
112
|
+
usages.push({
|
|
113
|
+
tokenName: match[1] ?? match[0],
|
|
114
|
+
filePath,
|
|
115
|
+
lineNumber,
|
|
116
|
+
columnNumber,
|
|
117
|
+
usageType,
|
|
118
|
+
context,
|
|
119
|
+
rawValue: storeRawValue ? match[0] : undefined,
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
function collectComponentUsages(content, lines, filePath, usages, knownComponents) {
|
|
124
|
+
const pattern = new RegExp(JSX_COMPONENT_PATTERN.source, 'g');
|
|
125
|
+
// Built-in HTML elements and React fragments to skip
|
|
126
|
+
const skipComponents = new Set([
|
|
127
|
+
'Fragment',
|
|
128
|
+
'React',
|
|
129
|
+
'Suspense',
|
|
130
|
+
'StrictMode',
|
|
131
|
+
'Provider',
|
|
132
|
+
'Consumer',
|
|
133
|
+
]);
|
|
134
|
+
let match;
|
|
135
|
+
while ((match = pattern.exec(content)) !== null) {
|
|
136
|
+
const componentName = match[1];
|
|
137
|
+
if (!componentName)
|
|
138
|
+
continue;
|
|
139
|
+
// Skip built-in/common wrappers
|
|
140
|
+
if (skipComponents.has(componentName))
|
|
141
|
+
continue;
|
|
142
|
+
// If we have known components, only include those
|
|
143
|
+
if (knownComponents && !knownComponents.includes(componentName))
|
|
144
|
+
continue;
|
|
145
|
+
const { lineNumber, columnNumber } = getPosition(content, match.index);
|
|
146
|
+
const line = lines[lineNumber - 1] ?? '';
|
|
147
|
+
// Skip if in a comment
|
|
148
|
+
if (isInComment(line, columnNumber))
|
|
149
|
+
continue;
|
|
150
|
+
// Extract props from the JSX
|
|
151
|
+
const propsUsed = extractProps(match[0]);
|
|
152
|
+
// Check if has children (not self-closing)
|
|
153
|
+
const hasChildren = !match[0].endsWith('/>');
|
|
154
|
+
// Get context
|
|
155
|
+
const contextStart = Math.max(0, lineNumber - 2);
|
|
156
|
+
const contextEnd = Math.min(lines.length, lineNumber + 2);
|
|
157
|
+
const context = lines.slice(contextStart, contextEnd).join('\n');
|
|
158
|
+
usages.push({
|
|
159
|
+
componentName,
|
|
160
|
+
filePath,
|
|
161
|
+
lineNumber,
|
|
162
|
+
propsUsed,
|
|
163
|
+
hasChildren,
|
|
164
|
+
context,
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
function getPosition(content, index) {
|
|
169
|
+
const before = content.slice(0, index);
|
|
170
|
+
const lineNumber = (before.match(/\n/g) ?? []).length + 1;
|
|
171
|
+
const lastNewline = before.lastIndexOf('\n');
|
|
172
|
+
const columnNumber = index - lastNewline;
|
|
173
|
+
return { lineNumber, columnNumber };
|
|
174
|
+
}
|
|
175
|
+
function isInComment(line, column) {
|
|
176
|
+
// Check for // comment before the position
|
|
177
|
+
const commentIndex = line.indexOf('//');
|
|
178
|
+
if (commentIndex !== -1 && commentIndex < column) {
|
|
179
|
+
return true;
|
|
180
|
+
}
|
|
181
|
+
// Check for /* comment (simplified - doesn't handle multi-line)
|
|
182
|
+
const blockCommentStart = line.indexOf('/*');
|
|
183
|
+
const blockCommentEnd = line.indexOf('*/');
|
|
184
|
+
if (blockCommentStart !== -1 &&
|
|
185
|
+
blockCommentStart < column &&
|
|
186
|
+
(blockCommentEnd === -1 || blockCommentEnd > column)) {
|
|
187
|
+
return true;
|
|
188
|
+
}
|
|
189
|
+
return false;
|
|
190
|
+
}
|
|
191
|
+
function extractProps(jsxString) {
|
|
192
|
+
const props = [];
|
|
193
|
+
// Simple regex to extract prop names
|
|
194
|
+
// Matches: propName= or propName (for boolean props)
|
|
195
|
+
const propPattern = /\s([a-zA-Z][a-zA-Z0-9]*)(?:=|\s|\/?>)/g;
|
|
196
|
+
let match;
|
|
197
|
+
while ((match = propPattern.exec(jsxString)) !== null) {
|
|
198
|
+
const propName = match[1];
|
|
199
|
+
if (propName && !['className', 'style', 'key', 'ref'].includes(propName)) {
|
|
200
|
+
props.push(propName);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
return [...new Set(props)];
|
|
204
|
+
}
|
|
205
|
+
// ============================================================================
|
|
206
|
+
// Specialized Collectors
|
|
207
|
+
// ============================================================================
|
|
208
|
+
/**
|
|
209
|
+
* Find all hardcoded color values in the codebase
|
|
210
|
+
*/
|
|
211
|
+
export async function findHardcodedColors(projectRoot) {
|
|
212
|
+
const result = await collectUsages({ projectRoot });
|
|
213
|
+
return result.hardcodedValues.filter((u) => u.rawValue?.startsWith('#') ||
|
|
214
|
+
u.rawValue?.startsWith('rgb') ||
|
|
215
|
+
u.rawValue?.startsWith('hsl'));
|
|
216
|
+
}
|
|
217
|
+
/**
|
|
218
|
+
* Find all CSS variable usages
|
|
219
|
+
*/
|
|
220
|
+
export async function findCSSVariableUsages(projectRoot) {
|
|
221
|
+
const result = await collectUsages({ projectRoot });
|
|
222
|
+
return result.tokenUsages.filter((u) => u.usageType === 'css-var');
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Find usages of a specific token
|
|
226
|
+
*/
|
|
227
|
+
export async function findTokenUsagesInFiles(projectRoot, tokenName) {
|
|
228
|
+
const result = await collectUsages({
|
|
229
|
+
projectRoot,
|
|
230
|
+
knownTokens: [tokenName],
|
|
231
|
+
});
|
|
232
|
+
return result.tokenUsages;
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Find usages of a specific component
|
|
236
|
+
*/
|
|
237
|
+
export async function findComponentUsagesInFiles(projectRoot, componentName) {
|
|
238
|
+
const result = await collectUsages({
|
|
239
|
+
projectRoot,
|
|
240
|
+
knownComponents: [componentName],
|
|
241
|
+
});
|
|
242
|
+
return result.componentUsages;
|
|
243
|
+
}
|
|
244
|
+
//# sourceMappingURL=usages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usages.js","sourceRoot":"","sources":["../../../src/graph/collectors/usages.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAC5B,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAoD5B,+EAA+E;AAC/E,WAAW;AACX,+EAA+E;AAE/E,2DAA2D;AAC3D,MAAM,eAAe,GAAG,mDAAmD,CAAC;AAE5E,6BAA6B;AAC7B,MAAM,gBAAgB,GAAG,6BAA6B,CAAC;AAEvD,6CAA6C;AAC7C,MAAM,0BAA0B,GAAG,0DAA0D,CAAC;AAE9F,iDAAiD;AACjD,MAAM,iBAAiB,GAAG,wBAAwB,CAAC;AAEnD,6DAA6D;AAC7D,MAAM,WAAW,GAAG,2DAA2D,CAAC;AAEhF,wDAA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jC,WAAW;QACX,eAAe,EAAE,CAAC,aAAa,CAAC;KACjC,CAAC,CAAC;IACH,OAAO,MAAM,CAAC,eAAe,CAAC;AAChC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Design System Knowledge Graph
|
|
3
|
+
*
|
|
4
|
+
* A graph-based representation of the design system that enables
|
|
5
|
+
* powerful queries about relationships, impact, and ownership.
|
|
6
|
+
*/
|
|
7
|
+
export * from './types.js';
|
|
8
|
+
export { createGraph, nodeId, edgeId, addNode, updateNode, addEdge, getNodesByType, getEdgesByType, getOutEdgesByType, getInEdgesByType, getGraphStats, exportToJSON, importFromJSON, exportToDOT, exportToCytoscape, GraphBuilder, type DesignSystemGraph, } from './builder.js';
|
|
9
|
+
export { findTokenUsages, findUnusedTokens, findDriftingTokens, findComponentRenderers, findUntestedComponents, findUndocumentedComponents, analyzeImpact, findOwnership, findDriftAuthor, findRepeatOffenders, findDeprecatedUsages, findDriftInPR, findFilesChangedInPR, calculateCoverage, } from './queries.js';
|
|
10
|
+
export * from './collectors/index.js';
|
|
11
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/graph/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,cAAc,YAAY,CAAC;AAG3B,OAAO,EACL,WAAW,EACX,MAAM,EACN,MAAM,EACN,OAAO,EACP,UAAU,EACV,OAAO,EACP,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EACb,YAAY,EACZ,cAAc,EACd,WAAW,EACX,iBAAiB,EACjB,YAAY,EACZ,KAAK,iBAAiB,GACvB,MAAM,cAAc,CAAC;AAGtB,OAAO,EAEL,eAAe,EACf,gBAAgB,EAChB,kBAAkB,EAElB,sBAAsB,EACtB,sBAAsB,EACtB,0BAA0B,EAE1B,aAAa,EAEb,aAAa,EACb,eAAe,EAEf,mBAAmB,EACnB,oBAAoB,EAEpB,aAAa,EACb,oBAAoB,EAEpB,iBAAiB,GAClB,MAAM,cAAc,CAAC;AAGtB,cAAc,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Design System Knowledge Graph
|
|
3
|
+
*
|
|
4
|
+
* A graph-based representation of the design system that enables
|
|
5
|
+
* powerful queries about relationships, impact, and ownership.
|
|
6
|
+
*/
|
|
7
|
+
// Types
|
|
8
|
+
export * from './types.js';
|
|
9
|
+
// Graph building
|
|
10
|
+
export { createGraph, nodeId, edgeId, addNode, updateNode, addEdge, getNodesByType, getEdgesByType, getOutEdgesByType, getInEdgesByType, getGraphStats, exportToJSON, importFromJSON, exportToDOT, exportToCytoscape, GraphBuilder, } from './builder.js';
|
|
11
|
+
// Queries
|
|
12
|
+
export {
|
|
13
|
+
// Token queries
|
|
14
|
+
findTokenUsages, findUnusedTokens, findDriftingTokens,
|
|
15
|
+
// Component queries
|
|
16
|
+
findComponentRenderers, findUntestedComponents, findUndocumentedComponents,
|
|
17
|
+
// Impact analysis
|
|
18
|
+
analyzeImpact,
|
|
19
|
+
// Ownership
|
|
20
|
+
findOwnership, findDriftAuthor,
|
|
21
|
+
// Pattern detection
|
|
22
|
+
findRepeatOffenders, findDeprecatedUsages,
|
|
23
|
+
// PR analysis
|
|
24
|
+
findDriftInPR, findFilesChangedInPR,
|
|
25
|
+
// Coverage
|
|
26
|
+
calculateCoverage, } from './queries.js';
|
|
27
|
+
// Collectors
|
|
28
|
+
export * from './collectors/index.js';
|
|
29
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/graph/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,QAAQ;AACR,cAAc,YAAY,CAAC;AAE3B,iBAAiB;AACjB,OAAO,EACL,WAAW,EACX,MAAM,EACN,MAAM,EACN,OAAO,EACP,UAAU,EACV,OAAO,EACP,cAAc,EACd,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,aAAa,EACb,YAAY,EACZ,cAAc,EACd,WAAW,EACX,iBAAiB,EACjB,YAAY,GAEb,MAAM,cAAc,CAAC;AAEtB,UAAU;AACV,OAAO;AACL,gBAAgB;AAChB,eAAe,EACf,gBAAgB,EAChB,kBAAkB;AAClB,oBAAoB;AACpB,sBAAsB,EACtB,sBAAsB,EACtB,0BAA0B;AAC1B,kBAAkB;AAClB,aAAa;AACb,YAAY;AACZ,aAAa,EACb,eAAe;AACf,oBAAoB;AACpB,mBAAmB,EACnB,oBAAoB;AACpB,cAAc;AACd,aAAa,EACb,oBAAoB;AACpB,WAAW;AACX,iBAAiB,GAClB,MAAM,cAAc,CAAC;AAEtB,aAAa;AACb,cAAc,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Graph Queries
|
|
3
|
+
*
|
|
4
|
+
* Query functions for analyzing the design system graph.
|
|
5
|
+
* Enables questions like "Who introduced this drift?" and "What uses this token?"
|
|
6
|
+
*/
|
|
7
|
+
import type { ImpactAnalysis, OwnershipInfo, UsageInfo } from './types.js';
|
|
8
|
+
import { type DesignSystemGraph } from './builder.js';
|
|
9
|
+
/**
|
|
10
|
+
* Find all usages of a token across the codebase
|
|
11
|
+
*/
|
|
12
|
+
export declare function findTokenUsages(graph: DesignSystemGraph, tokenId: string): UsageInfo;
|
|
13
|
+
/**
|
|
14
|
+
* Find tokens that are defined but never used
|
|
15
|
+
*/
|
|
16
|
+
export declare function findUnusedTokens(graph: DesignSystemGraph): string[];
|
|
17
|
+
/**
|
|
18
|
+
* Find tokens that drift from their W3C definition
|
|
19
|
+
*/
|
|
20
|
+
export declare function findDriftingTokens(graph: DesignSystemGraph): Array<{
|
|
21
|
+
tokenId: string;
|
|
22
|
+
expectedValue: string;
|
|
23
|
+
actualValue: string;
|
|
24
|
+
}>;
|
|
25
|
+
/**
|
|
26
|
+
* Find all components that render a given component
|
|
27
|
+
*/
|
|
28
|
+
export declare function findComponentRenderers(graph: DesignSystemGraph, componentId: string): string[];
|
|
29
|
+
/**
|
|
30
|
+
* Find components without test coverage
|
|
31
|
+
*/
|
|
32
|
+
export declare function findUntestedComponents(graph: DesignSystemGraph): string[];
|
|
33
|
+
/**
|
|
34
|
+
* Find components without Storybook documentation
|
|
35
|
+
*/
|
|
36
|
+
export declare function findUndocumentedComponents(graph: DesignSystemGraph): string[];
|
|
37
|
+
/**
|
|
38
|
+
* Analyze the impact of changing a token or component
|
|
39
|
+
*/
|
|
40
|
+
export declare function analyzeImpact(graph: DesignSystemGraph, entityId: string, maxDepth?: number): ImpactAnalysis;
|
|
41
|
+
/**
|
|
42
|
+
* Find who owns a file or component based on git history
|
|
43
|
+
*/
|
|
44
|
+
export declare function findOwnership(graph: DesignSystemGraph, entityId: string): OwnershipInfo | null;
|
|
45
|
+
/**
|
|
46
|
+
* Find who introduced a drift signal
|
|
47
|
+
*/
|
|
48
|
+
export declare function findDriftAuthor(graph: DesignSystemGraph, driftSignalId: string): string | null;
|
|
49
|
+
/**
|
|
50
|
+
* Find files that frequently have drift (repeat offenders)
|
|
51
|
+
*/
|
|
52
|
+
export declare function findRepeatOffenders(graph: DesignSystemGraph, threshold?: number): Array<{
|
|
53
|
+
file: string;
|
|
54
|
+
driftCount: number;
|
|
55
|
+
}>;
|
|
56
|
+
/**
|
|
57
|
+
* Find deprecated tokens that are still being used
|
|
58
|
+
*/
|
|
59
|
+
export declare function findDeprecatedUsages(graph: DesignSystemGraph): Array<{
|
|
60
|
+
token: string;
|
|
61
|
+
usageCount: number;
|
|
62
|
+
usedIn: string[];
|
|
63
|
+
}>;
|
|
64
|
+
/**
|
|
65
|
+
* Find drift signals in a specific PR
|
|
66
|
+
*/
|
|
67
|
+
export declare function findDriftInPR(graph: DesignSystemGraph, prId: string): string[];
|
|
68
|
+
/**
|
|
69
|
+
* Find what files were changed in a PR
|
|
70
|
+
*/
|
|
71
|
+
export declare function findFilesChangedInPR(graph: DesignSystemGraph, prId: string): string[];
|
|
72
|
+
/**
|
|
73
|
+
* Calculate design system coverage metrics
|
|
74
|
+
*/
|
|
75
|
+
export declare function calculateCoverage(graph: DesignSystemGraph): {
|
|
76
|
+
tokenCoverage: number;
|
|
77
|
+
componentCoverage: number;
|
|
78
|
+
testCoverage: number;
|
|
79
|
+
storyCoverage: number;
|
|
80
|
+
};
|
|
81
|
+
//# sourceMappingURL=queries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../../src/graph/queries.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EAIV,cAAc,EACd,aAAa,EACb,SAAS,EACV,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,KAAK,iBAAiB,EAKvB,MAAM,cAAc,CAAC;AAMtB;;GAEG;AACH,wBAAgB,eAAe,CAC7B,KAAK,EAAE,iBAAiB,EACxB,OAAO,EAAE,MAAM,GACd,SAAS,CA8BX;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,EAAE,CAKnE;AAED;;GAEG;AACH,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,iBAAiB,GACvB,KAAK,CAAC;IAAE,OAAO,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAA;CAAE,CAAC,CA2BxE;AAMD;;GAEG;AACH,wBAAgB,sBAAsB,CACpC,KAAK,EAAE,iBAAiB,EACxB,WAAW,EAAE,MAAM,GAClB,MAAM,EAAE,CAmBV;AAED;;GAEG;AACH,wBAAgB,sBAAsB,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,EAAE,CAKzE;AAED;;GAEG;AACH,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,EAAE,CAK7E;AAM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