@rayburst/cli 0.4.12 → 0.4.13
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-CQMSZCXH.js} +23 -241
- package/dist/index.js +1 -1
- package/dist/vite-plugin.js +1 -1
- package/package.json +2 -2
|
@@ -437,15 +437,15 @@ function createRouterDecisionNode(sourceFilePath, gitHash, routeCount) {
|
|
|
437
437
|
};
|
|
438
438
|
}
|
|
439
439
|
function extractRoutePathFromFile(routeFilePath) {
|
|
440
|
-
let
|
|
441
|
-
if (
|
|
440
|
+
let path5 = routeFilePath.replace(/^src\/routes\//, "/").replace(/\.(tsx?|jsx?)$/, "").replace(/\/route$/, "").replace(/\/index$/, "");
|
|
441
|
+
if (path5 === "/__root") {
|
|
442
442
|
return "/";
|
|
443
443
|
}
|
|
444
|
-
|
|
445
|
-
if (
|
|
444
|
+
path5 = path5.replace(/\/\$([^/]+)/g, (_, param) => `/:${param}`);
|
|
445
|
+
if (path5 === "" || path5 === "/") {
|
|
446
446
|
return "/";
|
|
447
447
|
}
|
|
448
|
-
return
|
|
448
|
+
return path5;
|
|
449
449
|
}
|
|
450
450
|
function createConfigBasedEdges(sourceNode, targetFilePaths, nodeMap, edges, edgeType = "config", useRoutePathLabels = false) {
|
|
451
451
|
let edgesCreated = 0;
|
|
@@ -1794,192 +1794,10 @@ function generateProjectId(projectPath) {
|
|
|
1794
1794
|
return `${baseName}-${timestamp}`;
|
|
1795
1795
|
}
|
|
1796
1796
|
|
|
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
1797
|
// src/vite-plugin.ts
|
|
1980
|
-
import
|
|
1798
|
+
import chalk from "chalk";
|
|
1981
1799
|
import * as fs3 from "fs";
|
|
1982
|
-
import * as
|
|
1800
|
+
import * as path4 from "path";
|
|
1983
1801
|
var unpluginFactory = (options = {}) => {
|
|
1984
1802
|
const {
|
|
1985
1803
|
enabled = process.env.CI !== "true",
|
|
@@ -1993,11 +1811,11 @@ var unpluginFactory = (options = {}) => {
|
|
|
1993
1811
|
let gitPollInterval = null;
|
|
1994
1812
|
const checkGitState = (projectPath) => {
|
|
1995
1813
|
try {
|
|
1996
|
-
const gitDir =
|
|
1814
|
+
const gitDir = path4.join(projectPath, ".git");
|
|
1997
1815
|
if (!fs3.existsSync(gitDir)) {
|
|
1998
1816
|
return false;
|
|
1999
1817
|
}
|
|
2000
|
-
const headPath =
|
|
1818
|
+
const headPath = path4.join(gitDir, "HEAD");
|
|
2001
1819
|
if (!fs3.existsSync(headPath)) {
|
|
2002
1820
|
return false;
|
|
2003
1821
|
}
|
|
@@ -2005,7 +1823,7 @@ var unpluginFactory = (options = {}) => {
|
|
|
2005
1823
|
let gitState = headContent;
|
|
2006
1824
|
if (headContent.startsWith("ref: ")) {
|
|
2007
1825
|
const refPath = headContent.substring(5);
|
|
2008
|
-
const fullRefPath =
|
|
1826
|
+
const fullRefPath = path4.join(gitDir, refPath);
|
|
2009
1827
|
if (fs3.existsSync(fullRefPath)) {
|
|
2010
1828
|
const refContent = fs3.readFileSync(fullRefPath, "utf-8").trim();
|
|
2011
1829
|
gitState = `${headContent}:${refContent}`;
|
|
@@ -2031,56 +1849,20 @@ var unpluginFactory = (options = {}) => {
|
|
|
2031
1849
|
const projectPath = config.root;
|
|
2032
1850
|
const previousAnalysis = await readLocalAnalysis(projectPath);
|
|
2033
1851
|
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
1852
|
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
|
-
}
|
|
1853
|
+
console.log(chalk.green("[Rayburst] Analysis updated"));
|
|
2072
1854
|
} else {
|
|
2073
1855
|
const firstBranch = Object.keys(newAnalysis.planData)[0];
|
|
2074
1856
|
const nodeCount = firstBranch ? newAnalysis.planData[firstBranch].nodes.length : 0;
|
|
2075
1857
|
const edgeCount = firstBranch ? newAnalysis.planData[firstBranch].edges.length : 0;
|
|
2076
1858
|
console.log(
|
|
2077
|
-
|
|
1859
|
+
chalk.green(`[Rayburst] Initial analysis complete: ${nodeCount} nodes, ${edgeCount} edges`)
|
|
2078
1860
|
);
|
|
2079
1861
|
}
|
|
2080
1862
|
await writeLocalAnalysis(projectPath, newAnalysis);
|
|
2081
1863
|
} catch (error) {
|
|
2082
1864
|
const message = error instanceof Error ? error.message : String(error);
|
|
2083
|
-
console.error(
|
|
1865
|
+
console.error(chalk.red("[Rayburst] Analysis failed:"), message);
|
|
2084
1866
|
} finally {
|
|
2085
1867
|
isAnalyzing = false;
|
|
2086
1868
|
}
|
|
@@ -2091,22 +1873,22 @@ var unpluginFactory = (options = {}) => {
|
|
|
2091
1873
|
// This hook is automatically called by Vite/Rollup when files change!
|
|
2092
1874
|
async watchChange(id, { event }) {
|
|
2093
1875
|
if (!enabled) return;
|
|
2094
|
-
console.log(
|
|
1876
|
+
console.log(chalk.gray(`[Rayburst] Raw file event: ${event} ${id}`));
|
|
2095
1877
|
if (!id.match(/\.(ts|tsx|js|jsx)$/)) {
|
|
2096
|
-
console.log(
|
|
1878
|
+
console.log(chalk.gray(`[Rayburst] Skipping (not TS/JS): ${id}`));
|
|
2097
1879
|
return;
|
|
2098
1880
|
}
|
|
2099
1881
|
if (id.includes("node_modules") || id.includes(".rayburst") || id.includes(".test.") || id.includes(".spec.")) {
|
|
2100
|
-
console.log(
|
|
1882
|
+
console.log(chalk.gray(`[Rayburst] Skipping (filtered): ${id}`));
|
|
2101
1883
|
return;
|
|
2102
1884
|
}
|
|
2103
|
-
console.log(
|
|
1885
|
+
console.log(chalk.yellow(`[Rayburst] Accepted file ${event}: ${id}`));
|
|
2104
1886
|
if (debounceTimer) {
|
|
2105
1887
|
clearTimeout(debounceTimer);
|
|
2106
1888
|
}
|
|
2107
1889
|
debounceTimer = setTimeout(() => {
|
|
2108
1890
|
const relativePath = id.replace(config.root, "").replace(/^\//, "");
|
|
2109
|
-
console.log(
|
|
1891
|
+
console.log(chalk.dim(`[Rayburst] Triggering analysis after debounce for: ${relativePath}`));
|
|
2110
1892
|
runAnalysis(id);
|
|
2111
1893
|
}, debounceMs);
|
|
2112
1894
|
},
|
|
@@ -2122,18 +1904,18 @@ var unpluginFactory = (options = {}) => {
|
|
|
2122
1904
|
const projectPath = config.root;
|
|
2123
1905
|
await ensureRayburstDir(projectPath);
|
|
2124
1906
|
await addGitignoreEntry(projectPath);
|
|
2125
|
-
console.log(
|
|
1907
|
+
console.log(chalk.blue("[Rayburst] Starting code analysis..."));
|
|
2126
1908
|
await runAnalysis();
|
|
2127
1909
|
},
|
|
2128
1910
|
configureServer(server) {
|
|
2129
1911
|
if (!enabled) return;
|
|
2130
|
-
console.log(
|
|
2131
|
-
const gitHeadPath =
|
|
1912
|
+
console.log(chalk.blue("[Rayburst] Configuring git watcher..."));
|
|
1913
|
+
const gitHeadPath = path4.join(config.root, ".git", "HEAD");
|
|
2132
1914
|
if (fs3.existsSync(gitHeadPath)) {
|
|
2133
1915
|
server.watcher.add(gitHeadPath);
|
|
2134
1916
|
const handleGitChange = (changedPath) => {
|
|
2135
1917
|
if (changedPath === gitHeadPath || changedPath.includes(".git/refs/heads/")) {
|
|
2136
|
-
console.log(
|
|
1918
|
+
console.log(chalk.dim("[Rayburst] Git state changed, re-analyzing..."));
|
|
2137
1919
|
runAnalysis("git-event");
|
|
2138
1920
|
}
|
|
2139
1921
|
};
|
|
@@ -2141,7 +1923,7 @@ var unpluginFactory = (options = {}) => {
|
|
|
2141
1923
|
checkGitState(config.root);
|
|
2142
1924
|
gitPollInterval = setInterval(() => {
|
|
2143
1925
|
if (checkGitState(config.root)) {
|
|
2144
|
-
console.log(
|
|
1926
|
+
console.log(chalk.dim("[Rayburst] Git state changed (poll), re-analyzing..."));
|
|
2145
1927
|
runAnalysis("git-poll");
|
|
2146
1928
|
}
|
|
2147
1929
|
}, 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.13",
|
|
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.10",
|
|
53
53
|
"@types/node": "^25.0.2",
|
|
54
54
|
"tsup": "^8.5.1",
|
|
55
55
|
"typescript": "^5.9.3",
|