@rayburst/cli 0.2.5 → 0.2.6
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.
|
@@ -191,6 +191,10 @@ async function analyzeProject(projectPath, projectId, onLog) {
|
|
|
191
191
|
packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
|
|
192
192
|
}
|
|
193
193
|
const branchId = gitInfo.branch.replace(/[^a-zA-Z0-9]/g, "-");
|
|
194
|
+
const entryPoint = detectEntryPoint(projectPath);
|
|
195
|
+
if (entryPoint) {
|
|
196
|
+
log(` Entry point detected: ${entryPoint}`);
|
|
197
|
+
}
|
|
194
198
|
const projectMetadata = {
|
|
195
199
|
id: projectId || crypto.createHash("md5").update(projectPath).digest("hex").substring(0, 12),
|
|
196
200
|
title: packageJson.name || path2.basename(projectPath),
|
|
@@ -198,7 +202,8 @@ async function analyzeProject(projectPath, projectId, onLog) {
|
|
|
198
202
|
value: `${nodes.length} nodes`,
|
|
199
203
|
trend: 0,
|
|
200
204
|
chartData: [30, 40, 35, 50, 45, 60, 55, 70],
|
|
201
|
-
chartColor: "#22c55e"
|
|
205
|
+
chartColor: "#22c55e",
|
|
206
|
+
entryPoint
|
|
202
207
|
};
|
|
203
208
|
const branchMetadata = {
|
|
204
209
|
id: branchId,
|
|
@@ -245,6 +250,7 @@ function createEmptyAnalysis(projectPath, gitInfo) {
|
|
|
245
250
|
packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
|
|
246
251
|
}
|
|
247
252
|
const branchId = gitInfo.branch.replace(/[^a-zA-Z0-9]/g, "-");
|
|
253
|
+
const entryPoint = detectEntryPoint(projectPath);
|
|
248
254
|
return {
|
|
249
255
|
project: {
|
|
250
256
|
id: crypto.createHash("md5").update(projectPath).digest("hex").substring(0, 12),
|
|
@@ -253,7 +259,8 @@ function createEmptyAnalysis(projectPath, gitInfo) {
|
|
|
253
259
|
value: "0 nodes",
|
|
254
260
|
trend: 0,
|
|
255
261
|
chartData: [],
|
|
256
|
-
chartColor: "#6b7280"
|
|
262
|
+
chartColor: "#6b7280",
|
|
263
|
+
entryPoint
|
|
257
264
|
},
|
|
258
265
|
branches: [{
|
|
259
266
|
id: branchId,
|
|
@@ -292,6 +299,64 @@ function getGitInfo(projectPath) {
|
|
|
292
299
|
};
|
|
293
300
|
}
|
|
294
301
|
}
|
|
302
|
+
function detectEntryPoint(projectPath) {
|
|
303
|
+
const packageJsonPath = path2.join(projectPath, "package.json");
|
|
304
|
+
if (fs.existsSync(packageJsonPath)) {
|
|
305
|
+
try {
|
|
306
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, "utf-8"));
|
|
307
|
+
if (packageJson.main) {
|
|
308
|
+
return packageJson.main;
|
|
309
|
+
}
|
|
310
|
+
} catch (error) {
|
|
311
|
+
console.error("Error reading package.json:", error);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
const viteConfigPaths = [
|
|
315
|
+
"vite.config.ts",
|
|
316
|
+
"vite.config.js",
|
|
317
|
+
"vite.config.mts",
|
|
318
|
+
"vite.config.mjs"
|
|
319
|
+
];
|
|
320
|
+
for (const configFile of viteConfigPaths) {
|
|
321
|
+
const configPath = path2.join(projectPath, configFile);
|
|
322
|
+
if (fs.existsSync(configPath)) {
|
|
323
|
+
try {
|
|
324
|
+
const configContent = fs.readFileSync(configPath, "utf-8");
|
|
325
|
+
const inputMatch = configContent.match(/input:\s*['"]([\w\/\.-]+)['"]/);
|
|
326
|
+
if (inputMatch) {
|
|
327
|
+
return inputMatch[1];
|
|
328
|
+
}
|
|
329
|
+
const htmlMatch = configContent.match(/['"]\.\/?(index\.html)['"]/);
|
|
330
|
+
if (htmlMatch) {
|
|
331
|
+
const indexHtmlPath = path2.join(projectPath, "index.html");
|
|
332
|
+
if (fs.existsSync(indexHtmlPath)) {
|
|
333
|
+
const htmlContent = fs.readFileSync(indexHtmlPath, "utf-8");
|
|
334
|
+
const scriptMatch = htmlContent.match(/<script[^>]+src=["']\/?([^"']+)["']/);
|
|
335
|
+
if (scriptMatch) {
|
|
336
|
+
return scriptMatch[1];
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
} catch (error) {
|
|
341
|
+
console.error(`Error reading ${configFile}:`, error);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
const commonEntryPoints = [
|
|
346
|
+
"src/main.ts",
|
|
347
|
+
"src/main.tsx",
|
|
348
|
+
"src/index.ts",
|
|
349
|
+
"src/index.tsx",
|
|
350
|
+
"src/app.ts",
|
|
351
|
+
"src/app.tsx"
|
|
352
|
+
];
|
|
353
|
+
for (const entry of commonEntryPoints) {
|
|
354
|
+
if (fs.existsSync(path2.join(projectPath, entry))) {
|
|
355
|
+
return entry;
|
|
356
|
+
}
|
|
357
|
+
}
|
|
358
|
+
return void 0;
|
|
359
|
+
}
|
|
295
360
|
function createNodeId(filePath, nodeName, gitHash, counter = 0) {
|
|
296
361
|
const suffix = counter > 0 ? `-${counter}` : "";
|
|
297
362
|
return `${filePath}::${nodeName}${suffix}::${gitHash}`;
|
package/dist/index.js
CHANGED
package/dist/vite-plugin.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rayburst/cli",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.6",
|
|
4
4
|
"description": "Rayburst - Automatic code analysis for TypeScript/JavaScript projects via Vite plugin",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"zod": "^4.2.0"
|
|
48
48
|
},
|
|
49
49
|
"devDependencies": {
|
|
50
|
-
"@rayburst/types": "^0.1.
|
|
50
|
+
"@rayburst/types": "^0.1.5",
|
|
51
51
|
"@types/node": "^25.0.2",
|
|
52
52
|
"tsup": "^8.5.1",
|
|
53
53
|
"typescript": "^5.9.3",
|