@rayburst/cli 0.4.10 → 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,7 +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
- function rayburstPlugin(options = {}) {
1983
+ var unpluginFactory = (options = {}) => {
1981
1984
  const {
1982
1985
  enabled = process.env.CI !== "true",
1983
1986
  // Disabled in CI by default
@@ -2084,82 +2087,80 @@ function rayburstPlugin(options = {}) {
2084
2087
  };
2085
2088
  return {
2086
2089
  name: "rayburst-analyzer",
2087
- // Hook 1: Store resolved config
2088
- configResolved(resolvedConfig) {
2089
- config = resolvedConfig;
2090
- },
2091
- // Hook 2: Run initial analysis when dev server starts
2092
- async buildStart() {
2093
- 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}`));
2094
2097
  return;
2095
2098
  }
2096
- const projectPath = config.root;
2097
- await ensureRayburstDir(projectPath);
2098
- await addGitignoreEntry(projectPath);
2099
- console.log(chalk2.blue("[Rayburst] Starting code analysis..."));
2100
- 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);
2101
2112
  },
2102
- // Hook 3: Watch for changes using Vite's built-in watcher
2103
- configureServer(server) {
2104
- if (!enabled) return;
2105
- console.log(chalk2.blue("[Rayburst] Configuring file watcher..."));
2106
- const handleFileChange = (filePath) => {
2107
- console.log(chalk2.gray(`[Rayburst] Raw file event: ${filePath}`));
2108
- if (!filePath.match(/\.(ts|tsx|js|jsx)$/)) {
2109
- console.log(chalk2.gray(`[Rayburst] Skipping (not TS/JS): ${filePath}`));
2110
- return;
2111
- }
2112
- if (filePath.includes("node_modules") || filePath.includes(".rayburst") || filePath.includes(".test.") || filePath.includes(".spec.")) {
2113
- 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") {
2114
2120
  return;
2115
2121
  }
2116
- console.log(chalk2.yellow(`[Rayburst] Accepted file change: ${filePath}`));
2117
- if (debounceTimer) {
2118
- 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);
2119
2148
  }
2120
- debounceTimer = setTimeout(() => {
2121
- const relativePath = filePath.replace(config.root, "").replace(/^\//, "");
2122
- console.log(chalk2.dim(`[Rayburst] File changed (after debounce): ${relativePath}`));
2123
- runAnalysis(filePath);
2124
- }, debounceMs);
2125
- };
2126
- console.log(chalk2.blue("[Rayburst] Registering watcher event handlers..."));
2127
- server.watcher.on("change", handleFileChange);
2128
- server.watcher.on("add", handleFileChange);
2129
- server.watcher.on("unlink", handleFileChange);
2130
- console.log(chalk2.blue("[Rayburst] File watcher configured successfully"));
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");
2149
+ return () => {
2150
+ if (debounceTimer) {
2151
+ clearTimeout(debounceTimer);
2138
2152
  }
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");
2153
+ if (gitPollInterval) {
2154
+ clearInterval(gitPollInterval);
2146
2155
  }
2147
- }, 5e3);
2156
+ };
2148
2157
  }
2149
- return () => {
2150
- server.watcher.off("change", handleFileChange);
2151
- server.watcher.off("add", handleFileChange);
2152
- server.watcher.off("unlink", handleFileChange);
2153
- if (debounceTimer) {
2154
- clearTimeout(debounceTimer);
2155
- }
2156
- if (gitPollInterval) {
2157
- clearInterval(gitPollInterval);
2158
- }
2159
- };
2160
2158
  }
2161
2159
  };
2162
- }
2160
+ };
2161
+ var unplugin = createUnplugin(unpluginFactory);
2162
+ var rayburstPlugin = unplugin.vite;
2163
+ var vite_plugin_default = rayburstPlugin;
2163
2164
 
2164
2165
  export {
2165
2166
  analyzeProject,
@@ -2171,5 +2172,7 @@ export {
2171
2172
  addGitignoreEntry,
2172
2173
  isProjectInitialized,
2173
2174
  initializeProject,
2174
- rayburstPlugin
2175
+ unpluginFactory,
2176
+ rayburstPlugin,
2177
+ vite_plugin_default
2175
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-UCHCYCAU.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-UCHCYCAU.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.10",
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",
@@ -45,6 +45,7 @@
45
45
  "@rayburst/cli": "^0.4.9",
46
46
  "chalk": "^5.3.0",
47
47
  "ts-morph": "^21.0.1",
48
+ "unplugin": "^1.16.1",
48
49
  "zod": "^4.2.0"
49
50
  },
50
51
  "devDependencies": {