@rayburst/cli 0.4.11 → 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-DWQK6WKX.js → chunk-CQMSZCXH.js} +82 -320
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -1
- package/dist/vite-plugin.d.ts +5 -3
- package/dist/vite-plugin.js +7 -3
- package/package.json +3 -3
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
// src/vite-plugin.ts
|
|
2
|
+
import { createUnplugin } from "unplugin";
|
|
3
|
+
|
|
1
4
|
// src/analysis/analyze-project.ts
|
|
2
5
|
import { Project, SyntaxKind, Node } from "ts-morph";
|
|
3
6
|
import { execSync as execSync2 } from "child_process";
|
|
@@ -434,15 +437,15 @@ function createRouterDecisionNode(sourceFilePath, gitHash, routeCount) {
|
|
|
434
437
|
};
|
|
435
438
|
}
|
|
436
439
|
function extractRoutePathFromFile(routeFilePath) {
|
|
437
|
-
let
|
|
438
|
-
if (
|
|
440
|
+
let path5 = routeFilePath.replace(/^src\/routes\//, "/").replace(/\.(tsx?|jsx?)$/, "").replace(/\/route$/, "").replace(/\/index$/, "");
|
|
441
|
+
if (path5 === "/__root") {
|
|
439
442
|
return "/";
|
|
440
443
|
}
|
|
441
|
-
|
|
442
|
-
if (
|
|
444
|
+
path5 = path5.replace(/\/\$([^/]+)/g, (_, param) => `/:${param}`);
|
|
445
|
+
if (path5 === "" || path5 === "/") {
|
|
443
446
|
return "/";
|
|
444
447
|
}
|
|
445
|
-
return
|
|
448
|
+
return path5;
|
|
446
449
|
}
|
|
447
450
|
function createConfigBasedEdges(sourceNode, targetFilePaths, nodeMap, edges, edgeType = "config", useRoutePathLabels = false) {
|
|
448
451
|
let edgesCreated = 0;
|
|
@@ -1791,194 +1794,11 @@ function generateProjectId(projectPath) {
|
|
|
1791
1794
|
return `${baseName}-${timestamp}`;
|
|
1792
1795
|
}
|
|
1793
1796
|
|
|
1794
|
-
// src/registry.ts
|
|
1795
|
-
import path4 from "path";
|
|
1796
|
-
import { fileURLToPath } from "url";
|
|
1797
|
-
import os from "os";
|
|
1798
|
-
var __filename = fileURLToPath(import.meta.url);
|
|
1799
|
-
var __dirname = path4.dirname(__filename);
|
|
1800
|
-
var RAYBURST_DIR = path4.join(os.homedir(), ".rayburst");
|
|
1801
|
-
var PROJECTS_FILE = path4.join(RAYBURST_DIR, "projects.json");
|
|
1802
|
-
var ANALYZED_DIR = path4.join(RAYBURST_DIR, "analyzed");
|
|
1803
|
-
|
|
1804
|
-
// src/incremental-analyzer.ts
|
|
1805
|
-
import chalk from "chalk";
|
|
1806
|
-
function generateDiff(oldAnalysis, newAnalysis) {
|
|
1807
|
-
const update = {
|
|
1808
|
-
added: {
|
|
1809
|
-
nodes: [],
|
|
1810
|
-
edges: []
|
|
1811
|
-
},
|
|
1812
|
-
removed: {
|
|
1813
|
-
nodeIds: [],
|
|
1814
|
-
edgeIds: []
|
|
1815
|
-
},
|
|
1816
|
-
modified: {
|
|
1817
|
-
nodes: [],
|
|
1818
|
-
edges: []
|
|
1819
|
-
}
|
|
1820
|
-
};
|
|
1821
|
-
const branches = /* @__PURE__ */ new Set([
|
|
1822
|
-
...Object.keys(oldAnalysis.planData || {}),
|
|
1823
|
-
...Object.keys(newAnalysis.planData || {})
|
|
1824
|
-
]);
|
|
1825
|
-
for (const branchId of branches) {
|
|
1826
|
-
const oldPlanData = oldAnalysis.planData?.[branchId];
|
|
1827
|
-
const newPlanData = newAnalysis.planData?.[branchId];
|
|
1828
|
-
if (!oldPlanData && newPlanData) {
|
|
1829
|
-
update.added.nodes.push(...newPlanData.nodes || []);
|
|
1830
|
-
update.added.edges.push(...newPlanData.edges || []);
|
|
1831
|
-
continue;
|
|
1832
|
-
}
|
|
1833
|
-
if (oldPlanData && !newPlanData) {
|
|
1834
|
-
update.removed.nodeIds.push(...(oldPlanData.nodes || []).map((n) => n.id));
|
|
1835
|
-
update.removed.edgeIds.push(...(oldPlanData.edges || []).map((e) => e.id));
|
|
1836
|
-
continue;
|
|
1837
|
-
}
|
|
1838
|
-
const branchDiff = comparePlanData(oldPlanData, newPlanData);
|
|
1839
|
-
update.added.nodes.push(...branchDiff.added.nodes);
|
|
1840
|
-
update.added.edges.push(...branchDiff.added.edges);
|
|
1841
|
-
update.removed.nodeIds.push(...branchDiff.removed.nodeIds);
|
|
1842
|
-
update.removed.edgeIds.push(...branchDiff.removed.edgeIds);
|
|
1843
|
-
update.modified.nodes.push(...branchDiff.modified.nodes);
|
|
1844
|
-
update.modified.edges.push(...branchDiff.modified.edges);
|
|
1845
|
-
}
|
|
1846
|
-
return update;
|
|
1847
|
-
}
|
|
1848
|
-
function comparePlanData(oldPlanData, newPlanData) {
|
|
1849
|
-
const oldNodes = oldPlanData?.nodes || [];
|
|
1850
|
-
const newNodes = newPlanData?.nodes || [];
|
|
1851
|
-
const oldEdges = oldPlanData?.edges || [];
|
|
1852
|
-
const newEdges = newPlanData?.edges || [];
|
|
1853
|
-
const oldNodeMap = new Map(oldNodes.map((n) => [n.id, n]));
|
|
1854
|
-
const newNodeMap = new Map(newNodes.map((n) => [n.id, n]));
|
|
1855
|
-
const oldEdgeMap = new Map(oldEdges.map((e) => [e.id, e]));
|
|
1856
|
-
const newEdgeMap = new Map(newEdges.map((e) => [e.id, e]));
|
|
1857
|
-
const diff = {
|
|
1858
|
-
added: { nodes: [], edges: [] },
|
|
1859
|
-
removed: { nodeIds: [], edgeIds: [] },
|
|
1860
|
-
modified: { nodes: [], edges: [] }
|
|
1861
|
-
};
|
|
1862
|
-
for (const [nodeId, newNode] of newNodeMap) {
|
|
1863
|
-
const oldNode = oldNodeMap.get(nodeId);
|
|
1864
|
-
if (!oldNode) {
|
|
1865
|
-
diff.added.nodes.push(newNode);
|
|
1866
|
-
} else if (hasNodeChanged(oldNode, newNode)) {
|
|
1867
|
-
diff.modified.nodes.push({
|
|
1868
|
-
id: nodeId,
|
|
1869
|
-
...getNodeChanges(oldNode, newNode)
|
|
1870
|
-
});
|
|
1871
|
-
}
|
|
1872
|
-
}
|
|
1873
|
-
for (const nodeId of oldNodeMap.keys()) {
|
|
1874
|
-
if (!newNodeMap.has(nodeId)) {
|
|
1875
|
-
diff.removed.nodeIds.push(nodeId);
|
|
1876
|
-
}
|
|
1877
|
-
}
|
|
1878
|
-
for (const [edgeId, newEdge] of newEdgeMap) {
|
|
1879
|
-
const oldEdge = oldEdgeMap.get(edgeId);
|
|
1880
|
-
if (!oldEdge) {
|
|
1881
|
-
diff.added.edges.push(newEdge);
|
|
1882
|
-
} else if (hasEdgeChanged(oldEdge, newEdge)) {
|
|
1883
|
-
diff.modified.edges.push({
|
|
1884
|
-
id: edgeId,
|
|
1885
|
-
...getEdgeChanges(oldEdge, newEdge)
|
|
1886
|
-
});
|
|
1887
|
-
}
|
|
1888
|
-
}
|
|
1889
|
-
for (const edgeId of oldEdgeMap.keys()) {
|
|
1890
|
-
if (!newEdgeMap.has(edgeId)) {
|
|
1891
|
-
diff.removed.edgeIds.push(edgeId);
|
|
1892
|
-
}
|
|
1893
|
-
}
|
|
1894
|
-
return diff;
|
|
1895
|
-
}
|
|
1896
|
-
function hasNodeChanged(oldNode, newNode) {
|
|
1897
|
-
const oldData = JSON.stringify({ ...oldNode.data, type: oldNode.type });
|
|
1898
|
-
const newData = JSON.stringify({ ...newNode.data, type: newNode.type });
|
|
1899
|
-
return oldData !== newData;
|
|
1900
|
-
}
|
|
1901
|
-
function getNodeChanges(oldNode, newNode) {
|
|
1902
|
-
const changes = {};
|
|
1903
|
-
if (oldNode.type !== newNode.type) {
|
|
1904
|
-
changes.type = newNode.type;
|
|
1905
|
-
}
|
|
1906
|
-
if (JSON.stringify(oldNode.data) !== JSON.stringify(newNode.data)) {
|
|
1907
|
-
changes.data = newNode.data;
|
|
1908
|
-
}
|
|
1909
|
-
return changes;
|
|
1910
|
-
}
|
|
1911
|
-
function hasEdgeChanged(oldEdge, newEdge) {
|
|
1912
|
-
return oldEdge.source !== newEdge.source || oldEdge.target !== newEdge.target || oldEdge.type !== newEdge.type || JSON.stringify(oldEdge.data) !== JSON.stringify(newEdge.data);
|
|
1913
|
-
}
|
|
1914
|
-
function getEdgeChanges(oldEdge, newEdge) {
|
|
1915
|
-
const changes = {};
|
|
1916
|
-
if (oldEdge.source !== newEdge.source) changes.source = newEdge.source;
|
|
1917
|
-
if (oldEdge.target !== newEdge.target) changes.target = newEdge.target;
|
|
1918
|
-
if (oldEdge.type !== newEdge.type) changes.type = newEdge.type;
|
|
1919
|
-
if (JSON.stringify(oldEdge.data) !== JSON.stringify(newEdge.data)) {
|
|
1920
|
-
changes.data = newEdge.data;
|
|
1921
|
-
}
|
|
1922
|
-
return changes;
|
|
1923
|
-
}
|
|
1924
|
-
function generateChangeHistoryEntry(diff, trigger, gitCommitHash, newPlanData) {
|
|
1925
|
-
const timestamp = Date.now();
|
|
1926
|
-
const analysisRunId = `${timestamp}-${Math.random().toString(36).substring(7)}`;
|
|
1927
|
-
const nodeChanges = [];
|
|
1928
|
-
for (const node of diff.added.nodes) {
|
|
1929
|
-
const filePath = node.id.split("::")[0] || "unknown";
|
|
1930
|
-
nodeChanges.push({
|
|
1931
|
-
timestamp,
|
|
1932
|
-
nodeId: node.id,
|
|
1933
|
-
changeType: "added",
|
|
1934
|
-
changedFields: void 0,
|
|
1935
|
-
previousState: void 0,
|
|
1936
|
-
currentState: node,
|
|
1937
|
-
filePath
|
|
1938
|
-
});
|
|
1939
|
-
}
|
|
1940
|
-
for (const nodeId of diff.removed.nodeIds) {
|
|
1941
|
-
const filePath = nodeId.split("::")[0] || "unknown";
|
|
1942
|
-
nodeChanges.push({
|
|
1943
|
-
timestamp,
|
|
1944
|
-
nodeId,
|
|
1945
|
-
changeType: "removed",
|
|
1946
|
-
changedFields: void 0,
|
|
1947
|
-
previousState: void 0,
|
|
1948
|
-
// We don't have the previous state in current diff
|
|
1949
|
-
currentState: void 0,
|
|
1950
|
-
filePath
|
|
1951
|
-
});
|
|
1952
|
-
}
|
|
1953
|
-
for (const modifiedNode of diff.modified.nodes) {
|
|
1954
|
-
const filePath = modifiedNode.id.split("::")[0] || "unknown";
|
|
1955
|
-
const changedFields = Object.keys(modifiedNode.changes || {});
|
|
1956
|
-
nodeChanges.push({
|
|
1957
|
-
timestamp,
|
|
1958
|
-
nodeId: modifiedNode.id,
|
|
1959
|
-
changeType: "modified",
|
|
1960
|
-
changedFields: changedFields.length > 0 ? changedFields : void 0,
|
|
1961
|
-
previousState: void 0,
|
|
1962
|
-
// Would need old plan data to populate
|
|
1963
|
-
currentState: newPlanData.nodes.find((n) => n.id === modifiedNode.id),
|
|
1964
|
-
filePath
|
|
1965
|
-
});
|
|
1966
|
-
}
|
|
1967
|
-
return {
|
|
1968
|
-
timestamp,
|
|
1969
|
-
analysisRunId,
|
|
1970
|
-
trigger,
|
|
1971
|
-
nodeChanges,
|
|
1972
|
-
gitCommitHash
|
|
1973
|
-
};
|
|
1974
|
-
}
|
|
1975
|
-
|
|
1976
1797
|
// src/vite-plugin.ts
|
|
1977
|
-
import
|
|
1798
|
+
import chalk from "chalk";
|
|
1978
1799
|
import * as fs3 from "fs";
|
|
1979
|
-
import * as
|
|
1980
|
-
|
|
1981
|
-
function rayburstPlugin(options = {}) {
|
|
1800
|
+
import * as path4 from "path";
|
|
1801
|
+
var unpluginFactory = (options = {}) => {
|
|
1982
1802
|
const {
|
|
1983
1803
|
enabled = process.env.CI !== "true",
|
|
1984
1804
|
// Disabled in CI by default
|
|
@@ -1989,14 +1809,13 @@ function rayburstPlugin(options = {}) {
|
|
|
1989
1809
|
let isAnalyzing = false;
|
|
1990
1810
|
let lastGitState = null;
|
|
1991
1811
|
let gitPollInterval = null;
|
|
1992
|
-
let fileWatcher = null;
|
|
1993
1812
|
const checkGitState = (projectPath) => {
|
|
1994
1813
|
try {
|
|
1995
|
-
const gitDir =
|
|
1814
|
+
const gitDir = path4.join(projectPath, ".git");
|
|
1996
1815
|
if (!fs3.existsSync(gitDir)) {
|
|
1997
1816
|
return false;
|
|
1998
1817
|
}
|
|
1999
|
-
const headPath =
|
|
1818
|
+
const headPath = path4.join(gitDir, "HEAD");
|
|
2000
1819
|
if (!fs3.existsSync(headPath)) {
|
|
2001
1820
|
return false;
|
|
2002
1821
|
}
|
|
@@ -2004,7 +1823,7 @@ function rayburstPlugin(options = {}) {
|
|
|
2004
1823
|
let gitState = headContent;
|
|
2005
1824
|
if (headContent.startsWith("ref: ")) {
|
|
2006
1825
|
const refPath = headContent.substring(5);
|
|
2007
|
-
const fullRefPath =
|
|
1826
|
+
const fullRefPath = path4.join(gitDir, refPath);
|
|
2008
1827
|
if (fs3.existsSync(fullRefPath)) {
|
|
2009
1828
|
const refContent = fs3.readFileSync(fullRefPath, "utf-8").trim();
|
|
2010
1829
|
gitState = `${headContent}:${refContent}`;
|
|
@@ -2030,159 +1849,100 @@ function rayburstPlugin(options = {}) {
|
|
|
2030
1849
|
const projectPath = config.root;
|
|
2031
1850
|
const previousAnalysis = await readLocalAnalysis(projectPath);
|
|
2032
1851
|
const newAnalysis = await analyzeProject(projectPath);
|
|
2033
|
-
const branches = Object.keys(newAnalysis.planData);
|
|
2034
|
-
if (!newAnalysis.changeHistory && branches.length > 0) {
|
|
2035
|
-
newAnalysis.changeHistory = {};
|
|
2036
|
-
for (const branchId of branches) {
|
|
2037
|
-
newAnalysis.changeHistory[branchId] = [];
|
|
2038
|
-
}
|
|
2039
|
-
}
|
|
2040
1852
|
if (previousAnalysis) {
|
|
2041
|
-
|
|
2042
|
-
if (diff.added.nodes.length > 0 || diff.removed.nodeIds.length > 0 || diff.modified.nodes.length > 0) {
|
|
2043
|
-
const trigger = triggerFile === "git-event" || triggerFile === "git-poll" ? "git-commit" : "file-change";
|
|
2044
|
-
const firstBranch = Object.keys(newAnalysis.planData)[0];
|
|
2045
|
-
if (firstBranch) {
|
|
2046
|
-
const planData = newAnalysis.planData[firstBranch];
|
|
2047
|
-
const historyEntry = generateChangeHistoryEntry(diff, trigger, void 0, planData);
|
|
2048
|
-
const existingHistory = previousAnalysis.changeHistory?.[firstBranch] || [];
|
|
2049
|
-
const maxHistoryEntries = 100;
|
|
2050
|
-
const updatedHistory = [...existingHistory, historyEntry].slice(-maxHistoryEntries);
|
|
2051
|
-
newAnalysis.changeHistory = {
|
|
2052
|
-
...newAnalysis.changeHistory,
|
|
2053
|
-
[firstBranch]: updatedHistory
|
|
2054
|
-
};
|
|
2055
|
-
}
|
|
2056
|
-
}
|
|
2057
|
-
console.log(chalk2.green("[Rayburst] Analysis updated:"));
|
|
2058
|
-
console.log(
|
|
2059
|
-
chalk2.gray(
|
|
2060
|
-
` Added: ${diff.added.nodes.length} nodes, ${diff.added.edges.length} edges`
|
|
2061
|
-
)
|
|
2062
|
-
);
|
|
2063
|
-
console.log(
|
|
2064
|
-
chalk2.gray(
|
|
2065
|
-
` Removed: ${diff.removed.nodeIds.length} nodes, ${diff.removed.edgeIds.length} edges`
|
|
2066
|
-
)
|
|
2067
|
-
);
|
|
2068
|
-
if (diff.modified.nodes.length > 0) {
|
|
2069
|
-
console.log(chalk2.gray(` Modified: ${diff.modified.nodes.length} nodes`));
|
|
2070
|
-
}
|
|
1853
|
+
console.log(chalk.green("[Rayburst] Analysis updated"));
|
|
2071
1854
|
} else {
|
|
2072
1855
|
const firstBranch = Object.keys(newAnalysis.planData)[0];
|
|
2073
1856
|
const nodeCount = firstBranch ? newAnalysis.planData[firstBranch].nodes.length : 0;
|
|
2074
1857
|
const edgeCount = firstBranch ? newAnalysis.planData[firstBranch].edges.length : 0;
|
|
2075
1858
|
console.log(
|
|
2076
|
-
|
|
1859
|
+
chalk.green(`[Rayburst] Initial analysis complete: ${nodeCount} nodes, ${edgeCount} edges`)
|
|
2077
1860
|
);
|
|
2078
1861
|
}
|
|
2079
1862
|
await writeLocalAnalysis(projectPath, newAnalysis);
|
|
2080
1863
|
} catch (error) {
|
|
2081
1864
|
const message = error instanceof Error ? error.message : String(error);
|
|
2082
|
-
console.error(
|
|
1865
|
+
console.error(chalk.red("[Rayburst] Analysis failed:"), message);
|
|
2083
1866
|
} finally {
|
|
2084
1867
|
isAnalyzing = false;
|
|
2085
1868
|
}
|
|
2086
1869
|
};
|
|
2087
1870
|
return {
|
|
2088
1871
|
name: "rayburst-analyzer",
|
|
2089
|
-
|
|
2090
|
-
|
|
2091
|
-
|
|
2092
|
-
|
|
2093
|
-
|
|
2094
|
-
|
|
2095
|
-
|
|
1872
|
+
enforce: "pre",
|
|
1873
|
+
// This hook is automatically called by Vite/Rollup when files change!
|
|
1874
|
+
async watchChange(id, { event }) {
|
|
1875
|
+
if (!enabled) return;
|
|
1876
|
+
console.log(chalk.gray(`[Rayburst] Raw file event: ${event} ${id}`));
|
|
1877
|
+
if (!id.match(/\.(ts|tsx|js|jsx)$/)) {
|
|
1878
|
+
console.log(chalk.gray(`[Rayburst] Skipping (not TS/JS): ${id}`));
|
|
2096
1879
|
return;
|
|
2097
1880
|
}
|
|
2098
|
-
|
|
2099
|
-
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
1881
|
+
if (id.includes("node_modules") || id.includes(".rayburst") || id.includes(".test.") || id.includes(".spec.")) {
|
|
1882
|
+
console.log(chalk.gray(`[Rayburst] Skipping (filtered): ${id}`));
|
|
1883
|
+
return;
|
|
1884
|
+
}
|
|
1885
|
+
console.log(chalk.yellow(`[Rayburst] Accepted file ${event}: ${id}`));
|
|
1886
|
+
if (debounceTimer) {
|
|
1887
|
+
clearTimeout(debounceTimer);
|
|
1888
|
+
}
|
|
1889
|
+
debounceTimer = setTimeout(() => {
|
|
1890
|
+
const relativePath = id.replace(config.root, "").replace(/^\//, "");
|
|
1891
|
+
console.log(chalk.dim(`[Rayburst] Triggering analysis after debounce for: ${relativePath}`));
|
|
1892
|
+
runAnalysis(id);
|
|
1893
|
+
}, debounceMs);
|
|
2103
1894
|
},
|
|
2104
|
-
//
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
if (!
|
|
2111
|
-
console.log(chalk2.gray(`[Rayburst] Skipping (not TS/JS): ${filePath}`));
|
|
2112
|
-
return;
|
|
2113
|
-
}
|
|
2114
|
-
if (filePath.includes("node_modules") || filePath.includes(".rayburst") || filePath.includes(".test.") || filePath.includes(".spec.")) {
|
|
2115
|
-
console.log(chalk2.gray(`[Rayburst] Skipping (filtered): ${filePath}`));
|
|
1895
|
+
// Vite-specific hooks
|
|
1896
|
+
vite: {
|
|
1897
|
+
configResolved(resolvedConfig) {
|
|
1898
|
+
config = resolvedConfig;
|
|
1899
|
+
},
|
|
1900
|
+
async buildStart() {
|
|
1901
|
+
if (!enabled || config.command !== "serve") {
|
|
2116
1902
|
return;
|
|
2117
1903
|
}
|
|
2118
|
-
|
|
2119
|
-
|
|
2120
|
-
|
|
1904
|
+
const projectPath = config.root;
|
|
1905
|
+
await ensureRayburstDir(projectPath);
|
|
1906
|
+
await addGitignoreEntry(projectPath);
|
|
1907
|
+
console.log(chalk.blue("[Rayburst] Starting code analysis..."));
|
|
1908
|
+
await runAnalysis();
|
|
1909
|
+
},
|
|
1910
|
+
configureServer(server) {
|
|
1911
|
+
if (!enabled) return;
|
|
1912
|
+
console.log(chalk.blue("[Rayburst] Configuring git watcher..."));
|
|
1913
|
+
const gitHeadPath = path4.join(config.root, ".git", "HEAD");
|
|
1914
|
+
if (fs3.existsSync(gitHeadPath)) {
|
|
1915
|
+
server.watcher.add(gitHeadPath);
|
|
1916
|
+
const handleGitChange = (changedPath) => {
|
|
1917
|
+
if (changedPath === gitHeadPath || changedPath.includes(".git/refs/heads/")) {
|
|
1918
|
+
console.log(chalk.dim("[Rayburst] Git state changed, re-analyzing..."));
|
|
1919
|
+
runAnalysis("git-event");
|
|
1920
|
+
}
|
|
1921
|
+
};
|
|
1922
|
+
server.watcher.on("change", handleGitChange);
|
|
1923
|
+
checkGitState(config.root);
|
|
1924
|
+
gitPollInterval = setInterval(() => {
|
|
1925
|
+
if (checkGitState(config.root)) {
|
|
1926
|
+
console.log(chalk.dim("[Rayburst] Git state changed (poll), re-analyzing..."));
|
|
1927
|
+
runAnalysis("git-poll");
|
|
1928
|
+
}
|
|
1929
|
+
}, 5e3);
|
|
2121
1930
|
}
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
|
|
2125
|
-
runAnalysis(filePath);
|
|
2126
|
-
}, debounceMs);
|
|
2127
|
-
};
|
|
2128
|
-
const srcPath = path5.join(config.root, "src");
|
|
2129
|
-
if (fs3.existsSync(srcPath)) {
|
|
2130
|
-
console.log(chalk2.blue("[Rayburst] Creating dedicated file watcher..."));
|
|
2131
|
-
fileWatcher = chokidar.watch(srcPath, {
|
|
2132
|
-
ignored: [
|
|
2133
|
-
"**/node_modules/**",
|
|
2134
|
-
"**/.rayburst/**",
|
|
2135
|
-
"**/*.test.*",
|
|
2136
|
-
"**/*.spec.*",
|
|
2137
|
-
"**/.git/**"
|
|
2138
|
-
],
|
|
2139
|
-
persistent: true,
|
|
2140
|
-
ignoreInitial: true,
|
|
2141
|
-
awaitWriteFinish: {
|
|
2142
|
-
stabilityThreshold: 100,
|
|
2143
|
-
pollInterval: 100
|
|
1931
|
+
return () => {
|
|
1932
|
+
if (debounceTimer) {
|
|
1933
|
+
clearTimeout(debounceTimer);
|
|
2144
1934
|
}
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
console.log(chalk2.green("[Rayburst] File watcher is ready and monitoring changes"));
|
|
2148
|
-
});
|
|
2149
|
-
fileWatcher.on("change", handleFileChange);
|
|
2150
|
-
fileWatcher.on("add", handleFileChange);
|
|
2151
|
-
fileWatcher.on("unlink", handleFileChange);
|
|
2152
|
-
console.log(chalk2.dim(`[Rayburst] Watching directory: ${srcPath}`));
|
|
2153
|
-
}
|
|
2154
|
-
const gitHeadPath = path5.join(config.root, ".git", "HEAD");
|
|
2155
|
-
if (fs3.existsSync(gitHeadPath)) {
|
|
2156
|
-
server.watcher.add(gitHeadPath);
|
|
2157
|
-
const handleGitChange = (changedPath) => {
|
|
2158
|
-
if (changedPath === gitHeadPath || changedPath.includes(".git/refs/heads/")) {
|
|
2159
|
-
console.log(chalk2.dim("[Rayburst] Git state changed, re-analyzing..."));
|
|
2160
|
-
runAnalysis("git-event");
|
|
1935
|
+
if (gitPollInterval) {
|
|
1936
|
+
clearInterval(gitPollInterval);
|
|
2161
1937
|
}
|
|
2162
1938
|
};
|
|
2163
|
-
server.watcher.on("change", handleGitChange);
|
|
2164
|
-
checkGitState(config.root);
|
|
2165
|
-
gitPollInterval = setInterval(() => {
|
|
2166
|
-
if (checkGitState(config.root)) {
|
|
2167
|
-
console.log(chalk2.dim("[Rayburst] Git state changed (poll), re-analyzing..."));
|
|
2168
|
-
runAnalysis("git-poll");
|
|
2169
|
-
}
|
|
2170
|
-
}, 5e3);
|
|
2171
1939
|
}
|
|
2172
|
-
return () => {
|
|
2173
|
-
if (fileWatcher) {
|
|
2174
|
-
fileWatcher.close();
|
|
2175
|
-
}
|
|
2176
|
-
if (debounceTimer) {
|
|
2177
|
-
clearTimeout(debounceTimer);
|
|
2178
|
-
}
|
|
2179
|
-
if (gitPollInterval) {
|
|
2180
|
-
clearInterval(gitPollInterval);
|
|
2181
|
-
}
|
|
2182
|
-
};
|
|
2183
1940
|
}
|
|
2184
1941
|
};
|
|
2185
|
-
}
|
|
1942
|
+
};
|
|
1943
|
+
var unplugin = createUnplugin(unpluginFactory);
|
|
1944
|
+
var rayburstPlugin = unplugin.vite;
|
|
1945
|
+
var vite_plugin_default = rayburstPlugin;
|
|
2186
1946
|
|
|
2187
1947
|
export {
|
|
2188
1948
|
analyzeProject,
|
|
@@ -2194,5 +1954,7 @@ export {
|
|
|
2194
1954
|
addGitignoreEntry,
|
|
2195
1955
|
isProjectInitialized,
|
|
2196
1956
|
initializeProject,
|
|
2197
|
-
|
|
1957
|
+
unpluginFactory,
|
|
1958
|
+
rayburstPlugin,
|
|
1959
|
+
vite_plugin_default
|
|
2198
1960
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
export { RayburstPluginOptions, rayburstPlugin } from './vite-plugin.js';
|
|
1
|
+
export { RayburstPluginOptions, default as rayburstPlugin } from './vite-plugin.js';
|
|
2
2
|
import { AnalysisResult } from '@rayburst/types';
|
|
3
3
|
export { AnalysisResult } from '@rayburst/types';
|
|
4
4
|
import 'vite';
|
|
5
|
+
import 'unplugin';
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* Analyze a TypeScript/React project and generate nodes/edges data
|
package/dist/index.js
CHANGED
package/dist/vite-plugin.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as vite from 'vite';
|
|
2
|
+
import { UnpluginFactory } from 'unplugin';
|
|
2
3
|
|
|
3
4
|
interface RayburstPluginOptions {
|
|
4
5
|
enabled?: boolean;
|
|
5
6
|
debounceMs?: number;
|
|
6
7
|
outputPath?: string;
|
|
7
8
|
}
|
|
8
|
-
declare
|
|
9
|
+
declare const unpluginFactory: UnpluginFactory<RayburstPluginOptions | undefined>;
|
|
10
|
+
declare const rayburstPlugin: (options?: RayburstPluginOptions) => vite.Plugin<any> | vite.Plugin<any>[];
|
|
9
11
|
|
|
10
|
-
export { type RayburstPluginOptions, rayburstPlugin };
|
|
12
|
+
export { type RayburstPluginOptions, rayburstPlugin as default, rayburstPlugin, unpluginFactory };
|
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",
|
|
@@ -44,12 +44,12 @@
|
|
|
44
44
|
"dependencies": {
|
|
45
45
|
"@rayburst/cli": "^0.4.9",
|
|
46
46
|
"chalk": "^5.3.0",
|
|
47
|
-
"chokidar": "^3.6.0",
|
|
48
47
|
"ts-morph": "^21.0.1",
|
|
48
|
+
"unplugin": "^1.16.1",
|
|
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",
|