@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,253 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Git History Collector
|
|
3
|
+
*
|
|
4
|
+
* Extracts commit history, authors, and file changes from git.
|
|
5
|
+
* Populates commits and developers tables.
|
|
6
|
+
*/
|
|
7
|
+
import { simpleGit } from 'simple-git';
|
|
8
|
+
import { createHash } from 'crypto';
|
|
9
|
+
// ============================================================================
|
|
10
|
+
// Collector
|
|
11
|
+
// ============================================================================
|
|
12
|
+
/**
|
|
13
|
+
* Collect git history from a repository
|
|
14
|
+
*/
|
|
15
|
+
export async function collectGitHistory(projectRoot, options = {}) {
|
|
16
|
+
const git = simpleGit(projectRoot);
|
|
17
|
+
// Build log options
|
|
18
|
+
const logOptions = {
|
|
19
|
+
'--date': 'iso-strict',
|
|
20
|
+
};
|
|
21
|
+
if (options.since) {
|
|
22
|
+
logOptions['--since'] = options.since.toISOString();
|
|
23
|
+
}
|
|
24
|
+
if (options.until) {
|
|
25
|
+
logOptions['--until'] = options.until.toISOString();
|
|
26
|
+
}
|
|
27
|
+
if (options.maxCount) {
|
|
28
|
+
logOptions['--max-count'] = options.maxCount;
|
|
29
|
+
}
|
|
30
|
+
// Get commit log
|
|
31
|
+
let log;
|
|
32
|
+
if (options.paths && options.paths.length > 0) {
|
|
33
|
+
log = await git.log({ ...logOptions, file: options.paths.join(' ') });
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
log = await git.log(logOptions);
|
|
37
|
+
}
|
|
38
|
+
const commits = [];
|
|
39
|
+
const developerMap = new Map();
|
|
40
|
+
for (const entry of log.all) {
|
|
41
|
+
// Parse commit
|
|
42
|
+
const commit = {
|
|
43
|
+
sha: entry.hash,
|
|
44
|
+
message: entry.message,
|
|
45
|
+
author: entry.author_name,
|
|
46
|
+
authorEmail: entry.author_email,
|
|
47
|
+
timestamp: new Date(entry.date),
|
|
48
|
+
parentSha: entry.refs ? null : null, // Will be populated if needed
|
|
49
|
+
filesChanged: [],
|
|
50
|
+
};
|
|
51
|
+
// Get file changes if requested
|
|
52
|
+
if (options.includeStats) {
|
|
53
|
+
try {
|
|
54
|
+
const diff = await git.diffSummary([`${entry.hash}^`, entry.hash]);
|
|
55
|
+
commit.filesChanged = diff.files.map((f) => {
|
|
56
|
+
// Handle different file types
|
|
57
|
+
const isBinary = 'binary' in f && f.binary;
|
|
58
|
+
const insertions = 'insertions' in f ? f.insertions : 0;
|
|
59
|
+
const deletions = 'deletions' in f ? f.deletions : 0;
|
|
60
|
+
return {
|
|
61
|
+
path: f.file,
|
|
62
|
+
status: isBinary
|
|
63
|
+
? 'modified'
|
|
64
|
+
: insertions > 0 && deletions === 0
|
|
65
|
+
? 'added'
|
|
66
|
+
: deletions > 0 && insertions === 0
|
|
67
|
+
? 'deleted'
|
|
68
|
+
: 'modified',
|
|
69
|
+
additions: insertions,
|
|
70
|
+
deletions: deletions,
|
|
71
|
+
};
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
// First commit has no parent, skip diff
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
commits.push(commit);
|
|
79
|
+
// Track developer
|
|
80
|
+
const devKey = entry.author_email.toLowerCase();
|
|
81
|
+
const existing = developerMap.get(devKey);
|
|
82
|
+
if (existing) {
|
|
83
|
+
existing.commitCount++;
|
|
84
|
+
if (commit.timestamp < existing.firstSeenAt) {
|
|
85
|
+
existing.firstSeenAt = commit.timestamp;
|
|
86
|
+
}
|
|
87
|
+
if (commit.timestamp > existing.lastSeenAt) {
|
|
88
|
+
existing.lastSeenAt = commit.timestamp;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
developerMap.set(devKey, {
|
|
93
|
+
id: generateDeveloperId(entry.author_email),
|
|
94
|
+
name: entry.author_name,
|
|
95
|
+
email: entry.author_email,
|
|
96
|
+
commitCount: 1,
|
|
97
|
+
firstSeenAt: commit.timestamp,
|
|
98
|
+
lastSeenAt: commit.timestamp,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
const developers = Array.from(developerMap.values());
|
|
103
|
+
// Calculate date range
|
|
104
|
+
let dateRange = null;
|
|
105
|
+
if (commits.length > 0) {
|
|
106
|
+
const timestamps = commits.map((c) => c.timestamp.getTime());
|
|
107
|
+
dateRange = {
|
|
108
|
+
start: new Date(Math.min(...timestamps)),
|
|
109
|
+
end: new Date(Math.max(...timestamps)),
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
return {
|
|
113
|
+
commits,
|
|
114
|
+
developers,
|
|
115
|
+
stats: {
|
|
116
|
+
totalCommits: commits.length,
|
|
117
|
+
totalDevelopers: developers.length,
|
|
118
|
+
dateRange,
|
|
119
|
+
},
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Collect commits that touched design-related files
|
|
124
|
+
*/
|
|
125
|
+
export async function collectDesignSystemHistory(projectRoot, options = {}) {
|
|
126
|
+
// Patterns for design-system related files
|
|
127
|
+
const designPatterns = [
|
|
128
|
+
'*.tokens.json',
|
|
129
|
+
'tokens.json',
|
|
130
|
+
'**/tokens/**',
|
|
131
|
+
'**/theme/**',
|
|
132
|
+
'**/design-system/**',
|
|
133
|
+
'*.css',
|
|
134
|
+
'*.scss',
|
|
135
|
+
'*.sass',
|
|
136
|
+
'*.less',
|
|
137
|
+
'tailwind.config.*',
|
|
138
|
+
'**/components/**/*.tsx',
|
|
139
|
+
'**/components/**/*.vue',
|
|
140
|
+
'**/components/**/*.svelte',
|
|
141
|
+
];
|
|
142
|
+
return collectGitHistory(projectRoot, {
|
|
143
|
+
...options,
|
|
144
|
+
paths: designPatterns,
|
|
145
|
+
includeStats: true,
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Get file history (who changed this file)
|
|
150
|
+
*/
|
|
151
|
+
export async function getFileHistory(projectRoot, filePath, options = {}) {
|
|
152
|
+
const result = await collectGitHistory(projectRoot, {
|
|
153
|
+
paths: [filePath],
|
|
154
|
+
maxCount: options.maxCount ?? 50,
|
|
155
|
+
includeStats: false,
|
|
156
|
+
});
|
|
157
|
+
return result.commits;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Get blame information for a file
|
|
161
|
+
*/
|
|
162
|
+
export async function getFileBlame(projectRoot, filePath) {
|
|
163
|
+
const git = simpleGit(projectRoot);
|
|
164
|
+
const blameMap = new Map();
|
|
165
|
+
try {
|
|
166
|
+
const blame = await git.raw(['blame', '--line-porcelain', filePath]);
|
|
167
|
+
const lines = blame.split('\n');
|
|
168
|
+
let currentSha = '';
|
|
169
|
+
let currentAuthor = '';
|
|
170
|
+
let currentEmail = '';
|
|
171
|
+
let currentDate = new Date();
|
|
172
|
+
let lineNumber = 0;
|
|
173
|
+
for (const line of lines) {
|
|
174
|
+
if (line.match(/^[0-9a-f]{40}/)) {
|
|
175
|
+
currentSha = line.slice(0, 40);
|
|
176
|
+
// Parse line number from "sha origLine finalLine numLines"
|
|
177
|
+
const parts = line.split(' ');
|
|
178
|
+
if (parts[2]) {
|
|
179
|
+
lineNumber = parseInt(parts[2], 10);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
else if (line.startsWith('author ')) {
|
|
183
|
+
currentAuthor = line.slice(7);
|
|
184
|
+
}
|
|
185
|
+
else if (line.startsWith('author-mail ')) {
|
|
186
|
+
currentEmail = line.slice(12).replace(/[<>]/g, '');
|
|
187
|
+
}
|
|
188
|
+
else if (line.startsWith('author-time ')) {
|
|
189
|
+
currentDate = new Date(parseInt(line.slice(12), 10) * 1000);
|
|
190
|
+
}
|
|
191
|
+
else if (line.startsWith('\t')) {
|
|
192
|
+
// This is the actual line content, save the blame info
|
|
193
|
+
blameMap.set(lineNumber, {
|
|
194
|
+
author: currentAuthor,
|
|
195
|
+
email: currentEmail,
|
|
196
|
+
sha: currentSha,
|
|
197
|
+
date: currentDate,
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
catch {
|
|
203
|
+
// File might not exist or not be tracked
|
|
204
|
+
}
|
|
205
|
+
return blameMap;
|
|
206
|
+
}
|
|
207
|
+
/**
|
|
208
|
+
* Check if a path is inside a git repository
|
|
209
|
+
*/
|
|
210
|
+
export async function isGitRepository(path) {
|
|
211
|
+
const git = simpleGit(path);
|
|
212
|
+
try {
|
|
213
|
+
await git.revparse(['--git-dir']);
|
|
214
|
+
return true;
|
|
215
|
+
}
|
|
216
|
+
catch {
|
|
217
|
+
return false;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Get the current branch name
|
|
222
|
+
*/
|
|
223
|
+
export async function getCurrentBranch(projectRoot) {
|
|
224
|
+
const git = simpleGit(projectRoot);
|
|
225
|
+
try {
|
|
226
|
+
const branch = await git.revparse(['--abbrev-ref', 'HEAD']);
|
|
227
|
+
return branch.trim();
|
|
228
|
+
}
|
|
229
|
+
catch {
|
|
230
|
+
return null;
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Get the remote URL
|
|
235
|
+
*/
|
|
236
|
+
export async function getRemoteUrl(projectRoot) {
|
|
237
|
+
const git = simpleGit(projectRoot);
|
|
238
|
+
try {
|
|
239
|
+
const remotes = await git.getRemotes(true);
|
|
240
|
+
const origin = remotes.find((r) => r.name === 'origin');
|
|
241
|
+
return origin?.refs.fetch ?? null;
|
|
242
|
+
}
|
|
243
|
+
catch {
|
|
244
|
+
return null;
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
// ============================================================================
|
|
248
|
+
// Helpers
|
|
249
|
+
// ============================================================================
|
|
250
|
+
function generateDeveloperId(email) {
|
|
251
|
+
return createHash('sha256').update(email.toLowerCase()).digest('hex').slice(0, 16);
|
|
252
|
+
}
|
|
253
|
+
//# sourceMappingURL=git.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"git.js","sourceRoot":"","sources":["../../../src/graph/collectors/git.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,SAAS,EAAyD,MAAM,YAAY,CAAC;AAC9F,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAwDpC,+EAA+E;AAC/E,YAAY;AACZ,+EAA+E;AAE/E;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,WAAmB,EACnB,UAA+B,EAAE;IAEjC,MAAM,GAAG,GAAc,SAAS,CAAC,WAAW,CAAC,CAAC;IAE9C,oBAAoB;IACpB,MAAM,UAAU,GAA0D;QACxE,QAAQ,EAAE,YAAY;KACvB,CAAC;IAEF,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;QAClB,UAAU,CAAC,SAAS,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC;IACtD,CAAC;IACD,IAAI,OAAO,CAAC,KAAK,EAAE,CAAC;QAClB,UAAU,CAAC,SAAS,CAAC,GAAG,OAAO,CAAC,KAAK,CAAC,WAAW,EAAE,CAA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C;AACH,CAAC;AAED,+EAA+E;AAC/E,UAAU;AACV,+EAA+E;AAE/E,SAAS,mBAAmB,CAAC,KAAa;IACxC,OAAO,UAAU,CAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,EAAE,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACrF,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Import Collector
|
|
3
|
+
*
|
|
4
|
+
* Extracts ES module import relationships between files.
|
|
5
|
+
* Creates a dependency graph for impact analysis.
|
|
6
|
+
*/
|
|
7
|
+
export type ImportType = 'default' | 'named' | 'namespace' | 'side-effect' | 'dynamic';
|
|
8
|
+
export interface FileImport {
|
|
9
|
+
sourceFile: string;
|
|
10
|
+
targetFile: string;
|
|
11
|
+
importType: ImportType;
|
|
12
|
+
importedNames: string[];
|
|
13
|
+
rawSpecifier: string;
|
|
14
|
+
isExternal: boolean;
|
|
15
|
+
lineNumber: number;
|
|
16
|
+
}
|
|
17
|
+
export interface ImportCollectorOptions {
|
|
18
|
+
projectRoot: string;
|
|
19
|
+
include?: string[];
|
|
20
|
+
exclude?: string[];
|
|
21
|
+
/** Resolve paths to actual files (slower but more accurate) */
|
|
22
|
+
resolvePaths?: boolean;
|
|
23
|
+
/** Include node_modules imports */
|
|
24
|
+
includeExternal?: boolean;
|
|
25
|
+
}
|
|
26
|
+
export interface ImportCollectorResult {
|
|
27
|
+
imports: FileImport[];
|
|
28
|
+
externalDependencies: Set<string>;
|
|
29
|
+
stats: {
|
|
30
|
+
filesScanned: number;
|
|
31
|
+
importsFound: number;
|
|
32
|
+
externalPackages: number;
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Collect import relationships from the codebase
|
|
37
|
+
*/
|
|
38
|
+
export declare function collectImports(options: ImportCollectorOptions): Promise<ImportCollectorResult>;
|
|
39
|
+
/**
|
|
40
|
+
* Get all files that import a specific file
|
|
41
|
+
*/
|
|
42
|
+
export declare function findImportersOf(projectRoot: string, targetFile: string): Promise<FileImport[]>;
|
|
43
|
+
/**
|
|
44
|
+
* Get all files imported by a specific file
|
|
45
|
+
*/
|
|
46
|
+
export declare function findImportsOf(projectRoot: string, sourceFile: string): Promise<FileImport[]>;
|
|
47
|
+
/**
|
|
48
|
+
* Build a dependency graph from imports
|
|
49
|
+
*/
|
|
50
|
+
export declare function buildDependencyGraph(projectRoot: string): Promise<Map<string, Set<string>>>;
|
|
51
|
+
/**
|
|
52
|
+
* Find circular dependencies
|
|
53
|
+
*/
|
|
54
|
+
export declare function findCircularDependencies(projectRoot: string): Promise<string[][]>;
|
|
55
|
+
//# sourceMappingURL=imports.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"imports.d.ts","sourceRoot":"","sources":["../../../src/graph/collectors/imports.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAWH,MAAM,MAAM,UAAU,GAAG,SAAS,GAAG,OAAO,GAAG,WAAW,GAAG,aAAa,GAAG,SAAS,CAAC;AAEvF,MAAM,WAAW,UAAU;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,UAAU,CAAC;IACvB,aAAa,EAAE,MAAM,EAAE,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,sBAAsB;IACrC,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,EAAE,CAAC;IACnB,+DAA+D;IAC/D,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,mCAAmC;IACnC,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,MAAM,WAAW,qBAAqB;IACpC,OAAO,EAAE,UAAU,EAAE,CAAC;IACtB,oBAAoB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IAClC,KAAK,EAAE;QACL,YAAY,EAAE,MAAM,CAAC;QACrB,YAAY,EAAE,MAAM,CAAC;QACrB,gBAAgB,EAAE,MAAM,CAAC;KAC1B,CAAC;CACH;AA8CD;;GAEG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC,qBAAqB,CAAC,CA2KhC;AAiHD;;GAEG;AACH,wBAAsB,eAAe,CACnC,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,UAAU,EAAE,CAAC,CAWvB;AAED;;GAEG;AACH,wBAAsB,aAAa,CACjC,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,MAAM,GACjB,OAAO,CAAC,UAAU,EAAE,CAAC,CAGvB;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CACxC,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAcnC;AAED;;GAEG;AACH,wBAAsB,wBAAwB,CAC5C,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAgCrB"}
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Import Collector
|
|
3
|
+
*
|
|
4
|
+
* Extracts ES module import relationships between files.
|
|
5
|
+
* Creates a dependency graph for impact analysis.
|
|
6
|
+
*/
|
|
7
|
+
import { readFile } from 'fs/promises';
|
|
8
|
+
import { glob } from 'glob';
|
|
9
|
+
import { join, dirname, resolve, relative } from 'path';
|
|
10
|
+
import { existsSync } from 'fs';
|
|
11
|
+
// ============================================================================
|
|
12
|
+
// Patterns
|
|
13
|
+
// ============================================================================
|
|
14
|
+
// ES import patterns
|
|
15
|
+
const IMPORT_PATTERNS = {
|
|
16
|
+
// import defaultExport from 'module'
|
|
17
|
+
default: /import\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s+from\s+['"]([^'"]+)['"]/g,
|
|
18
|
+
// import { named1, named2 } from 'module'
|
|
19
|
+
named: /import\s*\{([^}]+)\}\s*from\s*['"]([^'"]+)['"]/g,
|
|
20
|
+
// import * as namespace from 'module'
|
|
21
|
+
namespace: /import\s*\*\s*as\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s+from\s+['"]([^'"]+)['"]/g,
|
|
22
|
+
// import 'module' (side effect)
|
|
23
|
+
sideEffect: /import\s+['"]([^'"]+)['"]/g,
|
|
24
|
+
// import defaultExport, { named } from 'module'
|
|
25
|
+
mixed: /import\s+([a-zA-Z_$][a-zA-Z0-9_$]*)\s*,\s*\{([^}]+)\}\s*from\s*['"]([^'"]+)['"]/g,
|
|
26
|
+
// const x = await import('module') or import('module')
|
|
27
|
+
dynamic: /import\s*\(\s*['"]([^'"]+)['"]\s*\)/g,
|
|
28
|
+
// require('module') - CommonJS
|
|
29
|
+
require: /require\s*\(\s*['"]([^'"]+)['"]\s*\)/g,
|
|
30
|
+
};
|
|
31
|
+
// Re-export patterns
|
|
32
|
+
const REEXPORT_PATTERNS = {
|
|
33
|
+
// export { named } from 'module'
|
|
34
|
+
named: /export\s*\{([^}]+)\}\s*from\s*['"]([^'"]+)['"]/g,
|
|
35
|
+
// export * from 'module'
|
|
36
|
+
all: /export\s*\*\s*from\s*['"]([^'"]+)['"]/g,
|
|
37
|
+
// export { default } from 'module'
|
|
38
|
+
default: /export\s*\{\s*default\s*(?:as\s+[a-zA-Z_$][a-zA-Z0-9_$]*)?\s*\}\s*from\s*['"]([^'"]+)['"]/g,
|
|
39
|
+
};
|
|
40
|
+
// ============================================================================
|
|
41
|
+
// Collector
|
|
42
|
+
// ============================================================================
|
|
43
|
+
/**
|
|
44
|
+
* Collect import relationships from the codebase
|
|
45
|
+
*/
|
|
46
|
+
export async function collectImports(options) {
|
|
47
|
+
const { projectRoot, include = ['**/*.{ts,tsx,js,jsx,mjs,cjs}'], exclude = ['**/node_modules/**', '**/dist/**', '**/build/**'], resolvePaths = true, includeExternal = false, } = options;
|
|
48
|
+
const files = await glob(include, {
|
|
49
|
+
cwd: projectRoot,
|
|
50
|
+
ignore: exclude,
|
|
51
|
+
absolute: false,
|
|
52
|
+
});
|
|
53
|
+
const imports = [];
|
|
54
|
+
const externalDependencies = new Set();
|
|
55
|
+
for (const file of files) {
|
|
56
|
+
const fullPath = join(projectRoot, file);
|
|
57
|
+
let content;
|
|
58
|
+
try {
|
|
59
|
+
content = await readFile(fullPath, 'utf-8');
|
|
60
|
+
}
|
|
61
|
+
catch {
|
|
62
|
+
continue;
|
|
63
|
+
}
|
|
64
|
+
const lines = content.split('\n');
|
|
65
|
+
const fileDir = dirname(fullPath);
|
|
66
|
+
// Collect all import types
|
|
67
|
+
collectImportPattern(content, lines, file, fileDir, projectRoot, IMPORT_PATTERNS.default, 'default', imports, externalDependencies, resolvePaths, includeExternal, (match) => [match[1] ?? 'default'], (match) => match[2] ?? '');
|
|
68
|
+
collectImportPattern(content, lines, file, fileDir, projectRoot, IMPORT_PATTERNS.named, 'named', imports, externalDependencies, resolvePaths, includeExternal, (match) => parseNamedImports(match[1] ?? ''), (match) => match[2] ?? '');
|
|
69
|
+
collectImportPattern(content, lines, file, fileDir, projectRoot, IMPORT_PATTERNS.namespace, 'namespace', imports, externalDependencies, resolvePaths, includeExternal, (match) => [match[1] ?? '*'], (match) => match[2] ?? '');
|
|
70
|
+
collectImportPattern(content, lines, file, fileDir, projectRoot, IMPORT_PATTERNS.sideEffect, 'side-effect', imports, externalDependencies, resolvePaths, includeExternal, () => [], (match) => match[1] ?? '');
|
|
71
|
+
collectImportPattern(content, lines, file, fileDir, projectRoot, IMPORT_PATTERNS.mixed, 'named', imports, externalDependencies, resolvePaths, includeExternal, (match) => [match[1] ?? 'default', ...parseNamedImports(match[2] ?? '')], (match) => match[3] ?? '');
|
|
72
|
+
collectImportPattern(content, lines, file, fileDir, projectRoot, IMPORT_PATTERNS.dynamic, 'dynamic', imports, externalDependencies, resolvePaths, includeExternal, () => ['*'], (match) => match[1] ?? '');
|
|
73
|
+
// Collect re-exports
|
|
74
|
+
collectImportPattern(content, lines, file, fileDir, projectRoot, REEXPORT_PATTERNS.named, 'named', imports, externalDependencies, resolvePaths, includeExternal, (match) => parseNamedImports(match[1] ?? ''), (match) => match[2] ?? '');
|
|
75
|
+
collectImportPattern(content, lines, file, fileDir, projectRoot, REEXPORT_PATTERNS.all, 'namespace', imports, externalDependencies, resolvePaths, includeExternal, () => ['*'], (match) => match[1] ?? '');
|
|
76
|
+
}
|
|
77
|
+
return {
|
|
78
|
+
imports,
|
|
79
|
+
externalDependencies,
|
|
80
|
+
stats: {
|
|
81
|
+
filesScanned: files.length,
|
|
82
|
+
importsFound: imports.length,
|
|
83
|
+
externalPackages: externalDependencies.size,
|
|
84
|
+
},
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
// ============================================================================
|
|
88
|
+
// Helpers
|
|
89
|
+
// ============================================================================
|
|
90
|
+
function collectImportPattern(content, _lines, sourceFile, fileDir, projectRoot, pattern, importType, imports, externalDependencies, resolvePaths, includeExternal, getNames, getSpecifier) {
|
|
91
|
+
// Reset pattern
|
|
92
|
+
pattern.lastIndex = 0;
|
|
93
|
+
let match;
|
|
94
|
+
while ((match = pattern.exec(content)) !== null) {
|
|
95
|
+
const rawSpecifier = getSpecifier(match);
|
|
96
|
+
if (!rawSpecifier)
|
|
97
|
+
continue;
|
|
98
|
+
const isExternal = !rawSpecifier.startsWith('.') && !rawSpecifier.startsWith('/');
|
|
99
|
+
// Track external dependencies
|
|
100
|
+
if (isExternal) {
|
|
101
|
+
const packageName = getPackageName(rawSpecifier);
|
|
102
|
+
externalDependencies.add(packageName);
|
|
103
|
+
if (!includeExternal)
|
|
104
|
+
continue;
|
|
105
|
+
}
|
|
106
|
+
// Resolve target file
|
|
107
|
+
let targetFile = rawSpecifier;
|
|
108
|
+
if (!isExternal && resolvePaths) {
|
|
109
|
+
targetFile = resolveImportPath(rawSpecifier, fileDir, projectRoot);
|
|
110
|
+
}
|
|
111
|
+
// Get line number
|
|
112
|
+
const lineNumber = getLineNumber(content, match.index);
|
|
113
|
+
imports.push({
|
|
114
|
+
sourceFile,
|
|
115
|
+
targetFile,
|
|
116
|
+
importType,
|
|
117
|
+
importedNames: getNames(match),
|
|
118
|
+
rawSpecifier,
|
|
119
|
+
isExternal,
|
|
120
|
+
lineNumber,
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
function parseNamedImports(namedString) {
|
|
125
|
+
return namedString
|
|
126
|
+
.split(',')
|
|
127
|
+
.map((s) => s.trim())
|
|
128
|
+
.filter((s) => s.length > 0)
|
|
129
|
+
.map((s) => {
|
|
130
|
+
// Handle "original as alias"
|
|
131
|
+
const parts = s.split(/\s+as\s+/);
|
|
132
|
+
return parts[0]?.trim() ?? s;
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
function getPackageName(specifier) {
|
|
136
|
+
// Handle scoped packages: @scope/package/path -> @scope/package
|
|
137
|
+
if (specifier.startsWith('@')) {
|
|
138
|
+
const parts = specifier.split('/');
|
|
139
|
+
return parts.slice(0, 2).join('/');
|
|
140
|
+
}
|
|
141
|
+
// Regular packages: package/path -> package
|
|
142
|
+
return specifier.split('/')[0] ?? specifier;
|
|
143
|
+
}
|
|
144
|
+
function resolveImportPath(specifier, fromDir, projectRoot) {
|
|
145
|
+
// Resolve the path
|
|
146
|
+
const absolutePath = resolve(fromDir, specifier);
|
|
147
|
+
// Try common extensions
|
|
148
|
+
const extensions = ['', '.ts', '.tsx', '.js', '.jsx', '.mjs', '.cjs', '/index.ts', '/index.tsx', '/index.js'];
|
|
149
|
+
for (const ext of extensions) {
|
|
150
|
+
const tryPath = absolutePath + ext;
|
|
151
|
+
if (existsSync(tryPath)) {
|
|
152
|
+
return relative(projectRoot, tryPath);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
// Return as-is if not found
|
|
156
|
+
return relative(projectRoot, absolutePath);
|
|
157
|
+
}
|
|
158
|
+
function getLineNumber(content, index) {
|
|
159
|
+
const before = content.slice(0, index);
|
|
160
|
+
return (before.match(/\n/g) ?? []).length + 1;
|
|
161
|
+
}
|
|
162
|
+
// ============================================================================
|
|
163
|
+
// Specialized Functions
|
|
164
|
+
// ============================================================================
|
|
165
|
+
/**
|
|
166
|
+
* Get all files that import a specific file
|
|
167
|
+
*/
|
|
168
|
+
export async function findImportersOf(projectRoot, targetFile) {
|
|
169
|
+
const result = await collectImports({ projectRoot });
|
|
170
|
+
const normalizedTarget = targetFile.replace(/\.(ts|tsx|js|jsx)$/, '');
|
|
171
|
+
return result.imports.filter((imp) => {
|
|
172
|
+
const normalizedImport = imp.targetFile.replace(/\.(ts|tsx|js|jsx)$/, '');
|
|
173
|
+
return (normalizedImport === normalizedTarget ||
|
|
174
|
+
normalizedImport.endsWith('/' + normalizedTarget));
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Get all files imported by a specific file
|
|
179
|
+
*/
|
|
180
|
+
export async function findImportsOf(projectRoot, sourceFile) {
|
|
181
|
+
const result = await collectImports({ projectRoot });
|
|
182
|
+
return result.imports.filter((imp) => imp.sourceFile === sourceFile);
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Build a dependency graph from imports
|
|
186
|
+
*/
|
|
187
|
+
export async function buildDependencyGraph(projectRoot) {
|
|
188
|
+
const result = await collectImports({ projectRoot });
|
|
189
|
+
const graph = new Map();
|
|
190
|
+
for (const imp of result.imports) {
|
|
191
|
+
if (imp.isExternal)
|
|
192
|
+
continue;
|
|
193
|
+
if (!graph.has(imp.sourceFile)) {
|
|
194
|
+
graph.set(imp.sourceFile, new Set());
|
|
195
|
+
}
|
|
196
|
+
graph.get(imp.sourceFile)?.add(imp.targetFile);
|
|
197
|
+
}
|
|
198
|
+
return graph;
|
|
199
|
+
}
|
|
200
|
+
/**
|
|
201
|
+
* Find circular dependencies
|
|
202
|
+
*/
|
|
203
|
+
export async function findCircularDependencies(projectRoot) {
|
|
204
|
+
const graph = await buildDependencyGraph(projectRoot);
|
|
205
|
+
const cycles = [];
|
|
206
|
+
const visited = new Set();
|
|
207
|
+
const stack = new Set();
|
|
208
|
+
function dfs(node, path) {
|
|
209
|
+
if (stack.has(node)) {
|
|
210
|
+
// Found a cycle
|
|
211
|
+
const cycleStart = path.indexOf(node);
|
|
212
|
+
cycles.push(path.slice(cycleStart));
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
if (visited.has(node))
|
|
216
|
+
return;
|
|
217
|
+
visited.add(node);
|
|
218
|
+
stack.add(node);
|
|
219
|
+
const deps = graph.get(node) ?? new Set();
|
|
220
|
+
for (const dep of deps) {
|
|
221
|
+
dfs(dep, [...path, node]);
|
|
222
|
+
}
|
|
223
|
+
stack.delete(node);
|
|
224
|
+
}
|
|
225
|
+
for (const node of graph.keys()) {
|
|
226
|
+
dfs(node, []);
|
|
227
|
+
}
|
|
228
|
+
return cycles;
|
|
229
|
+
}
|
|
230
|
+
//# sourceMappingURL=imports.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"imports.js","sourceRoot":"","sources":["../../../src/graph/collectors/imports.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,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,IAAI,CAAC;AAsChC,+EAA+E;AAC/E,WAAW;AACX,+EAA+E;AAE/E,qBAAqB;AACrB,MAAM,eAAe,GAAG;IACtB,qCAAqC;IACrC,OAAO,EAAE,gEAAgE;IAEzE,0CAA0C;IAC1C,KAAK,EA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to populate the knowledge graph.
|
|
5
|
+
*/
|
|
6
|
+
export { collectGitHistory, collectDesignSystemHistory, getFileHistory, getFileBlame, isGitRepository, getCurrentBranch, getRemoteUrl, type CollectedCommit, type CollectedDeveloper, type FileChange, type GitCollectorOptions, type GitCollectorResult, } from './git.js';
|
|
7
|
+
export { collectUsages, findHardcodedColors, findCSSVariableUsages, findTokenUsagesInFiles, findComponentUsagesInFiles, type TokenUsage, type ComponentUsage, type UsageType, type UsageCollectorOptions, type UsageCollectorResult, } from './usages.js';
|
|
8
|
+
export { collectImports, findImportersOf, findImportsOf, buildDependencyGraph, findCircularDependencies, type FileImport, type ImportType, type ImportCollectorOptions, type ImportCollectorResult, } from './imports.js';
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/graph/collectors/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAGH,OAAO,EACL,iBAAiB,EACjB,0BAA0B,EAC1B,cAAc,EACd,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,YAAY,EACZ,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,KAAK,UAAU,EACf,KAAK,mBAAmB,EACxB,KAAK,kBAAkB,GACxB,MAAM,UAAU,CAAC;AAGlB,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,EACtB,0BAA0B,EAC1B,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,SAAS,EACd,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,GAC1B,MAAM,aAAa,CAAC;AAGrB,OAAO,EACL,cAAc,EACd,eAAe,EACf,aAAa,EACb,oBAAoB,EACpB,wBAAwB,EACxB,KAAK,UAAU,EACf,KAAK,UAAU,EACf,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,GAC3B,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Graph Collectors
|
|
3
|
+
*
|
|
4
|
+
* Extract data from various sources to populate the knowledge graph.
|
|
5
|
+
*/
|
|
6
|
+
// Git history
|
|
7
|
+
export { collectGitHistory, collectDesignSystemHistory, getFileHistory, getFileBlame, isGitRepository, getCurrentBranch, getRemoteUrl, } from './git.js';
|
|
8
|
+
// Token and component usages
|
|
9
|
+
export { collectUsages, findHardcodedColors, findCSSVariableUsages, findTokenUsagesInFiles, findComponentUsagesInFiles, } from './usages.js';
|
|
10
|
+
// Import relationships
|
|
11
|
+
export { collectImports, findImportersOf, findImportsOf, buildDependencyGraph, findCircularDependencies, } from './imports.js';
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/graph/collectors/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc;AACd,OAAO,EACL,iBAAiB,EACjB,0BAA0B,EAC1B,cAAc,EACd,YAAY,EACZ,eAAe,EACf,gBAAgB,EAChB,YAAY,GAMb,MAAM,UAAU,CAAC;AAElB,6BAA6B;AAC7B,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,EACtB,0BAA0B,GAM3B,MAAM,aAAa,CAAC;AAErB,uBAAuB;AACvB,OAAO,EACL,cAAc,EACd,eAAe,EACf,aAAa,EACb,oBAAoB,EACpB,wBAAwB,GAKzB,MAAM,cAAc,CAAC"}
|