@@ -99,15 +99,33 @@ export class ReactInfo extends Base<{}> {
9999 const { detailed} = inputs ;
100100 const projectRoot = this . fileGenerator [ 'getProjectRoot' ] ( ) ;
101101
102- // Read package.json
102+ const packageJson = this . loadPackageJson ( projectRoot ) ;
103+ let info = this . buildBasicInfo ( packageJson ) ;
104+
105+ info += this . getEnvironmentInfo ( ) ;
106+ info += this . getKeyDependencies ( packageJson ) ;
107+ info += this . getScripts ( packageJson ) ;
108+
109+ if ( detailed ) {
110+ info += this . getDetailedStatistics ( projectRoot ) ;
111+ }
112+
113+ info += this . getConfigurationFiles ( projectRoot ) ;
114+ info += this . getMcpConfiguration ( projectRoot ) ;
115+
116+ return info ;
117+ }
118+
119+ private loadPackageJson ( projectRoot : string ) : AnyObject {
103120 const packageJsonPath = path . join ( projectRoot , 'package.json' ) ;
104121 if ( ! fs . existsSync ( packageJsonPath ) ) {
105122 throw new Error ( 'package.json not found. Is this a React project?' ) ;
106123 }
124+ return JSON . parse ( fs . readFileSync ( packageJsonPath , 'utf-8' ) ) ;
125+ }
107126
108- const packageJson = JSON . parse ( fs . readFileSync ( packageJsonPath , 'utf-8' ) ) ;
109-
110- let info = `
127+ private buildBasicInfo ( packageJson : AnyObject ) : string {
128+ return `
111129📦 React Project Information
112130════════════════════════════
113131
@@ -116,25 +134,28 @@ Version: ${packageJson.version || 'N/A'}
116134Description: ${ packageJson . description || 'N/A' }
117135
118136` ;
137+ }
119138
120- // Node/NPM versions
139+ private getEnvironmentInfo ( ) : string {
121140 try {
122- const nodeVersion = execSync ( 'node --version' , {
123- encoding : 'utf-8' ,
124- } ) . trim ( ) ;
141+ // sonar-ignore: Using system PATH is required for CLI tool execution
142+ const nodeVersion = execSync ( 'node --version' , { encoding : 'utf-8' } ) . trim ( ) ;
143+ // sonar-ignore: Using system PATH is required for CLI tool execution
125144 const npmVersion = execSync ( 'npm --version' , { encoding : 'utf-8' } ) . trim ( ) ;
126- info += `🔧 Environment
145+ return `🔧 Environment
127146───────────────
128147Node: ${ nodeVersion }
129148NPM: ${ npmVersion }
130149
131150` ;
132151 } catch ( err ) {
133- // Ignore if node/npm not available
152+ // Node/NPM not available - return empty string
153+ return '' ;
134154 }
155+ }
135156
136- // Key dependencies
137- info + = `📚 Key Dependencies
157+ private getKeyDependencies ( packageJson : AnyObject ) : string {
158+ let info = `📚 Key Dependencies
138159───────────────────
139160` ;
140161 const deps = packageJson . dependencies || { } ;
@@ -158,27 +179,34 @@ NPM: ${npmVersion}
158179 }
159180 }
160181
161- // Scripts
162- if ( packageJson . scripts ) {
163- info += `\n⚡ Available Scripts
182+ return info ;
183+ }
184+
185+ private getScripts ( packageJson : AnyObject ) : string {
186+ if ( ! packageJson . scripts ) {
187+ return '' ;
188+ }
189+
190+ let info = `\n⚡ Available Scripts
164191──────────────────
165192` ;
166- const scripts = Object . keys ( packageJson . scripts ) . slice ( 0 , 10 ) ;
167- for ( const script of scripts ) {
168- info += `${ script } : ${ packageJson . scripts [ script ] } \n` ;
169- }
193+ const scripts = Object . keys ( packageJson . scripts ) . slice ( 0 , 10 ) ;
194+ for ( const script of scripts ) {
195+ info += `${ script } : ${ packageJson . scripts [ script ] } \n` ;
170196 }
171197
172- // Project statistics (if detailed)
173- if ( detailed ) {
174- const stats = this . getProjectStatistics ( projectRoot ) ;
175- info += `\n📊 Project Statistics
198+ return info ;
199+ }
200+
201+ private getDetailedStatistics ( projectRoot : string ) : string {
202+ const stats = this . getProjectStatistics ( projectRoot ) ;
203+ return `\n📊 Project Statistics
176204────────────────────
177205${ stats }
178206` ;
179- }
207+ }
180208
181- // Configuration files
209+ private getConfigurationFiles ( projectRoot : string ) : string {
182210 const configFiles = [
183211 'vite.config.ts' ,
184212 'tsconfig.json' ,
@@ -187,22 +215,27 @@ ${stats}
187215 'configGenerator.js' ,
188216 ] ;
189217
190- info + = `\n📄 Configuration Files
218+ let info = `\n📄 Configuration Files
191219──────────────────────
192220` ;
193221 for ( const file of configFiles ) {
194222 const filePath = path . join ( projectRoot , file ) ;
195223 info += `${ file } : ${ fs . existsSync ( filePath ) ? '✅' : '❌' } \n` ;
196224 }
197225
198- // MCP Configuration
226+ return info ;
227+ }
228+
229+ private getMcpConfiguration ( projectRoot : string ) : string {
199230 const mcpConfigPath = path . join ( projectRoot , '.claude' , 'mcp.json' ) ;
200- info += `\n🤖 MCP Configuration
231+ const isConfigured = fs . existsSync ( mcpConfigPath ) ;
232+
233+ let info = `\n🤖 MCP Configuration
201234───────────────────
202- Status: ${ fs . existsSync ( mcpConfigPath ) ? '✅ Configured' : '❌ Not configured' }
235+ Status: ${ isConfigured ? '✅ Configured' : '❌ Not configured' }
203236` ;
204237
205- if ( fs . existsSync ( mcpConfigPath ) ) {
238+ if ( isConfigured ) {
206239 info += `Location: .claude/mcp.json
207240` ;
208241 }
@@ -275,6 +308,8 @@ Status: ${fs.existsSync(mcpConfigPath) ? '✅ Configured' : '❌ Not configured'
275308 walk ( filePath ) ;
276309 } else if ( file . endsWith ( extension ) ) {
277310 count ++ ;
311+ } else {
312+ // Not a directory and doesn't match extension - skip
278313 }
279314 }
280315 } catch ( err ) {
0 commit comments