@rayburst/cli 0.4.12 → 0.4.14
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/{chunk-ANVJHFHG.js → chunk-Q2M2UILE.js} +148 -257
- package/dist/index.js +1 -1
- package/dist/vite-plugin.js +1 -1
- package/package.json +2 -2
|
@@ -30,6 +30,79 @@ function getUncommittedChanges(projectPath) {
|
|
|
30
30
|
return [];
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
|
+
function getUnstagedChanges(projectPath) {
|
|
34
|
+
try {
|
|
35
|
+
if (!isGitRepository(projectPath)) {
|
|
36
|
+
return [];
|
|
37
|
+
}
|
|
38
|
+
const output = execSync("git diff --name-only", {
|
|
39
|
+
cwd: projectPath,
|
|
40
|
+
encoding: "utf8",
|
|
41
|
+
stdio: ["pipe", "pipe", "ignore"]
|
|
42
|
+
});
|
|
43
|
+
return output.split("\n").filter(Boolean).map((file) => path.resolve(projectPath, file.trim()));
|
|
44
|
+
} catch (error) {
|
|
45
|
+
console.error("Failed to get unstaged changes:", error.message);
|
|
46
|
+
return [];
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function getStagedChanges(projectPath) {
|
|
50
|
+
try {
|
|
51
|
+
if (!isGitRepository(projectPath)) {
|
|
52
|
+
return [];
|
|
53
|
+
}
|
|
54
|
+
const output = execSync("git diff --name-only --cached", {
|
|
55
|
+
cwd: projectPath,
|
|
56
|
+
encoding: "utf8",
|
|
57
|
+
stdio: ["pipe", "pipe", "ignore"]
|
|
58
|
+
});
|
|
59
|
+
return output.split("\n").filter(Boolean).map((file) => path.resolve(projectPath, file.trim()));
|
|
60
|
+
} catch (error) {
|
|
61
|
+
console.error("Failed to get staged changes:", error.message);
|
|
62
|
+
return [];
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function getCommittedChanges(projectPath, remoteBranch = void 0) {
|
|
66
|
+
try {
|
|
67
|
+
if (!isGitRepository(projectPath)) {
|
|
68
|
+
return [];
|
|
69
|
+
}
|
|
70
|
+
let currentBranch;
|
|
71
|
+
try {
|
|
72
|
+
currentBranch = execSync("git branch --show-current", {
|
|
73
|
+
cwd: projectPath,
|
|
74
|
+
encoding: "utf8",
|
|
75
|
+
stdio: ["pipe", "pipe", "ignore"]
|
|
76
|
+
}).trim();
|
|
77
|
+
} catch {
|
|
78
|
+
currentBranch = execSync("git rev-parse --abbrev-ref HEAD", {
|
|
79
|
+
cwd: projectPath,
|
|
80
|
+
encoding: "utf8",
|
|
81
|
+
stdio: ["pipe", "pipe", "ignore"]
|
|
82
|
+
}).trim();
|
|
83
|
+
}
|
|
84
|
+
const remote = remoteBranch || `origin/${currentBranch}`;
|
|
85
|
+
try {
|
|
86
|
+
execSync(`git rev-parse --verify ${remote}`, {
|
|
87
|
+
cwd: projectPath,
|
|
88
|
+
stdio: ["pipe", "pipe", "ignore"]
|
|
89
|
+
});
|
|
90
|
+
} catch {
|
|
91
|
+
return [];
|
|
92
|
+
}
|
|
93
|
+
const output = execSync(`git diff --name-only ${remote}...HEAD`, {
|
|
94
|
+
cwd: projectPath,
|
|
95
|
+
encoding: "utf8",
|
|
96
|
+
stdio: ["pipe", "pipe", "ignore"]
|
|
97
|
+
});
|
|
98
|
+
const allChanges = output.split("\n").filter(Boolean).map((file) => path.resolve(projectPath, file.trim()));
|
|
99
|
+
const uncommitted = new Set(getUncommittedChanges(projectPath));
|
|
100
|
+
return allChanges.filter((file) => !uncommitted.has(file));
|
|
101
|
+
} catch (error) {
|
|
102
|
+
console.error("Failed to get committed changes:", error.message);
|
|
103
|
+
return [];
|
|
104
|
+
}
|
|
105
|
+
}
|
|
33
106
|
function isGitRepository(projectPath) {
|
|
34
107
|
try {
|
|
35
108
|
execSync("git rev-parse --is-inside-work-tree", {
|
|
@@ -437,15 +510,15 @@ function createRouterDecisionNode(sourceFilePath, gitHash, routeCount) {
|
|
|
437
510
|
};
|
|
438
511
|
}
|
|
439
512
|
function extractRoutePathFromFile(routeFilePath) {
|
|
440
|
-
let
|
|
441
|
-
if (
|
|
513
|
+
let path5 = routeFilePath.replace(/^src\/routes\//, "/").replace(/\.(tsx?|jsx?)$/, "").replace(/\/route$/, "").replace(/\/index$/, "");
|
|
514
|
+
if (path5 === "/__root") {
|
|
442
515
|
return "/";
|
|
443
516
|
}
|
|
444
|
-
|
|
445
|
-
if (
|
|
517
|
+
path5 = path5.replace(/\/\$([^/]+)/g, (_, param) => `/:${param}`);
|
|
518
|
+
if (path5 === "" || path5 === "/") {
|
|
446
519
|
return "/";
|
|
447
520
|
}
|
|
448
|
-
return
|
|
521
|
+
return path5;
|
|
449
522
|
}
|
|
450
523
|
function createConfigBasedEdges(sourceNode, targetFilePaths, nodeMap, edges, edgeType = "config", useRoutePathLabels = false) {
|
|
451
524
|
let edgesCreated = 0;
|
|
@@ -946,26 +1019,44 @@ async function analyzeProject(projectPath, projectId, onLog) {
|
|
|
946
1019
|
nodes,
|
|
947
1020
|
edges
|
|
948
1021
|
};
|
|
1022
|
+
const filterAndCollectMetadata = (files) => {
|
|
1023
|
+
const filtered = files.filter((filePath) => {
|
|
1024
|
+
return !filePath.includes("node_modules") && !filePath.includes(".test.") && !filePath.includes(".spec.") && (filePath.endsWith(".ts") || filePath.endsWith(".tsx") || filePath.endsWith(".js") || filePath.endsWith(".jsx"));
|
|
1025
|
+
});
|
|
1026
|
+
const metadata = [];
|
|
1027
|
+
for (const filePath of filtered) {
|
|
1028
|
+
try {
|
|
1029
|
+
const stats = fs.statSync(filePath);
|
|
1030
|
+
metadata.push({
|
|
1031
|
+
filePath,
|
|
1032
|
+
lastModified: stats.mtimeMs
|
|
1033
|
+
});
|
|
1034
|
+
} catch (error) {
|
|
1035
|
+
log(` Warning: Could not get stats for ${filePath}`);
|
|
1036
|
+
}
|
|
1037
|
+
}
|
|
1038
|
+
return { filtered, metadata };
|
|
1039
|
+
};
|
|
949
1040
|
log(" Checking for changed files vs remote...");
|
|
950
1041
|
const allChangedFiles = getChangedFilesVsRemote(projectPath);
|
|
951
1042
|
log(` Found ${allChangedFiles.length} changed files`);
|
|
952
|
-
const changedFiles = allChangedFiles
|
|
953
|
-
return !filePath.includes("node_modules") && !filePath.includes(".test.") && !filePath.includes(".spec.") && (filePath.endsWith(".ts") || filePath.endsWith(".tsx") || filePath.endsWith(".js") || filePath.endsWith(".jsx"));
|
|
954
|
-
});
|
|
1043
|
+
const { filtered: changedFiles, metadata: changedFilesMetadata } = filterAndCollectMetadata(allChangedFiles);
|
|
955
1044
|
log(` Filtered to ${changedFiles.length} analyzed source files`);
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
}
|
|
1045
|
+
log(" Checking for unstaged changes...");
|
|
1046
|
+
const allUnstagedFiles = getUnstagedChanges(projectPath);
|
|
1047
|
+
log(` Found ${allUnstagedFiles.length} unstaged files`);
|
|
1048
|
+
const { filtered: unstagedFiles, metadata: unstagedFilesMetadata } = filterAndCollectMetadata(allUnstagedFiles);
|
|
1049
|
+
log(` Filtered to ${unstagedFiles.length} analyzed source files`);
|
|
1050
|
+
log(" Checking for staged changes...");
|
|
1051
|
+
const allStagedFiles = getStagedChanges(projectPath);
|
|
1052
|
+
log(` Found ${allStagedFiles.length} staged files`);
|
|
1053
|
+
const { filtered: stagedFiles, metadata: stagedFilesMetadata } = filterAndCollectMetadata(allStagedFiles);
|
|
1054
|
+
log(` Filtered to ${stagedFiles.length} analyzed source files`);
|
|
1055
|
+
log(" Checking for committed changes...");
|
|
1056
|
+
const allCommittedFiles = getCommittedChanges(projectPath);
|
|
1057
|
+
log(` Found ${allCommittedFiles.length} committed files`);
|
|
1058
|
+
const { filtered: committedFiles, metadata: committedFilesMetadata } = filterAndCollectMetadata(allCommittedFiles);
|
|
1059
|
+
log(` Filtered to ${committedFiles.length} analyzed source files`);
|
|
969
1060
|
const result = {
|
|
970
1061
|
project: projectMetadata,
|
|
971
1062
|
branches: [branchMetadata],
|
|
@@ -979,6 +1070,24 @@ async function analyzeProject(projectPath, projectId, onLog) {
|
|
|
979
1070
|
} : void 0,
|
|
980
1071
|
changedFilesMetadata: changedFilesMetadata.length > 0 ? {
|
|
981
1072
|
[branchId]: changedFilesMetadata
|
|
1073
|
+
} : void 0,
|
|
1074
|
+
unstagedFiles: unstagedFiles.length > 0 ? {
|
|
1075
|
+
[branchId]: unstagedFiles
|
|
1076
|
+
} : void 0,
|
|
1077
|
+
unstagedFilesMetadata: unstagedFilesMetadata.length > 0 ? {
|
|
1078
|
+
[branchId]: unstagedFilesMetadata
|
|
1079
|
+
} : void 0,
|
|
1080
|
+
stagedFiles: stagedFiles.length > 0 ? {
|
|
1081
|
+
[branchId]: stagedFiles
|
|
1082
|
+
} : void 0,
|
|
1083
|
+
stagedFilesMetadata: stagedFilesMetadata.length > 0 ? {
|
|
1084
|
+
[branchId]: stagedFilesMetadata
|
|
1085
|
+
} : void 0,
|
|
1086
|
+
committedFiles: committedFiles.length > 0 ? {
|
|
1087
|
+
[branchId]: committedFiles
|
|
1088
|
+
} : void 0,
|
|
1089
|
+
committedFilesMetadata: committedFilesMetadata.length > 0 ? {
|
|
1090
|
+
[branchId]: committedFilesMetadata
|
|
982
1091
|
} : void 0
|
|
983
1092
|
};
|
|
984
1093
|
return result;
|
|
@@ -1794,192 +1903,10 @@ function generateProjectId(projectPath) {
|
|
|
1794
1903
|
return `${baseName}-${timestamp}`;
|
|
1795
1904
|
}
|
|
1796
1905
|
|
|
1797
|
-
// src/registry.ts
|
|
1798
|
-
import path4 from "path";
|
|
1799
|
-
import { fileURLToPath } from "url";
|
|
1800
|
-
import os from "os";
|
|
1801
|
-
var __filename = fileURLToPath(import.meta.url);
|
|
1802
|
-
var __dirname = path4.dirname(__filename);
|
|
1803
|
-
var RAYBURST_DIR = path4.join(os.homedir(), ".rayburst");
|
|
1804
|
-
var PROJECTS_FILE = path4.join(RAYBURST_DIR, "projects.json");
|
|
1805
|
-
var ANALYZED_DIR = path4.join(RAYBURST_DIR, "analyzed");
|
|
1806
|
-
|
|
1807
|
-
// src/incremental-analyzer.ts
|
|
1808
|
-
import chalk from "chalk";
|
|
1809
|
-
function generateDiff(oldAnalysis, newAnalysis) {
|
|
1810
|
-
const update = {
|
|
1811
|
-
added: {
|
|
1812
|
-
nodes: [],
|
|
1813
|
-
edges: []
|
|
1814
|
-
},
|
|
1815
|
-
removed: {
|
|
1816
|
-
nodeIds: [],
|
|
1817
|
-
edgeIds: []
|
|
1818
|
-
},
|
|
1819
|
-
modified: {
|
|
1820
|
-
nodes: [],
|
|
1821
|
-
edges: []
|
|
1822
|
-
}
|
|
1823
|
-
};
|
|
1824
|
-
const branches = /* @__PURE__ */ new Set([
|
|
1825
|
-
...Object.keys(oldAnalysis.planData || {}),
|
|
1826
|
-
...Object.keys(newAnalysis.planData || {})
|
|
1827
|
-
]);
|
|
1828
|
-
for (const branchId of branches) {
|
|
1829
|
-
const oldPlanData = oldAnalysis.planData?.[branchId];
|
|
1830
|
-
const newPlanData = newAnalysis.planData?.[branchId];
|
|
1831
|
-
if (!oldPlanData && newPlanData) {
|
|
1832
|
-
update.added.nodes.push(...newPlanData.nodes || []);
|
|
1833
|
-
update.added.edges.push(...newPlanData.edges || []);
|
|
1834
|
-
continue;
|
|
1835
|
-
}
|
|
1836
|
-
if (oldPlanData && !newPlanData) {
|
|
1837
|
-
update.removed.nodeIds.push(...(oldPlanData.nodes || []).map((n) => n.id));
|
|
1838
|
-
update.removed.edgeIds.push(...(oldPlanData.edges || []).map((e) => e.id));
|
|
1839
|
-
continue;
|
|
1840
|
-
}
|
|
1841
|
-
const branchDiff = comparePlanData(oldPlanData, newPlanData);
|
|
1842
|
-
update.added.nodes.push(...branchDiff.added.nodes);
|
|
1843
|
-
update.added.edges.push(...branchDiff.added.edges);
|
|
1844
|
-
update.removed.nodeIds.push(...branchDiff.removed.nodeIds);
|
|
1845
|
-
update.removed.edgeIds.push(...branchDiff.removed.edgeIds);
|
|
1846
|
-
update.modified.nodes.push(...branchDiff.modified.nodes);
|
|
1847
|
-
update.modified.edges.push(...branchDiff.modified.edges);
|
|
1848
|
-
}
|
|
1849
|
-
return update;
|
|
1850
|
-
}
|
|
1851
|
-
function comparePlanData(oldPlanData, newPlanData) {
|
|
1852
|
-
const oldNodes = oldPlanData?.nodes || [];
|
|
1853
|
-
const newNodes = newPlanData?.nodes || [];
|
|
1854
|
-
const oldEdges = oldPlanData?.edges || [];
|
|
1855
|
-
const newEdges = newPlanData?.edges || [];
|
|
1856
|
-
const oldNodeMap = new Map(oldNodes.map((n) => [n.id, n]));
|
|
1857
|
-
const newNodeMap = new Map(newNodes.map((n) => [n.id, n]));
|
|
1858
|
-
const oldEdgeMap = new Map(oldEdges.map((e) => [e.id, e]));
|
|
1859
|
-
const newEdgeMap = new Map(newEdges.map((e) => [e.id, e]));
|
|
1860
|
-
const diff = {
|
|
1861
|
-
added: { nodes: [], edges: [] },
|
|
1862
|
-
removed: { nodeIds: [], edgeIds: [] },
|
|
1863
|
-
modified: { nodes: [], edges: [] }
|
|
1864
|
-
};
|
|
1865
|
-
for (const [nodeId, newNode] of newNodeMap) {
|
|
1866
|
-
const oldNode = oldNodeMap.get(nodeId);
|
|
1867
|
-
if (!oldNode) {
|
|
1868
|
-
diff.added.nodes.push(newNode);
|
|
1869
|
-
} else if (hasNodeChanged(oldNode, newNode)) {
|
|
1870
|
-
diff.modified.nodes.push({
|
|
1871
|
-
id: nodeId,
|
|
1872
|
-
...getNodeChanges(oldNode, newNode)
|
|
1873
|
-
});
|
|
1874
|
-
}
|
|
1875
|
-
}
|
|
1876
|
-
for (const nodeId of oldNodeMap.keys()) {
|
|
1877
|
-
if (!newNodeMap.has(nodeId)) {
|
|
1878
|
-
diff.removed.nodeIds.push(nodeId);
|
|
1879
|
-
}
|
|
1880
|
-
}
|
|
1881
|
-
for (const [edgeId, newEdge] of newEdgeMap) {
|
|
1882
|
-
const oldEdge = oldEdgeMap.get(edgeId);
|
|
1883
|
-
if (!oldEdge) {
|
|
1884
|
-
diff.added.edges.push(newEdge);
|
|
1885
|
-
} else if (hasEdgeChanged(oldEdge, newEdge)) {
|
|
1886
|
-
diff.modified.edges.push({
|
|
1887
|
-
id: edgeId,
|
|
1888
|
-
...getEdgeChanges(oldEdge, newEdge)
|
|
1889
|
-
});
|
|
1890
|
-
}
|
|
1891
|
-
}
|
|
1892
|
-
for (const edgeId of oldEdgeMap.keys()) {
|
|
1893
|
-
if (!newEdgeMap.has(edgeId)) {
|
|
1894
|
-
diff.removed.edgeIds.push(edgeId);
|
|
1895
|
-
}
|
|
1896
|
-
}
|
|
1897
|
-
return diff;
|
|
1898
|
-
}
|
|
1899
|
-
function hasNodeChanged(oldNode, newNode) {
|
|
1900
|
-
const oldData = JSON.stringify({ ...oldNode.data, type: oldNode.type });
|
|
1901
|
-
const newData = JSON.stringify({ ...newNode.data, type: newNode.type });
|
|
1902
|
-
return oldData !== newData;
|
|
1903
|
-
}
|
|
1904
|
-
function getNodeChanges(oldNode, newNode) {
|
|
1905
|
-
const changes = {};
|
|
1906
|
-
if (oldNode.type !== newNode.type) {
|
|
1907
|
-
changes.type = newNode.type;
|
|
1908
|
-
}
|
|
1909
|
-
if (JSON.stringify(oldNode.data) !== JSON.stringify(newNode.data)) {
|
|
1910
|
-
changes.data = newNode.data;
|
|
1911
|
-
}
|
|
1912
|
-
return changes;
|
|
1913
|
-
}
|
|
1914
|
-
function hasEdgeChanged(oldEdge, newEdge) {
|
|
1915
|
-
return oldEdge.source !== newEdge.source || oldEdge.target !== newEdge.target || oldEdge.type !== newEdge.type || JSON.stringify(oldEdge.data) !== JSON.stringify(newEdge.data);
|
|
1916
|
-
}
|
|
1917
|
-
function getEdgeChanges(oldEdge, newEdge) {
|
|
1918
|
-
const changes = {};
|
|
1919
|
-
if (oldEdge.source !== newEdge.source) changes.source = newEdge.source;
|
|
1920
|
-
if (oldEdge.target !== newEdge.target) changes.target = newEdge.target;
|
|
1921
|
-
if (oldEdge.type !== newEdge.type) changes.type = newEdge.type;
|
|
1922
|
-
if (JSON.stringify(oldEdge.data) !== JSON.stringify(newEdge.data)) {
|
|
1923
|
-
changes.data = newEdge.data;
|
|
1924
|
-
}
|
|
1925
|
-
return changes;
|
|
1926
|
-
}
|
|
1927
|
-
function generateChangeHistoryEntry(diff, trigger, gitCommitHash, newPlanData) {
|
|
1928
|
-
const timestamp = Date.now();
|
|
1929
|
-
const analysisRunId = `${timestamp}-${Math.random().toString(36).substring(7)}`;
|
|
1930
|
-
const nodeChanges = [];
|
|
1931
|
-
for (const node of diff.added.nodes) {
|
|
1932
|
-
const filePath = node.id.split("::")[0] || "unknown";
|
|
1933
|
-
nodeChanges.push({
|
|
1934
|
-
timestamp,
|
|
1935
|
-
nodeId: node.id,
|
|
1936
|
-
changeType: "added",
|
|
1937
|
-
changedFields: void 0,
|
|
1938
|
-
previousState: void 0,
|
|
1939
|
-
currentState: node,
|
|
1940
|
-
filePath
|
|
1941
|
-
});
|
|
1942
|
-
}
|
|
1943
|
-
for (const nodeId of diff.removed.nodeIds) {
|
|
1944
|
-
const filePath = nodeId.split("::")[0] || "unknown";
|
|
1945
|
-
nodeChanges.push({
|
|
1946
|
-
timestamp,
|
|
1947
|
-
nodeId,
|
|
1948
|
-
changeType: "removed",
|
|
1949
|
-
changedFields: void 0,
|
|
1950
|
-
previousState: void 0,
|
|
1951
|
-
// We don't have the previous state in current diff
|
|
1952
|
-
currentState: void 0,
|
|
1953
|
-
filePath
|
|
1954
|
-
});
|
|
1955
|
-
}
|
|
1956
|
-
for (const modifiedNode of diff.modified.nodes) {
|
|
1957
|
-
const filePath = modifiedNode.id.split("::")[0] || "unknown";
|
|
1958
|
-
const changedFields = Object.keys(modifiedNode.changes || {});
|
|
1959
|
-
nodeChanges.push({
|
|
1960
|
-
timestamp,
|
|
1961
|
-
nodeId: modifiedNode.id,
|
|
1962
|
-
changeType: "modified",
|
|
1963
|
-
changedFields: changedFields.length > 0 ? changedFields : void 0,
|
|
1964
|
-
previousState: void 0,
|
|
1965
|
-
// Would need old plan data to populate
|
|
1966
|
-
currentState: newPlanData.nodes.find((n) => n.id === modifiedNode.id),
|
|
1967
|
-
filePath
|
|
1968
|
-
});
|
|
1969
|
-
}
|
|
1970
|
-
return {
|
|
1971
|
-
timestamp,
|
|
1972
|
-
analysisRunId,
|
|
1973
|
-
trigger,
|
|
1974
|
-
nodeChanges,
|
|
1975
|
-
gitCommitHash
|
|
1976
|
-
};
|
|
1977
|
-
}
|
|
1978
|
-
|
|
1979
1906
|
// src/vite-plugin.ts
|
|
1980
|
-
import
|
|
1907
|
+
import chalk from "chalk";
|
|
1981
1908
|
import * as fs3 from "fs";
|
|
1982
|
-
import * as
|
|
1909
|
+
import * as path4 from "path";
|
|
1983
1910
|
var unpluginFactory = (options = {}) => {
|
|
1984
1911
|
const {
|
|
1985
1912
|
enabled = process.env.CI !== "true",
|
|
@@ -1993,11 +1920,11 @@ var unpluginFactory = (options = {}) => {
|
|
|
1993
1920
|
let gitPollInterval = null;
|
|
1994
1921
|
const checkGitState = (projectPath) => {
|
|
1995
1922
|
try {
|
|
1996
|
-
const gitDir =
|
|
1923
|
+
const gitDir = path4.join(projectPath, ".git");
|
|
1997
1924
|
if (!fs3.existsSync(gitDir)) {
|
|
1998
1925
|
return false;
|
|
1999
1926
|
}
|
|
2000
|
-
const headPath =
|
|
1927
|
+
const headPath = path4.join(gitDir, "HEAD");
|
|
2001
1928
|
if (!fs3.existsSync(headPath)) {
|
|
2002
1929
|
return false;
|
|
2003
1930
|
}
|
|
@@ -2005,7 +1932,7 @@ var unpluginFactory = (options = {}) => {
|
|
|
2005
1932
|
let gitState = headContent;
|
|
2006
1933
|
if (headContent.startsWith("ref: ")) {
|
|
2007
1934
|
const refPath = headContent.substring(5);
|
|
2008
|
-
const fullRefPath =
|
|
1935
|
+
const fullRefPath = path4.join(gitDir, refPath);
|
|
2009
1936
|
if (fs3.existsSync(fullRefPath)) {
|
|
2010
1937
|
const refContent = fs3.readFileSync(fullRefPath, "utf-8").trim();
|
|
2011
1938
|
gitState = `${headContent}:${refContent}`;
|
|
@@ -2031,56 +1958,20 @@ var unpluginFactory = (options = {}) => {
|
|
|
2031
1958
|
const projectPath = config.root;
|
|
2032
1959
|
const previousAnalysis = await readLocalAnalysis(projectPath);
|
|
2033
1960
|
const newAnalysis = await analyzeProject(projectPath);
|
|
2034
|
-
const branches = Object.keys(newAnalysis.planData);
|
|
2035
|
-
if (!newAnalysis.changeHistory && branches.length > 0) {
|
|
2036
|
-
newAnalysis.changeHistory = {};
|
|
2037
|
-
for (const branchId of branches) {
|
|
2038
|
-
newAnalysis.changeHistory[branchId] = [];
|
|
2039
|
-
}
|
|
2040
|
-
}
|
|
2041
1961
|
if (previousAnalysis) {
|
|
2042
|
-
|
|
2043
|
-
if (diff.added.nodes.length > 0 || diff.removed.nodeIds.length > 0 || diff.modified.nodes.length > 0) {
|
|
2044
|
-
const trigger = triggerFile === "git-event" || triggerFile === "git-poll" ? "git-commit" : "file-change";
|
|
2045
|
-
const firstBranch = Object.keys(newAnalysis.planData)[0];
|
|
2046
|
-
if (firstBranch) {
|
|
2047
|
-
const planData = newAnalysis.planData[firstBranch];
|
|
2048
|
-
const historyEntry = generateChangeHistoryEntry(diff, trigger, void 0, planData);
|
|
2049
|
-
const existingHistory = previousAnalysis.changeHistory?.[firstBranch] || [];
|
|
2050
|
-
const maxHistoryEntries = 100;
|
|
2051
|
-
const updatedHistory = [...existingHistory, historyEntry].slice(-maxHistoryEntries);
|
|
2052
|
-
newAnalysis.changeHistory = {
|
|
2053
|
-
...newAnalysis.changeHistory,
|
|
2054
|
-
[firstBranch]: updatedHistory
|
|
2055
|
-
};
|
|
2056
|
-
}
|
|
2057
|
-
}
|
|
2058
|
-
console.log(chalk2.green("[Rayburst] Analysis updated:"));
|
|
2059
|
-
console.log(
|
|
2060
|
-
chalk2.gray(
|
|
2061
|
-
` Added: ${diff.added.nodes.length} nodes, ${diff.added.edges.length} edges`
|
|
2062
|
-
)
|
|
2063
|
-
);
|
|
2064
|
-
console.log(
|
|
2065
|
-
chalk2.gray(
|
|
2066
|
-
` Removed: ${diff.removed.nodeIds.length} nodes, ${diff.removed.edgeIds.length} edges`
|
|
2067
|
-
)
|
|
2068
|
-
);
|
|
2069
|
-
if (diff.modified.nodes.length > 0) {
|
|
2070
|
-
console.log(chalk2.gray(` Modified: ${diff.modified.nodes.length} nodes`));
|
|
2071
|
-
}
|
|
1962
|
+
console.log(chalk.green("[Rayburst] Analysis updated"));
|
|
2072
1963
|
} else {
|
|
2073
1964
|
const firstBranch = Object.keys(newAnalysis.planData)[0];
|
|
2074
1965
|
const nodeCount = firstBranch ? newAnalysis.planData[firstBranch].nodes.length : 0;
|
|
2075
1966
|
const edgeCount = firstBranch ? newAnalysis.planData[firstBranch].edges.length : 0;
|
|
2076
1967
|
console.log(
|
|
2077
|
-
|
|
1968
|
+
chalk.green(`[Rayburst] Initial analysis complete: ${nodeCount} nodes, ${edgeCount} edges`)
|
|
2078
1969
|
);
|
|
2079
1970
|
}
|
|
2080
1971
|
await writeLocalAnalysis(projectPath, newAnalysis);
|
|
2081
1972
|
} catch (error) {
|
|
2082
1973
|
const message = error instanceof Error ? error.message : String(error);
|
|
2083
|
-
console.error(
|
|
1974
|
+
console.error(chalk.red("[Rayburst] Analysis failed:"), message);
|
|
2084
1975
|
} finally {
|
|
2085
1976
|
isAnalyzing = false;
|
|
2086
1977
|
}
|
|
@@ -2091,22 +1982,22 @@ var unpluginFactory = (options = {}) => {
|
|
|
2091
1982
|
// This hook is automatically called by Vite/Rollup when files change!
|
|
2092
1983
|
async watchChange(id, { event }) {
|
|
2093
1984
|
if (!enabled) return;
|
|
2094
|
-
console.log(
|
|
1985
|
+
console.log(chalk.gray(`[Rayburst] Raw file event: ${event} ${id}`));
|
|
2095
1986
|
if (!id.match(/\.(ts|tsx|js|jsx)$/)) {
|
|
2096
|
-
console.log(
|
|
1987
|
+
console.log(chalk.gray(`[Rayburst] Skipping (not TS/JS): ${id}`));
|
|
2097
1988
|
return;
|
|
2098
1989
|
}
|
|
2099
1990
|
if (id.includes("node_modules") || id.includes(".rayburst") || id.includes(".test.") || id.includes(".spec.")) {
|
|
2100
|
-
console.log(
|
|
1991
|
+
console.log(chalk.gray(`[Rayburst] Skipping (filtered): ${id}`));
|
|
2101
1992
|
return;
|
|
2102
1993
|
}
|
|
2103
|
-
console.log(
|
|
1994
|
+
console.log(chalk.yellow(`[Rayburst] Accepted file ${event}: ${id}`));
|
|
2104
1995
|
if (debounceTimer) {
|
|
2105
1996
|
clearTimeout(debounceTimer);
|
|
2106
1997
|
}
|
|
2107
1998
|
debounceTimer = setTimeout(() => {
|
|
2108
1999
|
const relativePath = id.replace(config.root, "").replace(/^\//, "");
|
|
2109
|
-
console.log(
|
|
2000
|
+
console.log(chalk.dim(`[Rayburst] Triggering analysis after debounce for: ${relativePath}`));
|
|
2110
2001
|
runAnalysis(id);
|
|
2111
2002
|
}, debounceMs);
|
|
2112
2003
|
},
|
|
@@ -2122,18 +2013,18 @@ var unpluginFactory = (options = {}) => {
|
|
|
2122
2013
|
const projectPath = config.root;
|
|
2123
2014
|
await ensureRayburstDir(projectPath);
|
|
2124
2015
|
await addGitignoreEntry(projectPath);
|
|
2125
|
-
console.log(
|
|
2016
|
+
console.log(chalk.blue("[Rayburst] Starting code analysis..."));
|
|
2126
2017
|
await runAnalysis();
|
|
2127
2018
|
},
|
|
2128
2019
|
configureServer(server) {
|
|
2129
2020
|
if (!enabled) return;
|
|
2130
|
-
console.log(
|
|
2131
|
-
const gitHeadPath =
|
|
2021
|
+
console.log(chalk.blue("[Rayburst] Configuring git watcher..."));
|
|
2022
|
+
const gitHeadPath = path4.join(config.root, ".git", "HEAD");
|
|
2132
2023
|
if (fs3.existsSync(gitHeadPath)) {
|
|
2133
2024
|
server.watcher.add(gitHeadPath);
|
|
2134
2025
|
const handleGitChange = (changedPath) => {
|
|
2135
2026
|
if (changedPath === gitHeadPath || changedPath.includes(".git/refs/heads/")) {
|
|
2136
|
-
console.log(
|
|
2027
|
+
console.log(chalk.dim("[Rayburst] Git state changed, re-analyzing..."));
|
|
2137
2028
|
runAnalysis("git-event");
|
|
2138
2029
|
}
|
|
2139
2030
|
};
|
|
@@ -2141,7 +2032,7 @@ var unpluginFactory = (options = {}) => {
|
|
|
2141
2032
|
checkGitState(config.root);
|
|
2142
2033
|
gitPollInterval = setInterval(() => {
|
|
2143
2034
|
if (checkGitState(config.root)) {
|
|
2144
|
-
console.log(
|
|
2035
|
+
console.log(chalk.dim("[Rayburst] Git state changed (poll), re-analyzing..."));
|
|
2145
2036
|
runAnalysis("git-poll");
|
|
2146
2037
|
}
|
|
2147
2038
|
}, 5e3);
|
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.4.
|
|
3
|
+
"version": "0.4.14",
|
|
4
4
|
"description": "Rayburst - Automatic code analysis for TypeScript/JavaScript projects via Vite plugin",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"zod": "^4.2.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@rayburst/types": "^0.1.
|
|
52
|
+
"@rayburst/types": "^0.1.11",
|
|
53
53
|
"@types/node": "^25.0.2",
|
|
54
54
|
"tsup": "^8.5.1",
|
|
55
55
|
"typescript": "^5.9.3",
|