@rayburst/cli 0.4.11 → 0.4.12

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.
@@ -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";
@@ -1977,8 +1980,7 @@ function generateChangeHistoryEntry(diff, trigger, gitCommitHash, newPlanData) {
1977
1980
  import chalk2 from "chalk";
1978
1981
  import * as fs3 from "fs";
1979
1982
  import * as path5 from "path";
1980
- import chokidar from "chokidar";
1981
- function rayburstPlugin(options = {}) {
1983
+ var unpluginFactory = (options = {}) => {
1982
1984
  const {
1983
1985
  enabled = process.env.CI !== "true",
1984
1986
  // Disabled in CI by default
@@ -1989,7 +1991,6 @@ function rayburstPlugin(options = {}) {
1989
1991
  let isAnalyzing = false;
1990
1992
  let lastGitState = null;
1991
1993
  let gitPollInterval = null;
1992
- let fileWatcher = null;
1993
1994
  const checkGitState = (projectPath) => {
1994
1995
  try {
1995
1996
  const gitDir = path5.join(projectPath, ".git");
@@ -2086,103 +2087,80 @@ function rayburstPlugin(options = {}) {
2086
2087
  };
2087
2088
  return {
2088
2089
  name: "rayburst-analyzer",
2089
- // Hook 1: Store resolved config
2090
- configResolved(resolvedConfig) {
2091
- config = resolvedConfig;
2092
- },
2093
- // Hook 2: Run initial analysis when dev server starts
2094
- async buildStart() {
2095
- if (!enabled || config.command !== "serve") {
2090
+ enforce: "pre",
2091
+ // This hook is automatically called by Vite/Rollup when files change!
2092
+ async watchChange(id, { event }) {
2093
+ if (!enabled) return;
2094
+ console.log(chalk2.gray(`[Rayburst] Raw file event: ${event} ${id}`));
2095
+ if (!id.match(/\.(ts|tsx|js|jsx)$/)) {
2096
+ console.log(chalk2.gray(`[Rayburst] Skipping (not TS/JS): ${id}`));
2096
2097
  return;
2097
2098
  }
2098
- const projectPath = config.root;
2099
- await ensureRayburstDir(projectPath);
2100
- await addGitignoreEntry(projectPath);
2101
- console.log(chalk2.blue("[Rayburst] Starting code analysis..."));
2102
- await runAnalysis();
2099
+ if (id.includes("node_modules") || id.includes(".rayburst") || id.includes(".test.") || id.includes(".spec.")) {
2100
+ console.log(chalk2.gray(`[Rayburst] Skipping (filtered): ${id}`));
2101
+ return;
2102
+ }
2103
+ console.log(chalk2.yellow(`[Rayburst] Accepted file ${event}: ${id}`));
2104
+ if (debounceTimer) {
2105
+ clearTimeout(debounceTimer);
2106
+ }
2107
+ debounceTimer = setTimeout(() => {
2108
+ const relativePath = id.replace(config.root, "").replace(/^\//, "");
2109
+ console.log(chalk2.dim(`[Rayburst] Triggering analysis after debounce for: ${relativePath}`));
2110
+ runAnalysis(id);
2111
+ }, debounceMs);
2103
2112
  },
2104
- // Hook 3: Watch for changes using dedicated Chokidar watcher
2105
- configureServer(server) {
2106
- if (!enabled) return;
2107
- console.log(chalk2.blue("[Rayburst] Configuring file watcher..."));
2108
- const handleFileChange = (filePath) => {
2109
- console.log(chalk2.gray(`[Rayburst] Raw file event: ${filePath}`));
2110
- if (!filePath.match(/\.(ts|tsx|js|jsx)$/)) {
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}`));
2113
+ // Vite-specific hooks
2114
+ vite: {
2115
+ configResolved(resolvedConfig) {
2116
+ config = resolvedConfig;
2117
+ },
2118
+ async buildStart() {
2119
+ if (!enabled || config.command !== "serve") {
2116
2120
  return;
2117
2121
  }
2118
- console.log(chalk2.yellow(`[Rayburst] Accepted file change: ${filePath}`));
2119
- if (debounceTimer) {
2120
- clearTimeout(debounceTimer);
2122
+ const projectPath = config.root;
2123
+ await ensureRayburstDir(projectPath);
2124
+ await addGitignoreEntry(projectPath);
2125
+ console.log(chalk2.blue("[Rayburst] Starting code analysis..."));
2126
+ await runAnalysis();
2127
+ },
2128
+ configureServer(server) {
2129
+ if (!enabled) return;
2130
+ console.log(chalk2.blue("[Rayburst] Configuring git watcher..."));
2131
+ const gitHeadPath = path5.join(config.root, ".git", "HEAD");
2132
+ if (fs3.existsSync(gitHeadPath)) {
2133
+ server.watcher.add(gitHeadPath);
2134
+ const handleGitChange = (changedPath) => {
2135
+ if (changedPath === gitHeadPath || changedPath.includes(".git/refs/heads/")) {
2136
+ console.log(chalk2.dim("[Rayburst] Git state changed, re-analyzing..."));
2137
+ runAnalysis("git-event");
2138
+ }
2139
+ };
2140
+ server.watcher.on("change", handleGitChange);
2141
+ checkGitState(config.root);
2142
+ gitPollInterval = setInterval(() => {
2143
+ if (checkGitState(config.root)) {
2144
+ console.log(chalk2.dim("[Rayburst] Git state changed (poll), re-analyzing..."));
2145
+ runAnalysis("git-poll");
2146
+ }
2147
+ }, 5e3);
2121
2148
  }
2122
- debounceTimer = setTimeout(() => {
2123
- const relativePath = filePath.replace(config.root, "").replace(/^\//, "");
2124
- console.log(chalk2.dim(`[Rayburst] File changed (after debounce): ${relativePath}`));
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
2149
+ return () => {
2150
+ if (debounceTimer) {
2151
+ clearTimeout(debounceTimer);
2144
2152
  }
2145
- });
2146
- fileWatcher.on("ready", () => {
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");
2153
+ if (gitPollInterval) {
2154
+ clearInterval(gitPollInterval);
2161
2155
  }
2162
2156
  };
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
2157
  }
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
2158
  }
2184
2159
  };
2185
- }
2160
+ };
2161
+ var unplugin = createUnplugin(unpluginFactory);
2162
+ var rayburstPlugin = unplugin.vite;
2163
+ var vite_plugin_default = rayburstPlugin;
2186
2164
 
2187
2165
  export {
2188
2166
  analyzeProject,
@@ -2194,5 +2172,7 @@ export {
2194
2172
  addGitignoreEntry,
2195
2173
  isProjectInitialized,
2196
2174
  initializeProject,
2197
- rayburstPlugin
2175
+ unpluginFactory,
2176
+ rayburstPlugin,
2177
+ vite_plugin_default
2198
2178
  };
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
@@ -9,7 +9,7 @@ import {
9
9
  readLocalMeta,
10
10
  writeLocalAnalysis,
11
11
  writeLocalMeta
12
- } from "./chunk-DWQK6WKX.js";
12
+ } from "./chunk-ANVJHFHG.js";
13
13
  export {
14
14
  addGitignoreEntry,
15
15
  analyzeProject,
@@ -1,10 +1,12 @@
1
- import { Plugin } from 'vite';
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 function rayburstPlugin(options?: RayburstPluginOptions): Plugin;
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 };
@@ -1,6 +1,10 @@
1
1
  import {
2
- rayburstPlugin
3
- } from "./chunk-DWQK6WKX.js";
2
+ rayburstPlugin,
3
+ unpluginFactory,
4
+ vite_plugin_default
5
+ } from "./chunk-ANVJHFHG.js";
4
6
  export {
5
- rayburstPlugin
7
+ vite_plugin_default as default,
8
+ rayburstPlugin,
9
+ unpluginFactory
6
10
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rayburst/cli",
3
- "version": "0.4.11",
3
+ "version": "0.4.12",
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,8 +44,8 @@
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": {