@wtdlee/repomap 0.3.2 → 0.3.3

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,4 +1,4 @@
1
- import {a as a$2}from'./chunk-SL2GMDBN.js';import {a as a$3}from'./chunk-VV3A3UE3.js';import {e,d,c,b as b$2}from'./chunk-J2CM7T7U.js';import {a,b as b$1}from'./chunk-XWZH2RDG.js';import {a as a$1}from'./chunk-MOEA75XK.js';import {k}from'./chunk-UJT5KTVK.js';import {simpleGit}from'simple-git';import*as m from'fs/promises';import*as l from'path';import H from'fast-glob';import*as w from'crypto';import F from'express';import {Server}from'socket.io';import*as z from'http';import {marked}from'marked';import*as A from'net';var C="1.1",x=class{cacheDir;manifest;manifestPath;dirty=false;constructor(t){this.cacheDir=l.join(t,".repomap-cache"),this.manifestPath=l.join(this.cacheDir,"manifest.json"),this.manifest={version:C,entries:{}};}async init(){try{await m.mkdir(this.cacheDir,{recursive:!0});}catch(t){console.warn(` Warning: Could not create cache directory: ${t.message}`);return}try{let t=await m.readFile(this.manifestPath,"utf-8"),a=JSON.parse(t);a.version===C?this.manifest=a:(console.log(" Cache version mismatch, clearing cache..."),await this.clear());}catch{}}async computeFileHash(t){try{let a=await m.readFile(t,"utf-8");return w.createHash("md5").update(a).digest("hex")}catch{return ""}}async computeFilesHash(t){let a=[...t].sort(),e=50,n;a.length<=e*2?n=a:n=[...a.slice(0,e),...a.slice(-e)];let o=await Promise.all(n.map(i=>this.computeFileHash(i))),s=w.createHash("md5").update(String(a.length)).digest("hex");return w.createHash("md5").update(o.join("")+s).digest("hex")}get(t,a){let e=this.manifest.entries[t];return e&&e.hash===a?e.data:null}set(t,a,e){this.manifest.entries[t]={hash:a,timestamp:Date.now(),data:e},this.dirty=true;}async save(){if(this.dirty)try{await m.mkdir(this.cacheDir,{recursive:!0}),await m.writeFile(this.manifestPath,JSON.stringify(this.manifest,null,2)),this.dirty=!1;}catch(t){console.warn(" Warning: Failed to save cache:",t.message);}}async clear(){this.manifest={version:C,entries:{}},this.dirty=true;try{await m.rm(this.cacheDir,{recursive:!0,force:!0}),await m.mkdir(this.cacheDir,{recursive:!0});}catch{}}getStats(){let t=Object.keys(this.manifest.entries).length,a=JSON.stringify(this.manifest).length;return {entries:t,size:a>1024*1024?`${(a/1024/1024).toFixed(1)}MB`:`${(a/1024).toFixed(1)}KB`}}};var b=class{config;mermaidGenerator;markdownGenerator;noCache;constructor(t,a$1){this.config=t,this.mermaidGenerator=new a,this.markdownGenerator=new b$1,this.noCache=a$1?.noCache??false;}async generate(){console.log(`\u{1F680} Starting documentation generation...
1
+ import {a as a$2}from'./chunk-H4YGP3GL.js';import {a as a$3}from'./chunk-VV3A3UE3.js';import {e,d,c,b as b$2}from'./chunk-J2CM7T7U.js';import {a,b as b$1}from'./chunk-XWZH2RDG.js';import {a as a$1}from'./chunk-MOEA75XK.js';import {k}from'./chunk-PTR5IROV.js';import {simpleGit}from'simple-git';import*as m from'fs/promises';import*as l from'path';import H from'fast-glob';import*as w from'crypto';import F from'express';import {Server}from'socket.io';import*as z from'http';import {marked}from'marked';import*as A from'net';var C="1.1",x=class{cacheDir;manifest;manifestPath;dirty=false;constructor(t){this.cacheDir=l.join(t,".repomap-cache"),this.manifestPath=l.join(this.cacheDir,"manifest.json"),this.manifest={version:C,entries:{}};}async init(){try{await m.mkdir(this.cacheDir,{recursive:!0});}catch(t){console.warn(` Warning: Could not create cache directory: ${t.message}`);return}try{let t=await m.readFile(this.manifestPath,"utf-8"),a=JSON.parse(t);a.version===C?this.manifest=a:(console.log(" Cache version mismatch, clearing cache..."),await this.clear());}catch{}}async computeFileHash(t){try{let a=await m.readFile(t,"utf-8");return w.createHash("md5").update(a).digest("hex")}catch{return ""}}async computeFilesHash(t){let a=[...t].sort(),e=50,n;a.length<=e*2?n=a:n=[...a.slice(0,e),...a.slice(-e)];let o=await Promise.all(n.map(i=>this.computeFileHash(i))),s=w.createHash("md5").update(String(a.length)).digest("hex");return w.createHash("md5").update(o.join("")+s).digest("hex")}get(t,a){let e=this.manifest.entries[t];return e&&e.hash===a?e.data:null}set(t,a,e){this.manifest.entries[t]={hash:a,timestamp:Date.now(),data:e},this.dirty=true;}async save(){if(this.dirty)try{await m.mkdir(this.cacheDir,{recursive:!0}),await m.writeFile(this.manifestPath,JSON.stringify(this.manifest,null,2)),this.dirty=!1;}catch(t){console.warn(" Warning: Failed to save cache:",t.message);}}async clear(){this.manifest={version:C,entries:{}},this.dirty=true;try{await m.rm(this.cacheDir,{recursive:!0,force:!0}),await m.mkdir(this.cacheDir,{recursive:!0});}catch{}}getStats(){let t=Object.keys(this.manifest.entries).length,a=JSON.stringify(this.manifest).length;return {entries:t,size:a>1024*1024?`${(a/1024/1024).toFixed(1)}MB`:`${(a/1024).toFixed(1)}KB`}}};var b=class{config;mermaidGenerator;markdownGenerator;noCache;constructor(t,a$1){this.config=t,this.mermaidGenerator=new a,this.markdownGenerator=new b$1,this.noCache=a$1?.noCache??false;}async generate(){console.log(`\u{1F680} Starting documentation generation...
2
2
  `);let t=[];for(let i of this.config.repositories)try{console.log(`
3
3
  \u{1F4E6} Analyzing ${i.displayName}...`);let r=await this.analyzeRepository(i);t.push(r),console.log(`\u2705 Completed ${i.displayName}`);}catch(r){console.error(`\u274C Failed to analyze ${i.name}:`,r.message);}console.log(`
4
4
  \u{1F517} Running cross-repository analysis...`);let a=this.analyzeCrossRepo(t);console.log(`
@@ -1,4 +1,4 @@
1
- import {k}from'./chunk-UJT5KTVK.js';import*as r from'fs';import*as c from'path';var o=class{constructor(t){this.rootPath=t;}result=null;async generate(t={}){if(!this.rootPath)throw new Error("Root path required for analysis");let{title:e="Rails Application Map"}=t;this.result=await k(this.rootPath);let a=this.generateHTML(e);return t.outputPath&&(r.writeFileSync(t.outputPath,a),console.log(`
1
+ import {k}from'./chunk-PTR5IROV.js';import*as r from'fs';import*as c from'path';var o=class{constructor(t){this.rootPath=t;}result=null;async generate(t={}){if(!this.rootPath)throw new Error("Root path required for analysis");let{title:e="Rails Application Map"}=t;this.result=await k(this.rootPath);let a=this.generateHTML(e);return t.outputPath&&(r.writeFileSync(t.outputPath,a),console.log(`
2
2
  \u{1F4C4} Generated: ${t.outputPath}`)),a}generateFromResult(t,e="Rails Application Map"){return this.result=t,this.generateHTML(e)}generateHTML(t){if(!this.result)throw new Error("Analysis not run");let{routes:e,controllers:a,models:s,grpc:i,summary:l}=this.result;return `<!DOCTYPE html>
3
3
  <html lang="en">
4
4
  <head>
@@ -1,36 +1,36 @@
1
- import*as L from'fs';import*as x from'path';import {Parser,Language}from'web-tree-sitter';import {fileURLToPath}from'url';import {glob}from'glob';import*as A from'fs/promises';var ue=fileURLToPath(import.meta.url),te=x.dirname(ue),se=false,O=null,D=null;async function ne(){if(D&&O)return D;se||(await Parser.init(),se=true),D=new Parser;let l=[x.join(process.cwd(),"node_modules/tree-sitter-wasms/out/tree-sitter-ruby.wasm"),x.join(te,"../../../node_modules/tree-sitter-wasms/out/tree-sitter-ruby.wasm"),x.join(te,"../../../../tree-sitter-wasms/out/tree-sitter-ruby.wasm")],t=null;for(let e of l)if(L.existsSync(e)){t=e;break}if(!t)throw new Error("tree-sitter-ruby.wasm not found. Please install tree-sitter-wasms package.");return O=await Language.load(t),D.setLanguage(O),D}async function oe(l){let e=(await ne()).parse(l);if(!e)throw new Error("Failed to parse Ruby code");return e}async function N(l){let t=L.readFileSync(l,"utf-8");return oe(t)}function R(l,t){let e=[];l.type===t&&e.push(l);for(let o=0;o<l.childCount;o++){let s=l.child(o);s&&e.push(...R(s,t));}return e}function G(l,t){for(let e=0;e<l.childCount;e++){let o=l.child(e);if(o&&o.type===t)return o}return null}function w(l,t){let e=[];for(let o=0;o<l.childCount;o++){let s=l.child(o);s&&s.type===t&&e.push(s);}return e}function S(l){let t=l.childForFieldName("arguments");if(!t)return [];let e=[];for(let o=0;o<t.childCount;o++){let s=t.child(o);s&&s.type!=="("&&s.type!==")"&&s.type!==","&&e.push(s);}return e}function F(l){let t=l.childForFieldName("name");return t?t.text:null}function M(l){let t=l.childForFieldName("superclass");if(!t)return null;let e=G(t,"constant")||G(t,"scope_resolution");return e?e.text:null}function U(l){let t=l.childForFieldName("name");return t?t.text:null}function Z(l){let t=l.childForFieldName("parameters");if(!t)return [];let e=[];for(let o=0;o<t.childCount;o++){let s=t.child(o);if(s&&(s.type==="identifier"||s.type==="keyword_parameter"||s.type==="optional_parameter"||s.type==="splat_parameter")){let n=s.childForFieldName("name")||s;n.type==="identifier"?e.push(n.text):e.push(s.text);}}return e}var k=class{constructor(t){this.rootPath=t;this.routesDir=x.join(t,"config","routes");}routesDir;routes=[];namespaces=[];resources=[];mountedEngines=[];drawnFiles=[];errors=[];async analyze(){let t=x.join(this.rootPath,"config","routes.rb");if(!L.existsSync(t))return {routes:[],namespaces:[],resources:[],mountedEngines:[],drawnFiles:[],errors:[`routes.rb not found at ${t}`]};try{await this.parseRoutesFile(t,[]);}catch(e){this.errors.push(`Error parsing ${t}: ${e}`);}return {routes:this.routes,namespaces:[...new Set(this.namespaces)],resources:this.resources,mountedEngines:this.mountedEngines,drawnFiles:this.drawnFiles,errors:this.errors}}async parseRoutesFile(t,e){let s=(await N(t)).rootNode,n=R(s,"call");for(let r of n){let a=r.childForFieldName("method");if(!a)continue;let c=a.text,i=r.startPosition.row+1;switch(c){case "get":case "post":case "put":case "patch":case "delete":case "match":this.parseHttpRoute(r,c,e,i);break;case "resources":case "resource":await this.parseResources(r,e,i,c==="resource");break;case "namespace":await this.parseNamespace(r,e,t);break;case "mount":this.parseMount(r,i);break;case "draw":await this.parseDraw(r,e);break;case "devise_for":this.parseDeviseFor(r,e,i);break;case "root":this.parseRoot(r,e,i);break}}}parseHttpRoute(t,e,o,s){let n=S(t);if(n.length===0)return;let r=n[0],a=this.extractStringValue(r);if(!a)return;let c="",i="";for(let u of n)if(u.type==="hash"||u.type==="pair"){let m=u.type==="hash"?w(u,"pair"):[u];for(let d of m){let y=d.child(0)?.text?.replace(/^:/,""),f=d.child(2);if(y==="to"&&f){let g=this.extractStringValue(f);g&&g.includes("#")&&([c,i]=g.split("#"));}}}else if(u.type==="string"||u.type==="string_content"){let m=this.extractStringValue(u);m&&m.includes("#")&&!c&&([c,i]=m.split("#"));}if(!c&&!i){let u=a.replace(/^\//,"").split("/");c=u[0]||"",i=u[1]||"index";}o.length>0&&c&&!c.includes("/")&&(c=`${o.join("/")}/${c}`);let p=this.buildPath(o,a);this.routes.push({method:e==="match"?"ALL":e.toUpperCase(),path:p,controller:c,action:i,namespace:o.join("/")||void 0,line:s});}async parseResources(t,e,o,s){let n=S(t);if(n.length===0)return;let a=n[0].text.replace(/^:/,""),c={name:a,controller:e.length>0?`${e.join("/")}/${a}`:a,nested:[],memberRoutes:[],collectionRoutes:[],line:o};for(let p of n)if(p.type==="hash"){let u=w(p,"pair");for(let m of u){let d=m.child(0)?.text?.replace(/^:/,""),y=m.child(2);d==="only"&&y?c.only=this.extractArrayValues(y):d==="except"&&y&&(c.except=this.extractArrayValues(y));}}this.generateResourceRoutes(c,e,s),this.resources.push(c);let i=t.childForFieldName("block");if(i){let p=R(i,"call");for(let u of p){let m=u.childForFieldName("method")?.text;if(m==="member"){let d=u.childForFieldName("block");d&&this.parseMemberCollectionRoutes(d,c,e,"member");}else if(m==="collection"){let d=u.childForFieldName("block");d&&this.parseMemberCollectionRoutes(d,c,e,"collection");}}}}parseMemberCollectionRoutes(t,e,o,s){let n=R(t,"call");for(let r of n){let a=r.childForFieldName("method");if(!a)continue;let c=a.text;if(!["get","post","put","patch","delete"].includes(c))continue;let i=S(r);if(i.length===0)continue;let p=i[0].text.replace(/^:/,""),u=s==="member"?`/${e.name}/:id/${p}`:`/${e.name}/${p}`,m={method:c.toUpperCase(),path:this.buildPath(o,u),controller:e.controller,action:p,namespace:o.join("/")||void 0,line:r.startPosition.row+1};s==="member"?e.memberRoutes.push(m):e.collectionRoutes.push(m),this.routes.push(m);}}async parseNamespace(t,e,o){let s=S(t);if(s.length===0)return;let n=s[0].text.replace(/^:/,"");this.namespaces.push(n);let r=[...e,n],a=t.childForFieldName("block");if(a){let c=R(a,"call");for(let i of c){let p=i.childForFieldName("method");if(!p)continue;let u=p.text,m=i.startPosition.row+1;switch(u){case "get":case "post":case "put":case "patch":case "delete":case "match":this.parseHttpRoute(i,u,r,m);break;case "resources":case "resource":await this.parseResources(i,r,m,u==="resource");break;case "draw":await this.parseDraw(i,r);break}}}}parseMount(t,e){let o=S(t);if(o.length===0)return;let n=o[0].text,r="/";for(let a of o)if(a.type==="hash"||a.type==="pair"){let c=a.type==="hash"?w(a,"pair"):[a];for(let i of c){let p=i.child(0)?.text?.replace(/^:/,""),u=i.child(2);p==="at"&&u&&(r=this.extractStringValue(u)||r);}}else if(a.type==="string"){let c=this.extractStringValue(a);c&&c.startsWith("/")&&(r=c);}this.mountedEngines.push({engine:n,mountPath:r,line:e});}async parseDraw(t,e){let o=S(t);if(o.length===0)return;let s=o[0].text.replace(/^:/,""),n=x.join(this.routesDir,`${s}.rb`);if(L.existsSync(n)){this.drawnFiles.push(n);try{await this.parseRoutesFile(n,e);}catch(r){this.errors.push(`Error parsing drawn file ${n}: ${r}`);}}}parseDeviseFor(t,e,o){let s=S(t);if(s.length===0)return;let n=s[0].text.replace(/^:/,""),r=[{method:"GET",path:`/${n}/sign_in`,action:"new",controller:"devise/sessions"},{method:"POST",path:`/${n}/sign_in`,action:"create",controller:"devise/sessions"},{method:"DELETE",path:`/${n}/sign_out`,action:"destroy",controller:"devise/sessions"},{method:"GET",path:`/${n}/password/new`,action:"new",controller:"devise/passwords"},{method:"POST",path:`/${n}/password`,action:"create",controller:"devise/passwords"},{method:"GET",path:`/${n}/sign_up`,action:"new",controller:"devise/registrations"},{method:"POST",path:`/${n}`,action:"create",controller:"devise/registrations"}];for(let a of r)this.routes.push({method:a.method,path:this.buildPath(e,a.path),controller:a.controller,action:a.action,namespace:e.join("/")||void 0,line:o,authenticated:false});}parseRoot(t,e,o){let s=S(t),n="",r="index";for(let a of s)if(a.type==="string"){let c=this.extractStringValue(a);c&&c.includes("#")&&([n,r]=c.split("#"));}else if(a.type==="hash"||a.type==="pair"){let c=a.type==="hash"?w(a,"pair"):[a];for(let i of c){let p=i.child(0)?.text?.replace(/^:/,""),u=i.child(2);if(p==="to"&&u){let m=this.extractStringValue(u);m&&m.includes("#")&&([n,r]=m.split("#"));}}}n&&this.routes.push({method:"GET",path:this.buildPath(e,"/"),controller:n,action:r,namespace:e.join("/")||void 0,line:o});}generateResourceRoutes(t,e,o){let s=this.buildPath(e,`/${t.name}`),n=o?["show","new","create","edit","update","destroy"]:["index","show","new","create","edit","update","destroy"],r=t.only||(t.except?n.filter(i=>!t.except.includes(i)):n),a=[];o||r.includes("index")&&a.push({method:"GET",path:s,action:"index"}),r.includes("new")&&a.push({method:"GET",path:`${s}/new`,action:"new"}),r.includes("create")&&a.push({method:"POST",path:s,action:"create"});let c=o?s:`${s}/:id`;r.includes("show")&&a.push({method:"GET",path:c,action:"show"}),r.includes("edit")&&a.push({method:"GET",path:`${c}/edit`,action:"edit"}),r.includes("update")&&(a.push({method:"PUT",path:c,action:"update"}),a.push({method:"PATCH",path:c,action:"update"})),r.includes("destroy")&&a.push({method:"DELETE",path:c,action:"destroy"});for(let i of a)this.routes.push({method:i.method,path:i.path,controller:t.controller,action:i.action,namespace:e.join("/")||void 0,line:t.line});}buildPath(t,e){return e.startsWith("/")?e:`${t.length>0?`/${t.join("/")}`:""}/${e}`}extractStringValue(t){if(t.type==="string"){let e=G(t,"string_content");return e?e.text:t.text.replace(/^["']|["']$/g,"")}return t.type==="string_content"?t.text:t.type==="simple_symbol"||t.type==="symbol"?t.text.replace(/^:/,""):t.text.replace(/^["']|["']$/g,"")}extractArrayValues(t){let e=[];if(t.type==="array")for(let o=0;o<t.childCount;o++){let s=t.child(o);if(s&&s.type!=="["&&s.type!=="]"&&s.type!==","){let n=this.extractStringValue(s);n&&e.push(n);}}else {let o=this.extractStringValue(t);o&&e.push(o);}return e}};async function me(){let l=process.argv[2]||process.cwd();console.log(`Analyzing routes in: ${l}`);let e=await new k(l).analyze();if(console.log(`
1
+ import*as G from'fs';import*as x from'path';import {Parser,Language}from'web-tree-sitter';import {fileURLToPath}from'url';import {createRequire}from'module';import {glob}from'glob';import*as A from'fs/promises';var ue=createRequire(import.meta.url);var me=fileURLToPath(import.meta.url);x.dirname(me);var te=false,O=null,D=null;async function se(){if(D&&O)return D;te||(await Parser.init(),te=true),D=new Parser;let l=null;try{let e=ue.resolve("tree-sitter-wasms/package.json");l=x.join(x.dirname(e),"out/tree-sitter-ruby.wasm");}catch{let e=x.join(process.cwd(),"node_modules/tree-sitter-wasms/out/tree-sitter-ruby.wasm");G.existsSync(e)&&(l=e);}if(!l||!G.existsSync(l))throw new Error("tree-sitter-ruby.wasm not found. Please ensure tree-sitter-wasms package is installed.");return O=await Language.load(l),D.setLanguage(O),D}async function ne(l){let t=(await se()).parse(l);if(!t)throw new Error("Failed to parse Ruby code");return t}async function N(l){let e=G.readFileSync(l,"utf-8");return ne(e)}function R(l,e){let t=[];l.type===e&&t.push(l);for(let o=0;o<l.childCount;o++){let s=l.child(o);s&&t.push(...R(s,e));}return t}function L(l,e){for(let t=0;t<l.childCount;t++){let o=l.child(t);if(o&&o.type===e)return o}return null}function w(l,e){let t=[];for(let o=0;o<l.childCount;o++){let s=l.child(o);s&&s.type===e&&t.push(s);}return t}function S(l){let e=l.childForFieldName("arguments");if(!e)return [];let t=[];for(let o=0;o<e.childCount;o++){let s=e.child(o);s&&s.type!=="("&&s.type!==")"&&s.type!==","&&t.push(s);}return t}function F(l){let e=l.childForFieldName("name");return e?e.text:null}function M(l){let e=l.childForFieldName("superclass");if(!e)return null;let t=L(e,"constant")||L(e,"scope_resolution");return t?t.text:null}function U(l){let e=l.childForFieldName("name");return e?e.text:null}function Z(l){let e=l.childForFieldName("parameters");if(!e)return [];let t=[];for(let o=0;o<e.childCount;o++){let s=e.child(o);if(s&&(s.type==="identifier"||s.type==="keyword_parameter"||s.type==="optional_parameter"||s.type==="splat_parameter")){let n=s.childForFieldName("name")||s;n.type==="identifier"?t.push(n.text):t.push(s.text);}}return t}var k=class{constructor(e){this.rootPath=e;this.routesDir=x.join(e,"config","routes");}routesDir;routes=[];namespaces=[];resources=[];mountedEngines=[];drawnFiles=[];errors=[];async analyze(){let e=x.join(this.rootPath,"config","routes.rb");if(!G.existsSync(e))return {routes:[],namespaces:[],resources:[],mountedEngines:[],drawnFiles:[],errors:[`routes.rb not found at ${e}`]};try{await this.parseRoutesFile(e,[]);}catch(t){this.errors.push(`Error parsing ${e}: ${t}`);}return {routes:this.routes,namespaces:[...new Set(this.namespaces)],resources:this.resources,mountedEngines:this.mountedEngines,drawnFiles:this.drawnFiles,errors:this.errors}}async parseRoutesFile(e,t){let s=(await N(e)).rootNode,n=R(s,"call");for(let r of n){let a=r.childForFieldName("method");if(!a)continue;let c=a.text,i=r.startPosition.row+1;switch(c){case "get":case "post":case "put":case "patch":case "delete":case "match":this.parseHttpRoute(r,c,t,i);break;case "resources":case "resource":await this.parseResources(r,t,i,c==="resource");break;case "namespace":await this.parseNamespace(r,t,e);break;case "mount":this.parseMount(r,i);break;case "draw":await this.parseDraw(r,t);break;case "devise_for":this.parseDeviseFor(r,t,i);break;case "root":this.parseRoot(r,t,i);break}}}parseHttpRoute(e,t,o,s){let n=S(e);if(n.length===0)return;let r=n[0],a=this.extractStringValue(r);if(!a)return;let c="",i="";for(let u of n)if(u.type==="hash"||u.type==="pair"){let m=u.type==="hash"?w(u,"pair"):[u];for(let d of m){let y=d.child(0)?.text?.replace(/^:/,""),f=d.child(2);if(y==="to"&&f){let g=this.extractStringValue(f);g&&g.includes("#")&&([c,i]=g.split("#"));}}}else if(u.type==="string"||u.type==="string_content"){let m=this.extractStringValue(u);m&&m.includes("#")&&!c&&([c,i]=m.split("#"));}if(!c&&!i){let u=a.replace(/^\//,"").split("/");c=u[0]||"",i=u[1]||"index";}o.length>0&&c&&!c.includes("/")&&(c=`${o.join("/")}/${c}`);let p=this.buildPath(o,a);this.routes.push({method:t==="match"?"ALL":t.toUpperCase(),path:p,controller:c,action:i,namespace:o.join("/")||void 0,line:s});}async parseResources(e,t,o,s){let n=S(e);if(n.length===0)return;let a=n[0].text.replace(/^:/,""),c={name:a,controller:t.length>0?`${t.join("/")}/${a}`:a,nested:[],memberRoutes:[],collectionRoutes:[],line:o};for(let p of n)if(p.type==="hash"){let u=w(p,"pair");for(let m of u){let d=m.child(0)?.text?.replace(/^:/,""),y=m.child(2);d==="only"&&y?c.only=this.extractArrayValues(y):d==="except"&&y&&(c.except=this.extractArrayValues(y));}}this.generateResourceRoutes(c,t,s),this.resources.push(c);let i=e.childForFieldName("block");if(i){let p=R(i,"call");for(let u of p){let m=u.childForFieldName("method")?.text;if(m==="member"){let d=u.childForFieldName("block");d&&this.parseMemberCollectionRoutes(d,c,t,"member");}else if(m==="collection"){let d=u.childForFieldName("block");d&&this.parseMemberCollectionRoutes(d,c,t,"collection");}}}}parseMemberCollectionRoutes(e,t,o,s){let n=R(e,"call");for(let r of n){let a=r.childForFieldName("method");if(!a)continue;let c=a.text;if(!["get","post","put","patch","delete"].includes(c))continue;let i=S(r);if(i.length===0)continue;let p=i[0].text.replace(/^:/,""),u=s==="member"?`/${t.name}/:id/${p}`:`/${t.name}/${p}`,m={method:c.toUpperCase(),path:this.buildPath(o,u),controller:t.controller,action:p,namespace:o.join("/")||void 0,line:r.startPosition.row+1};s==="member"?t.memberRoutes.push(m):t.collectionRoutes.push(m),this.routes.push(m);}}async parseNamespace(e,t,o){let s=S(e);if(s.length===0)return;let n=s[0].text.replace(/^:/,"");this.namespaces.push(n);let r=[...t,n],a=e.childForFieldName("block");if(a){let c=R(a,"call");for(let i of c){let p=i.childForFieldName("method");if(!p)continue;let u=p.text,m=i.startPosition.row+1;switch(u){case "get":case "post":case "put":case "patch":case "delete":case "match":this.parseHttpRoute(i,u,r,m);break;case "resources":case "resource":await this.parseResources(i,r,m,u==="resource");break;case "draw":await this.parseDraw(i,r);break}}}}parseMount(e,t){let o=S(e);if(o.length===0)return;let n=o[0].text,r="/";for(let a of o)if(a.type==="hash"||a.type==="pair"){let c=a.type==="hash"?w(a,"pair"):[a];for(let i of c){let p=i.child(0)?.text?.replace(/^:/,""),u=i.child(2);p==="at"&&u&&(r=this.extractStringValue(u)||r);}}else if(a.type==="string"){let c=this.extractStringValue(a);c&&c.startsWith("/")&&(r=c);}this.mountedEngines.push({engine:n,mountPath:r,line:t});}async parseDraw(e,t){let o=S(e);if(o.length===0)return;let s=o[0].text.replace(/^:/,""),n=x.join(this.routesDir,`${s}.rb`);if(G.existsSync(n)){this.drawnFiles.push(n);try{await this.parseRoutesFile(n,t);}catch(r){this.errors.push(`Error parsing drawn file ${n}: ${r}`);}}}parseDeviseFor(e,t,o){let s=S(e);if(s.length===0)return;let n=s[0].text.replace(/^:/,""),r=[{method:"GET",path:`/${n}/sign_in`,action:"new",controller:"devise/sessions"},{method:"POST",path:`/${n}/sign_in`,action:"create",controller:"devise/sessions"},{method:"DELETE",path:`/${n}/sign_out`,action:"destroy",controller:"devise/sessions"},{method:"GET",path:`/${n}/password/new`,action:"new",controller:"devise/passwords"},{method:"POST",path:`/${n}/password`,action:"create",controller:"devise/passwords"},{method:"GET",path:`/${n}/sign_up`,action:"new",controller:"devise/registrations"},{method:"POST",path:`/${n}`,action:"create",controller:"devise/registrations"}];for(let a of r)this.routes.push({method:a.method,path:this.buildPath(t,a.path),controller:a.controller,action:a.action,namespace:t.join("/")||void 0,line:o,authenticated:false});}parseRoot(e,t,o){let s=S(e),n="",r="index";for(let a of s)if(a.type==="string"){let c=this.extractStringValue(a);c&&c.includes("#")&&([n,r]=c.split("#"));}else if(a.type==="hash"||a.type==="pair"){let c=a.type==="hash"?w(a,"pair"):[a];for(let i of c){let p=i.child(0)?.text?.replace(/^:/,""),u=i.child(2);if(p==="to"&&u){let m=this.extractStringValue(u);m&&m.includes("#")&&([n,r]=m.split("#"));}}}n&&this.routes.push({method:"GET",path:this.buildPath(t,"/"),controller:n,action:r,namespace:t.join("/")||void 0,line:o});}generateResourceRoutes(e,t,o){let s=this.buildPath(t,`/${e.name}`),n=o?["show","new","create","edit","update","destroy"]:["index","show","new","create","edit","update","destroy"],r=e.only||(e.except?n.filter(i=>!e.except.includes(i)):n),a=[];o||r.includes("index")&&a.push({method:"GET",path:s,action:"index"}),r.includes("new")&&a.push({method:"GET",path:`${s}/new`,action:"new"}),r.includes("create")&&a.push({method:"POST",path:s,action:"create"});let c=o?s:`${s}/:id`;r.includes("show")&&a.push({method:"GET",path:c,action:"show"}),r.includes("edit")&&a.push({method:"GET",path:`${c}/edit`,action:"edit"}),r.includes("update")&&(a.push({method:"PUT",path:c,action:"update"}),a.push({method:"PATCH",path:c,action:"update"})),r.includes("destroy")&&a.push({method:"DELETE",path:c,action:"destroy"});for(let i of a)this.routes.push({method:i.method,path:i.path,controller:e.controller,action:i.action,namespace:t.join("/")||void 0,line:e.line});}buildPath(e,t){return t.startsWith("/")?t:`${e.length>0?`/${e.join("/")}`:""}/${t}`}extractStringValue(e){if(e.type==="string"){let t=L(e,"string_content");return t?t.text:e.text.replace(/^["']|["']$/g,"")}return e.type==="string_content"?e.text:e.type==="simple_symbol"||e.type==="symbol"?e.text.replace(/^:/,""):e.text.replace(/^["']|["']$/g,"")}extractArrayValues(e){let t=[];if(e.type==="array")for(let o=0;o<e.childCount;o++){let s=e.child(o);if(s&&s.type!=="["&&s.type!=="]"&&s.type!==","){let n=this.extractStringValue(s);n&&t.push(n);}}else {let o=this.extractStringValue(e);o&&t.push(o);}return t}};async function de(){let l=process.argv[2]||process.cwd();console.log(`Analyzing routes in: ${l}`);let t=await new k(l).analyze();if(console.log(`
2
2
  === Rails Routes Analysis ===
3
- `),console.log(`Total routes: ${e.routes.length}`),console.log(`Namespaces: ${e.namespaces.join(", ")||"(none)"}`),console.log(`Resources: ${e.resources.length}`),console.log(`Mounted engines: ${e.mountedEngines.length}`),console.log(`External route files: ${e.drawnFiles.length}`),e.errors.length>0){console.log(`
4
- --- Errors ---`);for(let o of e.errors)console.log(` \u274C ${o}`);}console.log(`
5
- --- Sample Routes (first 30) ---`);for(let o of e.routes.slice(0,30))console.log(` ${o.method.padEnd(7)} ${o.path.padEnd(50)} => ${o.controller}#${o.action}`);console.log(`
6
- --- Mounted Engines ---`);for(let o of e.mountedEngines)console.log(` ${o.engine} => ${o.mountPath}`);console.log(`
7
- --- External Route Files ---`);for(let o of e.drawnFiles)console.log(` ${x.basename(o)}`);}var de=import.meta.url===`file://${process.argv[1]}`;de&&me().catch(console.error);var V=class{constructor(t){this.rootPath=t;this.controllersDir=x.join(t,"app","controllers");}controllersDir;controllers=[];errors=[];async analyze(){if(!L.existsSync(this.controllersDir))return {controllers:[],totalActions:0,namespaces:[],concerns:[],errors:[`Controllers directory not found at ${this.controllersDir}`]};let t=await glob("**/*_controller.rb",{cwd:this.controllersDir,ignore:["concerns/**"]});for(let n of t){let r=x.join(this.controllersDir,n);try{let a=await this.parseControllerFile(r,n);a&&this.controllers.push(a);}catch(a){this.errors.push(`Error parsing ${n}: ${a}`);}}let e=[...new Set(this.controllers.filter(n=>n.namespace).map(n=>n.namespace))],o=[...new Set(this.controllers.flatMap(n=>n.concerns))],s=this.controllers.reduce((n,r)=>n+r.actions.length,0);return {controllers:this.controllers,totalActions:s,namespaces:e,concerns:o,errors:this.errors}}async parseControllerFile(t,e){let s=(await N(t)).rootNode,n=e.replace(/_controller\.rb$/,"").split("/"),r=n.length>1?n.slice(0,-1).join("/"):void 0,a=n[n.length-1],c=R(s,"class");if(c.length===0)return null;let i=c[0],p=F(i),u=M(i);if(!p)return null;let m={name:a,filePath:e,className:p,parentClass:u||"ApplicationController",namespace:r,actions:[],beforeActions:[],afterActions:[],aroundActions:[],skipBeforeActions:[],concerns:[],helpers:[],rescueFrom:[],line:i.startPosition.row+1},d=R(i,"call");for(let h of d){let b=h.childForFieldName("method");if(!b)continue;let v=b.text,C=h.startPosition.row+1;switch(v){case "before_action":case "before_filter":this.parseFilter(h,m.beforeActions,C);break;case "after_action":case "after_filter":this.parseFilter(h,m.afterActions,C);break;case "around_action":case "around_filter":this.parseFilter(h,m.aroundActions,C);break;case "skip_before_action":case "skip_before_filter":this.parseFilter(h,m.skipBeforeActions,C);break;case "include":this.parseInclude(h,m.concerns);break;case "helper":this.parseHelper(h,m.helpers);break;case "layout":m.layoutInfo=this.parseLayout(h);break;case "rescue_from":this.parseRescueFrom(h,m.rescueFrom,C);break}}R(i,"method");let f="public",g=i.childForFieldName("body");if(g)for(let h=0;h<g.childCount;h++){let b=g.child(h);if(b){if(b.type==="identifier"){let v=b.text;v==="private"?f="private":v==="protected"?f="protected":v==="public"&&(f="public");}else if(b.type==="method"){let v=this.parseMethod(b,f);v&&m.actions.push(v);}}}return m}parseFilter(t,e,o){let s=this.getCallArguments(t);if(s.length===0)return;let a={name:s[0].text.replace(/^:/,""),line:o};for(let c of s.slice(1))if(c.type==="hash"){let i=w(c,"pair");for(let p of i){let u=p.child(0)?.text?.replace(/^:/,""),m=p.child(2);if(!(!u||!m))switch(u){case "only":a.only=this.extractArrayValues(m);break;case "except":a.except=this.extractArrayValues(m);break;case "if":a.if=m.text;break;case "unless":a.unless=m.text;break}}}e.push(a);}parseInclude(t,e){let o=this.getCallArguments(t);for(let s of o)(s.type==="constant"||s.type==="scope_resolution")&&e.push(s.text);}parseHelper(t,e){let o=this.getCallArguments(t);for(let s of o){let n=s.text.replace(/^:/,"");e.push(n);}}parseLayout(t){let e=this.getCallArguments(t);if(e.length===0)return;let o=e[0],s=o.text.replace(/^["']|["']$/g,"");s.startsWith(":")&&(s=s.substring(1)),(o.type==="lambda"||o.type==="proc")&&(s="(dynamic)");let n={name:s};for(let r of e.slice(1))r.type==="hash"&&(n.conditions=r.text);return n}parseRescueFrom(t,e,o){let s=this.getCallArguments(t);if(s.length===0)return;let n=s[0].text,r="unknown";for(let a of s.slice(1))if(a.type==="hash"||a.type==="pair"){let c=a.type==="hash"?w(a,"pair"):[a];for(let i of c){let p=i.child(0)?.text?.replace(/^:/,""),u=i.child(2);p==="with"&&u&&(r=u.text.replace(/^:/,""));}}e.push({exception:n,handler:r,line:o});}parseMethod(t,e){let o=U(t);if(!o||t.text.includes("def self."))return null;let s={name:o,line:t.startPosition.row+1,visibility:e,parameters:Z(t),servicesCalled:[],modelsCalled:[],methodCalls:[],instanceVarAssignments:[]},n=t.text,r=/@([a-z_][a-z0-9_]*)\s*=\s*([^\n]+)/gi,a;for(;(a=r.exec(n))!==null;){let p=a[1],u=a[2].trim().slice(0,100),m,d=u.match(/^([A-Z][a-zA-Z0-9]+)\.(find|find_by|find_by!|where|all|first|last|new|create|create!|build)/);d&&(m=d[1]);let y=u.match(/^@([a-z_]+)\.([a-z_]+)/);y&&!m&&(m=`${y[1]}.${y[2]}`);let f=u.match(/^current_([a-z_]+)/);f&&!m&&(m=f[1].charAt(0).toUpperCase()+f[1].slice(1));let g=u.match(/^([A-Z][a-zA-Z0-9]+Service)\.(call|new|perform)/);g&&!m&&(m=`Service:${g[1]}`),s.instanceVarAssignments&&s.instanceVarAssignments.push({name:p,assignedType:m,assignedValue:u.length>60?u.slice(0,57)+"...":u});}(n.includes("render json:")||n.includes("render :json"))&&(s.rendersJson=true),n.includes("render")&&!s.rendersJson&&(s.rendersHtml=true);let c=n.match(/redirect_to\s+([^,\n]+)/);if(c&&(s.redirectsTo=c[1].trim()),n.includes("respond_to")){let p=[];n.includes("format.html")&&p.push("html"),n.includes("format.json")&&p.push("json"),n.includes("format.xml")&&p.push("xml"),n.includes("format.js")&&p.push("js"),n.includes("format.csv")&&p.push("csv"),n.includes("format.pdf")&&p.push("pdf"),p.length>0&&(s.respondsTo=p);}let i=R(t,"call");for(let p of i){let u=p.childForFieldName("receiver"),m=p.childForFieldName("method");if(u&&m){let d=u.text,y=m.text;d.endsWith("Service")&&["call","new","perform","execute"].includes(y)&&(s.servicesCalled.includes(d)||s.servicesCalled.push(d));let f=["find","find_by","find_by!","where","all","first","last","create","create!","new","update","update!","destroy","delete"];/^[A-Z][a-zA-Z]+$/.test(d)&&f.includes(y)&&(["Rails","ActiveRecord","ActionController","ApplicationRecord"].includes(d)||s.modelsCalled.includes(d)||s.modelsCalled.push(d)),s.methodCalls.push(`${d}.${y}`);}else m&&!u&&s.methodCalls.push(m.text);}return s}getCallArguments(t){let e=t.childForFieldName("arguments");if(!e){let s=[];for(let n=0;n<t.childCount;n++){let r=t.child(n);r&&!["identifier","(",")",",","call"].includes(r.type)&&r!==t.childForFieldName("method")&&r!==t.childForFieldName("receiver")&&s.push(r);}return s}let o=[];for(let s=0;s<e.childCount;s++){let n=e.child(s);n&&n.type!=="("&&n.type!==")"&&n.type!==","&&o.push(n);}return o}extractArrayValues(t){let e=[];if(t.type==="array")for(let o=0;o<t.childCount;o++){let s=t.child(o);s&&s.type!=="["&&s.type!=="]"&&s.type!==","&&e.push(s.text.replace(/^:/,""));}else e.push(t.text.replace(/^:/,""));return e}};async function he(){let l=process.argv[2]||process.cwd();console.log(`Analyzing controllers in: ${l}`);let e=await new V(l).analyze();if(console.log(`
3
+ `),console.log(`Total routes: ${t.routes.length}`),console.log(`Namespaces: ${t.namespaces.join(", ")||"(none)"}`),console.log(`Resources: ${t.resources.length}`),console.log(`Mounted engines: ${t.mountedEngines.length}`),console.log(`External route files: ${t.drawnFiles.length}`),t.errors.length>0){console.log(`
4
+ --- Errors ---`);for(let o of t.errors)console.log(` \u274C ${o}`);}console.log(`
5
+ --- Sample Routes (first 30) ---`);for(let o of t.routes.slice(0,30))console.log(` ${o.method.padEnd(7)} ${o.path.padEnd(50)} => ${o.controller}#${o.action}`);console.log(`
6
+ --- Mounted Engines ---`);for(let o of t.mountedEngines)console.log(` ${o.engine} => ${o.mountPath}`);console.log(`
7
+ --- External Route Files ---`);for(let o of t.drawnFiles)console.log(` ${x.basename(o)}`);}var fe=import.meta.url===`file://${process.argv[1]}`;fe&&de().catch(console.error);var V=class{constructor(e){this.rootPath=e;this.controllersDir=x.join(e,"app","controllers");}controllersDir;controllers=[];errors=[];async analyze(){if(!G.existsSync(this.controllersDir))return {controllers:[],totalActions:0,namespaces:[],concerns:[],errors:[`Controllers directory not found at ${this.controllersDir}`]};let e=await glob("**/*_controller.rb",{cwd:this.controllersDir,ignore:["concerns/**"]});for(let n of e){let r=x.join(this.controllersDir,n);try{let a=await this.parseControllerFile(r,n);a&&this.controllers.push(a);}catch(a){this.errors.push(`Error parsing ${n}: ${a}`);}}let t=[...new Set(this.controllers.filter(n=>n.namespace).map(n=>n.namespace))],o=[...new Set(this.controllers.flatMap(n=>n.concerns))],s=this.controllers.reduce((n,r)=>n+r.actions.length,0);return {controllers:this.controllers,totalActions:s,namespaces:t,concerns:o,errors:this.errors}}async parseControllerFile(e,t){let s=(await N(e)).rootNode,n=t.replace(/_controller\.rb$/,"").split("/"),r=n.length>1?n.slice(0,-1).join("/"):void 0,a=n[n.length-1],c=R(s,"class");if(c.length===0)return null;let i=c[0],p=F(i),u=M(i);if(!p)return null;let m={name:a,filePath:t,className:p,parentClass:u||"ApplicationController",namespace:r,actions:[],beforeActions:[],afterActions:[],aroundActions:[],skipBeforeActions:[],concerns:[],helpers:[],rescueFrom:[],line:i.startPosition.row+1},d=R(i,"call");for(let h of d){let b=h.childForFieldName("method");if(!b)continue;let v=b.text,C=h.startPosition.row+1;switch(v){case "before_action":case "before_filter":this.parseFilter(h,m.beforeActions,C);break;case "after_action":case "after_filter":this.parseFilter(h,m.afterActions,C);break;case "around_action":case "around_filter":this.parseFilter(h,m.aroundActions,C);break;case "skip_before_action":case "skip_before_filter":this.parseFilter(h,m.skipBeforeActions,C);break;case "include":this.parseInclude(h,m.concerns);break;case "helper":this.parseHelper(h,m.helpers);break;case "layout":m.layoutInfo=this.parseLayout(h);break;case "rescue_from":this.parseRescueFrom(h,m.rescueFrom,C);break}}R(i,"method");let f="public",g=i.childForFieldName("body");if(g)for(let h=0;h<g.childCount;h++){let b=g.child(h);if(b){if(b.type==="identifier"){let v=b.text;v==="private"?f="private":v==="protected"?f="protected":v==="public"&&(f="public");}else if(b.type==="method"){let v=this.parseMethod(b,f);v&&m.actions.push(v);}}}return m}parseFilter(e,t,o){let s=this.getCallArguments(e);if(s.length===0)return;let a={name:s[0].text.replace(/^:/,""),line:o};for(let c of s.slice(1))if(c.type==="hash"){let i=w(c,"pair");for(let p of i){let u=p.child(0)?.text?.replace(/^:/,""),m=p.child(2);if(!(!u||!m))switch(u){case "only":a.only=this.extractArrayValues(m);break;case "except":a.except=this.extractArrayValues(m);break;case "if":a.if=m.text;break;case "unless":a.unless=m.text;break}}}t.push(a);}parseInclude(e,t){let o=this.getCallArguments(e);for(let s of o)(s.type==="constant"||s.type==="scope_resolution")&&t.push(s.text);}parseHelper(e,t){let o=this.getCallArguments(e);for(let s of o){let n=s.text.replace(/^:/,"");t.push(n);}}parseLayout(e){let t=this.getCallArguments(e);if(t.length===0)return;let o=t[0],s=o.text.replace(/^["']|["']$/g,"");s.startsWith(":")&&(s=s.substring(1)),(o.type==="lambda"||o.type==="proc")&&(s="(dynamic)");let n={name:s};for(let r of t.slice(1))r.type==="hash"&&(n.conditions=r.text);return n}parseRescueFrom(e,t,o){let s=this.getCallArguments(e);if(s.length===0)return;let n=s[0].text,r="unknown";for(let a of s.slice(1))if(a.type==="hash"||a.type==="pair"){let c=a.type==="hash"?w(a,"pair"):[a];for(let i of c){let p=i.child(0)?.text?.replace(/^:/,""),u=i.child(2);p==="with"&&u&&(r=u.text.replace(/^:/,""));}}t.push({exception:n,handler:r,line:o});}parseMethod(e,t){let o=U(e);if(!o||e.text.includes("def self."))return null;let s={name:o,line:e.startPosition.row+1,visibility:t,parameters:Z(e),servicesCalled:[],modelsCalled:[],methodCalls:[],instanceVarAssignments:[]},n=e.text,r=/@([a-z_][a-z0-9_]*)\s*=\s*([^\n]+)/gi,a;for(;(a=r.exec(n))!==null;){let p=a[1],u=a[2].trim().slice(0,100),m,d=u.match(/^([A-Z][a-zA-Z0-9]+)\.(find|find_by|find_by!|where|all|first|last|new|create|create!|build)/);d&&(m=d[1]);let y=u.match(/^@([a-z_]+)\.([a-z_]+)/);y&&!m&&(m=`${y[1]}.${y[2]}`);let f=u.match(/^current_([a-z_]+)/);f&&!m&&(m=f[1].charAt(0).toUpperCase()+f[1].slice(1));let g=u.match(/^([A-Z][a-zA-Z0-9]+Service)\.(call|new|perform)/);g&&!m&&(m=`Service:${g[1]}`),s.instanceVarAssignments&&s.instanceVarAssignments.push({name:p,assignedType:m,assignedValue:u.length>60?u.slice(0,57)+"...":u});}(n.includes("render json:")||n.includes("render :json"))&&(s.rendersJson=true),n.includes("render")&&!s.rendersJson&&(s.rendersHtml=true);let c=n.match(/redirect_to\s+([^,\n]+)/);if(c&&(s.redirectsTo=c[1].trim()),n.includes("respond_to")){let p=[];n.includes("format.html")&&p.push("html"),n.includes("format.json")&&p.push("json"),n.includes("format.xml")&&p.push("xml"),n.includes("format.js")&&p.push("js"),n.includes("format.csv")&&p.push("csv"),n.includes("format.pdf")&&p.push("pdf"),p.length>0&&(s.respondsTo=p);}let i=R(e,"call");for(let p of i){let u=p.childForFieldName("receiver"),m=p.childForFieldName("method");if(u&&m){let d=u.text,y=m.text;d.endsWith("Service")&&["call","new","perform","execute"].includes(y)&&(s.servicesCalled.includes(d)||s.servicesCalled.push(d));let f=["find","find_by","find_by!","where","all","first","last","create","create!","new","update","update!","destroy","delete"];/^[A-Z][a-zA-Z]+$/.test(d)&&f.includes(y)&&(["Rails","ActiveRecord","ActionController","ApplicationRecord"].includes(d)||s.modelsCalled.includes(d)||s.modelsCalled.push(d)),s.methodCalls.push(`${d}.${y}`);}else m&&!u&&s.methodCalls.push(m.text);}return s}getCallArguments(e){let t=e.childForFieldName("arguments");if(!t){let s=[];for(let n=0;n<e.childCount;n++){let r=e.child(n);r&&!["identifier","(",")",",","call"].includes(r.type)&&r!==e.childForFieldName("method")&&r!==e.childForFieldName("receiver")&&s.push(r);}return s}let o=[];for(let s=0;s<t.childCount;s++){let n=t.child(s);n&&n.type!=="("&&n.type!==")"&&n.type!==","&&o.push(n);}return o}extractArrayValues(e){let t=[];if(e.type==="array")for(let o=0;o<e.childCount;o++){let s=e.child(o);s&&s.type!=="["&&s.type!=="]"&&s.type!==","&&t.push(s.text.replace(/^:/,""));}else t.push(e.text.replace(/^:/,""));return t}};async function ge(){let l=process.argv[2]||process.cwd();console.log(`Analyzing controllers in: ${l}`);let t=await new V(l).analyze();if(console.log(`
8
8
  === Rails Controllers Analysis ===
9
- `),console.log(`Total controllers: ${e.controllers.length}`),console.log(`Total actions: ${e.totalActions}`),console.log(`Namespaces: ${e.namespaces.join(", ")||"(none)"}`),console.log(`Shared concerns: ${e.concerns.length}`),e.errors.length>0){console.log(`
10
- --- Errors (${e.errors.length}) ---`);for(let n of e.errors.slice(0,5))console.log(` \u274C ${n}`);e.errors.length>5&&console.log(` ... and ${e.errors.length-5} more`);}console.log(`
11
- --- Sample Controllers (first 10) ---`);for(let n of e.controllers.slice(0,10))console.log(`
12
- \u{1F4C1} ${n.className} (${n.filePath})`),console.log(` Parent: ${n.parentClass}`),console.log(` Actions (${n.actions.length}): ${n.actions.map(r=>r.name).slice(0,5).join(", ")}${n.actions.length>5?"...":""}`),n.beforeActions.length>0&&console.log(` Before: ${n.beforeActions.map(r=>r.name).join(", ")}`),n.concerns.length>0&&console.log(` Concerns: ${n.concerns.join(", ")}`);let o=e.controllers.flatMap(n=>n.actions.filter(r=>r.visibility==="public")),s=e.controllers.flatMap(n=>n.actions.filter(r=>r.visibility==="private"));console.log(`
13
- --- Action Visibility Summary ---`),console.log(` Public: ${o.length}`),console.log(` Private: ${s.length}`);}var ge=import.meta.url===`file://${process.argv[1]}`;ge&&he().catch(console.error);var j=class{constructor(t){this.rootPath=t;this.modelsDir=x.join(t,"app","models");}modelsDir;models=[];errors=[];async analyze(){if(!L.existsSync(this.modelsDir))return {models:[],totalAssociations:0,totalValidations:0,concerns:[],namespaces:[],errors:[`Models directory not found at ${this.modelsDir}`]};let t=await glob("**/*.rb",{cwd:this.modelsDir,ignore:["concerns/**","application_record.rb"]});for(let r of t){let a=x.join(this.modelsDir,r);try{let c=await this.parseModelFile(a,r);c&&this.models.push(c);}catch(c){this.errors.push(`Error parsing ${r}: ${c}`);}}let e=[...new Set(this.models.flatMap(r=>r.concerns))],o=[...new Set(this.models.map(r=>{let a=r.filePath.split("/");return a.length>1?a.slice(0,-1).join("/"):null}).filter(r=>r!==null))],s=this.models.reduce((r,a)=>r+a.associations.length,0),n=this.models.reduce((r,a)=>r+a.validations.length,0);return {models:this.models,totalAssociations:s,totalValidations:n,concerns:e,namespaces:o,errors:this.errors}}async parseModelFile(t,e){let s=(await N(t)).rootNode,n=R(s,"class");if(n.length===0)return null;let r=n[0],a=F(r),c=M(r);if(!a)return null;c&&this.isActiveRecordModel(c);let i={name:a.replace(/.*::/,""),filePath:e,className:a,parentClass:c||"ApplicationRecord",associations:[],validations:[],callbacks:[],scopes:[],concerns:[],enums:[],attributes:[],classMethodsCount:0,instanceMethodsCount:0,line:r.startPosition.row+1};i.tableName=this.parseTableName(r);let p=R(r,"call");for(let d of p){let y=d.childForFieldName("method");if(!y)continue;let f=y.text,g=d.startPosition.row+1;["belongs_to","has_one","has_many","has_and_belongs_to_many"].includes(f)?this.parseAssociation(d,f,i.associations,g):f.startsWith("validates")||f==="validate"?this.parseValidation(d,f,i.validations,g):this.isCallback(f)?this.parseCallback(d,f,i.callbacks,g):f==="scope"?this.parseScope(d,i.scopes,g):f==="include"?this.parseInclude(d,i.concerns):f==="enum"?this.parseEnum(d,i.enums,g):f==="attribute"&&this.parseAttribute(d,i.attributes,g);}let u=R(r,"method"),m=R(r,"singleton_method");return i.instanceMethodsCount=u.length,i.classMethodsCount=m.length,i}isActiveRecordModel(t){return ["ApplicationRecord","ActiveRecord::Base","ActiveRecord"].some(o=>t.includes(o))}parseTableName(t){let e=R(t,"call");for(let s of e)if(s.childForFieldName("method")?.text==="table_name="){let r=this.getCallArguments(s);if(r.length>0)return r[0].text.replace(/^["']|["']$/g,"")}let o=R(t,"assignment");for(let s of o)if(s.child(0)?.text?.includes("table_name")){let r=s.child(2);if(r)return r.text.replace(/^["']|["']$/g,"")}}parseAssociation(t,e,o,s){let n=this.getCallArguments(t);if(n.length===0)return;let a=n[0].text.replace(/^:/,""),c={type:e,name:a,line:s};for(let i of n.slice(1))if(i.type==="hash"){let p=w(i,"pair");for(let u of p){let m=u.child(0)?.text?.replace(/^:/,""),d=u.child(2);if(!(!m||!d))switch(m){case "class_name":c.className=d.text.replace(/^["']|["']$/g,"");break;case "foreign_key":c.foreignKey=d.text.replace(/^["']|["']$/g,"").replace(/^:/,"");break;case "through":c.through=d.text.replace(/^:/,"");break;case "polymorphic":c.polymorphic=d.text==="true";break;case "dependent":c.dependent=d.text.replace(/^:/,"");break;case "optional":c.optional=d.text==="true";break}}}o.push(c);}parseValidation(t,e,o,s){let n=this.getCallArguments(t);if(n.length===0)return;let r=[],a={},c=e;for(let i of n)if(i.type==="simple_symbol"||i.type==="symbol")r.push(i.text.replace(/^:/,""));else if(i.type==="hash"){let p=w(i,"pair");for(let u of p){let m=u.child(0)?.text?.replace(/^:/,""),d=u.child(2);m&&d&&(["presence","uniqueness","numericality","length","format","inclusion","exclusion","acceptance","confirmation"].includes(m)&&(c=m),a[m]=d.text);}}(r.length>0||e==="validate")&&o.push({type:c,attributes:r,options:Object.keys(a).length>0?a:void 0,line:s});}isCallback(t){return ["before_validation","after_validation","before_save","around_save","after_save","before_create","around_create","after_create","before_update","around_update","after_update","before_destroy","around_destroy","after_destroy","after_commit","after_rollback","after_initialize","after_find","after_touch"].includes(t)}parseCallback(t,e,o,s){let n=this.getCallArguments(t);if(n.length===0)return;let a=n[0].text.replace(/^:/,""),c={type:e,method:a,line:s};for(let i of n.slice(1))if(i.type==="hash"){let p=w(i,"pair");for(let u of p){let m=u.child(0)?.text?.replace(/^:/,""),d=u.child(2);m&&d&&["if","unless"].includes(m)&&(c.conditions=`${m}: ${d.text}`);}}o.push(c);}parseScope(t,e,o){let s=this.getCallArguments(t);if(s.length===0)return;let r=s[0].text.replace(/^:/,""),a=s.length>1&&(s[1].type==="lambda"||s[1].text.includes("->"));e.push({name:r,lambda:a,line:o});}parseInclude(t,e){let o=this.getCallArguments(t);for(let s of o)(s.type==="constant"||s.type==="scope_resolution")&&e.push(s.text);}parseEnum(t,e,o){let s=this.getCallArguments(t);if(s.length!==0){for(let n of s)if(n.type==="hash"){let r=w(n,"pair");for(let a of r){let c=a.child(0)?.text?.replace(/^:/,""),i=a.child(2);if(c&&i&&i.type==="hash"){let p=[],u=w(i,"pair");for(let m of u){let d=m.child(0)?.text?.replace(/^:/,"");d&&p.push(d);}e.push({name:c,values:p,line:o});}else if(c&&i&&i.type==="array"){let p=[];for(let u=0;u<i.childCount;u++){let m=i.child(u);m&&m.type!=="["&&m.type!=="]"&&m.type!==","&&p.push(m.text.replace(/^:/,""));}e.push({name:c,values:p,line:o});}}}}}parseAttribute(t,e,o){let s=this.getCallArguments(t);if(s.length===0)return;let a={name:s[0].text.replace(/^:/,""),line:o};if(s.length>1){let c=s[1];a.type=c.text.replace(/^:/,"");}for(let c of s)if(c.type==="hash"){let i=w(c,"pair");for(let p of i){let u=p.child(0)?.text?.replace(/^:/,""),m=p.child(2);u==="default"&&m&&(a.default=m.text);}}e.push(a);}getCallArguments(t){let e=t.childForFieldName("arguments");if(!e){let s=[];for(let n=0;n<t.childCount;n++){let r=t.child(n);r&&!["identifier","(",")",",","call"].includes(r.type)&&r!==t.childForFieldName("method")&&r!==t.childForFieldName("receiver")&&s.push(r);}return s}let o=[];for(let s=0;s<e.childCount;s++){let n=e.child(s);n&&n.type!=="("&&n.type!==")"&&n.type!==","&&o.push(n);}return o}};async function be(){let l=process.argv[2]||process.cwd();console.log(`Analyzing models in: ${l}`);let e=await new j(l).analyze();if(console.log(`
9
+ `),console.log(`Total controllers: ${t.controllers.length}`),console.log(`Total actions: ${t.totalActions}`),console.log(`Namespaces: ${t.namespaces.join(", ")||"(none)"}`),console.log(`Shared concerns: ${t.concerns.length}`),t.errors.length>0){console.log(`
10
+ --- Errors (${t.errors.length}) ---`);for(let n of t.errors.slice(0,5))console.log(` \u274C ${n}`);t.errors.length>5&&console.log(` ... and ${t.errors.length-5} more`);}console.log(`
11
+ --- Sample Controllers (first 10) ---`);for(let n of t.controllers.slice(0,10))console.log(`
12
+ \u{1F4C1} ${n.className} (${n.filePath})`),console.log(` Parent: ${n.parentClass}`),console.log(` Actions (${n.actions.length}): ${n.actions.map(r=>r.name).slice(0,5).join(", ")}${n.actions.length>5?"...":""}`),n.beforeActions.length>0&&console.log(` Before: ${n.beforeActions.map(r=>r.name).join(", ")}`),n.concerns.length>0&&console.log(` Concerns: ${n.concerns.join(", ")}`);let o=t.controllers.flatMap(n=>n.actions.filter(r=>r.visibility==="public")),s=t.controllers.flatMap(n=>n.actions.filter(r=>r.visibility==="private"));console.log(`
13
+ --- Action Visibility Summary ---`),console.log(` Public: ${o.length}`),console.log(` Private: ${s.length}`);}var ye=import.meta.url===`file://${process.argv[1]}`;ye&&ge().catch(console.error);var j=class{constructor(e){this.rootPath=e;this.modelsDir=x.join(e,"app","models");}modelsDir;models=[];errors=[];async analyze(){if(!G.existsSync(this.modelsDir))return {models:[],totalAssociations:0,totalValidations:0,concerns:[],namespaces:[],errors:[`Models directory not found at ${this.modelsDir}`]};let e=await glob("**/*.rb",{cwd:this.modelsDir,ignore:["concerns/**","application_record.rb"]});for(let r of e){let a=x.join(this.modelsDir,r);try{let c=await this.parseModelFile(a,r);c&&this.models.push(c);}catch(c){this.errors.push(`Error parsing ${r}: ${c}`);}}let t=[...new Set(this.models.flatMap(r=>r.concerns))],o=[...new Set(this.models.map(r=>{let a=r.filePath.split("/");return a.length>1?a.slice(0,-1).join("/"):null}).filter(r=>r!==null))],s=this.models.reduce((r,a)=>r+a.associations.length,0),n=this.models.reduce((r,a)=>r+a.validations.length,0);return {models:this.models,totalAssociations:s,totalValidations:n,concerns:t,namespaces:o,errors:this.errors}}async parseModelFile(e,t){let s=(await N(e)).rootNode,n=R(s,"class");if(n.length===0)return null;let r=n[0],a=F(r),c=M(r);if(!a)return null;c&&this.isActiveRecordModel(c);let i={name:a.replace(/.*::/,""),filePath:t,className:a,parentClass:c||"ApplicationRecord",associations:[],validations:[],callbacks:[],scopes:[],concerns:[],enums:[],attributes:[],classMethodsCount:0,instanceMethodsCount:0,line:r.startPosition.row+1};i.tableName=this.parseTableName(r);let p=R(r,"call");for(let d of p){let y=d.childForFieldName("method");if(!y)continue;let f=y.text,g=d.startPosition.row+1;["belongs_to","has_one","has_many","has_and_belongs_to_many"].includes(f)?this.parseAssociation(d,f,i.associations,g):f.startsWith("validates")||f==="validate"?this.parseValidation(d,f,i.validations,g):this.isCallback(f)?this.parseCallback(d,f,i.callbacks,g):f==="scope"?this.parseScope(d,i.scopes,g):f==="include"?this.parseInclude(d,i.concerns):f==="enum"?this.parseEnum(d,i.enums,g):f==="attribute"&&this.parseAttribute(d,i.attributes,g);}let u=R(r,"method"),m=R(r,"singleton_method");return i.instanceMethodsCount=u.length,i.classMethodsCount=m.length,i}isActiveRecordModel(e){return ["ApplicationRecord","ActiveRecord::Base","ActiveRecord"].some(o=>e.includes(o))}parseTableName(e){let t=R(e,"call");for(let s of t)if(s.childForFieldName("method")?.text==="table_name="){let r=this.getCallArguments(s);if(r.length>0)return r[0].text.replace(/^["']|["']$/g,"")}let o=R(e,"assignment");for(let s of o)if(s.child(0)?.text?.includes("table_name")){let r=s.child(2);if(r)return r.text.replace(/^["']|["']$/g,"")}}parseAssociation(e,t,o,s){let n=this.getCallArguments(e);if(n.length===0)return;let a=n[0].text.replace(/^:/,""),c={type:t,name:a,line:s};for(let i of n.slice(1))if(i.type==="hash"){let p=w(i,"pair");for(let u of p){let m=u.child(0)?.text?.replace(/^:/,""),d=u.child(2);if(!(!m||!d))switch(m){case "class_name":c.className=d.text.replace(/^["']|["']$/g,"");break;case "foreign_key":c.foreignKey=d.text.replace(/^["']|["']$/g,"").replace(/^:/,"");break;case "through":c.through=d.text.replace(/^:/,"");break;case "polymorphic":c.polymorphic=d.text==="true";break;case "dependent":c.dependent=d.text.replace(/^:/,"");break;case "optional":c.optional=d.text==="true";break}}}o.push(c);}parseValidation(e,t,o,s){let n=this.getCallArguments(e);if(n.length===0)return;let r=[],a={},c=t;for(let i of n)if(i.type==="simple_symbol"||i.type==="symbol")r.push(i.text.replace(/^:/,""));else if(i.type==="hash"){let p=w(i,"pair");for(let u of p){let m=u.child(0)?.text?.replace(/^:/,""),d=u.child(2);m&&d&&(["presence","uniqueness","numericality","length","format","inclusion","exclusion","acceptance","confirmation"].includes(m)&&(c=m),a[m]=d.text);}}(r.length>0||t==="validate")&&o.push({type:c,attributes:r,options:Object.keys(a).length>0?a:void 0,line:s});}isCallback(e){return ["before_validation","after_validation","before_save","around_save","after_save","before_create","around_create","after_create","before_update","around_update","after_update","before_destroy","around_destroy","after_destroy","after_commit","after_rollback","after_initialize","after_find","after_touch"].includes(e)}parseCallback(e,t,o,s){let n=this.getCallArguments(e);if(n.length===0)return;let a=n[0].text.replace(/^:/,""),c={type:t,method:a,line:s};for(let i of n.slice(1))if(i.type==="hash"){let p=w(i,"pair");for(let u of p){let m=u.child(0)?.text?.replace(/^:/,""),d=u.child(2);m&&d&&["if","unless"].includes(m)&&(c.conditions=`${m}: ${d.text}`);}}o.push(c);}parseScope(e,t,o){let s=this.getCallArguments(e);if(s.length===0)return;let r=s[0].text.replace(/^:/,""),a=s.length>1&&(s[1].type==="lambda"||s[1].text.includes("->"));t.push({name:r,lambda:a,line:o});}parseInclude(e,t){let o=this.getCallArguments(e);for(let s of o)(s.type==="constant"||s.type==="scope_resolution")&&t.push(s.text);}parseEnum(e,t,o){let s=this.getCallArguments(e);if(s.length!==0){for(let n of s)if(n.type==="hash"){let r=w(n,"pair");for(let a of r){let c=a.child(0)?.text?.replace(/^:/,""),i=a.child(2);if(c&&i&&i.type==="hash"){let p=[],u=w(i,"pair");for(let m of u){let d=m.child(0)?.text?.replace(/^:/,"");d&&p.push(d);}t.push({name:c,values:p,line:o});}else if(c&&i&&i.type==="array"){let p=[];for(let u=0;u<i.childCount;u++){let m=i.child(u);m&&m.type!=="["&&m.type!=="]"&&m.type!==","&&p.push(m.text.replace(/^:/,""));}t.push({name:c,values:p,line:o});}}}}}parseAttribute(e,t,o){let s=this.getCallArguments(e);if(s.length===0)return;let a={name:s[0].text.replace(/^:/,""),line:o};if(s.length>1){let c=s[1];a.type=c.text.replace(/^:/,"");}for(let c of s)if(c.type==="hash"){let i=w(c,"pair");for(let p of i){let u=p.child(0)?.text?.replace(/^:/,""),m=p.child(2);u==="default"&&m&&(a.default=m.text);}}t.push(a);}getCallArguments(e){let t=e.childForFieldName("arguments");if(!t){let s=[];for(let n=0;n<e.childCount;n++){let r=e.child(n);r&&!["identifier","(",")",",","call"].includes(r.type)&&r!==e.childForFieldName("method")&&r!==e.childForFieldName("receiver")&&s.push(r);}return s}let o=[];for(let s=0;s<t.childCount;s++){let n=t.child(s);n&&n.type!=="("&&n.type!==")"&&n.type!==","&&o.push(n);}return o}};async function xe(){let l=process.argv[2]||process.cwd();console.log(`Analyzing models in: ${l}`);let t=await new j(l).analyze();if(console.log(`
14
14
  === Rails Models Analysis ===
15
- `),console.log(`Total models: ${e.models.length}`),console.log(`Total associations: ${e.totalAssociations}`),console.log(`Total validations: ${e.totalValidations}`),console.log(`Shared concerns: ${e.concerns.length}`),console.log(`Namespaces: ${e.namespaces.join(", ")||"(none)"}`),e.errors.length>0){console.log(`
16
- --- Errors (${e.errors.length}) ---`);for(let a of e.errors.slice(0,5))console.log(` \u274C ${a}`);e.errors.length>5&&console.log(` ... and ${e.errors.length-5} more`);}console.log(`
17
- --- Sample Models (first 15) ---`);for(let a of e.models.slice(0,15)){if(console.log(`
18
- \u{1F4E6} ${a.className} (${a.filePath})`),console.log(` Parent: ${a.parentClass}`),a.associations.length>0){let c=a.associations.slice(0,3).map(i=>`${i.type} :${i.name}`);console.log(` Associations: ${c.join(", ")}${a.associations.length>3?"...":""}`);}if(a.validations.length>0&&console.log(` Validations: ${a.validations.length}`),a.scopes.length>0){let c=a.scopes.slice(0,3).map(i=>i.name);console.log(` Scopes: ${c.join(", ")}${a.scopes.length>3?"...":""}`);}if(a.enums.length>0){let c=a.enums.map(i=>`${i.name}(${i.values.length})`);console.log(` Enums: ${c.join(", ")}`);}a.concerns.length>0&&console.log(` Concerns: ${a.concerns.slice(0,3).join(", ")}${a.concerns.length>3?"...":""}`);}let o=e.models.flatMap(a=>a.associations),s=o.filter(a=>a.type==="belongs_to").length,n=o.filter(a=>a.type==="has_many").length,r=o.filter(a=>a.type==="has_one").length;console.log(`
19
- --- Association Summary ---`),console.log(` belongs_to: ${s}`),console.log(` has_many: ${n}`),console.log(` has_one: ${r}`);}var xe=import.meta.url===`file://${process.argv[1]}`;xe&&be().catch(console.error);var T=class{constructor(t){this.rootPath=t;this.grpcDir=x.join(t,"app","grpc_services");}grpcDir;services=[];errors=[];async analyze(){if(!L.existsSync(this.grpcDir))return {services:[],totalRpcs:0,namespaces:[],errors:[`gRPC services directory not found at ${this.grpcDir}`]};let t=await glob("**/*_grpc_service.rb",{cwd:this.grpcDir});for(let s of t){let n=x.join(this.grpcDir,s);try{let r=await this.parseServiceFile(n,s);r&&this.services.push(r);}catch(r){this.errors.push(`Error parsing ${s}: ${r}`);}}let e=[...new Set(this.services.filter(s=>s.namespace).map(s=>s.namespace))],o=this.services.reduce((s,n)=>s+n.rpcs.length,0);return {services:this.services,totalRpcs:o,namespaces:e,errors:this.errors}}async parseServiceFile(t,e){let s=(await N(t)).rootNode,n=e.replace(/_grpc_service\.rb$/,"").split("/"),r=n.length>1?n.slice(0,-1).join("/"):void 0,a=n[n.length-1],c=R(s,"class");if(c.length===0)return null;let i=c[0],p=F(i),u=M(i);if(!p)return null;let m={name:a,filePath:e,className:p,parentClass:u||"Unknown",namespace:r,rpcs:[],policies:[],serializers:[],concerns:[],line:i.startPosition.row+1};u&&u.match(/(\w+)::Service$/)&&(m.protoService=u.replace("::Service",""));let d=R(i,"call");for(let h of d)if(h.childForFieldName("method")?.text==="include"){let v=this.getCallArguments(h);for(let C of v)(C.type==="constant"||C.type==="scope_resolution")&&m.concerns.push(C.text);}R(i,"method");let f="public",g=i.childForFieldName("body");if(g)for(let h=0;h<g.childCount;h++){let b=g.child(h);if(b){if(b.type==="identifier"){let v=b.text;v==="private"?f="private":v==="protected"?f="protected":v==="public"&&(f="public");}else if(b.type==="method"&&f==="public"){let v=this.parseRpcMethod(b);if(v){let C=R(b,"call");for(let X of C){let B=X.childForFieldName("method")?.text,P=X.childForFieldName("receiver")?.text;(B==="authorize!"||B==="new")&&P?.includes("Policy")&&(m.policies.includes(P)||m.policies.push(P),v.policyMethod="authorize!"),P?.includes("Serializer")&&B==="new"&&(m.serializers.includes(P)||m.serializers.push(P));}m.rpcs.push(v);}}}}return m}parseRpcMethod(t){let e=U(t);if(!e||["initialize","to_s","inspect","call","perform","execute"].includes(e))return null;Z(t);let n=t.text,r={name:e,line:t.startPosition.row+1,streaming:"none",modelsUsed:[],servicesUsed:[]},a=n.match(/@param\s+\[([^\]]+)\]\s+req/);a&&(r.requestType=a[1]);let c=n.match(/@return\s+\[([^\]]+)\]/);c&&(r.responseType=c[1]);let i=n.matchAll(/\b([A-Z][a-zA-Z]+)\.(find|find_by|where|all|first|last|create|joins|includes)\b/g);for(let u of i){let m=u[1];!["Rails","ActiveRecord","GRPC","Visit","Google"].includes(m)&&!r.modelsUsed.includes(m)&&r.modelsUsed.push(m);}let p=n.matchAll(/\b(\w+Service)\.(call|new|perform)\b/g);for(let u of p){let m=u[1];r.servicesUsed.includes(m)||r.servicesUsed.push(m);}return r}getCallArguments(t){let e=t.childForFieldName("arguments");if(!e){let s=[];for(let n=0;n<t.childCount;n++){let r=t.child(n);r&&!["identifier","(",")",",","call"].includes(r.type)&&r!==t.childForFieldName("method")&&r!==t.childForFieldName("receiver")&&s.push(r);}return s}let o=[];for(let s=0;s<e.childCount;s++){let n=e.child(s);n&&n.type!=="("&&n.type!==")"&&n.type!==","&&o.push(n);}return o}};async function ve(){let l=process.argv[2]||process.cwd();console.log(`Analyzing gRPC services in: ${l}`);let e=await new T(l).analyze();if(console.log(`
15
+ `),console.log(`Total models: ${t.models.length}`),console.log(`Total associations: ${t.totalAssociations}`),console.log(`Total validations: ${t.totalValidations}`),console.log(`Shared concerns: ${t.concerns.length}`),console.log(`Namespaces: ${t.namespaces.join(", ")||"(none)"}`),t.errors.length>0){console.log(`
16
+ --- Errors (${t.errors.length}) ---`);for(let a of t.errors.slice(0,5))console.log(` \u274C ${a}`);t.errors.length>5&&console.log(` ... and ${t.errors.length-5} more`);}console.log(`
17
+ --- Sample Models (first 15) ---`);for(let a of t.models.slice(0,15)){if(console.log(`
18
+ \u{1F4E6} ${a.className} (${a.filePath})`),console.log(` Parent: ${a.parentClass}`),a.associations.length>0){let c=a.associations.slice(0,3).map(i=>`${i.type} :${i.name}`);console.log(` Associations: ${c.join(", ")}${a.associations.length>3?"...":""}`);}if(a.validations.length>0&&console.log(` Validations: ${a.validations.length}`),a.scopes.length>0){let c=a.scopes.slice(0,3).map(i=>i.name);console.log(` Scopes: ${c.join(", ")}${a.scopes.length>3?"...":""}`);}if(a.enums.length>0){let c=a.enums.map(i=>`${i.name}(${i.values.length})`);console.log(` Enums: ${c.join(", ")}`);}a.concerns.length>0&&console.log(` Concerns: ${a.concerns.slice(0,3).join(", ")}${a.concerns.length>3?"...":""}`);}let o=t.models.flatMap(a=>a.associations),s=o.filter(a=>a.type==="belongs_to").length,n=o.filter(a=>a.type==="has_many").length,r=o.filter(a=>a.type==="has_one").length;console.log(`
19
+ --- Association Summary ---`),console.log(` belongs_to: ${s}`),console.log(` has_many: ${n}`),console.log(` has_one: ${r}`);}var Re=import.meta.url===`file://${process.argv[1]}`;Re&&xe().catch(console.error);var T=class{constructor(e){this.rootPath=e;this.grpcDir=x.join(e,"app","grpc_services");}grpcDir;services=[];errors=[];async analyze(){if(!G.existsSync(this.grpcDir))return {services:[],totalRpcs:0,namespaces:[],errors:[`gRPC services directory not found at ${this.grpcDir}`]};let e=await glob("**/*_grpc_service.rb",{cwd:this.grpcDir});for(let s of e){let n=x.join(this.grpcDir,s);try{let r=await this.parseServiceFile(n,s);r&&this.services.push(r);}catch(r){this.errors.push(`Error parsing ${s}: ${r}`);}}let t=[...new Set(this.services.filter(s=>s.namespace).map(s=>s.namespace))],o=this.services.reduce((s,n)=>s+n.rpcs.length,0);return {services:this.services,totalRpcs:o,namespaces:t,errors:this.errors}}async parseServiceFile(e,t){let s=(await N(e)).rootNode,n=t.replace(/_grpc_service\.rb$/,"").split("/"),r=n.length>1?n.slice(0,-1).join("/"):void 0,a=n[n.length-1],c=R(s,"class");if(c.length===0)return null;let i=c[0],p=F(i),u=M(i);if(!p)return null;let m={name:a,filePath:t,className:p,parentClass:u||"Unknown",namespace:r,rpcs:[],policies:[],serializers:[],concerns:[],line:i.startPosition.row+1};u&&u.match(/(\w+)::Service$/)&&(m.protoService=u.replace("::Service",""));let d=R(i,"call");for(let h of d)if(h.childForFieldName("method")?.text==="include"){let v=this.getCallArguments(h);for(let C of v)(C.type==="constant"||C.type==="scope_resolution")&&m.concerns.push(C.text);}R(i,"method");let f="public",g=i.childForFieldName("body");if(g)for(let h=0;h<g.childCount;h++){let b=g.child(h);if(b){if(b.type==="identifier"){let v=b.text;v==="private"?f="private":v==="protected"?f="protected":v==="public"&&(f="public");}else if(b.type==="method"&&f==="public"){let v=this.parseRpcMethod(b);if(v){let C=R(b,"call");for(let X of C){let B=X.childForFieldName("method")?.text,P=X.childForFieldName("receiver")?.text;(B==="authorize!"||B==="new")&&P?.includes("Policy")&&(m.policies.includes(P)||m.policies.push(P),v.policyMethod="authorize!"),P?.includes("Serializer")&&B==="new"&&(m.serializers.includes(P)||m.serializers.push(P));}m.rpcs.push(v);}}}}return m}parseRpcMethod(e){let t=U(e);if(!t||["initialize","to_s","inspect","call","perform","execute"].includes(t))return null;Z(e);let n=e.text,r={name:t,line:e.startPosition.row+1,streaming:"none",modelsUsed:[],servicesUsed:[]},a=n.match(/@param\s+\[([^\]]+)\]\s+req/);a&&(r.requestType=a[1]);let c=n.match(/@return\s+\[([^\]]+)\]/);c&&(r.responseType=c[1]);let i=n.matchAll(/\b([A-Z][a-zA-Z]+)\.(find|find_by|where|all|first|last|create|joins|includes)\b/g);for(let u of i){let m=u[1];!["Rails","ActiveRecord","GRPC","Visit","Google"].includes(m)&&!r.modelsUsed.includes(m)&&r.modelsUsed.push(m);}let p=n.matchAll(/\b(\w+Service)\.(call|new|perform)\b/g);for(let u of p){let m=u[1];r.servicesUsed.includes(m)||r.servicesUsed.push(m);}return r}getCallArguments(e){let t=e.childForFieldName("arguments");if(!t){let s=[];for(let n=0;n<e.childCount;n++){let r=e.child(n);r&&!["identifier","(",")",",","call"].includes(r.type)&&r!==e.childForFieldName("method")&&r!==e.childForFieldName("receiver")&&s.push(r);}return s}let o=[];for(let s=0;s<t.childCount;s++){let n=t.child(s);n&&n.type!=="("&&n.type!==")"&&n.type!==","&&o.push(n);}return o}};async function we(){let l=process.argv[2]||process.cwd();console.log(`Analyzing gRPC services in: ${l}`);let t=await new T(l).analyze();if(console.log(`
20
20
  === Rails gRPC Services Analysis ===
21
- `),console.log(`Total services: ${e.services.length}`),console.log(`Total RPCs: ${e.totalRpcs}`),console.log(`Namespaces: ${e.namespaces.join(", ")||"(none)"}`),e.errors.length>0){console.log(`
22
- --- Errors (${e.errors.length}) ---`);for(let n of e.errors.slice(0,5))console.log(` \u274C ${n}`);}console.log(`
23
- --- Sample Services (first 15) ---`);for(let n of e.services.slice(0,15))console.log(`
24
- \u{1F4E1} ${n.className} (${n.filePath})`),console.log(` Proto: ${n.protoService||"unknown"}`),console.log(` RPCs (${n.rpcs.length}): ${n.rpcs.map(r=>r.name).join(", ")}`),n.policies.length>0&&console.log(` Policies: ${n.policies.join(", ")}`),n.serializers.length>0&&console.log(` Serializers: ${n.serializers.join(", ")}`);let o=e.services.flatMap(n=>n.rpcs),s=o.filter(n=>n.modelsUsed.length>0);console.log(`
25
- --- RPC Summary ---`),console.log(` Total RPCs: ${o.length}`),console.log(` RPCs using models: ${s.length}`);}var we=import.meta.url===`file://${process.argv[1]}`;we&&ve().catch(console.error);async function K(l){let t=x.join(l,"app/views"),e=x.join(l,"app/controllers");try{await A.access(t);}catch{return {views:[],pages:[],summary:{totalViews:0,totalPages:0,byController:{},byTemplate:{}}}}let o=await glob("**/*.{haml,erb,html.haml,html.erb,yml}",{cwd:t,nodir:true}),s=[],n={},r={};for(let c of o){let i=await Ae(t,c);i&&(s.push(i),n[i.controller]=(n[i.controller]||0)+1,r[i.template]=(r[i.template]||0)+1);}let a=await _e(e,s,l);return {views:s,pages:a,summary:{totalViews:s.length,totalPages:a.length,byController:n,byTemplate:r}}}async function Ae(l,t){let e=x.join(l,t);try{let o=await A.readFile(e,"utf-8"),s=t.split("/");if(s.some(g=>g.endsWith("_mailer")||g==="layouts"||g==="shared"||g==="devise"))return null;let n=s.pop()||"",r=s.join("/")||"application",a=n.split("."),c=a[0].replace(/^_/,""),i=n.startsWith("_"),p;n.endsWith(".yml")?p="yml":n.endsWith(".haml")?p="haml":n.endsWith(".erb")?p="erb":p="other";let u=a.length>2?a[1]:"html";if(i)return null;let m=[],d=[],y=[],f=[];return p==="yml"?(y=$e(o),f=[{name:"App",ssr:!0,propsVar:"@yml_data"}]):(m=Ce(o,p),d=Ne(o,p),y=Pe(o),f=Se(o,p)),{name:c,path:t,controller:r,action:c,format:u,template:p,partials:m,helpers:d,instanceVars:y,reactComponents:f}}catch{return null}}function Ce(l,t){let e=[];if(t==="haml"){let o=l.matchAll(/=\s*render\s+(?:partial:\s*)?['"]([^'"]+)['"]/g);for(let s of o)e.push(s[1]);}else if(t==="erb"){let o=l.matchAll(/<%=?\s*render\s+(?:partial:\s*)?['"]([^'"]+)['"]/g);for(let s of o)e.push(s[1]);}return [...new Set(e)]}function Ne(l,t){let e=[],o=/\b(link_to|form_for|form_with|image_tag|content_for|yield|render|t|l|raw|html_safe|simple_form_for)\b/g,s=l.matchAll(o);for(let n of s)e.push(n[1]);return [...new Set(e)]}function Se(l,t){let e=[],o=/render_react_component\s*\(?\s*["']([^"']+)["'](?:,\s*\{[^}]*\})?\s*(?:,\s*ssr:\s*(true|false))?\)?/g,s;for(;(s=o.exec(l))!==null;)e.push({name:s[1],ssr:s[2]==="true"});let n=/data:\s*\{\s*react_component:\s*["']([^"']+)["'](?:,\s*react_component_props:\s*(@?\w+)(?:\.to_json)?)?/g;for(;(s=n.exec(l))!==null;)e.push({name:s[1],propsVar:s[2],ssr:false});let r=/ReactComponent\s+name=["']([^"']+)["']/g;for(;(s=r.exec(l))!==null;)e.push({name:s[1],ssr:false});let a=new Set;return e.filter(c=>a.has(c.name)?false:(a.add(c.name),true))}function $e(l){let t=[],e=l.split(`
26
- `);for(let o of e){let s=o.match(/^([a-z_]+):/);s&&!s[1].startsWith("_")&&t.push(s[1]);let n=o.match(/^\s+-\s+(\w+)/);n&&t.push(n[1]);}return [...new Set(t)].slice(0,50)}function Pe(l){let t=[],e=l.matchAll(/@(\w+)/g);for(let o of e)["import","media","keyframes","charset"].includes(o[1])||t.push(o[1]);return [...new Set(t)]}async function _e(l,t,e){let o=[];try{await A.access(l);}catch{return o}let s=await glob("**/*_controller.rb",{cwd:l,nodir:true}),n=await Fe(e);for(let r of s){let a=x.join(l,r),c=await A.readFile(a,"utf-8"),i=r.replace(/_controller\.rb$/,"").replace(/\//g,"/"),p=Me(c,i,r,t,n);o.push(...p);}return o}async function Fe(l){let t=new Map;try{let e=x.join(l,".repomap","rails-routes.json"),o=await A.readFile(e,"utf-8"),s=JSON.parse(o);for(let n of s){let r=`${n.controller}#${n.action}`;t.set(r,{path:n.path,method:n.method});}}catch{}return t}function Me(l,t,e,o,s){let n=[],r=l.split(/\n\s*(private|protected)\b/)[0],a=/def\s+(\w+)/g,c;for(;(c=a.exec(r))!==null;){let i=c[1];["initialize","new","create","update","destroy","index","show","edit"].includes(i)||i.startsWith("set_")||i.startsWith("_");let p=c.index,u=Ie(r,p),m=ke(u,e),d=Ve(u),y=je(u),f=Te(u),g=o.find(v=>v.controller===t&&v.action===i),h=`${t}#${i}`,b=s.get(h);n.push({route:b?.path||`/${t}/${i}`,method:b?.method||"GET",controller:t,action:i,view:g,apis:m,services:d,grpcCalls:y,modelAccess:f});}return n}function Ie(l,t){let e=0,o=false,s="";for(let n=t;n<l.length;n++){let r=l.slice(n,l.indexOf(`
27
- `,n)+1||l.length);if(r.match(/^\s*(def|class|module|if|unless|case|while|until|for|begin|do)\b/)&&(e++,o=true),r.match(/^\s*end\b/)&&(e--,o&&e===0)||(s+=r,n=l.indexOf(`
28
- `,n),n===-1))break}return s}function ke(l,t){let e=[],o=[/HTTPClient\.(get|post|put|patch|delete)\s*\(\s*['"]([^'"]+)['"]/gi,/RestClient\.(get|post|put|patch|delete)\s*\(\s*['"]([^'"]+)['"]/gi,/Faraday\.(get|post|put|patch|delete)\s*\(\s*['"]([^'"]+)['"]/gi,/Net::HTTP\.(get|post)\s*\(/gi];for(let s of o){let n;for(;(n=s.exec(l))!==null;)e.push({type:"http",name:n[2]||"HTTP call",method:n[1]?.toUpperCase(),source:t});}return e}function Ve(l){let t=[],e=/(\w+(?:::\w+)*Service)\.(?:call!?|new)/g,o;for(;(o=e.exec(l))!==null;)t.push(o[1]);return [...new Set(t)]}function je(l){let t=[],e=[/(\w+(?:::\w+)*Grpc(?:::\w+)?)\./g,/Grpc::(\w+(?:::\w+)*)/g,/(\w+GrpcService)\./g];for(let o of e){let s;for(;(s=o.exec(l))!==null;)t.push(s[1]);}return [...new Set(t)]}function Te(l){let t=[],e=/([A-Z][a-zA-Z0-9]+)\.(?:find|where|find_by|first|last|all|create|update|destroy|new)/g,o;for(;(o=e.exec(l))!==null;)["File","Dir","Time","Date","DateTime","JSON","YAML","CSV","Logger"].includes(o[1])||t.push(o[1]);return [...new Set(t)]}var ze=["app/javascript/packs","app/javascript/entrypoints","app/frontend/entrypoints","app/javascript/application","frontend/assets/javascripts/entries","frontend/entries","app/assets/javascripts/entries","client/entries","src/entries"],Ee=["app/javascript/components","app/javascript/react","app/javascript/src/components","app/javascript/bundles","app/frontend/components","app/frontend/react","frontend/assets/javascripts/react","frontend/assets/javascripts/components","frontend/src","frontend/src/components","frontend/components","client/components","src/components"],E={dataReactComponent:/react_component:\s*["']([A-Za-z0-9_/]+)["']/g,renderReactComponent:/render_react_component\s*\(?\s*["']([A-Za-z0-9_/]+)["']/g,reactComponent:/<%=?\s*react_component\s*\(\s*["']([A-Za-z0-9_/]+)["']/g,reduxStore:/<%=?\s*redux_store\s*\(\s*["']([A-Za-z0-9_/]+)["']/g,dataComponent:/data-component\s*[=:]\s*["']([A-Za-z0-9_/]+)["']/g,dataReactClass:/data-react-class\s*[=:]\s*["']([A-Za-z0-9_/]+)["']/g};async function Q(l){let t=new Map,e=[],o=await De(l);console.log(` \u{1F4C2} Detected paths: ${o.entryDirs.length} entry dirs, ${o.componentDirs.length} component dirs (${o.integrationPattern})`);for(let a of o.entryDirs){let c=x.join(l,a);try{await A.access(c);let i=await glob("**/*.{tsx,ts,jsx,js}",{cwd:c,nodir:!0,ignore:["**/*.d.ts","**/*.test.*","**/*.spec.*"]});for(let p of i){let u=await Ue(x.join(c,p),p,a);if(u&&(e.push(u),u.componentName)){let m=t.get(u.componentName);m?(m.entryFile=x.join(a,p),m.importPath=u.imports[0]):t.set(u.componentName,{name:u.componentName,entryFile:x.join(a,p),importPath:u.imports[0],ssr:!1,usedIn:[]});}}}catch{}}let s=x.join(l,"app/views");try{await A.access(s);let a=await glob("**/*.{haml,erb,html.haml,html.erb,slim}",{cwd:s,nodir:!0});for(let c of a){let i=await Ze(x.join(s,c),c);for(let p of i){let u=t.get(p.componentName);u?(u.usedIn.push({viewPath:c,controller:p.controller,action:p.action,propsVar:p.propsVar,line:p.line,pattern:p.pattern}),p.ssr&&(u.ssr=!0)):t.set(p.componentName,{name:p.componentName,ssr:p.ssr,usedIn:[{viewPath:c,controller:p.controller,action:p.action,propsVar:p.propsVar,line:p.line,pattern:p.pattern}]});}}}catch{}await Be(l,t,o.componentDirs);let n=Array.from(t.values()),r=n.filter(a=>a.ssr).length;return {components:n,entryPoints:e,detectedPaths:o,summary:{totalComponents:n.length,totalEntryPoints:e.length,ssrComponents:r,clientComponents:n.length-r}}}async function De(l){let t=[],e=[],o="unknown";for(let s of ze){let n=x.join(l,s);try{(await A.stat(n)).isDirectory()&&t.push(s);}catch{}}for(let s of Ee){let n=x.join(l,s);try{(await A.stat(n)).isDirectory()&&e.push(s);}catch{}}if(o=await Ge(l),t.length===0){let s=await Le(l);t.push(...s);}return e.length===0&&t.length>0&&e.push(...t),{entryDirs:t,componentDirs:e,integrationPattern:o}}async function Ge(l){try{let t=x.join(l,"Gemfile"),e=await A.readFile(t,"utf-8");if(e.includes("react_on_rails"))return "react_on_rails";if(e.includes("react-rails"))return "react-rails";if(e.includes("vite_rails")||e.includes("vite_ruby"))return "vite";if(e.includes("webpacker"))return "webpacker";try{return await A.access(x.join(l,"vite.config.ts")),"vite"}catch{}try{return await A.access(x.join(l,"vite.config.js")),"vite"}catch{}return "custom"}catch{return "unknown"}}async function Le(l){let t=[],e=["app/**/entries","app/**/packs","frontend/**/entries","client/**/entries","src/**/entries"];for(let o of e)try{let s=await glob(o,{cwd:l,nodir:!1});for(let n of s){let r=x.join(l,n);try{(await A.stat(r)).isDirectory()&&t.push(n);}catch{}}}catch{}return t}async function Ue(l,t,e){try{let o=await A.readFile(l,"utf-8"),s=[/\[data-react-component[=:][\s]*["']?([A-Za-z0-9_]+)["']?\]/,/\[data-component[=:][\s]*["']?([A-Za-z0-9_]+)["']?\]/,/\[data-react-class[=:][\s]*["']?([A-Za-z0-9_]+)["']?\]/,/getElementById\s*\(\s*["']([A-Za-z0-9_-]+)["']\s*\)/,/querySelector\s*\(\s*["']#([A-Za-z0-9_-]+)["']\s*\)/],n=null,r;for(let p of s){let u=o.match(p);if(u){n=u[1],r=u[0];break}}n||(n=x.basename(t,x.extname(t)).split(/[-_]/).map(u=>u.charAt(0).toUpperCase()+u.slice(1)).join(""));let a=[],c=o.matchAll(/import\s+(?:\{[^}]+\}|\*\s+as\s+\w+|\w+)\s+from\s+["']([^"']+)["']/g);for(let p of c){let u=p[1];(u.includes("/react/")||u.includes("/components/")||u.includes("/containers/")||u.includes("/bundles/")||u.includes("/pages/")||u.match(/\/[A-Z][a-zA-Z0-9]*/))&&a.push(u);}let i=o.matchAll(/require\s*\(\s*["']([^"']+)["']\s*\)/g);for(let p of i){let u=p[1];(u.includes("/react/")||u.includes("/components/")||u.includes("/containers/"))&&a.push(u);}return !n&&a.length===0?null:{file:t,fullPath:x.join(e,t),componentName:n||"",imports:a,selector:r}}catch{return null}}async function Ze(l,t){let e=[];try{let s=(await A.readFile(l,"utf-8")).split(`
29
- `),n=t.split("/"),r=n.pop()||"",a=n.join("/")||"application",c=r.split(".")[0].replace(/^_/,""),i=0;for(let p of s){i++;let u=p.matchAll(E.dataReactComponent);for(let h of u){let b=p.match(/react_component_props:\s*(@?\w+(?:\.\w+)*)/);e.push({componentName:h[1],controller:a,action:c,propsVar:b?b[1]:void 0,line:i,pattern:"data-react-component",ssr:!1});}let m=p.match(E.renderReactComponent);if(m){let h=p.match(/ssr:\s*(true|false|@\w+)/);e.push({componentName:m[1],controller:a,action:c,line:i,pattern:"render_react_component",ssr:h?h[1]==="true"||h[1].startsWith("@"):!1});}let d=p.match(E.reactComponent);if(d){let h=p.match(/props:\s*(@?\w+(?:\.\w+)*)/),b=p.match(/prerender:\s*(true|false)/);e.push({componentName:d[1],controller:a,action:c,propsVar:h?h[1]:void 0,line:i,pattern:"react_component",ssr:b?b[1]==="true":!1});}let y=p.match(E.reduxStore);y&&e.push({componentName:y[1],controller:a,action:c,line:i,pattern:"redux_store",ssr:!1});let f=p.match(E.dataComponent);f&&e.push({componentName:f[1],controller:a,action:c,line:i,pattern:"data-react-component",ssr:!1});let g=p.match(E.dataReactClass);g&&e.push({componentName:g[1],controller:a,action:c,line:i,pattern:"data-react-component",ssr:!1});}}catch{}return e}async function Be(l,t,e){for(let[o,s]of t)if(!(!o||typeof o!="string")){if(s.importPath&&typeof s.importPath=="string"){let n=s.importPath.replace(/\.js$/,"").replace(/\.tsx?$/,"").replace(/^\.\.\//,"").replace(/^\.\//,"");s.sourceFile=n;}else if(!s.sourceFile){let n=[".tsx",".ts",".jsx",".js"],r=[o,Oe(o),We(o)].filter(Boolean),a=false;for(let c of e){if(a)break;for(let i of r){if(a)break;for(let p of n){let u=[x.join(l,c,i,`index${p}`),x.join(l,c,i,`${i}${p}`),x.join(l,c,`${i}${p}`),x.join(l,c,"components",`${i}${p}`),x.join(l,c,"containers",`${i}${p}`)];for(let m of u)try{await A.access(m),s.sourceFile=x.relative(l,m),a=!0;break}catch{}}}}}}}function Oe(l){return l?l.replace(/([A-Z])/g,"_$1").toLowerCase().replace(/^_/,""):""}function We(l){return l?l.replace(/([A-Z])/g,"-$1").toLowerCase().replace(/^-/,""):""}async function He(l){console.log(`
21
+ `),console.log(`Total services: ${t.services.length}`),console.log(`Total RPCs: ${t.totalRpcs}`),console.log(`Namespaces: ${t.namespaces.join(", ")||"(none)"}`),t.errors.length>0){console.log(`
22
+ --- Errors (${t.errors.length}) ---`);for(let n of t.errors.slice(0,5))console.log(` \u274C ${n}`);}console.log(`
23
+ --- Sample Services (first 15) ---`);for(let n of t.services.slice(0,15))console.log(`
24
+ \u{1F4E1} ${n.className} (${n.filePath})`),console.log(` Proto: ${n.protoService||"unknown"}`),console.log(` RPCs (${n.rpcs.length}): ${n.rpcs.map(r=>r.name).join(", ")}`),n.policies.length>0&&console.log(` Policies: ${n.policies.join(", ")}`),n.serializers.length>0&&console.log(` Serializers: ${n.serializers.join(", ")}`);let o=t.services.flatMap(n=>n.rpcs),s=o.filter(n=>n.modelsUsed.length>0);console.log(`
25
+ --- RPC Summary ---`),console.log(` Total RPCs: ${o.length}`),console.log(` RPCs using models: ${s.length}`);}var Ae=import.meta.url===`file://${process.argv[1]}`;Ae&&we().catch(console.error);async function K(l){let e=x.join(l,"app/views"),t=x.join(l,"app/controllers");try{await A.access(e);}catch{return {views:[],pages:[],summary:{totalViews:0,totalPages:0,byController:{},byTemplate:{}}}}let o=await glob("**/*.{haml,erb,html.haml,html.erb,yml}",{cwd:e,nodir:true}),s=[],n={},r={};for(let c of o){let i=await Ce(e,c);i&&(s.push(i),n[i.controller]=(n[i.controller]||0)+1,r[i.template]=(r[i.template]||0)+1);}let a=await Fe(t,s,l);return {views:s,pages:a,summary:{totalViews:s.length,totalPages:a.length,byController:n,byTemplate:r}}}async function Ce(l,e){let t=x.join(l,e);try{let o=await A.readFile(t,"utf-8"),s=e.split("/");if(s.some(g=>g.endsWith("_mailer")||g==="layouts"||g==="shared"||g==="devise"))return null;let n=s.pop()||"",r=s.join("/")||"application",a=n.split("."),c=a[0].replace(/^_/,""),i=n.startsWith("_"),p;n.endsWith(".yml")?p="yml":n.endsWith(".haml")?p="haml":n.endsWith(".erb")?p="erb":p="other";let u=a.length>2?a[1]:"html";if(i)return null;let m=[],d=[],y=[],f=[];return p==="yml"?(y=Pe(o),f=[{name:"App",ssr:!0,propsVar:"@yml_data"}]):(m=Ne(o,p),d=Se(o,p),y=_e(o),f=$e(o,p)),{name:c,path:e,controller:r,action:c,format:u,template:p,partials:m,helpers:d,instanceVars:y,reactComponents:f}}catch{return null}}function Ne(l,e){let t=[];if(e==="haml"){let o=l.matchAll(/=\s*render\s+(?:partial:\s*)?['"]([^'"]+)['"]/g);for(let s of o)t.push(s[1]);}else if(e==="erb"){let o=l.matchAll(/<%=?\s*render\s+(?:partial:\s*)?['"]([^'"]+)['"]/g);for(let s of o)t.push(s[1]);}return [...new Set(t)]}function Se(l,e){let t=[],o=/\b(link_to|form_for|form_with|image_tag|content_for|yield|render|t|l|raw|html_safe|simple_form_for)\b/g,s=l.matchAll(o);for(let n of s)t.push(n[1]);return [...new Set(t)]}function $e(l,e){let t=[],o=/render_react_component\s*\(?\s*["']([^"']+)["'](?:,\s*\{[^}]*\})?\s*(?:,\s*ssr:\s*(true|false))?\)?/g,s;for(;(s=o.exec(l))!==null;)t.push({name:s[1],ssr:s[2]==="true"});let n=/data:\s*\{\s*react_component:\s*["']([^"']+)["'](?:,\s*react_component_props:\s*(@?\w+)(?:\.to_json)?)?/g;for(;(s=n.exec(l))!==null;)t.push({name:s[1],propsVar:s[2],ssr:false});let r=/ReactComponent\s+name=["']([^"']+)["']/g;for(;(s=r.exec(l))!==null;)t.push({name:s[1],ssr:false});let a=new Set;return t.filter(c=>a.has(c.name)?false:(a.add(c.name),true))}function Pe(l){let e=[],t=l.split(`
26
+ `);for(let o of t){let s=o.match(/^([a-z_]+):/);s&&!s[1].startsWith("_")&&e.push(s[1]);let n=o.match(/^\s+-\s+(\w+)/);n&&e.push(n[1]);}return [...new Set(e)].slice(0,50)}function _e(l){let e=[],t=l.matchAll(/@(\w+)/g);for(let o of t)["import","media","keyframes","charset"].includes(o[1])||e.push(o[1]);return [...new Set(e)]}async function Fe(l,e,t){let o=[];try{await A.access(l);}catch{return o}let s=await glob("**/*_controller.rb",{cwd:l,nodir:true}),n=await Me(t);for(let r of s){let a=x.join(l,r),c=await A.readFile(a,"utf-8"),i=r.replace(/_controller\.rb$/,"").replace(/\//g,"/"),p=Ie(c,i,r,e,n);o.push(...p);}return o}async function Me(l){let e=new Map;try{let t=x.join(l,".repomap","rails-routes.json"),o=await A.readFile(t,"utf-8"),s=JSON.parse(o);for(let n of s){let r=`${n.controller}#${n.action}`;e.set(r,{path:n.path,method:n.method});}}catch{}return e}function Ie(l,e,t,o,s){let n=[],r=l.split(/\n\s*(private|protected)\b/)[0],a=/def\s+(\w+)/g,c;for(;(c=a.exec(r))!==null;){let i=c[1];["initialize","new","create","update","destroy","index","show","edit"].includes(i)||i.startsWith("set_")||i.startsWith("_");let p=c.index,u=ke(r,p),m=Ve(u,t),d=je(u),y=Te(u),f=ze(u),g=o.find(v=>v.controller===e&&v.action===i),h=`${e}#${i}`,b=s.get(h);n.push({route:b?.path||`/${e}/${i}`,method:b?.method||"GET",controller:e,action:i,view:g,apis:m,services:d,grpcCalls:y,modelAccess:f});}return n}function ke(l,e){let t=0,o=false,s="";for(let n=e;n<l.length;n++){let r=l.slice(n,l.indexOf(`
27
+ `,n)+1||l.length);if(r.match(/^\s*(def|class|module|if|unless|case|while|until|for|begin|do)\b/)&&(t++,o=true),r.match(/^\s*end\b/)&&(t--,o&&t===0)||(s+=r,n=l.indexOf(`
28
+ `,n),n===-1))break}return s}function Ve(l,e){let t=[],o=[/HTTPClient\.(get|post|put|patch|delete)\s*\(\s*['"]([^'"]+)['"]/gi,/RestClient\.(get|post|put|patch|delete)\s*\(\s*['"]([^'"]+)['"]/gi,/Faraday\.(get|post|put|patch|delete)\s*\(\s*['"]([^'"]+)['"]/gi,/Net::HTTP\.(get|post)\s*\(/gi];for(let s of o){let n;for(;(n=s.exec(l))!==null;)t.push({type:"http",name:n[2]||"HTTP call",method:n[1]?.toUpperCase(),source:e});}return t}function je(l){let e=[],t=/(\w+(?:::\w+)*Service)\.(?:call!?|new)/g,o;for(;(o=t.exec(l))!==null;)e.push(o[1]);return [...new Set(e)]}function Te(l){let e=[],t=[/(\w+(?:::\w+)*Grpc(?:::\w+)?)\./g,/Grpc::(\w+(?:::\w+)*)/g,/(\w+GrpcService)\./g];for(let o of t){let s;for(;(s=o.exec(l))!==null;)e.push(s[1]);}return [...new Set(e)]}function ze(l){let e=[],t=/([A-Z][a-zA-Z0-9]+)\.(?:find|where|find_by|first|last|all|create|update|destroy|new)/g,o;for(;(o=t.exec(l))!==null;)["File","Dir","Time","Date","DateTime","JSON","YAML","CSV","Logger"].includes(o[1])||e.push(o[1]);return [...new Set(e)]}var Ee=["app/javascript/packs","app/javascript/entrypoints","app/frontend/entrypoints","app/javascript/application","frontend/assets/javascripts/entries","frontend/entries","app/assets/javascripts/entries","client/entries","src/entries"],De=["app/javascript/components","app/javascript/react","app/javascript/src/components","app/javascript/bundles","app/frontend/components","app/frontend/react","frontend/assets/javascripts/react","frontend/assets/javascripts/components","frontend/src","frontend/src/components","frontend/components","client/components","src/components"],E={dataReactComponent:/react_component:\s*["']([A-Za-z0-9_/]+)["']/g,renderReactComponent:/render_react_component\s*\(?\s*["']([A-Za-z0-9_/]+)["']/g,reactComponent:/<%=?\s*react_component\s*\(\s*["']([A-Za-z0-9_/]+)["']/g,reduxStore:/<%=?\s*redux_store\s*\(\s*["']([A-Za-z0-9_/]+)["']/g,dataComponent:/data-component\s*[=:]\s*["']([A-Za-z0-9_/]+)["']/g,dataReactClass:/data-react-class\s*[=:]\s*["']([A-Za-z0-9_/]+)["']/g};async function Q(l){let e=new Map,t=[],o=await Ge(l);console.log(` \u{1F4C2} Detected paths: ${o.entryDirs.length} entry dirs, ${o.componentDirs.length} component dirs (${o.integrationPattern})`);for(let a of o.entryDirs){let c=x.join(l,a);try{await A.access(c);let i=await glob("**/*.{tsx,ts,jsx,js}",{cwd:c,nodir:!0,ignore:["**/*.d.ts","**/*.test.*","**/*.spec.*"]});for(let p of i){let u=await Ze(x.join(c,p),p,a);if(u&&(t.push(u),u.componentName)){let m=e.get(u.componentName);m?(m.entryFile=x.join(a,p),m.importPath=u.imports[0]):e.set(u.componentName,{name:u.componentName,entryFile:x.join(a,p),importPath:u.imports[0],ssr:!1,usedIn:[]});}}}catch{}}let s=x.join(l,"app/views");try{await A.access(s);let a=await glob("**/*.{haml,erb,html.haml,html.erb,slim}",{cwd:s,nodir:!0});for(let c of a){let i=await Be(x.join(s,c),c);for(let p of i){let u=e.get(p.componentName);u?(u.usedIn.push({viewPath:c,controller:p.controller,action:p.action,propsVar:p.propsVar,line:p.line,pattern:p.pattern}),p.ssr&&(u.ssr=!0)):e.set(p.componentName,{name:p.componentName,ssr:p.ssr,usedIn:[{viewPath:c,controller:p.controller,action:p.action,propsVar:p.propsVar,line:p.line,pattern:p.pattern}]});}}}catch{}await Oe(l,e,o.componentDirs);let n=Array.from(e.values()),r=n.filter(a=>a.ssr).length;return {components:n,entryPoints:t,detectedPaths:o,summary:{totalComponents:n.length,totalEntryPoints:t.length,ssrComponents:r,clientComponents:n.length-r}}}async function Ge(l){let e=[],t=[],o="unknown";for(let s of Ee){let n=x.join(l,s);try{(await A.stat(n)).isDirectory()&&e.push(s);}catch{}}for(let s of De){let n=x.join(l,s);try{(await A.stat(n)).isDirectory()&&t.push(s);}catch{}}if(o=await Le(l),e.length===0){let s=await Ue(l);e.push(...s);}return t.length===0&&e.length>0&&t.push(...e),{entryDirs:e,componentDirs:t,integrationPattern:o}}async function Le(l){try{let e=x.join(l,"Gemfile"),t=await A.readFile(e,"utf-8");if(t.includes("react_on_rails"))return "react_on_rails";if(t.includes("react-rails"))return "react-rails";if(t.includes("vite_rails")||t.includes("vite_ruby"))return "vite";if(t.includes("webpacker"))return "webpacker";try{return await A.access(x.join(l,"vite.config.ts")),"vite"}catch{}try{return await A.access(x.join(l,"vite.config.js")),"vite"}catch{}return "custom"}catch{return "unknown"}}async function Ue(l){let e=[],t=["app/**/entries","app/**/packs","frontend/**/entries","client/**/entries","src/**/entries"];for(let o of t)try{let s=await glob(o,{cwd:l,nodir:!1});for(let n of s){let r=x.join(l,n);try{(await A.stat(r)).isDirectory()&&e.push(n);}catch{}}}catch{}return e}async function Ze(l,e,t){try{let o=await A.readFile(l,"utf-8"),s=[/\[data-react-component[=:][\s]*["']?([A-Za-z0-9_]+)["']?\]/,/\[data-component[=:][\s]*["']?([A-Za-z0-9_]+)["']?\]/,/\[data-react-class[=:][\s]*["']?([A-Za-z0-9_]+)["']?\]/,/getElementById\s*\(\s*["']([A-Za-z0-9_-]+)["']\s*\)/,/querySelector\s*\(\s*["']#([A-Za-z0-9_-]+)["']\s*\)/],n=null,r;for(let p of s){let u=o.match(p);if(u){n=u[1],r=u[0];break}}n||(n=x.basename(e,x.extname(e)).split(/[-_]/).map(u=>u.charAt(0).toUpperCase()+u.slice(1)).join(""));let a=[],c=o.matchAll(/import\s+(?:\{[^}]+\}|\*\s+as\s+\w+|\w+)\s+from\s+["']([^"']+)["']/g);for(let p of c){let u=p[1];(u.includes("/react/")||u.includes("/components/")||u.includes("/containers/")||u.includes("/bundles/")||u.includes("/pages/")||u.match(/\/[A-Z][a-zA-Z0-9]*/))&&a.push(u);}let i=o.matchAll(/require\s*\(\s*["']([^"']+)["']\s*\)/g);for(let p of i){let u=p[1];(u.includes("/react/")||u.includes("/components/")||u.includes("/containers/"))&&a.push(u);}return !n&&a.length===0?null:{file:e,fullPath:x.join(t,e),componentName:n||"",imports:a,selector:r}}catch{return null}}async function Be(l,e){let t=[];try{let s=(await A.readFile(l,"utf-8")).split(`
29
+ `),n=e.split("/"),r=n.pop()||"",a=n.join("/")||"application",c=r.split(".")[0].replace(/^_/,""),i=0;for(let p of s){i++;let u=p.matchAll(E.dataReactComponent);for(let h of u){let b=p.match(/react_component_props:\s*(@?\w+(?:\.\w+)*)/);t.push({componentName:h[1],controller:a,action:c,propsVar:b?b[1]:void 0,line:i,pattern:"data-react-component",ssr:!1});}let m=p.match(E.renderReactComponent);if(m){let h=p.match(/ssr:\s*(true|false|@\w+)/);t.push({componentName:m[1],controller:a,action:c,line:i,pattern:"render_react_component",ssr:h?h[1]==="true"||h[1].startsWith("@"):!1});}let d=p.match(E.reactComponent);if(d){let h=p.match(/props:\s*(@?\w+(?:\.\w+)*)/),b=p.match(/prerender:\s*(true|false)/);t.push({componentName:d[1],controller:a,action:c,propsVar:h?h[1]:void 0,line:i,pattern:"react_component",ssr:b?b[1]==="true":!1});}let y=p.match(E.reduxStore);y&&t.push({componentName:y[1],controller:a,action:c,line:i,pattern:"redux_store",ssr:!1});let f=p.match(E.dataComponent);f&&t.push({componentName:f[1],controller:a,action:c,line:i,pattern:"data-react-component",ssr:!1});let g=p.match(E.dataReactClass);g&&t.push({componentName:g[1],controller:a,action:c,line:i,pattern:"data-react-component",ssr:!1});}}catch{}return t}async function Oe(l,e,t){for(let[o,s]of e)if(!(!o||typeof o!="string")){if(s.importPath&&typeof s.importPath=="string"){let n=s.importPath.replace(/\.js$/,"").replace(/\.tsx?$/,"").replace(/^\.\.\//,"").replace(/^\.\//,"");s.sourceFile=n;}else if(!s.sourceFile){let n=[".tsx",".ts",".jsx",".js"],r=[o,We(o),He(o)].filter(Boolean),a=false;for(let c of t){if(a)break;for(let i of r){if(a)break;for(let p of n){let u=[x.join(l,c,i,`index${p}`),x.join(l,c,i,`${i}${p}`),x.join(l,c,`${i}${p}`),x.join(l,c,"components",`${i}${p}`),x.join(l,c,"containers",`${i}${p}`)];for(let m of u)try{await A.access(m),s.sourceFile=x.relative(l,m),a=!0;break}catch{}}}}}}}function We(l){return l?l.replace(/([A-Z])/g,"_$1").toLowerCase().replace(/^_/,""):""}function He(l){return l?l.replace(/([A-Z])/g,"-$1").toLowerCase().replace(/^-/,""):""}async function qe(l){console.log(`
30
30
  \u{1F4E6} Analyzing Rails application at: ${l}
31
- `),console.log("\u{1F504} Analyzing routes...");let e=await new k(l).analyze();console.log(` \u2705 Found ${e.routes.length} routes`),console.log("\u{1F504} Analyzing controllers...");let s=await new V(l).analyze();console.log(` \u2705 Found ${s.controllers.length} controllers with ${s.totalActions} actions`),console.log("\u{1F504} Analyzing models...");let r=await new j(l).analyze();console.log(` \u2705 Found ${r.models.length} models with ${r.totalAssociations} associations`),console.log("\u{1F504} Analyzing gRPC services...");let c=await new T(l).analyze();console.log(` \u2705 Found ${c.services.length} gRPC services with ${c.totalRpcs} RPCs`),console.log("\u{1F504} Analyzing views...");let i=await K(l);console.log(` \u2705 Found ${i.summary.totalViews} views and ${i.summary.totalPages} pages`),console.log("\u{1F504} Analyzing React components...");let p=await Q(l);console.log(` \u2705 Found ${p.summary.totalComponents} React components (${p.summary.ssrComponents} SSR, ${p.summary.clientComponents} client)`);let u=[...new Set([...e.namespaces,...s.namespaces,...r.namespaces,...c.namespaces])],m=[...new Set([...s.concerns,...r.concerns])],d={totalRoutes:e.routes.length,totalControllers:s.controllers.length,totalActions:s.totalActions,totalModels:r.models.length,totalAssociations:r.totalAssociations,totalValidations:r.totalValidations,totalGrpcServices:c.services.length,totalRpcs:c.totalRpcs,totalViews:i.summary.totalViews,totalPages:i.summary.totalPages,totalReactComponents:p.summary.totalComponents,ssrReactComponents:p.summary.ssrComponents,namespaces:u,concerns:m};return {routes:e,controllers:s,models:r,grpc:c,views:i,react:p,summary:d}}async function qe(){let l=process.argv[2]||process.cwd(),t=await He(l);console.log(`
31
+ `),console.log("\u{1F504} Analyzing routes...");let t=await new k(l).analyze();console.log(` \u2705 Found ${t.routes.length} routes`),console.log("\u{1F504} Analyzing controllers...");let s=await new V(l).analyze();console.log(` \u2705 Found ${s.controllers.length} controllers with ${s.totalActions} actions`),console.log("\u{1F504} Analyzing models...");let r=await new j(l).analyze();console.log(` \u2705 Found ${r.models.length} models with ${r.totalAssociations} associations`),console.log("\u{1F504} Analyzing gRPC services...");let c=await new T(l).analyze();console.log(` \u2705 Found ${c.services.length} gRPC services with ${c.totalRpcs} RPCs`),console.log("\u{1F504} Analyzing views...");let i=await K(l);console.log(` \u2705 Found ${i.summary.totalViews} views and ${i.summary.totalPages} pages`),console.log("\u{1F504} Analyzing React components...");let p=await Q(l);console.log(` \u2705 Found ${p.summary.totalComponents} React components (${p.summary.ssrComponents} SSR, ${p.summary.clientComponents} client)`);let u=[...new Set([...t.namespaces,...s.namespaces,...r.namespaces,...c.namespaces])],m=[...new Set([...s.concerns,...r.concerns])],d={totalRoutes:t.routes.length,totalControllers:s.controllers.length,totalActions:s.totalActions,totalModels:r.models.length,totalAssociations:r.totalAssociations,totalValidations:r.totalValidations,totalGrpcServices:c.services.length,totalRpcs:c.totalRpcs,totalViews:i.summary.totalViews,totalPages:i.summary.totalPages,totalReactComponents:p.summary.totalComponents,ssrReactComponents:p.summary.ssrComponents,namespaces:u,concerns:m};return {routes:t,controllers:s,models:r,grpc:c,views:i,react:p,summary:d}}async function Je(){let l=process.argv[2]||process.cwd(),e=await qe(l);console.log(`
32
32
  `+"=".repeat(60)),console.log("\u{1F4CA} RAILS APPLICATION ANALYSIS SUMMARY"),console.log("=".repeat(60)+`
33
- `),console.log("\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510"),console.log("\u2502 Routes \u2502"),console.log("\u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524"),console.log(`\u2502 Total routes: ${String(t.summary.totalRoutes).padStart(6)} \u2502`),console.log(`\u2502 Resources: ${String(t.routes.resources.length).padStart(6)} \u2502`),console.log(`\u2502 Mounted engines: ${String(t.routes.mountedEngines.length).padStart(6)} \u2502`),console.log(`\u2502 External files: ${String(t.routes.drawnFiles.length).padStart(6)} \u2502`),console.log("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518"),console.log("\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510"),console.log("\u2502 Controllers \u2502"),console.log("\u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524"),console.log(`\u2502 Total controllers: ${String(t.summary.totalControllers).padStart(6)} \u2502`),console.log(`\u2502 Total actions: ${String(t.summary.totalActions).padStart(6)} \u2502`),console.log(`\u2502 Namespaces: ${String(t.controllers.namespaces.length).padStart(6)} \u2502`),console.log("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518"),console.log("\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510"),console.log("\u2502 Models \u2502"),console.log("\u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524"),console.log(`\u2502 Total models: ${String(t.summary.totalModels).padStart(6)} \u2502`),console.log(`\u2502 Associations: ${String(t.summary.totalAssociations).padStart(6)} \u2502`),console.log(`\u2502 Validations: ${String(t.summary.totalValidations).padStart(6)} \u2502`),console.log("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518"),console.log("\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510"),console.log("\u2502 gRPC Services \u2502"),console.log("\u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524"),console.log(`\u2502 Total services: ${String(t.summary.totalGrpcServices).padStart(6)} \u2502`),console.log(`\u2502 Total RPCs: ${String(t.summary.totalRpcs).padStart(6)} \u2502`),console.log("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518"),console.log("\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510"),console.log("\u2502 Shared \u2502"),console.log("\u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524"),console.log(`\u2502 Total namespaces: ${String(t.summary.namespaces.length).padStart(6)} \u2502`),console.log(`\u2502 Total concerns: ${String(t.summary.concerns.length).padStart(6)} \u2502`),console.log("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518");let e=t.routes.errors.length+t.controllers.errors.length+t.models.errors.length+t.grpc.errors.length;e>0?console.log(`
34
- \u26A0\uFE0F Total errors: ${e}`):console.log(`
35
- \u2705 Analysis completed without errors!`);}var Je=import.meta.url===`file://${process.argv[1]}`;Je&&qe().catch(console.error);
36
- export{ne as a,oe as b,N as c,R as d,k as e,V as f,j as g,T as h,K as i,Q as j,He as k};
33
+ `),console.log("\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510"),console.log("\u2502 Routes \u2502"),console.log("\u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524"),console.log(`\u2502 Total routes: ${String(e.summary.totalRoutes).padStart(6)} \u2502`),console.log(`\u2502 Resources: ${String(e.routes.resources.length).padStart(6)} \u2502`),console.log(`\u2502 Mounted engines: ${String(e.routes.mountedEngines.length).padStart(6)} \u2502`),console.log(`\u2502 External files: ${String(e.routes.drawnFiles.length).padStart(6)} \u2502`),console.log("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518"),console.log("\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510"),console.log("\u2502 Controllers \u2502"),console.log("\u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524"),console.log(`\u2502 Total controllers: ${String(e.summary.totalControllers).padStart(6)} \u2502`),console.log(`\u2502 Total actions: ${String(e.summary.totalActions).padStart(6)} \u2502`),console.log(`\u2502 Namespaces: ${String(e.controllers.namespaces.length).padStart(6)} \u2502`),console.log("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518"),console.log("\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510"),console.log("\u2502 Models \u2502"),console.log("\u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524"),console.log(`\u2502 Total models: ${String(e.summary.totalModels).padStart(6)} \u2502`),console.log(`\u2502 Associations: ${String(e.summary.totalAssociations).padStart(6)} \u2502`),console.log(`\u2502 Validations: ${String(e.summary.totalValidations).padStart(6)} \u2502`),console.log("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518"),console.log("\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510"),console.log("\u2502 gRPC Services \u2502"),console.log("\u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524"),console.log(`\u2502 Total services: ${String(e.summary.totalGrpcServices).padStart(6)} \u2502`),console.log(`\u2502 Total RPCs: ${String(e.summary.totalRpcs).padStart(6)} \u2502`),console.log("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518"),console.log("\u250C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510"),console.log("\u2502 Shared \u2502"),console.log("\u251C\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2524"),console.log(`\u2502 Total namespaces: ${String(e.summary.namespaces.length).padStart(6)} \u2502`),console.log(`\u2502 Total concerns: ${String(e.summary.concerns.length).padStart(6)} \u2502`),console.log("\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518");let t=e.routes.errors.length+e.controllers.errors.length+e.models.errors.length+e.grpc.errors.length;t>0?console.log(`
34
+ \u26A0\uFE0F Total errors: ${t}`):console.log(`
35
+ \u2705 Analysis completed without errors!`);}var Ke=import.meta.url===`file://${process.argv[1]}`;Ke&&Je().catch(console.error);
36
+ export{se as a,ne as b,N as c,R as d,k as e,V as f,j as g,T as h,K as i,Q as j,qe as k};
package/dist/cli.js CHANGED
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env node
2
- import {a,b}from'./chunk-4K4MGTPV.js';import'./chunk-SL2GMDBN.js';import'./chunk-VV3A3UE3.js';import'./chunk-J2CM7T7U.js';import'./chunk-XWZH2RDG.js';import'./chunk-MOEA75XK.js';import'./chunk-UJT5KTVK.js';import {Command}from'commander';import n from'chalk';import*as p from'path';import*as s from'fs/promises';var d=new Command;d.name("repomap").description("Interactive documentation generator for code repositories").version("0.1.0");async function $(e){let o=p.basename(e),a=false,t=p.join(e,"Gemfile"),c=p.join(e,"config","routes.rb");try{await s.access(t),await s.access(c);let u=await s.readFile(t,"utf-8");a=u.includes("gem 'rails'")||u.includes('gem "rails"');}catch{}let r=p.join(e,"package.json"),i=false,l=false,m={};try{let u=JSON.parse(await s.readFile(r,"utf-8")),w={...u.dependencies,...u.devDependencies};i=!!w.react,l=!!w.next;let f=["src/pages","pages","app","src/app","frontend/src"];for(let g of f)try{await s.access(p.join(e,g)),m.pagesDir=g;break}catch{}let b=["src/features","features","src/modules","modules","frontend/src"];for(let g of b)try{await s.access(p.join(e,g)),m.featuresDir=g;break}catch{}let D=["src/components","components","src/common/components","frontend/src"];for(let g of D)try{await s.access(p.join(e,g)),m.componentsDir=g;break}catch{}}catch{}let h=[];(i||l)&&h.push("pages","graphql","dataflow","rest-api");let y="generic";return l?y="nextjs":a&&(y="rails"),!a&&!i&&!l?null:{name:o,displayName:o,description:a&&i?"Rails + React application":a?"Rails application":"",path:e,branch:"main",type:y,analyzers:h,settings:m}}async function x(e){let o=await $(e);if(!o)throw new Error("Could not detect project. Please create a repomap.config.ts file or run 'repomap init'.");return {outputDir:"./.repomap",site:{title:`${o.displayName} Documentation`,description:"Auto-generated documentation",baseUrl:"/docs"},repositories:[o],analysis:{include:["**/*.tsx","**/*.ts"],exclude:["**/node_modules/**","**/__tests__/**","**/*.test.*","**/*.spec.*","**/dist/**","**/.next/**"],maxDepth:5},diagrams:{enabled:true,types:["flowchart","sequence"],theme:"default"},watch:{enabled:false,debounce:1e3},integrations:{github:{enabled:false,organization:""},slack:{enabled:false}}}}async function P(e,o){let a=e?[e]:["repomap.config.ts","repomap.config.js","repomap.config.mjs"];for(let t of a){let c=p.resolve(o,t);try{await s.access(c),console.log(n.gray(`Loading config from: ${c}`));let r=await import(c);return r.config||r.default}catch{}}return console.log(n.gray("No config file found, auto-detecting project...")),x(o)}d.command("generate").description("Generate documentation from source code").option("-c, --config <path>","Path to config file").option("-o, --output <path>","Output directory").option("--repo <name>","Analyze specific repository only").option("--watch","Watch for changes and regenerate").option("--no-cache","Disable caching (always analyze from scratch)").option("--format <type>","Output format: json, html, markdown (default: all)","all").option("--ci","CI mode: minimal output, exit codes for errors").option("--static","Generate standalone HTML files (for GitHub Pages)").action(async e=>{let o=e.ci||process.env.CI==="true";o||console.log(n.blue.bold(`
2
+ import {a,b}from'./chunk-53ANJE42.js';import'./chunk-H4YGP3GL.js';import'./chunk-VV3A3UE3.js';import'./chunk-J2CM7T7U.js';import'./chunk-XWZH2RDG.js';import'./chunk-MOEA75XK.js';import'./chunk-PTR5IROV.js';import {Command}from'commander';import n from'chalk';import*as p from'path';import*as s from'fs/promises';var d=new Command;d.name("repomap").description("Interactive documentation generator for code repositories").version("0.1.0");async function $(e){let o=p.basename(e),a=false,t=p.join(e,"Gemfile"),c=p.join(e,"config","routes.rb");try{await s.access(t),await s.access(c);let u=await s.readFile(t,"utf-8");a=u.includes("gem 'rails'")||u.includes('gem "rails"');}catch{}let r=p.join(e,"package.json"),i=false,l=false,m={};try{let u=JSON.parse(await s.readFile(r,"utf-8")),w={...u.dependencies,...u.devDependencies};i=!!w.react,l=!!w.next;let f=["src/pages","pages","app","src/app","frontend/src"];for(let g of f)try{await s.access(p.join(e,g)),m.pagesDir=g;break}catch{}let b=["src/features","features","src/modules","modules","frontend/src"];for(let g of b)try{await s.access(p.join(e,g)),m.featuresDir=g;break}catch{}let D=["src/components","components","src/common/components","frontend/src"];for(let g of D)try{await s.access(p.join(e,g)),m.componentsDir=g;break}catch{}}catch{}let h=[];(i||l)&&h.push("pages","graphql","dataflow","rest-api");let y="generic";return l?y="nextjs":a&&(y="rails"),!a&&!i&&!l?null:{name:o,displayName:o,description:a&&i?"Rails + React application":a?"Rails application":"",path:e,branch:"main",type:y,analyzers:h,settings:m}}async function x(e){let o=await $(e);if(!o)throw new Error("Could not detect project. Please create a repomap.config.ts file or run 'repomap init'.");return {outputDir:"./.repomap",site:{title:`${o.displayName} Documentation`,description:"Auto-generated documentation",baseUrl:"/docs"},repositories:[o],analysis:{include:["**/*.tsx","**/*.ts"],exclude:["**/node_modules/**","**/__tests__/**","**/*.test.*","**/*.spec.*","**/dist/**","**/.next/**"],maxDepth:5},diagrams:{enabled:true,types:["flowchart","sequence"],theme:"default"},watch:{enabled:false,debounce:1e3},integrations:{github:{enabled:false,organization:""},slack:{enabled:false}}}}async function P(e,o){let a=e?[e]:["repomap.config.ts","repomap.config.js","repomap.config.mjs"];for(let t of a){let c=p.resolve(o,t);try{await s.access(c),console.log(n.gray(`Loading config from: ${c}`));let r=await import(c);return r.config||r.default}catch{}}return console.log(n.gray("No config file found, auto-detecting project...")),x(o)}d.command("generate").description("Generate documentation from source code").option("-c, --config <path>","Path to config file").option("-o, --output <path>","Output directory").option("--repo <name>","Analyze specific repository only").option("--watch","Watch for changes and regenerate").option("--no-cache","Disable caching (always analyze from scratch)").option("--format <type>","Output format: json, html, markdown (default: all)","all").option("--ci","CI mode: minimal output, exit codes for errors").option("--static","Generate standalone HTML files (for GitHub Pages)").action(async e=>{let o=e.ci||process.env.CI==="true";o||console.log(n.blue.bold(`
3
3
  \u{1F4DA} Repomap - Documentation Generator
4
4
  `));try{let a$1=process.cwd(),t=await P(e.config,a$1);e.output&&(t.outputDir=e.output),e.repo&&(t.repositories=t.repositories.filter(r=>r.name===e.repo),t.repositories.length===0&&(console.error(n.red(`Repository "${e.repo}" not found in config`)),process.exit(1)));let c=new a(t,{noCache:!e.cache});if(e.watch)console.log(n.yellow(`
5
5
  \u{1F440} Watch mode enabled. Press Ctrl+C to stop.
6
6
  `)),await C(c,t);else {let r=await c.generate();if(e.format==="json"||e.static){let i=p.join(t.outputDir,"report.json");await s.mkdir(t.outputDir,{recursive:!0}),await s.writeFile(i,JSON.stringify(r,null,2)),o||console.log(n.green(`\u{1F4C4} JSON report: ${i}`));}if(e.static&&await G(t,r,o),!o)N(r);else {let i=r.repositories.reduce((l,m)=>l+m.summary.totalPages,0);console.log(`\u2705 Generated: ${i} pages, ${r.repositories.length} repos`);}}}catch(a){console.error(o?`Error: ${a.message}`:n.red(`
7
- \u274C Error:`),a.message),process.exit(1);}});async function G(e,o,a){let{PageMapGenerator:t}=await import('./page-map-generator-XNZ4TDJT.js'),{detectEnvironments:c}=await import('./env-detector-BIWJ7OYF.js'),r=e.outputDir;await s.mkdir(r,{recursive:true});let i=e.repositories[0]?.path||process.cwd(),l=await c(i),m=null;if(l.hasRails){let{analyzeRailsApp:f}=await import('./rails-TJCDGBBF.js');m=await f(i);}let y=new t().generatePageMapHtml(o,{envResult:l,railsAnalysis:m,staticMode:true});if(await s.writeFile(p.join(r,"index.html"),y),a||console.log(n.green(`\u{1F4C4} Static page map: ${p.join(r,"index.html")}`)),m){let{RailsMapGenerator:f}=await import('./rails-map-generator-JL5PKHYP.js'),D=new f().generateFromResult(m);await s.writeFile(p.join(r,"rails-map.html"),D),a||console.log(n.green(`\u{1F4C4} Static Rails map: ${p.join(r,"rails-map.html")}`));}let u=["common.css","page-map.css","docs.css","rails-map.css"],w=p.join(r,"assets");await s.mkdir(w,{recursive:true});for(let f of u)try{let b=new URL(`./generators/assets/${f}`,import.meta.url),D=await s.readFile(b,"utf-8");await s.writeFile(p.join(w,f),D);}catch{}a||(console.log(n.green(`
7
+ \u274C Error:`),a.message),process.exit(1);}});async function G(e,o,a){let{PageMapGenerator:t}=await import('./page-map-generator-XNZ4TDJT.js'),{detectEnvironments:c}=await import('./env-detector-BIWJ7OYF.js'),r=e.outputDir;await s.mkdir(r,{recursive:true});let i=e.repositories[0]?.path||process.cwd(),l=await c(i),m=null;if(l.hasRails){let{analyzeRailsApp:f}=await import('./rails-FFISZ4AE.js');m=await f(i);}let y=new t().generatePageMapHtml(o,{envResult:l,railsAnalysis:m,staticMode:true});if(await s.writeFile(p.join(r,"index.html"),y),a||console.log(n.green(`\u{1F4C4} Static page map: ${p.join(r,"index.html")}`)),m){let{RailsMapGenerator:f}=await import('./rails-map-generator-UFLCMFAT.js'),D=new f().generateFromResult(m);await s.writeFile(p.join(r,"rails-map.html"),D),a||console.log(n.green(`\u{1F4C4} Static Rails map: ${p.join(r,"rails-map.html")}`));}let u=["common.css","page-map.css","docs.css","rails-map.css"],w=p.join(r,"assets");await s.mkdir(w,{recursive:true});for(let f of u)try{let b=new URL(`./generators/assets/${f}`,import.meta.url),D=await s.readFile(b,"utf-8");await s.writeFile(p.join(w,f),D);}catch{}a||(console.log(n.green(`
8
8
  \u2705 Static site generated in: ${r}`)),console.log(n.gray(" Deploy to GitHub Pages or any static hosting")));}d.command("serve").description("Start local documentation server with live reload").option("-c, --config <path>","Path to config file").option("--path <path>","Path to repository to analyze (auto-detect if no config)").option("-p, --port <number>","Server port","3030").option("--no-open","Don't open browser automatically").option("--no-cache","Disable caching (always analyze from scratch)").action(async e=>{console.log(n.blue.bold(`
9
9
  \u{1F310} Repomap - Documentation Server
10
10
  `));try{let o=e.path||process.cwd(),a=await P(e.config,o);await new b(a,parseInt(e.port),{noCache:!e.cache}).start(!e.open);}catch(o){console.error(n.red(`
@@ -68,7 +68,7 @@ export default config;
68
68
  `;await s.writeFile(o,h,"utf-8"),console.log(n.green(`\u2705 Created ${o}`)),console.log(n.gray(`
69
69
  Run 'npx repomap serve' to start the documentation server.`));}catch(a){console.error(n.red("Failed to create config:"),a.message);}});d.command("rails").description("Analyze a Rails application and generate interactive map").option("--path <path>","Path to Rails application").option("-o, --output <path>","Output HTML file path").action(async e=>{console.log(n.blue.bold(`
70
70
  \u{1F6E4}\uFE0F Repomap - Rails Analyzer
71
- `));try{let o=e.path||process.cwd();try{await s.access(p.join(o,"config","routes.rb"));}catch{console.error(n.red("Not a Rails project (config/routes.rb not found)")),process.exit(1);}let{RailsMapGenerator:a}=await import('./rails-map-generator-JL5PKHYP.js'),t=e.output||p.join(o,"rails-map.html");await new a(o).generate({title:`${p.basename(o)} - Rails Map`,outputPath:t}),console.log(n.green(`
71
+ `));try{let o=e.path||process.cwd();try{await s.access(p.join(o,"config","routes.rb"));}catch{console.error(n.red("Not a Rails project (config/routes.rb not found)")),process.exit(1);}let{RailsMapGenerator:a}=await import('./rails-map-generator-UFLCMFAT.js'),t=e.output||p.join(o,"rails-map.html");await new a(o).generate({title:`${p.basename(o)} - Rails Map`,outputPath:t}),console.log(n.green(`
72
72
  \u2705 Rails map generated: ${t}`));let{exec:r}=await import('child_process');r(`open "${t}"`);}catch(o){console.error(n.red(`
73
73
  \u274C Error:`),o.message),process.exit(1);}});d.command("diff").description("Show documentation changes since last generation").option("-c, --config <path>","Path to config file").action(async e=>{console.log(n.blue.bold(`
74
74
  \u{1F4CA} Documentation Diff
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import'./chunk-6F4PWJZI.js';export{a as DocGeneratorEngine,b as DocServer}from'./chunk-4K4MGTPV.js';import'./chunk-SL2GMDBN.js';import'./chunk-VV3A3UE3.js';export{a as BaseAnalyzer,d as DataFlowAnalyzer,c as GraphQLAnalyzer,b as PagesAnalyzer}from'./chunk-J2CM7T7U.js';export{b as MarkdownGenerator,a as MermaidGenerator}from'./chunk-XWZH2RDG.js';export{a as PageMapGenerator}from'./chunk-MOEA75XK.js';import'./chunk-UJT5KTVK.js';
1
+ import'./chunk-6F4PWJZI.js';export{a as DocGeneratorEngine,b as DocServer}from'./chunk-53ANJE42.js';import'./chunk-H4YGP3GL.js';import'./chunk-VV3A3UE3.js';export{a as BaseAnalyzer,d as DataFlowAnalyzer,c as GraphQLAnalyzer,b as PagesAnalyzer}from'./chunk-J2CM7T7U.js';export{b as MarkdownGenerator,a as MermaidGenerator}from'./chunk-XWZH2RDG.js';export{a as PageMapGenerator}from'./chunk-MOEA75XK.js';import'./chunk-PTR5IROV.js';
@@ -1 +1 @@
1
- export{f as RailsControllerAnalyzer,h as RailsGrpcAnalyzer,g as RailsModelAnalyzer,e as RailsRoutesAnalyzer,k as analyzeRailsApp,i as analyzeRailsViews,j as analyzeReactComponents,d as findNodes,a as initRubyParser,b as parseRuby,c as parseRubyFile}from'./chunk-UJT5KTVK.js';
1
+ export{f as RailsControllerAnalyzer,h as RailsGrpcAnalyzer,g as RailsModelAnalyzer,e as RailsRoutesAnalyzer,k as analyzeRailsApp,i as analyzeRailsViews,j as analyzeReactComponents,d as findNodes,a as initRubyParser,b as parseRuby,c as parseRubyFile}from'./chunk-PTR5IROV.js';
@@ -0,0 +1 @@
1
+ export{a as RailsMapGenerator}from'./chunk-H4YGP3GL.js';import'./chunk-PTR5IROV.js';
@@ -1 +1 @@
1
- export{b as DocServer}from'../chunk-4K4MGTPV.js';import'../chunk-SL2GMDBN.js';import'../chunk-VV3A3UE3.js';import'../chunk-J2CM7T7U.js';import'../chunk-XWZH2RDG.js';import'../chunk-MOEA75XK.js';import'../chunk-UJT5KTVK.js';
1
+ export{b as DocServer}from'../chunk-53ANJE42.js';import'../chunk-H4YGP3GL.js';import'../chunk-VV3A3UE3.js';import'../chunk-J2CM7T7U.js';import'../chunk-XWZH2RDG.js';import'../chunk-MOEA75XK.js';import'../chunk-PTR5IROV.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wtdlee/repomap",
3
- "version": "0.3.2",
3
+ "version": "0.3.3",
4
4
  "description": "Interactive documentation generator for code repositories - visualize pages, components, GraphQL operations, and data flows",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -1 +0,0 @@
1
- export{a as RailsMapGenerator}from'./chunk-SL2GMDBN.js';import'./chunk-UJT5KTVK.js';